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