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