1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #ifndef __wxContourMainFrame_h_INCLUDED_H__
27 #define __wxContourMainFrame_h_INCLUDED_H__
30 // -----------------------------------------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // -----------------------------------------------------------------------------------------------------------
35 #include <wx/wxprec.h>
44 //------------------------------------------------------------------------------------------------------------
46 //------------------------------------------------------------------------------------------------------------
47 #include "wx/aui/aui.h"
49 #include "interfMainPanel.h"
50 #include "KernelManagerContour.h"
52 //#include "wxVtkBaseView_SceneManager.h"
53 #include "wxInstantChooserPanel.h"
54 #include "wxContourViewPanel.h"
56 //#include "ContourWorkspace.h"
57 #include "ContourExtractData.h"
58 #include "PerformingOperation.h"
60 #include "manualLineControler.h"
61 #include "manualContourModelLine.h"
62 #include "manualViewLine.h"
64 #include "ThresholdImageView.h"
65 #include "ThresholdImageViewPanel.h"
66 #include "ColorLayerImageView.h"
67 #include "ColorLayerImageViewPanel.h"
72 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
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"
83 //EED10JUIN2011 #include "itkImageFileWriter.h"
88 #include "itkImageToVTKImageFilter.h"
89 #include "itkVTKImageToImageFilter.h"
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>
108 //#include "vtkMetaImageReader.h"
110 //------------------------------------------------------------------------------------------------------------
111 // Events declaration
112 //------------------------------------------------------------------------------------------------------------
114 //BEGIN_DECLARE_EVENT_TYPES()
115 //END_DECLARE_EVENT_TYPES()
117 /** file wxContourMainFrame.h */
120 //------------------------------------------------------------------------------------------------------------
122 //------------------------------------------------------------------------------------------------------------
123 class interfMainPanel;
124 class wxContourMainFrame : public wxPanel {
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 ////------------------------------------------------------------------------------------------------------------
153 ////------------------------------------------------------------------------------------------------------------
154 //// Model management methods
155 ////------------------------------------------------------------------------------------------------------------
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();
164 //------------------------------------------------------------------------------------------------------------
165 // Other functional methods
166 //------------------------------------------------------------------------------------------------------------
169 ** This method returns the vector of images selected by the user
170 ** return value std::vector<vtkImageData*>
172 std::vector<vtkImageData*> getVectImages();
175 ** This methods connect the event in the class interfMainPanel with the world of the appli
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 ///////////////////////////
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
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);
226 void referenceLine();
229 void refLineChangeWidth(int width);
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);
241 //====================================================================================================
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);
256 void onSpreadAddAll();
257 void onSpreadGo(int type);
258 void getInstantVector(std::vector<int>& tempVector);
259 std::vector<std::string> getOutlinesName(int slide);
263 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
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*);
279 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
282 * Associates the String parameter with the contour
283 * @param label Label entered by the user
284 * @param manualBaseModel Currently selected contour
286 void onPrintLabel (wxString label, manualBaseModel* manualModel);
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
292 void onInsertCalculation(manualBaseModel* manualModel);
295 * Assigns and returns the value of a pixel in millimeters
296 @ param value Measure of the pixel in millimeters
298 double onePixelSize(double value);
301 * Returns the type of the currently selected contour
306 * Returns the size in pixels of the currently selected contour
308 double getContourSizeInPixels();
311 * Returns the currently selected contour. If no contour is selected returns NULL
313 manualBaseModel* getContour();
316 * Returns the Path of the data persistence file
318 std::string GetFileLocation();
321 * Assign a new path to the data persistence file
322 @ param newFileLocation New path of the file
324 void SetFileLocation(std::string newFileLocation);
325 //------------------------------------------------------------------------------------------------------------
327 void SetScalarRange(int grayRangeMin, int grayRangeMax);
328 std::string GetStringTypeImage( vtkImageData* image);
330 //------------------------------------------------------------------------------------------------------------
332 void SetXY(int x,int y);
336 //------------------------------------------------------------------------------------------------------------
338 //------------------------------------------------------------------------------------------------------------
341 //------------------------------------------------------------------------------------------------------------
343 //------------------------------------------------------------------------------------------------------------
346 static wxContourMainFrame *instance;
347 KernelManagerContour *kernelManager;
348 interfMainPanel *_pannew;
349 PerformingOperation *_performingOperation;
350 std::string _datadir;
351 wxContourViewPanel *_theViewPanel;
352 wxInstantChooserPanel *_instantPanel;
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;
360 wxAuiNotebook *notebook;
361 long m_notebook_style;
362 long m_notebook_theme;
363 int _numberOfVariablesStatistics;
365 // Contour Image Mask
366 ThresholdImageView *_viewMaskImage;
367 ThresholdImageViewPanel *_viewMaskImagePanel;
370 ThresholdImageView *_viewThresholdImage;
371 ThresholdImageViewPanel *_viewThresholdImagePanel;
374 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
375 std::vector<vtkImageData*> _images;
378 // temporary variables readding .roi file
379 int _tmpReadFileImageDim[3];
380 double _tmpReadFileImageSpac[3];
381 int _tmpReadFileTypeOfTransformation;
382 void readDimSpc(FILE *pFile, bool interactiveOption);
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;
396 void loadState(std::string filename);
398 // void loadContours( FILE *pFile, bool staticContour );
400 void saveFileWithContours( std::string filename );
401 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
402 void SetZForAllContours(int pz);
406 std::string stundoredo;
409 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
411 wxPanel *calibrationPanel;
412 wxPanel *calibrationPanelError;
413 double _onePixelSize;
414 std::string _imageLocation;
415 std::string _fileLocation;
416 //------------------------------------------------------------------------------------------------------------
418 wxFrame *_frameShowResultImages;