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 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 ////------------------------------------------------------------------------------------------------------------
151 ////------------------------------------------------------------------------------------------------------------
152 //// Model management methods
153 ////------------------------------------------------------------------------------------------------------------
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();
162 //------------------------------------------------------------------------------------------------------------
163 // Other functional methods
164 //------------------------------------------------------------------------------------------------------------
167 ** This method returns the vector of images selected by the user
168 ** return value std::vector<vtkImageData*>
170 std::vector<vtkImageData*> getVectImages();
173 ** This methods connect the event in the class interfMainPanel with the world of the appli
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 ///////////////////////////
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
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);
224 void referenceLine();
227 void refLineChangeWidth(int width);
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);
239 //====================================================================================================
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);
254 void onSpreadAddAll();
255 void onSpreadGo(int type);
256 void getInstantVector(std::vector<int>& tempVector);
257 std::vector<std::string> getOutlinesName(int slide);
261 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
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);
276 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
279 * Associates the String parameter with the contour
280 * @param label Label entered by the user
281 * @param manualBaseModel Currently selected contour
283 void onPrintLabel (wxString label, manualBaseModel* manualModel);
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
289 void onInsertCalculation(manualBaseModel* manualModel);
292 * Assigns and returns the value of a pixel in millimeters
293 @ param value Measure of the pixel in millimeters
295 double onePixelSize(double value);
298 * Returns the type of the currently selected contour
303 * Returns the size in pixels of the currently selected contour
305 double getContourSizeInPixels();
308 * Returns the currently selected contour. If no contour is selected returns NULL
310 manualBaseModel* getContour();
313 * Returns the Path of the data persistence file
315 std::string GetFileLocation();
318 * Assign a new path to the data persistence file
319 @ param newFileLocation New path of the file
321 void SetFileLocation(std::string newFileLocation);
322 //------------------------------------------------------------------------------------------------------------
324 void SetScalarRange(int grayRangeMin, int grayRangeMax);
325 std::string GetStringTypeImage( vtkImageData* image);
327 //------------------------------------------------------------------------------------------------------------
329 void SetXY(int x,int y);
333 //------------------------------------------------------------------------------------------------------------
335 //------------------------------------------------------------------------------------------------------------
338 //------------------------------------------------------------------------------------------------------------
340 //------------------------------------------------------------------------------------------------------------
343 static wxContourMainFrame *instance;
344 KernelManagerContour *kernelManager;
345 interfMainPanel *_pannew;
346 PerformingOperation *_performingOperation;
347 std::string _datadir;
348 wxContourViewPanel *_theViewPanel;
349 wxInstantChooserPanel *_instantPanel;
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;
357 wxAuiNotebook *notebook;
358 long m_notebook_style;
359 long m_notebook_theme;
360 int _numberOfVariablesStatistics;
362 // Contour Image Mask
363 ThresholdImageView *_viewMaskImage;
364 ThresholdImageViewPanel *_viewMaskImagePanel;
367 ThresholdImageView *_viewThresholdImage;
368 ThresholdImageViewPanel *_viewThresholdImagePanel;
371 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
372 std::vector<vtkImageData*> _images;
375 // temporary variables readding .roi file
376 int _tmpReadFileImageDim[3];
377 double _tmpReadFileImageSpac[3];
378 int _tmpReadFileTypeOfTransformation;
379 void readDimSpc(FILE *pFile, bool interactiveOption);
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;
393 void loadState(std::string filename);
395 // void loadContours( FILE *pFile, bool staticContour );
397 void saveFileWithContours( std::string filename );
398 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
399 void SetZForAllContours(int pz);
403 std::string stundoredo;
406 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
408 wxPanel *calibrationPanel;
409 wxPanel *calibrationPanelError;
410 double _onePixelSize;
411 std::string _imageLocation;
412 std::string _fileLocation;
413 //------------------------------------------------------------------------------------------------------------
415 wxFrame *_frameShowResultImages;