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
209 void onLoad(bool interactiveInterface=true);
213 void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
214 void RefreshInterface();
215 vtkImageData* getImageData();
216 void onSegmentationOneSlice(double 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, double isovalue, int sampling, int method , vtkImageData *imagedata);
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 onSegmentationAllSlices(int minZ,int maxZ,double isovalue,int sampling,int method);
224 void onSegmentationAllSlices2(int step ,double isovalue,int samplsing,int method,int minZ, int maxZ,vtkImageData* imagedata);
227 void referenceLine();
230 void refLineChangeWidth(int width);
236 void FlipContours(int typeContourFlip, int flipDirection);
237 void FlipSelectedContours(int flipDirection);
238 void FlipActualSliceContours(int flipDirection);
239 void FlipAllContours(int flipDirection);
240 void FlipLstOfContours(std::vector<std::string> lstNameThings, int flipDirection);
242 //====================================================================================================
244 void showAxis(bool show);
245 void onRigidPressed();
246 void onWidthOfContour(double width);
247 int getColorWindow();
248 int getWindowLevel();
249 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
250 void onInterpolation(bool interpolate);
251 void onShowTextContour(bool show);
252 void onBeforeAfterContour(bool before, bool after);
253 void onJumpSlice(int step,int shift);
254 void onChangeInstant(std::string name,int actual);
257 void onSpreadAddAll();
258 void onSpreadGo(int type);
259 void getInstantVector(std::vector<int>& tempVector);
260 std::vector<std::string> getOutlinesName(int slide);
264 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
266 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
267 void onSaveResults(std::string directory,std::string namefile, std::string filename,
268 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
269 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
270 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
271 void onSnakePressed();
272 void saveFileWithContoursAutomatique();
273 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
274 wxPanel *getMaskImageViewPanel(wxWindow *parent);
275 void SetContourGroup(int contourGroup);
276 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
277 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
278 void SetColorLayerImage(vtkImageData*);
280 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
283 * Associates the String parameter with the contour
284 * @param label Label entered by the user
285 * @param manualBaseModel Currently selected contour
287 void onPrintLabel (wxString label, manualBaseModel* manualModel);
290 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
291 * @param manualBaseModel Currently selected contour
293 void onInsertCalculation(manualBaseModel* manualModel);
296 * Assigns and returns the value of a pixel in millimeters
297 @ param value Measure of the pixel in millimeters
299 double onePixelSize(double value);
302 * Returns the type of the currently selected contour
307 * Returns the size in pixels of the currently selected contour
309 double getContourSizeInPixels();
312 * Returns the currently selected contour. If no contour is selected returns NULL
314 manualBaseModel* getContour();
317 * Returns the Path of the data persistence file
319 std::string GetFileLocation();
322 * Assign a new path to the data persistence file
323 @ param newFileLocation New path of the file
325 void SetFileLocation(std::string newFileLocation);
326 //------------------------------------------------------------------------------------------------------------
328 void SetScalarRange(int grayRangeMin, int grayRangeMax);
329 std::string GetStringTypeImage( vtkImageData* image);
331 //------------------------------------------------------------------------------------------------------------
332 void SetXY(int x,int y);
335 //------------------------------------------------------------------------------------------------------------
337 //------------------------------------------------------------------------------------------------------------
340 //------------------------------------------------------------------------------------------------------------
342 //------------------------------------------------------------------------------------------------------------
345 static wxContourMainFrame *instance;
346 KernelManagerContour *kernelManager;
347 interfMainPanel *_pannew;
348 PerformingOperation *_performingOperation;
349 std::string _datadir;
350 wxContourViewPanel *_theViewPanel;
351 wxInstantChooserPanel *_instantPanel;
353 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
354 manualLineControler *_refLineControl;
355 manualContourModelLine *_refLineModel;
356 manualViewLine *_refLineView;
359 wxAuiNotebook *notebook;
360 long m_notebook_style;
361 long m_notebook_theme;
362 int _numberOfVariablesStatistics;
364 // Contour Image Mask
365 ThresholdImageView *_viewMaskImage;
366 ThresholdImageViewPanel *_viewMaskImagePanel;
369 ThresholdImageView *_viewThresholdImage;
370 ThresholdImageViewPanel *_viewThresholdImagePanel;
373 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
374 std::vector<vtkImageData*> _images;
377 // temporary variables readding .roi file
378 int _tmpReadFileImageDim[3];
379 double _tmpReadFileImageSpac[3];
380 int _tmpReadFileTypeOfTransformation;
381 void readDimSpc(FILE *pFile, bool interactiveOption);
384 /*DECLARE_CLASS(wxContourMainFrame)
385 // any class wishing to process wxWindows events must use this macro
386 DECLARE_EVENT_TABLE()*/
387 bool _creatingContoursActive;
388 ////////JCP 21 - 11 - 08
389 void createContour( int typeContour );
390 //manualContourModel * factoryManualContourModel(int typeContour);
391 manualBaseModel * factoryManualContourModel(wxPanel* panel);
392 ContourExtractData *_contourextractdata;
395 void loadState(std::string filename);
397 // void loadContours( FILE *pFile, bool staticContour );
399 void saveFileWithContours( std::string filename );
400 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
401 void SetZForAllContours(int pz);
405 std::string stundoredo;
408 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
410 wxPanel *calibrationPanel;
411 wxPanel *calibrationPanelError;
412 double _onePixelSize;
413 std::string _imageLocation;
414 std::string _fileLocation;
415 //------------------------------------------------------------------------------------------------------------
417 wxFrame *_frameShowResultImages;