]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h
install creaImageIO descriptor
[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 onSpreadGo(int type);
250         void getInstantVector(std::vector<int>& tempVector);
251         std::vector<std::string> getOutlinesName(int slide);
252
253         //
254         //
255         // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
256         //
257         void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
258         void onSaveResults(std::string directory,std::string namefile, std::string filename,
259                 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
260         void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
261         void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
262         void onSnakePressed();
263         void saveFileWithContoursAutomatique();
264         void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
265         wxPanel *getMaskImageViewPanel(wxWindow *parent);
266         void SetContourGroup(int contourGroup);
267         wxPanel *getThresholdImageViewPanel(wxWindow *parent);
268         wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
269
270
271 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
272
273         /**
274         * Associates the String parameter with the contour
275         * @param label Label entered by the user
276         * @param manualBaseModel Currently selected contour
277         */
278         void onPrintLabel (wxString label, manualBaseModel* manualModel);
279
280         /**
281         * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
282         * @param manualBaseModel Currently selected contour
283         */
284         void onInsertCalculation(manualBaseModel* manualModel);
285
286         /**
287         * Assigns and returns the value of a pixel in millimeters
288         @ param value Measure of the pixel in millimeters
289         */
290         double onePixelSize(double value);
291
292         /**
293         * Returns the type of the currently selected contour
294         */
295         int getType();
296
297         /**
298         * Returns the size in pixels of the currently selected contour
299         */
300         double getContourSizeInPixels();
301
302         /**
303         * Returns the currently selected contour. If no contour is selected returns NULL
304         */
305         manualBaseModel* getContour();
306
307         /**
308         * Returns the Path of the data persistence file
309         */
310         std::string GetFileLocation();
311
312         /**
313         * Assign a new path to the data persistence file
314         @ param newFileLocation New path of the file
315         */
316         void SetFileLocation(std::string newFileLocation);
317 //------------------------------------------------------------------------------------------------------------
318
319         void SetScalarRange(int grayRangeMin, int grayRangeMax);
320
321 //------------------------------------------------------------------------------------------------------------
322
323 private:
324         //------------------------------------------------------------------------------------------------------------
325         //  Private methods
326         //------------------------------------------------------------------------------------------------------------
327
328
329         //------------------------------------------------------------------------------------------------------------
330         // Attributtes
331         //------------------------------------------------------------------------------------------------------------
332
333         int _contourGroup;
334         static wxContourMainFrame   *instance;
335         KernelManagerContour        *kernelManager;
336         interfMainPanel             *_pannew;
337         PerformingOperation         *_performingOperation;
338         std::string                 _datadir;
339         wxContourViewPanel          *_theViewPanel;
340         wxInstantChooserPanel       *_instantPanel;
341
342         //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
343         manualLineControler         *_refLineControl;
344         manualContourModelLine      *_refLineModel;
345         manualViewLine              *_refLineView;
346
347         wxAuiManager                m_mgr;
348         wxAuiNotebook               *notebook;
349     long                        m_notebook_style;
350     long                        m_notebook_theme;
351     int                         _numberOfVariablesStatistics;
352
353         // Contour Image Mask
354         ThresholdImageView                      *_viewMaskImage;
355         ThresholdImageViewPanel         *_viewMaskImagePanel;
356
357         // Threshold Image
358         ThresholdImageView                      *_viewThresholdImage;
359         ThresholdImageViewPanel         *_viewThresholdImagePanel;
360
361         // Color Layer Image
362         ColorLayerImageView                     *_viewColorLayerImage;
363         ColorLayerImageViewPanel        *_viewColorLayerImagePanel;
364         std::vector<vtkImageData*>  _images;
365         bool                        _actorPresent;
366
367     // temporary variables readding .roi file
368     int             _tmpReadFileImageDim[3];
369         double          _tmpReadFileImageSpac[3];
370     int             _tmpReadFileTypeOfTransformation;
371     void readDimSpc(FILE *pFile);
372
373
374         /*DECLARE_CLASS(wxContourMainFrame)
375         // any class wishing to process wxWindows events must use this macro
376         DECLARE_EVENT_TABLE()*/
377         bool                        _creatingContoursActive;
378 ////////JCP 21 - 11 - 08
379         void createContour( int typeContour );
380         //manualContourModel * factoryManualContourModel(int typeContour);
381         manualBaseModel * factoryManualContourModel(wxPanel* panel);
382         ContourExtractData              *_contourextractdata;
383
384         void saveState();
385         void loadState(std::string filename);
386         void loadContours( FILE *pFile, bool staticContour );
387         void saveFileWithContours( std::string filename );
388         void onLoadContours(std::string fileNameContourROI);
389
390         int                         inredo;
391         int                         inundo;
392         std::string                     stundoredo;
393         static char                 COPY;
394
395 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
396         wxWindow                    *infoWin2;
397         wxPanel                     *calibrationPanel;
398         wxPanel                     *calibrationPanelError;
399         double                      _onePixelSize;
400         std::string                 _imageLocation;
401         std::string                 _fileLocation;
402 //------------------------------------------------------------------------------------------------------------
403
404 };
405
406 #endif