1 #ifndef __wxContourMainFrame_h_INCLUDED_H__
2 #define __wxContourMainFrame_h_INCLUDED_H__
5 // -----------------------------------------------------------------------------------------------------------
6 // WX headers inclusion.
7 // For compilers that support precompilation, includes <wx/wx.h>.
8 // -----------------------------------------------------------------------------------------------------------
10 #include <wx/wxprec.h>
19 //------------------------------------------------------------------------------------------------------------
21 //------------------------------------------------------------------------------------------------------------
22 #include "wx/aui/aui.h"
24 #include "interfMainPanel.h"
25 #include "KernelManagerContour.h"
27 //#include "wxVtkBaseView_SceneManager.h"
28 #include "wxInstantChooserPanel.h"
29 #include "wxContourViewPanel.h"
31 //#include "ContourWorkspace.h"
32 #include "ContourExtractData.h"
33 #include "PerformingOperation.h"
35 #include "manualLineControler.h"
36 #include "manualContourModelLine.h"
37 #include "manualViewLine.h"
39 #include "ThresholdImageView.h"
40 #include "ThresholdImageViewPanel.h"
41 #include "ColorLayerImageView.h"
42 #include "ColorLayerImageViewPanel.h"
47 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
49 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
50 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
51 #include "itkSigmoidImageFilter.h"
52 #include "itkFastMarchingImageFilter.h"
53 #include "itkRescaleIntensityImageFilter.h"
54 #include "itkBinaryThresholdImageFilter.h"
55 #include "itkZeroCrossingImageFilter.h"
56 #include "itkCastImageFilter.h"
58 //EED10JUIN2011 #include "itkImageFileWriter.h"
60 #include "itkImageToVTKImageFilter.h"
61 #include "itkVTKImageToImageFilter.h"
64 #include <vtkImageSeedConnectivity.h>
65 #include <vtkImageMarchingCubes.h>
66 #include "vtkContourFilter.h"
67 #include "vtkMarchingContourFilter.h"
68 #include "vtkPolyDataConnectivityFilter.h"
69 #include "vtkCleanPolyData.h"
70 #include "vtkImageReslice.h"
71 #include "vtkMetaImageWriter.h"
72 #include "vtkImageData.h"
73 #include "vtkTransform.h"
75 #include "vtkCamera.h"
76 #include "vtkImageActor.h"
77 #include <vtkImageMapToColors.h>
78 #include <vtkLookupTable.h>
79 #include <vtkCommand.h>
81 //#include "vtkMetaImageReader.h"
83 //------------------------------------------------------------------------------------------------------------
85 //------------------------------------------------------------------------------------------------------------
87 //BEGIN_DECLARE_EVENT_TYPES()
88 //END_DECLARE_EVENT_TYPES()
90 /** file wxContourMainFrame.h */
93 //------------------------------------------------------------------------------------------------------------
95 //------------------------------------------------------------------------------------------------------------
96 class interfMainPanel;
97 class wxContourMainFrame : public wxPanel {
101 //------------------------------------------------------------------------------------------------------------
102 // Constructors & Destructors
103 //------------------------------------------------------------------------------------------------------------
106 wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
107 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/");
109 ~wxContourMainFrame();
111 //------------------------------------------------------------------------------------------------------------
112 // Creational and initialization methods
113 //------------------------------------------------------------------------------------------------------------
115 void setVectImages(std::vector<vtkImageData*> imgs);
117 bool configurePanels( );
119 bool addNewPanel(wxPanel* panel);
121 wxAuiNotebook * createNotebook();
123 void createInstantChooserPanel(wxAuiNotebook * parent);
125 void createViewPanel(wxAuiNotebook * parent);
127 void createInstantChooserPanel(wxWindow * parent);
129 void createViewPanel(wxWindow * parent);
131 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
133 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
135 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
137 void ShowToolsPanel(bool show);
140 ////------------------------------------------------------------------------------------------------------------
141 //// Methods for capturing events
142 ////------------------------------------------------------------------------------------------------------------
145 ////------------------------------------------------------------------------------------------------------------
146 //// Model management methods
147 ////------------------------------------------------------------------------------------------------------------
150 //------------------------------------------------------------------------------------------------------------
151 // Attributes getters and setters
152 //------------------------------------------------------------------------------------------------------------
153 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/");
154 static wxContourMainFrame* getInstance();
155 static void resetInstance();
157 //------------------------------------------------------------------------------------------------------------
158 // Other functional methods
159 //------------------------------------------------------------------------------------------------------------
162 ** This method returns the vector of images selected by the user
163 ** return value std::vector<vtkImageData*>
165 std::vector<vtkImageData*> getVectImages();
168 ** This methods connect the event in the class interfMainPanel with the world of the appli
170 void onCreateContourSpline( );
171 void onCreateContourRectangle( );
172 void onCreateContourCircle( );
173 void onCreateContourLine( );
174 void onCreateContourPoints( );
175 void onCreateContourPolygon( );
176 void onCreateContourBullEye(wxPanel* pan);
177 /////////////////////////////////
178 void onDeleteContour();
179 void deleteContours( std::vector<std::string> keyNamesVector );
180 void deleteContour( std::string theKeyName );
181 void onDeleteContoursActSlice();
182 void onDeleteAllContours();
183 void deleteAllContours();
184 void setConceptValue( std::string name, int value );
185 ConceptDataWrap* getLastConceptData();
186 bool getIfConceptCheckedAt( std::string name, int pos );
188 void changeInstant();
190 int getNamesWrappingSize();
192 std::string getNameWrapping(int i);
194 void updateInstantOutlines();
195 void updateInstantImageData();
196 void updateInstantAxes();
198 void onChangeDeep(int val);
200 ///////////////////////////
205 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
206 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
207 ///////////////////////7
212 void openContours( FILE *pFile, FILE *pFileData, bool staticContour );
214 void RefreshInterface();
216 vtkImageData* getImageData();
218 void onSegmentationOneSlice(int isovalue,int sampling,int method);
219 void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
220 void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
221 void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
222 void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
223 int GetImageDataSizeZ();
224 void GetImageDataRange(double *range);
225 void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
228 void referenceLine();
231 void refLineChangeWidth(int width);
237 //====================================================================================================
239 void showAxis(bool show);
240 void onRigidPressed();
241 void onWidthOfContour(double width);
242 int getColorWindow();
243 int getWindowLevel();
244 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
245 void onInterpolation(bool interpolate);
246 void onChangeInstant(std::string name,int actual);
249 void onSpreadAddAll();
250 void onSpreadGo(int type);
251 void getInstantVector(std::vector<int>& tempVector);
252 std::vector<std::string> getOutlinesName(int slide);
256 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
258 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
259 void onSaveResults(std::string directory,std::string namefile, std::string filename,
260 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
261 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
262 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
263 void onSnakePressed();
264 void saveFileWithContoursAutomatique();
265 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
266 wxPanel *getMaskImageViewPanel(wxWindow *parent);
267 void SetContourGroup(int contourGroup);
268 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
269 wxPanel *getColorLayerImageViewPanel(wxWindow *parent);
272 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
275 * Associates the String parameter with the contour
276 * @param label Label entered by the user
277 * @param manualBaseModel Currently selected contour
279 void onPrintLabel (wxString label, manualBaseModel* manualModel);
282 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
283 * @param manualBaseModel Currently selected contour
285 void onInsertCalculation(manualBaseModel* manualModel);
288 * Assigns and returns the value of a pixel in millimeters
289 @ param value Measure of the pixel in millimeters
291 double onePixelSize(double value);
294 * Returns the type of the currently selected contour
299 * Returns the size in pixels of the currently selected contour
301 double getContourSizeInPixels();
304 * Returns the currently selected contour. If no contour is selected returns NULL
306 manualBaseModel* getContour();
309 * Returns the Path of the data persistence file
311 std::string GetFileLocation();
314 * Assign a new path to the data persistence file
315 @ param newFileLocation New path of the file
317 void SetFileLocation(std::string newFileLocation);
318 //------------------------------------------------------------------------------------------------------------
320 void SetScalarRange(int grayRangeMin, int grayRangeMax);
322 //------------------------------------------------------------------------------------------------------------
325 //------------------------------------------------------------------------------------------------------------
327 //------------------------------------------------------------------------------------------------------------
330 //------------------------------------------------------------------------------------------------------------
332 //------------------------------------------------------------------------------------------------------------
335 static wxContourMainFrame *instance;
336 KernelManagerContour *kernelManager;
337 interfMainPanel *_pannew;
338 PerformingOperation *_performingOperation;
339 std::string _datadir;
340 wxContourViewPanel *_theViewPanel;
341 wxInstantChooserPanel *_instantPanel;
343 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
344 manualLineControler *_refLineControl;
345 manualContourModelLine *_refLineModel;
346 manualViewLine *_refLineView;
349 wxAuiNotebook *notebook;
350 long m_notebook_style;
351 long m_notebook_theme;
352 int _numberOfVariablesStatistics;
354 // Contour Image Mask
355 ThresholdImageView *_viewMaskImage;
356 ThresholdImageViewPanel *_viewMaskImagePanel;
359 ThresholdImageView *_viewThresholdImage;
360 ThresholdImageViewPanel *_viewThresholdImagePanel;
363 ColorLayerImageView *_viewColorLayerImage;
364 ColorLayerImageViewPanel *_viewColorLayerImagePanel;
365 std::vector<vtkImageData*> _images;
368 // temporary variables readding .roi file
369 int _tmpReadFileImageDim[3];
370 double _tmpReadFileImageSpac[3];
371 int _tmpReadFileTypeOfTransformation;
372 void readDimSpc(FILE *pFile, bool interactiveOption);
375 /*DECLARE_CLASS(wxContourMainFrame)
376 // any class wishing to process wxWindows events must use this macro
377 DECLARE_EVENT_TABLE()*/
378 bool _creatingContoursActive;
379 ////////JCP 21 - 11 - 08
380 void createContour( int typeContour );
381 //manualContourModel * factoryManualContourModel(int typeContour);
382 manualBaseModel * factoryManualContourModel(wxPanel* panel);
383 ContourExtractData *_contourextractdata;
386 void loadState(std::string filename);
388 // void loadContours( FILE *pFile, bool staticContour );
390 void saveFileWithContours( std::string filename );
391 void onLoadContours(std::string fileNameContourROI, bool interactiveInterface);
395 std::string stundoredo;
398 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
400 wxPanel *calibrationPanel;
401 wxPanel *calibrationPanelError;
402 double _onePixelSize;
403 std::string _imageLocation;
404 std::string _fileLocation;
405 //------------------------------------------------------------------------------------------------------------