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