]> Creatis software - creaContours.git/blob - lib/Interface_Icons_NDimensions/interfMainPanel.cxx
*** empty log message ***
[creaContours.git] / lib / Interface_Icons_NDimensions / interfMainPanel.cxx
1 #include "interfMainPanel.h"
2
3 /*
4 #include "interfNewContourMenu.h"
5 #include "interfIOMenu.h"
6 #include "interfEditMenu.h"
7 #include "interfDeleteMenu.h"
8 #include "interfToolsMenu.h"
9 #include "interfToolsSpreadPanel.h"
10 #include "interfMenuBar.h"
11 #include "interfSegmentationMenu.h"
12 */
13
14 interfMainPanel* interfMainPanel::interfmainpanel=NULL;
15 wxFrame* interfMainPanel::_newframe=NULL;
16
17 interfMainPanel::interfMainPanel(wxWindow * parent, int sizex, int sizey, wxEvtHandler * evtHandler, std::string datadir)
18 : wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN)
19 {
20
21         PANEL                   = "New Contour";
22         PANEL1                  = "I/O";
23         PANEL2                  = "Edit";
24         PANEL3                  = "Delete";
25         PANEL4                  = "Tools";  
26         PANEL5                  = "Segmentation";
27         segmentPanel            = NULL;
28         segmentPanelITK         = NULL;
29         configPanel             = NULL;
30         spreadPanel             = NULL;
31         infoWin                 = NULL;
32         infoPanel               = NULL;
33         infoPanelMask           = NULL;
34         informationPanel        = NULL;
35         mirrorPanel             = NULL;
36         thresholdPanel          = NULL;
37         currentWindow           = NULL;
38
39 //CMRU 17-08-09 ------------------------------------------------------------------
40         infoPanelCalibration = NULL;
41         panelAux = NULL;
42 //--------------------------------------------------------------------------------
43         splitterwindow = new wxSplitterWindow(this,-1, wxDefaultPosition, wxSize(sizex, sizey), wxSP_3DSASH, wxString(_T("")));
44
45         splitterwindow->SetMinimumPaneSize( 10 );
46         sizey = sizey/8;
47
48         wxPanel* toolpanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
49
50         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(6,2,1,1);      
51         toolpanel->SetSizer(flexsizer, true);
52         toolpanel->SetAutoLayout( true );
53
54         wxButton* b = getButton(toolpanel);
55         b->SetClientData(&PANEL);
56         wxButton* b1 = getButton(toolpanel);
57         b1->SetClientData(&PANEL1);
58         wxButton* b2 = getButton(toolpanel);
59         b2->SetClientData(&PANEL2);
60         wxButton* b3 = getButton(toolpanel);
61         b3->SetClientData(&PANEL3);
62         wxButton* b4 = getButton(toolpanel);
63         b4->SetClientData(&PANEL4);
64         wxButton* b5 = getButton(toolpanel);
65         b5->SetClientData(&PANEL5);
66
67         wxPanel* mentex  = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
68         wxPanel* mentex1 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
69         wxPanel* mentex2 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
70         wxPanel* mentex3 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
71         wxPanel* mentex4 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
72         wxPanel* mentex5 = new wxPanel(toolpanel, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxString(_T("")));
73         
74         menubar  = new interfNewContourMenu  (mentex,  sizex, sizey, evtHandler, datadir);              
75         menubar1 = new interfIOMenu          (mentex1, sizex, sizey, evtHandler, datadir);      
76         menubar2 = new interfEditMenu        (mentex2, sizex, sizey, evtHandler, datadir);      
77         menubar3 = new interfDeleteMenu      (mentex3, sizex, sizey, evtHandler, datadir);      
78         menubar4 = new interfToolsMenu       (mentex4, sizex ,sizey, evtHandler, datadir);
79         menubar5 = new interfSegmentationMenu(mentex5, sizex, sizey, evtHandler, datadir);
80                 
81         statictext  = getText(mentex,  PANEL);  
82         statictext1 = getText(mentex1, PANEL1); 
83         statictext2 = getText(mentex2, PANEL2); 
84         statictext3 = getText(mentex3, PANEL3); 
85         statictext4 = getText(mentex4, PANEL4); 
86         statictext5 = getText(mentex5, PANEL5); 
87         
88         flexsizer->Add(b, wxFIXED_MINSIZE);
89         flexsizer->Add(setMenuTextSizer(mentex, menubar,statictext), wxFIXED_MINSIZE);
90
91         flexsizer->Add(b1, wxFIXED_MINSIZE);
92         flexsizer->Add(setMenuTextSizer(mentex1, menubar1,statictext1), wxFIXED_MINSIZE);
93         
94         flexsizer->Add(b2, wxFIXED_MINSIZE);
95         flexsizer->Add(setMenuTextSizer(mentex2, menubar2,statictext2), wxFIXED_MINSIZE);
96         
97         flexsizer->Add(b3, wxFIXED_MINSIZE);
98         flexsizer->Add(setMenuTextSizer(mentex3, menubar3,statictext3), wxFIXED_MINSIZE);
99         
100         flexsizer->Add(b4, wxFIXED_MINSIZE);
101         flexsizer->Add(setMenuTextSizer(mentex4, menubar4,statictext4), wxFIXED_MINSIZE);
102
103         flexsizer->Add(b5, wxFIXED_MINSIZE);
104         flexsizer->Add(setMenuTextSizer(mentex5, menubar5,statictext5), wxFIXED_MINSIZE);
105
106         toolpanel->Update();
107         toolpanel->Layout();
108
109         infoPanel = new wxPanel(splitterwindow, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
110         wxFlexGridSizer* infosizer = new wxFlexGridSizer(1,1,2,2);      
111         infoPanel->SetSizer(infosizer, true);
112         infoPanel->SetAutoLayout( true );       
113
114         splitterwindow->Initialize(toolpanel);
115         splitterwindow->SetSashGravity(1);
116         splitterwindow->SplitHorizontally(toolpanel, infoPanel);        
117
118         Connect(b->GetId(),  wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
119         Connect(b1->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
120         Connect(b2->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
121         Connect(b3->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
122         Connect(b4->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
123         Connect(b5->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&interfMainPanel::onActionButtonPressed1);
124
125         this->Layout();
126 }
127
128 interfMainPanel::~interfMainPanel(void)
129 {
130
131 }
132
133 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, std::string datadir, wxEvtHandler * evtHandler)
134 {
135         _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT);
136                                                                                                                                                                 
137         if(interfmainpanel == NULL){
138                 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler, datadir);
139         }
140         _newframe->Show(TRUE);
141         return interfmainpanel;
142 }
143
144 interfMainPanel* interfMainPanel::getInstance(wxWindow* parent, wxEvtHandler * evtHandler)
145 {       
146
147         _newframe = new wxFrame(parent, -1, wxT(" Contour Tools "), wxPoint(25,50), wxSize(350,900),wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
148
149         if(interfmainpanel == NULL){
150                 interfmainpanel = new interfMainPanel(_newframe, 350, 900, evtHandler);
151         }
152         _newframe->Show(TRUE);
153         return interfmainpanel;
154 }
155
156 bool interfMainPanel::Show(bool show)
157 {
158         return _newframe->Show(show);
159 }
160
161 interfMainPanel* interfMainPanel::getInstance()
162 {       
163         return interfmainpanel;
164 }
165
166 void interfMainPanel :: resetInstance()
167 {
168         //delete interfmainpanel;
169         delete _newframe;
170         interfmainpanel = NULL;
171 }
172
173 wxPanel* interfMainPanel::initializeToolsPanel(wxWindow* parent, int sizex, int sizey, wxEvtHandler * evtHandler)
174 {
175         wxPanel* panel = new wxPanel(parent, -1, wxDefaultPosition, wxSize(sizex, sizey), wxBORDER_SUNKEN, wxString(_T("Spread")));
176
177         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2)       ;
178         panel->SetSizer(flexsizer, true);
179         panel->SetAutoLayout( true );
180
181         interfToolsMenu* menu = new interfToolsMenu(panel, sizex, sizey, evtHandler);
182         toolspread = new interfToolsSpreadPanel(panel, sizex, 300, evtHandler);
183
184         flexsizer->Add(menu, wxFIXED_MINSIZE);
185         flexsizer->Add(toolspread, wxFIXED_MINSIZE);
186
187         panel->Layout();
188
189         return panel;
190 }
191
192 /**
193 **      Adds a new checkbox to the scrolledwindow using the checkboxsizer
194 **      @Params id of contour
195 **      
196 **/
197 void interfMainPanel::addContourCheckBox(std::string id)
198 {
199         toolspread->addContourCheckBox(id);
200 }
201
202 /**
203 **      Removes a checkbox from the list of checkboxes in the flexsizer (checkboxsizer)
204 **      @Params id of contour
205 **      
206 **/
207 void interfMainPanel::removeContourCheckBox(std::string id)
208 {
209         toolspread->removeContourCheckBox(id);
210 }
211
212 void interfMainPanel::onActionButtonPressed1( wxCommandEvent& event )
213 {
214         //((interfToolsMenu*)menubar4)->hideAxis();
215         wxButton* b = (wxButton*)event.GetEventObject();
216         wxPanel* dmenu;
217         wxStaticText* text;
218         std::string dstring = *((std::string*) b->GetClientData());
219         int sizechange=0;
220
221         if(dstring.compare(PANEL)==0){
222                 dmenu = menubar;
223                 text = statictext;
224         }else if(dstring.compare(PANEL1)==0 ){
225                 dmenu = menubar1;       
226                 text = statictext1;
227         }else if(dstring.compare(PANEL2)==0){
228                 dmenu = menubar2;
229                 text = statictext2;
230         }else if(dstring.compare(PANEL3)==0){
231                 dmenu = menubar3;
232                 text = statictext3;
233         }else if(dstring.compare(PANEL4)==0){
234                 dmenu = menubar4;
235                 text = statictext4;
236         }else if(dstring.compare(PANEL5)==0){
237                 dmenu = menubar5;
238                 text = statictext5;
239         }
240
241         if(wxStrcmp(b->GetLabel(),_T("+"))==0 ){
242                 dmenu->Show(true);
243                 sizechange = 1;
244                 b->SetLabel(_T("-"));
245         }else{
246                 dmenu->Show(false);             
247                 sizechange = -1;
248                 b->SetLabel(_T("+"));
249         }       
250         
251         sizechange *= dmenu->GetSize().GetHeight();
252         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+sizechange);
253         
254         this->Layout();
255         this->Refresh();
256 }
257
258 wxStaticText* interfMainPanel::getText(wxWindow* parent, std::string nom)
259 {
260         return new wxStaticText(parent, -1, wxString(nom.c_str(),wxConvUTF8), wxDefaultPosition, 
261                                         wxDefaultSize, wxALIGN_CENTRE, wxString(nom.c_str(),wxConvUTF8));
262 }
263
264 wxButton* interfMainPanel::getButton(wxWindow* parent)
265 {
266         wxButton* b = new wxButton(parent, -1, wxString(_T("-")), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, 
267                                         wxDefaultValidator, wxString(_T("-"))); 
268         return b;
269 }
270
271 wxPanel* interfMainPanel::setMenuTextSizer(wxWindow* parent, wxPanel* panel, wxStaticText* text)
272 {
273
274         wxFlexGridSizer* flexsizer = new wxFlexGridSizer(2,1,2,2);      
275         parent->SetSizer(flexsizer, true);
276         parent->SetAutoLayout( true );
277
278         flexsizer->Add(text, wxFLEX_GROWMODE_ALL);
279         flexsizer->Add(panel, wxFLEX_GROWMODE_ALL);
280
281         parent->Layout();
282         return (wxPanel*)parent;
283 }
284
285 /**
286 **      Shows the panel in the 
287 **/
288 void interfMainPanel::showPanel(wxWindow* panel)
289 {
290         wxContourMainFrame::getInstance()->showAxis(false);
291         wxSizer* sizer = infoPanel->GetSizer();
292
293         if(currentWindow != NULL){
294                 currentWindow->Hide();
295                 sizer->Remove(currentWindow);
296         }       
297         sizer->Add(panel);
298         currentWindow = panel;
299         currentWindow->Show(true);
300
301         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
302         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
303
304         infoPanel->Layout();
305         infoPanel->Refresh();
306         this->Layout();
307         this->Refresh();
308 }
309
310 /**
311 **      Hide the panel in the lower box
312 **/
313 void interfMainPanel::hidePanel( )
314 {
315         wxContourMainFrame::getInstance()->showAxis(false);
316         wxSizer* sizer = infoPanel->GetSizer();
317
318         if(currentWindow != NULL){
319                 currentWindow->Hide();
320                 sizer->Remove(currentWindow);
321         }
322         wxPanel * emptyPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
323         sizer->Add(emptyPanel);
324         currentWindow = emptyPanel;
325         currentWindow->Show(true);
326
327         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()+1);
328         splitterwindow->SetSashPosition(splitterwindow->GetSashPosition()-1);
329
330         infoPanel->Layout();
331         infoPanel->Refresh();
332         this->Layout();
333         this->Refresh();
334 }
335
336 /**
337 **      Gets the Information panel
338 **/
339 wxPanel* interfMainPanel::getInfoPanel()
340 {
341         return infoPanel;
342 }
343
344 void interfMainPanel::onCreateContourSpline( )
345 {
346         wxContourMainFrame::getInstance()->showAxis(false);
347         wxContourMainFrame::getInstance()->onCreateContourSpline();
348 }
349
350 void interfMainPanel::onCreateContourRectangle( )
351 {
352         wxContourMainFrame::getInstance()->showAxis(false);
353     wxContourMainFrame::getInstance()->onCreateContourRectangle();
354 }
355 void interfMainPanel::onCreateContourCircle( )
356 {
357         wxContourMainFrame::getInstance()->showAxis(false);
358     wxContourMainFrame::getInstance()->onCreateContourCircle();
359 }
360
361 void interfMainPanel::onCreateContourLine( )
362 {
363         wxContourMainFrame::getInstance()->showAxis(false);
364     wxContourMainFrame::getInstance()->onCreateContourLine();
365 }
366
367 // RaC 09-09 ---------------------
368 void interfMainPanel::onCreateContourPoints( )
369 {
370         wxContourMainFrame::getInstance()->showAxis(false);
371     wxContourMainFrame::getInstance()->onCreateContourPoints();
372 }
373 // RaC 09-09 ---------------------
374
375 // RaC 10-09 ---------------------
376 void interfMainPanel::onCreateContourPolygon( )
377 {
378         wxContourMainFrame::getInstance()->showAxis(false);
379     wxContourMainFrame::getInstance()->onCreateContourPolygon();
380 }
381 // RaC 10-09 ---------------------
382
383 void interfMainPanel::onCreateContoursBullEye(wxPanel* panBull)
384 {
385         wxContourMainFrame::getInstance()->showAxis(false);
386         wxContourMainFrame::getInstance()->onCreateContourBullEye(panBull);
387 }
388
389 void interfMainPanel::onDeleteContour()
390 {
391         wxContourMainFrame::getInstance()->showAxis(false);
392         wxContourMainFrame::getInstance()->onDeleteContour();
393 }
394
395 void interfMainPanel::onDeleteContoursActSlice()
396 {
397         wxContourMainFrame::getInstance()->showAxis(false);
398         wxContourMainFrame::getInstance()->onDeleteContoursActSlice();
399 }
400
401 void interfMainPanel::onDeleteAllContours()
402 {
403         wxContourMainFrame::getInstance()->showAxis(false);
404         wxContourMainFrame::getInstance()->onDeleteAllContours();
405 }
406
407 void interfMainPanel::onCopy()
408 {
409         wxContourMainFrame::getInstance()->onCopy();
410 }
411
412 void interfMainPanel::onPaste()
413 {
414         wxContourMainFrame::getInstance()->onPaste();
415 }
416
417 void interfMainPanel::onUndo()
418 {
419         wxContourMainFrame::getInstance()->onUndo();
420 }
421
422 void interfMainPanel::onRedo()
423 {
424         wxContourMainFrame::getInstance()->onRedo();
425 }
426
427 void interfMainPanel::onLoad()
428 {
429         wxContourMainFrame::getInstance()->onLoad();
430 }
431
432 void interfMainPanel::onSave()
433 {
434         wxContourMainFrame::getInstance()->onSave();
435 }
436
437 void interfMainPanel::RefreshInterface()
438 {
439         wxContourMainFrame::getInstance()->RefreshInterface();
440 }
441
442 vtkImageData* interfMainPanel::getImageData()
443 {
444         return wxContourMainFrame::getInstance()->getImageData();
445 }
446
447 void interfMainPanel::getImageRange(double  range[2] )
448 {
449         vtkImageData * img = getImageData();
450         img->GetScalarRange(range);
451 }
452
453 void interfMainPanel::onSegmentationOneSlice(int isovalue,int sampling,int method)
454 {
455         wxContourMainFrame::getInstance()->onSegmentationOneSlice(isovalue, sampling, method);
456 }
457
458 void interfMainPanel::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
459 {
460         wxContourMainFrame::getInstance()->onSegmentationOneSliceITK(distance, sigma, alfa, beta, propagation, iterations, inflation);
461 }
462
463 int interfMainPanel::GetImageDataSizeZ()
464 {
465         return wxContourMainFrame::getInstance()->GetImageDataSizeZ();
466 }
467
468 void interfMainPanel::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
469 {
470         wxContourMainFrame::getInstance()->onSegmentationAllSlice(minZ, maxZ,isovalue,sampling,method);
471 }
472
473 void interfMainPanel::setLabelSegmentationPanelVTK(wxString tmpString)
474 {       
475     ((interfSegmentationPanelVTK*)segmentationPanel)->setLabel(tmpString);
476 }
477 void interfMainPanel::onSegmentationPressed()
478 {
479         if(segmentPanel == NULL){
480                 segmentPanel = new wxPanel(getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
481                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
482                 segmentPanel->SetSizer(flexsizer, true);
483                 segmentPanel->SetAutoLayout(true);      
484                 segmentPanel->SetEventHandler(this);
485                 
486                 //wxPanel* panel = contourevent->getSegmentationPanel(segmentPanel);
487                 segmentationPanel = new interfSegmentationPanelVTK(segmentPanel);
488         
489
490                 wxStaticText* stattext = new wxStaticText(segmentPanel, -1, wxString(_T("   Automatic Segmentation   ")), wxDefaultPosition,
491                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
492
493                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
494                 flexsizer->Add(segmentationPanel, wxEXPAND);
495                 segmentPanel->Layout();
496         }
497         showPanel(segmentPanel);
498         wxContourMainFrame::getInstance()->showAxis(true);
499         axisshown = true;
500 }
501
502 void interfMainPanel::onSegmentationPressedITK()
503 {
504     if(segmentPanelITK == NULL){
505                 segmentPanelITK = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
506                         
507
508                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
509                 segmentPanelITK->SetSizer(flexsizer, true);
510                 segmentPanelITK->SetAutoLayout( true ); 
511                 //segmentPanelITK->SetEventHandler(this->contourevent);
512                 
513                 //wxPanel* panel = contourevent->getSegmentationPanelITK(segmentPanelITK);
514                 wxPanel* panel = new interfSegmentationPanelITK(segmentPanelITK);
515         
516                 wxStaticText* stattext = new wxStaticText(segmentPanelITK, -1, wxString(_T("   Automatic ITK Segmentation   ")), wxDefaultPosition,
517                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
518
519                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
520                 flexsizer->Add(panel, wxEXPAND);
521                 segmentPanelITK->Layout();
522         }
523         showPanel(segmentPanelITK);
524         wxContourMainFrame::getInstance()->showAxis(true);
525         axisshown = true;
526 }
527
528 void interfMainPanel::onRigidPressed()
529 {
530         wxContourMainFrame::getInstance()->onRigidPressed();
531 }
532
533 void interfMainPanel::onWidthOfContour(double width)
534 {    
535         wxContourMainFrame::getInstance()->onWidthOfContour(width);
536 }
537
538 int interfMainPanel::getColorWindow()
539 {
540         return wxContourMainFrame::getInstance()->getColorWindow();
541 }
542 int interfMainPanel::getWindowLevel()
543 {
544         return wxContourMainFrame::getInstance()->getWindowLevel();
545 }
546 void interfMainPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
547 {
548         wxContourMainFrame::getInstance()->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
549 }
550
551 void interfMainPanel::onInterpolation(bool interpolate)
552 {
553         wxContourMainFrame::getInstance()->onInterpolation(interpolate);
554 }
555
556
557 void interfMainPanel::onConfigurationPressed()
558 {
559         if(configPanel == NULL){
560                 configPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
561                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
562                 configPanel->SetSizer(flexsizer, true);
563                 configPanel->SetAutoLayout( true );     
564                 //configPanel->SetEventHandler(this->contourevent);
565                 wxPanel* panel = new interfConfigurationPanel(configPanel);
566                 wxStaticText* stattext = new wxStaticText(configPanel, -1, wxString(_T("   Interface Configuration   ")), wxDefaultPosition,
567                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
568                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
569                 flexsizer->Add(panel, wxEXPAND);
570                 configPanel->Layout();
571         }
572         showPanel(configPanel);
573 }
574
575 void interfMainPanel::onSpreadPressed()
576 {
577     if(spreadPanel==NULL){
578
579                 spreadPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
580                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
581                 spreadPanel->SetSizer(flexsizer, true);
582                 spreadPanel->SetAutoLayout( true );     
583                 //spreadPanel->SetEventHandler(this->contourevent);
584                 
585                 //wxPanel* panel = contourevent->getSpreadPanel(spreadPanel);
586                 panelSpread = new interfSpreadPanel(spreadPanel);
587         
588
589                 wxStaticText* stattext = new wxStaticText(spreadPanel, -1, wxString(_T("   Automatic Spread   ")), wxDefaultPosition,
590                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
591
592                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
593                 flexsizer->Add(panelSpread, wxEXPAND);
594                 spreadPanel->Layout();
595         }       
596         showPanel(spreadPanel);
597         //hideAxis();
598 }
599
600 void interfMainPanel::resetAppend()
601 {
602         wxContourMainFrame::getInstance()->resetAppend();
603 }
604
605 void interfMainPanel::onSpreadAdd()
606 {
607         wxContourMainFrame::getInstance()->onSpreadAdd();
608 }
609
610 void interfMainPanel::appendStringSpread(std::string val)
611 {
612     panelSpread->appendStringSpread(val);
613 }
614
615 void interfMainPanel::onSpreadGo(int type)
616 {
617         wxContourMainFrame::getInstance()->onSpreadGo(type);
618 }
619
620 void interfMainPanel::setStringSpread(std::string stringtemp)
621 {
622         panelSpread->setStringSpread(stringtemp);
623 }
624
625 void interfMainPanel::onInformationPressed()
626 {
627         
628         // Statistics frame
629         if(infoWin ==NULL){
630                 infoWin                 = new wxFrame (this, -1,_T("  Statistics  "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION |  wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER  );
631                 infoWin->SetSize( wxSize(825,650) );
632                 
633                 wxSize sizepanel(825,675);
634                 informationPanel        = new interfInformationPanel(infoWin);//contourevent->getInformationPanel(infoWin);
635
636                 wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
637                 sizerPanel -> Add( informationPanel, 1, wxEXPAND ,0);
638
639                 infoWin->SetSizer( sizerPanel );
640                 infoWin->SetAutoLayout( true );
641                 infoWin->Layout();
642                 infoWin->Show();
643         }else {
644
645                 if (infoWin->IsShown()==true)
646                 {
647                         infoWin->Show(false);
648                 } else  {
649                         //contourevent->FillGridWithContoursInformation();
650                         infoWin->Show(true);
651                 }
652         }
653                 
654 //CMRU 29-08-09-----------------------------------------------------------------------------------------------  
655         if(panelAux == NULL)
656         {
657                 panelAux = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
658         }       
659 //------------------------------------------------------------------------------------------------------------
660
661         // mask view control panel
662         if(infoPanelMask == NULL){
663                 infoPanelMask = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
664                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
665                 infoPanelMask->SetSizer(flexsizer, true);
666                 infoPanelMask->SetAutoLayout( true );   
667                 //configPanel->SetEventHandler(this->contourevent);
668                 wxPanel *panel = wxContourMainFrame::getInstance()->getMaskImageViewPanel( infoPanelMask );                             
669                 wxStaticText* stattext = new wxStaticText(infoPanelMask, -1, wxString(_T("   Mask segmentation    ")), wxDefaultPosition,
670                                                                                                   wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
671                 
672                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
673                 
674                 flexsizer->Add(panel, wxEXPAND);
675                 infoPanelMask->Layout();
676                 
677         }
678         
679 //CMRU 29-08-09-----------------------------------------------------------------------------------------------
680         //Calibration panel
681         if(infoPanelCalibration == NULL)
682         {
683                 infoPanelCalibration = new wxPanel(panelAux, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER , wxString(_T("")));
684                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
685                 infoPanelCalibration->SetSizer(flexsizer, true);
686                 infoPanelCalibration->SetAutoLayout( true );    
687
688                 wxPanel *panel = new interfCalibrationPanel(infoPanelCalibration);
689                 wxStaticText* stattext = new wxStaticText(infoPanelCalibration, -1, wxString(_T("              Calibration               ")), wxDefaultPosition,
690                                                                                                   wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
691                 
692                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
693                 
694                 flexsizer->Add(panel, wxEXPAND);
695                 infoPanelCalibration->Layout();
696         }
697
698         wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
699         panelAux->SetSizer(sizer, true);
700         panelAux->SetAutoLayout( true );        
701         sizer->Add(infoPanelMask);
702         sizer->Add(infoPanelCalibration);
703         
704         showPanel(panelAux);
705
706 //------------------------------------------------------------------
707
708         wxContourMainFrame::getInstance()->changeInstant();
709 }
710
711 void interfMainPanel::getInstantVector(std::vector<int>& tempVector)
712 {
713         wxContourMainFrame::getInstance()->getInstantVector(tempVector);
714 }
715
716 std::vector<std::string> interfMainPanel::getOutlinesName(int slide)
717 {
718         return wxContourMainFrame::getInstance()->getOutlinesName(slide);
719 }
720
721 void interfMainPanel::onInformationContourLabels(int typeContourGroup,int selection,int minZ,int maxZ,int grayRangeMin,int grayRangeMax){
722         wxContourMainFrame::getInstance()->onInformationContourLabels(typeContourGroup, selection, minZ, maxZ,grayRangeMin,grayRangeMax);
723 }
724
725 void interfMainPanel::setStringInfoPanel(wxString tmpString)
726 {
727         if(informationPanel!=NULL){
728                 ((interfInformationPanel*)informationPanel)->setStringInfoPanel(tmpString);
729         }
730 }
731
732 void interfMainPanel::setRowLabelInfoPanel(int z, wxString tempString)
733 {
734         ((interfInformationPanel*)informationPanel)->setRowLabelInfoPanel(z, tempString);
735 }
736
737 int interfMainPanel::getNumberColsInformationPanel()
738 {
739         return ((interfInformationPanel*)informationPanel)->getNumberCols();
740 }
741
742 void interfMainPanel::appendColsInformationPanel(int _numberOfVariablesStatistics)
743 {
744         ((interfInformationPanel*)informationPanel)->appendCols(_numberOfVariablesStatistics);
745 }
746
747 void interfMainPanel::setCellValueInfoPanel(int z,int tmpIntA,wxString tempString)
748 {
749         ((interfInformationPanel*)informationPanel)->setCellValue(z, tmpIntA, tempString);
750 }
751
752 void interfMainPanel::setColLableInfoPanel(int tmpIntB,wxString tmpTitleString)
753 {
754         ((interfInformationPanel*)informationPanel)->setColLabel(tmpIntB, tmpTitleString);
755
756 }
757
758 void interfMainPanel::SetScalarRange(int grayRangeMin,int grayRangeMax)
759 {
760         wxContourMainFrame::getInstance()->SetScalarRange(grayRangeMin, grayRangeMax); 
761 }
762
763 void interfMainPanel::onSaveResults(std::string directory,std::string namefile, std::string filename, 
764                                                                         int typeContourGroup, int selection, int minZ, int maxZ ,bool XYZValues, bool contourImage, bool statistics)
765 {
766         wxContourMainFrame::getInstance()->onSaveResults(directory, namefile, filename, 
767                 typeContourGroup, selection, minZ,maxZ, XYZValues, contourImage, statistics);
768 }
769
770 wxString interfMainPanel::getCellValue(int j,int i){
771         return ((interfInformationPanel*)informationPanel)->getCellValue(j, i );
772 }
773
774 void interfMainPanel::onSnakePressed()
775 {
776         axisshown=false;
777         wxContourMainFrame::getInstance()->showAxis(axisshown);
778         wxContourMainFrame::getInstance()->onSnakePressed();
779 }
780
781 void interfMainPanel::onMirrorPressed(){
782     if(mirrorPanel==NULL)
783         {
784
785                 mirrorPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC, wxString(_T("")));
786                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
787                 mirrorPanel->SetSizer(flexsizer, true);
788                 mirrorPanel->SetAutoLayout( true );     
789                 panelMirror = new interfMirrorPanel(mirrorPanel);
790         
791                 wxStaticText* stattext = new wxStaticText(mirrorPanel, -1, wxString(_T("   Mirroring Tool   ")), wxDefaultPosition,
792                         wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
793
794                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
795                 flexsizer->Add(panelMirror, wxEXPAND);
796                 mirrorPanel->Layout();
797
798                 refLineShown=true;
799                 wxContourMainFrame::getInstance()->referenceLine();
800         }       
801
802         else
803         {
804
805                 if (!refLineShown)
806                 {
807                         wxContourMainFrame::getInstance()->refLineShow();
808                         refLineShown=true;
809                 }
810         }
811
812         showPanel(mirrorPanel);
813 }
814
815 void interfMainPanel::onMirror()
816 {
817         wxContourMainFrame::getInstance()->onMirror();
818 }
819
820 void interfMainPanel::onMirrorAxisShow()
821 {
822         if (!refLineShown)
823         {
824                 wxContourMainFrame::getInstance()->refLineShow();
825                 refLineShown=true;
826         }
827 }
828
829 void interfMainPanel::onMirrorAxisHide()
830 {
831         if (refLineShown)
832         {
833                 wxContourMainFrame::getInstance()->refLineHide();
834                 refLineShown=false;
835         }
836 }
837
838 void interfMainPanel::onMirrorChangeWidth(int width)
839 {
840         wxContourMainFrame::getInstance()->refLineChangeWidth(width);
841 }
842
843
844
845 //EED01
846 void interfMainPanel::onThresholdPressed()
847 {
848         
849         // Threshold view control panel
850         if(thresholdPanel == NULL){
851                 thresholdPanel = new wxPanel(interfMainPanel::getInstance()->getInfoPanel(), -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, wxString(_T("")));
852                 wxFlexGridSizer* flexsizer = new wxFlexGridSizer(1);    
853                 thresholdPanel->SetSizer(flexsizer, true);
854                 thresholdPanel->SetAutoLayout( true );  
855                 //configPanel->SetEventHandler(this->contourevent);
856                 wxPanel *panel = wxContourMainFrame::getInstance()->getThresholdImageViewPanel( thresholdPanel );                               
857                 wxStaticText* stattext = new wxStaticText(thresholdPanel, -1, wxString(_T("   Threshold segmentation    ")), wxDefaultPosition,
858                                                                                                   wxDefaultSize, wxALIGN_CENTRE|wxBORDER_SIMPLE|wxFULL_REPAINT_ON_RESIZE, wxString(_T("")));
859                 
860                 flexsizer->Add(stattext,wxALIGN_CENTER | wxALIGN_CENTRE);
861                 
862                 flexsizer->Add(panel, wxEXPAND);
863                 thresholdPanel->Layout();
864                 
865         }
866         showPanel(thresholdPanel);
867         wxContourMainFrame::getInstance()->changeInstant();
868 }
869
870
871 void interfMainPanel::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
872 {
873         wxContourMainFrame::getInstance()->ShowResultImages(typeContourGroup, selection, minZ, maxZ);
874 }
875
876
877 void interfMainPanel::SetContourGroup(int contourGroup)
878 {
879         wxContourMainFrame::getInstance()->SetContourGroup( contourGroup);
880 }
881
882 //CMRU 17-08-09 ---------------------------------------------
883 void interfMainPanel::onPrintLabel () 
884 {
885         wxString label;
886         manualBaseModel* manualModel = wxContourMainFrame::getInstance()->getContour();
887
888         if(manualModel==NULL)
889         {
890         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a Contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
891                 dial->ShowModal();
892                 return;
893         }
894
895         wxTextEntryDialog* dialog = new wxTextEntryDialog(this,_T("Enter a tag name: ")) ;
896         
897         if (dialog->ShowModal() == wxID_OK)
898         {
899                 label = dialog->GetValue(); 
900
901                 if(label.Len()!=0)
902                 {
903                         wxContourMainFrame::getInstance()->onPrintLabel(label,manualModel);
904                         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The tag name was updated"), wxT("Information"), wxOK | wxICON_INFORMATION);
905                         dial->ShowModal();
906                 }
907                 else
908                 {
909                         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a valid tag"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
910                         dial->ShowModal();
911                 }
912         }
913 }
914
915 void interfMainPanel::onCalibration(wxString size, int unit)
916 {
917         int type = 0;
918         double contourSize = 0.0; 
919         double realSizeDouble = 0.0;
920
921         type = wxContourMainFrame::getInstance()->getType(); 
922         contourSize = wxContourMainFrame::getInstance()->getContourSizeInPixels();
923
924         std::cout<<"Cata->TamaƱo del contorno en pixeles:"<<contourSize<<endl;
925         
926         if ( type == 6 ) 
927         {
928                 if (size.ToDouble(&realSizeDouble))
929                 {
930                         if(unit==1)
931                         {
932                                 realSizeDouble = realSizeDouble * 10;
933                         }
934                         if(unit==2)
935                         {
936                                 realSizeDouble = realSizeDouble * 25.4;
937                         }
938                         std::cout<< "Valor del usuario" << realSizeDouble<< endl ; 
939                         onePixelSize (realSizeDouble,contourSize);
940                  }
941                  else
942                  {
943                         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please enter a numeric value"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
944                         dial->ShowModal();
945                  }              
946         }
947         else 
948         {
949                 wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Please select a line contour"), wxT("Warning"), wxOK | wxICON_EXCLAMATION);
950                 dial->ShowModal();
951         }
952         
953         wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("The calibration was made"), wxT("Information"), wxOK | wxICON_INFORMATION);
954         dial->ShowModal();
955         std::cout<< "Cata-> Se ha realizado la calibracion" << endl ;
956 }
957
958 double interfMainPanel::onePixelSize (double realSize,double sizePixel) 
959 {
960         _pixelValue = realSize/sizePixel;
961         std::cout<< "Valor del un pixel = " << _pixelValue<< endl ;
962         wxContourMainFrame::getInstance()->onePixelSize (_pixelValue);
963         return _pixelValue ;
964 }
965
966 double interfMainPanel::GetPixelValue()
967 {
968         return _pixelValue;
969 }
970 //------------------------------------------------------------------------------------------------------------