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