]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h
c109ece302ccdc7dce31f191bb5eca6f0c5897b4
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.h
1 #ifndef __wxContourMainFrame_h_INCLUDED_H__
2 #define __wxContourMainFrame_h_INCLUDED_H__
3
4
5 // -----------------------------------------------------------------------------------------------------------
6 // WX headers inclusion.
7 // For compilers that support precompilation, includes <wx/wx.h>.
8 // -----------------------------------------------------------------------------------------------------------
9
10 #include <wx/wxprec.h>
11 #ifdef __BORLANDC__
12 #pragma hdrstop
13 #endif
14 #ifndef WX_PRECOMP
15 #include <wx/wx.h>
16 #endif
17
18
19 //------------------------------------------------------------------------------------------------------------
20 // Includes
21 //------------------------------------------------------------------------------------------------------------
22 #include "wx/aui/aui.h"
23
24 #include "interfMainPanel.h"
25 #include "KernelManagerContour.h"
26
27 //#include "wxVtkBaseView_SceneManager.h"
28 #include "wxInstantChooserPanel.h"
29 #include "wxContourViewPanel.h"
30
31 //#include "ContourWorkspace.h"
32 #include "ContourExtractData.h"
33 #include "PerformingOperation.h"
34
35 #include "manualLineControler.h"
36 #include "manualContourModelLine.h"
37 #include "manualViewLine.h"
38
39 #include "ThresholdImageView.h"
40 #include "ThresholdImageViewPanel.h"
41 #include "ColorLayerImageView.h"
42 #include "ColorLayerImageViewPanel.h"
43
44
45 //ITK
46 #include "itkImage.h"
47 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
48
49 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
50 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
51 #include "itkSigmoidImageFilter.h"
52 #include "itkFastMarchingImageFilter.h"
53 #include "itkRescaleIntensityImageFilter.h"
54 #include "itkBinaryThresholdImageFilter.h"
55 #include "itkZeroCrossingImageFilter.h"
56 #include "itkCastImageFilter.h"
57
58 #include "itkImageFileWriter.h"
59
60 #include "itkImageToVTKImageFilter.h"
61 #include "itkVTKImageToImageFilter.h"
62
63 //VTK
64 #include <vtkImageSeedConnectivity.h>
65 #include <vtkImageMarchingCubes.h>
66 #include "vtkContourFilter.h"
67 #include "vtkMarchingContourFilter.h"
68 #include "vtkPolyDataConnectivityFilter.h"
69 #include "vtkCleanPolyData.h"
70 #include "vtkImageReslice.h"
71 #include "vtkMetaImageWriter.h"
72 #include "vtkImageData.h"
73 #include "vtkTransform.h"
74
75 #include "vtkCamera.h"
76 #include "vtkImageActor.h"
77 #include <vtkImageMapToColors.h>
78 #include <vtkLookupTable.h>
79 #include <vtkCommand.h>
80
81 //#include "vtkMetaImageReader.h"
82
83 //------------------------------------------------------------------------------------------------------------
84 // Events declaration
85 //------------------------------------------------------------------------------------------------------------
86
87 //BEGIN_DECLARE_EVENT_TYPES()
88 //END_DECLARE_EVENT_TYPES()
89
90 /** file wxContourMainFrame.h */
91
92
93 //------------------------------------------------------------------------------------------------------------
94 // Class definition
95 //------------------------------------------------------------------------------------------------------------
96 class interfMainPanel;
97 class wxContourMainFrame : public wxPanel {
98
99         public:
100
101         //------------------------------------------------------------------------------------------------------------
102         // Constructors & Destructors
103         //------------------------------------------------------------------------------------------------------------
104
105
106         wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style  = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
107         wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style  = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER,std::string datadir="C:/Creatis/creaContoursBin/RelWithDebInfo/");
108
109         ~wxContourMainFrame();
110
111         //------------------------------------------------------------------------------------------------------------
112         // Creational and initialization methods
113         //------------------------------------------------------------------------------------------------------------
114
115         void setVectImages(std::vector<vtkImageData*> imgs);
116
117         bool configurePanels( );
118
119         bool addNewPanel(wxPanel* panel);
120
121         wxAuiNotebook * createNotebook();
122
123         void createInstantChooserPanel(wxAuiNotebook * parent);
124
125         void createViewPanel(wxAuiNotebook * parent);
126
127         void createInstantChooserPanel(wxWindow * parent);
128
129         void createViewPanel(wxWindow * parent);
130
131         void setInstantChooserPanel(  wxInstantChooserPanel * theInstantChooserPanel );
132
133         void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
134
135         void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
136
137         void ShowToolsPanel(bool show);
138
139
140         ////------------------------------------------------------------------------------------------------------------
141         //// Methods for capturing events
142         ////------------------------------------------------------------------------------------------------------------
143
144
145         ////------------------------------------------------------------------------------------------------------------
146         ////  Model management methods
147         ////------------------------------------------------------------------------------------------------------------
148
149
150         //------------------------------------------------------------------------------------------------------------
151         //  Attributes getters and setters
152         //------------------------------------------------------------------------------------------------------------
153         static wxContourMainFrame* getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style  = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER, std::string datadir="C:/Creatis/creaContoursBin/RelWithDebInfo/");
154         static wxContourMainFrame* getInstance();
155         static void resetInstance();
156
157         //------------------------------------------------------------------------------------------------------------
158         //  Other functional methods
159         //------------------------------------------------------------------------------------------------------------
160
161         /*
162         ** This method returns the vector of images selected by the user
163         **      return value std::vector<vtkImageData*>
164         */
165         std::vector<vtkImageData*> getVectImages();
166
167         /**
168         **      This methods connect the event in the class interfMainPanel with the world of the appli
169         **/
170         void onCreateContourSpline( );
171         void onCreateContourRectangle( );
172         void onCreateContourCircle( );
173         void onCreateContourLine( );
174         void onCreateContourPoints( );
175         void onCreateContourPolygon( );
176         void onCreateContourBullEye(wxPanel* pan);
177         /////////////////////////////////
178         void onDeleteContour();
179         void deleteContours( std::vector<std::string>  keyNamesVector );
180         void deleteContour( std::string theKeyName );
181         void onDeleteContoursActSlice();
182         void onDeleteAllContours();
183         void deleteAllContours();
184         void setConceptValue( std::string name, int value );
185         ConceptDataWrap* getLastConceptData();
186         bool getIfConceptCheckedAt( std::string name, int pos );
187
188         void changeInstant();
189
190         int getNamesWrappingSize();
191
192         std::string getNameWrapping(int i);
193
194         void updateInstantOutlines();
195         void updateInstantImageData();
196         void updateInstantAxes();
197
198         void onChangeDeep(int val);
199
200 ///////////////////////////
201         void onCopy();
202         void onPaste();
203         void onUndo();
204         void onRedo();
205         void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
206         void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
207 ///////////////////////7
208         void onLoad();
209         void onSave();
210         void onImport();
211         void onTest();
212         void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
213
214         void RefreshInterface();
215
216         vtkImageData* getImageData();
217
218         void onSegmentationOneSlice(int isovalue,int sampling,int method);
219         void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
220         void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
221         void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
222         void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
223         int  GetImageDataSizeZ();
224         void GetImageDataRange(double *range);
225         void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
226
227         //AD
228         void referenceLine();
229         void refLineHide();
230         void refLineShow();
231         void refLineChangeWidth(int width);
232
233         //AD
234         void onMirror();
235
236
237 //====================================================================================================
238
239         void showAxis(bool show);
240         void onRigidPressed();
241         void onWidthOfContour(double width);
242         int getColorWindow();
243         int getWindowLevel();
244         void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
245         void onInterpolation(bool interpolate);
246         void onChangeInstant(std::string name,int actual);
247         void resetAppend();
248         void onSpreadAdd();
249         void onSpreadAddAll();
250         void onSpreadGo(int type);
251         void getInstantVector(std::vector<int>& tempVector);
252         std::vector<std::string> getOutlinesName(int slide);
253
254         //
255         //
256         // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
257         //
258         void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
259         void onSaveResults(std::string directory,std::string namefile, std::string filename,
260                 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
261         void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
262         void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
263         void onSnakePressed();
264         void saveFileWithContoursAutomatique();
265         void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
266         wxPanel *getMaskImageViewPanel(wxWindow *parent);
267         void SetContourGroup(int contourGroup);
268         wxPanel *getThresholdImageViewPanel(wxWindow *parent);
269         wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
270
271
272 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
273
274         /**
275         * Associates the String parameter with the contour
276         * @param label Label entered by the user
277         * @param manualBaseModel Currently selected contour
278         */
279         void onPrintLabel (wxString label, manualBaseModel* manualModel);
280
281         /**
282         * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
283         * @param manualBaseModel Currently selected contour
284         */
285         void onInsertCalculation(manualBaseModel* manualModel);
286
287         /**
288         * Assigns and returns the value of a pixel in millimeters
289         @ param value Measure of the pixel in millimeters
290         */
291         double onePixelSize(double value);
292
293         /**
294         * Returns the type of the currently selected contour
295         */
296         int getType();
297
298         /**
299         * Returns the size in pixels of the currently selected contour
300         */
301         double getContourSizeInPixels();
302
303         /**
304         * Returns the currently selected contour. If no contour is selected returns NULL
305         */
306         manualBaseModel* getContour();
307
308         /**
309         * Returns the Path of the data persistence file
310         */
311         std::string GetFileLocation();
312
313         /**
314         * Assign a new path to the data persistence file
315         @ param newFileLocation New path of the file
316         */
317         void SetFileLocation(std::string newFileLocation);
318 //------------------------------------------------------------------------------------------------------------
319
320         void SetScalarRange(int grayRangeMin, int grayRangeMax);
321
322 //------------------------------------------------------------------------------------------------------------
323
324 private:
325         //------------------------------------------------------------------------------------------------------------
326         //  Private methods
327         //------------------------------------------------------------------------------------------------------------
328
329
330         //------------------------------------------------------------------------------------------------------------
331         // Attributtes
332         //------------------------------------------------------------------------------------------------------------
333
334         int _contourGroup;
335         static wxContourMainFrame   *instance;
336         KernelManagerContour        *kernelManager;
337         interfMainPanel             *_pannew;
338         PerformingOperation         *_performingOperation;
339         std::string                 _datadir;
340         wxContourViewPanel          *_theViewPanel;
341         wxInstantChooserPanel       *_instantPanel;
342
343         //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
344         manualLineControler         *_refLineControl;
345         manualContourModelLine      *_refLineModel;
346         manualViewLine              *_refLineView;
347
348         wxAuiManager                m_mgr;
349         wxAuiNotebook               *notebook;
350     long                        m_notebook_style;
351     long                        m_notebook_theme;
352     int                         _numberOfVariablesStatistics;
353
354         // Contour Image Mask
355         ThresholdImageView                      *_viewMaskImage;
356         ThresholdImageViewPanel         *_viewMaskImagePanel;
357
358         // Threshold Image
359         ThresholdImageView                      *_viewThresholdImage;
360         ThresholdImageViewPanel         *_viewThresholdImagePanel;
361
362         // Color Layer Image
363         ColorLayerImageView                     *_viewColorLayerImage;
364         ColorLayerImageViewPanel        *_viewColorLayerImagePanel;
365         std::vector<vtkImageData*>  _images;
366         bool                        _actorPresent;
367
368     // temporary variables readding .roi file
369     int             _tmpReadFileImageDim[3];
370         double          _tmpReadFileImageSpac[3];
371     int             _tmpReadFileTypeOfTransformation;
372     void readDimSpc(FILE *pFile, bool interactiveOption);
373
374
375         /*DECLARE_CLASS(wxContourMainFrame)
376         // any class wishing to process wxWindows events must use this macro
377         DECLARE_EVENT_TABLE()*/
378         bool                        _creatingContoursActive;
379 ////////JCP 21 - 11 - 08
380         void createContour( int typeContour );
381         //manualContourModel * factoryManualContourModel(int typeContour);
382         manualBaseModel * factoryManualContourModel(wxPanel* panel);
383         ContourExtractData              *_contourextractdata;
384
385         void saveState();
386         void loadState(std::string filename);
387
388 //      void loadContours( FILE *pFile, bool staticContour );
389
390         void saveFileWithContours( std::string filename );
391         void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
392
393         int                         inredo;
394         int                         inundo;
395         std::string                     stundoredo;
396         static char                 COPY;
397
398 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
399         wxWindow                    *infoWin2;
400         wxPanel                     *calibrationPanel;
401         wxPanel                     *calibrationPanelError;
402         double                      _onePixelSize;
403         std::string                 _imageLocation;
404         std::string                 _fileLocation;
405 //------------------------------------------------------------------------------------------------------------
406
407 };
408
409 #endif