]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
6414f887227c789aa2de213d1f1a6abd6ddb9c0a
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualPaint / ManualPaintModel.cpp
1 #include "ManualPaintModel.h"
2
3 ManualPaintModel::ManualPaintModel() {
4         _tool = 0; // 0 pencil         ,   1 fill
5         _brushfilter = new BrushFilter();
6         _fillfilter = new FillFilter();
7         _imageUndoRedo = new ImageUndoRedo();
8 }
9
10 //---------------------------------------------------------------------------
11 ManualPaintModel::~ManualPaintModel() {
12         delete _brushfilter;
13         delete _fillfilter;
14 }
15
16 //---------------------------------------------------------------------------
17 void ManualPaintModel::PaintImage(int px, int py, int pz) {
18         if (_tool == 0) {
19                 _brushfilter->SetPoint(px, py, pz);
20                 _brushfilter->Run();
21         }
22         if (_tool == 1) {
23                 _fillfilter->SetPoint(px, py, pz);
24                 _fillfilter->Run();
25         }
26 }
27
28 //---------------------------------------------------------------------------
29 void ManualPaintModel::SetTool(int tool) {
30         _tool = tool;
31 }
32
33 //---------------------------------------------------------------------------
34 void ManualPaintModel::Set2D3D(int dim2D3D) {
35         _brushfilter->Set2D3D(dim2D3D);
36         _fillfilter->Set2D3D(dim2D3D);
37 }
38
39 //---------------------------------------------------------------------------
40 void ManualPaintModel::SetImage(vtkImageData *image) {
41         _brushfilter->SetImage(image);
42         _fillfilter->SetImage(image);
43         _imageUndoRedo->SetImage(image);
44 }
45
46 //---------------------------------------------------------------------------
47 void ManualPaintModel::SetGrayLevel(double graylevel) {
48         _brushfilter->SetGrayLevel(graylevel);
49         _fillfilter->SetGrayLevel(graylevel);
50 }
51
52 //---------------------------------------------------------------------------
53 void ManualPaintModel::SetRangeMin(int min) {
54         _brushfilter->SetRangeMin(min);
55         _fillfilter->SetRangeMin(min);
56 }
57
58 //---------------------------------------------------------------------------
59 void ManualPaintModel::SetRangeMax(int max) {
60         _brushfilter->SetRangeMax(max);
61         _fillfilter->SetRangeMax(max);
62 }
63
64 //---------------------------------------------------------------------------
65 void ManualPaintModel::SetDirection(int direction) {
66         _brushfilter->SetDirection(direction);
67         _fillfilter->SetDirection(direction);
68 }
69
70 //---------------------------------------------------------------------------
71 void ManualPaintModel::SetBrushSize(int brushsize) {
72         _brushfilter->SetBrushSize(brushsize);
73 }
74
75 //---------------------------------------------------------------------------
76 void ManualPaintModel::SetBrushForm(int brushform) {
77         _brushfilter->SetBrushForm(brushform);
78 }
79
80 //---------------------------------------------------------------------------
81 void ManualPaintModel::SetToleranceFill(double tolerancefill) {
82         _fillfilter->SetToleranceFill(tolerancefill);
83 }
84
85 //---------------------------------------------------------------------------
86 void ManualPaintModel::SetDistanceFill(int distancefill) {
87         _fillfilter->SetDistanceFill(distancefill);
88 }
89 //---------------------------------------------------------------------------
90 void ManualPaintModel::GetScalarRange(double * range) {
91         _fillfilter->GetScalarRange(range);
92 }
93 //---------------------------------------------------------------------------
94 void ManualPaintModel::SetUndoImage() {
95         ImageMManager* imMManager = NULL;
96         if (_tool == 0) {
97                 imMManager = this->_brushfilter->GetImageMManager();
98         }
99         if (_tool == 1) {
100                 imMManager = this->_fillfilter->GetImageMManager();
101         }
102         this->_imageUndoRedo->SetUndoImage(imMManager);
103         this->_brushfilter->CleanImageMManager();
104         this->_fillfilter->CleanImageMManager();
105 }
106 //---------------------------------------------------------------------------
107
108 void ManualPaintModel::Undo() {
109         this->_imageUndoRedo->Undo();
110 }
111
112 void ManualPaintModel::Redo() {
113         this->_imageUndoRedo->Redo();
114 }