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"
43 //#include "ContourThing.h"
44 //#include "AxeThing.h"
45 //#include "ImageSourceThing.h"
46 //#include "ImageSectionThing.h"
47 //#include "InstantMembersNameList.h"
48 //#include "OutlineGroup.h"
49 //#include "SomeEnvironment.h"
50 //#include "ContourWorkspace.h"
51 //#include "ContourWrap_ViewControl.h"
52 //#include "Instant.h"
53 //#include "PerformingOperation.h"
55 //#include "ContourThing.h"
57 //#include "OutlineModelManager.h"
59 //#include "wxContour_ButtonsBar.h"
60 //#include "wxContour_ControlPanel.h"
62 //#include "wxContour_Grid.h"
63 //#include "wxContour_DrawToolsPanel.h"
64 //#include "wxContour_OperationsToolsPanel.h"
65 //#include "wxContour_AutomaticFormsToolsPanel.h"
66 //#include "wxContour_StandardToolsPanel.h"
67 //#include "wxContour_EdtionToolsPanel.h"
68 //#include "wxContour_ListViewPanel.h"
73 #include "itkGeodesicActiveContourLevelSetImageFilter.h"
75 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
76 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
77 #include "itkSigmoidImageFilter.h"
78 #include "itkFastMarchingImageFilter.h"
79 #include "itkRescaleIntensityImageFilter.h"
80 #include "itkBinaryThresholdImageFilter.h"
81 #include "itkZeroCrossingImageFilter.h"
82 #include "itkCastImageFilter.h"
84 #include "itkImageFileWriter.h"
86 #include "itkImageToVTKImageFilter.h"
87 #include "itkVTKImageToImageFilter.h"
90 #include <vtkImageSeedConnectivity.h>
91 #include <vtkImageMarchingCubes.h>
92 #include "vtkContourFilter.h"
93 #include "vtkMarchingContourFilter.h"
94 #include "vtkPolyDataConnectivityFilter.h"
95 #include "vtkCleanPolyData.h"
96 #include "vtkImageReslice.h"
97 #include "vtkMetaImageWriter.h"
98 #include "vtkImageData.h"
99 #include "vtkTransform.h"
101 #include "vtkCamera.h"
102 #include "vtkImageActor.h"
103 #include <vtkImageMapToColors.h>
104 #include <vtkLookupTable.h>
105 #include <vtkCommand.h>
107 //#include "vtkMetaImageReader.h"
109 //------------------------------------------------------------------------------------------------------------
110 // Events declaration
111 //------------------------------------------------------------------------------------------------------------
113 //BEGIN_DECLARE_EVENT_TYPES()
114 //END_DECLARE_EVENT_TYPES()
116 /** file wxContourMainFrame.h */
119 //------------------------------------------------------------------------------------------------------------
121 //------------------------------------------------------------------------------------------------------------
122 class interfMainPanel;
123 class wxContourMainFrame : public wxPanel {
127 //------------------------------------------------------------------------------------------------------------
128 // Constructors & Destructors
129 //------------------------------------------------------------------------------------------------------------
132 wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
133 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/");
135 ~wxContourMainFrame();
137 //------------------------------------------------------------------------------------------------------------
138 // Creational and initialization methods
139 //------------------------------------------------------------------------------------------------------------
141 void setVectImages(std::vector<vtkImageData*> imgs);
143 bool configurePanels( );
145 bool addNewPanel(wxPanel* panel);
147 wxAuiNotebook * createNotebook();
149 void createInstantChooserPanel(wxAuiNotebook * parent);
151 void createViewPanel(wxAuiNotebook * parent);
153 void createInstantChooserPanel(wxWindow * parent);
155 void createViewPanel(wxWindow * parent);
157 void setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel );
159 void getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ);
161 void SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value);
163 void ShowToolsPanel(bool show);
166 // void setButtonsBar( wxContour_ButtonsBar * theButtonsBar );
167 // void setGrid( wxContour_Grid * theGridPanel );
168 // void setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel );
169 // void setOperationsToolsPanel( wxContour_OperationsToolsPanel * theDrawToolsPanel );
170 // void setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel );
171 // void setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel );
172 // void setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel );
173 // void setListViewPanel( wxContour_ListViewPanel * theListViewPanel );
176 ////------------------------------------------------------------------------------------------------------------
177 //// Methods for capturing events
178 ////------------------------------------------------------------------------------------------------------------
181 ////------------------------------------------------------------------------------------------------------------
182 //// Model management methods
183 ////------------------------------------------------------------------------------------------------------------
186 //------------------------------------------------------------------------------------------------------------
187 // Attributes getters and setters
188 //------------------------------------------------------------------------------------------------------------
189 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/");
190 static wxContourMainFrame* getInstance();
191 static void resetInstance();
193 //------------------------------------------------------------------------------------------------------------
194 // Other functional methods
195 //------------------------------------------------------------------------------------------------------------
198 ** This method returns the vector of images selected by the user
199 ** return value std::vector<vtkImageData*>
201 std::vector<vtkImageData*> getVectImages();
204 ** This methods connect the event in the class interfMainPanel with the world of the appli
206 void onCreateContourSpline( );
207 void onCreateContourRectangle( );
208 void onCreateContourCircle( );
209 void onCreateContourLine( );
210 void onCreateContourPoints( );
211 void onCreateContourPolygon( );
212 void onCreateContourBullEye(wxPanel* pan);
213 /////////////////////////////////
214 void onDeleteContour();
215 void deleteContours( std::vector<std::string> keyNamesVector );
216 void deleteContour( std::string theKeyName );
217 void onDeleteContoursActSlice();
218 void onDeleteAllContours();
219 void deleteAllContours();
220 void setConceptValue( std::string name, int value );
221 ConceptDataWrap* getLastConceptData();
222 bool getIfConceptCheckedAt( std::string name, int pos );
224 void changeInstant();
226 int getNamesWrappingSize();
228 std::string getNameWrapping(int i);
230 void updateInstantOutlines();
231 void updateInstantImageData();
232 void updateInstantAxes();
234 void onChangeDeep(int val);
236 ///////////////////////////
241 void createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
242 void createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append );
243 ///////////////////////7
248 void openContours( FILE *pFile, FILE *pFileData, int version, bool staticContour );
250 void RefreshInterface();
252 vtkImageData* getImageData();
254 void onSegmentationOneSlice(int isovalue,int sampling,int method);
255 void onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
256 void SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method );
257 void SegmentationOneSliceITK(int x, int y, int z, wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation);
258 void Mirror( int x, int y, int z, int isovalue, int sampling, int method );
259 int GetImageDataSizeZ();
260 void GetImageDataRange(double *range);
261 void onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method);
264 void referenceLine();
267 void refLineChangeWidth(int width);
273 //====================================================================================================
275 void showAxis(bool show);
277 void onRigidPressed();
279 void onWidthOfContour(double width);
281 int getColorWindow();
282 int getWindowLevel();
284 void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
286 void onInterpolation(bool interpolate);
288 void onChangeInstant(std::string name,int actual);
294 void onSpreadGo(int type);
296 void getInstantVector(std::vector<int>& tempVector);
298 std::vector<std::string> getOutlinesName(int slide);
302 // @param typeContourGroup - int The operation id (AND,OR,XOR,ALL=3)
304 void onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax);
306 void onSaveResults(std::string directory,std::string namefile, std::string filename,
307 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics);
309 void SaveValuesXYZ(std::string directory,std::string namefile, int typeContourGroup);
313 void onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow);
315 void onSnakePressed();
317 void saveFileWithContoursAutomatique();
319 void ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ );
321 wxPanel *getMaskImageViewPanel(wxWindow *parent);
322 void SetContourGroup(int contourGroup);
323 wxPanel *getThresholdImageViewPanel(wxWindow *parent);
326 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
329 * Associates the String parameter with the contour
330 * @param label Label entered by the user
331 * @param manualBaseModel Currently selected contour
333 void onPrintLabel (wxString label, manualBaseModel* manualModel);
336 * Calculates the size of the contour received as a parameter. Uses the measure of a pixel in millimeters.
337 * @param manualBaseModel Currently selected contour
339 void onInsertCalculation(manualBaseModel* manualModel);
342 * Assigns and returns the value of a pixel in millimeters
343 @ param value Measure of the pixel in millimeters
345 double onePixelSize(double value);
348 * Returns the type of the currently selected contour
353 * Returns the size in pixels of the currently selected contour
355 double getContourSizeInPixels();
358 * Returns the currently selected contour. If no contour is selected returns NULL
360 manualBaseModel* getContour();
363 * Returns the Path of the data persistence file
365 std::string GetFileLocation();
368 * Assign a new path to the data persistence file
369 @ param newFileLocation New path of the file
371 void SetFileLocation(std::string newFileLocation);
372 //------------------------------------------------------------------------------------------------------------
374 void SetScalarRange(int grayRangeMin, int grayRangeMax);
376 //------------------------------------------------------------------------------------------------------------
379 //------------------------------------------------------------------------------------------------------------
381 //------------------------------------------------------------------------------------------------------------
384 //------------------------------------------------------------------------------------------------------------
386 //------------------------------------------------------------------------------------------------------------
390 static wxContourMainFrame* instance;
392 KernelManagerContour* kernelManager;
394 interfMainPanel* _pannew;
396 PerformingOperation* _performingOperation;
398 std::string _datadir;
400 wxContourViewPanel* _theViewPanel;
402 wxInstantChooserPanel * _instantPanel;
404 //AD: 03-09: This attributes represents the reference line that is going to be used for the mirroring
405 manualLineControler * _refLineControl;
406 manualContourModelLine * _refLineModel;
407 manualViewLine * _refLineView;
412 wxAuiNotebook * notebook;
414 long m_notebook_style;
415 long m_notebook_theme;
416 int _numberOfVariablesStatistics;
419 // Contour Image Mask
420 ThresholdImageView *_viewMaskImage;
421 ThresholdImageViewPanel *_viewMaskImagePanel;
424 ThresholdImageView *_viewThresholdImage;
425 ThresholdImageViewPanel *_viewThresholdImagePanel;
428 std::vector<vtkImageData*> _images;
436 /*DECLARE_CLASS(wxContourMainFrame)
437 // any class wishing to process wxWindows events must use this macro
438 DECLARE_EVENT_TABLE()*/
439 bool _creatingContoursActive;
440 ////////JCP 21 - 11 - 08
441 void createContour( int typeContour );
443 //manualContourModel * factoryManualContourModel(int typeContour);
445 manualBaseModel * factoryManualContourModel(wxPanel* panel);
447 ContourExtractData *_contourextractdata;
451 void loadState(std::string filename);
452 void loadContours( FILE *pFile, bool staticContour );
454 void saveFileWithContours( std::string filename );
455 void onLoadContours(std::string fileNameContourROI);
459 std::string stundoredo;
464 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
466 wxPanel *calibrationPanel;
467 wxPanel *calibrationPanelError;
468 double _onePixelSize;
469 std::string _imageLocation;
470 std::string _fileLocation;
471 //------------------------------------------------------------------------------------------------------------