]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h
#3058 creaMaracasVisu Feature New Normal - optimizing of manualContourView of a...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualViewBaseContour.h
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 #ifndef manualViewBaseContour_h
27 #define manualViewBaseContour_h
28
29 #include "vtkRenderWindow.h"
30
31 #include "vtkRenderer.h"
32 #include "vtkRenderWindowInteractor.h" //extremely important with VC++ don't remove !
33 #include "vtkCommand.h"
34 #include "vtkPolyData.h"
35 #include "vtkCellArray.h"
36 #include "vtkPolyDataMapper.h"
37 #include "vtkInteractorObserver.h"
38 #include "vtkInteractorStyleImage.h"
39 #include <vtkKochanekSpline.h>
40
41 #include <vtkActor.h>
42 #include <vtkProperty.h>
43 #include <vtkCellArray.h>
44 #include <vtkRenderer.h>
45 #include <vtkCoordinate.h>
46 #include <vtkTextProperty.h>
47 #include <vtkTextActor.h>
48 #include <vtkProperty2D.h>
49 #include <vtkPointPicker.h>
50 //#include "widgets/UtilVtk3DGeometriSelection.h"
51 #include "UtilVtk3DGeometriSelection.h"
52 #include <vtkCellPicker.h> 
53
54
55 #include <vtkCamera.h> 
56 #include <vtkPolyLine.h>
57 #include <vtkDataSetMapper.h>
58 #include <vtkUnstructuredGrid.h>
59
60 #include "wxVTKRenderWindowInteractor.h"
61
62
63 //--
64
65 #include <vector>
66 #include "wxVtkBaseView.h"
67 #include "marTypes.h"
68
69 #include "manualViewPoint.h"
70 #include "manualContourModel.h"
71
72 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
75
76
77 class creaMaracasVisu_EXPORT manualViewBaseContour{
78
79 //---------------------------------------------------
80 // PUBLIC METHODS & ATTS
81 //---------------------------------------------------
82
83 public:
84         manualViewBaseContour();
85         virtual ~manualViewBaseContour();
86
87         virtual int GetType();
88         virtual void Save(FILE *pFile);
89         virtual void Open(FILE *pFile);
90
91         void    AddPoint();
92         virtual void    AddPoint( manualViewPoint * manualViewPoint );
93         void    InsertPoint(int id);
94         void    DeleteContour();
95         void    DeletePoint(int x, int y,int z);
96         virtual void    DeletePoint(int id);
97
98         virtual void    UpdateViewPoint(int id);
99         virtual void    UpdateViewPoints();
100
101         void    SetSelected(bool selected);
102         void    SetPosibleSelected(bool posibleSelected);
103         bool    GetSelected();
104         bool    GetPosibleSelected();
105         void    DeleteSelectedPoints();
106         bool    GetEditable();
107         void    SetEditable( bool * condition );
108
109
110
111         virtual int             GetIdPoint(int x, int y, int z);
112
113         void    SelectPoint(int i,bool select);
114         void    SelectLstPoints();
115         void    SelectAllPoints(bool select);
116         virtual int             SelectPosiblePoint(int x, int y ,int z);
117         bool    SelectPosibleContour(int x, int y ,int z);
118         void    SelectAllPossibleSelected(bool select);
119         void    SetPointSelected(int id,bool select);
120         void    SetPointPosibleSelected(int id,bool select);
121         void    SetIfViewControlPoints(bool ifShow);
122         bool    GetIfViewControlPoints();
123         
124         void    UnSelectPoint(int i);
125         void    UnSelectLstPoints();
126         void    UnSelectAllPoints();
127
128         void    SetModel(manualBaseModel *manContModel);
129         void    SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview);
130
131         virtual void    Refresh();
132         int             GetNumberOfPoints();                                            // ??? 
133         //int   GetNumberOfPointsSpline();                                      //JSTG 25-02-08 In ContourModel is the same method 
134         //void  SetNumberOfPointsSpline(int size);                      //JSTG 25-02-08 In ContourModel is the same method 
135
136         void    CreateNewContour();
137         double* GetVectorPointsXManualContour();
138         double* GetVectorPointsYManualContour();
139         double* GetVectorPointsZManualContour();
140
141         virtual bool    ifTouchContour(int x,int y, int z);
142         void    UpdateColorActor();
143
144         void    SetRange(double range);
145         double  GetRange();
146         void    SetZ(int z);
147         int             GetZ();
148
149         wxVtkBaseView *GetWxVtkBaseView();
150
151         virtual void InitMove(int x, int y, int z);
152         virtual void MoveContour(int x, int y, int z);
153         virtual void MoveContour(int horizontalUnits, int verticalUnits );
154         virtual void GetMinMax( double &minX,double &minY, double &minZ, double &maxX, double &maxY, double &maxZ );
155         virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2);
156
157         void    ClearContour();
158         virtual void    ClearPoint(int id);
159
160         void    SetVisible(bool ok);
161         void    SetShowText(bool ok);
162
163         void    GetSpacing(double spc[3]);
164         void    SetSpacing(double spc[3]);
165
166         void    SetColorNormalContour(double r, double g, double b);
167         void    GetColorNormalContour(double &r, double &g, double &b);
168         void    SetColorEditContour(double r, double g, double b);
169         void    GetColorEditContour(double &r, double &g, double &b);
170         void    SetColorSelectContour(double r, double g, double b);
171         void    GetColorSelectContour(double &r, double &g, double &b);
172         
173         //Addinging and removing from visualization specific actors included in the viewer contour
174         void    AddCompleteContourActor( bool ifControlPoints = false);
175         void    RemoveCompleteContourActor();
176         virtual void    AddSplineActor();
177         virtual void    RemoveSplineActor();
178         virtual void    AddControlPoints();
179         virtual void    RemoveControlPoints();  
180         void    AddTextActor();
181         void    RemoveTextActor();
182         void InitTextActor();
183
184         virtual manualViewBaseContour * Clone();
185                         void                                    CopyAttributesTo( manualViewBaseContour *cloneObject );
186         virtual void                                    RefreshContour();
187                         void                                    SetWidthLine(double width);
188                         double                                  GetWidthLine();
189
190         virtual void                    ConstructVTKObjects();
191
192         void SetCellArray(bool type);
193 //---------------------------------------------------
194 // PRIVATE METHODS & ATTS
195 //---------------------------------------------------
196
197 private:
198
199         vtkPolyData                                                     *_pd;
200         vtkCellArray                                            *_splineCell;
201         vtkCellArray                                            *_lineCell;
202         vtkActor                                                        *_contourVtkActor;
203         vtkPolyDataMapper                                       *_bboxMapper;
204
205         void                    DeleteVtkObjects();
206         
207
208 //---------------------------------------------------
209 // PROTECTED METHODS & ATTS
210 //---------------------------------------------------
211
212 protected:
213
214         double                                                          _range;
215
216         double                                                          _coulorEdit_r;
217         double                                                          _coulorEdit_g;
218         double                                                          _coulorEdit_b;
219         double                                                          _coulorNormal_r;
220         double                                                          _coulorNormal_g;
221         double                                                          _coulorNormal_b;
222         double                                                          _coulorSelection_r;
223         double                                                          _coulorSelection_g;
224         double                                                          _coulorSelection_b;
225         double                                                          _widthline;
226
227         //
228         // Reference to VTKBaseView
229         //
230         wxVtkBaseView                                           *_wxvtkbaseview;
231
232         //
233         // Is the contour selected
234         //
235         bool                                                            _selected;
236         bool                                                            *_editable;
237         bool                                                            _posibleSelected;
238         bool                                                            _viewControlPoints;
239
240         // text
241         bool                                                            _show_text;
242         int                                                                     _id_viewPoint_for_text;
243         vtkTextActor                                            *_textActor;
244         vtkTextActor                                            *_textActor2;
245
246         //
247         // Contour model
248         //
249         manualBaseModel                                         *_manContModel;
250
251         vtkPoints                                                       *_pts;
252 // JSTG 25-02-08 --------------------------------------------
253         int                                                                     _sizePointsContour;
254 //-----------------------------------------------------------
255
256         //
257         // Control points list
258         //
259         std::vector<manualViewPoint*>           _lstViewPoints;
260
261         //
262         // Spacing
263         //
264         double                                                          _spc[3];
265
266         virtual void    RefreshText();
267
268 };
269
270
271 #endif // manualViewBaseContour_h