3 /* Diagrama de Secuaencia de cambiar un instante
4 wxContourEventHandler :: changeInstant()
5 OutlineModelManager :: ->setInstant( _actualInstant );
6 OutlineModelManager :: updateToActualInstant()
7 OutlineModelManager :: getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate)
8 OutlineModelManager :: annotateOutlinesWrap(std::vector<std::string> kNamesVector, std::vector<ContourThing **> theOutlinesVector)
9 wxContourEventHandler :: updateInstantOutlines()
10 OutlineModelManager :: getActualInstantOutlines ()
11 wxVtkBaseView_SceneManager :: addToScene( std::vector< std::string> theKeyNameVector, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
12 wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
13 wxVtkBaseView_SceneManager :: getContourWrap_ViewControlOf
15 void wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
21 \mainpage NDimension with wxWidgets and maracas
23 \section intro Introduction
25 This is the introduction.
34 node [shape=record, fontname=Helvetica, fontsize=10];
36 _wxContourGUIExample [ label="wxContourGUIExample" URL="\ref wxContourGUIExample"];
37 _wxContourEventHandler [ label="wxContourEventHandler" URL="\ref wxContourEventHandler"];
39 _OutlineModelManager [ label="OutlineModelManager" URL="\ref OutlineModelManager"];
40 _wxInstantChooserPanel [ label="wxInstantChooserPanel" URL="\ref wxInstantChooserPanel"];
41 _wxContourViewPanel [ label="wxContourViewPanel" URL="\ref wxContourViewPanel"];
42 _wxContour_ButtonsBar [ label="wxContour_ButtonsBar" URL="\ref wxContour_ButtonsBar"];
43 _OutlineModelManager [ label="OutlineModelManager" URL="\ref OutlineModelManager"];
44 _wxVtkBaseView_SceneManager [ label="wxVtkBaseView_SceneManager" URL="\ref wxVtkBaseView_SceneManager"];
45 _SomeEnvironment [ label="SomeEnvironment" URL="\ref SomeEnvironment"];
48 _wxContourGUIExample -> _wxContourEventHandler [ arrowhead="open", style="dashed" ];
49 _wxContourGUIExample -> _OutlineModelManager [ arrowhead="open", style="dashed" ];
50 _wxContourGUIExample -> _wxInstantChooserPanel [ arrowhead="open", style="dashed" ];
51 _wxContourGUIExample -> _wxContourViewPanel [ arrowhead="open", style="dashed" ];
52 _wxContourGUIExample -> _wxContour_ButtonsBar [ arrowhead="open", style="dashed" ];
53 _wxContourViewPanel -> wxMaracas_N_ViewersWidget [ arrowhead="open", style="dashed" ];
54 _wxContourEventHandler -> _OutlineModelManager [ arrowhead="open", style="dashed" ];
55 _wxContourEventHandler -> _wxVtkBaseView_SceneManager [ arrowhead="open", style="dashed" ];
56 _OutlineModelManager -> _SomeEnvironment [ arrowhead="open", style="dashed" ];
68 //----------------------------------------------------------------------------------------------------------------
69 // Class definition include
70 //----------------------------------------------------------------------------------------------------------------
71 #include "wxContourEventHandler.h"
72 #include <wx/filedlg.h>
73 #include <wx/spinctrl.h>
77 //----------------------------------------------------------------------------------------------------------------
78 // Class implementation
79 //----------------------------------------------------------------------------------------------------------------
80 /** @file wxContourEventHandler.cxx */
83 //------------------------------------------------------------------------------------------------------------
85 //------------------------------------------------------------------------------------------------------------
87 #include "wxContour_ActionCommandsID.h"
88 #include "NameWrapper.h"
89 #include "ConceptDataWrap.h"
90 #include "OutlineGroup.h"
92 #include <manualContour.h>
93 #include "Contour/ContourExtractData.h"
94 #include "ImageSourceThing.h"
96 #include "vtkImageData.h"
97 #include <vtkContourFilter.h>
98 #include <vtkCleanPolyData.h>
99 #include <vtkPolyDataConnectivityFilter.h>
100 #include <vtkStripper.h>
101 #include <vtkImageReslice.h>
102 #include <vtkMetaImageWriter.h>
103 #include <vtkImageMapToWindowLevelColors.h>
107 //------------------------------------------------------------------------------------------------------------
108 //------------------------------------------------------------------------------------------------------------
109 //------------------------------------------------------------------------------------------------------------
111 PanelBullEyeOptions::PanelBullEyeOptions (wxWindow * parent, wxSize size) :
112 wxPanel(parent, -1, wxDefaultPosition, size)
117 wxSize sizepanel(190,300);
118 wxPanel *panel = this;
121 wxString lstOptions[2];
122 lstOptions[0]="General options";
123 lstOptions[1]="Detail options";
124 _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, "General/Detail options", wxDefaultPosition, wxSize(200,45), 2 , lstOptions, 2, wxRA_SPECIFY_COLS);
125 _radioboxBullEyeGenOpt->SetSelection(0);
127 _spinctrlBullEyeNumOfCrowns = new wxSpinCtrl( panel , -1,_T("B"),wxDefaultPosition, wxSize(40,20) );
128 _spinctrlBullEyeNumOfCrowns->SetRange(1,_maxLevels);
129 _spinctrlBullEyeNumOfCrowns->SetValue(3);
131 _spinctrlBullEyeNumOfSec = new wxSpinCtrl( panel , -1,_T("A"),wxDefaultPosition, wxSize(40,20) );
132 _spinctrlBullEyeNumOfSec->SetRange(1,_maxSections);
133 _spinctrlBullEyeNumOfSec->SetValue(5);
136 _sliderBullEyeAngle = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
138 wxFlexGridSizer * sizerGeneralOptions = new wxFlexGridSizer(10);
140 wxFlexGridSizer * sizerGeneralOptionsA = new wxFlexGridSizer(1);
141 wxFlexGridSizer * sizerGeneralOptionsB = new wxFlexGridSizer(1);
142 wxFlexGridSizer * sizerGeneralOptionsC = new wxFlexGridSizer(1);
143 sizerGeneralOptionsA -> Add( new wxStaticText(panel,-1,_T("Crowns")) , 1, wxGROW );
144 sizerGeneralOptionsA -> Add( _spinctrlBullEyeNumOfCrowns , 1/*, wxGROW*/ );
145 sizerGeneralOptionsB -> Add( new wxStaticText(panel,-1,_T("Sections")) , 1, wxGROW );
146 sizerGeneralOptionsB -> Add( _spinctrlBullEyeNumOfSec , 1/*, wxGROW*/ );
147 sizerGeneralOptionsC -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
148 sizerGeneralOptionsC -> Add( _sliderBullEyeAngle , 1/*, wxGROW*/ );
150 sizerGeneralOptions -> Add( sizerGeneralOptionsA , 1/*, wxGROW*/ );
151 sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
152 sizerGeneralOptions -> Add( sizerGeneralOptionsB , 1/*, wxGROW*/ );
153 sizerGeneralOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
154 sizerGeneralOptions -> Add( sizerGeneralOptionsC , 1/*, wxGROW*/ );
157 wxSpinCtrl *tmpSpinSection;
158 wxSlider *tmpSliderRadio;
159 wxSlider *tmpSliderAng;
161 wxFlexGridSizer * sizerDetailOptions = new wxFlexGridSizer(6);
163 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T("Crown ")) , 1, wxGROW );
164 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Sections ")) , 1, wxGROW );
165 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
166 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Radio %")) , 1, wxGROW );
167 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
168 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" Angle")) , 1, wxGROW );
170 wxString tmpwxstring;
172 for (i=0;i<_maxLevels;i++){
173 tmpSpinSection = new wxSpinCtrl( panel , -1,_T(""),wxDefaultPosition, wxSize(40,20) );
174 tmpSliderRadio = new wxSlider( panel , -1 ,0,0,100, wxDefaultPosition, wxSize(110,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
175 tmpSliderAng = new wxSlider( panel , -1 ,0,0,180, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
177 tmpSpinSection ->SetRange(1,_maxSections);
179 tmpwxstring.Printf(_T(" %d. "),i+1);
180 sizerDetailOptions -> Add( new wxStaticText(panel,-1,tmpwxstring) , 1, wxGROW );
181 sizerDetailOptions -> Add( tmpSpinSection, 1 );
182 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
183 sizerDetailOptions -> Add( tmpSliderRadio, 1, wxGROW );
184 sizerDetailOptions -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
185 sizerDetailOptions -> Add( tmpSliderAng, 1, wxGROW );
187 tmpSpinSection -> SetValue(5);
188 tmpSliderRadio -> SetValue( 100-(double)((i)*100.0/_maxLevels) );
189 tmpSliderAng -> SetValue(0);
191 Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
192 Connect( tmpSliderRadio->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
194 _lstBullEyeDetailNumOfSec.push_back( tmpSpinSection );
195 _lstBullEyeDetailRadio.push_back( tmpSliderRadio );
196 _lstBullEyeDetailAngle.push_back( tmpSliderAng );
200 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
201 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
202 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
203 sizer -> Add( _radioboxBullEyeGenOpt , 1, wxGROW );
204 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
205 sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye general options --")) , 1, wxGROW );
206 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
207 sizer -> Add( sizerGeneralOptions , 1, wxGROW );
208 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
209 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
210 sizer -> Add( new wxStaticText(panel,-1,_T(" -- Bull Eye detail options --")) , 1, wxGROW );
211 sizer -> Add( new wxStaticText(panel,-1,_T("")) , 1, wxGROW );
212 sizer -> Add( sizerDetailOptions , 1, wxGROW );
214 Connect( _radioboxBullEyeGenOpt->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
215 Connect( _spinctrlBullEyeNumOfCrowns->GetId(), wxEVT_COMMAND_TEXT_UPDATED , (wxObjectEventFunction) &PanelBullEyeOptions::onRefreshPanel );
217 panel->SetSizer( sizer );
218 panel->SetSize( sizepanel );
219 panel->SetAutoLayout( true );
226 //------------------------------------------------------------------------------------------------------------
227 PanelBullEyeOptions::~PanelBullEyeOptions()
231 //------------------------------------------------------------------------------------------------------------
232 void PanelBullEyeOptions::onRefreshPanel( wxCommandEvent& event )
237 //------------------------------------------------------------------------------------------------------------
238 void PanelBullEyeOptions::RefreshPanel()
242 if (this->_radioboxBullEyeGenOpt->GetSelection()==0){
243 for (i=0; i<_maxLevels; i++)
245 _lstBullEyeDetailNumOfSec[i] -> Enable(false);
246 _lstBullEyeDetailRadio[i] -> Enable(false);
247 _lstBullEyeDetailAngle[i] -> Enable(false);
250 int spinSelec = _spinctrlBullEyeNumOfCrowns->GetValue();
251 for (i=0; i<_maxLevels; i++)
253 ok = (i < spinSelec);
254 _lstBullEyeDetailNumOfSec[i] -> Enable(ok);
255 _lstBullEyeDetailRadio[i] -> Enable(ok);
256 _lstBullEyeDetailAngle[i] -> Enable(ok);
259 if (_lstBullEyeDetailRadio[i]->GetValue() > _lstBullEyeDetailRadio[i-1]->GetValue())
261 _lstBullEyeDetailRadio[i]->SetValue( _lstBullEyeDetailRadio[i-1]->GetValue() );
268 //------------------------------------------------------------------------------------------------------------
269 int PanelBullEyeOptions::GetNumberOfCrowns()
271 return this->_spinctrlBullEyeNumOfCrowns->GetValue();
274 //------------------------------------------------------------------------------------------------------------
275 int PanelBullEyeOptions::GetNumberOfSections(int nCrown)
278 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
280 result = this->_spinctrlBullEyeNumOfSec->GetValue();
282 result = this->_lstBullEyeDetailNumOfSec[nCrown]->GetValue();
287 //------------------------------------------------------------------------------------------------------------
288 int PanelBullEyeOptions::GetRadioOfCrown(int nCrown)
292 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
294 sizeCrowns = (double)( this->_spinctrlBullEyeNumOfCrowns->GetValue() );
295 result = 100.0 * (nCrown+1)/sizeCrowns ;
297 result = this->_lstBullEyeDetailRadio[nCrown]->GetValue();
302 //------------------------------------------------------------------------------------------------------------
303 double PanelBullEyeOptions::GetAngOfCrownSection(int nCrown,int section)
306 if (this->_radioboxBullEyeGenOpt->GetSelection()==0)
308 angle = this->_sliderBullEyeAngle->GetValue();
310 angle = this->_lstBullEyeDetailAngle[nCrown]->GetValue();
312 double numOfSec = (double)GetNumberOfSections(nCrown);
313 double deltaSec = GetAngDeltaOfCrownSection(nCrown);
314 return angle + section*deltaSec ;
317 //------------------------------------------------------------------------------------------------------------
318 double PanelBullEyeOptions::GetAngDeltaOfCrownSection(int nCrown)
320 double numOfSec = (double)GetNumberOfSections(nCrown);
321 return 360.0/numOfSec;
326 //------------------------------------------------------------------------------------------------------------
327 //------------------------------------------------------------------------------------------------------------
328 //------------------------------------------------------------------------------------------------------------
331 //------------------------------------------------------------------------------------------------------------
332 // Constructors & Destructors
333 //------------------------------------------------------------------------------------------------------------
335 wxContourEventHandler ::wxContourEventHandler()
338 _creatingContoursActive = false;
339 _theViewPanel = NULL;
340 _modelManager = NULL;
341 _instantPanel = NULL;
344 _drawToolsPanel = NULL;
345 _operationsToolsPanel = NULL;
346 _autoFormsPanel = NULL;
347 _standardToolsPanel = NULL;
348 _editionToolsPanel = NULL;
349 _listViewPanel = NULL;
350 _sceneManager = NULL;
351 _actualInstant = NULL;
352 _performingOperation = new PerformingOperation();
354 // EED Interface and Spread
356 _segmentationFrame = NULL;
357 _contourPropagation = NULL;
358 _createContourFrame = NULL;
360 _InformationContourFrame = NULL;
361 _interfaceConfigurationFrame = NULL;
363 _wxtextctrlTest = NULL;
364 _panelBullEyeOptions = NULL;
366 fileNameContourROI = "";
367 _numberOfVariablesStatistics=6+1;
371 stundoredo = "data/temp";
372 mkdir(stundoredo.c_str());
373 stundoredo += "/cont";
375 //------------------------------------------------------------------------------------------------------------
376 wxContourEventHandler :: ~ wxContourEventHandler()
378 delete _actualInstant;
379 /*delete _theViewPanel;
380 delete _instantPanel;
382 delete _actualInstant;
384 delete _sceneManager;
385 delete _performingOperation;
389 //------------------------------------------------------------------------------------------------------------
390 // Configuration methods
391 //------------------------------------------------------------------------------------------------------------
393 bool wxContourEventHandler :: configureEventsHandling()
395 bool configured = true;
400 //------------------------------------------------------------------------------------------------------------
401 // Methods for capturing events
402 //------------------------------------------------------------------------------------------------------------
403 void wxContourEventHandler :: onProcessMessage( wxCommandEvent& event )
407 //------------------------------------------------------------------------------------------------------------
409 void wxContourEventHandler :: onActionButtonPressed( wxCommandEvent& event )
411 const char buttonTool = *(char *)event.GetClientData();
412 executeActionCommand( buttonTool );
414 //------------------------------------------------------------------------------------------------------------
415 void wxContourEventHandler :: onChangedDeep ( wxCommandEvent& event )
417 double val = _theViewPanel->getCurrentDeep();
418 _instantPanel->setConceptValue( "Axe Depth", (int)val );
419 _theViewPanel->setActualVertical( (int)val );
423 //------------------------------------------------------------------------------------------------------------
424 void wxContourEventHandler :: onChangeInstant( wxCommandEvent& event )
426 ConceptDataWrap * dataConcept = NULL;
427 if ( _theViewPanel->GetId() == event.GetId() )
429 dataConcept = (ConceptDataWrap *)event.GetClientData();
430 int value = dataConcept->getActualValue();
431 _instantPanel->setConceptValue( dataConcept->getName(), value );
435 dataConcept = _instantPanel->getLastConceptData();
436 if( dataConcept->getName().compare( _theViewPanel->getVerticalConceptName() ) )
438 _theViewPanel->setActualVertical( dataConcept->getActualValue());
439 //_theViewPanel->setVerticalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
441 else if( dataConcept->getName().compare( _theViewPanel->getHorizontalConceptName() ) || _instantPanel->getIfConceptCheckedAt( dataConcept->getName(), 0 ) )
443 _theViewPanel->setHorizontalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
448 //------------------------------------------------------------------------------------------------------------
450 void wxContourEventHandler :: onCreateMultipleROI( wxCommandEvent& event )
452 _creatingContoursActive = !_creatingContoursActive;
453 if( _creatingContoursActive )
458 //------------------------------------------------------------------------------------------------------------
459 void wxContourEventHandler :: onCreateROI( wxCommandEvent& event )
461 if( _creatingContoursActive )
467 //------------------------------------------------------------------------------------------------------------
468 void wxContourEventHandler :: onStopCreateROI( wxCommandEvent& event )
473 //------------------------------------------------------------------------------------------------------------
474 void wxContourEventHandler :: onDeleterROI( wxCommandEvent& event )
478 //------------------------------------------------------------------------------------------------------------
479 void wxContourEventHandler :: onSelectROI( wxCommandEvent& event )
483 //------------------------------------------------------------------------------------------------------------
486 void wxContourEventHandler :: onUnSelectROI( wxCommandEvent& event )
490 //------------------------------------------------------------------------------------------------------------
492 void wxContourEventHandler :: onManualHidedROI( wxCommandEvent& event )
496 //------------------------------------------------------------------------------------------------------------
498 void wxContourEventHandler :: onManualShowedROI( wxCommandEvent& event )
502 //------------------------------------------------------------------------------------------------------------
504 void wxContourEventHandler :: onEditingROI( wxCommandEvent& event )
508 //------------------------------------------------------------------------------------------------------------
510 void wxContourEventHandler :: onMovingROI( wxCommandEvent& event )
515 //------------------------------------------------------------------------------------------------------------
516 // Model management methods
517 //------------------------------------------------------------------------------------------------------------
519 void wxContourEventHandler::onSpreadReset( wxCommandEvent& event )
521 _wxtextctrlSpread->SetValue("");
522 _contourPropagation->resetAppend();
525 //------------------------------------------------------------------------------------------------------------
526 void wxContourEventHandler::onSpreadAdd( wxCommandEvent& event )
528 std::vector<double> vecX;
529 std::vector<double> vecY;
530 std::vector<double> vecZ;
531 _sceneManager->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
534 std::vector<int> tempVector;
535 _instantPanel->getInstant( tempVector );
536 int i,size=vecZ.size();
537 int actualSlice = tempVector[1];
538 for ( i=0 ; i<size ; i++ )
540 vecZ[i] = actualSlice;
543 _contourPropagation->appendContour(&vecX , &vecY , &vecZ);
545 newstring.Printf("%s %d -",_wxtextctrlSpread->GetValue(), actualSlice );
546 _wxtextctrlSpread->SetValue(newstring);
550 //------------------------------------------------------------------------------------------------------------
551 void wxContourEventHandler::onSpreadGo( wxCommandEvent& event )
554 //JCP 20-10-08 Undo redo implementation
556 //JCP 20-10-08 Undo redo implementation
559 int typeMethodFindCtrlPoints=_spreadMethodRadiobox->GetSelection();
560 int typeofcontour = 1;
561 manualContourModel *manModelContour;
562 std::vector<double> vecCtrlPointX;
563 std::vector<double> vecCtrlPointY;
564 std::vector<double> vecCtrlPointZ;
570 std::vector<int> tempVector;
571 _instantPanel->getInstant( tempVector );
574 _contourPropagation->getMaxMinZ(&minZ,&maxZ);
575 //JSTG_16-07-08_----------------------------------------------------------------
576 //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
577 _contourPropagation->setInterpolationNumber(100);
578 _contourPropagation->CalculeSplinePropagation();
580 double totalZ = maxZ-minZ+1;
583 //--------------------------------------------------------------------
584 for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
586 porcent = 100.0* (z-minZ)/totalZ;
587 tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , (int)(z-minZ+1), (int)totalZ,z );
588 _staticTextSpread->SetLabel(tmpString);
590 if (_contourPropagation->ifSliceKeyContourExist(z)==false)
592 manModelContour = factoryManualContourModel( typeofcontour );
593 idTmp = _contourPropagation->FindIdWithZ(z);
594 if (typeMethodFindCtrlPoints==0) // Initial Points
596 _contourPropagation->GetInitialControlPoints( idTmp , &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
598 if (typeMethodFindCtrlPoints==1) // Automatique Method
600 _contourPropagation->GetControlPoints( idTmp ,&vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
602 if (typeMethodFindCtrlPoints==2) // sampling
604 _contourPropagation->GetControlPoints( idTmp , 20.0 ,&vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
606 //--------------------------------------------------------------------
607 sizeCtrPt = vecCtrlPointX.size();
608 for (j=0 ; j<sizeCtrPt ; j++)
610 //JSTG_16-07-08_----------------------------------------------------------------
611 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , -900 );
612 //--------------------------------------------------------------------
617 theName = _modelManager->createOutline( manModelContour, tempVector );
618 bool addedModel = theName.compare("") != 0;
621 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
622 this->_theViewPanel->getSpacing(spc);
623 //Adding the manualContourControler to interface objects structure
624 //Adding the manualViewContour to interface objects structure
625 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
626 _sceneManager->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
628 }// ifSliceKeyContourExist
630 _staticTextSpread->SetLabel(" ");
631 //RefreshInterface();
637 //------------------------------------------------------------------------------------------------------------
638 void wxContourEventHandler :: onSpread( )
640 if (_spreadFrame==NULL)
643 _spreadFrame = new wxFrame (_theViewPanel, -1,_T(" Spread "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
645 wxSize sizepanel(250,400);
646 _spreadFrame->SetSize( sizepanel );
647 _spreadFrame->SetEventHandler( this );
648 wxPanel *panel = getSpreadPanel(_spreadFrame);
649 panel->SetSize(sizepanel);
650 /**new wxPanel(_spreadFrame,-1);
652 wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxSize(80,35) );
653 wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxSize(80,35));
655 wxString lstOptions[3];
659 _spreadMethodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
660 _spreadMethodRadiobox->SetSelection(2);
662 wxButton *spreadGoBtn = new wxButton(panel,-1,_T("Go"),wxDefaultPosition, wxSize(80,35));
663 _staticTextSpread = new wxStaticText(panel,-1,_T(" "));
665 _wxtextctrlSpread = new wxTextCtrl(panel,-1, "",wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE );
667 _spreadFrame->SetEventHandler( this );
668 Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadReset );
669 Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadAdd );
670 Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadGo );
672 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
673 sizer -> Add( spreadResetBtn , 1, wxGROW );
674 sizer -> Add( spreadAddBtn , 1, wxGROW );
675 sizer -> Add( _spreadMethodRadiobox , 1, wxGROW );
676 sizer -> Add( spreadGoBtn , 1, wxGROW );
677 sizer -> Add( _staticTextSpread , 1, wxGROW );
678 sizer -> Add( _wxtextctrlSpread , 1, wxGROW );
681 panel->SetSizer( sizer );
682 panel->SetSize( sizepanel );
683 panel->SetAutoLayout( true );
685 _spreadFrame->Show();
687 if (_spreadFrame->IsShown()==true)
689 _spreadFrame->Show(false);
691 _spreadFrame->Show(true);
696 wxPanel* wxContourEventHandler::getSpreadPanel(wxWindow* parent){
697 //wxPanel *panel = new wxPanel(parent,-1);
699 _contourPropagation = new ContourPropagation();
701 wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString(""));
703 wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxDefaultSize );
704 wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxDefaultSize);
706 wxString lstOptions[3];
710 _spreadMethodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxDefaultSize, 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
711 _spreadMethodRadiobox->SetSelection(2);
713 wxButton *spreadGoBtn = new wxButton(panel,-1,_T("Go"),wxDefaultPosition, wxDefaultSize);
714 _staticTextSpread = new wxStaticText(panel,-1,_T(" "));
716 _wxtextctrlSpread = new wxTextCtrl(panel,-1, "",wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
719 Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadReset );
720 Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadAdd );
721 Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadGo );
723 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
724 sizer -> Add( spreadResetBtn , 1, wxGROW );
725 sizer -> Add( spreadAddBtn , 1, wxGROW );
726 sizer -> Add( _spreadMethodRadiobox , 1, wxGROW );
727 sizer -> Add( spreadGoBtn , 1, wxGROW );
728 sizer -> Add( _staticTextSpread , 1, wxGROW );
729 sizer -> Add( _wxtextctrlSpread , 1, wxGROW );
732 panel->SetSizer( sizer );
733 //panel->SetSize( wxDefaultSize );
734 panel->SetAutoLayout( true );
739 //------------------------------------------------------------------------------------------------------------
740 void wxContourEventHandler::onSegmentationAllSlice( wxCommandEvent& event )
742 //JCP 20-10-08 Undo redo implementation
744 //JCP 20-10-08 Undo redo implementation
747 int x = this->_theViewPanel->GetX();
748 int y = this->_theViewPanel->GetY();
752 minZ=_mbarrange->GetStart();
753 maxZ=_mbarrange->GetEnd();
754 double totalZ = maxZ-minZ+1;
755 for( z=minZ ; z<=maxZ ; z++ )
757 porcent = 100.0* (z-minZ)/totalZ;
758 tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
759 _staticTextSegmentation->SetLabel(tmpString);
760 SegmentationOneSlice( x,y,z );
762 _staticTextSegmentation->SetLabel(" ");
768 //------------------------------------------------------------------------------------------------------------
769 void wxContourEventHandler::onSegmentationOneSlice( wxCommandEvent& event )
771 //JCP 20-10-08 Undo redo implementation
773 //JCP 20-10-08 Undo redo implementation
776 int x = this->_theViewPanel->GetX();
777 int y = this->_theViewPanel->GetY();
778 int z = this->_theViewPanel->GetZ();
779 SegmentationOneSlice( x,y,z );
784 //------------------------------------------------------------------------------------------------------------
785 void wxContourEventHandler::SegmentationOneSlice( int x, int y, int z )
787 int typeofcontour = 1;
788 //--Extracting Contour
789 vtkImageData *imagedata = _sceneManager->GetImageData();
790 // double *range = imagedata->GetScalarRange();
792 int isovalue = _isovalue->GetValue();
793 int sampling = _sampling->GetValue();
795 vtkImageReslice *imageReslice = vtkImageReslice::New();
798 // imagedata->GetSpacing(spc);
803 imageReslice->SetInput( imagedata );
804 imageReslice->SetInformationInput(imagedata);
805 imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
806 imageReslice->SetResliceAxesOrigin(0,0,z);
807 imageReslice->SetOutputDimensionality(2);
808 imageReslice->SetInterpolationModeToLinear();
810 imagedata = imageReslice->GetOutput();
812 imagedata->UpdateInformation();
814 vtkContourFilter* cntVTK = vtkContourFilter::New( );
815 cntVTK->SetInput( imagedata );
817 cntVTK->SetNumberOfContours( 1 );
818 //cntVTK->SetValue( 0, vmin );
819 // cntVTK->SetValue( 0, (range[1]*thr/100) );
820 cntVTK->SetValue( 1, isovalue );
821 // cntVTK->SetValue( 1, vmax );
823 cntVTK->UpdateInformation();
825 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
826 cpd->SetInput( cntVTK->GetOutput( ) );
827 cpd->ConvertLinesToPointsOff( );
829 cpd->UpdateInformation();
831 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
832 conn->SetExtractionModeToClosestPointRegion( );
833 //conn->SetMaxRecursionDepth( 3000 );
835 conn->SetInput( cpd->GetOutput( ) );
837 conn->SetClosestPoint( x, y, 0 );
839 conn->UpdateInformation();
841 vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
842 cpd2->SetInput( conn->GetOutput( ) );
844 cpd2->UpdateInformation();
846 vtkStripper* vtkstripper = vtkStripper::New( );
847 vtkstripper->SetInput( cpd2->GetOutput() );
848 vtkstripper->Update();
849 vtkstripper->UpdateInformation();
852 vtkPolyData* polyDataResult = vtkstripper->GetOutput();
854 polyDataResult->Update( );
855 polyDataResult->UpdateInformation();
859 myfile.open ("c:/temp/example.txt");
861 polyDataResult->Print(myfile);
862 myfile << "-------------------------------------\n";
863 polyDataResult->GetLines()->Print(myfile);
873 //--Calculating control points
875 std::vector<double> vecX;
876 std::vector<double> vecY;
877 std::vector<double> vecZ;
879 std::vector<double> vecCtrlPointX;
880 std::vector<double> vecCtrlPointY;
881 std::vector<double> vecCtrlPointZ;
885 int ii,size=polyDataResult->GetNumberOfPoints();
887 for (ii=1;ii<=size;ii++)
889 id = polyDataResult->GetLines()->GetData()->GetValue(ii);
890 p = polyDataResult->GetPoint(id);
893 vecX.push_back( p[0] );
894 vecY.push_back( p[1] );
895 vecZ.push_back( -900 );
896 // vecZ.push_back( p[2] );
900 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
901 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
904 if (methodRadiobox->GetSelection()==0){
905 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
907 if (methodRadiobox->GetSelection()==1){
908 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
910 if (methodRadiobox->GetSelection()==2){
911 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
912 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
915 //--Adding contour to the system
917 std::vector<int> actualInstantVector;
918 _instantPanel->getInstant( actualInstantVector );
919 actualInstantVector[1]=z;
921 int j,sizeCtrPt = vecCtrlPointX.size();
922 manualContourModel *manModelContour = factoryManualContourModel( typeofcontour );
923 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
925 for (j=0 ; j<sizeCtrPt ; j++)
927 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
930 theName = _modelManager->createOutline( manModelContour, actualInstantVector );
931 bool addedModel = theName.compare("") != 0;
934 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
935 this->_theViewPanel->getSpacing(spc);
936 //Adding the manualContourControler to interface objects structure
937 //Adding the manualViewContour to interface objects structure
938 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
939 _sceneManager->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
944 //------------------------------------------------------------------------------------------------------------
945 void wxContourEventHandler :: onAutomatiqueSegmentation( )
947 if (_segmentationFrame==NULL)
950 /*int sizeZ = _sceneManager->GetImageDataSizeZ();
952 _sceneManager->GetImageDataRange(range);*/
955 wxSize sizePanel( 300, 470);
956 _segmentationFrame = new wxFrame (_theViewPanel, -1,_T(" Segmentation "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
957 _segmentationFrame->SetSize( sizePanel );
958 wxPanel *panel = getSegmentationPanel(_segmentationFrame);
959 /*new wxPanel(_segmentationFrame,-1);
960 wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
961 wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
962 _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
963 _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
964 wxString lstOptions[3];
968 methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
969 methodRadiobox->SetSelection(2);
970 _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
973 _mbarrange = new mBarRange(panel,70, 65);
974 _mbarrange->SetMin(0);
975 _mbarrange->SetStart(0);
977 _mbarrange-> SetOrientation( true );
978 _mbarrange-> setActiveStateTo(true);
979 _mbarrange-> setVisibleLabels( true );
980 _mbarrange-> setDeviceEndMargin(10);
981 _mbarrange-> setRepresentedValues( 0 , sizeZ );
982 _mbarrange-> setDeviceBlitStart(10,10);
983 _mbarrange-> setIfWithActualDrawed( false );
984 _mbarrange-> SetStart( 0 );
985 _mbarrange-> SetEnd( sizeZ );
988 // _segmentationFrame->SetEventHandler( this );
989 segmentationOneSliceBtn->SetEventHandler( this );
990 segmentationAllSliceBtn->SetEventHandler( this );
991 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSlice );
992 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSlice );
994 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
995 sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
996 sizer -> Add( _isovalue , 1, wxGROW );
997 sizer -> Add( methodRadiobox , 1, wxGROW );
998 sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
999 sizer -> Add( _sampling , 1, wxGROW );
1000 sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
1001 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
1002 sizer -> Add( _staticTextSegmentation , 1, wxGROW );
1003 sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
1004 sizer -> Add( _mbarrange , 1, wxGROW );
1006 panel->SetSizer( sizer );
1007 panel->SetSize( sizePanel );
1008 panel->SetAutoLayout( true );
1011 this->_theViewPanel->SetVisibleAxis(true);
1012 this->_theViewPanel->Refresh();
1013 _segmentationFrame->Show(true);
1014 //JCP 13-10-09 View the method getSegmentationPanel(), this two methods where moved to getSegmentationPanel
1015 //this->_theViewPanel->SetVisibleAxis(true);
1016 //this->_theViewPanel->Refresh();
1018 if (_segmentationFrame->IsShown()==true)
1020 _segmentationFrame->Show(false);
1021 this->_theViewPanel->SetVisibleAxis(false);
1022 this->_theViewPanel->Refresh();
1024 _segmentationFrame->Show(true);
1025 this->_theViewPanel->SetVisibleAxis(true);
1026 this->_theViewPanel->Refresh();
1031 void wxContourEventHandler::showAxis(bool show){
1032 this->_theViewPanel->SetVisibleAxis(show);
1033 this->_theViewPanel->Refresh();
1035 wxPanel* wxContourEventHandler::getSegmentationPanel(wxWindow* parent){
1036 int sizeZ = _sceneManager->GetImageDataSizeZ();
1038 _sceneManager->GetImageDataRange(range);
1040 wxPanel *panel = new wxPanel(parent,-1);
1041 wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
1042 wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
1043 _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
1044 _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
1045 wxString lstOptions[3];
1049 methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
1050 methodRadiobox->SetSelection(2);
1051 _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
1054 _mbarrange = new mBarRange(panel,70, 65);
1055 _mbarrange->SetMin(0);
1056 _mbarrange->SetStart(0);
1058 _mbarrange-> SetOrientation( true );
1059 _mbarrange-> setActiveStateTo(true);
1060 _mbarrange-> setVisibleLabels( true );
1061 _mbarrange-> setDeviceEndMargin(10);
1062 _mbarrange-> setRepresentedValues( 0 , sizeZ );
1063 _mbarrange-> setDeviceBlitStart(10,10);
1064 _mbarrange-> setIfWithActualDrawed( false );
1065 _mbarrange-> SetStart( 0 );
1066 _mbarrange-> SetEnd( sizeZ );
1069 // _segmentationFrame->SetEventHandler( this );
1070 segmentationOneSliceBtn->SetEventHandler( this );
1071 segmentationAllSliceBtn->SetEventHandler( this );
1072 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSlice );
1073 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSlice );
1075 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
1076 sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
1077 sizer -> Add( _isovalue , 1, wxGROW );
1078 sizer -> Add( methodRadiobox , 1, wxGROW );
1079 sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
1080 sizer -> Add( _sampling , 1, wxGROW );
1081 sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
1082 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
1083 sizer -> Add( _staticTextSegmentation , 1, wxGROW );
1084 sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
1085 sizer -> Add( _mbarrange , 1, wxGROW );
1087 panel->SetSizer( sizer );
1088 // panel->SetSize( sizePanel );
1089 panel->SetSize( wxDefaultSize );
1090 panel->SetAutoLayout( true );
1095 void wxContourEventHandler :: onInterfaceTestFrame( )
1097 if (_TestFrame==NULL)
1099 _contourPropagation = new ContourPropagation();
1100 _TestFrame = new wxFrame (_theViewPanel, -1,_T(" Test Segmentation "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
1101 wxSize sizepanel(200,300);
1102 _TestFrame->SetSize( sizepanel );
1103 wxPanel *panel = new wxPanel(_TestFrame,-1);
1104 wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxSize(80,35) );
1105 wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxSize(80,35));
1106 wxButton *spreadGoBtn = new wxButton(panel,-1,_T("GoA"),wxDefaultPosition, wxSize(80,35));
1107 _wxtextctrlTest = new wxTextCtrl(panel,-1, "",wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE );
1109 _TestFrame->SetEventHandler( this );
1110 Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestReset );
1111 Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestAdd );
1112 Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestGo );
1114 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
1115 sizer -> Add( spreadResetBtn , 1, wxGROW );
1116 sizer -> Add( spreadAddBtn , 1, wxGROW );
1117 sizer -> Add( spreadGoBtn , 1, wxGROW );
1118 sizer -> Add( _wxtextctrlTest , 1, wxGROW );
1120 panel->SetSizer( sizer );
1121 panel->SetSize( sizepanel );
1122 panel->SetAutoLayout( true );
1126 if (_TestFrame->IsShown()==true)
1128 _TestFrame->Show(false);
1130 _TestFrame->Show(true);
1135 void wxContourEventHandler::onTestReset( wxCommandEvent& event )
1137 _wxtextctrlTest->SetValue("");
1138 _contourPropagation->resetAppend();
1141 //------------------------------------------------------------------------------------------------------------
1142 void wxContourEventHandler::onTestAdd( wxCommandEvent& event )
1144 std::vector<double> vecX;
1145 std::vector<double> vecY;
1146 std::vector<double> vecZ;
1147 _sceneManager->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
1149 if (vecX.size()!=0){
1150 std::vector<int> tempVector;
1151 _instantPanel->getInstant( tempVector );
1152 int i,size=vecZ.size();
1153 int actualSlice = tempVector[1];
1154 for ( i=0 ; i<size ; i++ )
1156 vecZ[i] = actualSlice;
1159 _contourPropagation->appendContour(&vecX , &vecY , &vecZ);
1161 newstring.Printf("%s %d -",_wxtextctrlTest->GetValue(), actualSlice );
1162 _wxtextctrlTest->SetValue(newstring);
1166 //------------------------------------------------------------------------------------------------------------
1167 void wxContourEventHandler::onTestGo( wxCommandEvent& event )
1169 std::vector<double> vecX;
1170 std::vector<double> vecY;
1171 std::vector<double> vecZ;
1172 std::vector<int> size;
1174 std::vector<double> vecCtrlPointX;
1175 std::vector<double> vecCtrlPointY;
1176 std::vector<double> vecCtrlPointZ;
1178 //Getting the points of the actual contour
1180 _contourPropagation->GetKeyContours(&vecX , &vecY , &vecZ, &size);
1181 for(int i = 0; i < vecX.size();i++){
1185 /*std::vector<double> vecX1;
1186 std::vector<double> vecY1;
1187 std::vector<double> vecZ1;
1188 _sceneManager->GetPointsOfActualContour( &vecX1 , &vecY1 , &vecZ1 );
1190 std::ofstream file1;
1191 file1.open( "Temp.txt" );
1194 for(int i = 0; i < vecX.size(); i++){
1195 file1<<vecX[i] <<" X1 "<< vecX1[i] <<" Y "<<vecY[i] <<" Y1 "<< vecY1[i] <<" Z "<<vecZ[i] <<" Z1 "<< vecZ1[i]<<std::endl;
1203 //Setting the points of the contour
1205 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
1206 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
1208 //Getting the control points of the contour by method A
1210 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1212 std::vector<int> actualInstantVector;
1213 _instantPanel->getInstant( actualInstantVector );
1214 actualInstantVector[1]= this->_theViewPanel->GetZ();
1220 //Adding the Contour to the scene
1222 manualContourModel *manModelContour = new manualContourModel();
1223 int j,sizeCtrPt = vecCtrlPointX.size();
1225 for (j=0 ; j<sizeCtrPt ; j++)
1227 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
1229 std::string theName;
1230 theName = _modelManager->createOutline( manModelContour, actualInstantVector );
1231 bool addedModel = theName.compare("") != 0;
1234 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1235 this->_theViewPanel->getSpacing(spc);
1236 //Adding the manualContourControler to interface objects structure
1237 //Adding the manualViewContour to interface objects structure
1238 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1239 _sceneManager->configureViewControlTo( theName, manModelContour,spc,1 ) ;
1244 //------------------------------------------------------------------------------------------------------------
1245 void wxContourEventHandler::FillGridWithContoursInformation()
1247 wxString tempString;
1249 _grid->SetColLabelValue(0, _T("A") );
1250 _grid->SetColLabelValue(1, _T("B") );
1251 _grid->SetColLabelValue(2, _T("C") );
1252 _grid->SetColLabelValue(3, _T("D") );
1253 _grid->SetColLabelValue(4, _T("E") );
1254 _grid->SetColLabelValue(5, _T("F") );
1256 std::vector<int> tempVector;
1257 _instantPanel->getInstant( tempVector );
1259 int z,sizeZ = _sceneManager->GetImageDataSizeZ();
1260 int ii,sizeLstContourThings;
1261 for ( z=0 ; z<sizeZ ; z++)
1264 Instant instant(&tempVector);
1265 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1267 sizeLstContourThings = lstContourThings.size();
1268 tempString.Printf("%d - %d",z, sizeLstContourThings);
1269 _grid->SetRowLabelValue(z, tempString );
1271 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1273 ContourThing **contourthing = lstContourThings[ii];
1274 tempString = (*contourthing)->getName().c_str() ;
1275 _grid->SetCellValue( z, ii, tempString );
1282 //------------------------------------------------------------------------------------------------------------
1283 std::vector<manualContourModel*> wxContourEventHandler::ExploseEachModel( std::vector<manualContourModel*> lstManConMod )
1285 std::vector<manualContourModel*> lstTmp;
1286 std::vector<manualContourModel*> lstResult;
1288 int i,iSize=lstManConMod.size();
1289 for (i=0;i<iSize;i++)
1291 lstTmp = lstManConMod[i]->ExploseModel();
1292 jSize=lstTmp.size();
1293 for (j=0;j<jSize;j++)
1295 lstResult.push_back( lstTmp[j] );
1301 //------------------------------------------------------------------------------------------------------------
1302 void wxContourEventHandler::onExtractInformation( wxCommandEvent& event )
1305 int maxContourGroup = 0;
1309 ContourExtractData *contourextractdata = new ContourExtractData();
1310 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1311 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1313 std::vector<manualContourModel*> lstManConMod;
1314 std::vector<manualContourModel*> lstManConModTmp;
1315 std::vector<manualContourModel*> lstManConModExp;
1316 std::vector<double> pLstValue;
1317 std::vector<double> pLstValuePosX;
1318 std::vector<double> pLstValuePosY;
1319 std::vector<double> pLstValuePosZ;
1322 int resultGrayRangeCount;
1325 double resultAverage;
1326 double resultStandardeviation;
1328 std::vector<int> tempVector;
1329 _instantPanel->getInstant( tempVector );
1331 vtkImageData *imagedata = _sceneManager->GetImageData();
1332 int sizeZ = _sceneManager->GetImageDataSizeZ();
1334 int ii,sizeLstContourThings;
1343 if (_informationRadiobox->GetSelection()==0 ) // actual slice
1345 std::vector<int> tempVector;
1346 _instantPanel->getInstant( tempVector );
1347 int actualSlice = tempVector[1];
1351 if (_informationRadiobox->GetSelection()==1 ) // slice range
1353 minZ = _mbarrangeSliceInformation->GetStart();
1354 maxZ = _mbarrangeSliceInformation->GetEnd();
1356 if (_informationRadiobox->GetSelection()==2 ) // All slices
1362 totalZ = maxZ-minZ+1;
1363 contourextractdata->SetImage( imagedata);
1366 for ( z=minZ ; z<=maxZ ; z++ )
1368 porcent = 100.0* (z-minZ)/totalZ;
1369 tmpString.Printf(" %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1370 _staticTextInformation->SetLabel(tmpString);
1372 //Extraction data from contours of each slice
1373 contourextractdata->SetZtoBeAnalys( z);
1376 Instant instant(&tempVector);
1377 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1378 sizeLstContourThings = lstContourThings.size();
1380 lstManConMod.clear();
1381 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1383 ContourThing **contourthing = lstContourThings[ii];
1384 lstManConMod.push_back( (*contourthing)->getModel() );
1386 lstManConModExp = ExploseEachModel( lstManConMod );
1389 wxString tempString;
1390 tempString.Printf("%d - %d",z, sizeLstContourThings);
1391 _grid->SetRowLabelValue(z, tempString );
1393 int iContourGroup,sizeContourGroup;
1394 if (typeContourGroup==3) // contour separete
1396 sizeContourGroup=lstManConModExp.size();
1397 if ( maxContourGroup<sizeContourGroup )
1399 maxContourGroup=sizeContourGroup;
1401 } else { // contour AND OR XOR
1410 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1411 lstManConModTmp.clear();
1412 if (typeContourGroup==3) // contour separete
1414 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1415 } else { // contour AND OR XOR
1416 lstManConModTmp = lstManConModExp;
1419 contourextractdata->SetLstManualContourModel( lstManConModTmp );
1422 pLstValuePosX.clear();
1423 pLstValuePosY.clear();
1424 pLstValuePosZ.clear();
1425 contourextractdata->GetValuesInsideCrown( &pLstValue,
1429 // Statistics of each slice.
1430 contourextractdata->Statistics( &pLstValue,
1431 _mbarrangeRangeInformation->GetStart(),
1432 _mbarrangeRangeInformation->GetEnd(),
1433 &resultGrayRangeCount,
1438 &resultStandardeviation);
1439 if (_grid->GetNumberCols()<_numberOfVariablesStatistics*(iContourGroup+1) )
1441 _grid->AppendCols(_numberOfVariablesStatistics);
1444 tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
1446 tempString.Printf("%d",resultSize);
1447 _grid->SetCellValue( z, tmpIntA + 0, tempString );
1448 tempString.Printf("%d",resultGrayRangeCount);
1449 _grid->SetCellValue( z, tmpIntA + 1, tempString );
1450 tempString.Printf("%f",resultMin);
1451 _grid->SetCellValue( z, tmpIntA + 2, tempString );
1452 tempString.Printf("%f",resultMax);
1453 _grid->SetCellValue( z, tmpIntA + 3, tempString );
1454 tempString.Printf("%f",resultAverage);
1455 _grid->SetCellValue( z, tmpIntA + 4, tempString );
1456 tempString.Printf("%f",resultStandardeviation);
1457 _grid->SetCellValue( z, tmpIntA + 5, tempString );
1459 } // for iContourGroup
1463 wxString tmpTitleString;
1465 for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
1467 tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
1468 tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
1469 _grid->SetColLabelValue( tmpIntB + 0, tmpTitleString );
1470 _grid->SetColLabelValue( tmpIntB + 1, _T("Size Range") );
1471 _grid->SetColLabelValue( tmpIntB + 2, _T("Min") );
1472 _grid->SetColLabelValue( tmpIntB + 3, _T("Max") );
1473 _grid->SetColLabelValue( tmpIntB + 4, _T("Average") );
1474 _grid->SetColLabelValue( tmpIntB + 5, _T("St.Dev.") );
1475 _grid->SetColLabelValue( tmpIntB + 6, _T(" ") );
1478 _staticTextInformation->SetLabel( _T("") );
1479 delete contourextractdata;
1483 //------------------------------------------------------------------------------------------------------------
1484 void wxContourEventHandler::SaveValuesXYZ(std::string directory,std::string namefile)
1487 ContourExtractData *contourextractdata = new ContourExtractData();
1488 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1489 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1491 std::vector<manualContourModel*> lstManConMod;
1492 std::vector<manualContourModel*> lstManConModTmp;
1493 std::vector<manualContourModel*> lstManConModExp;
1494 std::vector<double> pLstValue;
1495 std::vector<double> pLstValuePosX;
1496 std::vector<double> pLstValuePosY;
1497 std::vector<double> pLstValuePosZ;
1499 std::vector<int> tempVector;
1500 _instantPanel->getInstant( tempVector );
1502 vtkImageData *imagedata = _sceneManager->GetImageData();
1503 int sizeZ = _sceneManager->GetImageDataSizeZ();
1505 int ii,sizeLstContourThings;
1512 minZ = 0;// _mbarrange->GetStart();
1513 maxZ = sizeZ;//_mbarrange->GetEnd();
1514 totalZ = maxZ-minZ+1;
1516 contourextractdata->SetImage( imagedata);
1519 for ( z=0 ; z<sizeZ ; z++)
1522 porcent = 100.0* (z-minZ)/totalZ;
1523 tmpString.Printf("Saving Values %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1524 _staticTextInformation->SetLabel(tmpString);
1527 //Extraction data from contours of each slice
1528 contourextractdata->SetZtoBeAnalys( z);
1531 Instant instant(&tempVector);
1532 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1533 sizeLstContourThings = lstContourThings.size();
1535 lstManConMod.clear();
1536 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1538 ContourThing **contourthing = lstContourThings[ii];
1539 lstManConMod.push_back( (*contourthing)->getModel() );
1541 lstManConModExp = ExploseEachModel( lstManConMod );
1546 int iContourGroup,sizeContourGroup;
1547 if (typeContourGroup==3) // contour separete
1549 sizeContourGroup=lstManConModExp.size();
1550 } else { // contour AND OR XOR
1554 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1555 lstManConModTmp.clear();
1556 if (typeContourGroup==3) // contour separete
1558 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1559 } else { // contour AND OR XOR
1560 lstManConModTmp = lstManConModExp;
1563 contourextractdata->SetLstManualContourModel( lstManConModTmp );
1566 pLstValuePosX.clear();
1567 pLstValuePosY.clear();
1568 pLstValuePosZ.clear();
1569 contourextractdata->GetValuesInsideCrown( &pLstValue,
1575 filename.Printf("%s\\%s-slice%d-cont%d.txt",directory.c_str(),namefile.c_str(),z,iContourGroup);
1576 FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
1577 fprintf(pFile,"value \t x \t y \t z\n" );
1578 int iLstValue,sizeLstValue=pLstValue.size();
1579 for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
1581 fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
1584 } // for iContourGroup
1586 _staticTextInformation->SetLabel( _T("") );
1587 delete contourextractdata;
1591 //------------------------------------------------------------------------------------------------------------
1592 void wxContourEventHandler::SaveImageResult(std::string directory,std::string namefile)
1595 ContourExtractData *contourextractdata = new ContourExtractData( true );
1596 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1597 if (typeContourGroup==3)
1601 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1603 std::vector<manualContourModel*> lstManConMod;
1604 std::vector<manualContourModel*> lstManConModTmp;
1605 std::vector<manualContourModel*> lstManConModExp;
1607 std::vector<int> tempVector;
1608 _instantPanel->getInstant( tempVector );
1610 vtkImageData *imagedata = _sceneManager->GetImageData();
1611 int sizeZ = _sceneManager->GetImageDataSizeZ();
1613 int ii,sizeLstContourThings;
1622 minZ = 0;// _mbarrange->GetStart();
1623 maxZ = sizeZ;//_mbarrange->GetEnd();
1624 totalZ = maxZ-minZ+1;
1626 contourextractdata->SetImage( imagedata);
1629 for ( z=0 ; z<sizeZ ; z++)
1632 porcent = 100.0* (z-minZ)/totalZ;
1633 tmpString.Printf("Saving Values %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1634 _staticTextInformation->SetLabel(tmpString);
1636 //Extraction data from contours of each slice
1637 contourextractdata->SetZtoBeAnalys( z);
1640 Instant instant(&tempVector);
1641 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1642 sizeLstContourThings = lstContourThings.size();
1644 lstManConMod.clear();
1645 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1647 ContourThing **contourthing = lstContourThings[ii];
1648 lstManConMod.push_back( (*contourthing)->getModel() );
1650 lstManConModExp = ExploseEachModel( lstManConMod );
1653 int iContourGroup,sizeContourGroup;
1654 if (typeContourGroup==3) // contour separete
1656 sizeContourGroup=lstManConModExp.size();
1657 } else { // contour AND OR XOR
1661 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1662 lstManConModTmp.clear();
1663 if (typeContourGroup==3) // contour separete
1665 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1666 } else { // contour AND OR XOR
1667 lstManConModTmp = lstManConModExp;
1670 contourextractdata->SetLstManualContourModel( lstManConModTmp );
1673 // for (ii=0 ; ii<sizeLstContourThings ; ii++)
1675 // ContourThing **contourthing = lstContourThings[ii];
1676 // lstManConMod.push_back( (*contourthing)->getModel() );
1678 // contourextractdata->SetLstManualContourModel( lstManConMod );
1680 contourextractdata->CalculateImageResult(); // with actual Z
1682 } // for iContourGroup
1687 filename.Printf("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z);
1690 vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
1691 writerValueImage->SetInput( contourextractdata->GetVtkImageValueResult() );
1692 writerValueImage->SetFileName( (const char *)filename.mb_str() );
1693 writerValueImage->SetFileDimensionality( 3 );
1694 writerValueImage->Write( );
1697 filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z);
1698 vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
1699 writerMaskImage->SetInput( contourextractdata->GetVtkImageMaskResult() );
1700 writerMaskImage->SetFileName( (const char *)filename.mb_str() );
1701 writerMaskImage->SetFileDimensionality( 3 );
1702 writerMaskImage->Write( );
1704 _staticTextInformation->SetLabel( _T("") );
1705 delete contourextractdata;
1709 //------------------------------------------------------------------------------------------------------------
1710 void wxContourEventHandler::onInformationContourLabels( wxCommandEvent& event )
1713 FillGridWithContoursInformation();
1717 //------------------------------------------------------------------------------------------------------------
1718 void wxContourEventHandler::onSaveResults( wxCommandEvent& event )
1720 wxFileDialog dialog(_InformationContourFrame, _T("Choose a file"), _T(""), _T(""), _T("*.txt"), wxSAVE );
1721 if (dialog.ShowModal() == wxID_OK)
1723 onExtractInformation( event );
1724 std::string directory=(const char *)(dialog.GetDirectory().mb_str());
1725 std::string namefile=(const char *)(dialog.GetFilename().mb_str());
1727 SaveValuesXYZ( directory , namefile );
1728 SaveImageResult( directory , namefile );
1730 std::string filename = (const char *)(dialog.GetPath().mb_str() );
1731 FILE *pFile=fopen(filename.c_str(),"w+");
1733 int sizeZ = _sceneManager->GetImageDataSizeZ();
1736 int i,j,maxX,maxY=sizeZ;
1737 maxX=this->_grid->GetNumberCols();
1739 int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
1740 for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
1742 fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.char_str() );
1744 fprintf(pFile,"\n" );
1748 for ( j=0; j<maxY ; j++)
1750 fprintf(pFile,"%d\t" , j );
1751 for (i=0 ; i<maxX ; i++){
1752 tmpString = _grid->GetCellValue( j , i );
1753 fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
1755 fprintf(pFile,"\n" );
1765 //------------------------------------------------------------------------------------------------------------
1766 void wxContourEventHandler::onInformationContourFrame()
1768 if (_InformationContourFrame==NULL)
1770 _InformationContourFrame = new wxFrame (_theViewPanel, -1,_T(" Information "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
1771 _InformationContourFrame->SetSize( wxSize(500,450) );
1772 wxSize sizepanel(200,300);
1773 wxPanel *panel = getInformationPanel(_InformationContourFrame);
1774 //JCP 13-10-09 Grouping the panel in a method
1775 /*new wxPanel(_InformationContourFrame,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
1777 wxString lstOptions[4];
1778 lstOptions[0]=_T("Actual Slice");
1779 lstOptions[1]=_T("Range Slices");
1780 lstOptions[2]=_T("All Slices");
1781 _informationRadiobox = new wxRadioBox(panel, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
1783 wxString lstOptContOperation[5];
1784 lstOptContOperation[0]=_T("AND");
1785 lstOptContOperation[1]=_T("OR");
1786 lstOptContOperation[2]=_T("XOR");
1787 lstOptContOperation[3]=_T("ALL");
1788 _radiolstboxContourGroup = new wxRadioBox(panel, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
1790 wxButton *informationContourLabelsBtn = new wxButton(panel,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
1791 informationContourLabelsBtn->SetEventHandler( this );
1792 Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onInformationContourLabels );
1794 wxButton *statisticsContourBtn = new wxButton(panel,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
1795 statisticsContourBtn->SetEventHandler( this );
1796 Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onExtractInformation );
1798 wxButton *saveResultsBtn = new wxButton(panel,-1,_T("Save statistics results"),wxDefaultPosition, wxSize(140,35) );
1799 saveResultsBtn->SetEventHandler( this );
1800 Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSaveResults );
1803 int sizeZ = this->_sceneManager->GetImageDataSizeZ();
1804 _mbarrangeSliceInformation = new mBarRange(panel,65,65);
1805 _mbarrangeSliceInformation->SetMin(0);
1806 _mbarrangeSliceInformation->SetStart(0);
1807 _mbarrangeSliceInformation-> SetOrientation( true );
1808 _mbarrangeSliceInformation-> setActiveStateTo(true);
1809 _mbarrangeSliceInformation-> setVisibleLabels( true );
1810 _mbarrangeSliceInformation-> setDeviceEndMargin(10);
1811 _mbarrangeSliceInformation-> setRepresentedValues( 0 , sizeZ-1 );
1812 _mbarrangeSliceInformation-> setDeviceBlitStart(10,10);
1813 _mbarrangeSliceInformation-> setIfWithActualDrawed( false );
1814 _mbarrangeSliceInformation-> SetStart( 0 );
1815 _mbarrangeSliceInformation-> SetEnd( sizeZ-1 );
1819 this->_sceneManager->GetImageDataRange(range);
1820 _mbarrangeRangeInformation = new mBarRange(panel,65,65);
1821 _mbarrangeRangeInformation->SetMin(0);
1822 _mbarrangeRangeInformation->SetStart(0);
1823 _mbarrangeRangeInformation-> SetOrientation( true );
1824 _mbarrangeRangeInformation-> setActiveStateTo(true);
1825 _mbarrangeRangeInformation-> setVisibleLabels( true );
1826 _mbarrangeRangeInformation-> setDeviceEndMargin(10);
1827 _mbarrangeRangeInformation-> setRepresentedValues( range[0] , range[1] );
1828 _mbarrangeRangeInformation-> setDeviceBlitStart(10,10);
1829 _mbarrangeRangeInformation-> setIfWithActualDrawed( false );
1830 _mbarrangeRangeInformation-> SetStart( range[0] );
1831 _mbarrangeRangeInformation-> SetEnd( range[1] );
1834 _staticTextInformation = new wxStaticText(panel,-1,_T(" "));
1837 // wxButton *XXXXXXXBtn = new wxButton(panel,-1,_T("Statistics"),wxDefaultPosition, wxSize(180,35) );
1838 // XXXXXXXBtn->SetEventHandler( this );
1839 // Connect( XXXXXXXBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onXXXXX );
1842 _grid = new wxGrid( panel,
1845 wxSize( 100, 100 ) );
1847 int i,gridCol=10,gridRow=sizeZ;
1848 _grid->CreateGrid( 0, 0 );
1849 _grid->AppendRows(gridRow);
1850 _grid->AppendCols(gridCol);
1852 for (i=0;i<gridRow;i++)
1854 _grid->SetRowLabelValue(i, _T(" ") );
1856 // _grid->SetColLabelSize(0);
1859 FillGridWithContoursInformation();
1861 wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
1862 sizerA->Add( _informationRadiobox , 1, wxALL ,2 );
1863 sizerA->Add( _radiolstboxContourGroup , 1, wxALL ,2 );
1865 wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
1866 sizerB->Add( informationContourLabelsBtn , 1, wxALL ,2 );
1867 sizerB->Add( statisticsContourBtn , 1, wxALL ,2 );
1868 sizerB->Add( saveResultsBtn , 1, wxALL ,2 );
1870 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
1871 sizer->AddGrowableCol(0);
1872 sizer->AddGrowableRow(7);
1873 sizer->Add( sizerA , 1, wxALL , 0 );
1874 sizer->Add( new wxStaticText(panel ,-1,_T("Slice Range")) , 1, wxALL , 0 );
1875 sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
1876 sizer->Add( new wxStaticText(panel ,-1,_T("Gray Range")) , 1, wxALL , 0 );
1877 sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
1878 sizer->Add( sizerB , 1, wxALL , 0 );
1879 sizer->Add( _staticTextInformation , 1, wxALL , 0 );
1880 sizer->Add( _grid , 1, wxEXPAND , 0 );
1884 panel->SetSizer( sizer );
1885 panel->SetSize( wxSize(1500,1500) );
1886 //panel->SetBackgroundColour( wxColour(100,100,100) );
1887 panel->SetAutoLayout( true );
1890 wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
1892 // sizerPanel->AddGrowableCol(0);
1893 // sizerPanel->AddGrowableRow(0);
1896 //sizerPanel -> Add( sizer , 1, wxEXPAND ,0);
1897 sizerPanel -> Add( panel->GetSizer() , 1, wxEXPAND ,0);
1902 _InformationContourFrame->SetSizer( sizerPanel );
1903 _InformationContourFrame->SetAutoLayout( true );
1904 _InformationContourFrame->Layout();
1906 _InformationContourFrame->Show();
1908 if (_InformationContourFrame->IsShown()==true)
1910 _InformationContourFrame->Show(false);
1912 FillGridWithContoursInformation();
1913 _InformationContourFrame->Show(true);
1918 wxPanel* wxContourEventHandler::getInformationPanel(wxWindow* parent){
1919 wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
1921 wxString lstOptions[4];
1922 lstOptions[0]=_T("Actual Slice");
1923 lstOptions[1]=_T("Range Slices");
1924 lstOptions[2]=_T("All Slices");
1925 _informationRadiobox = new wxRadioBox(panel, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
1927 wxString lstOptContOperation[5];
1928 lstOptContOperation[0]=_T("AND");
1929 lstOptContOperation[1]=_T("OR");
1930 lstOptContOperation[2]=_T("XOR");
1931 lstOptContOperation[3]=_T("ALL");
1932 _radiolstboxContourGroup = new wxRadioBox(panel, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
1934 wxButton *informationContourLabelsBtn = new wxButton(panel,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
1935 informationContourLabelsBtn->SetEventHandler( this );
1936 Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onInformationContourLabels );
1938 wxButton *statisticsContourBtn = new wxButton(panel,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
1939 statisticsContourBtn->SetEventHandler( this );
1940 Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onExtractInformation );
1942 wxButton *saveResultsBtn = new wxButton(panel,-1,_T("Save statistics results"),wxDefaultPosition, wxSize(140,35) );
1943 saveResultsBtn->SetEventHandler( this );
1944 Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSaveResults );
1947 int sizeZ = this->_sceneManager->GetImageDataSizeZ();
1948 _mbarrangeSliceInformation = new mBarRange(panel,65,65);
1949 _mbarrangeSliceInformation->SetMin(0);
1950 _mbarrangeSliceInformation->SetStart(0);
1951 _mbarrangeSliceInformation-> SetOrientation( true );
1952 _mbarrangeSliceInformation-> setActiveStateTo(true);
1953 _mbarrangeSliceInformation-> setVisibleLabels( true );
1954 _mbarrangeSliceInformation-> setDeviceEndMargin(10);
1955 _mbarrangeSliceInformation-> setRepresentedValues( 0 , sizeZ-1 );
1956 _mbarrangeSliceInformation-> setDeviceBlitStart(10,10);
1957 _mbarrangeSliceInformation-> setIfWithActualDrawed( false );
1958 _mbarrangeSliceInformation-> SetStart( 0 );
1959 _mbarrangeSliceInformation-> SetEnd( sizeZ-1 );
1963 this->_sceneManager->GetImageDataRange(range);
1964 _mbarrangeRangeInformation = new mBarRange(panel,65,65);
1965 _mbarrangeRangeInformation->SetMin(0);
1966 _mbarrangeRangeInformation->SetStart(0);
1967 _mbarrangeRangeInformation-> SetOrientation( true );
1968 _mbarrangeRangeInformation-> setActiveStateTo(true);
1969 _mbarrangeRangeInformation-> setVisibleLabels( true );
1970 _mbarrangeRangeInformation-> setDeviceEndMargin(10);
1971 _mbarrangeRangeInformation-> setRepresentedValues( range[0] , range[1] );
1972 _mbarrangeRangeInformation-> setDeviceBlitStart(10,10);
1973 _mbarrangeRangeInformation-> setIfWithActualDrawed( false );
1974 _mbarrangeRangeInformation-> SetStart( range[0] );
1975 _mbarrangeRangeInformation-> SetEnd( range[1] );
1978 _staticTextInformation = new wxStaticText(panel,-1,_T(" "));
1981 // wxButton *XXXXXXXBtn = new wxButton(panel,-1,_T("Statistics"),wxDefaultPosition, wxSize(180,35) );
1982 // XXXXXXXBtn->SetEventHandler( this );
1983 // Connect( XXXXXXXBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onXXXXX );
1986 _grid = new wxGrid( panel,
1989 wxSize( 100, 100 ) );
1991 int i,gridCol=10,gridRow=sizeZ;
1992 _grid->CreateGrid( 0, 0 );
1993 _grid->AppendRows(gridRow);
1994 _grid->AppendCols(gridCol);
1996 for (i=0;i<gridRow;i++)
1998 _grid->SetRowLabelValue(i, _T(" ") );
2000 // _grid->SetColLabelSize(0);
2003 FillGridWithContoursInformation();
2005 wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
2006 sizerA->Add( _informationRadiobox , 1, wxALL ,2 );
2007 sizerA->Add( _radiolstboxContourGroup , 1, wxALL ,2 );
2009 wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
2010 sizerB->Add( informationContourLabelsBtn , 1, wxALL ,2 );
2011 sizerB->Add( statisticsContourBtn , 1, wxALL ,2 );
2012 sizerB->Add( saveResultsBtn , 1, wxALL ,2 );
2014 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
2015 sizer->AddGrowableCol(0);
2016 sizer->AddGrowableRow(7);
2017 sizer->Add( sizerA , 1, wxALL , 0 );
2018 sizer->Add( new wxStaticText(panel ,-1,_T("Slice Range")) , 1, wxALL , 0 );
2019 sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
2020 sizer->Add( new wxStaticText(panel ,-1,_T("Gray Range")) , 1, wxALL , 0 );
2021 sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
2022 sizer->Add( sizerB , 1, wxALL , 0 );
2023 sizer->Add( _staticTextInformation , 1, wxALL , 0 );
2024 sizer->Add( _grid , 1, wxEXPAND , 0 );
2028 panel->SetSizer( sizer );
2029 panel->SetSize( wxSize(1500,1500) );
2030 //panel->SetBackgroundColour( wxColour(100,100,100) );
2031 panel->SetAutoLayout( true );
2035 //------------------------------------------------------------------------------------------------------------
2036 void wxContourEventHandler :: onSpreadInDepth( std::vector<std::string> & keyNamesVector )
2040 //------------------------------------------------------------------------------------------------------------
2041 void wxContourEventHandler :: onOutline_Union_Of( std::vector<std::string> & keyNamesVector )
2045 //------------------------------------------------------------------------------------------------------------
2046 void wxContourEventHandler :: onOutline_Intersection_Of( std::vector<std::string> & keyNamesVector )
2050 //------------------------------------------------------------------------------------------------------------
2051 void wxContourEventHandler :: onOutline_Combination_Of( std::vector<std::string> & keyNamesVector )
2055 //------------------------------------------------------------------------------------------------------------
2056 void wxContourEventHandler :: onOutline_Fragmentation_Of( std::vector<std::string> & keyNamesVector )
2060 //------------------------------------------------------------------------------------------------------------
2061 void wxContourEventHandler :: onOutline_Agrupation_Of( std::vector<std::string> & keyNamesVector )
2065 //------------------------------------------------------------------------------------------------------------
2066 void wxContourEventHandler :: onCopyOutlines( std::vector<std::string> & keyNamesVector )
2068 std::vector<int> tempVector;
2069 _instantPanel->getInstant( tempVector );
2070 _performingOperation->reset();
2071 _performingOperation->setStartCommand( (char)wxContour_ActionCommandsID::COPY_TOOL );
2072 _performingOperation->setStartOperationInstantVector( tempVector );
2073 _performingOperation->setKeyNamesOperationElems( keyNamesVector );
2076 //------------------------------------------------------------------------------------------------------------
2077 void wxContourEventHandler :: onPasteOutlines( )
2079 char theStartCommand = _performingOperation->getStartCommand();
2080 if ( theStartCommand == wxContour_ActionCommandsID::COPY_TOOL )
2082 //JCP 20-10-08 Undo redo implementation
2084 //JCP 20-10-08 Undo redo implementation
2087 std::vector<int> tempVector;
2088 _instantPanel->getInstant( tempVector );
2089 _performingOperation->setEndOperationInstantVector ( tempVector );
2090 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
2091 int i,size = elems.size();
2092 for( i=0; i<size; i++ )
2094 createCopyContourOf( elems[i], tempVector, i>0 );
2101 //------------------------------------------------------------------------------------------------------------
2102 void wxContourEventHandler :: onShowOutlines( std::vector<std::string> & keyNamesVector )
2106 //------------------------------------------------------------------------------------------------------------
2107 void wxContourEventHandler :: onHideOutlines( std::vector<std::string> & keyNamesVector )
2111 //------------------------------------------------------------------------------------------------------------
2112 void wxContourEventHandler :: onSelectOutlines( std::vector<std::string> & keyNamesVector )
2114 //if( keyNamesVector.empty() )
2116 _sceneManager->drawSelectionROI( );
2120 int ok = keyNamesVector.size();
2121 _sceneManager->selectObjects( keyNamesVector );
2122 std::string name = keyNamesVector[0];
2125 _sceneManager->drawSelectionROI( );
2126 std::vector<std::string> currentSelection = _sceneManager->getSelectedObjects();
2127 int ok = currentSelection.size();
2128 _sceneManager->selectObjects( currentSelection );*/
2130 //------------------------------------------------------------------------------------------------------------
2131 void wxContourEventHandler :: onEditOutlines( std::vector<std::string> & keyNamesVector )
2135 //------------------------------------------------------------------------------------------------------------
2137 //------------------------------------------------------------------------------------------------------------
2138 void wxContourEventHandler :: deleteContour( std::string theKeyName )
2140 manualContourModel * cModel;
2141 manualViewBaseContour * cViewer;
2142 manualContourBaseControler * cControler;
2144 ContourWrap_ViewControl *conwrapviewControl = _sceneManager->getContourWrap_ViewControlOf( theKeyName );
2145 cControler = conwrapviewControl->getControler();
2146 int ispartofstaticlst= _modelManager->IsPartOfStaticList(theKeyName);
2147 if ((cControler!=NULL) && (cControler->IsEditable()==false) && (ispartofstaticlst==-1) )
2149 _sceneManager->removeFromScene( theKeyName );
2150 cModel = _modelManager->getOutlineByKeyName(theKeyName)->getModel();
2151 _modelManager->removeOutline( theKeyName );
2152 cViewer = conwrapviewControl->getViewer();
2153 _sceneManager->removeWrap( theKeyName );
2155 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
2156 //fprintf(ff,"EED wxContourEventHandler::deleteContours() \n" );
2157 //fprintf(ff," %s %p\n",keyNamesVector[i].c_str(), cControler );
2165 //------------------------------------------------------------------------------------------------------------
2166 void wxContourEventHandler :: deleteContours( std::vector<std::string> & keyNamesVector )
2168 int i,size=keyNamesVector.size();
2169 for (i=0;i<size;i++)
2171 deleteContour( keyNamesVector[i] );
2175 //------------------------------------------------------------------------------------------------------------
2176 void wxContourEventHandler :: deleteAllContours( )
2179 std::vector<int> tempVector;
2180 _instantPanel->getInstant( tempVector );
2182 //JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
2183 // the values in GetStart and GetEnd will then not be initialize also.
2184 // We use instead the values given when initializing the _deletepanel.
2186 //int minZ = _mbarrangeDeleteAll->GetStart();
2187 //int maxZ = _mbarrangeDeleteAll->GetEnd();
2191 maxZ = _sceneManager->GetImageDataSizeZ();
2195 _sceneManager->removeSceneContours( );
2196 _modelManager->removeAllOutlines();
2197 _sceneManager->removeAllOutlines();
2200 if ( (minZ==0) && (maxZ==_mbarrangeDeleteAll->GetMax() ))
2202 _sceneManager->removeSceneContours( );
2203 _modelManager->removeAllOutlines();
2204 _sceneManager->removeAllOutlines();
2207 for ( z=minZ ; z<=maxZ ; z++)
2210 Instant instant(&tempVector);
2211 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
2213 sizeLstContourThings = lstContourThings.size();
2214 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2216 ContourThing **contourthing = lstContourThings[ii];
2217 deleteContour( (*contourthing)->getName() );
2224 //------------------------------------------------------------------------------------------------------------
2225 void wxContourEventHandler::openContours( FILE *pFile, bool staticContour )
2228 fscanf(pFile,"%s",tmp); // NumberOfContours
2229 fscanf(pFile,"%s",tmp); // ##
2230 int numberOfContours = atoi(tmp);
2232 std::vector<int> instantVector;
2233 int typeContourModel;
2234 manualContourModel *manModelContour;
2238 for (i=0;i<numberOfContours;i++)
2240 instantVector.clear();
2241 fscanf(pFile,"%s",tmp); // Instant
2243 fscanf(pFile,"%s",tmp); // 1
2244 instantVector.push_back( atoi(tmp) );
2245 fscanf(pFile,"%s",tmp); // 2
2246 instantVector.push_back( atoi(tmp) );
2247 fscanf(pFile,"%s",tmp); // 3
2248 instantVector.push_back( atoi(tmp) );
2249 fscanf(pFile,"%s",tmp); // 4
2250 instantVector.push_back( atoi(tmp) );
2251 fscanf(pFile,"%s",tmp); // 5
2252 instantVector.push_back( atoi(tmp) );
2253 fscanf(pFile,"%s",tmp); // 6
2254 instantVector.push_back( atoi(tmp) );
2257 fscanf(pFile,"%s",tmp); // TypeContourModel
2258 fscanf(pFile,"%s",tmp); // ##
2259 typeContourModel = atoi(tmp);
2261 manModelContour = factoryManualContourModel(typeContourModel);
2262 manModelContour->Open(pFile);
2264 fscanf(pFile,"%s",tmp); // TypeView
2265 fscanf(pFile,"%s",tmp); // ##
2266 typeView = atoi(tmp);
2274 std::string theName;
2275 theName = _modelManager->createOutline( manModelContour, instantVector );
2276 bool addedModel = theName.compare("") != 0;
2279 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2280 this->_theViewPanel->getSpacing(spc);
2281 //Adding the manualContourControler to interface objects structure
2282 //Adding the manualViewContour to interface objects structure
2283 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
2284 _sceneManager->configureViewControlTo( theName, manModelContour,spc , typeView) ;
2287 if (staticContour==true)
2289 Instant instant(&instantVector);
2290 changeContourOfManager( theName , &instant );
2293 }// for numberOfContours
2299 //------------------------------------------------------------------------------------------------------------
2300 void wxContourEventHandler::openFileWithContours()
2303 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
2304 if (dialog.ShowModal() == wxID_OK)
2306 fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
2307 FILE *pFile=fopen(fileNameContourROI.c_str(),"r+");
2309 fscanf(pFile,"%s",tmp); // --CreaContour--
2311 fscanf(pFile,"%s",tmp); // Version
2312 fscanf(pFile,"%s",tmp); // 1.0.1
2313 std::string version(tmp);
2315 openContours(pFile,false);
2316 if (version!="1.0.0"){
2317 openContours(pFile,true);
2319 // _sceneManager->openFileWithContours(ff);
2323 _sceneManager->removeSceneContours();
2325 //updateInstantOutlines();
2329 //------------------------------------------------------------------------------------------------------------
2330 void wxContourEventHandler::saveFileWithContours( std::string filename )
2332 FILE *pFile=fopen(filename.c_str(),"w+");
2333 std::vector< std::string > lstNameThings;
2334 int i,sizeLstNameThings;
2336 fprintf(pFile,"--CreaContour--\n");
2337 fprintf(pFile,"Version %s\n", "1.0.1" );
2340 lstNameThings = _modelManager->GetLstNameThings();
2341 sizeLstNameThings = lstNameThings.size();
2342 fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
2343 for (i=0 ; i<sizeLstNameThings ; i++)
2345 _modelManager->SaveThingName( pFile, lstNameThings[i] );
2346 _sceneManager->SaveThingName( pFile, lstNameThings[i] );
2349 //-- Contours Statics
2350 lstNameThings = _modelManager->GetLstNameThingsStatic();
2351 sizeLstNameThings = lstNameThings.size();
2352 fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
2353 for (i=0 ; i<sizeLstNameThings ; i++)
2355 _modelManager->SaveThingName( pFile, lstNameThings[i] );
2356 _sceneManager->SaveThingName( pFile, lstNameThings[i] );
2362 //----------------------------------------------------------
2364 void wxContourEventHandler::saveFileWithContours()
2366 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
2367 if (dialog.ShowModal() == wxID_OK)
2369 fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
2370 saveFileWithContours( fileNameContourROI );
2374 //------------------------------------------------------------------------------------------------------------
2375 void wxContourEventHandler :: saveFileWithContoursAutomatique()
2377 if (fileNameContourROI=="")
2379 saveFileWithContours();
2381 saveFileWithContours(fileNameContourROI);
2386 //------------------------------------------------------------------------------------------------------------
2387 void wxContourEventHandler :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append )
2389 std::string cloneName = _modelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
2390 manualContourModel * manualModel = _modelManager->getOutlineByKeyName( cloneName )->getModel();
2391 _sceneManager->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
2395 //------------------------------------------------------------------------------------------------------------
2396 manualContourModel * wxContourEventHandler::factoryManualContourModel(int typeContour)
2398 manualContourModel *manModelContour=NULL;
2403 manModelContour = new manualContourModel();
2409 manModelContour = new manualContourModel();
2415 manModelContour = new manualContourModelRoi();
2421 manModelContour = new manualContourModelCircle();
2427 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
2428 manModelContour = manModelContourBullEye;
2429 if (_panelBullEyeOptions!=NULL){
2430 int iCrown,sizeCrowns,iSector,sizeSectors;
2431 double radioA,radioB,ang,angDelta ;
2432 sizeCrowns = _panelBullEyeOptions->GetNumberOfCrowns();
2433 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
2435 sizeSectors = _panelBullEyeOptions->GetNumberOfSections(iCrown);
2436 radioB = _panelBullEyeOptions->GetRadioOfCrown(iCrown);
2437 if (iCrown==sizeCrowns-1)
2441 radioA = _panelBullEyeOptions->GetRadioOfCrown(iCrown+1);
2443 radioA=radioA/100.0;
2444 radioB=radioB/100.0;
2445 for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
2447 ang = _panelBullEyeOptions->GetAngOfCrownSection(iCrown,iSector);
2448 angDelta= _panelBullEyeOptions->GetAngDeltaOfCrownSection(iCrown);
2449 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
2452 } // if _panelBullEyeOptions
2453 }// if typeContour==4
2455 return manModelContour;
2458 //------------------------------------------------------------------------------------------------------------
2459 void wxContourEventHandler :: createContour( int typeContour )
2461 //Creating the manualContourModel and including in the model
2462 manualContourModel * manModelContour = factoryManualContourModel(typeContour);
2463 std::vector<int> instantVector;
2464 _instantPanel->getInstant( instantVector );
2465 std::string theName;
2466 theName= _modelManager->createOutline( manModelContour, instantVector );
2467 bool addedModel = theName.compare("") != 0;
2470 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2471 this->_theViewPanel->getSpacing(spc);
2472 //Adding the manualContourControler to interface objects structure
2473 //Adding the manualViewContour to interface objects structure
2474 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
2475 _sceneManager->configureViewControlTo( theName, manModelContour,spc , typeContour) ;
2479 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
2480 //fprintf(ff,"EED wxContourEventHandler::createContour() \n" );
2481 //fprintf(ff," %s\n %p ",theName.c_str() , );
2486 manualContourModel * wxContourEventHandler::factoryManualContourModel(PanelBullEyeOptions* panel){
2488 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
2489 manualContourModel *manModelContour=NULL;
2490 manModelContour = manModelContourBullEye;
2492 int iCrown,sizeCrowns,iSector,sizeSectors;
2493 double radioA,radioB,ang,angDelta ;
2494 sizeCrowns = panel->GetNumberOfCrowns();
2495 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
2497 sizeSectors = panel->GetNumberOfSections(iCrown);
2498 radioB = panel->GetRadioOfCrown(iCrown);
2499 if (iCrown==sizeCrowns-1)
2503 radioA = panel->GetRadioOfCrown(iCrown+1);
2505 radioA=radioA/100.0;
2506 radioB=radioB/100.0;
2507 for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
2509 ang = panel->GetAngOfCrownSection(iCrown,iSector);
2510 angDelta= panel->GetAngDeltaOfCrownSection(iCrown);
2511 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
2514 } // if _panelBullEyeOptions
2516 return manModelContour;
2519 void wxContourEventHandler :: createContourBullsEye(PanelBullEyeOptions* panel )
2521 //Creating the manualContourModel and including in the model
2522 manualContourModel * manModelContour = factoryManualContourModel(panel );
2523 std::vector<int> instantVector;
2524 _instantPanel->getInstant( instantVector );
2525 std::string theName;
2526 theName= _modelManager->createOutline( manModelContour, instantVector );
2527 bool addedModel = theName.compare("") != 0;
2530 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2531 this->_theViewPanel->getSpacing(spc);
2532 //Adding the manualContourControler to interface objects structure
2533 //Adding the manualViewContour to interface objects structure
2534 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
2535 _sceneManager->configureViewControlTo( theName, manModelContour,spc , 4) ;
2539 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
2540 //fprintf(ff,"EED wxContourEventHandler::createContour() \n" );
2541 //fprintf(ff," %s\n %p ",theName.c_str() , );
2547 //------------------------------------------------------------------------------------------------------------
2548 // Attributes getters and setters
2549 //------------------------------------------------------------------------------------------------------------
2551 void wxContourEventHandler :: setModelManager( OutlineModelManager * theModelManager )
2553 _modelManager = theModelManager;
2554 _workSpace = _modelManager->getContourWorkspace();
2556 //------------------------------------------------------------------------------------------------------------
2557 void wxContourEventHandler :: setViewPanel( wxContourViewPanel * theViewPanel )
2559 _theViewPanel = theViewPanel;
2560 _theViewPanel->setWxEventHandler( this );
2563 this->_theViewPanel->getSpacing(spc);
2564 _sceneManager = new wxVtkBaseView_SceneManager ( this->_theViewPanel->getWxVtkBaseView(), this, spc );
2566 Connect( _theViewPanel->GetId(), wxINSTANT_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant );
2567 Connect( wxID_ANY, wxEVT_START_CREATE_MULT_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onCreateMultipleROI );
2568 Connect( wxID_ANY, wxEVT_START_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onCreateROI );
2569 Connect( wxID_ANY, wxEVT_STOP_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onStopCreateROI );
2570 Connect( wxID_ANY, wxEVT_CHANGED_DEEP, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangedDeep );
2571 Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler :: onActionButtonPressed );
2576 //------------------------------------------------------------------------------------------------------------
2577 void wxContourEventHandler :: setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel )
2579 _instantPanel = theInstantChooserPanel;
2580 _instantPanel->setWxEventHandler( this );
2582 Connect( _instantPanel->GetId(), wxINSTANT_CHOOSER_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant );
2584 std::vector<int> vect;
2585 _instantPanel->getInstant( vect );
2586 _actualInstant = new Instant( &vect );
2588 if( _modelManager!=NULL )
2590 std::vector<std::string> conceptNameVect;
2591 std::vector<int> conceptSizeVect;
2592 _modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect);
2594 int max = conceptNameVect.size();
2597 if( conceptNameVect[i].compare("Axe Depth") == 0 )
2599 _instantPanel->addConcept( conceptNameVect[i], 0, conceptSizeVect[i], 1);
2601 _instantPanel->addConcept( conceptNameVect[i], 1, conceptSizeVect[i], 1);
2605 //Should be configured later, or abort program, because Model -NEEDS- to be added before chooserPanel
2607 if( _theViewPanel!=NULL )
2609 double val = _theViewPanel->getCurrentDeep();
2610 _instantPanel->setConceptValue( "Axe Depth", (int)val );
2611 ConceptDataWrap * data = _instantPanel->getConceptDataOf( "Axe Depth" );
2613 _theViewPanel->setVerticalConcept( "Axe Depth", data->getMinValue(), data->getMaxValue(), data->getMinShowedValue(), data->getMaxShowedValue(), data->getActualValue() );
2615 //Should be configured later, or abort program, because ViewPanel -NEEDS- to be added before chooserPanel
2620 //------------------------------------------------------------------------------------------------------------
2621 void wxContourEventHandler :: setButtonsBar( wxContour_ButtonsBar * theButtonsBar )
2623 _buttonsBar = theButtonsBar;
2624 _buttonsBar->setWxEventHandler( this );
2625 Connect( _buttonsBar->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler:: onActionButtonPressed );
2627 //------------------------------------------------------------------------------------------------------------
2628 void wxContourEventHandler :: setGrid( wxContour_Grid * theGridPanel )
2630 _gridPanel = theGridPanel;
2632 //------------------------------------------------------------------------------------------------------------
2633 void wxContourEventHandler :: setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel )
2635 _drawToolsPanel = theDrawToolsPanel;
2637 //------------------------------------------------------------------------------------------------------------
2638 void wxContourEventHandler :: setOperationsToolsPanel( wxContour_OperationsToolsPanel * theOperationsToolsPanel )
2640 _operationsToolsPanel = theOperationsToolsPanel;
2642 //------------------------------------------------------------------------------------------------------------
2643 void wxContourEventHandler :: setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel )
2645 _autoFormsPanel = theAutoFormsPanel;
2648 void wxContourEventHandler :: setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel )
2650 _standardToolsPanel= theStandardToolsPanel;
2652 //------------------------------------------------------------------------------------------------------------
2653 void wxContourEventHandler :: setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel )
2655 _editionToolsPanel = theEditionToolsPanel;
2658 //------------------------------------------------------------------------------------------------------------
2659 void wxContourEventHandler :: setListViewPanel( wxContour_ListViewPanel * theListViewPanel )
2661 _listViewPanel = theListViewPanel;
2663 //------------------------------------------------------------------------------------------------------------
2664 // Other functional methods
2665 //------------------------------------------------------------------------------------------------------------
2668 //------------------------------------------------------------------------------------------------------------
2669 void wxContourEventHandler::onDeleteContour( wxCommandEvent& event )
2672 //JCP 20-10-08 Undo redo implementation
2674 //JCP 20-10-08 Undo redo implementation
2677 int i,size=_sceneManager->getSelectedObjects().size();
2680 std::string keyName = _sceneManager->getSelectedObjects()[i];
2681 int ispartofstaticlist = this->_modelManager->IsPartOfStaticList( keyName );
2682 if ( ispartofstaticlist>=0 )
2684 std::vector<int> tempVector;
2685 _instantPanel->getInstant( tempVector );
2686 Instant instant(&tempVector);
2687 this->_modelManager->ChangeContourOfList(keyName, &instant);
2691 std::vector<std::string> lstKeyName;
2692 std::vector<std::string> lstKeyNameActualSlice;
2693 std::vector<std::string> lstKeyNameToBeErase;
2695 lstKeyNameToBeErase = _sceneManager->getSelectedObjects();
2696 lstKeyNameActualSlice = _sceneManager->GetlstContoursNameActualSlice();
2697 int k,kSize=lstKeyNameToBeErase.size();
2698 int j,jSize=lstKeyNameActualSlice.size();
2700 for (k=0;k<kSize; k++)
2703 for (j=0;j<jSize; j++)
2705 if (lstKeyNameToBeErase[k]==lstKeyNameActualSlice[j])
2712 lstKeyName.push_back( lstKeyNameToBeErase[k] );
2716 deleteContours( lstKeyName );
2721 //------------------------------------------------------------------------------------------------------------
2722 void wxContourEventHandler::onDeleteContoursActSlice( wxCommandEvent& event )
2724 //JCP 20-10-08 Undo redo implementation
2726 //JCP 20-10-08 Undo redo implementation
2727 deleteContours( _sceneManager->GetlstContoursNameActualSlice() );
2732 //------------------------------------------------------------------------------------------------------------
2733 void wxContourEventHandler::onDeleteAllContours( wxCommandEvent& event )
2735 //JCP 20-10-08 Undo redo implementation
2737 //JCP 20-10-08 Undo redo implementation
2738 deleteAllContours( );
2743 //------------------------------------------------------------------------------------------------------------
2744 void wxContourEventHandler :: onDeleteFrame( )
2746 if (_deleteFrame==NULL)
2748 _deleteFrame = new wxFrame (_theViewPanel, -1,_T(" Delete Contour "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
2750 wxSize sizepanel(width,230);
2751 _deleteFrame->SetSize( sizepanel );
2752 wxPanel *panel = new wxPanel(_deleteFrame,-1);
2753 wxButton *deleteContourBtn = new wxButton(panel,-1,_T("Delete contour selected"),wxDefaultPosition, wxSize(width-10,35) );
2754 wxButton *deleteContoursActSliceBtn = new wxButton(panel,-1,_T("Delete contours of actual slice"),wxDefaultPosition, wxSize(width-10,35));
2755 wxButton *deleteAllContoursBtn = new wxButton(panel,-1,_T("Delete all contours"),wxDefaultPosition, wxSize(width-10,35));
2757 int sizeZ = _sceneManager->GetImageDataSizeZ();
2758 _mbarrangeDeleteAll = new mBarRange(panel,70, 65);
2759 _mbarrangeDeleteAll->SetMin(0);
2760 _mbarrangeDeleteAll->SetStart(0);
2762 _mbarrangeDeleteAll-> SetOrientation( true );
2763 _mbarrangeDeleteAll-> setActiveStateTo(true);
2764 _mbarrangeDeleteAll-> setVisibleLabels( true );
2765 _mbarrangeDeleteAll-> setDeviceEndMargin(10);
2766 _mbarrangeDeleteAll-> setRepresentedValues( 0 , sizeZ );
2767 _mbarrangeDeleteAll-> setDeviceBlitStart(10,10);
2768 _mbarrangeDeleteAll-> setIfWithActualDrawed( false );
2769 _mbarrangeDeleteAll-> SetStart( 0 );
2770 _mbarrangeDeleteAll-> SetEnd( sizeZ );
2773 _deleteFrame->SetEventHandler( this );
2774 Connect( deleteContourBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteContour );
2775 Connect( deleteContoursActSliceBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteContoursActSlice );
2776 Connect( deleteAllContoursBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteAllContours );
2778 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
2779 sizer -> Add( deleteContourBtn , 1, wxGROW );
2780 sizer -> Add( deleteContoursActSliceBtn , 1, wxGROW );
2781 sizer -> Add( deleteAllContoursBtn , 1, wxGROW );
2782 sizer -> Add( _mbarrangeDeleteAll , 1, wxGROW );
2784 panel->SetSizer( sizer );
2785 panel->SetSize( sizepanel );
2786 panel->SetAutoLayout( true );
2788 _deleteFrame->Show(true);
2790 if (_deleteFrame->IsShown()==true)
2792 _deleteFrame->Show(false);
2794 _deleteFrame->Show(true);
2800 //------------------------------------------------------------------------------------------------------------
2801 void wxContourEventHandler::onCreateContourSpline( wxCommandEvent& event )
2804 //JCP 20-10-08 Undo redo implementation
2806 //JCP 20-10-08 Undo redo implementation
2813 //------------------------------------------------------------------------------------------------------------
2814 void wxContourEventHandler::onCreateContourRectangle( wxCommandEvent& event )
2817 //JCP 20-10-08 Undo redo implementation
2819 //JCP 20-10-08 Undo redo implementation
2825 //------------------------------------------------------------------------------------------------------------
2826 void wxContourEventHandler::onCreateContourCircle( wxCommandEvent& event )
2828 //JCP 20-10-08 Undo redo implementation
2830 //JCP 20-10-08 Undo redo implementation
2835 //------------------------------------------------------------------------------------------------------------
2836 void wxContourEventHandler::onCreateContourBullEye( wxCommandEvent& event )
2838 //JCP 20-10-08 Undo redo implementation
2840 //JCP 20-10-08 Undo redo implementation
2849 //------------------------------------------------------------------------------------------------------------
2850 void wxContourEventHandler :: onCreateContourFrame( )
2852 if (_createContourFrame==NULL)
2854 _createContourFrame = new wxFrame (_theViewPanel, -1,_T(" New Contour "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
2855 wxSize sizepanel(490,600);
2856 _createContourFrame->SetSize( sizepanel );
2857 wxPanel *panel = new wxPanel(_createContourFrame,-1);
2858 wxButton *newContourSplineBtn = new wxButton(panel,-1,_T("Interpolation B-spline (close)"),wxDefaultPosition, wxSize(180,35) );
2859 newContourSplineBtn->SetToolTip(_T("CTRL-N"));
2860 wxButton *newContourRectangleBtn = new wxButton(panel,-1,_T("Rectangle"),wxDefaultPosition, wxSize(180,35));
2861 wxButton *newContourCircleBtn = new wxButton(panel,-1,_T("Circle"),wxDefaultPosition, wxSize(180,35));
2862 wxButton *newContourStarBtn = new wxButton(panel,-1,_T("Bull eye"),wxDefaultPosition, wxSize(180,35));
2864 _panelBullEyeOptions = new PanelBullEyeOptions(panel, wxSize(100,200));
2866 _createContourFrame->SetEventHandler( this );
2867 Connect( newContourSplineBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourSpline );
2868 Connect( newContourRectangleBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourRectangle );
2869 Connect( newContourCircleBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourCircle );
2870 Connect( newContourStarBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourBullEye );
2872 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
2873 sizer -> Add( newContourSplineBtn , 1, wxGROW );
2874 sizer -> Add( newContourRectangleBtn , 1, wxGROW );
2875 sizer -> Add( newContourCircleBtn , 1, wxGROW );
2876 sizer -> Add( newContourStarBtn , 1, wxGROW );
2877 sizer -> Add( _panelBullEyeOptions , 1, wxGROW );
2879 panel->SetSizer( sizer );
2880 panel->SetSize( sizepanel );
2881 panel->SetAutoLayout( true );
2883 _createContourFrame->Show(true);
2885 if (_createContourFrame->IsShown()==true)
2887 _createContourFrame->Show(false);
2889 _createContourFrame->Show(true);
2895 //------------------------------------------------------------------------
2896 void wxContourEventHandler::RefreshInterface()
2899 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2900 wxvtk2dbaseview->Refresh();
2903 //------------------------------------------------------------------------
2904 void wxContourEventHandler::onWidthOfContour(wxScrollEvent& event){
2905 _sceneManager->removeSceneContours();
2906 double width = (double)_withOfContourLine->GetValue() / 2.0;
2907 _sceneManager->SetWidthContour( width );
2912 //------------------------------------------------------------------------
2914 void wxContourEventHandler::onBrigthnessColorWindowLevel(wxScrollEvent& event){
2915 int colorwindow = _brithtnessColorLevel->GetValue();
2916 int windowlevel = _brithtnessWindowLevel->GetValue();
2917 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2918 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
2919 imageviewer->SetColorWindow(colorwindow);
2920 imageviewer->SetColorLevel(windowlevel);
2921 // wxvtk2dbaseview->Refresh();
2925 void wxContourEventHandler::OnInterpolation(wxCommandEvent& event)
2927 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2928 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
2929 if (_interpolationCheckBox->GetValue()==true)
2931 imageviewer->GetImageActor()->InterpolateOn();
2933 imageviewer->GetImageActor()->InterpolateOff();
2939 //------------------------------------------------------------------------------------------------------------
2940 void wxContourEventHandler :: onInterfaceConfigurationFrame( )
2942 if (_interfaceConfigurationFrame==NULL)
2944 _interfaceConfigurationFrame = new wxFrame (_theViewPanel, -1,_T(" Interface Configuration "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
2945 wxSize sizepanel(190,400);
2946 _interfaceConfigurationFrame->SetSize( sizepanel );
2947 _interfaceConfigurationFrame->SetEventHandler( this );
2948 wxPanel* panel = getConfigurationPanel(_interfaceConfigurationFrame);
2949 panel->SetSize(sizepanel);
2950 _interfaceConfigurationFrame->Show(true);
2952 if (_interfaceConfigurationFrame->IsShown()==true)
2954 _interfaceConfigurationFrame->Show(false);
2956 _interfaceConfigurationFrame->Show(true);
2964 wxPanel* wxContourEventHandler :: getConfigurationPanel(wxWindow* parent){
2966 /*wxPanel *panel = new wxPanel(parent,-1);
2967 _withOfContourLine = new wxSlider(panel, -1, 1 , 1, 10, wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
2970 this->_sceneManager->GetImageDataRange(range);
2972 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2973 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
2974 int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
2975 int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
2977 _brithtnessWindowLevel = new wxSlider(panel, -1, windowlevel , 1, range[1], wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
2978 _brithtnessColorLevel = new wxSlider(panel, -1, colorwindow , 1, range[1], wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
2980 _interpolationCheckBox = new wxCheckBox(panel, -1, _T("Image interpolation") );
2981 _interpolationCheckBox->SetValue(true);
2983 _interfaceConfigurationFrame->SetEventHandler( this );
2985 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
2986 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
2988 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
2989 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
2990 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
2991 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
2992 Connect( _interpolationCheckBox->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::OnInterpolation );
2994 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
2995 sizer -> Add( new wxStaticText(panel,-1,_T("Contour width")) , 1, wxGROW );
2996 sizer -> Add( _withOfContourLine , 1, wxGROW );
2997 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
2998 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
2999 sizer -> Add( new wxStaticText(panel,-1,_T("Brightness of the image")) , 1, wxGROW );
3000 sizer -> Add( new wxStaticText(panel,-1,_T("--Window level--")) , 1, wxGROW );
3001 sizer -> Add( _brithtnessWindowLevel , 1, wxGROW );
3002 sizer -> Add( new wxStaticText(panel,-1,_T("--Color level--")) , 1, wxGROW );
3003 sizer -> Add( _brithtnessColorLevel, 1, wxGROW );
3004 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3005 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3006 sizer -> Add( _interpolationCheckBox , 1, wxGROW );
3008 panel->SetSizer( sizer );
3010 //panel->SetSize( sizepanel );
3012 panel->SetAutoLayout( true );
3017 wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString(""));
3018 _withOfContourLine = new wxSlider(panel, -1, 1 , 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3021 this->_sceneManager->GetImageDataRange(range);
3023 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
3024 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
3025 int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
3026 int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
3028 _brithtnessWindowLevel = new wxSlider(panel, -1, windowlevel , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3029 _brithtnessColorLevel = new wxSlider(panel, -1, colorwindow , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3031 _interpolationCheckBox = new wxCheckBox(panel, -1, _T("Image interpolation") );
3032 _interpolationCheckBox->SetValue(true);
3034 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
3035 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
3037 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3038 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3039 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3040 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3041 Connect( _interpolationCheckBox->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::OnInterpolation );
3043 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
3044 sizer -> Add( new wxStaticText(panel,-1,_T("Contour width")) , 1, wxGROW );
3045 sizer -> Add( _withOfContourLine , 1, wxGROW );
3046 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3047 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3048 sizer -> Add( new wxStaticText(panel,-1,_T("Brightness of the image")) , 1, wxGROW );
3049 sizer -> Add( new wxStaticText(panel,-1,_T("--Window level--")) , 1, wxGROW );
3050 sizer -> Add( _brithtnessWindowLevel , 1, wxGROW );
3051 sizer -> Add( new wxStaticText(panel,-1,_T("--Color level--")) , 1, wxGROW );
3052 sizer -> Add( _brithtnessColorLevel, 1, wxGROW );
3053 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3054 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3055 sizer -> Add( _interpolationCheckBox , 1, wxGROW );
3057 panel->SetSizer( sizer );
3059 //panel->SetSize( sizepanel );
3061 panel->SetAutoLayout( true );
3071 //------------------------------------------------------------------
3072 void wxContourEventHandler :: changeContourOfManager(std::string keyName, Instant *instant)
3074 this->_modelManager->ChangeContourOfList(keyName, instant);
3077 //------------------------------------------------------------------
3078 void wxContourEventHandler :: changeContoursOfManager( std::vector<std::string> & keyNamesVector )
3081 //JCP 20-10-08 Undo redo implementation
3083 //JCP 20-10-08 Undo redo implementation
3085 std::vector<int> tempVector;
3086 _instantPanel->getInstant( tempVector );
3087 Instant instant(&tempVector);
3089 int i , size=keyNamesVector.size();
3090 for ( i=0 ; i<size ; i++ )
3092 changeContourOfManager(keyNamesVector[i], &instant);
3099 //------------------------------------------------------------------
3100 void wxContourEventHandler :: executeActionCommand( const char toolCommand )
3102 std::vector<std::string> currentSelection = _sceneManager->getSelectedObjects();
3103 int elementsSelected = currentSelection.size();
3104 if( toolCommand == (wxContour_ActionCommandsID::CREATE_TOOL) )
3106 onCreateContourFrame();
3108 if( toolCommand == (wxContour_ActionCommandsID::CREATE_CONTOUR_KEY) )
3112 else if( toolCommand == wxContour_ActionCommandsID::DELETE_TOOL )
3116 else if( toolCommand == wxContour_ActionCommandsID::DELETE_KEY )
3118 deleteContours( currentSelection );
3120 else if( toolCommand == wxContour_ActionCommandsID::SAVE_TOOL )
3122 saveFileWithContours( );
3124 else if( toolCommand == wxContour_ActionCommandsID::SAVE_KEY )
3126 saveFileWithContoursAutomatique( );
3128 else if( toolCommand == wxContour_ActionCommandsID::OPEN_TOOL )
3130 openFileWithContours( );
3132 else if( toolCommand == wxContour_ActionCommandsID::CHANGE_TOOL )
3134 if ( elementsSelected >= 1 )
3136 changeContoursOfManager( currentSelection );
3140 else if( toolCommand == wxContour_ActionCommandsID::HIDE_TOOL )
3142 if ( elementsSelected >= 1 )
3144 onHideOutlines( currentSelection );
3147 else if( toolCommand == wxContour_ActionCommandsID::SHOW_TOOL )
3149 if ( elementsSelected >= 1 )
3151 onShowOutlines( currentSelection );
3154 else if( toolCommand == wxContour_ActionCommandsID::COPY_TOOL )
3156 if ( elementsSelected >= 1 )
3158 onCopyOutlines( currentSelection );
3161 else if( toolCommand == wxContour_ActionCommandsID::PASTE_TOOL )
3165 else if( toolCommand == wxContour_ActionCommandsID::SPREAD_TOOL )
3169 else if( toolCommand == wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL )
3171 onAutomatiqueSegmentation( );
3174 else if( toolCommand == wxContour_ActionCommandsID::SELECT_TOOL )
3176 onSelectOutlines( currentSelection );
3179 else if( toolCommand == wxContour_ActionCommandsID::EDIT_TOOL )
3181 if ( elementsSelected >= 1 )
3183 onEditOutlines( currentSelection );
3186 else if( toolCommand == wxContour_ActionCommandsID::UNDO_TOOL )
3190 else if( toolCommand == wxContour_ActionCommandsID::REDO_TOOL )
3194 else if( toolCommand == wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL )
3196 onInformationContourFrame();
3198 else if( toolCommand == wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL )
3200 onInterfaceConfigurationFrame();
3202 else if( toolCommand == wxContour_ActionCommandsID::TEST_TOOL )
3204 onInterfaceTestFrame();
3211 //------------------------------------------------------------------------------------------------------------
3212 // Getting information methods
3213 //------------------------------------------------------------------------------------------------------------
3217 //------------------------------------------------------------------------------------------------------------
3219 //------------------------------------------------------------------------------------------------------------
3221 void wxContourEventHandler :: updateInstantOutlines()
3223 std::vector<NameWrapper *> namesWrapping = _modelManager->getActualInstantOutlines();
3224 int size = namesWrapping.size();
3225 _sceneManager->removeSceneContours();
3226 for( int i=0; i<size; i++)
3228 _sceneManager->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false );
3231 //------------------------------------------------------------------------------------------------------------
3232 void wxContourEventHandler :: updateInstantImageData()
3236 //------------------------------------------------------------------------------------------------------------
3238 void wxContourEventHandler :: updateInstantAxes()
3242 //------------------------------------------------------------------------------------------------------------
3243 void wxContourEventHandler :: changeInstant()
3245 std::vector<int> instantVect;
3246 _instantPanel->getInstant( instantVect );
3247 Instant * theInstant = new Instant ( &instantVect );
3248 //if( !theInstant->isEquals( _actualInstant ))
3250 //Setting the actual instant
3251 _actualInstant = theInstant;
3252 _modelManager->setInstant( _actualInstant );
3254 updateInstantOutlines();
3255 updateInstantImageData();
3256 updateInstantAxes();
3258 //Searching the elements at the specified instant
3261 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
3262 iter = contours_ViewControl->find("Outline 0");
3263 (iter->second)->getViewer()->RemoveCompleteContourActor();*/
3267 void wxContourEventHandler :: saveState(){
3273 itoa(inundo, str, 10);
3275 std::string temp = stundoredo + *str + ".roi";
3276 saveFileWithContours(temp);
3281 void wxContourEventHandler ::loadState(std::string filename){
3284 FILE *pFile=fopen(filename.c_str(),"r+");
3286 fscanf(pFile,"%s",tmp); // --CreaContour--
3288 fscanf(pFile,"%s",tmp); // Version
3289 fscanf(pFile,"%s",tmp); // 1.0.1
3290 std::string version(tmp);
3292 deleteAllContours();
3294 openContours(pFile,false);
3295 if (version!="1.0.0"){
3296 openContours(pFile,true);
3301 //_sceneManager->removeSceneContours();
3305 void wxContourEventHandler :: onREDO()
3312 itoa(inundo, str, 10);
3315 std::string temp = stundoredo + *str + ".roi";
3323 //------------------------------------------------------------------------------------------------------------
3324 void wxContourEventHandler :: onUNDO()
3330 itoa(inundo, str, 10);
3332 std::string temp = stundoredo + *str + ".roi";
3333 saveFileWithContours(temp);
3340 itoa(inundo, str, 10);
3343 std::string temp = stundoredo + *str + ".roi";
3349 void wxContourEventHandler :: getValuesXYZ(double **vectx, double **vecty, double **vectz, std::vector<int>* size){
3353 ContourExtractData *contourextractdata = new ContourExtractData();
3354 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
3355 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
3357 std::vector<manualContourModel*> lstManConMod;
3358 std::vector<manualContourModel*> lstManConModTmp;
3359 std::vector<manualContourModel*> lstManConModExp;
3360 std::vector<double> pLstValue;
3361 std::vector<double> pLstValuePosX;
3362 std::vector<double> pLstValuePosY;
3363 std::vector<double> pLstValuePosZ;
3365 std::vector<int> tempVector;
3366 _instantPanel->getInstant( tempVector );
3368 vtkImageData *imagedata = _sceneManager->GetImageData();
3369 int sizeZ = _sceneManager->GetImageDataSizeZ();
3371 int ii,sizeLstContourThings;
3378 minZ = 0;// _mbarrange->GetStart();
3379 maxZ = sizeZ;//_mbarrange->GetEnd();
3380 totalZ = maxZ-minZ+1;
3382 contourextractdata->SetImage( imagedata);
3385 vectx = new double *[sizeZ];
3386 vecty = new double *[sizeZ];
3387 vectz = new double *[sizeZ];
3388 for ( z=0 ; z<sizeZ ; z++)
3391 porcent = 100.0* (z-minZ)/totalZ;
3393 //Extraction data from contours of each slice
3394 contourextractdata->SetZtoBeAnalys( z);
3397 Instant instant(&tempVector);
3398 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
3399 sizeLstContourThings = lstContourThings.size();
3401 lstManConMod.clear();
3402 for (ii=0 ; ii<sizeLstContourThings ; ii++)
3404 ContourThing **contourthing = lstContourThings[ii];
3405 lstManConMod.push_back( (*contourthing)->getModel() );
3407 lstManConModExp = ExploseEachModel( lstManConMod );
3412 int iContourGroup,sizeContourGroup;
3413 if (typeContourGroup==3) // contour separete
3415 sizeContourGroup=lstManConModExp.size();
3416 } else { // contour AND OR XOR
3420 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
3421 lstManConModTmp.clear();
3422 if (typeContourGroup==3) // contour separete
3424 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
3425 } else { // contour AND OR XOR
3426 lstManConModTmp = lstManConModExp;
3429 contourextractdata->SetLstManualContourModel( lstManConModTmp );
3432 pLstValuePosX.clear();
3433 pLstValuePosY.clear();
3434 pLstValuePosZ.clear();
3435 contourextractdata->GetValuesInsideCrown( &pLstValue,
3441 int iLstValue,sizeLstValue=pLstValue.size();
3443 //We initialize the pointers
3444 size->push_back(sizeLstValue);
3445 vectx[sizeZ] = new double[sizeLstValue];
3446 vecty[sizeZ] = new double[sizeLstValue];
3447 vectz[sizeZ] = new double[sizeLstValue];
3449 for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
3452 vectx[sizeZ][iLstValue] = pLstValuePosX[iLstValue];
3453 vecty[sizeZ][iLstValue] = pLstValuePosY[iLstValue];
3454 vectz[sizeZ][iLstValue] = pLstValuePosZ[iLstValue];
3457 //The size of the contour is saved
3462 } // for iContourGroup
3464 //_staticTextInformation->SetLabel( _T("") );
3465 delete contourextractdata;
3470 void wxContourEventHandler :: getMaskValue(vtkImageData* mask, vtkImageData* value){
3474 ContourExtractData *contourextractdata = new ContourExtractData( true );
3475 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
3476 if (typeContourGroup==3)
3480 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
3482 std::vector<manualContourModel*> lstManConMod;
3483 std::vector<manualContourModel*> lstManConModTmp;
3484 std::vector<manualContourModel*> lstManConModExp;
3486 std::vector<int> tempVector;
3487 _instantPanel->getInstant( tempVector );
3489 vtkImageData *imagedata = _sceneManager->GetImageData();
3490 int sizeZ = _sceneManager->GetImageDataSizeZ();
3492 int ii,sizeLstContourThings;
3501 minZ = 0;// _mbarrange->GetStart();
3502 maxZ = sizeZ;//_mbarrange->GetEnd();
3503 totalZ = maxZ-minZ+1;
3505 contourextractdata->SetImage( imagedata);
3508 for ( z=0 ; z<sizeZ ; z++)
3511 porcent = 100.0* (z-minZ)/totalZ;
3512 tmpString.Printf("Saving Values %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
3513 _staticTextInformation->SetLabel(tmpString);
3515 //Extraction data from contours of each slice
3516 contourextractdata->SetZtoBeAnalys( z);
3519 Instant instant(&tempVector);
3520 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
3521 sizeLstContourThings = lstContourThings.size();
3523 lstManConMod.clear();
3524 for (ii=0 ; ii<sizeLstContourThings ; ii++)
3526 ContourThing **contourthing = lstContourThings[ii];
3527 lstManConMod.push_back( (*contourthing)->getModel() );
3529 lstManConModExp = ExploseEachModel( lstManConMod );
3532 int iContourGroup,sizeContourGroup;
3533 if (typeContourGroup==3) // contour separete
3535 sizeContourGroup=lstManConModExp.size();
3536 } else { // contour AND OR XOR
3540 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
3541 lstManConModTmp.clear();
3542 if (typeContourGroup==3) // contour separete
3544 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
3545 } else { // contour AND OR XOR
3546 lstManConModTmp = lstManConModExp;
3549 contourextractdata->SetLstManualContourModel( lstManConModTmp );
3552 contourextractdata->CalculateImageResult(); // with actual Z
3554 } // for iContourGroup
3560 value = contourextractdata->GetVtkImageValueResult();
3563 mask = contourextractdata->GetVtkImageMaskResult();
3565 delete contourextractdata;
3569 wxPanel* wxContourEventHandler::getSegmentationPanelITK(wxWindow* parent){
3571 int sizeZ = _sceneManager->GetImageDataSizeZ();
3573 _sceneManager->GetImageDataRange(range);
3575 wxPanel *panel = new wxPanel(parent,-1);
3576 wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
3577 wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
3578 _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3579 _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3580 wxString lstOptions[3];
3584 methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
3585 methodRadiobox->SetSelection(2);
3586 _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
3589 _mbarrange = new mBarRange(panel,70, 65);
3590 _mbarrange->SetMin(0);
3591 _mbarrange->SetStart(0);
3593 _mbarrange-> SetOrientation( true );
3594 _mbarrange-> setActiveStateTo(true);
3595 _mbarrange-> setVisibleLabels( true );
3596 _mbarrange-> setDeviceEndMargin(10);
3597 _mbarrange-> setRepresentedValues( 0 , sizeZ );
3598 _mbarrange-> setDeviceBlitStart(10,10);
3599 _mbarrange-> setIfWithActualDrawed( false );
3600 _mbarrange-> SetStart( 0 );
3601 _mbarrange-> SetEnd( sizeZ );
3604 // _segmentationFrame->SetEventHandler( this );
3605 segmentationOneSliceBtn->SetEventHandler( this );
3606 segmentationAllSliceBtn->SetEventHandler( this );
3607 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSliceITK );
3608 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSliceITK );
3610 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
3611 sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
3612 sizer -> Add( _isovalue , 1, wxGROW );
3613 sizer -> Add( methodRadiobox , 1, wxGROW );
3614 sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
3615 sizer -> Add( _sampling , 1, wxGROW );
3616 sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
3617 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3618 sizer -> Add( _staticTextSegmentation , 1, wxGROW );
3619 sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
3620 sizer -> Add( _mbarrange , 1, wxGROW );
3622 panel->SetSizer( sizer );
3623 // panel->SetSize( sizePanel );
3624 panel->SetSize( wxDefaultSize );
3625 panel->SetAutoLayout( true );
3632 void wxContourEventHandler::onSegmentationAllSliceITK( wxCommandEvent& event ){
3633 //TODO implementar el método para todos los slices ver ayuda en onSegmentationAllSlice
3635 void wxContourEventHandler::onSegmentationOneSliceITK( wxCommandEvent& event ){
3636 //TODO implementar el método de segmentación en ITK ver ayuda en onSegmentationOneSlice y el método
3637 // SegmentationOneSlice(x, y, z) que es la implementación del método en VTK
3639 //JCP 20-10-08 Undo redo implementation
3641 //JCP 20-10-08 Undo redo implementation
3644 int x = this->_theViewPanel->GetX();
3645 int y = this->_theViewPanel->GetY();
3646 int z = this->_theViewPanel->GetZ();
3647 //SegmentationOneSlice( x,y,z );
3650 void wxContourEventHandler::onSnakePressed(wxWindow* parent){
3652 std::vector<double> vecX;
3653 std::vector<double> vecY;
3654 std::vector<double> vecZ;
3655 _sceneManager->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
3657 if (vecX.size()!=0){
3658 std::vector<int> tempVector;
3659 _instantPanel->getInstant( tempVector );
3660 int i,size=vecZ.size();
3661 int actualSlice = tempVector[1];
3662 for ( i=0 ; i<size ; i++ )
3664 vecZ[i] = actualSlice;
3667 wxDialog* dialog = new wxDialog(parent, -1, wxString("Snake"));
3668 wxPanel* panel = new wxPanel(dialog,-1);
3669 wxStaticText* sttext = new wxStaticText(panel, -1, wxString("Panel para snake"));
3670 dialog->ShowModal();
3675 void wxContourEventHandler::checkInformationPanel(){
3676 if (_InformationContourFrame==NULL){
3677 onInformationContourFrame();
3678 _InformationContourFrame->Show(false);