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