]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h
d773a7e3b9e4c63acf57ea4613dad1fa50c05c42
[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 //---------------------------------------------------
193 // PRIVATE METHODS & ATTS
194 //---------------------------------------------------
195
196 private:
197
198         vtkPolyData                                             *_pd;
199         vtkActor                                                *_contourVtkActor;
200         vtkPolyDataMapper                               *_bboxMapper;
201
202         void                    DeleteVtkObjects();
203         
204
205 //---------------------------------------------------
206 // PROTECTED METHODS & ATTS
207 //---------------------------------------------------
208
209 protected:
210
211         double                                  _range;
212
213         double                                  _coulorEdit_r;
214         double                                  _coulorEdit_g;
215         double                                  _coulorEdit_b;
216         double                                  _coulorNormal_r;
217         double                                  _coulorNormal_g;
218         double                                  _coulorNormal_b;
219         double                                  _coulorSelection_r;
220         double                                  _coulorSelection_g;
221         double                                  _coulorSelection_b;
222         double                                  _widthline;
223
224         //
225         // Reference to VTKBaseView
226         //
227         wxVtkBaseView                           *_wxvtkbaseview;
228
229         //
230         // Is the contour selected
231         //
232         bool                                    _selected;
233         bool                                    *_editable;
234         bool                                    _posibleSelected;
235         bool                                    _viewControlPoints;
236
237         // text
238         bool                                    _show_text;
239         int                                     _id_viewPoint_for_text;
240         vtkTextActor                            *_textActor;
241         vtkTextActor                            *_textActor2;
242
243         //
244         // Contour model
245         //
246         manualBaseModel                         *_manContModel;
247
248         vtkPoints                               *_pts;
249 // JSTG 25-02-08 --------------------------------------------
250         int                                     _sizePointsContour;
251 //-----------------------------------------------------------
252
253         //
254         // Control points list
255         //
256         std::vector<manualViewPoint*>           _lstViewPoints;
257
258         //
259         // Spacing
260         //
261         double                                  _spc[3];
262
263         virtual void    RefreshText();
264
265 };
266
267
268 #endif // manualViewBaseContour_h