]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp
ac69465260736205c291c5a5c9ad1b8fead13e72
[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         _active         = true;
30         _tool           = 0; // 0 pencil         ,   1 fill
31         _brushfilter    = new BrushFilter();
32         _fillfilter     = new FillFilter();
33         _imageUndoRedo  = new ImageUndoRedo();
34 }
35
36 //---------------------------------------------------------------------------
37 ManualPaintModel::~ManualPaintModel() 
38 {
39         delete _brushfilter;
40         delete _fillfilter;
41 }
42
43
44 //---------------------------------------------------------------------------
45 void ManualPaintModel::SetActive( bool active )
46 {
47   _active = active;
48 }
49
50 //---------------------------------------------------------------------------
51 void ManualPaintModel::PaintImage(int px, int py, int pz) 
52 {
53 printf("EED   ManualPaintModel::PaintImage\n");
54   if (_active==true)
55   {
56
57         if (_tool == 0) 
58         {
59                 _brushfilter->SetPoint(px, py, pz);
60                 _brushfilter->Run();
61         } // _tool 2
62
63         if (_tool == 1) 
64         {
65                 _fillfilter->SetPoint(px, py, pz);
66                 _fillfilter->Run();
67         } // _tool 1
68   } // _active
69 }
70
71 //---------------------------------------------------------------------------
72 void ManualPaintModel::SetTool(int tool) {
73         _tool = tool;
74 }
75
76 //---------------------------------------------------------------------------
77 void ManualPaintModel::Set2D3D(int dim2D3D) {
78         _brushfilter->Set2D3D(dim2D3D);
79         _fillfilter->Set2D3D(dim2D3D);
80 }
81
82 //---------------------------------------------------------------------------
83 void ManualPaintModel::SetImage(vtkImageData *image) {
84         _brushfilter->SetImage(image);
85         _fillfilter->SetImage(image);
86         _imageUndoRedo->SetImage(image);
87 }
88
89 //---------------------------------------------------------------------------
90 void ManualPaintModel::SetGrayLevel(double graylevel) {
91         _brushfilter->SetGrayLevel(graylevel);
92         _fillfilter->SetGrayLevel(graylevel);
93 }
94
95 //---------------------------------------------------------------------------
96 void ManualPaintModel::SetRangeMin(int min) {
97         _brushfilter->SetRangeMin(min);
98         _fillfilter->SetRangeMin(min);
99 }
100
101 //---------------------------------------------------------------------------
102 void ManualPaintModel::SetRangeMax(int max) {
103         _brushfilter->SetRangeMax(max);
104         _fillfilter->SetRangeMax(max);
105 }
106
107 //---------------------------------------------------------------------------
108 void ManualPaintModel::SetDirection(int direction) {
109         _brushfilter->SetDirection(direction);
110         _fillfilter->SetDirection(direction);
111 }
112
113 //---------------------------------------------------------------------------
114 void ManualPaintModel::SetBrushSize(int brushsize) {
115         _brushfilter->SetBrushSize(brushsize);
116 }
117
118 //---------------------------------------------------------------------------
119 void ManualPaintModel::SetBrushForm(int brushform) {
120         _brushfilter->SetBrushForm(brushform);
121 }
122
123 //---------------------------------------------------------------------------
124 void ManualPaintModel::SetToleranceFill(double tolerancefill) {
125         _fillfilter->SetToleranceFill(tolerancefill);
126 }
127
128 //---------------------------------------------------------------------------
129 void ManualPaintModel::SetDistanceFill(int distancefill) {
130         _fillfilter->SetDistanceFill(distancefill);
131 }
132 //---------------------------------------------------------------------------
133 void ManualPaintModel::GetScalarRange(double * range) {
134         _fillfilter->GetScalarRange(range);
135 }
136 //---------------------------------------------------------------------------
137 void ManualPaintModel::SetUndoImage() {
138         ImageMManager* imMManager = NULL;
139          if (_tool == 0) {
140          imMManager = this->_brushfilter->GetImageMManager();
141          }
142          if (_tool == 1) {
143          imMManager = this->_fillfilter->GetImageMManager();
144          }
145          this->_imageUndoRedo->SetURImages(imMManager);
146          this->_brushfilter->CleanImageMManager();
147          this->_fillfilter->CleanImageMManager();
148 }
149 //---------------------------------------------------------------------------
150
151 void ManualPaintModel::Undo() {
152         this->_imageUndoRedo->Undo();
153 }
154
155 void ManualPaintModel::Redo() {
156         this->_imageUndoRedo->Redo();
157 }