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