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