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]=_T("General options");
123 lstOptions[1]=_T("Detail options");
124 _radioboxBullEyeGenOpt = new wxRadioBox(panel, -1, _T("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 char buff[3000]; // hope it's enough!
373 sprintf(buff, "mkdir %s;",stundoredo.c_str());
375 //mkdir(stundoredo.c_str());
376 stundoredo += "/cont";
378 //------------------------------------------------------------------------------------------------------------
379 wxContourEventHandler :: ~ wxContourEventHandler()
381 delete _actualInstant;
382 /*delete _theViewPanel;
383 delete _instantPanel;
385 delete _actualInstant;
387 delete _sceneManager;
388 delete _performingOperation;
392 //------------------------------------------------------------------------------------------------------------
393 // Configuration methods
394 //------------------------------------------------------------------------------------------------------------
396 bool wxContourEventHandler :: configureEventsHandling()
398 bool configured = true;
403 //------------------------------------------------------------------------------------------------------------
404 // Methods for capturing events
405 //------------------------------------------------------------------------------------------------------------
406 void wxContourEventHandler :: onProcessMessage( wxCommandEvent& event )
410 //------------------------------------------------------------------------------------------------------------
412 void wxContourEventHandler :: onActionButtonPressed( wxCommandEvent& event )
414 const char buttonTool = *(char *)event.GetClientData();
415 executeActionCommand( buttonTool );
417 //------------------------------------------------------------------------------------------------------------
418 void wxContourEventHandler :: onChangedDeep ( wxCommandEvent& event )
420 double val = _theViewPanel->getCurrentDeep();
421 _instantPanel->setConceptValue( "Axe Depth", (int)val );
422 _theViewPanel->setActualVertical( (int)val );
426 //------------------------------------------------------------------------------------------------------------
427 void wxContourEventHandler :: onChangeInstant( wxCommandEvent& event )
429 ConceptDataWrap * dataConcept = NULL;
430 if ( _theViewPanel->GetId() == event.GetId() )
432 dataConcept = (ConceptDataWrap *)event.GetClientData();
433 int value = dataConcept->getActualValue();
434 _instantPanel->setConceptValue( dataConcept->getName(), value );
438 dataConcept = _instantPanel->getLastConceptData();
439 if( dataConcept->getName().compare( _theViewPanel->getVerticalConceptName() ) )
441 _theViewPanel->setActualVertical( dataConcept->getActualValue());
442 //_theViewPanel->setVerticalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
444 else if( dataConcept->getName().compare( _theViewPanel->getHorizontalConceptName() ) || _instantPanel->getIfConceptCheckedAt( dataConcept->getName(), 0 ) )
446 _theViewPanel->setHorizontalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
451 //------------------------------------------------------------------------------------------------------------
453 void wxContourEventHandler :: onCreateMultipleROI( wxCommandEvent& event )
455 _creatingContoursActive = !_creatingContoursActive;
456 if( _creatingContoursActive )
461 //------------------------------------------------------------------------------------------------------------
462 void wxContourEventHandler :: onCreateROI( wxCommandEvent& event )
464 if( _creatingContoursActive )
470 //------------------------------------------------------------------------------------------------------------
471 void wxContourEventHandler :: onStopCreateROI( wxCommandEvent& event )
476 //------------------------------------------------------------------------------------------------------------
477 void wxContourEventHandler :: onDeleterROI( wxCommandEvent& event )
481 //------------------------------------------------------------------------------------------------------------
482 void wxContourEventHandler :: onSelectROI( wxCommandEvent& event )
486 //------------------------------------------------------------------------------------------------------------
489 void wxContourEventHandler :: onUnSelectROI( wxCommandEvent& event )
493 //------------------------------------------------------------------------------------------------------------
495 void wxContourEventHandler :: onManualHidedROI( wxCommandEvent& event )
499 //------------------------------------------------------------------------------------------------------------
501 void wxContourEventHandler :: onManualShowedROI( wxCommandEvent& event )
505 //------------------------------------------------------------------------------------------------------------
507 void wxContourEventHandler :: onEditingROI( wxCommandEvent& event )
511 //------------------------------------------------------------------------------------------------------------
513 void wxContourEventHandler :: onMovingROI( wxCommandEvent& event )
518 //------------------------------------------------------------------------------------------------------------
519 // Model management methods
520 //------------------------------------------------------------------------------------------------------------
522 void wxContourEventHandler::onSpreadReset( wxCommandEvent& event )
524 _wxtextctrlSpread->SetValue(_T(""));
525 _contourPropagation->resetAppend();
528 //------------------------------------------------------------------------------------------------------------
529 void wxContourEventHandler::onSpreadAdd( wxCommandEvent& event )
531 std::vector<double> vecX;
532 std::vector<double> vecY;
533 std::vector<double> vecZ;
534 _sceneManager->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
537 std::vector<int> tempVector;
538 _instantPanel->getInstant( tempVector );
539 int i,size=vecZ.size();
540 int actualSlice = tempVector[1];
541 for ( i=0 ; i<size ; i++ )
543 vecZ[i] = actualSlice;
546 _contourPropagation->appendContour(&vecX , &vecY , &vecZ);
548 newstring.Printf(_T("%s %d -"),
549 _wxtextctrlSpread->GetValue().c_str(),
551 _wxtextctrlSpread->SetValue(newstring);
555 //------------------------------------------------------------------------------------------------------------
556 void wxContourEventHandler::onSpreadGo( wxCommandEvent& event )
559 //JCP 20-10-08 Undo redo implementation
561 //JCP 20-10-08 Undo redo implementation
564 int typeMethodFindCtrlPoints=_spreadMethodRadiobox->GetSelection();
565 int typeofcontour = 1;
566 manualContourModel *manModelContour;
567 std::vector<double> vecCtrlPointX;
568 std::vector<double> vecCtrlPointY;
569 std::vector<double> vecCtrlPointZ;
575 std::vector<int> tempVector;
576 _instantPanel->getInstant( tempVector );
579 _contourPropagation->getMaxMinZ(&minZ,&maxZ);
580 //JSTG_16-07-08_----------------------------------------------------------------
581 //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
582 _contourPropagation->setInterpolationNumber(100);
583 _contourPropagation->CalculeSplinePropagation();
585 double totalZ = maxZ-minZ+1;
588 //--------------------------------------------------------------------
589 for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
591 porcent = 100.0* (z-minZ)/totalZ;
592 tmpString.Printf( _T(" %d %c %d/%d %d"), (int)porcent , 37 , (int)(z-minZ+1), (int)totalZ,z );
593 _staticTextSpread->SetLabel(tmpString);
595 if (_contourPropagation->ifSliceKeyContourExist(z)==false)
597 manModelContour = factoryManualContourModel( typeofcontour );
598 idTmp = _contourPropagation->FindIdWithZ(z);
599 if (typeMethodFindCtrlPoints==0) // Initial Points
601 _contourPropagation->GetInitialControlPoints( idTmp , &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
603 if (typeMethodFindCtrlPoints==1) // Automatique Method
605 _contourPropagation->GetControlPoints( idTmp ,&vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
607 if (typeMethodFindCtrlPoints==2) // sampling
609 _contourPropagation->GetControlPoints( idTmp , 20.0 ,&vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ);
611 //--------------------------------------------------------------------
612 sizeCtrPt = vecCtrlPointX.size();
613 for (j=0 ; j<sizeCtrPt ; j++)
615 //JSTG_16-07-08_----------------------------------------------------------------
616 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , -900 );
617 //--------------------------------------------------------------------
622 theName = _modelManager->createOutline( manModelContour, tempVector );
623 bool addedModel = theName.compare("") != 0;
626 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
627 this->_theViewPanel->getSpacing(spc);
628 //Adding the manualContourControler to interface objects structure
629 //Adding the manualViewContour to interface objects structure
630 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
631 _sceneManager->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
633 }// ifSliceKeyContourExist
635 _staticTextSpread->SetLabel(_T(" "));
636 //RefreshInterface();
642 //------------------------------------------------------------------------------------------------------------
643 void wxContourEventHandler :: onSpread( )
645 if (_spreadFrame==NULL)
648 _spreadFrame = new wxFrame (_theViewPanel, -1,_T(" Spread "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
650 wxSize sizepanel(250,400);
651 _spreadFrame->SetSize( sizepanel );
652 _spreadFrame->SetEventHandler( this );
653 wxPanel *panel = getSpreadPanel(_spreadFrame);
654 panel->SetSize(sizepanel);
655 /**new wxPanel(_spreadFrame,-1);
657 wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxSize(80,35) );
658 wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxSize(80,35));
660 wxString lstOptions[3];
664 _spreadMethodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
665 _spreadMethodRadiobox->SetSelection(2);
667 wxButton *spreadGoBtn = new wxButton(panel,-1,_T("Go"),wxDefaultPosition, wxSize(80,35));
668 _staticTextSpread = new wxStaticText(panel,-1,_T(" "));
670 _wxtextctrlSpread = new wxTextCtrl(panel,-1, "",wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE );
672 _spreadFrame->SetEventHandler( this );
673 Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadReset );
674 Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadAdd );
675 Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadGo );
677 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
678 sizer -> Add( spreadResetBtn , 1, wxGROW );
679 sizer -> Add( spreadAddBtn , 1, wxGROW );
680 sizer -> Add( _spreadMethodRadiobox , 1, wxGROW );
681 sizer -> Add( spreadGoBtn , 1, wxGROW );
682 sizer -> Add( _staticTextSpread , 1, wxGROW );
683 sizer -> Add( _wxtextctrlSpread , 1, wxGROW );
686 panel->SetSizer( sizer );
687 panel->SetSize( sizepanel );
688 panel->SetAutoLayout( true );
690 _spreadFrame->Show();
692 if (_spreadFrame->IsShown()==true)
694 _spreadFrame->Show(false);
696 _spreadFrame->Show(true);
701 wxPanel* wxContourEventHandler::getSpreadPanel(wxWindow* parent){
702 //wxPanel *panel = new wxPanel(parent,-1);
704 _contourPropagation = new ContourPropagation();
706 wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, /*wxString("")*/ _T("") );
708 wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxDefaultSize );
709 wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxDefaultSize);
711 wxString lstOptions[3];
712 lstOptions[0]=_T("A");
713 lstOptions[1]=_T("B");
714 lstOptions[2]=_T("C");
715 _spreadMethodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxDefaultSize, 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
716 _spreadMethodRadiobox->SetSelection(2);
718 wxButton *spreadGoBtn = new wxButton(panel,-1,_T("Go"),wxDefaultPosition, wxDefaultSize);
719 _staticTextSpread = new wxStaticText(panel,-1,_T(" "));
721 _wxtextctrlSpread = new wxTextCtrl(panel,-1, _T("") ,wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
724 Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadReset );
725 Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadAdd );
726 Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSpreadGo );
728 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
729 sizer -> Add( spreadResetBtn , 1, wxGROW );
730 sizer -> Add( spreadAddBtn , 1, wxGROW );
731 sizer -> Add( _spreadMethodRadiobox , 1, wxGROW );
732 sizer -> Add( spreadGoBtn , 1, wxGROW );
733 sizer -> Add( _staticTextSpread , 1, wxGROW );
734 sizer -> Add( _wxtextctrlSpread , 1, wxGROW );
737 panel->SetSizer( sizer );
738 //panel->SetSize( wxDefaultSize );
739 panel->SetAutoLayout( true );
744 //------------------------------------------------------------------------------------------------------------
745 void wxContourEventHandler::onSegmentationAllSlice( wxCommandEvent& event )
747 //JCP 20-10-08 Undo redo implementation
749 //JCP 20-10-08 Undo redo implementation
752 int x = this->_theViewPanel->GetX();
753 int y = this->_theViewPanel->GetY();
757 minZ=_mbarrange->GetStart();
758 maxZ=_mbarrange->GetEnd();
759 double totalZ = maxZ-minZ+1;
760 for( z=minZ ; z<=maxZ ; z++ )
762 porcent = 100.0* (z-minZ)/totalZ;
763 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
764 _staticTextSegmentation->SetLabel(tmpString);
765 SegmentationOneSlice( x,y,z );
767 _staticTextSegmentation->SetLabel(_T(" "));
773 //------------------------------------------------------------------------------------------------------------
774 void wxContourEventHandler::onSegmentationOneSlice( wxCommandEvent& event )
776 //JCP 20-10-08 Undo redo implementation
778 //JCP 20-10-08 Undo redo implementation
781 int x = this->_theViewPanel->GetX();
782 int y = this->_theViewPanel->GetY();
783 int z = this->_theViewPanel->GetZ();
784 SegmentationOneSlice( x,y,z );
789 //------------------------------------------------------------------------------------------------------------
790 void wxContourEventHandler::SegmentationOneSlice( int x, int y, int z )
792 int typeofcontour = 1;
793 //--Extracting Contour
794 vtkImageData *imagedata = _sceneManager->GetImageData();
795 // double *range = imagedata->GetScalarRange();
797 int isovalue = _isovalue->GetValue();
798 int sampling = _sampling->GetValue();
800 vtkImageReslice *imageReslice = vtkImageReslice::New();
803 // imagedata->GetSpacing(spc);
808 imageReslice->SetInput( imagedata );
809 imageReslice->SetInformationInput(imagedata);
810 imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
811 imageReslice->SetResliceAxesOrigin(0,0,z);
812 imageReslice->SetOutputDimensionality(2);
813 imageReslice->SetInterpolationModeToLinear();
815 imagedata = imageReslice->GetOutput();
817 imagedata->UpdateInformation();
819 vtkContourFilter* cntVTK = vtkContourFilter::New( );
820 cntVTK->SetInput( imagedata );
822 cntVTK->SetNumberOfContours( 1 );
823 //cntVTK->SetValue( 0, vmin );
824 // cntVTK->SetValue( 0, (range[1]*thr/100) );
825 cntVTK->SetValue( 1, isovalue );
826 // cntVTK->SetValue( 1, vmax );
828 cntVTK->UpdateInformation();
830 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
831 cpd->SetInput( cntVTK->GetOutput( ) );
832 cpd->ConvertLinesToPointsOff( );
834 cpd->UpdateInformation();
836 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
837 conn->SetExtractionModeToClosestPointRegion( );
838 //conn->SetMaxRecursionDepth( 3000 );
840 conn->SetInput( cpd->GetOutput( ) );
842 conn->SetClosestPoint( x, y, 0 );
844 conn->UpdateInformation();
846 vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
847 cpd2->SetInput( conn->GetOutput( ) );
849 cpd2->UpdateInformation();
851 vtkStripper* vtkstripper = vtkStripper::New( );
852 vtkstripper->SetInput( cpd2->GetOutput() );
853 vtkstripper->Update();
854 vtkstripper->UpdateInformation();
857 vtkPolyData* polyDataResult = vtkstripper->GetOutput();
859 polyDataResult->Update( );
860 polyDataResult->UpdateInformation();
864 myfile.open ("c:/temp/example.txt");
866 polyDataResult->Print(myfile);
867 myfile << "-------------------------------------\n";
868 polyDataResult->GetLines()->Print(myfile);
878 //--Calculating control points
880 std::vector<double> vecX;
881 std::vector<double> vecY;
882 std::vector<double> vecZ;
884 std::vector<double> vecCtrlPointX;
885 std::vector<double> vecCtrlPointY;
886 std::vector<double> vecCtrlPointZ;
890 int ii,size=polyDataResult->GetNumberOfPoints();
892 for (ii=1;ii<=size;ii++)
894 id = polyDataResult->GetLines()->GetData()->GetValue(ii);
895 p = polyDataResult->GetPoint(id);
898 vecX.push_back( p[0] );
899 vecY.push_back( p[1] );
900 vecZ.push_back( -900 );
901 // vecZ.push_back( p[2] );
905 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
906 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
909 if (methodRadiobox->GetSelection()==0){
910 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
912 if (methodRadiobox->GetSelection()==1){
913 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
915 if (methodRadiobox->GetSelection()==2){
916 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
917 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
920 //--Adding contour to the system
922 std::vector<int> actualInstantVector;
923 _instantPanel->getInstant( actualInstantVector );
924 actualInstantVector[1]=z;
926 int j,sizeCtrPt = vecCtrlPointX.size();
927 manualContourModel *manModelContour = factoryManualContourModel( typeofcontour );
928 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
930 for (j=0 ; j<sizeCtrPt ; j++)
932 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
935 theName = _modelManager->createOutline( manModelContour, actualInstantVector );
936 bool addedModel = theName.compare("") != 0;
939 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
940 this->_theViewPanel->getSpacing(spc);
941 //Adding the manualContourControler to interface objects structure
942 //Adding the manualViewContour to interface objects structure
943 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
944 _sceneManager->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
949 //------------------------------------------------------------------------------------------------------------
950 void wxContourEventHandler :: onAutomatiqueSegmentation( )
952 if (_segmentationFrame==NULL)
955 /*int sizeZ = _sceneManager->GetImageDataSizeZ();
957 _sceneManager->GetImageDataRange(range);*/
960 wxSize sizePanel( 300, 470);
961 _segmentationFrame = new wxFrame (_theViewPanel, -1,_T(" Segmentation "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
962 _segmentationFrame->SetSize( sizePanel );
963 wxPanel *panel = getSegmentationPanel(_segmentationFrame);
964 /*new wxPanel(_segmentationFrame,-1);
965 wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
966 wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
967 _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
968 _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
969 wxString lstOptions[3];
973 methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
974 methodRadiobox->SetSelection(2);
975 _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
978 _mbarrange = new mBarRange(panel,70, 65);
979 _mbarrange->SetMin(0);
980 _mbarrange->SetStart(0);
982 _mbarrange-> SetOrientation( true );
983 _mbarrange-> setActiveStateTo(true);
984 _mbarrange-> setVisibleLabels( true );
985 _mbarrange-> setDeviceEndMargin(10);
986 _mbarrange-> setRepresentedValues( 0 , sizeZ );
987 _mbarrange-> setDeviceBlitStart(10,10);
988 _mbarrange-> setIfWithActualDrawed( false );
989 _mbarrange-> SetStart( 0 );
990 _mbarrange-> SetEnd( sizeZ );
993 // _segmentationFrame->SetEventHandler( this );
994 segmentationOneSliceBtn->SetEventHandler( this );
995 segmentationAllSliceBtn->SetEventHandler( this );
996 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSlice );
997 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSlice );
999 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
1000 sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
1001 sizer -> Add( _isovalue , 1, wxGROW );
1002 sizer -> Add( methodRadiobox , 1, wxGROW );
1003 sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
1004 sizer -> Add( _sampling , 1, wxGROW );
1005 sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
1006 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
1007 sizer -> Add( _staticTextSegmentation , 1, wxGROW );
1008 sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
1009 sizer -> Add( _mbarrange , 1, wxGROW );
1011 panel->SetSizer( sizer );
1012 panel->SetSize( sizePanel );
1013 panel->SetAutoLayout( true );
1016 this->_theViewPanel->SetVisibleAxis(true);
1017 this->_theViewPanel->Refresh();
1018 _segmentationFrame->Show(true);
1019 //JCP 13-10-09 View the method getSegmentationPanel(), this two methods where moved to getSegmentationPanel
1020 //this->_theViewPanel->SetVisibleAxis(true);
1021 //this->_theViewPanel->Refresh();
1023 if (_segmentationFrame->IsShown()==true)
1025 _segmentationFrame->Show(false);
1026 this->_theViewPanel->SetVisibleAxis(false);
1027 this->_theViewPanel->Refresh();
1029 _segmentationFrame->Show(true);
1030 this->_theViewPanel->SetVisibleAxis(true);
1031 this->_theViewPanel->Refresh();
1036 void wxContourEventHandler::showAxis(bool show){
1037 this->_theViewPanel->SetVisibleAxis(show);
1038 this->_theViewPanel->Refresh();
1040 wxPanel* wxContourEventHandler::getSegmentationPanel(wxWindow* parent){
1041 int sizeZ = _sceneManager->GetImageDataSizeZ();
1043 _sceneManager->GetImageDataRange(range);
1045 wxPanel *panel = new wxPanel(parent,-1);
1046 wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
1047 wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
1048 _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
1049 _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
1050 wxString lstOptions[3];
1051 lstOptions[0]=_T("A");
1052 lstOptions[1]=_T("B");
1053 lstOptions[2]=_T("C");
1054 methodRadiobox = new wxRadioBox(panel, -1, _T("Method (find ctrl. Points)"), wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
1055 methodRadiobox->SetSelection(2);
1056 _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
1059 _mbarrange = new mBarRange(panel,70, 65);
1060 _mbarrange->SetMin(0);
1061 _mbarrange->SetStart(0);
1063 _mbarrange-> SetOrientation( true );
1064 _mbarrange-> setActiveStateTo(true);
1065 _mbarrange-> setVisibleLabels( true );
1066 _mbarrange-> setDeviceEndMargin(10);
1067 _mbarrange-> setRepresentedValues( 0 , sizeZ );
1068 _mbarrange-> setDeviceBlitStart(10,10);
1069 _mbarrange-> setIfWithActualDrawed( false );
1070 _mbarrange-> SetStart( 0 );
1071 _mbarrange-> SetEnd( sizeZ );
1074 // _segmentationFrame->SetEventHandler( this );
1075 segmentationOneSliceBtn->SetEventHandler( this );
1076 segmentationAllSliceBtn->SetEventHandler( this );
1077 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSlice );
1078 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSlice );
1080 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
1081 sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
1082 sizer -> Add( _isovalue , 1, wxGROW );
1083 sizer -> Add( methodRadiobox , 1, wxGROW );
1084 sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
1085 sizer -> Add( _sampling , 1, wxGROW );
1086 sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
1087 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
1088 sizer -> Add( _staticTextSegmentation , 1, wxGROW );
1089 sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
1090 sizer -> Add( _mbarrange , 1, wxGROW );
1092 panel->SetSizer( sizer );
1093 // panel->SetSize( sizePanel );
1094 panel->SetSize( wxDefaultSize );
1095 panel->SetAutoLayout( true );
1100 void wxContourEventHandler :: onInterfaceTestFrame( )
1102 if (_TestFrame==NULL)
1104 _contourPropagation = new ContourPropagation();
1105 _TestFrame = new wxFrame (_theViewPanel, -1,_T(" Test Segmentation "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
1106 wxSize sizepanel(200,300);
1107 _TestFrame->SetSize( sizepanel );
1108 wxPanel *panel = new wxPanel(_TestFrame,-1);
1109 wxButton *spreadResetBtn = new wxButton(panel,-1,_T("Reset"),wxDefaultPosition, wxSize(80,35) );
1110 wxButton *spreadAddBtn = new wxButton(panel,-1,_T("Add"),wxDefaultPosition, wxSize(80,35));
1111 wxButton *spreadGoBtn = new wxButton(panel,-1,_T("GoA"),wxDefaultPosition, wxSize(80,35));
1112 _wxtextctrlTest = new wxTextCtrl(panel,-1, _T(""),wxDefaultPosition, wxSize(200,150), wxTE_MULTILINE );
1114 _TestFrame->SetEventHandler( this );
1115 Connect( spreadResetBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestReset );
1116 Connect( spreadAddBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestAdd );
1117 Connect( spreadGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onTestGo );
1119 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
1120 sizer -> Add( spreadResetBtn , 1, wxGROW );
1121 sizer -> Add( spreadAddBtn , 1, wxGROW );
1122 sizer -> Add( spreadGoBtn , 1, wxGROW );
1123 sizer -> Add( _wxtextctrlTest , 1, wxGROW );
1125 panel->SetSizer( sizer );
1126 panel->SetSize( sizepanel );
1127 panel->SetAutoLayout( true );
1131 if (_TestFrame->IsShown()==true)
1133 _TestFrame->Show(false);
1135 _TestFrame->Show(true);
1140 void wxContourEventHandler::onTestReset( wxCommandEvent& event )
1142 _wxtextctrlTest->SetValue(_T(""));
1143 _contourPropagation->resetAppend();
1146 //------------------------------------------------------------------------------------------------------------
1147 void wxContourEventHandler::onTestAdd( wxCommandEvent& event )
1149 std::vector<double> vecX;
1150 std::vector<double> vecY;
1151 std::vector<double> vecZ;
1152 _sceneManager->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
1154 if (vecX.size()!=0){
1155 std::vector<int> tempVector;
1156 _instantPanel->getInstant( tempVector );
1157 int i,size=vecZ.size();
1158 int actualSlice = tempVector[1];
1159 for ( i=0 ; i<size ; i++ )
1161 vecZ[i] = actualSlice;
1164 _contourPropagation->appendContour(&vecX , &vecY , &vecZ);
1165 wxString newstring1( _wxtextctrlTest->GetValue().c_str() , wxConvUTF8);
1166 wxString newstring2;
1167 newstring2.Printf(_T(" %d -"), actualSlice );
1170 newstring = newstring1+newstring2;
1172 //newstring.Printf("%s %d -",_wxtextctrlTest->GetValue(), actualSlice );
1174 _wxtextctrlTest->SetValue(newstring);
1178 //------------------------------------------------------------------------------------------------------------
1179 void wxContourEventHandler::onTestGo( wxCommandEvent& event )
1181 std::vector<double> vecX;
1182 std::vector<double> vecY;
1183 std::vector<double> vecZ;
1184 std::vector<int> size;
1186 std::vector<double> vecCtrlPointX;
1187 std::vector<double> vecCtrlPointY;
1188 std::vector<double> vecCtrlPointZ;
1190 //Getting the points of the actual contour
1192 _contourPropagation->GetKeyContours(&vecX , &vecY , &vecZ, &size);
1193 for(int i = 0; i < vecX.size();i++){
1197 /*std::vector<double> vecX1;
1198 std::vector<double> vecY1;
1199 std::vector<double> vecZ1;
1200 _sceneManager->GetPointsOfActualContour( &vecX1 , &vecY1 , &vecZ1 );
1202 std::ofstream file1;
1203 file1.open( "Temp.txt" );
1206 for(int i = 0; i < vecX.size(); i++){
1207 file1<<vecX[i] <<" X1 "<< vecX1[i] <<" Y "<<vecY[i] <<" Y1 "<< vecY1[i] <<" Z "<<vecZ[i] <<" Z1 "<< vecZ1[i]<<std::endl;
1215 //Setting the points of the contour
1217 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
1218 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
1220 //Getting the control points of the contour by method A
1222 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1224 std::vector<int> actualInstantVector;
1225 _instantPanel->getInstant( actualInstantVector );
1226 actualInstantVector[1]= this->_theViewPanel->GetZ();
1232 //Adding the Contour to the scene
1234 manualContourModel *manModelContour = new manualContourModel();
1235 int j,sizeCtrPt = vecCtrlPointX.size();
1237 for (j=0 ; j<sizeCtrPt ; j++)
1239 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
1241 std::string theName;
1242 theName = _modelManager->createOutline( manModelContour, actualInstantVector );
1243 bool addedModel = theName.compare("") != 0;
1246 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1247 this->_theViewPanel->getSpacing(spc);
1248 //Adding the manualContourControler to interface objects structure
1249 //Adding the manualViewContour to interface objects structure
1250 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1251 _sceneManager->configureViewControlTo( theName, manModelContour,spc,1 ) ;
1256 //------------------------------------------------------------------------------------------------------------
1257 void wxContourEventHandler::FillGridWithContoursInformation()
1260 _grid->SetColLabelValue(0, _T("A") );
1261 _grid->SetColLabelValue(1, _T("B") );
1262 _grid->SetColLabelValue(2, _T("C") );
1263 _grid->SetColLabelValue(3, _T("D") );
1264 _grid->SetColLabelValue(4, _T("E") );
1265 _grid->SetColLabelValue(5, _T("F") );
1267 std::vector<int> tempVector;
1268 _instantPanel->getInstant( tempVector );
1270 int z,sizeZ = _sceneManager->GetImageDataSizeZ();
1271 int ii,sizeLstContourThings;
1272 for ( z=0 ; z<sizeZ ; z++)
1275 Instant instant(&tempVector);
1276 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1278 sizeLstContourThings = lstContourThings.size();
1279 wxString tempString;
1280 tempString.Printf(_T("%d - %d"),
1282 sizeLstContourThings);
1284 _grid->SetRowLabelValue(z, tempString );
1286 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1288 ContourThing **contourthing = lstContourThings[ii];
1289 //wxString tempString = (*contourthing)->getName() ; // Doesn't compile. See Creatis Wiki !
1290 const wxString tempString2((*contourthing)->getName().c_str(),wxConvUTF8 );
1291 _grid->SetCellValue( z, ii, tempString2 );
1298 //------------------------------------------------------------------------------------------------------------
1299 std::vector<manualContourModel*> wxContourEventHandler::ExploseEachModel( std::vector<manualContourModel*> lstManConMod )
1301 std::vector<manualContourModel*> lstTmp;
1302 std::vector<manualContourModel*> lstResult;
1304 int i,iSize=lstManConMod.size();
1305 for (i=0;i<iSize;i++)
1307 lstTmp = lstManConMod[i]->ExploseModel();
1308 jSize=lstTmp.size();
1309 for (j=0;j<jSize;j++)
1311 lstResult.push_back( lstTmp[j] );
1317 //------------------------------------------------------------------------------------------------------------
1318 void wxContourEventHandler::onExtractInformation( wxCommandEvent& event )
1321 int maxContourGroup = 0;
1325 ContourExtractData *contourextractdata = new ContourExtractData();
1326 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1327 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1329 std::vector<manualContourModel*> lstManConMod;
1330 std::vector<manualContourModel*> lstManConModTmp;
1331 std::vector<manualContourModel*> lstManConModExp;
1332 std::vector<double> pLstValue;
1333 std::vector<double> pLstValuePosX;
1334 std::vector<double> pLstValuePosY;
1335 std::vector<double> pLstValuePosZ;
1338 int resultGrayRangeCount;
1341 double resultAverage;
1342 double resultStandardeviation;
1344 std::vector<int> tempVector;
1345 _instantPanel->getInstant( tempVector );
1347 vtkImageData *imagedata = _sceneManager->GetImageData();
1348 int sizeZ = _sceneManager->GetImageDataSizeZ();
1350 int ii,sizeLstContourThings;
1359 if (_informationRadiobox->GetSelection()==0 ) // actual slice
1361 std::vector<int> tempVector;
1362 _instantPanel->getInstant( tempVector );
1363 int actualSlice = tempVector[1];
1367 if (_informationRadiobox->GetSelection()==1 ) // slice range
1369 minZ = _mbarrangeSliceInformation->GetStart();
1370 maxZ = _mbarrangeSliceInformation->GetEnd();
1372 if (_informationRadiobox->GetSelection()==2 ) // All slices
1378 totalZ = maxZ-minZ+1;
1379 contourextractdata->SetImage( imagedata);
1382 for ( z=minZ ; z<=maxZ ; z++ )
1384 porcent = 100.0* (z-minZ)/totalZ;
1385 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1386 _staticTextInformation->SetLabel(tmpString);
1388 //Extraction data from contours of each slice
1389 contourextractdata->SetZtoBeAnalys( z);
1392 Instant instant(&tempVector);
1393 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1394 sizeLstContourThings = lstContourThings.size();
1396 lstManConMod.clear();
1397 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1399 ContourThing **contourthing = lstContourThings[ii];
1400 lstManConMod.push_back( (*contourthing)->getModel() );
1402 lstManConModExp = ExploseEachModel( lstManConMod );
1405 wxString tempString;
1406 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
1407 _grid->SetRowLabelValue(z, tempString );
1409 int iContourGroup,sizeContourGroup;
1410 if (typeContourGroup==3) // contour separete
1412 sizeContourGroup=lstManConModExp.size();
1413 if ( maxContourGroup<sizeContourGroup )
1415 maxContourGroup=sizeContourGroup;
1417 } else { // contour AND OR XOR
1426 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1427 lstManConModTmp.clear();
1428 if (typeContourGroup==3) // contour separete
1430 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1431 } else { // contour AND OR XOR
1432 lstManConModTmp = lstManConModExp;
1435 contourextractdata->SetLstManualContourModel( lstManConModTmp );
1438 pLstValuePosX.clear();
1439 pLstValuePosY.clear();
1440 pLstValuePosZ.clear();
1441 contourextractdata->GetValuesInsideCrown( &pLstValue,
1445 // Statistics of each slice.
1446 contourextractdata->Statistics( &pLstValue,
1447 _mbarrangeRangeInformation->GetStart(),
1448 _mbarrangeRangeInformation->GetEnd(),
1449 &resultGrayRangeCount,
1454 &resultStandardeviation);
1455 if (_grid->GetNumberCols()<_numberOfVariablesStatistics*(iContourGroup+1) )
1457 _grid->AppendCols(_numberOfVariablesStatistics);
1460 tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
1462 tempString.Printf(_T("%d"),resultSize);
1463 _grid->SetCellValue( z, tmpIntA + 0, tempString );
1464 tempString.Printf(_T("%d"),resultGrayRangeCount);
1465 _grid->SetCellValue( z, tmpIntA + 1, tempString );
1466 tempString.Printf(_T("%f"),resultMin);
1467 _grid->SetCellValue( z, tmpIntA + 2, tempString );
1468 tempString.Printf(_T("%f"),resultMax);
1469 _grid->SetCellValue( z, tmpIntA + 3, tempString );
1470 tempString.Printf(_T("%f"),resultAverage);
1471 _grid->SetCellValue( z, tmpIntA + 4, tempString );
1472 tempString.Printf(_T("%f"),resultStandardeviation);
1473 _grid->SetCellValue( z, tmpIntA + 5, tempString );
1475 } // for iContourGroup
1479 wxString tmpTitleString;
1481 for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
1483 tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
1484 tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
1485 _grid->SetColLabelValue( tmpIntB + 0, tmpTitleString );
1486 _grid->SetColLabelValue( tmpIntB + 1, _T("Size Range") );
1487 _grid->SetColLabelValue( tmpIntB + 2, _T("Min") );
1488 _grid->SetColLabelValue( tmpIntB + 3, _T("Max") );
1489 _grid->SetColLabelValue( tmpIntB + 4, _T("Average") );
1490 _grid->SetColLabelValue( tmpIntB + 5, _T("St.Dev.") );
1491 _grid->SetColLabelValue( tmpIntB + 6, _T(" ") );
1494 _staticTextInformation->SetLabel( _T("") );
1495 delete contourextractdata;
1499 //------------------------------------------------------------------------------------------------------------
1500 void wxContourEventHandler::SaveValuesXYZ(std::string directory,std::string namefile)
1503 ContourExtractData *contourextractdata = new ContourExtractData();
1504 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1505 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1507 std::vector<manualContourModel*> lstManConMod;
1508 std::vector<manualContourModel*> lstManConModTmp;
1509 std::vector<manualContourModel*> lstManConModExp;
1510 std::vector<double> pLstValue;
1511 std::vector<double> pLstValuePosX;
1512 std::vector<double> pLstValuePosY;
1513 std::vector<double> pLstValuePosZ;
1515 std::vector<int> tempVector;
1516 _instantPanel->getInstant( tempVector );
1518 vtkImageData *imagedata = _sceneManager->GetImageData();
1519 int sizeZ = _sceneManager->GetImageDataSizeZ();
1521 int ii,sizeLstContourThings;
1528 minZ = 0;// _mbarrange->GetStart();
1529 maxZ = sizeZ;//_mbarrange->GetEnd();
1530 totalZ = maxZ-minZ+1;
1532 contourextractdata->SetImage( imagedata);
1535 for ( z=0 ; z<sizeZ ; z++)
1538 porcent = 100.0* (z-minZ)/totalZ;
1539 tmpString.Printf(_T("Saving Values %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1540 _staticTextInformation->SetLabel(tmpString);
1543 //Extraction data from contours of each slice
1544 contourextractdata->SetZtoBeAnalys( z);
1547 Instant instant(&tempVector);
1548 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1549 sizeLstContourThings = lstContourThings.size();
1551 lstManConMod.clear();
1552 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1554 ContourThing **contourthing = lstContourThings[ii];
1555 lstManConMod.push_back( (*contourthing)->getModel() );
1557 lstManConModExp = ExploseEachModel( lstManConMod );
1562 int iContourGroup,sizeContourGroup;
1563 if (typeContourGroup==3) // contour separete
1565 sizeContourGroup=lstManConModExp.size();
1566 } else { // contour AND OR XOR
1570 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1571 lstManConModTmp.clear();
1572 if (typeContourGroup==3) // contour separete
1574 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1575 } else { // contour AND OR XOR
1576 lstManConModTmp = lstManConModExp;
1579 contourextractdata->SetLstManualContourModel( lstManConModTmp );
1582 pLstValuePosX.clear();
1583 pLstValuePosY.clear();
1584 pLstValuePosZ.clear();
1585 contourextractdata->GetValuesInsideCrown( &pLstValue,
1591 filename.Printf(_T("%s\\%s-slice%d-cont%d.txt"),directory.c_str(),namefile.c_str(),z,iContourGroup);
1592 FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
1593 fprintf(pFile,"value \t x \t y \t z\n" );
1594 int iLstValue,sizeLstValue=pLstValue.size();
1595 for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
1597 fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
1600 } // for iContourGroup
1602 _staticTextInformation->SetLabel( _T("") );
1603 delete contourextractdata;
1607 //------------------------------------------------------------------------------------------------------------
1608 void wxContourEventHandler::SaveImageResult(std::string directory,std::string namefile)
1611 ContourExtractData *contourextractdata = new ContourExtractData( true );
1612 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
1613 if (typeContourGroup==3)
1617 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
1619 std::vector<manualContourModel*> lstManConMod;
1620 std::vector<manualContourModel*> lstManConModTmp;
1621 std::vector<manualContourModel*> lstManConModExp;
1623 std::vector<int> tempVector;
1624 _instantPanel->getInstant( tempVector );
1626 vtkImageData *imagedata = _sceneManager->GetImageData();
1627 int sizeZ = _sceneManager->GetImageDataSizeZ();
1629 int ii,sizeLstContourThings;
1638 minZ = 0;// _mbarrange->GetStart();
1639 maxZ = sizeZ;//_mbarrange->GetEnd();
1640 totalZ = maxZ-minZ+1;
1642 contourextractdata->SetImage( imagedata);
1645 for ( z=0 ; z<sizeZ ; z++)
1648 porcent = 100.0* (z-minZ)/totalZ;
1649 tmpString.Printf(_T("Saving Values %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
1650 _staticTextInformation->SetLabel(tmpString);
1652 //Extraction data from contours of each slice
1653 contourextractdata->SetZtoBeAnalys( z);
1656 Instant instant(&tempVector);
1657 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
1658 sizeLstContourThings = lstContourThings.size();
1660 lstManConMod.clear();
1661 for (ii=0 ; ii<sizeLstContourThings ; ii++)
1663 ContourThing **contourthing = lstContourThings[ii];
1664 lstManConMod.push_back( (*contourthing)->getModel() );
1666 lstManConModExp = ExploseEachModel( lstManConMod );
1669 int iContourGroup,sizeContourGroup;
1670 if (typeContourGroup==3) // contour separete
1672 sizeContourGroup=lstManConModExp.size();
1673 } else { // contour AND OR XOR
1677 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
1678 lstManConModTmp.clear();
1679 if (typeContourGroup==3) // contour separete
1681 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
1682 } else { // contour AND OR XOR
1683 lstManConModTmp = lstManConModExp;
1686 contourextractdata->SetLstManualContourModel( lstManConModTmp );
1689 // for (ii=0 ; ii<sizeLstContourThings ; ii++)
1691 // ContourThing **contourthing = lstContourThings[ii];
1692 // lstManConMod.push_back( (*contourthing)->getModel() );
1694 // contourextractdata->SetLstManualContourModel( lstManConMod );
1696 contourextractdata->CalculateImageResult(); // with actual Z
1698 } // for iContourGroup
1703 filename.Printf(_T("%s\\%s-Value.mhd"),directory.c_str(),namefile.c_str(),z);
1706 vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
1707 writerValueImage->SetInput( contourextractdata->GetVtkImageValueResult() );
1708 writerValueImage->SetFileName( (const char *)filename.mb_str() );
1709 writerValueImage->SetFileDimensionality( 3 );
1710 writerValueImage->Write( );
1713 filename.Printf(_T("%s\\%s-Mask.mhd"),directory.c_str(),namefile.c_str(),z);
1714 vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
1715 writerMaskImage->SetInput( contourextractdata->GetVtkImageMaskResult() );
1716 writerMaskImage->SetFileName( (const char *)filename.mb_str() );
1717 writerMaskImage->SetFileDimensionality( 3 );
1718 writerMaskImage->Write( );
1720 _staticTextInformation->SetLabel( _T("") );
1721 delete contourextractdata;
1725 //------------------------------------------------------------------------------------------------------------
1726 void wxContourEventHandler::onInformationContourLabels( wxCommandEvent& event )
1729 FillGridWithContoursInformation();
1733 //------------------------------------------------------------------------------------------------------------
1734 void wxContourEventHandler::onSaveResults( wxCommandEvent& event )
1736 wxFileDialog dialog(_InformationContourFrame, _T("Choose a file"), _T(""), _T(""), _T("*.txt"), wxSAVE );
1737 if (dialog.ShowModal() == wxID_OK)
1739 onExtractInformation( event );
1740 std::string directory=(const char *)(dialog.GetDirectory().mb_str());
1741 std::string namefile=(const char *)(dialog.GetFilename().mb_str());
1743 SaveValuesXYZ( directory , namefile );
1744 SaveImageResult( directory , namefile );
1746 std::string filename = (const char *)(dialog.GetPath().mb_str() );
1747 FILE *pFile=fopen(filename.c_str(),"w+");
1749 int sizeZ = _sceneManager->GetImageDataSizeZ();
1752 int i,j,maxX,maxY=sizeZ;
1753 maxX=this->_grid->GetNumberCols();
1755 int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
1756 for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
1758 fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.char_str() );
1760 fprintf(pFile,"\n" );
1764 for ( j=0; j<maxY ; j++)
1766 fprintf(pFile,"%d\t" , j );
1767 for (i=0 ; i<maxX ; i++){
1768 tmpString = _grid->GetCellValue( j , i );
1769 fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
1771 fprintf(pFile,"\n" );
1781 //------------------------------------------------------------------------------------------------------------
1782 void wxContourEventHandler::onInformationContourFrame()
1784 if (_InformationContourFrame==NULL)
1786 _InformationContourFrame = new wxFrame (_theViewPanel, -1,_T(" Information "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
1787 _InformationContourFrame->SetSize( wxSize(500,450) );
1788 wxSize sizepanel(200,300);
1789 wxPanel *panel = getInformationPanel(_InformationContourFrame);
1790 //JCP 13-10-09 Grouping the panel in a method
1791 /*new wxPanel(_InformationContourFrame,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
1793 wxString lstOptions[4];
1794 lstOptions[0]=_T("Actual Slice");
1795 lstOptions[1]=_T("Range Slices");
1796 lstOptions[2]=_T("All Slices");
1797 _informationRadiobox = new wxRadioBox(panel, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
1799 wxString lstOptContOperation[5];
1800 lstOptContOperation[0]=_T("AND");
1801 lstOptContOperation[1]=_T("OR");
1802 lstOptContOperation[2]=_T("XOR");
1803 lstOptContOperation[3]=_T("ALL");
1804 _radiolstboxContourGroup = new wxRadioBox(panel, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
1806 wxButton *informationContourLabelsBtn = new wxButton(panel,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
1807 informationContourLabelsBtn->SetEventHandler( this );
1808 Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onInformationContourLabels );
1810 wxButton *statisticsContourBtn = new wxButton(panel,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
1811 statisticsContourBtn->SetEventHandler( this );
1812 Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onExtractInformation );
1814 wxButton *saveResultsBtn = new wxButton(panel,-1,_T("Save statistics results"),wxDefaultPosition, wxSize(140,35) );
1815 saveResultsBtn->SetEventHandler( this );
1816 Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSaveResults );
1819 int sizeZ = this->_sceneManager->GetImageDataSizeZ();
1820 _mbarrangeSliceInformation = new mBarRange(panel,65,65);
1821 _mbarrangeSliceInformation->SetMin(0);
1822 _mbarrangeSliceInformation->SetStart(0);
1823 _mbarrangeSliceInformation-> SetOrientation( true );
1824 _mbarrangeSliceInformation-> setActiveStateTo(true);
1825 _mbarrangeSliceInformation-> setVisibleLabels( true );
1826 _mbarrangeSliceInformation-> setDeviceEndMargin(10);
1827 _mbarrangeSliceInformation-> setRepresentedValues( 0 , sizeZ-1 );
1828 _mbarrangeSliceInformation-> setDeviceBlitStart(10,10);
1829 _mbarrangeSliceInformation-> setIfWithActualDrawed( false );
1830 _mbarrangeSliceInformation-> SetStart( 0 );
1831 _mbarrangeSliceInformation-> SetEnd( sizeZ-1 );
1835 this->_sceneManager->GetImageDataRange(range);
1836 _mbarrangeRangeInformation = new mBarRange(panel,65,65);
1837 _mbarrangeRangeInformation->SetMin(0);
1838 _mbarrangeRangeInformation->SetStart(0);
1839 _mbarrangeRangeInformation-> SetOrientation( true );
1840 _mbarrangeRangeInformation-> setActiveStateTo(true);
1841 _mbarrangeRangeInformation-> setVisibleLabels( true );
1842 _mbarrangeRangeInformation-> setDeviceEndMargin(10);
1843 _mbarrangeRangeInformation-> setRepresentedValues( range[0] , range[1] );
1844 _mbarrangeRangeInformation-> setDeviceBlitStart(10,10);
1845 _mbarrangeRangeInformation-> setIfWithActualDrawed( false );
1846 _mbarrangeRangeInformation-> SetStart( range[0] );
1847 _mbarrangeRangeInformation-> SetEnd( range[1] );
1850 _staticTextInformation = new wxStaticText(panel,-1,_T(" "));
1853 // wxButton *XXXXXXXBtn = new wxButton(panel,-1,_T("Statistics"),wxDefaultPosition, wxSize(180,35) );
1854 // XXXXXXXBtn->SetEventHandler( this );
1855 // Connect( XXXXXXXBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onXXXXX );
1858 _grid = new wxGrid( panel,
1861 wxSize( 100, 100 ) );
1863 int i,gridCol=10,gridRow=sizeZ;
1864 _grid->CreateGrid( 0, 0 );
1865 _grid->AppendRows(gridRow);
1866 _grid->AppendCols(gridCol);
1868 for (i=0;i<gridRow;i++)
1870 _grid->SetRowLabelValue(i, _T(" ") );
1872 // _grid->SetColLabelSize(0);
1875 FillGridWithContoursInformation();
1877 wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
1878 sizerA->Add( _informationRadiobox , 1, wxALL ,2 );
1879 sizerA->Add( _radiolstboxContourGroup , 1, wxALL ,2 );
1881 wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
1882 sizerB->Add( informationContourLabelsBtn , 1, wxALL ,2 );
1883 sizerB->Add( statisticsContourBtn , 1, wxALL ,2 );
1884 sizerB->Add( saveResultsBtn , 1, wxALL ,2 );
1886 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
1887 sizer->AddGrowableCol(0);
1888 sizer->AddGrowableRow(7);
1889 sizer->Add( sizerA , 1, wxALL , 0 );
1890 sizer->Add( new wxStaticText(panel ,-1,_T("Slice Range")) , 1, wxALL , 0 );
1891 sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
1892 sizer->Add( new wxStaticText(panel ,-1,_T("Gray Range")) , 1, wxALL , 0 );
1893 sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
1894 sizer->Add( sizerB , 1, wxALL , 0 );
1895 sizer->Add( _staticTextInformation , 1, wxALL , 0 );
1896 sizer->Add( _grid , 1, wxEXPAND , 0 );
1900 panel->SetSizer( sizer );
1901 panel->SetSize( wxSize(1500,1500) );
1902 //panel->SetBackgroundColour( wxColour(100,100,100) );
1903 panel->SetAutoLayout( true );
1906 wxBoxSizer * sizerPanel = new wxBoxSizer(wxHORIZONTAL);
1908 // sizerPanel->AddGrowableCol(0);
1909 // sizerPanel->AddGrowableRow(0);
1912 //sizerPanel -> Add( sizer , 1, wxEXPAND ,0);
1913 sizerPanel -> Add( panel->GetSizer() , 1, wxEXPAND ,0);
1918 _InformationContourFrame->SetSizer( sizerPanel );
1919 _InformationContourFrame->SetAutoLayout( true );
1920 _InformationContourFrame->Layout();
1922 _InformationContourFrame->Show();
1924 if (_InformationContourFrame->IsShown()==true)
1926 _InformationContourFrame->Show(false);
1928 FillGridWithContoursInformation();
1929 _InformationContourFrame->Show(true);
1934 wxPanel* wxContourEventHandler::getInformationPanel(wxWindow* parent){
1935 wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxTAB_TRAVERSAL);
1937 wxString lstOptions[4];
1938 lstOptions[0]=_T("Actual Slice");
1939 lstOptions[1]=_T("Range Slices");
1940 lstOptions[2]=_T("All Slices");
1941 _informationRadiobox = new wxRadioBox(panel, -1, _T("Slice analysis"), wxDefaultPosition, wxSize(270,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
1943 wxString lstOptContOperation[5];
1944 lstOptContOperation[0]=_T("AND");
1945 lstOptContOperation[1]=_T("OR");
1946 lstOptContOperation[2]=_T("XOR");
1947 lstOptContOperation[3]=_T("ALL");
1948 _radiolstboxContourGroup = new wxRadioBox(panel, -1, _T("Contour group"), wxDefaultPosition, wxSize(270,45), 4 , lstOptContOperation, 4, wxRA_SPECIFY_COLS);
1950 wxButton *informationContourLabelsBtn = new wxButton(panel,-1,_T("Contour labels"),wxDefaultPosition, wxSize(140,35) );
1951 informationContourLabelsBtn->SetEventHandler( this );
1952 Connect( informationContourLabelsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onInformationContourLabels );
1954 wxButton *statisticsContourBtn = new wxButton(panel,-1,_T("Contour statistics"),wxDefaultPosition, wxSize(140,35) );
1955 statisticsContourBtn->SetEventHandler( this );
1956 Connect( statisticsContourBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onExtractInformation );
1958 wxButton *saveResultsBtn = new wxButton(panel,-1,_T("Save statistics results"),wxDefaultPosition, wxSize(140,35) );
1959 saveResultsBtn->SetEventHandler( this );
1960 Connect( saveResultsBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSaveResults );
1963 int sizeZ = this->_sceneManager->GetImageDataSizeZ();
1964 _mbarrangeSliceInformation = new mBarRange(panel,65,65);
1965 _mbarrangeSliceInformation->SetMin(0);
1966 _mbarrangeSliceInformation->SetStart(0);
1967 _mbarrangeSliceInformation-> SetOrientation( true );
1968 _mbarrangeSliceInformation-> setActiveStateTo(true);
1969 _mbarrangeSliceInformation-> setVisibleLabels( true );
1970 _mbarrangeSliceInformation-> setDeviceEndMargin(10);
1971 _mbarrangeSliceInformation-> setRepresentedValues( 0 , sizeZ-1 );
1972 _mbarrangeSliceInformation-> setDeviceBlitStart(10,10);
1973 _mbarrangeSliceInformation-> setIfWithActualDrawed( false );
1974 _mbarrangeSliceInformation-> SetStart( 0 );
1975 _mbarrangeSliceInformation-> SetEnd( sizeZ-1 );
1979 this->_sceneManager->GetImageDataRange(range);
1980 _mbarrangeRangeInformation = new mBarRange(panel,65,65);
1981 _mbarrangeRangeInformation->SetMin(0);
1982 _mbarrangeRangeInformation->SetStart(0);
1983 _mbarrangeRangeInformation-> SetOrientation( true );
1984 _mbarrangeRangeInformation-> setActiveStateTo(true);
1985 _mbarrangeRangeInformation-> setVisibleLabels( true );
1986 _mbarrangeRangeInformation-> setDeviceEndMargin(10);
1987 _mbarrangeRangeInformation-> setRepresentedValues( range[0] , range[1] );
1988 _mbarrangeRangeInformation-> setDeviceBlitStart(10,10);
1989 _mbarrangeRangeInformation-> setIfWithActualDrawed( false );
1990 _mbarrangeRangeInformation-> SetStart( range[0] );
1991 _mbarrangeRangeInformation-> SetEnd( range[1] );
1994 _staticTextInformation = new wxStaticText(panel,-1,_T(" "));
1997 // wxButton *XXXXXXXBtn = new wxButton(panel,-1,_T("Statistics"),wxDefaultPosition, wxSize(180,35) );
1998 // XXXXXXXBtn->SetEventHandler( this );
1999 // Connect( XXXXXXXBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onXXXXX );
2002 _grid = new wxGrid( panel,
2005 wxSize( 100, 100 ) );
2007 int i,gridCol=10,gridRow=sizeZ;
2008 _grid->CreateGrid( 0, 0 );
2009 _grid->AppendRows(gridRow);
2010 _grid->AppendCols(gridCol);
2012 for (i=0;i<gridRow;i++)
2014 _grid->SetRowLabelValue(i, _T(" ") );
2016 // _grid->SetColLabelSize(0);
2019 FillGridWithContoursInformation();
2021 wxFlexGridSizer * sizerA = new wxFlexGridSizer(10);
2022 sizerA->Add( _informationRadiobox , 1, wxALL ,2 );
2023 sizerA->Add( _radiolstboxContourGroup , 1, wxALL ,2 );
2025 wxFlexGridSizer * sizerB = new wxFlexGridSizer(10);
2026 sizerB->Add( informationContourLabelsBtn , 1, wxALL ,2 );
2027 sizerB->Add( statisticsContourBtn , 1, wxALL ,2 );
2028 sizerB->Add( saveResultsBtn , 1, wxALL ,2 );
2030 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
2031 sizer->AddGrowableCol(0);
2032 sizer->AddGrowableRow(7);
2033 sizer->Add( sizerA , 1, wxALL , 0 );
2034 sizer->Add( new wxStaticText(panel ,-1,_T("Slice Range")) , 1, wxALL , 0 );
2035 sizer->Add( _mbarrangeSliceInformation , 1, wxALL|wxGROW , 2 );
2036 sizer->Add( new wxStaticText(panel ,-1,_T("Gray Range")) , 1, wxALL , 0 );
2037 sizer->Add( _mbarrangeRangeInformation , 1, wxALL|wxGROW , 2 );
2038 sizer->Add( sizerB , 1, wxALL , 0 );
2039 sizer->Add( _staticTextInformation , 1, wxALL , 0 );
2040 sizer->Add( _grid , 1, wxEXPAND , 0 );
2044 panel->SetSizer( sizer );
2045 panel->SetSize( wxSize(1500,1500) );
2046 //panel->SetBackgroundColour( wxColour(100,100,100) );
2047 panel->SetAutoLayout( true );
2051 //------------------------------------------------------------------------------------------------------------
2052 void wxContourEventHandler :: onSpreadInDepth( std::vector<std::string> & keyNamesVector )
2056 //------------------------------------------------------------------------------------------------------------
2057 void wxContourEventHandler :: onOutline_Union_Of( std::vector<std::string> & keyNamesVector )
2061 //------------------------------------------------------------------------------------------------------------
2062 void wxContourEventHandler :: onOutline_Intersection_Of( std::vector<std::string> & keyNamesVector )
2066 //------------------------------------------------------------------------------------------------------------
2067 void wxContourEventHandler :: onOutline_Combination_Of( std::vector<std::string> & keyNamesVector )
2071 //------------------------------------------------------------------------------------------------------------
2072 void wxContourEventHandler :: onOutline_Fragmentation_Of( std::vector<std::string> & keyNamesVector )
2076 //------------------------------------------------------------------------------------------------------------
2077 void wxContourEventHandler :: onOutline_Agrupation_Of( std::vector<std::string> & keyNamesVector )
2081 //------------------------------------------------------------------------------------------------------------
2082 void wxContourEventHandler :: onCopyOutlines( std::vector<std::string> & keyNamesVector )
2084 std::vector<int> tempVector;
2085 _instantPanel->getInstant( tempVector );
2086 _performingOperation->reset();
2087 _performingOperation->setStartCommand( /*(char)*/wxContour_ActionCommandsID::COPY_TOOL );
2088 _performingOperation->setStartOperationInstantVector( tempVector );
2089 _performingOperation->setKeyNamesOperationElems( keyNamesVector );
2092 //------------------------------------------------------------------------------------------------------------
2093 void wxContourEventHandler :: onPasteOutlines( )
2095 char theStartCommand = _performingOperation->getStartCommand();
2096 if ( theStartCommand == wxContour_ActionCommandsID::COPY_TOOL )
2098 //JCP 20-10-08 Undo redo implementation
2100 //JCP 20-10-08 Undo redo implementation
2103 std::vector<int> tempVector;
2104 _instantPanel->getInstant( tempVector );
2105 _performingOperation->setEndOperationInstantVector ( tempVector );
2106 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
2107 int i,size = elems.size();
2108 for( i=0; i<size; i++ )
2110 createCopyContourOf( elems[i], tempVector, i>0 );
2117 //------------------------------------------------------------------------------------------------------------
2118 void wxContourEventHandler :: onShowOutlines( std::vector<std::string> & keyNamesVector )
2122 //------------------------------------------------------------------------------------------------------------
2123 void wxContourEventHandler :: onHideOutlines( std::vector<std::string> & keyNamesVector )
2127 //------------------------------------------------------------------------------------------------------------
2128 void wxContourEventHandler :: onSelectOutlines( std::vector<std::string> & keyNamesVector )
2130 //if( keyNamesVector.empty() )
2132 _sceneManager->drawSelectionROI( );
2136 int ok = keyNamesVector.size();
2137 _sceneManager->selectObjects( keyNamesVector );
2138 std::string name = keyNamesVector[0];
2141 _sceneManager->drawSelectionROI( );
2142 std::vector<std::string> currentSelection = _sceneManager->getSelectedObjects();
2143 int ok = currentSelection.size();
2144 _sceneManager->selectObjects( currentSelection );*/
2146 //------------------------------------------------------------------------------------------------------------
2147 void wxContourEventHandler :: onEditOutlines( std::vector<std::string> & keyNamesVector )
2151 //------------------------------------------------------------------------------------------------------------
2153 //------------------------------------------------------------------------------------------------------------
2154 void wxContourEventHandler :: deleteContour( std::string theKeyName )
2156 manualContourModel * cModel;
2157 manualViewBaseContour * cViewer;
2158 manualContourBaseControler * cControler;
2160 ContourWrap_ViewControl *conwrapviewControl = _sceneManager->getContourWrap_ViewControlOf( theKeyName );
2161 cControler = conwrapviewControl->getControler();
2162 int ispartofstaticlst= _modelManager->IsPartOfStaticList(theKeyName);
2163 if ((cControler!=NULL) && (cControler->IsEditable()==false) && (ispartofstaticlst==-1) )
2165 _sceneManager->removeFromScene( theKeyName );
2166 cModel = _modelManager->getOutlineByKeyName(theKeyName)->getModel();
2167 _modelManager->removeOutline( theKeyName );
2168 cViewer = conwrapviewControl->getViewer();
2169 _sceneManager->removeWrap( theKeyName );
2171 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
2172 //fprintf(ff,"EED wxContourEventHandler::deleteContours() \n" );
2173 //fprintf(ff," %s %p\n",keyNamesVector[i].c_str(), cControler );
2181 //------------------------------------------------------------------------------------------------------------
2182 void wxContourEventHandler :: deleteContours( std::vector<std::string> & keyNamesVector )
2184 int i,size=keyNamesVector.size();
2185 for (i=0;i<size;i++)
2187 deleteContour( keyNamesVector[i] );
2191 //------------------------------------------------------------------------------------------------------------
2192 void wxContourEventHandler :: deleteAllContours( )
2195 std::vector<int> tempVector;
2196 _instantPanel->getInstant( tempVector );
2198 //JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
2199 // the values in GetStart and GetEnd will then not be initialize also.
2200 // We use instead the values given when initializing the _deletepanel.
2202 //int minZ = _mbarrangeDeleteAll->GetStart();
2203 //int maxZ = _mbarrangeDeleteAll->GetEnd();
2207 maxZ = _sceneManager->GetImageDataSizeZ();
2211 _sceneManager->removeSceneContours( );
2212 _modelManager->removeAllOutlines();
2213 _sceneManager->removeAllOutlines();
2216 if ( (minZ==0) && (maxZ==_mbarrangeDeleteAll->GetMax() ))
2218 _sceneManager->removeSceneContours( );
2219 _modelManager->removeAllOutlines();
2220 _sceneManager->removeAllOutlines();
2223 for ( z=minZ ; z<=maxZ ; z++)
2226 Instant instant(&tempVector);
2227 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
2229 sizeLstContourThings = lstContourThings.size();
2230 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2232 ContourThing **contourthing = lstContourThings[ii];
2233 deleteContour( (*contourthing)->getName() );
2240 //------------------------------------------------------------------------------------------------------------
2241 void wxContourEventHandler::openContours( FILE *pFile, bool staticContour )
2244 fscanf(pFile,"%s",tmp); // NumberOfContours
2245 fscanf(pFile,"%s",tmp); // ##
2246 int numberOfContours = atoi(tmp);
2248 std::vector<int> instantVector;
2249 int typeContourModel;
2250 manualContourModel *manModelContour;
2254 for (i=0;i<numberOfContours;i++)
2256 instantVector.clear();
2257 fscanf(pFile,"%s",tmp); // Instant
2259 fscanf(pFile,"%s",tmp); // 1
2260 instantVector.push_back( atoi(tmp) );
2261 fscanf(pFile,"%s",tmp); // 2
2262 instantVector.push_back( atoi(tmp) );
2263 fscanf(pFile,"%s",tmp); // 3
2264 instantVector.push_back( atoi(tmp) );
2265 fscanf(pFile,"%s",tmp); // 4
2266 instantVector.push_back( atoi(tmp) );
2267 fscanf(pFile,"%s",tmp); // 5
2268 instantVector.push_back( atoi(tmp) );
2269 fscanf(pFile,"%s",tmp); // 6
2270 instantVector.push_back( atoi(tmp) );
2273 fscanf(pFile,"%s",tmp); // TypeContourModel
2274 fscanf(pFile,"%s",tmp); // ##
2275 typeContourModel = atoi(tmp);
2277 manModelContour = factoryManualContourModel(typeContourModel);
2278 manModelContour->Open(pFile);
2280 fscanf(pFile,"%s",tmp); // TypeView
2281 fscanf(pFile,"%s",tmp); // ##
2282 typeView = atoi(tmp);
2290 std::string theName;
2291 theName = _modelManager->createOutline( manModelContour, instantVector );
2292 bool addedModel = theName.compare("") != 0;
2295 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2296 this->_theViewPanel->getSpacing(spc);
2297 //Adding the manualContourControler to interface objects structure
2298 //Adding the manualViewContour to interface objects structure
2299 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
2300 _sceneManager->configureViewControlTo( theName, manModelContour,spc , typeView) ;
2303 if (staticContour==true)
2305 Instant instant(&instantVector);
2306 changeContourOfManager( theName , &instant );
2309 }// for numberOfContours
2315 //------------------------------------------------------------------------------------------------------------
2316 void wxContourEventHandler::openFileWithContours()
2319 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
2320 if (dialog.ShowModal() == wxID_OK)
2322 fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
2323 FILE *pFile=fopen(fileNameContourROI.c_str(),"r+");
2325 fscanf(pFile,"%s",tmp); // --CreaContour--
2327 fscanf(pFile,"%s",tmp); // Version
2328 fscanf(pFile,"%s",tmp); // 1.0.1
2329 std::string version(tmp);
2331 openContours(pFile,false);
2332 if (version!="1.0.0"){
2333 openContours(pFile,true);
2335 // _sceneManager->openFileWithContours(ff);
2339 _sceneManager->removeSceneContours();
2341 //updateInstantOutlines();
2345 //------------------------------------------------------------------------------------------------------------
2346 void wxContourEventHandler::saveFileWithContours( std::string filename )
2348 FILE *pFile=fopen(filename.c_str(),"w+");
2349 std::vector< std::string > lstNameThings;
2350 int i,sizeLstNameThings;
2352 fprintf(pFile,"--CreaContour--\n");
2353 fprintf(pFile,"Version %s\n", "1.0.1" );
2356 lstNameThings = _modelManager->GetLstNameThings();
2357 sizeLstNameThings = lstNameThings.size();
2358 fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
2359 for (i=0 ; i<sizeLstNameThings ; i++)
2361 _modelManager->SaveThingName( pFile, lstNameThings[i] );
2362 _sceneManager->SaveThingName( pFile, lstNameThings[i] );
2365 //-- Contours Statics
2366 lstNameThings = _modelManager->GetLstNameThingsStatic();
2367 sizeLstNameThings = lstNameThings.size();
2368 fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
2369 for (i=0 ; i<sizeLstNameThings ; i++)
2371 _modelManager->SaveThingName( pFile, lstNameThings[i] );
2372 _sceneManager->SaveThingName( pFile, lstNameThings[i] );
2378 //----------------------------------------------------------
2380 void wxContourEventHandler::saveFileWithContours()
2382 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
2383 if (dialog.ShowModal() == wxID_OK)
2385 fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
2386 saveFileWithContours( fileNameContourROI );
2390 //------------------------------------------------------------------------------------------------------------
2391 void wxContourEventHandler :: saveFileWithContoursAutomatique()
2393 if (fileNameContourROI=="")
2395 saveFileWithContours();
2397 saveFileWithContours(fileNameContourROI);
2402 //------------------------------------------------------------------------------------------------------------
2403 void wxContourEventHandler :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append )
2405 std::string cloneName = _modelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
2406 manualContourModel * manualModel = _modelManager->getOutlineByKeyName( cloneName )->getModel();
2407 _sceneManager->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
2411 //------------------------------------------------------------------------------------------------------------
2412 manualContourModel * wxContourEventHandler::factoryManualContourModel(int typeContour)
2414 manualContourModel *manModelContour=NULL;
2419 manModelContour = new manualContourModel();
2425 manModelContour = new manualContourModel();
2431 manModelContour = new manualContourModelRoi();
2437 manModelContour = new manualContourModelCircle();
2443 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
2444 manModelContour = manModelContourBullEye;
2445 if (_panelBullEyeOptions!=NULL){
2446 int iCrown,sizeCrowns,iSector,sizeSectors;
2447 double radioA,radioB,ang,angDelta ;
2448 sizeCrowns = _panelBullEyeOptions->GetNumberOfCrowns();
2449 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
2451 sizeSectors = _panelBullEyeOptions->GetNumberOfSections(iCrown);
2452 radioB = _panelBullEyeOptions->GetRadioOfCrown(iCrown);
2453 if (iCrown==sizeCrowns-1)
2457 radioA = _panelBullEyeOptions->GetRadioOfCrown(iCrown+1);
2459 radioA=radioA/100.0;
2460 radioB=radioB/100.0;
2461 for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
2463 ang = _panelBullEyeOptions->GetAngOfCrownSection(iCrown,iSector);
2464 angDelta= _panelBullEyeOptions->GetAngDeltaOfCrownSection(iCrown);
2465 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
2468 } // if _panelBullEyeOptions
2469 }// if typeContour==4
2471 return manModelContour;
2474 //------------------------------------------------------------------------------------------------------------
2475 void wxContourEventHandler :: createContour( int typeContour )
2477 //Creating the manualContourModel and including in the model
2478 manualContourModel * manModelContour = factoryManualContourModel(typeContour);
2479 std::vector<int> instantVector;
2480 _instantPanel->getInstant( instantVector );
2481 std::string theName;
2482 theName= _modelManager->createOutline( manModelContour, instantVector );
2483 bool addedModel = theName.compare("") != 0;
2486 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2487 this->_theViewPanel->getSpacing(spc);
2488 //Adding the manualContourControler to interface objects structure
2489 //Adding the manualViewContour to interface objects structure
2490 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
2491 _sceneManager->configureViewControlTo( theName, manModelContour,spc , typeContour) ;
2495 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
2496 //fprintf(ff,"EED wxContourEventHandler::createContour() \n" );
2497 //fprintf(ff," %s\n %p ",theName.c_str() , );
2502 manualContourModel * wxContourEventHandler::factoryManualContourModel(PanelBullEyeOptions* panel){
2504 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
2505 manualContourModel *manModelContour=NULL;
2506 manModelContour = manModelContourBullEye;
2508 int iCrown,sizeCrowns,iSector,sizeSectors;
2509 double radioA,radioB,ang,angDelta ;
2510 sizeCrowns = panel->GetNumberOfCrowns();
2511 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
2513 sizeSectors = panel->GetNumberOfSections(iCrown);
2514 radioB = panel->GetRadioOfCrown(iCrown);
2515 if (iCrown==sizeCrowns-1)
2519 radioA = panel->GetRadioOfCrown(iCrown+1);
2521 radioA=radioA/100.0;
2522 radioB=radioB/100.0;
2523 for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
2525 ang = panel->GetAngOfCrownSection(iCrown,iSector);
2526 angDelta= panel->GetAngDeltaOfCrownSection(iCrown);
2527 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
2530 } // if _panelBullEyeOptions
2532 return manModelContour;
2535 void wxContourEventHandler :: createContourBullsEye(PanelBullEyeOptions* panel )
2537 //Creating the manualContourModel and including in the model
2538 manualContourModel * manModelContour = factoryManualContourModel(panel );
2539 std::vector<int> instantVector;
2540 _instantPanel->getInstant( instantVector );
2541 std::string theName;
2542 theName= _modelManager->createOutline( manModelContour, instantVector );
2543 bool addedModel = theName.compare("") != 0;
2546 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2547 this->_theViewPanel->getSpacing(spc);
2548 //Adding the manualContourControler to interface objects structure
2549 //Adding the manualViewContour to interface objects structure
2550 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
2551 _sceneManager->configureViewControlTo( theName, manModelContour,spc , 4) ;
2555 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
2556 //fprintf(ff,"EED wxContourEventHandler::createContour() \n" );
2557 //fprintf(ff," %s\n %p ",theName.c_str() , );
2563 //------------------------------------------------------------------------------------------------------------
2564 // Attributes getters and setters
2565 //------------------------------------------------------------------------------------------------------------
2567 void wxContourEventHandler :: setModelManager( OutlineModelManager * theModelManager )
2569 _modelManager = theModelManager;
2570 _workSpace = _modelManager->getContourWorkspace();
2572 //------------------------------------------------------------------------------------------------------------
2573 void wxContourEventHandler :: setViewPanel( wxContourViewPanel * theViewPanel )
2575 _theViewPanel = theViewPanel;
2576 _theViewPanel->setWxEventHandler( this );
2579 this->_theViewPanel->getSpacing(spc);
2580 _sceneManager = new wxVtkBaseView_SceneManager ( this->_theViewPanel->getWxVtkBaseView(), this, spc );
2582 Connect( _theViewPanel->GetId(), wxINSTANT_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant );
2583 Connect( wxID_ANY, wxEVT_START_CREATE_MULT_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onCreateMultipleROI );
2584 Connect( wxID_ANY, wxEVT_START_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onCreateROI );
2585 Connect( wxID_ANY, wxEVT_STOP_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onStopCreateROI );
2586 Connect( wxID_ANY, wxEVT_CHANGED_DEEP, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangedDeep );
2587 Connect( wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler :: onActionButtonPressed );
2592 //------------------------------------------------------------------------------------------------------------
2593 void wxContourEventHandler :: setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel )
2595 _instantPanel = theInstantChooserPanel;
2596 _instantPanel->setWxEventHandler( this );
2598 Connect( _instantPanel->GetId(), wxINSTANT_CHOOSER_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction) &wxContourEventHandler::onChangeInstant );
2600 std::vector<int> vect;
2601 _instantPanel->getInstant( vect );
2602 _actualInstant = new Instant( &vect );
2604 if( _modelManager!=NULL )
2606 std::vector<std::string> conceptNameVect;
2607 std::vector<int> conceptSizeVect;
2608 _modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect);
2610 int max = conceptNameVect.size();
2613 if( conceptNameVect[i].compare("Axe Depth") == 0 )
2615 _instantPanel->addConcept( conceptNameVect[i], 0, conceptSizeVect[i], 1);
2617 _instantPanel->addConcept( conceptNameVect[i], 1, conceptSizeVect[i], 1);
2621 //Should be configured later, or abort program, because Model -NEEDS- to be added before chooserPanel
2623 if( _theViewPanel!=NULL )
2625 double val = _theViewPanel->getCurrentDeep();
2626 _instantPanel->setConceptValue( "Axe Depth", (int)val );
2627 ConceptDataWrap * data = _instantPanel->getConceptDataOf( "Axe Depth" );
2629 _theViewPanel->setVerticalConcept( "Axe Depth", data->getMinValue(), data->getMaxValue(), data->getMinShowedValue(), data->getMaxShowedValue(), data->getActualValue() );
2631 //Should be configured later, or abort program, because ViewPanel -NEEDS- to be added before chooserPanel
2636 //------------------------------------------------------------------------------------------------------------
2637 void wxContourEventHandler :: setButtonsBar( wxContour_ButtonsBar * theButtonsBar )
2639 _buttonsBar = theButtonsBar;
2640 _buttonsBar->setWxEventHandler( this );
2641 Connect( _buttonsBar->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler:: onActionButtonPressed );
2643 //------------------------------------------------------------------------------------------------------------
2644 void wxContourEventHandler :: setGrid( wxContour_Grid * theGridPanel )
2646 _gridPanel = theGridPanel;
2648 //------------------------------------------------------------------------------------------------------------
2649 void wxContourEventHandler :: setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel )
2651 _drawToolsPanel = theDrawToolsPanel;
2653 //------------------------------------------------------------------------------------------------------------
2654 void wxContourEventHandler :: setOperationsToolsPanel( wxContour_OperationsToolsPanel * theOperationsToolsPanel )
2656 _operationsToolsPanel = theOperationsToolsPanel;
2658 //------------------------------------------------------------------------------------------------------------
2659 void wxContourEventHandler :: setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel )
2661 _autoFormsPanel = theAutoFormsPanel;
2664 void wxContourEventHandler :: setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel )
2666 _standardToolsPanel= theStandardToolsPanel;
2668 //------------------------------------------------------------------------------------------------------------
2669 void wxContourEventHandler :: setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel )
2671 _editionToolsPanel = theEditionToolsPanel;
2674 //------------------------------------------------------------------------------------------------------------
2675 void wxContourEventHandler :: setListViewPanel( wxContour_ListViewPanel * theListViewPanel )
2677 _listViewPanel = theListViewPanel;
2679 //------------------------------------------------------------------------------------------------------------
2680 // Other functional methods
2681 //------------------------------------------------------------------------------------------------------------
2684 //------------------------------------------------------------------------------------------------------------
2685 void wxContourEventHandler::onDeleteContour( wxCommandEvent& event )
2688 //JCP 20-10-08 Undo redo implementation
2690 //JCP 20-10-08 Undo redo implementation
2693 int i,size=_sceneManager->getSelectedObjects().size();
2696 std::string keyName = _sceneManager->getSelectedObjects()[i];
2697 int ispartofstaticlist = this->_modelManager->IsPartOfStaticList( keyName );
2698 if ( ispartofstaticlist>=0 )
2700 std::vector<int> tempVector;
2701 _instantPanel->getInstant( tempVector );
2702 Instant instant(&tempVector);
2703 this->_modelManager->ChangeContourOfList(keyName, &instant);
2707 std::vector<std::string> lstKeyName;
2708 std::vector<std::string> lstKeyNameActualSlice;
2709 std::vector<std::string> lstKeyNameToBeErase;
2711 lstKeyNameToBeErase = _sceneManager->getSelectedObjects();
2712 lstKeyNameActualSlice = _sceneManager->GetlstContoursNameActualSlice();
2713 int k,kSize=lstKeyNameToBeErase.size();
2714 int j,jSize=lstKeyNameActualSlice.size();
2716 for (k=0;k<kSize; k++)
2719 for (j=0;j<jSize; j++)
2721 if (lstKeyNameToBeErase[k]==lstKeyNameActualSlice[j])
2728 lstKeyName.push_back( lstKeyNameToBeErase[k] );
2732 deleteContours( lstKeyName );
2737 //------------------------------------------------------------------------------------------------------------
2738 void wxContourEventHandler::onDeleteContoursActSlice( wxCommandEvent& event )
2740 //JCP 20-10-08 Undo redo implementation
2742 //JCP 20-10-08 Undo redo implementation
2743 deleteContours( _sceneManager->GetlstContoursNameActualSlice() );
2748 //------------------------------------------------------------------------------------------------------------
2749 void wxContourEventHandler::onDeleteAllContours( wxCommandEvent& event )
2751 //JCP 20-10-08 Undo redo implementation
2753 //JCP 20-10-08 Undo redo implementation
2754 deleteAllContours( );
2759 //------------------------------------------------------------------------------------------------------------
2760 void wxContourEventHandler :: onDeleteFrame( )
2762 if (_deleteFrame==NULL)
2764 _deleteFrame = new wxFrame (_theViewPanel, -1,_T(" Delete Contour "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
2766 wxSize sizepanel(width,230);
2767 _deleteFrame->SetSize( sizepanel );
2768 wxPanel *panel = new wxPanel(_deleteFrame,-1);
2769 wxButton *deleteContourBtn = new wxButton(panel,-1,_T("Delete contour selected"),wxDefaultPosition, wxSize(width-10,35) );
2770 wxButton *deleteContoursActSliceBtn = new wxButton(panel,-1,_T("Delete contours of actual slice"),wxDefaultPosition, wxSize(width-10,35));
2771 wxButton *deleteAllContoursBtn = new wxButton(panel,-1,_T("Delete all contours"),wxDefaultPosition, wxSize(width-10,35));
2773 int sizeZ = _sceneManager->GetImageDataSizeZ();
2774 _mbarrangeDeleteAll = new mBarRange(panel,70, 65);
2775 _mbarrangeDeleteAll->SetMin(0);
2776 _mbarrangeDeleteAll->SetStart(0);
2778 _mbarrangeDeleteAll-> SetOrientation( true );
2779 _mbarrangeDeleteAll-> setActiveStateTo(true);
2780 _mbarrangeDeleteAll-> setVisibleLabels( true );
2781 _mbarrangeDeleteAll-> setDeviceEndMargin(10);
2782 _mbarrangeDeleteAll-> setRepresentedValues( 0 , sizeZ );
2783 _mbarrangeDeleteAll-> setDeviceBlitStart(10,10);
2784 _mbarrangeDeleteAll-> setIfWithActualDrawed( false );
2785 _mbarrangeDeleteAll-> SetStart( 0 );
2786 _mbarrangeDeleteAll-> SetEnd( sizeZ );
2789 _deleteFrame->SetEventHandler( this );
2790 Connect( deleteContourBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteContour );
2791 Connect( deleteContoursActSliceBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteContoursActSlice );
2792 Connect( deleteAllContoursBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onDeleteAllContours );
2794 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
2795 sizer -> Add( deleteContourBtn , 1, wxGROW );
2796 sizer -> Add( deleteContoursActSliceBtn , 1, wxGROW );
2797 sizer -> Add( deleteAllContoursBtn , 1, wxGROW );
2798 sizer -> Add( _mbarrangeDeleteAll , 1, wxGROW );
2800 panel->SetSizer( sizer );
2801 panel->SetSize( sizepanel );
2802 panel->SetAutoLayout( true );
2804 _deleteFrame->Show(true);
2806 if (_deleteFrame->IsShown()==true)
2808 _deleteFrame->Show(false);
2810 _deleteFrame->Show(true);
2816 //------------------------------------------------------------------------------------------------------------
2817 void wxContourEventHandler::onCreateContourSpline( wxCommandEvent& event )
2820 //JCP 20-10-08 Undo redo implementation
2822 //JCP 20-10-08 Undo redo implementation
2829 //------------------------------------------------------------------------------------------------------------
2830 void wxContourEventHandler::onCreateContourRectangle( wxCommandEvent& event )
2833 //JCP 20-10-08 Undo redo implementation
2835 //JCP 20-10-08 Undo redo implementation
2841 //------------------------------------------------------------------------------------------------------------
2842 void wxContourEventHandler::onCreateContourCircle( wxCommandEvent& event )
2844 //JCP 20-10-08 Undo redo implementation
2846 //JCP 20-10-08 Undo redo implementation
2851 //------------------------------------------------------------------------------------------------------------
2852 void wxContourEventHandler::onCreateContourBullEye( wxCommandEvent& event )
2854 //JCP 20-10-08 Undo redo implementation
2856 //JCP 20-10-08 Undo redo implementation
2865 //------------------------------------------------------------------------------------------------------------
2866 void wxContourEventHandler :: onCreateContourFrame( )
2868 if (_createContourFrame==NULL)
2870 _createContourFrame = new wxFrame (_theViewPanel, -1,_T(" New Contour "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
2871 wxSize sizepanel(490,600);
2872 _createContourFrame->SetSize( sizepanel );
2873 wxPanel *panel = new wxPanel(_createContourFrame,-1);
2874 wxButton *newContourSplineBtn = new wxButton(panel,-1,_T("Interpolation B-spline (close)"),wxDefaultPosition, wxSize(180,35) );
2875 newContourSplineBtn->SetToolTip(_T("CTRL-N"));
2876 wxButton *newContourRectangleBtn = new wxButton(panel,-1,_T("Rectangle"),wxDefaultPosition, wxSize(180,35));
2877 wxButton *newContourCircleBtn = new wxButton(panel,-1,_T("Circle"),wxDefaultPosition, wxSize(180,35));
2878 wxButton *newContourStarBtn = new wxButton(panel,-1,_T("Bull eye"),wxDefaultPosition, wxSize(180,35));
2880 _panelBullEyeOptions = new PanelBullEyeOptions(panel, wxSize(100,200));
2882 _createContourFrame->SetEventHandler( this );
2883 Connect( newContourSplineBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourSpline );
2884 Connect( newContourRectangleBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourRectangle );
2885 Connect( newContourCircleBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourCircle );
2886 Connect( newContourStarBtn->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onCreateContourBullEye );
2888 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
2889 sizer -> Add( newContourSplineBtn , 1, wxGROW );
2890 sizer -> Add( newContourRectangleBtn , 1, wxGROW );
2891 sizer -> Add( newContourCircleBtn , 1, wxGROW );
2892 sizer -> Add( newContourStarBtn , 1, wxGROW );
2893 sizer -> Add( _panelBullEyeOptions , 1, wxGROW );
2895 panel->SetSizer( sizer );
2896 panel->SetSize( sizepanel );
2897 panel->SetAutoLayout( true );
2899 _createContourFrame->Show(true);
2901 if (_createContourFrame->IsShown()==true)
2903 _createContourFrame->Show(false);
2905 _createContourFrame->Show(true);
2911 //------------------------------------------------------------------------
2912 void wxContourEventHandler::RefreshInterface()
2915 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2916 wxvtk2dbaseview->Refresh();
2919 //------------------------------------------------------------------------
2920 void wxContourEventHandler::onWidthOfContour(wxScrollEvent& event){
2921 _sceneManager->removeSceneContours();
2922 double width = (double)_withOfContourLine->GetValue() / 2.0;
2923 _sceneManager->SetWidthContour( width );
2928 //------------------------------------------------------------------------
2930 void wxContourEventHandler::onBrigthnessColorWindowLevel(wxScrollEvent& event){
2931 int colorwindow = _brithtnessColorLevel->GetValue();
2932 int windowlevel = _brithtnessWindowLevel->GetValue();
2933 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2934 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
2935 imageviewer->SetColorWindow(colorwindow);
2936 imageviewer->SetColorLevel(windowlevel);
2937 // wxvtk2dbaseview->Refresh();
2941 void wxContourEventHandler::OnInterpolation(wxCommandEvent& event)
2943 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2944 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
2945 if (_interpolationCheckBox->GetValue()==true)
2947 imageviewer->GetImageActor()->InterpolateOn();
2949 imageviewer->GetImageActor()->InterpolateOff();
2955 //------------------------------------------------------------------------------------------------------------
2956 void wxContourEventHandler :: onInterfaceConfigurationFrame( )
2958 if (_interfaceConfigurationFrame==NULL)
2960 _interfaceConfigurationFrame = new wxFrame (_theViewPanel, -1,_T(" Interface Configuration "), wxDefaultPosition, wxDefaultSize, wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT );
2961 wxSize sizepanel(190,400);
2962 _interfaceConfigurationFrame->SetSize( sizepanel );
2963 _interfaceConfigurationFrame->SetEventHandler( this );
2964 wxPanel* panel = getConfigurationPanel(_interfaceConfigurationFrame);
2965 panel->SetSize(sizepanel);
2966 _interfaceConfigurationFrame->Show(true);
2968 if (_interfaceConfigurationFrame->IsShown()==true)
2970 _interfaceConfigurationFrame->Show(false);
2972 _interfaceConfigurationFrame->Show(true);
2980 wxPanel* wxContourEventHandler :: getConfigurationPanel(wxWindow* parent){
2982 /*wxPanel *panel = new wxPanel(parent,-1);
2983 _withOfContourLine = new wxSlider(panel, -1, 1 , 1, 10, wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
2986 this->_sceneManager->GetImageDataRange(range);
2988 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
2989 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
2990 int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
2991 int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
2993 _brithtnessWindowLevel = new wxSlider(panel, -1, windowlevel , 1, range[1], wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
2994 _brithtnessColorLevel = new wxSlider(panel, -1, colorwindow , 1, range[1], wxDefaultPosition, wxSize(180,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
2996 _interpolationCheckBox = new wxCheckBox(panel, -1, _T("Image interpolation") );
2997 _interpolationCheckBox->SetValue(true);
2999 _interfaceConfigurationFrame->SetEventHandler( this );
3001 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
3002 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
3004 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3005 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3006 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3007 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3008 Connect( _interpolationCheckBox->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::OnInterpolation );
3010 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
3011 sizer -> Add( new wxStaticText(panel,-1,_T("Contour width")) , 1, wxGROW );
3012 sizer -> Add( _withOfContourLine , 1, wxGROW );
3013 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3014 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3015 sizer -> Add( new wxStaticText(panel,-1,_T("Brightness of the image")) , 1, wxGROW );
3016 sizer -> Add( new wxStaticText(panel,-1,_T("--Window level--")) , 1, wxGROW );
3017 sizer -> Add( _brithtnessWindowLevel , 1, wxGROW );
3018 sizer -> Add( new wxStaticText(panel,-1,_T("--Color level--")) , 1, wxGROW );
3019 sizer -> Add( _brithtnessColorLevel, 1, wxGROW );
3020 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3021 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3022 sizer -> Add( _interpolationCheckBox , 1, wxGROW );
3024 panel->SetSizer( sizer );
3026 //panel->SetSize( sizepanel );
3028 panel->SetAutoLayout( true );
3033 wxPanel *panel = new wxPanel(parent,-1,wxDefaultPosition, wxDefaultSize,wxNO_BORDER, wxString(""));
3034 _withOfContourLine = new wxSlider(panel, -1, 1 , 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3037 this->_sceneManager->GetImageDataRange(range);
3039 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
3040 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
3041 int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
3042 int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
3044 _brithtnessWindowLevel = new wxSlider(panel, -1, windowlevel , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3045 _brithtnessColorLevel = new wxSlider(panel, -1, colorwindow , 1, range[1], wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3047 _interpolationCheckBox = new wxCheckBox(panel, -1, _T("Image interpolation") );
3048 _interpolationCheckBox->SetValue(true);
3050 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
3051 Connect( _withOfContourLine->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onWidthOfContour );
3053 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3054 Connect( _brithtnessWindowLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3055 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_CHANGED , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3056 Connect( _brithtnessColorLevel->GetId() , wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &wxContourEventHandler::onBrigthnessColorWindowLevel );
3057 Connect( _interpolationCheckBox->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::OnInterpolation );
3059 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
3060 sizer -> Add( new wxStaticText(panel,-1,_T("Contour width")) , 1, wxGROW );
3061 sizer -> Add( _withOfContourLine , 1, wxGROW );
3062 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3063 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3064 sizer -> Add( new wxStaticText(panel,-1,_T("Brightness of the image")) , 1, wxGROW );
3065 sizer -> Add( new wxStaticText(panel,-1,_T("--Window level--")) , 1, wxGROW );
3066 sizer -> Add( _brithtnessWindowLevel , 1, wxGROW );
3067 sizer -> Add( new wxStaticText(panel,-1,_T("--Color level--")) , 1, wxGROW );
3068 sizer -> Add( _brithtnessColorLevel, 1, wxGROW );
3069 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3070 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3071 sizer -> Add( _interpolationCheckBox , 1, wxGROW );
3073 panel->SetSizer( sizer );
3075 //panel->SetSize( sizepanel );
3077 panel->SetAutoLayout( true );
3087 //------------------------------------------------------------------
3088 void wxContourEventHandler :: changeContourOfManager(std::string keyName, Instant *instant)
3090 this->_modelManager->ChangeContourOfList(keyName, instant);
3093 //------------------------------------------------------------------
3094 void wxContourEventHandler :: changeContoursOfManager( std::vector<std::string> & keyNamesVector )
3097 //JCP 20-10-08 Undo redo implementation
3099 //JCP 20-10-08 Undo redo implementation
3101 std::vector<int> tempVector;
3102 _instantPanel->getInstant( tempVector );
3103 Instant instant(&tempVector);
3105 int i , size=keyNamesVector.size();
3106 for ( i=0 ; i<size ; i++ )
3108 changeContourOfManager(keyNamesVector[i], &instant);
3115 //------------------------------------------------------------------
3116 void wxContourEventHandler :: executeActionCommand( const wxString & toolCommand )
3118 std::vector<std::string> currentSelection = _sceneManager->getSelectedObjects();
3119 int elementsSelected = currentSelection.size();
3120 if( toolCommand == (wxContour_ActionCommandsID::CREATE_TOOL) )
3122 onCreateContourFrame();
3124 if( toolCommand == (wxContour_ActionCommandsID::CREATE_CONTOUR_KEY) )
3128 else if( toolCommand == wxContour_ActionCommandsID::DELETE_TOOL )
3132 else if( toolCommand == wxContour_ActionCommandsID::DELETE_KEY )
3134 deleteContours( currentSelection );
3136 else if( toolCommand == wxContour_ActionCommandsID::SAVE_TOOL )
3138 saveFileWithContours( );
3140 else if( toolCommand == wxContour_ActionCommandsID::SAVE_KEY )
3142 saveFileWithContoursAutomatique( );
3144 else if( toolCommand == wxContour_ActionCommandsID::OPEN_TOOL )
3146 openFileWithContours( );
3148 else if( toolCommand == wxContour_ActionCommandsID::CHANGE_TOOL )
3150 if ( elementsSelected >= 1 )
3152 changeContoursOfManager( currentSelection );
3156 else if( toolCommand == wxContour_ActionCommandsID::HIDE_TOOL )
3158 if ( elementsSelected >= 1 )
3160 onHideOutlines( currentSelection );
3163 else if( toolCommand == wxContour_ActionCommandsID::SHOW_TOOL )
3165 if ( elementsSelected >= 1 )
3167 onShowOutlines( currentSelection );
3170 else if( toolCommand == wxContour_ActionCommandsID::COPY_TOOL )
3172 if ( elementsSelected >= 1 )
3174 onCopyOutlines( currentSelection );
3177 else if( toolCommand == wxContour_ActionCommandsID::PASTE_TOOL )
3181 else if( toolCommand == wxContour_ActionCommandsID::SPREAD_TOOL )
3185 else if( toolCommand == wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL )
3187 onAutomatiqueSegmentation( );
3190 else if( toolCommand == wxContour_ActionCommandsID::SELECT_TOOL )
3192 onSelectOutlines( currentSelection );
3195 else if( toolCommand == wxContour_ActionCommandsID::EDIT_TOOL )
3197 if ( elementsSelected >= 1 )
3199 onEditOutlines( currentSelection );
3202 else if( toolCommand == wxContour_ActionCommandsID::UNDO_TOOL )
3206 else if( toolCommand == wxContour_ActionCommandsID::REDO_TOOL )
3210 else if( toolCommand == wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL )
3212 onInformationContourFrame();
3214 else if( toolCommand == wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL )
3216 onInterfaceConfigurationFrame();
3218 else if( toolCommand == wxContour_ActionCommandsID::TEST_TOOL )
3220 onInterfaceTestFrame();
3227 //------------------------------------------------------------------------------------------------------------
3228 // Getting information methods
3229 //------------------------------------------------------------------------------------------------------------
3233 //------------------------------------------------------------------------------------------------------------
3235 //------------------------------------------------------------------------------------------------------------
3237 void wxContourEventHandler :: updateInstantOutlines()
3239 std::vector<NameWrapper *> namesWrapping = _modelManager->getActualInstantOutlines();
3240 int size = namesWrapping.size();
3241 _sceneManager->removeSceneContours();
3242 for( int i=0; i<size; i++)
3244 _sceneManager->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false );
3247 //------------------------------------------------------------------------------------------------------------
3248 void wxContourEventHandler :: updateInstantImageData()
3252 //------------------------------------------------------------------------------------------------------------
3254 void wxContourEventHandler :: updateInstantAxes()
3258 //------------------------------------------------------------------------------------------------------------
3259 void wxContourEventHandler :: changeInstant()
3261 std::vector<int> instantVect;
3262 _instantPanel->getInstant( instantVect );
3263 Instant * theInstant = new Instant ( &instantVect );
3264 //if( !theInstant->isEquals( _actualInstant ))
3266 //Setting the actual instant
3267 _actualInstant = theInstant;
3268 _modelManager->setInstant( _actualInstant );
3270 updateInstantOutlines();
3271 updateInstantImageData();
3272 updateInstantAxes();
3274 //Searching the elements at the specified instant
3277 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
3278 iter = contours_ViewControl->find("Outline 0");
3279 (iter->second)->getViewer()->RemoveCompleteContourActor();*/
3283 void wxContourEventHandler :: saveState(){
3289 //itoa(inundo, str, 10);
3290 sprintf(str, "%d", inundo);
3292 std::string temp = stundoredo + *str + ".roi";
3293 saveFileWithContours(temp);
3298 void wxContourEventHandler ::loadState(std::string filename){
3301 FILE *pFile=fopen(filename.c_str(),"r+");
3303 fscanf(pFile,"%s",tmp); // --CreaContour--
3305 fscanf(pFile,"%s",tmp); // Version
3306 fscanf(pFile,"%s",tmp); // 1.0.1
3307 std::string version(tmp);
3309 deleteAllContours();
3311 openContours(pFile,false);
3312 if (version!="1.0.0"){
3313 openContours(pFile,true);
3318 //_sceneManager->removeSceneContours();
3322 void wxContourEventHandler :: onREDO()
3329 //itoa(inundo, str, 10);
3330 sprintf(str, "%d", inundo);
3333 std::string temp = stundoredo + *str + ".roi";
3341 //------------------------------------------------------------------------------------------------------------
3342 void wxContourEventHandler :: onUNDO()
3349 //itoa(inundo, str, 10);
3350 sprintf(str, "%d",inundo);
3352 std::string temp = stundoredo + *str + ".roi";
3353 saveFileWithContours(temp);
3360 //itoa(inundo, str, 10);
3361 sprintf(str, "%d",inundo);
3363 std::string temp = stundoredo + *str + ".roi";
3369 void wxContourEventHandler :: getValuesXYZ(double **vectx, double **vecty, double **vectz, std::vector<int>* size){
3373 ContourExtractData *contourextractdata = new ContourExtractData();
3374 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
3375 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
3377 std::vector<manualContourModel*> lstManConMod;
3378 std::vector<manualContourModel*> lstManConModTmp;
3379 std::vector<manualContourModel*> lstManConModExp;
3380 std::vector<double> pLstValue;
3381 std::vector<double> pLstValuePosX;
3382 std::vector<double> pLstValuePosY;
3383 std::vector<double> pLstValuePosZ;
3385 std::vector<int> tempVector;
3386 _instantPanel->getInstant( tempVector );
3388 vtkImageData *imagedata = _sceneManager->GetImageData();
3389 int sizeZ = _sceneManager->GetImageDataSizeZ();
3391 int ii,sizeLstContourThings;
3398 minZ = 0;// _mbarrange->GetStart();
3399 maxZ = sizeZ;//_mbarrange->GetEnd();
3400 totalZ = maxZ-minZ+1;
3402 contourextractdata->SetImage( imagedata);
3405 vectx = new double *[sizeZ];
3406 vecty = new double *[sizeZ];
3407 vectz = new double *[sizeZ];
3408 for ( z=0 ; z<sizeZ ; z++)
3411 porcent = 100.0* (z-minZ)/totalZ;
3413 //Extraction data from contours of each slice
3414 contourextractdata->SetZtoBeAnalys( z);
3417 Instant instant(&tempVector);
3418 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
3419 sizeLstContourThings = lstContourThings.size();
3421 lstManConMod.clear();
3422 for (ii=0 ; ii<sizeLstContourThings ; ii++)
3424 ContourThing **contourthing = lstContourThings[ii];
3425 lstManConMod.push_back( (*contourthing)->getModel() );
3427 lstManConModExp = ExploseEachModel( lstManConMod );
3432 int iContourGroup,sizeContourGroup;
3433 if (typeContourGroup==3) // contour separete
3435 sizeContourGroup=lstManConModExp.size();
3436 } else { // contour AND OR XOR
3440 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
3441 lstManConModTmp.clear();
3442 if (typeContourGroup==3) // contour separete
3444 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
3445 } else { // contour AND OR XOR
3446 lstManConModTmp = lstManConModExp;
3449 contourextractdata->SetLstManualContourModel( lstManConModTmp );
3452 pLstValuePosX.clear();
3453 pLstValuePosY.clear();
3454 pLstValuePosZ.clear();
3455 contourextractdata->GetValuesInsideCrown( &pLstValue,
3461 int iLstValue,sizeLstValue=pLstValue.size();
3463 //We initialize the pointers
3464 size->push_back(sizeLstValue);
3465 vectx[sizeZ] = new double[sizeLstValue];
3466 vecty[sizeZ] = new double[sizeLstValue];
3467 vectz[sizeZ] = new double[sizeLstValue];
3469 for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
3472 vectx[sizeZ][iLstValue] = pLstValuePosX[iLstValue];
3473 vecty[sizeZ][iLstValue] = pLstValuePosY[iLstValue];
3474 vectz[sizeZ][iLstValue] = pLstValuePosZ[iLstValue];
3477 //The size of the contour is saved
3482 } // for iContourGroup
3484 //_staticTextInformation->SetLabel( _T("") );
3485 delete contourextractdata;
3490 void wxContourEventHandler :: getMaskValue(vtkImageData* mask, vtkImageData* value){
3494 ContourExtractData *contourextractdata = new ContourExtractData( true );
3495 int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
3496 if (typeContourGroup==3)
3500 contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
3502 std::vector<manualContourModel*> lstManConMod;
3503 std::vector<manualContourModel*> lstManConModTmp;
3504 std::vector<manualContourModel*> lstManConModExp;
3506 std::vector<int> tempVector;
3507 _instantPanel->getInstant( tempVector );
3509 vtkImageData *imagedata = _sceneManager->GetImageData();
3510 int sizeZ = _sceneManager->GetImageDataSizeZ();
3512 int ii,sizeLstContourThings;
3521 minZ = 0;// _mbarrange->GetStart();
3522 maxZ = sizeZ;//_mbarrange->GetEnd();
3523 totalZ = maxZ-minZ+1;
3525 contourextractdata->SetImage( imagedata);
3528 for ( z=0 ; z<sizeZ ; z++)
3531 porcent = 100.0* (z-minZ)/totalZ;
3532 tmpString.Printf("Saving Values %d %c %d/%d %d", (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
3533 _staticTextInformation->SetLabel(tmpString);
3535 //Extraction data from contours of each slice
3536 contourextractdata->SetZtoBeAnalys( z);
3539 Instant instant(&tempVector);
3540 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
3541 sizeLstContourThings = lstContourThings.size();
3543 lstManConMod.clear();
3544 for (ii=0 ; ii<sizeLstContourThings ; ii++)
3546 ContourThing **contourthing = lstContourThings[ii];
3547 lstManConMod.push_back( (*contourthing)->getModel() );
3549 lstManConModExp = ExploseEachModel( lstManConMod );
3552 int iContourGroup,sizeContourGroup;
3553 if (typeContourGroup==3) // contour separete
3555 sizeContourGroup=lstManConModExp.size();
3556 } else { // contour AND OR XOR
3560 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
3561 lstManConModTmp.clear();
3562 if (typeContourGroup==3) // contour separete
3564 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
3565 } else { // contour AND OR XOR
3566 lstManConModTmp = lstManConModExp;
3569 contourextractdata->SetLstManualContourModel( lstManConModTmp );
3572 contourextractdata->CalculateImageResult(); // with actual Z
3574 } // for iContourGroup
3580 value = contourextractdata->GetVtkImageValueResult();
3583 mask = contourextractdata->GetVtkImageMaskResult();
3585 delete contourextractdata;
3589 wxPanel* wxContourEventHandler::getSegmentationPanelITK(wxWindow* parent){
3591 int sizeZ = _sceneManager->GetImageDataSizeZ();
3593 _sceneManager->GetImageDataRange(range);
3595 wxPanel *panel = new wxPanel(parent,-1);
3596 wxButton *segmentationOneSliceBtn = new wxButton(panel,-1,_T("Actual slice"), wxDefaultPosition, wxSize(200,35) );
3597 wxButton *segmentationAllSliceBtn = new wxButton(panel,-1,_T("All slices") ,wxDefaultPosition, wxSize(200,35) );
3598 _isovalue = new wxSlider(panel, -1, 40 , (int)(range[0]), (int)(range[1]), wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3599 _sampling = new wxSlider(panel, -1, 20 , 4, 50, wxDefaultPosition, wxSize(200,35), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
3600 wxString lstOptions[3];
3604 methodRadiobox = new wxRadioBox(panel, -1, "Method (find ctrl. Points)", wxDefaultPosition, wxSize(200,45), 3 , lstOptions, 3, wxRA_SPECIFY_COLS);
3605 methodRadiobox->SetSelection(2);
3606 _staticTextSegmentation = new wxStaticText(panel,-1,_T(" "));
3609 _mbarrange = new mBarRange(panel,70, 65);
3610 _mbarrange->SetMin(0);
3611 _mbarrange->SetStart(0);
3613 _mbarrange-> SetOrientation( true );
3614 _mbarrange-> setActiveStateTo(true);
3615 _mbarrange-> setVisibleLabels( true );
3616 _mbarrange-> setDeviceEndMargin(10);
3617 _mbarrange-> setRepresentedValues( 0 , sizeZ );
3618 _mbarrange-> setDeviceBlitStart(10,10);
3619 _mbarrange-> setIfWithActualDrawed( false );
3620 _mbarrange-> SetStart( 0 );
3621 _mbarrange-> SetEnd( sizeZ );
3624 // _segmentationFrame->SetEventHandler( this );
3625 segmentationOneSliceBtn->SetEventHandler( this );
3626 segmentationAllSliceBtn->SetEventHandler( this );
3627 Connect( segmentationOneSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationOneSliceITK );
3628 Connect( segmentationAllSliceBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourEventHandler::onSegmentationAllSliceITK );
3630 wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
3631 sizer -> Add( new wxStaticText(panel,-1,_T("Isovalue (Gray level)")) , 1, wxGROW );
3632 sizer -> Add( _isovalue , 1, wxGROW );
3633 sizer -> Add( methodRadiobox , 1, wxGROW );
3634 sizer -> Add( new wxStaticText(panel,-1,_T("Sampling (%)")) , 1, wxGROW );
3635 sizer -> Add( _sampling , 1, wxGROW );
3636 sizer -> Add( segmentationOneSliceBtn , 1, wxGROW );
3637 sizer -> Add( new wxStaticText(panel,-1,_T(" ")) , 1, wxGROW );
3638 sizer -> Add( _staticTextSegmentation , 1, wxGROW );
3639 sizer -> Add( segmentationAllSliceBtn , 1, wxGROW );
3640 sizer -> Add( _mbarrange , 1, wxGROW );
3642 panel->SetSizer( sizer );
3643 // panel->SetSize( sizePanel );
3644 panel->SetSize( wxDefaultSize );
3645 panel->SetAutoLayout( true );
3652 void wxContourEventHandler::onSegmentationAllSliceITK( wxCommandEvent& event ){
3653 //TODO implementar el método para todos los slices ver ayuda en onSegmentationAllSlice
3655 void wxContourEventHandler::onSegmentationOneSliceITK( wxCommandEvent& event ){
3656 //TODO implementar el método de segmentación en ITK ver ayuda en onSegmentationOneSlice y el método
3657 // SegmentationOneSlice(x, y, z) que es la implementación del método en VTK
3659 //JCP 20-10-08 Undo redo implementation
3661 //JCP 20-10-08 Undo redo implementation
3664 int x = this->_theViewPanel->GetX();
3665 int y = this->_theViewPanel->GetY();
3666 int z = this->_theViewPanel->GetZ();
3667 //SegmentationOneSlice( x,y,z );
3670 void wxContourEventHandler::onSnakePressed(wxWindow* parent){
3672 std::vector<double> vecX;
3673 std::vector<double> vecY;
3674 std::vector<double> vecZ;
3675 _sceneManager->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
3677 if (vecX.size()!=0){
3678 std::vector<int> tempVector;
3679 _instantPanel->getInstant( tempVector );
3680 int i,size=vecZ.size();
3681 int actualSlice = tempVector[1];
3682 for ( i=0 ; i<size ; i++ )
3684 vecZ[i] = actualSlice;
3687 wxDialog* dialog = new wxDialog(parent, -1, _T("Snake"));
3688 wxPanel* panel = new wxPanel(dialog,-1);
3689 wxStaticText* sttext = new wxStaticText(panel, -1, _T("Panel para snake"));
3690 dialog->ShowModal();
3695 void wxContourEventHandler::checkInformationPanel(){
3696 if (_InformationContourFrame==NULL){
3697 onInformationContourFrame();
3698 _InformationContourFrame->Show(false);