]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h
SetColorImage update
[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         void    SetColorLayerImage(vtkImageData*);
276
277 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
278
279         /**
280         * Associates the String parameter with the contour
281         * @param label Label entered by the user
282         * @param manualBaseModel Currently selected contour
283         */
284         void onPrintLabel (wxString label, manualBaseModel* manualModel);
285
286         /**
287         * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
288         * @param manualBaseModel Currently selected contour
289         */
290         void onInsertCalculation(manualBaseModel* manualModel);
291
292         /**
293         * Assigns and returns the value of a pixel in millimeters
294         @ param value Measure of the pixel in millimeters
295         */
296         double onePixelSize(double value);
297
298         /**
299         * Returns the type of the currently selected contour
300         */
301         int getType();
302
303         /**
304         * Returns the size in pixels of the currently selected contour
305         */
306         double getContourSizeInPixels();
307
308         /**
309         * Returns the currently selected contour. If no contour is selected returns NULL
310         */
311         manualBaseModel* getContour();
312
313         /**
314         * Returns the Path of the data persistence file
315         */
316         std::string GetFileLocation();
317
318         /**
319         * Assign a new path to the data persistence file
320         @ param newFileLocation New path of the file
321         */
322         void SetFileLocation(std::string newFileLocation);
323 //------------------------------------------------------------------------------------------------------------
324
325         void SetScalarRange(int grayRangeMin, int grayRangeMax);
326         std::string GetStringTypeImage( vtkImageData* image);
327
328 //------------------------------------------------------------------------------------------------------------
329
330         void SetXY(int x,int y);
331
332
333 private:
334         //------------------------------------------------------------------------------------------------------------
335         //  Private methods
336         //------------------------------------------------------------------------------------------------------------
337
338
339         //------------------------------------------------------------------------------------------------------------
340         // Attributtes
341         //------------------------------------------------------------------------------------------------------------
342
343         int                                             _contourGroup;
344         static wxContourMainFrame   *instance;
345         KernelManagerContour        *kernelManager;
346         interfMainPanel             *_pannew;
347         PerformingOperation         *_performingOperation;
348         std::string                 _datadir;
349         wxContourViewPanel          *_theViewPanel;
350         wxInstantChooserPanel       *_instantPanel;
351
352         //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
353         manualLineControler         *_refLineControl;
354         manualContourModelLine      *_refLineModel;
355         manualViewLine              *_refLineView;
356
357         wxAuiManager                m_mgr;
358         wxAuiNotebook               *notebook;
359     long                                                m_notebook_style;
360     long                        m_notebook_theme;
361     int                          _numberOfVariablesStatistics;
362
363         // Contour Image Mask
364         ThresholdImageView                      *_viewMaskImage;
365         ThresholdImageViewPanel         *_viewMaskImagePanel;
366
367         // Threshold Image
368         ThresholdImageView                      *_viewThresholdImage;
369         ThresholdImageViewPanel         *_viewThresholdImagePanel;
370
371         // Color Layer Image
372         ColorLayerImageViewPanel        *_viewColorLayerImagePanel;
373         std::vector<vtkImageData*>  _images;
374         bool                        _actorPresent;
375
376     // temporary variables readding .roi file
377     int                                 _tmpReadFileImageDim[3];
378         double                                  _tmpReadFileImageSpac[3];
379     int                                 _tmpReadFileTypeOfTransformation;
380     void readDimSpc(FILE *pFile, bool interactiveOption);
381
382
383         /*DECLARE_CLASS(wxContourMainFrame)
384         // any class wishing to process wxWindows events must use this macro
385         DECLARE_EVENT_TABLE()*/
386         bool                        _creatingContoursActive;
387 ////////JCP 21 - 11 - 08
388         void createContour( int typeContour );
389         //manualContourModel * factoryManualContourModel(int typeContour);
390         manualBaseModel * factoryManualContourModel(wxPanel* panel);
391         ContourExtractData              *_contourextractdata;
392
393         void saveState();
394         void loadState(std::string filename);
395
396 //      void loadContours( FILE *pFile, bool staticContour );
397
398         void saveFileWithContours( std::string filename );
399         void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
400         void SetZForAllContours(int pz);
401
402         int                         inredo;
403         int                         inundo;
404         std::string                     stundoredo;
405         static char                 COPY;
406
407 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
408         wxWindow                    *infoWin2;
409         wxPanel                     *calibrationPanel;
410         wxPanel                     *calibrationPanelError;
411         double                      _onePixelSize;
412         std::string                 _imageLocation;
413         std::string                 _fileLocation;
414 //------------------------------------------------------------------------------------------------------------
415
416         wxFrame                                         *_frameShowResultImages;
417
418 };
419
420 #endif