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