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