]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
c74dfdfce0818dde2d0d95801958a199b139a605
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualPaint / ManualPaintModel.cpp
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "ManualPaintModel.h"
27
28 ManualPaintModel::ManualPaintModel() 
29 {
30         _active                                 = true;
31         _tool                                   = 0; // 0 pencil         ,   1 fill
32         _brushfilter                    = new BrushFilter();
33         _fillfilter                     = new FillFilter();
34         _imageUndoRedo                  = new ImageUndoRedo();
35 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
36 //      _imageUndoRedo_visited  = new ImageUndoRedo();
37 }
38
39 //---------------------------------------------------------------------------
40 ManualPaintModel::~ManualPaintModel() 
41 {
42         delete _brushfilter;
43         delete _fillfilter;
44 }
45
46
47 //---------------------------------------------------------------------------
48 void ManualPaintModel::SetActive( bool active )
49 {
50   _active = active;
51 }
52
53 //---------------------------------------------------------------------------
54 void ManualPaintModel::PaintImage(int px, int py, int pz) 
55 {
56   if (_active==true)
57   {
58         if (_tool == 0) 
59         {
60                 _brushfilter->SetPoint(px, py, pz);
61                 _brushfilter->Run();
62         } // _tool 2
63         if (_tool == 1) 
64         {
65                 _fillfilter->SetPoint(px, py, pz);
66                 _fillfilter->Run(px,py,pz);
67         } // _tool 1
68   } // _active
69 }
70
71 //---------------------------------------------------------------------------
72 void ManualPaintModel::SetTool(int tool) 
73 {
74         _tool = tool;
75 }
76
77 //---------------------------------------------------------------------------
78 void ManualPaintModel::Set2D3D(int dim2D3D) 
79 {
80         _brushfilter -> Set2D3D(dim2D3D);
81         _fillfilter  -> Set2D3D(dim2D3D);
82 }
83
84 //---------------------------------------------------------------------------
85 void ManualPaintModel::SetImages(vtkImageData *image,vtkImageData *image2) 
86 {
87 printf("EED ManualPaintModel::SetImage Start\n ");
88         if (image!=NULL)
89         {
90 printf("EED ManualPaintModel::SetImage 1\n ");
91                 _brushfilter -> SetImages(image,image2);
92 printf("EED ManualPaintModel::SetImage 2\n ");
93                 _fillfilter  -> SetImages(image,image2);
94 printf("EED ManualPaintModel::SetImage 3\n ");
95                 if (image2!=NULL)
96                 {
97                         _imageUndoRedo->SetImage(image2);
98 printf("EED ManualPaintModel::SetImage 4\n ");
99                 } else {
100                         _imageUndoRedo->SetImage(image);
101 printf("EED ManualPaintModel::SetImage 5\n ");
102                 }
103 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
104 //              _imageUndoRedo_visited->SetImage( _fillfilter->GetAuxImageFill() );
105         } else {
106                 printf("EED Warning image=NULL in ManualPaintModel::SetImages(image,image2)\n ");
107         }
108 printf("EED ManualPaintModel::SetImage End\n ");
109 }
110
111 //---------------------------------------------------------------------------
112 void ManualPaintModel::SetGrayLevel(double graylevel) 
113 {
114         _brushfilter->SetGrayLevel(graylevel);
115         _fillfilter->SetGrayLevel(graylevel);
116 }
117
118 //---------------------------------------------------------------------------
119 void ManualPaintModel::SetRangeMin(int min) 
120 {
121         _brushfilter->SetRangeMin(min);
122         _fillfilter->SetRangeMin(min);
123 }
124
125 //---------------------------------------------------------------------------
126 void ManualPaintModel::SetRangeMax(int max) 
127 {
128         _brushfilter->SetRangeMax(max);
129         _fillfilter->SetRangeMax(max);
130 }
131
132 //---------------------------------------------------------------------------
133 void ManualPaintModel::SetDirection(int direction) 
134 {
135         _brushfilter->SetDirection(direction);
136         _fillfilter->SetDirection(direction);
137 }
138
139 //---------------------------------------------------------------------------
140 void ManualPaintModel::SetBrushSize(int brushsize) 
141 {
142         _brushfilter->SetBrushSize(brushsize);
143 }
144
145 //---------------------------------------------------------------------------
146 void ManualPaintModel::SetBrushForm(int brushform) 
147 {
148         _brushfilter->SetBrushForm(brushform);
149 }
150
151 //--------------------C:\Eduardo\Creatis\C11\ct\cs\creaMaracasVisu-------------------------------------------------------
152 void ManualPaintModel::SetToleranceFill(double tolerancefill) 
153 {
154         _fillfilter->SetToleranceFill(tolerancefill);
155 }
156
157 //---------------------------------------------------------------------------
158 void ManualPaintModel::SetDistanceFill(int distancefill) 
159 {
160         _fillfilter->SetDistanceFill(distancefill);
161 }
162
163 //---------------------------------------------------------------------------
164 void ManualPaintModel::GetScalarRange(double * range) 
165 {
166         _fillfilter->GetScalarRange(range);
167 }
168
169 //---------------------------------------------------------------------------
170 void ManualPaintModel::SetUndoImage() 
171 {
172         ImageMManager* imMManager = NULL;
173         if (_tool == 0) 
174         {
175                 imMManager = this->_brushfilter->GetImageMManager();
176         } // if 0
177         if (_tool == 1) 
178         {
179                 imMManager = this->_fillfilter->GetImageMManager();
180         } // if 1
181         this->_imageUndoRedo                    -> SetURImages(imMManager);
182 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
183 //      this->_imageUndoRedo_visited    -> SetURImages(imMManager);
184         this->_brushfilter                              -> CleanImageMManager();
185         this->_fillfilter                               -> CleanImageMManager();
186 }
187 //---------------------------------------------------------------------------
188
189 void ManualPaintModel::Undo() 
190 {
191         this->_imageUndoRedo->Undo();
192 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
193 //      this->_imageUndoRedo_visited->Undo();
194 }
195
196 void ManualPaintModel::Redo() 
197 {
198         this->_imageUndoRedo->Redo();
199 //EED 2020-04-28  BORRAME Change to local variables to use with openmp
200 //      this->_imageUndoRedo_visited->Redo();
201 }
202
203
204 int ManualPaintModel::GetRestorBaseInitialPointX() 
205 {
206         return  this->_imageUndoRedo->GetRestorBaseInitialPointX();
207 }
208
209 int ManualPaintModel::GetRestorBaseInitialPointY() 
210 {
211         return  this->_imageUndoRedo->GetRestorBaseInitialPointY();
212 }
213
214 int ManualPaintModel::GetRestorBaseInitialPointZ() 
215 {
216         return  this->_imageUndoRedo->GetRestorBaseInitialPointZ();
217 }
218
219 void ManualPaintModel::Copy_GeneralAuxFill_to_Results()
220 {
221         if (_tool == 0) 
222         {
223                 //
224         } // if 0
225         if (_tool == 1)   // fillfilter
226         {
227                 this->_fillfilter->Copy_GeneralAuxFill_to_Results();
228         } // if 1
229 }
230