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"
85 #include "itkImageToVTKImageFilter.h"
86 #include "itkVTKImageToImageFilter.h"
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"
100 #include "vtkCamera.h"
101 #include "vtkImageActor.h"
102 #include <vtkImageMapToColors.h>
103 #include <vtkLookupTable.h>
104 #include <vtkCommand.h>
106 //#include "vtkMetaImageReader.h"
108 //------------------------------------------------------------------------------------------------------------
109 // Events declaration
110 //------------------------------------------------------------------------------------------------------------
112 //BEGIN_DECLARE_EVENT_TYPES()
113 //END_DECLARE_EVENT_TYPES()
115 /** file wxContourMainFrame.h */
118 //------------------------------------------------------------------------------------------------------------
120 //------------------------------------------------------------------------------------------------------------
121 class interfMainPanel;
122 class wxContourMainFrame : public wxPanel {
126 //------------------------------------------------------------------------------------------------------------
127 // Constructors & Destructors
128 //------------------------------------------------------------------------------------------------------------
131 wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
132 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/");
134 ~wxContourMainFrame();
136 //------------------------------------------------------------------------------------------------------------
137 // Creational and initialization methods
138 //------------------------------------------------------------------------------------------------------------
140 void setVectImages(std::vector<vtkImageData*> imgs);
142 bool configurePanels( );
144 bool addNewPanel(wxPanel* panel);
146 wxAuiNotebook * createNotebook();
148 void createInstantChooserPanel(wxAuiNotebook * parent);
150 void createViewPanel(wxAuiNotebook * parent);
152 void createInstantChooserPanel(wxWindow * parent);
154 void createViewPanel(wxWindow * parent);
156 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
158 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
160 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
162 void ShowToolsPanel(bool show);
165 ////------------------------------------------------------------------------------------------------------------
166 //// Methods for capturing events
167 ////------------------------------------------------------------------------------------------------------------
170 ////------------------------------------------------------------------------------------------------------------
171 //// Model management methods
172 ////------------------------------------------------------------------------------------------------------------
175 //------------------------------------------------------------------------------------------------------------
176 // Attributes getters and setters
177 //------------------------------------------------------------------------------------------------------------
178 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/");
179 static wxContourMainFrame* getInstance();
180 static void resetInstance();
182 //------------------------------------------------------------------------------------------------------------
183 // Other functional methods
184 //------------------------------------------------------------------------------------------------------------
187 ** This method returns the vector of images selected by the user
188 ** return value std::vector<vtkImageData*>
190 std::vector<vtkImageData*> getVectImages();
193 ** This methods connect the event in the class interfMainPanel with the world of the appli
195 void onCreateContourSpline( );
196 void onCreateContourRectangle( );
197 void onCreateContourCircle( );
198 void onCreateContourLine( );
199 void onCreateContourPoints( );
200 void onCreateContourPolygon( );
201 void onCreateContourBullEye(wxPanel* pan);
202 /////////////////////////////////
203 void onDeleteContour();
204 void deleteContours( std::vector<std::string> keyNamesVector );
205 void deleteContour( std::string theKeyName );
206 void onDeleteContoursActSlice();
207 void onDeleteAllContours();
208 void deleteAllContours();
209 void setConceptValue( std::string name, int value );
210 ConceptDataWrap* getLastConceptData();
211 bool getIfConceptCheckedAt( std::string name, int pos );
213 void changeInstant();
215 int getNamesWrappingSize();
217 std::string getNameWrapping(int i);
219 void updateInstantOutlines();
220 void updateInstantImageData();
221 void updateInstantAxes();
223 void onChangeDeep(int val);
225 ///////////////////////////
230 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
231 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
232 ///////////////////////7
237 void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
239 void RefreshInterface();
241 vtkImageData* getImageData();
243 void onSegmentationOneSlice(int isovalue,int sampling,int method);
244 void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
245 void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
246 void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
247 void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
248 int GetImageDataSizeZ();
249 void GetImageDataRange(double *range);
250 void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
253 void referenceLine();
256 void refLineChangeWidth(int width);
262 //====================================================================================================
264 void showAxis(bool show);
265 void onRigidPressed();
266 void onWidthOfContour(double width);
267 int getColorWindow();
268 int getWindowLevel();
269 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
270 void onInterpolation(bool interpolate);
271 void onChangeInstant(std::string name,int actual);
274 void onSpreadAddAll();
275 void onSpreadGo(int type);
276 void getInstantVector(std::vector<int>& tempVector);
277 std::vector<std::string> getOutlinesName(int slide);
281 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
283 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
284 void onSaveResults(std::string directory,std::string namefile, std::string filename,
285 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
286 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
287 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
288 void onSnakePressed();
289 void saveFileWithContoursAutomatique();
290 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
291 wxPanel *getMaskImageViewPanel(wxWindow *parent);
292 void SetContourGroup(int contourGroup);
293 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
294 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
297 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
300 * Associates the String parameter with the contour
301 * @param label Label entered by the user
302 * @param manualBaseModel Currently selected contour
304 void onPrintLabel (wxString label, manualBaseModel* manualModel);
307 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
308 * @param manualBaseModel Currently selected contour
310 void onInsertCalculation(manualBaseModel* manualModel);
313 * Assigns and returns the value of a pixel in millimeters
314 @ param value Measure of the pixel in millimeters
316 double onePixelSize(double value);
319 * Returns the type of the currently selected contour
324 * Returns the size in pixels of the currently selected contour
326 double getContourSizeInPixels();
329 * Returns the currently selected contour. If no contour is selected returns NULL
331 manualBaseModel* getContour();
334 * Returns the Path of the data persistence file
336 std::string GetFileLocation();
339 * Assign a new path to the data persistence file
340 @ param newFileLocation New path of the file
342 void SetFileLocation(std::string newFileLocation);
343 //------------------------------------------------------------------------------------------------------------
345 void SetScalarRange(int grayRangeMin, int grayRangeMax);
347 //------------------------------------------------------------------------------------------------------------
350 //------------------------------------------------------------------------------------------------------------
352 //------------------------------------------------------------------------------------------------------------
355 //------------------------------------------------------------------------------------------------------------
357 //------------------------------------------------------------------------------------------------------------
360 static wxContourMainFrame *instance;
361 KernelManagerContour *kernelManager;
362 interfMainPanel *_pannew;
363 PerformingOperation *_performingOperation;
364 std::string _datadir;
365 wxContourViewPanel *_theViewPanel;
366 wxInstantChooserPanel *_instantPanel;
368 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
369 manualLineControler *_refLineControl;
370 manualContourModelLine *_refLineModel;
371 manualViewLine *_refLineView;
374 wxAuiNotebook *notebook;
375 long m_notebook_style;
376 long m_notebook_theme;
377 int _numberOfVariablesStatistics;
379 // Contour Image Mask
380 ThresholdImageView *_viewMaskImage;
381 ThresholdImageViewPanel *_viewMaskImagePanel;
384 ThresholdImageView *_viewThresholdImage;
385 ThresholdImageViewPanel *_viewThresholdImagePanel;
388 ColorLayerImageView *_viewColorLayerImage;
389 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
390 std::vector<vtkImageData*> _images;
393 // temporary variables readding .roi file
394 int _tmpReadFileImageDim[3];
395 double _tmpReadFileImageSpac[3];
396 int _tmpReadFileTypeOfTransformation;
397 void readDimSpc(FILE *pFile, bool interactiveOption);
400 /*DECLARE_CLASS(wxContourMainFrame)
401 // any class wishing to process wxWindows events must use this macro
402 DECLARE_EVENT_TABLE()*/
403 bool _creatingContoursActive;
404 ////////JCP 21 - 11 - 08
405 void createContour( int typeContour );
406 //manualContourModel * factoryManualContourModel(int typeContour);
407 manualBaseModel * factoryManualContourModel(wxPanel* panel);
408 ContourExtractData *_contourextractdata;
411 void loadState(std::string filename);
413 // void loadContours( FILE *pFile, bool staticContour );
415 void saveFileWithContours( std::string filename );
416 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
420 std::string stundoredo;
423 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
425 wxPanel *calibrationPanel;
426 wxPanel *calibrationPanelError;
427 double _onePixelSize;
428 std::string _imageLocation;
429 std::string _fileLocation;
430 //------------------------------------------------------------------------------------------------------------