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