1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #ifndef manualViewBaseContour_h
27 #define manualViewBaseContour_h
29 #include "vtkRenderWindow.h"
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>
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>
55 #include <vtkCamera.h>
56 #include <vtkPolyLine.h>
57 #include <vtkDataSetMapper.h>
58 #include <vtkUnstructuredGrid.h>
60 #include "creawxVTKRenderWindowInteractor.h"
66 #include "wxVtkBaseView.h"
69 #include "manualViewPoint.h"
70 #include "manualContourModel.h"
72 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
77 class creaMaracasVisu_EXPORT manualViewBaseContour
80 //---------------------------------------------------
81 // PUBLIC METHODS & ATTS
82 //---------------------------------------------------
85 manualViewBaseContour();
86 virtual ~manualViewBaseContour();
88 virtual int GetType();
89 virtual void Save(FILE *pFile);
90 virtual void Open(FILE *pFile);
93 virtual void AddPoint( manualViewPoint * manualViewPoint );
94 void InsertPoint(int id);
96 void DeletePoint(int x, int y,int z);
97 virtual void DeletePoint(int id);
99 virtual void UpdateViewPoint(int id);
100 virtual void UpdateViewPoints();
102 void SetSelected(bool selected);
103 void SetPosibleSelected(bool posibleSelected);
105 bool GetPosibleSelected();
106 void DeleteSelectedPoints();
108 void SetEditable( bool * condition );
112 virtual int GetIdPoint(int x, int y, int z);
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();
125 void UnSelectPoint(int i);
126 void UnSelectLstPoints();
127 void UnSelectAllPoints();
129 void SetModel(manualBaseModel *manContModel);
130 void SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview);
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
137 void CreateNewContour();
138 double* GetVectorPointsXManualContour();
139 double* GetVectorPointsYManualContour();
140 double* GetVectorPointsZManualContour();
142 virtual bool ifTouchContour(int x,int y, int z);
143 void UpdateColorActor();
145 void SetRange(double range);
150 wxVtkBaseView *GetWxVtkBaseView();
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);
159 virtual void ClearPoint(int id);
161 void SetVisible(bool ok);
162 void SetShowText(bool ok);
164 void GetSpacing(double spc[3]);
165 void SetSpacing(double spc[3]);
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);
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();
182 void RemoveTextActor();
183 void InitTextActor();
185 virtual manualViewBaseContour * Clone();
186 void CopyAttributesTo( manualViewBaseContour *cloneObject );
187 virtual void RefreshContour();
188 void SetWidthLine(double width);
189 double GetWidthLine();
191 virtual void ConstructVTKObjects();
193 void SetCellArray(bool type);
194 //---------------------------------------------------
195 // PRIVATE METHODS & ATTS
196 //---------------------------------------------------
201 vtkCellArray *_splineCell;
202 vtkCellArray *_lineCell;
203 vtkActor *_contourVtkActor;
204 vtkPolyDataMapper *_bboxMapper;
206 void DeleteVtkObjects();
209 //---------------------------------------------------
210 // PROTECTED METHODS & ATTS
211 //---------------------------------------------------
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;
229 // Reference to VTKBaseView
231 wxVtkBaseView *_wxvtkbaseview;
234 // Is the contour selected
238 bool _posibleSelected;
239 bool _viewControlPoints;
243 int _id_viewPoint_for_text;
244 vtkTextActor *_textActor;
245 vtkTextActor *_textActor2;
250 manualBaseModel *_manContModel;
253 // JSTG 25-02-08 --------------------------------------------
254 int _sizePointsContour;
255 //-----------------------------------------------------------
258 // Control points list
260 std::vector<manualViewPoint*> _lstViewPoints;
267 virtual void RefreshText();
272 #endif // manualViewBaseContour_h