1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 //----------------------------------------------------------------------------------------------------------------
27 // Class definition include
28 //----------------------------------------------------------------------------------------------------------------
29 #include "wxContourMainFrame.h"
33 //----------------------------------------------------------------------------------------------------------------
35 //----------------------------------------------------------------------------------------------------------------
38 #include "NameWrapper.h"
39 #include "wx/artprov.h"
40 #include "ConceptDataWrap.h"
46 //----------------------------------------------------------------------------------------------------------------
47 // Class implementation
48 //----------------------------------------------------------------------------------------------------------------
49 /** @file wxContourMainFrame.cxx */
51 //------------------------------------------------------------------------------------------------------------
52 // Constructors & Destructors
53 //------------------------------------------------------------------------------------------------------------
55 wxContourMainFrame* wxContourMainFrame::instance=NULL;
56 char wxContourMainFrame::COPY = 'C';
58 wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style)
59 //: wxPanel(parent, id, title, pos, size, style)
60 //: wxWindow(parent, id, pos, size, style)
61 : wxPanel(parent, id, pos, size, style)
63 m_mgr.SetManagedWindow(this);
65 _creatingContoursActive = false;
67 // _modelManager = NULL;
69 // _buttonsBar = NULL;
71 // _drawToolsPanel = NULL;
72 // _operationsToolsPanel = NULL;
73 //_autoFormsPanel = NULL;
74 // _standardToolsPanel = NULL;
75 // _editionToolsPanel = NULL;
76 // _listViewPanel = NULL;
77 // _sceneManager = NULL;
78 //_actualInstant = NULL;
79 _numberOfVariablesStatistics= 6+1;
81 _refLineControl = NULL;
84 // _actorPresent = false;
86 // set up default notebook style
87 // m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
88 // m_notebook_theme = 0;
89 //wxContour_ActionCommandsID a;
91 _contourextractdata = NULL;
92 _viewMaskImage = NULL;
93 _viewMaskImagePanel = NULL;
94 _viewThresholdImage = NULL;
95 _viewThresholdImagePanel = NULL;
96 _viewColorLayerImagePanel = NULL;
97 _frameShowResultImages = NULL;
100 wxContourMainFrame::wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir)
101 : wxPanel(parent, id, pos, size, style)
103 m_mgr.SetManagedWindow(this);
105 _creatingContoursActive = false;
106 _theViewPanel = NULL;
107 _instantPanel = NULL;
108 _refLineControl = NULL;
109 _refLineModel = NULL;
111 // _actorPresent = false;
112 _viewMaskImage = NULL;
113 _viewMaskImagePanel = NULL;
114 _viewThresholdImage = NULL;
115 _viewThresholdImagePanel = NULL;
116 _viewColorLayerImagePanel = NULL;
117 // set up default notebook style
118 m_notebook_style = wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
119 m_notebook_theme = 0;
120 //wxContour_ActionCommandsID a;
121 _numberOfVariablesStatistics= 7;
125 _pannew = interfMainPanel::getInstance(this,datadir+"/data/Icons");//, eventHandler);
126 _performingOperation = new PerformingOperation();
127 if(images.size() > 0)
129 this->configure(images);
131 _contourextractdata = NULL;
135 void wxContourMainFrame::changeImage(int id, vtkImageData *img)
137 if ( id<_images.size() ) _images[id]=img;
138 kernelManager->changeImage(id,img);
139 _theViewPanel->changeImage(img);
140 // updateInstantImageData();
144 void wxContourMainFrame::configure(std::vector<vtkImageData*> imgs)
148 std::string str_home(getenv("USERPROFILE"));
149 #elif defined(__GNUC__)
150 std::string str_home(getenv("HOME"));
152 std::string strCreaContourDataTmp = str_home + "/.creaContourDataTemp/";
153 std::vector<std::string> conceptNameVect;
154 std::vector<int> conceptSizeVect;
155 notebook = this->createNotebook();
156 kernelManager = new KernelManagerContour( imgs , _datadir+"/data/" , strCreaContourDataTmp );
157 _instantPanel = new wxInstantChooserPanel( notebook, "Instant Chooser", true, false, "c" );
158 _theViewPanel = new wxContourViewPanel( kernelManager->getSourceImage(), notebook );
159 //-------------------------------------------------------------
160 kernelManager->getConceptsInformation(conceptNameVect, conceptSizeVect);
161 _instantPanel->addConcepts(conceptNameVect, conceptSizeVect);
162 double val = _theViewPanel->getCurrentDeep();
163 _instantPanel->setConceptValue( "Axe Depth", (int)val );
164 //JCP _instantPanel->setConceptValue("time", num de imagenes);
165 ConceptDataWrap * data = _instantPanel->getConceptDataOf( "Axe Depth" );
166 //*******************changeInstant();
167 _theViewPanel->setVerticalConcept( "Axe Depth", data->getMinValue(), data->getMaxValue(), data->getMinShowedValue(), data->getMaxShowedValue(), data->getActualValue() );
168 this->configurePanels( );
172 wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir )
176 instance=new wxContourMainFrame(parent, id, title, pos, size, images, style,datadir);
181 std::vector<vtkImageData*> wxContourMainFrame::getVectImages()
183 return kernelManager->getVectImages();
186 wxContourMainFrame* wxContourMainFrame::getInstance()
191 void wxContourMainFrame::resetInstance()
196 wxContourMainFrame::~wxContourMainFrame()
198 delete _contourextractdata;
201 interfMainPanel::resetInstance();
202 delete kernelManager;
204 //_pannew->Destroy();
210 //El problema al cerrar la aplicacion puede estar asociado
211 //a que wxAUINotebook esta en la aplicacion
212 //principal (wxContourGUIExample)tambien
213 //EED???? delete _theViewPanel;
214 //EED???? delete _instantPanel;
215 //EED???? delete _buttonsBar;
216 //EED???? delete _actualInstant;
217 //EED???? delete _sceneManager;
221 //------------------------------------------------------------------------------------------------------------
222 // Creational and initialization methods using WxAui
223 //------------------------------------------------------------------------------------------------------------
225 wxAuiNotebook * wxContourMainFrame::createNotebook()
227 wxSize client_size = GetClientSize();
228 wxAuiNotebook* noteBook = new wxAuiNotebook(this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200), m_notebook_style);
229 wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
234 //------------------------------------------------------------------------------------------------------------
235 // Creational and initialization methods
236 //------------------------------------------------------------------------------------------------------------
237 bool wxContourMainFrame::configurePanels( )
239 bool configured = _theViewPanel!=NULL;
241 configured &= _theViewPanel!=NULL;
242 if( _theViewPanel!=NULL )
244 notebook->AddPage( _theViewPanel, wxT(" View ") );
249 notebook->AddPage( _instantPanel, wxT("Instant Page") );
252 m_mgr.AddPane(notebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false));
254 SetMinSize(wxSize(300,300));
260 bool wxContourMainFrame::addNewPanel(wxPanel* panel)
262 bool configured = panel!=NULL;
263 configured &= panel!=NULL;
267 notebook->AddPage( panel, wxT(" Viewer "), true );
273 //------------------------------------------------------------------------------------------------------------
274 // Attributes getters and setters
275 //------------------------------------------------------------------------------------------------------------
279 void wxContourMainFrame :: setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel )
281 _instantPanel = theInstantChooserPanel;
284 // void wxContourMainFrame :: setButtonsBar( wxContour_ButtonsBar * theButtonsBar )
286 // _buttonsBar = theButtonsBar;
289 // void wxContourMainFrame :: setGrid( wxContour_Grid * theGridPanel )
291 // _gridPanel = theGridPanel;
294 // void wxContourMainFrame :: setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel )
296 // _drawToolsPanel = theDrawToolsPanel;
299 // void wxContourMainFrame :: setOperationsToolsPanel( wxContour_OperationsToolsPanel * theOperationsToolsPanel )
301 // _operationsToolsPanel = theOperationsToolsPanel;
304 // void wxContourMainFrame :: setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel )
306 // _autoFormsPanel = theAutoFormsPanel;
309 // void wxContourMainFrame :: setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel )
311 // _standardToolsPanel= theStandardToolsPanel;
314 // void wxContourMainFrame :: setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel )
316 // _editionToolsPanel = theEditionToolsPanel;
319 // void wxContourMainFrame :: setListViewPanel( wxContour_ListViewPanel * theListViewPanel )
321 // _listViewPanel = theListViewPanel;
326 void wxContourMainFrame::onCreateContourSpline( ){
328 //JCP 20-10-08 Undo redo implementation
330 //JCP 20-10-08 Undo redo implementation
335 void wxContourMainFrame::onCreateContourRectangle( )
337 //JCP 20-10-08 Undo redo implementation
339 //JCP 20-10-08 Undo redo implementation
343 void wxContourMainFrame::onCreateContourCircle( )
345 //JCP 20-10-08 Undo redo implementation
347 //JCP 20-10-08 Undo redo implementation
351 void wxContourMainFrame::onCreateContourLine( )
353 //JCP 20-10-08 Undo redo implementation
355 //JCP 20-10-08 Undo redo implementation
359 // RaC 09-09 --------------------------------------
360 void wxContourMainFrame::onCreateContourPoints( )
362 //JCP 20-10-08 Undo redo implementation
364 //JCP 20-10-08 Undo redo implementation
367 // RaC 09-09 --------------------------------------
369 // RaC 10-09 --------------------------------------
370 void wxContourMainFrame::onCreateContourPolygon( )
372 //JCP 20-10-08 Undo redo implementation
374 //JCP 20-10-08 Undo redo implementation
377 // RaC 10-09 --------------------------------------
379 //------------------------------------------------------------------------------------------------------------
381 void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel )
383 //Creating the manualBaseModel and including in the model
384 manualBaseModel * manModelContour = factoryManualContourModel(panel );
386 std::vector<int> instantVector;
387 _instantPanel->getInstant( instantVector );
388 std::string theName = kernelManager->createOutline(manModelContour, instantVector);
390 /*std::vector<int> instantVector;
391 _instantPanel->getInstant( instantVector );
393 theName= _modelManager->createOutline( manModelContour, instantVector );*/
394 bool addedModel = theName.compare("") != 0;//??
398 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
399 _theViewPanel->getSpacing(spc);
400 //Adding the manualContourControler to interface objects structure
401 //Adding the manualViewContour to interface objects structure
402 //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
403 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , 4) ;
407 void wxContourMainFrame::createContour( int typeContour )
409 //Creating the manualContourModel and including in the model
410 manualBaseModel * manModelContour = kernelManager->factoryManualContourModel(typeContour);
411 std::vector<int> instantVector;
412 _instantPanel->getInstant( instantVector );
414 std::vector<int> tempVector;
415 getInstantVector( tempVector );
416 manModelContour->SetLabel2( std::to_string(tempVector[1]) );
418 std::string theName = kernelManager->createOutline(manModelContour, instantVector);
419 /*std::vector<int> instantVector;
420 _instantPanel->getInstant( instantVector );
422 theName= _modelManager->createOutline( manModelContour, instantVector );*/
423 bool addedModel = theName.compare("") != 0;//??
426 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
427 _theViewPanel->getSpacing(spc);
428 //Adding the manualContourControler to interface objects structure
429 //Adding the manualViewContour to interface objects structure
430 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
431 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ;
435 manualBaseModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){
437 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
438 manualBaseModel *manModelContour=NULL;
439 manModelContour = manModelContourBullEye;
441 int iCrown,sizeCrowns,iSector,sizeSectors;
442 double radioA,radioB,ang,angDelta ;
443 sizeCrowns = ((PanelBullEyeOptions*)panel)->GetNumberOfCrowns();
444 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
446 sizeSectors = ((PanelBullEyeOptions*)panel)->GetNumberOfSections(iCrown);
447 radioB = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown);
448 if (iCrown==sizeCrowns-1)
452 radioA = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown+1);
456 for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
458 ang = ((PanelBullEyeOptions*)panel)->GetAngOfCrownSection(iCrown,iSector);
459 angDelta= ((PanelBullEyeOptions*)panel)->GetAngDeltaOfCrownSection(iCrown);
460 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
463 } // if _panelBullEyeOptions
465 return manModelContour;
468 void wxContourMainFrame :: saveState()
470 std::string temp = kernelManager->saveState();
471 saveFileWithContours(temp);
474 void wxContourMainFrame::onDeleteContour()
476 //JCP 20-10-08 Undo redo implementation
478 //JCP 20-10-08 Undo redo implementation
480 std::vector<std::string> lstKeyNameToBeErase;
481 lstKeyNameToBeErase = _theViewPanel->getSceneManager()->getSelectedObjects();
482 deleteContours( lstKeyNameToBeErase );
484 int i,size=_sceneManager->getSelectedObjects().size();
487 std::string keyName = _sceneManager->getSelectedObjects()[i];
488 int ispartofstaticlist = this->_modelManager->IsPartOfStaticList( keyName );
489 if ( ispartofstaticlist>=0 )
491 std::vector<int> tempVector;
492 _instantPanel->getInstant( tempVector );
493 Instant instant(&tempVector);
494 this->_modelManager->ChangeContourOfList(keyName, &instant);
498 std::vector<std::string> lstKeyName;
499 std::vector<std::string> lstKeyNameActualSlice;
500 std::vector<std::string> lstKeyNameToBeErase;
502 lstKeyNameToBeErase = _sceneManager->getSelectedObjects();
503 lstKeyNameActualSlice = _sceneManager->GetlstContoursNameActualSlice();
504 int k,kSize=lstKeyNameToBeErase.size();
505 int j,jSize=lstKeyNameActualSlice.size();
507 for (k=0;k<kSize; k++)
510 for (j=0;j<jSize; j++)
512 if (lstKeyNameToBeErase[k]==lstKeyNameActualSlice[j])
519 lstKeyName.push_back( lstKeyNameToBeErase[k] );
523 deleteContours( lstKeyName );
527 void wxContourMainFrame :: deleteContours( std::vector<std::string> keyNamesVector )
529 int i,size=keyNamesVector.size();
532 deleteContour( keyNamesVector[i] );
536 void wxContourMainFrame :: deleteContour( std::string theKeyName )
539 manualContourModel * cModel;
540 manualViewBaseContour * cViewer;
541 manualContourBaseControler * cControler;
543 ContourWrap_ViewControl *conwrapviewControl = _theViewPanel->getSceneManager()->getContourWrap_ViewControlOf( theKeyName );
544 cControler = conwrapviewControl->getControler();*/
547 bool isedit = _theViewPanel->isEditableCControler(theKeyName);
548 bool ispartofstaticlst = kernelManager->IsPartOfStaticList(theKeyName);
550 if (isedit && ispartofstaticlst)
552 _theViewPanel->removeFromScene(theKeyName);
554 kernelManager->deleteCModel(theKeyName);
555 //_theViewPanel->getSceneManager()->removeFromScene( theKeyName );
556 //cViewer = conwrapviewControl->getViewer();
557 //_theViewPanel->getSceneManager()->removeWrap( theKeyName );
558 //cControler* conwrapviewControl->getControler();
561 // delete cControler;
566 void wxContourMainFrame::onDeleteContoursActSlice()
568 //JCP 20-10-08 Undo redo implementation
570 //JCP 20-10-08 Undo redo implementation
572 std::vector<int> tempVector;
573 getInstantVector( tempVector );
574 deleteContours( getOutlinesName( tempVector[1] ) );
575 // deleteContours( (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() );
578 void wxContourMainFrame::onDeleteAllContours(){
579 //JCP 20-10-08 Undo redo implementation
583 void wxContourMainFrame::deleteAllContours(){
584 //JCP 20-10-08 Undo redo implementation
587 std::vector<int> tempVector;
588 _instantPanel->getInstant( tempVector );
590 //JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
591 // the values in GetStart and GetEnd will then not be initialize also.
592 // We use instead the values given when initializing the _deletepanel.
594 //int minZ = _mbarrangeDeleteAll->GetStart();
595 //int maxZ = _mbarrangeDeleteAll->GetEnd();
599 maxZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
603 _theViewPanel->getSceneManager()->removeSceneContours( );
604 _theViewPanel->getSceneManager()->removeAllOutlines();
605 kernelManager->removeAllOutlines();
608 if ( (minZ==0) && (maxZ==_mbarrangeDeleteAll->GetMax() ))
610 _theViewPanel->getSceneManager()->removeSceneContours( );
611 _modelManager->removeAllOutlines();
612 _theViewPanel->getSceneManager()->removeAllOutlines();
615 for ( z=minZ ; z<=maxZ ; z++)
618 Instant instant(&tempVector);
619 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
621 sizeLstContourThings = lstContourThings.size();
622 for (ii=0 ; ii<sizeLstContourThings ; ii++)
624 ContourThing **contourthing = lstContourThings[ii];
625 deleteContour( (*contourthing)->getName() );
632 void wxContourMainFrame::setConceptValue( std::string name, int value )
634 _instantPanel->setConceptValue(name, value);
638 ConceptDataWrap* wxContourMainFrame::getLastConceptData()
640 return _instantPanel->getLastConceptData();
644 bool wxContourMainFrame::getIfConceptCheckedAt( std::string name, int pos )
646 return _instantPanel->getIfConceptCheckedAt( name, pos );
651 void wxContourMainFrame::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
654 vtkImageData * value;
655 this->getMaskValue(&mask, &value, typeContourGroup, selection, minZ, maxZ);
657 std::vector<int> nTypeView;
658 nTypeView.push_back(5);
659 nTypeView.push_back(1);
660 nTypeView.push_back(2);
661 nTypeView.push_back(0);
663 if (_frameShowResultImages==NULL)
665 // wxFrame *_frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), wxDEFAULT_FRAME_STYLE|wxSTAY_ON_TOP);
666 _frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600),
667 wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
669 wxAuiManager *m_mgr_noteBookViewerResult = new wxAuiManager();
670 m_mgr_noteBookViewerResult->SetManagedWindow(_frameShowResultImages);
672 wxAuiNotebook* noteBookViewerResult = new wxAuiNotebook(_frameShowResultImages, -1, wxPoint(600, 600), wxSize(430,200), m_notebook_style);
673 m_mgr_noteBookViewerResult->AddPane(noteBookViewerResult, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false));
675 wxPanel *panelViewer1 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView);
676 wxPanel *panelViewer2 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView);
679 noteBookViewerResult->AddPage( panelViewer1, wxT("Image result") );
680 noteBookViewerResult->AddPage( panelViewer2, wxT("Mask result") );
681 m_mgr_noteBookViewerResult->Update();
682 _frameShowResultImages->Show();
683 } // if _frameShowResultImages
689 void wxContourMainFrame::changeInstant()
691 std::vector<int> instantVect;
692 _instantPanel->getInstant( instantVect );
693 int actualSlice = instantVect[1];
694 kernelManager->setInstant(instantVect);
695 // Refresh Mask image
696 if(_viewMaskImage!=NULL)
698 _viewMaskImage->SetZ(actualSlice);
699 if (_viewMaskImagePanel->IsVisible()==true)
701 vtkImageData *mask, *value;
702 getMaskValue(&mask,&value, _contourGroup , 0, -1, -1);
703 _viewMaskImage->onThreshold();
705 } // if _viewMaskImage
706 // Refresh Threshold image
707 if(_viewThresholdImage!=NULL)
709 _viewThresholdImage->SetZ(actualSlice);
710 if (_viewThresholdImagePanel->IsVisible()==true)
712 _viewThresholdImage->onThreshold();
714 } // if _viewThresholdImage
715 updateInstantOutlines();
716 updateInstantImageData();
722 void wxContourMainFrame::updateInstantOutlines()
724 _theViewPanel->removeSceneContours();
725 _theViewPanel->addNameWrapperToScene();
727 //for( int i=0; i<size; i++)
729 // _theViewPanel->getSceneManager()->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false );
733 int wxContourMainFrame::getNamesWrappingSize()
735 return kernelManager->getNamesWrappingSize();
738 std::string wxContourMainFrame::getNameWrapping(int i)
740 return kernelManager->getNameWrapping(i);
743 void wxContourMainFrame::updateInstantImageData()
745 std::vector<int> inst;
746 _instantPanel->getInstant(inst);
747 vtkImageData* img = kernelManager->getImageAtInstant(inst);
750 _theViewPanel->changeImage(img);
753 int z = _instantPanel->getConceptDataOf("Axe Depth")->getActualValue();
754 _theViewPanel->setImageSlice(z);
758 void wxContourMainFrame::updateInstantAxes()
763 void wxContourMainFrame::onChangeDeep(int val){
764 _instantPanel->setConceptValue( "Axe Depth", (int)val );
769 void wxContourMainFrame::onCopy(){
770 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
771 std::vector<int> tempVector;
772 _instantPanel->getInstant( tempVector );
773 _performingOperation->reset();
774 _performingOperation->setStartCommand( COPY );
775 _performingOperation->setStartOperationInstantVector( tempVector );
776 _performingOperation->setKeyNamesOperationElems( currentSelection );
779 void wxContourMainFrame::onPaste()
781 char theStartCommand = _performingOperation->getStartCommand();
782 if ( theStartCommand == COPY )
784 //JCP 20-10-08 Undo redo implementation
786 //JCP 20-10-08 Undo redo implementation
787 std::vector<int> tempVector;
788 _instantPanel->getInstant( tempVector );
789 _performingOperation->setEndOperationInstantVector ( tempVector );
790 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
791 int i,size = elems.size();
792 for( i=0; i<size; i++ )
794 createCopyContourOf( elems[i], tempVector, i>0 );
799 void wxContourMainFrame::onUndo()
801 std::string filename;
802 if(kernelManager->onUndoSaveFile(filename)){
803 saveFileWithContours(filename);
805 if(kernelManager->onUndo(filename)){
809 void wxContourMainFrame::onRedo(){
810 std::string filename;
811 if(kernelManager->onRedo(filename)){
816 void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append )
818 std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
819 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
820 _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
823 ///AD: 03-09 Copy the object and apply the given transformation
824 void wxContourMainFrame :: createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append )
826 std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
827 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);
829 manualPoint * refPoint1 = _refLineModel->GetManualPoint(0);
830 manualPoint * refPoint2 = _refLineModel->GetManualPoint(1);
832 double pnt1X = refPoint1->GetX();
833 double pnt1Y = refPoint1->GetY();
834 // double pnt1Z = refPoint1->GetZ();
835 double pnt2X = refPoint2->GetX();
836 double pnt2Y = refPoint2->GetY();
837 // double pnt2Z = refPoint2->GetZ();
839 double angle = (atan2(pnt2Y - pnt1Y, pnt2X - pnt1X) * 180 / 3.1415926535897932384626433832795)+90;
840 vtkTransform *t = vtkTransform::New();
844 t->Translate(-pnt1X, -pnt1Y, 0);
848 t->Translate(pnt1X, pnt1Y, 0);
851 int i,size=manualModel->GetSizeLstPoints();
854 manualPoint * mp = manualModel->GetManualPoint(i);
860 t->TransformPoint( vecIn, vecOut );
861 mp->SetPointX( vecOut[0] );
862 mp->SetPointY( vecOut[1] );
863 mp->SetPointZ( vecOut[2] );
866 _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
869 void wxContourMainFrame ::loadState(std::string filename)
872 onLoadContours(filename,false);
875 void wxContourMainFrame::onLoad(bool interactiveInterface) // interactiveInterface default true
877 std::string fileNameContourROI = GetFileLocation();
878 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
879 if(GetFileLocation().empty())
881 //------------------------------------------------------------------------------------------------------------
882 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
883 #if wxMAJOR_VERSION <= 2
884 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
886 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxFD_OPEN );
888 if (dialog.ShowModal() == wxID_OK)
890 fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
893 onLoadContours(fileNameContourROI, interactiveInterface );
896 void wxContourMainFrame::SetZForAllContours(int pz)
899 std::vector< std::string > lstNameThings;
900 int i,sizeLstNameThings;
901 int ii,sizeLstPoints;
902 lstNameThings = kernelManager->GetLstNameThings();
903 sizeLstNameThings = lstNameThings.size();
904 for (i=0 ; i<sizeLstNameThings ; i++)
906 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
907 sizeLstPoints = manualModel->GetSizeLstPoints();
908 for (ii=0 ; ii<sizeLstPoints ; ii++)
910 manualModel->GetManualPoint(ii)->SetPointZ(-900);
911 }// for ii list of points
912 }// for i list of Things
916 lstNameThings = kernelManager->GetLstNameThingsStatic();
917 sizeLstNameThings = lstNameThings.size();
918 for (i=0 ; i<sizeLstNameThings ; i++)
920 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
921 sizeLstPoints = manualModel->GetSizeLstPoints();
922 for (ii=0 ; ii<sizeLstPoints ; ii++)
924 manualModel->GetManualPoint(ii)->SetPointZ(-900);
925 }// for ii list of points
926 }// for i list of static things
929 void wxContourMainFrame::onLoadContours(std::string fileNameContourROI, bool interactiveInterface)
933 FILE *pFile =fopen(fileNameContourROI.c_str(),"r+");
934 //CMRU 03-09-09- ----------------------------------------------------------------------------------------------
937 //------------------------------------------------------------------------------------------------------------
938 fileNameContourROI.append("data");
939 FILE *pFileData=fopen(fileNameContourROI.c_str(),"r+");
940 if(pFileData != NULL)
942 fscanf(pFileData,"%s",tmpD); // --CreaContour--
943 fscanf(pFileData,"%s",tmpD); // Version
944 fscanf(pFileData,"%s",tmpD); // 1.0.3 || 1.0.2 || 1.0.1 || 1.0.0
946 fscanf(pFileData,"%s",tmpD); // onePixelSize
947 fscanf(pFileData,"%s",tmpD); // #
948 _onePixelSize = atof(tmpD);
949 fscanf(pFileData,"%s",tmpD); // NumberOfContours
950 fscanf(pFileData,"%s",tmpD); // #
952 fscanf(pFile,"%s",tmp); // --CreaContour--
953 fscanf(pFile,"%s",tmp); // Version
954 fscanf(pFile,"%s",tmp); // 1.0.3 || 1.0.2 || 1.0.1 || 1.0.0
955 std::string version(tmp);
957 _tmpReadFileTypeOfTransformation=-1;
958 if (version=="1.0.3")
960 readDimSpc(pFile,interactiveInterface); // DimSpc interactive ON
961 openContours(pFile,pFileData,false);
962 openContours(pFile,pFileData,true); //Load StaticContours
964 if (version=="1.0.2")
967 readDimSpc(pFile,interactiveInterface); // DimSpc interactive ON
968 openContours(pFile,pFileData,false);
969 readDimSpc(pFile,false); // DimSpc interactive OFF
970 openContours(pFile,pFileData,true); // Load StaticContours
971 SetZForAllContours(-900);
972 } else if (version=="1.0.1") { //AD:02-06-09
973 openContours(pFile,pFileData,false); //Skips ImageDimensions and ImageSpacing
974 openContours(pFile,pFileData,true); //Load StaticContours, skips ImageDimensions and ImageSpacing
975 } else if (version=="1.0.0") { //AD:02-06-09
976 openContours(pFile,pFileData,false); //Skips ImageDimensions and ImageSpacing
979 if(pFileData != NULL)
984 _theViewPanel->getSceneManager()->removeSceneContours();
989 void wxContourMainFrame::onImport()
991 std::string filename, filenamecontours;
992 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
993 #if wxMAJOR_VERSION <= 2
994 wxFileDialog dialog(NULL, _T("Choose a XML Osirix File"), _T(""), _T(""), _T("*.xml"), wxOPEN );
996 wxFileDialog dialog(NULL, _T("Choose a XML Osirix File"), _T(""), _T(""), _T("*.xml"), wxFD_OPEN );
998 if (dialog.ShowModal() == wxID_OK)
1000 filename = dialog.GetPath().mb_str();
1001 filenamecontours = kernelManager->parseOsirixFile(filename);
1003 if(filenamecontours.compare("") != 0)
1005 onLoadContours(filenamecontours,true);
1010 void wxContourMainFrame::onTest()
1012 std::string filename, filenamecontours;
1013 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1014 #if wxMAJOR_VERSION <= 2
1015 wxFileDialog dialog(NULL, _T("Choose a File"), _T(""), _T(""), _T("*.*"), wxOPEN );
1017 wxFileDialog dialog(NULL, _T("Choose a File"), _T(""), _T(""), _T("*.*"), wxFD_OPEN );
1019 if (dialog.ShowModal() == wxID_OK)
1021 filename = dialog.GetPath().mb_str();
1022 std::cout << "This is the filename: " << filename << std::endl;
1027 void wxContourMainFrame::onSave()
1029 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1030 if(GetFileLocation().empty())
1032 //------------------------------------------------------------------------------------------------------------
1033 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1034 #if wxMAJOR_VERSION <= 2
1035 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
1037 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxFD_SAVE );
1039 if (dialog.ShowModal() == wxID_OK)
1041 std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
1042 kernelManager->setCurrentFileName(fileNameContourROI);
1043 saveFileWithContours( fileNameContourROI );
1045 } else {//CMRU 03-09-09-----------------------------------------------------------------------------------------------
1046 std::cout<<"Nombre del archivo: "<<GetFileLocation()<<std::endl;
1047 std::string fileNameContourROI = GetFileLocation();
1048 std::cout<<"Nombre del archivo: "<<fileNameContourROI<<std::endl;
1049 kernelManager->setCurrentFileName(fileNameContourROI);
1050 saveFileWithContours( fileNameContourROI);
1052 //------------------------------------------------------------------------------------------------------------
1056 void wxContourMainFrame::saveFileWithContours( std::string filename )
1059 FILE *pFile=fopen(filename.c_str(),"w+");
1061 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1062 filename.append("data");
1063 std::cout<<"Nombre del archivo: "<<filename<<std::endl;
1064 FILE *pFileData=fopen(filename.c_str(),"w+");
1065 //------------------------------------------------------------------------------------------------------------
1067 std::vector< std::string > lstNameThings;
1068 int i,sizeLstNameThings;
1070 fprintf(pFile,"--CreaContour--\n");
1071 fprintf(pFile,"Version %s\n", "1.0.3" );
1073 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1074 fprintf(pFileData,"--CreaContour--\n");
1075 fprintf(pFileData,"Version %s\n", "1.0.3" );
1076 fprintf(pFileData,"OnePixelSize %f\n", _onePixelSize);
1077 //------------------------------------------------------------------------------------------------------------
1078 vtkImageData *image = _images[0];
1080 image->GetDimensions(dimRange);
1081 fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
1083 image->GetSpacing(spaRange);
1084 fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
1086 lstNameThings = kernelManager->GetLstNameThings();
1087 sizeLstNameThings = lstNameThings.size();
1088 fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
1089 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1090 fprintf(pFileData,"NumberOfContours %d\n", sizeLstNameThings );
1091 //------------------------------------------------------------------------------------------------------------
1097 for (i=0 ; i<sizeLstNameThings ; i++)
1099 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1100 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
1102 // double sizeInPixel = manualModel ->GetPathSize( );
1103 double sizeInPixel = manualModel ->GetPathSize( spc );
1104 double realContourSize = sizeInPixel*_onePixelSize;
1105 manualModel ->SetRealSize(realContourSize);
1106 //------------------------------------------------------------------------------------------------------------
1107 //int size= kernelManager->GetLstNameThings().size();
1108 kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
1109 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
1111 //-- Static Contours
1112 // fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
1113 // fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
1114 lstNameThings = kernelManager->GetLstNameThingsStatic();
1115 sizeLstNameThings = lstNameThings.size();
1116 fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
1117 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1118 fprintf(pFileData,"NumberOfContoursStatic %d\n", sizeLstNameThings );
1119 //------------------------------------------------------------------------------------------------------------
1120 for (i=0 ; i<sizeLstNameThings ; i++)
1122 kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
1123 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
1131 void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption)
1135 double imageSpac[3];
1136 vtkImageData *image = _images[0];
1137 image->GetDimensions(imageDim);
1138 image->GetSpacing(imageSpac);
1140 fscanf(pFile,"%s",tmp); // ImageDimensions
1141 fscanf(pFile,"%s",tmp); // X
1142 _tmpReadFileImageDim[0] = atoi(tmp);
1143 fscanf(pFile,"%s",tmp); // Y
1144 _tmpReadFileImageDim[1] = atoi(tmp);
1145 fscanf(pFile,"%s",tmp); // Z
1146 _tmpReadFileImageDim[2] = atoi(tmp);
1148 fscanf(pFile,"%s",tmp); // ImageSpacing
1149 fscanf(pFile,"%s",tmp); // X
1150 _tmpReadFileImageSpac[0] = atof(tmp);
1151 fscanf(pFile,"%s",tmp); // Y
1152 _tmpReadFileImageSpac[1] = atof(tmp);
1153 fscanf(pFile,"%s",tmp); // Z
1154 _tmpReadFileImageSpac[2] = atof(tmp);
1157 if (interactiveOption==true)
1159 //Compare Spacing and Dims in X and Y (Necessary in Z?) - Just for Version 2
1160 if (imageDim[0]!=_tmpReadFileImageDim[0] || imageDim[1]!=_tmpReadFileImageDim[1] || imageSpac[0]!=_tmpReadFileImageSpac[0] || imageSpac[1]!=_tmpReadFileImageSpac[1])
1162 wxDialog* dial = new wxDialog (this,-1,_T("Tools"),wxDefaultPosition, wxSize(460,360));
1163 wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
1164 // wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL);
1165 wxFlexGridSizer *dialSizer = new wxFlexGridSizer(1);
1167 wxString lstOptOperation[3];
1168 lstOptOperation[0]=_T("By Dimension (XY)");
1169 lstOptOperation[1]=_T("By Spacing (XY)");
1170 lstOptOperation[2]=_T("By Spacing (XYZ)");
1171 wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(370,200), 3 , lstOptOperation, 3, wxRA_SPECIFY_ROWS);
1173 dialSizer->Add( new wxStaticText(dial,-1,_T("The image resolution is not compatible with the ")) , 0, wxGROW );
1174 dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW );
1175 dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
1176 dialSizer->Add(radioOpts,0,wxGROW);
1177 dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
1178 dialSizer->Add(buttonsSizer,0,wxGROW);
1179 dial->SetSizer(dialSizer, true);
1183 _tmpReadFileTypeOfTransformation = -1;
1184 //EED bool transform = false;
1186 if (dial->GetReturnCode() == wxID_OK)
1188 _tmpReadFileTypeOfTransformation = radioOpts->GetSelection();
1192 } // if interactiveOption
1199 void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool staticContour )
1203 vtkImageData *image = _images[0];
1206 double imageSpac[3];
1207 image->GetDimensions(imageDim);
1208 image->GetSpacing(imageSpac);
1211 fscanf(pFile,"%s",tmp); // NumberOfContours
1212 fscanf(pFile,"%s",tmp); // ##
1213 int numberOfContours = atoi(tmp);
1215 std::vector<int> instantVector;
1216 int typeContourModel;
1217 manualBaseModel *manModelContour;
1221 if (compatible==true)
1224 for (i=0;i<numberOfContours;i++)
1226 instantVector.clear();
1227 fscanf(pFile,"%s",tmp); // Instant
1229 fscanf(pFile,"%s",tmp); // 1
1230 instantVector.push_back( atoi(tmp) );
1231 fscanf(pFile,"%s",tmp); // 2
1232 instantVector.push_back( atoi(tmp) );
1233 fscanf(pFile,"%s",tmp); // 3
1234 instantVector.push_back( atoi(tmp) );
1235 fscanf(pFile,"%s",tmp); // 4
1236 instantVector.push_back( atoi(tmp) );
1237 fscanf(pFile,"%s",tmp); // 5
1238 instantVector.push_back( atoi(tmp) );
1239 fscanf(pFile,"%s",tmp); // 6
1240 instantVector.push_back( atoi(tmp) );
1243 fscanf(pFile,"%s",tmp); // TypeContourModel
1244 fscanf(pFile,"%s",tmp); // ##
1245 typeContourModel = atoi(tmp);
1247 manModelContour = kernelManager->factoryManualContourModel(typeContourModel);
1248 manModelContour->Open(pFile);
1249 if(pFileData != NULL)
1251 manModelContour->OpenData(pFileData);
1254 fscanf(pFile,"%s",tmp); // TypeView
1255 fscanf(pFile,"%s",tmp); // ##
1256 typeView = atoi(tmp);
1258 std::string theName;
1259 theName = kernelManager->createOutline( manModelContour, instantVector );
1260 bool addedModel = theName.compare("") != 0;
1263 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1264 _theViewPanel->getSpacing(spc);
1265 //Adding the manualContourControler to interface objects structure
1266 //Adding the manualViewContour to interface objects structure
1267 //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1268 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
1271 if (staticContour) //StaticContours (will appear in all slices)
1273 Instant instant(&instantVector);
1274 kernelManager->changeContourOfManager( theName , &instant );
1277 }// for numberOfContours
1280 else if (compatible==false)
1285 for (i=0;i<numberOfContours;i++)
1287 instantVector.clear();
1288 fscanf(pFile,"%s",tmp); // Instant
1290 fscanf(pFile,"%s",tmp); // 1
1291 instantVector.push_back( atoi(tmp) );
1292 fscanf(pFile,"%s",tmp); // 2
1293 instantVector.push_back( atoi(tmp) );
1294 fscanf(pFile,"%s",tmp); // 3
1295 instantVector.push_back( atoi(tmp) );
1296 fscanf(pFile,"%s",tmp); // 4
1297 instantVector.push_back( atoi(tmp) );
1298 fscanf(pFile,"%s",tmp); // 5
1299 instantVector.push_back( atoi(tmp) );
1300 fscanf(pFile,"%s",tmp); // 6
1301 instantVector.push_back( atoi(tmp) );
1303 fscanf(pFile,"%s",tmp); // TypeContourModel
1304 fscanf(pFile,"%s",tmp); // ##
1305 typeContourModel = atoi(tmp);
1307 manModelContour = kernelManager->factoryManualContourModel(typeContourModel);
1308 manModelContour->Open(pFile);
1309 if(pFileData != NULL)
1311 manModelContour->OpenData(pFileData);
1314 if (_tmpReadFileTypeOfTransformation==-1){
1316 } else if (_tmpReadFileTypeOfTransformation==0){
1317 double transX, transY;
1318 transX = (double) imageDim[0]/_tmpReadFileImageDim[0]; // X
1319 transY = (double) imageDim[1]/_tmpReadFileImageDim[1]; // Y
1320 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
1321 } else if (_tmpReadFileTypeOfTransformation==1) {
1322 double transX, transY;
1323 transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0]; // X
1324 transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1]; // Y
1325 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
1326 } else if (_tmpReadFileTypeOfTransformation==2) { // with Z include
1327 double transX, transY;
1328 transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0]; // X
1329 transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1]; // Y
1330 instantVector[1]=instantVector[1]*_tmpReadFileImageSpac[2]/imageSpac[2]; // Z
1331 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
1333 printf ("EED Warnning! wxContourMainFrame::openContours _tmpReadFileTypeOfTransformation not set. \n");
1336 fscanf(pFile,"%s",tmp); // TypeView
1337 fscanf(pFile,"%s",tmp); // ##
1338 typeView = atoi(tmp);
1340 std::string theName;
1341 theName = kernelManager->createOutline( manModelContour, instantVector );
1342 bool addedModel = theName.compare("") != 0;
1345 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1346 _theViewPanel->getSpacing(spc);
1347 //Adding the manualContourControler to interface objects structure
1348 //Adding the manualViewContour to interface objects structure
1349 //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1350 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
1353 if (staticContour) //StaticContours (will appear in all slices)
1355 Instant instant(&instantVector);
1356 kernelManager->changeContourOfManager( theName , &instant );
1358 }// for numberOfContours
1364 void wxContourMainFrame::RefreshInterface()
1367 _theViewPanel->RefreshInterface();
1368 //wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
1369 //wxvtk2dbaseview->Refresh();
1372 vtkImageData* wxContourMainFrame::getImageData()
1374 return _theViewPanel->getImageData();
1377 void wxContourMainFrame::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
1379 //JCP 20-10-08 Undo redo implementation
1381 //JCP 20-10-08 Undo redo implementation
1384 int x = _theViewPanel->GetX();
1385 int y = _theViewPanel->GetY();
1386 int z = _theViewPanel->GetZ();
1387 SegmentationOneSliceITK( x,y,z,distance, sigma, alfa, beta, propagation, iterations, inflation);
1391 void wxContourMainFrame::SegmentationOneSliceITK(int x, int y, int z, wxString distanc, wxString sigm, wxString alf, wxString bet, wxString prop, wxString iter, wxString inflation)
1393 int typeofcontour = 1;
1395 vtkImageData *imagedata = getImageData();
1396 //Tipo de pixeles a utilizar internamente en ITK
1397 typedef float InternalPixelType;
1398 const unsigned int Dimension = 2;
1399 typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
1400 //Tipo de pixeles de salida 1
1401 typedef unsigned char OutputPixelType;
1402 typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
1403 //Tipo de pixeles de salida 2
1404 typedef unsigned short OutputPixelType2;
1405 typedef itk::Image< OutputPixelType2, Dimension > OutputImageType2;
1406 //DefiniciÛn del thresholder
1407 typedef itk::BinaryThresholdImageFilter<
1409 OutputImageType > ThresholdingFilterType;
1410 //DefiniciÛn del primer filtro de conversiÛn de pixeles
1411 typedef itk::CastImageFilter<
1412 OutputImageType, OutputImageType2 > CastFilterType;
1413 //DefiniciÛn del segundo tipo de conversiÛn de pixeles
1414 typedef itk::CastImageFilter<
1415 OutputImageType2, InternalImageType > CastFilterType2;
1416 //Tercer tipo de conversiÛn
1417 typedef itk::RescaleIntensityImageFilter<
1419 OutputImageType > CastFilterType3;
1420 //Cuarto tipo de conversiÛn
1421 typedef itk::RescaleIntensityImageFilter<
1423 OutputImageType > CastFilterType4;
1424 ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();
1425 thresholder->SetLowerThreshold( 0.0 );
1426 thresholder->SetUpperThreshold( 128 );
1427 thresholder->SetOutsideValue( 255 );
1428 thresholder->SetInsideValue( 0 );
1429 //DefinciÛn de conexiÛnes entre VTK e ITK y el writer
1430 typedef itk::VTKImageToImageFilter<OutputImageType2> ConnectorType;
1431 typedef itk::ImageToVTKImageFilter<OutputImageType> ConnectorType2;
1432 //EED10JUIN2011 typedef itk::ImageFileWriter< OutputImageType > WriterType;
1433 ConnectorType::Pointer connector = ConnectorType::New();
1434 ConnectorType2::Pointer connector2 = ConnectorType2::New();
1435 CastFilterType::Pointer filter = CastFilterType::New();
1436 CastFilterType2::Pointer filter2 = CastFilterType2::New();
1437 connector->SetInput( imagedata );
1438 filter2->SetInput(connector->GetOutput());
1439 typedef itk::CurvatureAnisotropicDiffusionImageFilter<
1441 InternalImageType > SmoothingFilterType;
1442 SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();
1443 typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<
1445 InternalImageType > GradientFilterType;
1446 typedef itk::SigmoidImageFilter<
1448 InternalImageType > SigmoidFilterType;
1449 GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();
1450 SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
1451 sigmoid->SetOutputMinimum( 0.0 );
1452 sigmoid->SetOutputMaximum( 255.0 );
1453 typedef itk::FastMarchingImageFilter<
1455 InternalImageType > FastMarchingFilterType;
1456 FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();
1457 typedef itk::GeodesicActiveContourLevelSetImageFilter< InternalImageType,
1458 InternalImageType > GeodesicActiveContourFilterType;
1459 GeodesicActiveContourFilterType::Pointer geodesicActiveContour =
1460 GeodesicActiveContourFilterType::New();
1461 typedef itk::ZeroCrossingImageFilter<
1463 InternalImageType > ZeroCrossingFilterType;
1464 ZeroCrossingFilterType::Pointer zeroCrossing =
1465 ZeroCrossingFilterType::New();
1466 const double propagationScaling = atof( crea::wx2std(prop).c_str() );
1467 geodesicActiveContour->SetPropagationScaling( propagationScaling );
1468 geodesicActiveContour->SetCurvatureScaling( 1.0 );
1469 geodesicActiveContour->SetAdvectionScaling( 1.0 );
1470 geodesicActiveContour->SetMaximumRMSError( 0.02 );
1471 int it=atoi( crea::wx2std(iter).c_str() );
1472 geodesicActiveContour->SetNumberOfIterations( it );
1473 smoothing->SetInput( filter2->GetOutput() );
1474 gradientMagnitude->SetInput( smoothing->GetOutput() );
1475 sigmoid->SetInput( gradientMagnitude->GetOutput() );
1476 fastMarching->SetInput( sigmoid->GetOutput() );
1477 geodesicActiveContour->SetInput( fastMarching->GetOutput() );
1478 geodesicActiveContour->SetFeatureImage( sigmoid->GetOutput() );
1479 zeroCrossing->SetInput( geodesicActiveContour->GetOutput() );
1480 //thresholder->SetInput( zeroCrossing->GetOutput() );
1481 thresholder->SetInput( geodesicActiveContour->GetOutput() );
1482 connector2->SetInput( thresholder->GetOutput() );
1483 smoothing->SetTimeStep( 0.125 );
1484 smoothing->SetNumberOfIterations( 5 );
1485 smoothing->SetConductanceParameter( 9.0 );
1486 const double sigma = atof( crea::wx2std(sigm).c_str() );
1487 gradientMagnitude->SetSigma( sigma );
1488 const double alpha = atof( crea::wx2std(alf).c_str() );
1489 const double beta = atof( crea::wx2std(bet).c_str() );
1490 sigmoid->SetAlpha( alpha );
1491 sigmoid->SetBeta( beta );
1492 typedef FastMarchingFilterType::NodeContainer NodeContainer;
1493 typedef FastMarchingFilterType::NodeType NodeType;
1494 NodeContainer::Pointer seeds = NodeContainer::New();
1495 InternalImageType::IndexType seedPosition;
1496 seedPosition[0] = x;
1497 seedPosition[1] = y;
1498 const double initialDistance = atof( crea::wx2std(distanc).c_str() );
1500 const double seedValue = - initialDistance;
1501 node.SetValue( seedValue );
1502 node.SetIndex( seedPosition );
1503 seeds->Initialize();
1504 seeds->InsertElement( 0, node );
1505 fastMarching->SetTrialPoints( seeds );
1506 fastMarching->SetSpeedConstant( 1.0 );
1507 fastMarching->SetOutputSize( connector->GetOutput()->GetBufferedRegion().GetSize() );
1508 fastMarching->SetStoppingValue( 800 );
1511 // connector2->Update();
1512 vtkImageData *idata = NULL;
1513 idata = connector2->GetOutput();
1514 vtkMarchingContourFilter* cntVTK = vtkMarchingContourFilter::New( );
1515 cntVTK->SetNumberOfContours( 1 );
1516 cntVTK->SetValue( 0, 255 );
1517 //EED 2017-01-01 Migration VTK7
1518 #if VTK_MAJOR_VERSION <= 5
1519 cntVTK->SetInput( idata );
1521 cntVTK->UpdateInformation();
1523 cntVTK->SetInputData( idata );
1525 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
1526 //EED 2017-01-01 Migration VTK7
1527 #if VTK_MAJOR_VERSION <= 5
1528 cpd->SetInput( cntVTK->GetOutput( ) );
1530 cpd->UpdateInformation();
1532 cpd->SetInputData( cntVTK->GetOutput( ) );
1534 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
1535 conn->SetExtractionModeToLargestRegion( );
1536 //EED 2017-01-01 Migration VTK7
1537 #if VTK_MAJOR_VERSION <= 5
1538 conn->SetInput( cpd->GetOutput( ) );
1540 conn->UpdateInformation();
1542 conn->SetInputData( cpd->GetOutput( ) );
1544 vtkStripper* vtkstripper = vtkStripper::New( );
1545 //EED 2017-01-01 Migration VTK7
1546 #if VTK_MAJOR_VERSION <= 5
1547 vtkstripper->SetInput( conn->GetOutput() );
1548 vtkstripper->Update();
1549 vtkstripper->UpdateInformation();
1551 vtkstripper->SetInputData( conn->GetOutput() );
1554 vtkPolyData* polyDataResult = cntVTK->GetOutput();
1555 //std::cout<<"Points "<<polyDataResult->GetNumberOfPoints()<<std::endl;
1557 //EED 2017-01-01 Migration VTK7
1558 #if VTK_MAJOR_VERSION <= 5
1559 polyDataResult->Update( );
1560 polyDataResult->UpdateInformation();
1567 //--Calculating control points
1568 std::vector<double> vecX;
1569 std::vector<double> vecY;
1570 std::vector<double> vecXo;
1571 std::vector<double> vecYo;
1572 std::vector<double>::iterator vecXoi;
1573 std::vector<double>::iterator vecYoi;
1574 std::vector<double> vecZ;
1575 std::vector<double> vecCtrlPointX;
1576 std::vector<double> vecCtrlPointY;
1577 std::vector<double> vecCtrlPointZ;
1581 int ii,size=polyDataResult->GetNumberOfPoints();
1583 myfile.open ("C:/Creatis/example2.txt");
1584 size=polyDataResult->GetNumberOfPoints();
1585 for (ii=0;ii<size;ii++)
1592 p = polyDataResult->GetPoint(ii);
1595 // if(fabs(yAct-y)>20)
1597 // if((xAct-x)>1 || (xAct-x)<-1)
1599 // vecX.push_back( p[0] );
1600 // vecY.push_back( p[1] );
1601 // myfile <<p[0]<<","<<p[1]<<"\n";
1602 // std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
1603 // std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
1604 // std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
1605 // vecZ.push_back( 900 );
1609 // vecXo.push_back(p[0]);
1610 // vecYo.push_back(p[1]);
1616 vecXo.push_back(p[0]);
1617 vecYo.push_back(p[1]);
1619 vecX.push_back( p[0] );
1620 myfile <<p[0]<<","<<p[1]<<"\n";
1621 //std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
1622 //std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
1623 //std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
1624 vecY.push_back( p[1] );
1626 vecZ.push_back( -900 );
1634 while(!vecXo.empty())
1636 vecX.push_back(vecXo.back());
1637 //std::cout<<" x Siguiente "<<vecXo.back();
1640 vecZ.push_back( -900 );
1642 while(!vecYo.empty())
1644 vecY.push_back(vecYo.back());
1649 // for(int l=0;l<vecX.size();l++)
1653 // vecXo.push_back(p[0]);
1654 // vecYo.push_back(p[1]);
1656 // if(vecXoi[l-1]==)
1662 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
1663 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
1668 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1669 } else if (method==1){
1670 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1671 } else if (method==2){
1672 extractcontrolpoints2d->SetSamplingControlPoints( 15 );
1673 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1675 //--Adding contour to the system
1677 std::vector<int> actualInstantVector;
1678 _instantPanel->getInstant( actualInstantVector );
1679 actualInstantVector[1]=z;
1681 int j,sizeCtrPt = vecCtrlPointX.size();
1683 manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour );
1684 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
1686 for (j=0 ; j<sizeCtrPt ; j++)
1688 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
1690 std::string theName;
1691 //theName = _modelManager->createOutline( manModelContour, actualInstantVector );
1692 theName = kernelManager->createOutline( manModelContour, actualInstantVector );
1693 bool addedModel = theName.compare("") != 0;
1696 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1697 _theViewPanel->getSpacing(spc);
1698 //Adding the manualContourControler to interface objects structure
1699 //Adding the manualViewContour to interface objects structure
1700 //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1701 _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
1702 //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
1706 } catch( itk::ExceptionObject & excep ) {
1707 std::cerr << "Exception caught !" << std::endl;
1708 std::cerr << excep << std::endl;
1713 void wxContourMainFrame::onSegmentationOneSlice(double isovalue,int sampling,int method){
1715 //JCP 20-10-08 Undo redo implementation
1717 //JCP 20-10-08 Undo redo implementation
1720 int x = _theViewPanel->GetX();
1721 int y = _theViewPanel->GetY();
1722 int z = _theViewPanel->GetZ();
1723 SegmentationOneSlice( x,y,z,isovalue, sampling, method , getImageData() );
1728 void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, double isovalue, int sampling, int method , vtkImageData *imagedata)
1730 int typeofcontour = 1;
1731 //--Extracting Contour
1733 // vtkImageData *imagedata = getImageData();
1735 vtkImageReslice *imageReslice = vtkImageReslice::New();
1738 imagedata->GetSpacing(spc);
1743 //EED 2017-01-01 Migration VTK7
1744 #if VTK_MAJOR_VERSION <= 5
1745 imageReslice->SetInput( imagedata );
1747 imageReslice->SetInputData( imagedata );
1749 imageReslice->SetInformationInput(imagedata);
1750 imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
1751 imageReslice->SetResliceAxesOrigin(0,0,z*spc[2]);
1752 imageReslice->SetOutputDimensionality(2);
1753 imageReslice->SetInterpolationModeToLinear();
1755 //EED 2017-01-01 Migration VTK7
1756 #if VTK_MAJOR_VERSION <= 5
1759 imageReslice->Update();
1762 imagedata = imageReslice->GetOutput();
1763 //EED 2017-01-01 Migration VTK7
1764 #if VTK_MAJOR_VERSION <= 5
1765 imagedata->Update();
1766 imagedata->UpdateInformation();
1771 vtkContourFilter* cntVTK = vtkContourFilter::New( );
1772 //EED 2017-01-01 Migration VTK7
1773 #if VTK_MAJOR_VERSION <= 5
1774 cntVTK->SetInput( imagedata );
1776 cntVTK->SetInputData( imagedata );
1779 cntVTK->SetNumberOfContours( 1 );
1780 //cntVTK->SetValue( 0, vmin );
1781 // cntVTK->SetValue( 0, (range[1]*thr/100) );
1782 cntVTK->SetValue( 1, isovalue );
1783 // cntVTK->SetValue( 1, vmax );
1785 cntVTK->UpdateInformation();
1787 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
1788 //EED 2017-01-01 Migration VTK7
1789 #if VTK_MAJOR_VERSION <= 5
1790 cpd->SetInput( cntVTK->GetOutput( ) );
1792 cpd->SetInputData( cntVTK->GetOutput( ) );
1794 cpd->ConvertLinesToPointsOff( );
1796 cpd->UpdateInformation();
1798 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
1800 // conn->SetExtractionModeToPointSeededRegions();
1801 // conn->SetExtractionModeToCellSeededRegions();
1802 // conn->SetExtractionModeToSpecifiedRegions();
1803 // conn->SetExtractionModeToLargestRegion();
1804 // conn->SetExtractionModeToAllRegions();
1806 conn->SetExtractionModeToClosestPointRegion();
1808 //conn->SetMaxRecursionDepth( 3000 );
1810 //EED 2017-01-01 Migration VTK7
1811 #if VTK_MAJOR_VERSION <= 5
1812 conn->SetInput( cpd->GetOutput( ) );
1814 conn->SetInputData( cpd->GetOutput( ) );
1817 conn->SetClosestPoint( x, y, 0 );
1819 conn->UpdateInformation();
1821 vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
1822 //EED 2017-01-01 Migration VTK7
1823 #if VTK_MAJOR_VERSION <= 5
1824 cpd2->SetInput( conn->GetOutput( ) );
1826 cpd2->SetInputData( conn->GetOutput( ) );
1829 cpd2->UpdateInformation();
1831 vtkStripper* vtkstripper = vtkStripper::New( );
1832 vtkstripper->SetJoinContiguousSegments(true);
1833 vtkstripper->SetMaximumLength(20000);
1834 //EED 2017-01-01 Migration VTK7
1835 #if VTK_MAJOR_VERSION <= 5
1836 vtkstripper->SetInput( cpd2->GetOutput() );
1838 vtkstripper->SetInputData( cpd2->GetOutput() );
1839 // vtkstripper->SetInputData( cntVTK->GetOutput() );
1842 vtkstripper->Update();
1843 vtkstripper->UpdateInformation();
1846 vtkPolyData* polyDataResult = vtkstripper->GetOutput();
1848 //EED 2017-01-01 Migration VTK7
1849 #if VTK_MAJOR_VERSION <= 5
1850 polyDataResult->Update( );
1851 polyDataResult->UpdateInformation();
1858 myfile.open ("c:/temp/example.txt");
1860 polyDataResult->Print(myfile);
1861 myfile << "-------------------------------------\n";
1862 polyDataResult->GetLines()->Print(myfile);
1870 //--Calculating control points
1871 std::vector<double> vecX;
1872 std::vector<double> vecY;
1873 std::vector<double> vecZ;
1874 std::vector<double> vecCtrlPointX;
1875 std::vector<double> vecCtrlPointY;
1876 std::vector<double> vecCtrlPointZ;
1878 //printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() );
1879 //int numberOfPointsInCell;
1880 //int numberOfcells=polyDataResult->GetNumberOfCells();
1881 //for (int jj=0; jj<numberOfcells ; jj++)
1883 // vtkCell* vtkcell = polyDataResult->GetCell( jj );
1884 // numberOfPointsInCell=vtkcell->GetNumberOfPoints();
1885 // printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d points=%d \n",jj,numberOfPointsInCell );
1887 // printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n");
1888 // polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
1891 if (polyDataResult->GetNumberOfCells()>0)
1894 vtkCell* vtkcell = polyDataResult->GetCell( 0 );
1895 // int ii,size=polyDataResult->GetNumberOfPoints();
1896 int ii,size=vtkcell->GetNumberOfPoints();
1898 for (ii=0;ii<size;ii++)
1900 // id = polyDataResult->GetLines()->GetData()->GetValue(ii);
1901 // p = polyDataResult->GetPoint(id);
1902 p = vtkcell->GetPoints()->GetPoint(ii);
1903 // printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d px=%f py=%f\n",ii,id, p[0],p[1]);
1906 vecX.push_back( p[0] );
1907 vecY.push_back( p[1] );
1909 vecZ.push_back( -900 );
1910 // vecZ.push_back( p[2] );
1912 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
1913 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
1915 /*if (methodRadiobox->GetSelection()==0){
1916 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1918 if (methodRadiobox->GetSelection()==1){
1919 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1921 if (methodRadiobox->GetSelection()==2){
1922 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
1923 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1928 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1929 } else if (method==1){
1930 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1931 } else if (method==2){
1932 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
1933 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1936 //--Adding contour to the system
1937 std::vector<int> actualInstantVector;
1938 _instantPanel->getInstant( actualInstantVector );
1939 actualInstantVector[1]=z;
1941 int j,sizeCtrPt = vecCtrlPointX.size();
1942 manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour );
1943 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 *2 );
1944 manModelContour->SetLabel2( std::to_string(z) );
1947 for (j=0 ; j<sizeCtrPt ; j++)
1949 manModelContour->AddPoint( vecCtrlPointX[j] / spc[0], vecCtrlPointY[j] / spc[1], vecCtrlPointZ[j] );
1951 std::string theName;
1952 //theName = _modelManager->createOutline( manModelContour, actualInstantVector );
1953 theName = kernelManager->createOutline( manModelContour, actualInstantVector );
1954 bool addedModel = theName.compare("") != 0;
1957 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1958 _theViewPanel->getSpacing(spc);
1959 //Adding the manualContourControler to interface objects structure
1960 //Adding the manualViewContour to interface objects structure
1961 //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
1962 _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
1963 //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
1966 } // if NumberOfCells > 0
1967 //printf("EED wxContourMainFrame::SegmentationOneSlice End\n");
1970 int wxContourMainFrame::GetImageDataSizeZ()
1972 return _theViewPanel->GetImageDataSizeZ();
1975 void wxContourMainFrame::GetImageDataRange(double *range)
1977 _theViewPanel->GetImageDataRange(range);
1980 void wxContourMainFrame::onSegmentationAllSlices2(int step ,double isovalue,int sampling,int method,int minZ, int maxZ,vtkImageData* imagedata)
1982 //JCP 20-10-08 Undo redo implementation
1984 //JCP 20-10-08 Undo redo implementation
1986 // int x = _theViewPanel->GetX();
1987 // int y = _theViewPanel->GetY();
1990 // wxString tmpString;
1991 // double totalZ = maxZ-minZ+1;
1993 imagedata->GetExtent(ext);
1994 int sizeZ = ext[5]-ext[4]+1;
1995 if (minZ<0) { minZ=0; }
1996 if (maxZ>=sizeZ) { maxZ=sizeZ-1; }
1997 for( z=minZ ; z<=maxZ ; z=z+step )
1999 // porcent = 100.0* (z-minZ)/totalZ;
2000 // tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
2001 // interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
2002 //_staticTextSegmentation->SetLabel(tmpString);
2003 SegmentationOneSlice( 100,100,z,isovalue, sampling,method , imagedata );
2005 // interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" "));
2009 void wxContourMainFrame::onSegmentationAllSlices(int minZ,int maxZ,double isovalue,int sampling,int method)
2011 //JCP 20-10-08 Undo redo implementation
2013 //JCP 20-10-08 Undo redo implementation
2016 int x = _theViewPanel->GetX();
2017 int y = _theViewPanel->GetY();
2021 double totalZ = maxZ-minZ+1;
2022 for( z=minZ ; z<=maxZ ; z++ )
2024 porcent = 100.0* (z-minZ)/totalZ;
2025 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
2026 interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
2027 //_staticTextSegmentation->SetLabel(tmpString);
2028 SegmentationOneSlice( x,y,z,isovalue, sampling,method , getImageData() );
2030 interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" "));
2035 //Creates a reference line to be used as the axis of the mirroring
2036 void wxContourMainFrame::referenceLine()
2038 if (_refLineControl==NULL)
2043 vtkImageData *vtkimagedata = _theViewPanel->getImageData();
2044 vtkimagedata->GetSpacing(spc);
2046 wxVtkBaseView * viewer2D = _theViewPanel->getWxVtkBaseView();
2048 _refLineControl = new manualLineControler();
2049 _refLineModel = new manualContourModelLine();
2050 _refLineView = new manualViewLine();
2051 _refLineView->SetModel( _refLineModel );
2052 _refLineView->SetWxVtkBaseView( viewer2D );
2053 _refLineView->SetRange( 2 );
2054 _refLineView->SetZ( 1200 );
2056 _refLineView->SetSpacing(spc);
2058 _refLineView->SetColorNormalContour(0, 0, 1);
2059 _refLineView->SetColorEditContour(0, 0.5, 0.5);
2060 _refLineView->SetWidthLine(4);
2062 _refLineControl->SetModelView( _refLineModel , _refLineView );
2063 vtkInteractorStyleBaseView* style = (vtkInteractorStyleBaseView*)viewer2D->GetInteractorStyleBaseView();
2064 style->AddInteractorStyleMaracas( _refLineControl );
2065 _refLineModel->SetCloseContour(false);
2066 _refLineControl->CreateNewManualContour();
2068 //AD: Inicializar el mirroring con una linea ya pintada
2070 double z = _refLineControl->GetZ();
2073 image->GetDimensions(imageDim);
2074 double x = (double) imageDim[0]/2;
2075 double y1 = (double) (imageDim[1]/2)+15;
2076 double y2 = (double) (imageDim[1]/2)-15;
2078 _refLineControl->AddPoint(x,y1,z);
2079 _refLineControl->AddPoint(x,y2,z);
2080 _refLineControl->SetCompleteCreation(true);
2082 _refLineModel->AddPoint(x,y1,z);
2083 _refLineModel->AddPoint(x,y2,z);
2084 _refLineModel->UpdateSpline();
2086 _refLineView->UpdateViewPoint(0);
2087 _refLineView->UpdateViewPoint(1);
2090 _refLineControl->SetActive(true);
2091 _refLineView->RefreshContour();
2095 //Hides the referenceLine
2096 void wxContourMainFrame::refLineHide()
2098 if (_refLineControl!=NULL)
2100 if (_refLineControl->GetActive())
2102 _refLineView->RemoveCompleteContourActor();
2103 _refLineControl->SetEditable(false);
2104 _refLineControl->SetActive(false);
2111 //Shows the referenceLine
2112 void wxContourMainFrame::refLineShow()
2114 if (_refLineControl!=NULL)
2116 if (_refLineControl->GetActive()==false)
2118 wxVtkBaseView * viewer2D = _theViewPanel->getWxVtkBaseView();
2120 _refLineView->SetModel( _refLineModel );
2121 _refLineView->SetWxVtkBaseView( viewer2D );
2122 _refLineView->SetRange( 2 );
2123 _refLineView->SetZ( 1200 );
2125 _refLineControl->SetModelView( _refLineModel , _refLineView );
2126 vtkInteractorStyleBaseView* style = (vtkInteractorStyleBaseView*)viewer2D->GetInteractorStyleBaseView();
2127 style->AddInteractorStyleMaracas( _refLineControl );
2128 _refLineControl->CreateNewManualContour();
2129 _refLineControl->SetActive(true);
2130 _refLineView->RefreshContour();
2137 void wxContourMainFrame::refLineChangeWidth(int width)
2139 _refLineView->SetWidthLine(width);
2140 _refLineView->RefreshContour();
2146 void wxContourMainFrame::onMirror()
2149 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
2150 std::vector<std::string> filterCurrentSelection;
2152 std::vector<int> tempVector;
2153 _instantPanel->getInstant( tempVector );
2154 _performingOperation->reset();
2155 _performingOperation->setStartCommand( COPY );
2156 _performingOperation->setStartOperationInstantVector( tempVector );
2157 _performingOperation->setKeyNamesOperationElems( currentSelection );
2159 char theStartCommand = _performingOperation->getStartCommand();
2160 if ( theStartCommand == COPY )
2162 //JCP 20-10-08 Undo redo implementation
2164 //JCP 20-10-08 Undo redo implementation
2165 std::vector<int> tempVector;
2166 _instantPanel->getInstant( tempVector );
2167 _performingOperation->setEndOperationInstantVector ( tempVector );
2168 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
2169 int i,size = elems.size();
2170 for( i=0; i<size; i++ )
2172 createMirrorContourOf( elems[i], tempVector, i>0 );
2176 //deleteContour( _refName );
2181 void wxContourMainFrame::showAxis(bool show)
2183 _theViewPanel->SetVisibleAxis(show);
2184 _theViewPanel->Refresh();
2188 void wxContourMainFrame::onRigidPressed(){
2189 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
2190 int elementsSelected = currentSelection.size();
2192 if ( elementsSelected >= 1 ){
2193 //JCP 20-10-08 Undo redo implementation
2195 //JCP 20-10-08 Undo redo implementation
2197 std::vector<int> tempVector;
2198 _instantPanel->getInstant( tempVector );
2199 Instant instant(&tempVector);
2201 int i , size=currentSelection.size();
2202 for ( i=0 ; i<size ; i++ )
2204 kernelManager->changeContourOfManager(currentSelection[i], &instant);
2209 void wxContourMainFrame::onWidthOfContour(double width){
2211 _theViewPanel->removeSceneContours();
2212 _theViewPanel->SetWidthContour(width);
2214 //_theViewPanel->getSceneManager()->SetWidthContour( width );
2219 int wxContourMainFrame::getColorWindow()
2223 vtkImageData * img = getImageData();
2224 img->GetScalarRange(range);
2226 std::cout<<"Val 1: "<<range[0]<<" Val 2: "<<range[1]<<std::endl;
2228 return (int)range[1];
2230 return _theViewPanel->getColorWindow();
2233 int wxContourMainFrame::getWindowLevel()
2237 vtkImageData * img = getImageData();
2238 img->GetScalarRange(range);
2240 std::cout<<"Val 1: "<<range[0]<<" Val 2: "<<range[1]<<std::endl;
2242 return (int)range[1];
2244 return _theViewPanel->getWindowLevel();
2247 void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
2249 _theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
2253 void wxContourMainFrame::onInterpolation(bool interpolate)
2255 _theViewPanel->onInterpolation(interpolate);
2259 void wxContourMainFrame::onBeforeAfterContour(bool before,bool after)
2261 _theViewPanel->onBeforeAfterContour(before,after);
2265 void wxContourMainFrame::onJumpSlice(int step, int shift)
2267 std::vector<int> tempVector;
2268 _instantPanel->getInstant( tempVector );
2270 int pos = tempVector[1];
2271 int maxZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
2272 pos=(pos/ss)*ss+step+shift;
2273 if ((pos>=0) && (pos<maxZ))
2276 _instantPanel->setInstant( tempVector );
2281 void wxContourMainFrame::onShowTextContour(bool show)
2283 _theViewPanel->onShowTextContour(show);
2287 void wxContourMainFrame::onChangeInstant(std::string name,int actual)
2289 _instantPanel->setConceptValue( name, actual );
2292 void wxContourMainFrame::resetAppend()
2294 kernelManager->resetAppend();
2297 void wxContourMainFrame::onSpreadAdd()
2299 std::vector<double> vecX;
2300 std::vector<double> vecY;
2301 std::vector<double> vecZ;
2302 _theViewPanel->GetPointsOfActualContour(&vecX , &vecY , &vecZ );
2303 std::vector<int> tempVector;
2304 _instantPanel->getInstant( tempVector );
2305 std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
2306 interfMainPanel::getInstance()->appendStringSpread(val);
2310 void wxContourMainFrame::onSpreadAddAll()
2313 std::vector<int> tempVector;
2314 _instantPanel->getInstant( tempVector );
2317 maxZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
2319 int sizeLstContourThings;
2320 for ( z=minZ ; z<=maxZ ; z++ )
2323 Instant instant(&tempVector);
2324 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
2325 sizeLstContourThings = lstContourThings.size();
2326 if (sizeLstContourThings>=1)
2328 std::vector<double> vecX;
2329 std::vector<double> vecY;
2330 std::vector<double> vecZ;
2331 ContourThing **contourthing = lstContourThings[0];
2332 manualBaseModel *cModel = (*contourthing)->getModel();
2333 int i,size = cModel->GetNumberOfPointsSpline();
2335 for (i=0; i<size; i++)
2337 cModel->GetSpline_i_Point(i, &x, &y, &z);
2342 std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
2343 interfMainPanel::getInstance()->appendStringSpread(val);
2344 }// if sizeLstContourThings
2349 void wxContourMainFrame::onSpreadGo(int type)
2351 //JCP 20-10-08 Undo redo implementation
2353 //JCP 20-10-08 Undo redo implementation
2355 std::vector<double> vecCtrlPointX;
2356 std::vector<double> vecCtrlPointY;
2357 std::vector<double> vecCtrlPointZ;
2361 std::vector<int> tempVector;
2362 _instantPanel->getInstant( tempVector );
2365 kernelManager->getMaxMinZ(&minZ,&maxZ);
2366 //JSTG_16-07-08_----------------------------------------------------------------
2367 //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
2368 kernelManager->CalculeSplinePropagation();
2370 double totalZ = maxZ-minZ+1;
2373 //--------------------------------------------------------------------
2374 for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
2376 porcent = 100.0* (z-minZ)/totalZ;
2377 int numero = (int)(z-minZ+1)/(int)totalZ;
2378 std::string stringtemp = " "+kernelManager->intToString(porcent)+"% "+kernelManager->intToString(numero)+" "+kernelManager->intToString(z);
2380 interfMainPanel::getInstance()->setStringSpread(stringtemp);
2382 int typeofcontour = 1;
2383 std::string theName;
2384 manualBaseModel* manModelContour = kernelManager->GetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector);
2386 if( manModelContour!=NULL ){
2387 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2388 this->_theViewPanel->getSpacing(spc);
2389 //Adding the manualContourControler to interface objects structure
2390 //Adding the manualViewContour to interface objects structure
2391 //_theViewPanel->getSceneManager()->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
2392 _theViewPanel->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
2397 int numero = (int)(z-minZ+1)/(int)totalZ;
2398 std::string stringtemp = " "+kernelManager->intToString(porcent)+"% "+kernelManager->intToString(numero)+" "+kernelManager->intToString(z);
2400 interfMainPanel::getInstance()->setStringSpread(stringtemp);
2402 //RefreshInterface();
2405 void wxContourMainFrame::getInstantVector(std::vector<int>& tempVector)
2407 _instantPanel->getInstant( tempVector );
2410 std::vector<std::string> wxContourMainFrame::getOutlinesName(int slide)
2412 std::vector<int> tempVector;
2413 _instantPanel->getInstant(tempVector);
2414 //Asignation of slide number should be different ex by name
2415 tempVector[1]=slide;
2416 return kernelManager->getOutlinesNameAtInstant(tempVector);
2420 void wxContourMainFrame::SetScalarRange(int grayRangeMin, int grayRangeMax)
2422 _contourextractdata->SetScalarRange(grayRangeMin,grayRangeMax);
2426 void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax)
2429 wxString tempString;
2430 int maxContourGroup = 0;
2432 _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
2434 std::vector<manualBaseModel*> lstManConMod;
2435 std::vector<manualBaseModel*> lstManConModTmp;
2436 std::vector<manualBaseModel*> lstManConModExp;
2437 std::vector<double> pLstValue;
2438 std::vector<double> pLstValuePosX;
2439 std::vector<double> pLstValuePosY;
2440 std::vector<double> pLstValuePosZ;
2443 int resultGrayRangeCount;
2446 double resultAverage;
2447 double resultStandardeviation;
2449 std::vector<int> tempVector;
2450 _instantPanel->getInstant( tempVector );
2453 int ii,sizeLstContourThings;
2462 if (selection==0 ) // actual slice
2464 int actualSlice = tempVector[1];
2467 } else { // slice range
2473 totalZ = maxZ-minZ+1;
2475 _contourextractdata->InitVolumeStatistics();
2478 for ( z=minZ ; z<=maxZ ; z++ )
2481 porcent = 100.0* (z-minZ)/totalZ;
2482 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
2484 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
2485 //_staticTextInformation->SetLabel(tmpString);
2487 //Extraction data from contours of each slice
2488 _contourextractdata->SetZtoBeAnalys(z);
2491 Instant instant(&tempVector);
2492 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
2493 sizeLstContourThings = lstContourThings.size();
2495 lstManConMod.clear();
2496 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2498 ContourThing **contourthing = lstContourThings[ii];
2499 lstManConMod.push_back( (*contourthing)->getModel() );
2502 lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
2504 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
2505 interfMainPanel::getInstance()->setRowLabelInfoPanel(z, tempString);
2506 //_grid->SetRowLabelValue(z, tempString );
2508 int iContourGroup,sizeContourGroup;
2509 if (typeContourGroup==3) // contour separete
2511 sizeContourGroup=lstManConModExp.size();
2512 if ( maxContourGroup<sizeContourGroup )
2514 maxContourGroup=sizeContourGroup;
2516 } else { // contour AND OR XOR
2523 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
2524 lstManConModTmp.clear();
2528 if (typeContourGroup==3) // contour separete
2530 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
2531 } else { // contour AND OR XOR
2532 lstManConModTmp = lstManConModExp;
2535 _contourextractdata->SetLstManualContourModel( lstManConModTmp );
2536 _contourextractdata->SetScalarRange(grayRangeMin,grayRangeMax);
2539 pLstValuePosX.clear();
2540 pLstValuePosY.clear();
2541 pLstValuePosZ.clear();
2545 _contourextractdata->GetValuesInsideCrown( &numberOfPixels,
2551 resultSize=numberOfPixels;
2552 // Statistics of each slice.
2553 _contourextractdata->Statistics( &pLstValue,
2556 &resultGrayRangeCount,
2561 &resultStandardeviation);
2563 if (interfMainPanel::getInstance()->getNumberColsInformationPanel()<_numberOfVariablesStatistics*(iContourGroup+1) )
2565 interfMainPanel::getInstance()->appendColsInformationPanel(_numberOfVariablesStatistics);
2568 tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
2570 tempString.Printf(_T("%d"),numberOfPixels);
2572 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA, tempString);
2574 tempString.Printf(_T("%d"),resultGrayRangeCount);
2575 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+1, tempString);
2577 tempString.Printf(_T("%f"),resultMin);
2578 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+2, tempString);
2580 tempString.Printf(_T("%f"),resultMax);
2581 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+3, tempString);
2583 tempString.Printf(_T("%f"),resultAverage);
2584 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+4, tempString);
2586 tempString.Printf(_T("%f"),resultStandardeviation);
2587 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+5, tempString);
2590 } // for iContourGroup
2593 // Print Volume Statistics
2596 int vol_rCountRange;
2598 double vol_minValue;
2599 double vol_maxValue;
2601 double vol_standardeviation;
2603 if (selection!=0 ) // actual slice
2606 _contourextractdata->GetVolumeStatistics(&vol_rCountRange, &vol_rsize,
2607 &vol_minValue, &vol_maxValue,
2608 &vol_average, &vol_standardeviation);
2610 interfMainPanel::getInstance()->setRowLabelInfoPanel(maxZ+2, _T("Total:"));
2612 tempString.Printf(_T("%d"),vol_rsize);
2613 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 0, tempString);
2615 tempString.Printf(_T("%d"),vol_rCountRange);
2616 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 1, tempString);
2618 tempString.Printf(_T("%f"),vol_minValue);
2619 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 2, tempString);
2621 tempString.Printf(_T("%f"),vol_maxValue);
2622 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 3, tempString);
2624 tempString.Printf(_T("%f"),vol_average);
2625 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 4, tempString);
2627 tempString.Printf(_T("%f"),vol_standardeviation);
2628 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 5, tempString);
2630 //-----------------------------------------
2633 wxString tmpTitleString;
2635 for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
2637 tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
2638 tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
2639 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString);
2641 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString );
2642 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 1, _T("Size Range") );
2643 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 2, _T("Min") );
2644 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 3, _T("Max") );
2645 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 4, _T("Average") );
2646 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 5, _T("St.Dev.") );
2647 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 6, _T(" ") );
2649 interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
2653 void wxContourMainFrame::onSaveResults(std::string directory,std::string namefile, std::string filename,
2654 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics)
2658 SaveValuesXYZ( directory , namefile, typeContourGroup );
2663 vtkImageData * mask;
2664 vtkImageData * value;
2665 this->getMaskValue(&mask, &value, typeContourGroup,selection,minZ,maxZ);
2666 this->SaveImageResult( directory , namefile, mask, value);
2671 std::ostringstream name;
2672 name << filename << ".xls";
2675 FILE *pFile=fopen(name.str().c_str(),"w+");
2681 // int sizeZ = _theViewPanel->GetImageDataSizeZ();
2682 // int maxY=sizeZ+2;
2684 maxX= interfMainPanel::getInstance()->getNumberColsInformationPanel();//this->_grid->GetNumberCols();
2687 int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
2688 for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
2690 // fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.c_str() );
2691 fprintf(pFile,"slice\t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle );
2693 fprintf(pFile,"\n\n" );
2697 if (selection==0 ) // actual slice
2699 std::vector<int> tempVector;
2700 _instantPanel->getInstant( tempVector );
2701 int actualSlice = tempVector[1];
2707 for ( j=minZ; j<=maxZ ; j++)
2709 fprintf(pFile,"%d\t" , j );
2710 for (i=0 ; i<maxX ; i++){
2711 tmpString = interfMainPanel::getInstance()->getCellValue(j, i);//_grid->GetCellValue( j , i );
2712 fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
2714 fprintf(pFile,"\n" );
2718 // Total of stadistics.....
2721 fprintf(pFile,"\n Total:\t" );
2722 for (i=0 ; i<maxX ; i++){
2723 tmpString = interfMainPanel::getInstance()->getCellValue(maxZ+2, i);//_grid->GetCellValue( maxZ+2 , i );
2724 fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
2726 fprintf(pFile,"\n" );
2734 void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup)
2738 //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
2739 _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
2741 std::vector<manualBaseModel*> lstManConMod;
2742 std::vector<manualBaseModel*> lstManConModTmp;
2743 std::vector<manualBaseModel*> lstManConModExp;
2744 std::vector<double> pLstValue;
2745 std::vector<double> pLstValuePosX;
2746 std::vector<double> pLstValuePosY;
2747 std::vector<double> pLstValuePosZ;
2749 std::vector<int> tempVector;
2750 _instantPanel->getInstant( tempVector );
2752 int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
2754 int ii,sizeLstContourThings;
2761 minZ = 0;// _mbarrange->GetStart();
2762 maxZ = sizeZ;//_mbarrange->GetEnd();
2763 totalZ = maxZ-minZ+1;
2767 for ( z=0 ; z<sizeZ ; z++)
2770 porcent = 100.0* (z-minZ)/totalZ;
2772 tmpString.Printf(_T("Saving Values"));
2773 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
2774 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
2775 //_staticTextInformation->SetLabel(tmpString);
2778 //Extraction data from contours of each slice
2779 _contourextractdata->SetZtoBeAnalys( z);
2782 Instant instant(&tempVector);
2783 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant(&instant);//this->_modelManager->getOutlinesAtInstant( &instant );
2784 sizeLstContourThings = lstContourThings.size();
2786 lstManConMod.clear();
2787 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2789 ContourThing **contourthing = lstContourThings[ii];
2790 lstManConMod.push_back( (*contourthing)->getModel() );
2792 lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
2797 int iContourGroup,sizeContourGroup;
2798 if (typeContourGroup==3) // contour separete
2800 sizeContourGroup=lstManConModExp.size();
2801 } else { // contour AND OR XOR
2805 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
2806 lstManConModTmp.clear();
2807 if (typeContourGroup==3) // contour separete
2809 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
2810 } else { // contour AND OR XOR
2811 lstManConModTmp = lstManConModExp;
2814 _contourextractdata->SetLstManualContourModel( lstManConModTmp );
2817 pLstValuePosX.clear();
2818 pLstValuePosY.clear();
2819 pLstValuePosZ.clear();
2821 _contourextractdata->GetValuesInsideCrown( &numberOfPixels,
2827 std::string temp = directory + "/" + namefile + "-slice";
2828 temp = temp + kernelManager->intToString(z) + "-cont" + kernelManager->intToString(iContourGroup);
2829 temp = temp + ".txt";
2831 // LG 14/01/09 : using crea
2832 wxString filename = crea::std2wx(temp);
2833 /*filename.Printf(_T("%s"),directory.c_str());
2834 filename.append(_T("\\"));
2835 filename.append(_T("%s"),namefile.c_str());
2836 filename.append(_T("-slice"));
2837 filename.append(_T("%d"),z);
2838 filename.append(_T("-cont"));
2839 filename.append(_T("%d"),iContourGroup);
2840 filename.append(_T(".txt"));*/
2841 // filename.Printf(temp.c_str());
2845 FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
2846 fprintf(pFile,"value \t x \t y \t z\n" );
2847 int iLstValue,sizeLstValue=pLstValue.size();
2848 for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
2850 fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
2853 } // for iContourGroup
2855 interfMainPanel::getInstance()->setStringInfoPanel(_T(""));
2856 //_staticTextInformation->SetLabel( _T("") );
2860 void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ){
2863 //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
2864 if (typeContourGroup==3)
2868 _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
2870 std::vector<manualBaseModel*> lstManConMod;
2871 std::vector<manualBaseModel*> lstManConModTmp;
2872 std::vector<manualBaseModel*> lstManConModExp;
2874 std::vector<int> tempVector;
2875 _instantPanel->getInstant( tempVector );
2877 vtkImageData *imagedata = _theViewPanel->getImageData();
2879 imagedata->GetExtent(ext);
2880 int sizeZimage = ext[5]-ext[4]+1;
2882 int ii,sizeLstContourThings;
2890 if (selection==0 ) // actual slice
2892 int actualSlice = tempVector[1];
2900 // cleanning image before range
2901 for (z=0; z<minZ; z++){
2902 _contourextractdata->ResetImageResult(z);
2904 // cleanning image after range
2905 for (z=maxZ+1; z<sizeZimage; z++){
2906 _contourextractdata->ResetImageResult(z);
2911 for ( z=minZ ; z<=maxZ ; z++)
2914 porcent = 100.0* (z-minZ)/totalZ;
2915 tmpString.Printf(_T("Saving Values"));
2916 tmpString.Printf(_T("%d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
2917 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
2919 //Extraction data from contours of each slice
2920 _contourextractdata->SetZtoBeAnalys( z);
2923 Instant instant(&tempVector);
2924 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
2925 sizeLstContourThings = lstContourThings.size();
2927 lstManConMod.clear();
2928 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2930 ContourThing **contourthing = lstContourThings[ii];
2931 lstManConMod.push_back( (*contourthing)->getModel() );
2933 lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
2936 int iContourGroup,sizeContourGroup;
2937 if (typeContourGroup==3) // contour separete
2939 sizeContourGroup=lstManConModExp.size();
2940 } else { // contour AND OR XOR
2944 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
2945 lstManConModTmp.clear();
2946 if (typeContourGroup==3) // contour separete
2948 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
2949 } else { // contour AND OR XOR
2950 lstManConModTmp = lstManConModExp;
2953 _contourextractdata->SetLstManualContourModel( lstManConModTmp );
2954 _contourextractdata->CalculateImageResult(); // with actual Z
2956 } // for iContourGroup
2959 (*value) = _contourextractdata->GetVtkImageValueResult();
2960 (*mask) = _contourextractdata->GetVtkImageMaskResult();
2964 std::string wxContourMainFrame::GetStringTypeImage( vtkImageData* image)
2966 std::string result="";
2967 if ( image->GetScalarType()==VTK_CHAR )
2970 } else if ( image->GetScalarType()==VTK_UNSIGNED_CHAR ){
2972 } else if ( image->GetScalarType()==VTK_FLOAT ){
2974 } else if ( image->GetScalarType()==VTK_DOUBLE ){
2976 } else if ( image->GetScalarType()==VTK_INT ){
2978 } else if ( image->GetScalarType()==VTK_UNSIGNED_INT ){
2980 } else if ( image->GetScalarType()==VTK_SHORT ){
2982 } else if ( image->GetScalarType()==VTK_UNSIGNED_SHORT ){
2984 } else if ( image->GetScalarType()==VTK_LONG ){
2986 } else if ( image->GetScalarType()==VTK_UNSIGNED_LONG ){
2992 void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value)
2994 std::string stringType;
2996 kernelManager->GetSpacing(spc,0); // returns the spacing of the first image
2997 stringType = GetStringTypeImage(value);
2998 std::string temp = directory + "/" + namefile + "-image-Value-"+stringType+".mhd";
3000 wxString filename = crea::std2wx(temp);
3004 vtkImageChangeInformation *valueChInfo = vtkImageChangeInformation::New();
3005 //EED 2017-01-01 Migration VTK7
3006 #if VTK_MAJOR_VERSION <= 5
3007 valueChInfo->SetInput(value);
3009 valueChInfo->SetInputData(value);
3011 valueChInfo->SetSpacingScale(spc);
3012 valueChInfo->Update();
3013 vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
3015 //EED 2017-01-01 Migration VTK7
3016 #if VTK_MAJOR_VERSION <= 5
3017 writerValueImage->SetInput( valueChInfo->GetOutput() );
3019 writerValueImage->SetInputData( valueChInfo->GetOutput() );
3021 writerValueImage->SetFileName( (const char *)filename.mb_str() );
3022 writerValueImage->SetFileDimensionality( 3 );
3023 writerValueImage->SetCompression(false);
3024 writerValueImage->Write( );
3027 stringType = GetStringTypeImage(mask);
3028 temp = directory + "/" + namefile + "-image-Mask-"+stringType+".mhd";
3030 // LG 14/01/09 : using crea
3031 filename = crea::std2wx(temp);
3032 // filename.Printf(_T(temp.c_str()));
3035 vtkImageChangeInformation *maskChInfo = vtkImageChangeInformation::New();
3036 //EED 2017-01-01 Migration VTK7
3037 #if VTK_MAJOR_VERSION <= 5
3038 maskChInfo->SetInput(mask);
3040 maskChInfo->SetInputData(mask);
3042 maskChInfo->SetSpacingScale(spc);
3043 maskChInfo->Update();
3044 vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
3046 //EED 2017-01-01 Migration VTK7
3047 #if VTK_MAJOR_VERSION <= 5
3048 writerMaskImage->SetInput( maskChInfo->GetOutput() );
3050 writerMaskImage->SetInputData( maskChInfo->GetOutput() );
3053 writerMaskImage->SetFileName( (const char *)filename.mb_str() );
3054 writerMaskImage->SetFileDimensionality( 3 );
3055 writerMaskImage->SetCompression(false);
3056 writerMaskImage->Write( );
3058 interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
3064 void wxContourMainFrame::onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow){
3065 if( name.compare( _theViewPanel->getVerticalConceptName() ) == 0){
3066 _theViewPanel->setActualVertical( value);
3068 else if( name.compare( _theViewPanel->getHorizontalConceptName() ) == 0|| _instantPanel->getIfConceptCheckedAt( name, 0 ) ) {
3069 _theViewPanel->setHorizontalConcept( name, minshow, maxshow, minshow, maxshow, value);
3075 void wxContourMainFrame::onSnakePressed(){
3076 std::vector<double> vecX;
3077 std::vector<double> vecY;
3078 std::vector<double> vecZ;
3079 _theViewPanel->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
3081 if (vecX.size()!=0){
3082 std::vector<int> tempVector;
3083 _instantPanel->getInstant( tempVector );
3084 int i,size=vecZ.size();
3085 int actualSlice = tempVector[1];
3086 for ( i=0 ; i<size ; i++ )
3088 vecZ[i] = actualSlice;
3091 wxDialog* dialog = new wxDialog(this, -1, wxString(_T("Snake")));
3092 wxPanel* panel = new wxPanel(dialog,-1);
3093 // wxStaticText* sttext = new wxStaticText(panel, -1, wxString(_T("Panel para snake")));
3094 new wxStaticText(panel, -1, wxString(_T("Panel para snake")));
3095 dialog->ShowModal();
3100 void wxContourMainFrame::saveFileWithContoursAutomatique()
3102 std::string filename = kernelManager->getCurrentFileName();
3103 if(filename.compare("")!=0){
3104 saveFileWithContours(filename);
3110 void wxContourMainFrame::ShowToolsPanel(bool show)
3112 _pannew->Show(show);
3115 void wxContourMainFrame::SetContourGroup(int contourGroup)
3117 _contourGroup = contourGroup;
3120 wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
3122 if (_viewMaskImagePanel==NULL)
3124 _contourextractdata = new ContourExtractData(true);
3125 _contourextractdata->SetImage( _theViewPanel->getImageData() );
3127 // _theViewPanel->getImageData()->GetScalarRange(range);
3128 //int min = (int)floor (range[0]);
3129 //int max = (int)ceil (range[1]);
3135 _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , -1,-1, 0);
3136 _viewMaskImage = new ThresholdImageView();
3137 _viewMaskImage->SetImage( _contourextractdata->GetVtkImageMaskResult() );
3138 _viewMaskImage->SetminMaxValue( min, max);
3139 _viewMaskImage->SetBaseColor( 0,0,1 );
3142 std::vector<int> colorbarposition;
3143 colorbarposition.push_back( -999 );
3144 colorbarposition.push_back( -999 );
3145 _viewMaskImage->SetColorBarPosition( colorbarposition );
3147 _viewMaskImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() );
3148 _viewMaskImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() );
3150 _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage );
3151 _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
3152 _viewMaskImage->onThresholdChangeOpacity( 25 );
3154 return _viewMaskImagePanel;
3158 wxPanel *wxContourMainFrame::getColorLayerImageViewPanel(wxWindow *parent)
3160 if (_viewColorLayerImagePanel==NULL)
3163 _theViewPanel->getImageData()->GetScalarRange(range);
3164 int min = (int)floor (range[0]);
3165 int max = (int)ceil (range[1]);
3166 _viewColorLayerImagePanel = new ColorLayerImageViewPanel( parent, min, max, 100, 1);
3167 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , _theViewPanel->getWxVtkBaseView() );
3168 // std::vector<double> range = bbGetInputlstRangeForColorBar();
3169 // clivp->GetColorLayerImageViewManager()->SetRangeForColorBar( range );
3170 std::vector<int> colorbarposition;
3171 colorbarposition.push_back( 50 );
3172 colorbarposition.push_back( 105 );
3173 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetColorBarPosition( colorbarposition );
3174 // std::vector<double> base_color;
3175 // _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseColors( base_color );
3176 // std::vector<double> grey_level_boundaries;
3177 // clivp->GetColorLayerImageViewManager()->SetGreyLevelBoundaries( grey_level_boundaries );
3178 std::vector<double> transparence_level_boundaries;
3179 transparence_level_boundaries.push_back(0);
3180 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseTransparence( transparence_level_boundaries );
3181 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetPlainOrGradientColor( false );
3182 // _viewColorLayerImagePanel->SetFittingMode( 3 );
3184 return _viewColorLayerImagePanel;
3187 void wxContourMainFrame::SetColorLayerImage(vtkImageData* img)
3189 if (_viewColorLayerImagePanel!=NULL)
3193 _viewColorLayerImagePanel->SetActive(true);
3194 _viewColorLayerImagePanel->SetImage( img );
3195 // RefreshInterface();
3197 } // _viewColorLayerImagePanel
3200 wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
3202 if (_viewThresholdImagePanel==NULL)
3205 _theViewPanel->getImageData()->GetScalarRange(range);
3206 int min = (int)floor (range[0]);
3207 int max = (int)ceil (range[1]);
3208 int start = (max+min)/2 - (max-min)*0.25;
3209 int end = (max+min)/2 + (max-min)*0.25;
3210 _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max, start, end , 1);
3211 _viewThresholdImage = new ThresholdImageView();
3212 _viewThresholdImage->SetminMaxValue(start,end);
3213 // _viewThresholdImage->SetminMaxValue(range[0],range[1]);
3214 _viewThresholdImage->SetImage( _theViewPanel->getImageData() );
3215 std::vector<int> colorbarposition;
3216 colorbarposition.push_back( 10 );
3217 colorbarposition.push_back( 105 );
3218 _viewThresholdImage->SetColorBarPosition( colorbarposition );
3220 _viewThresholdImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() );
3221 _viewThresholdImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() );
3223 _viewThresholdImage->SetBaseColor( 1,0,0 );
3224 _viewThresholdImagePanel->SetThresholdImageView( _viewThresholdImage );
3225 _viewThresholdImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
3226 _viewThresholdImage->onThresholdChangeOpacity( 25 );
3229 return _viewThresholdImagePanel;
3232 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
3233 int wxContourMainFrame::getType ()
3236 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
3238 if(!currentSelection.empty())
3240 std::string cloneName = currentSelection [0];
3241 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);
3242 tipo = manualModel-> GetTypeModel();
3247 double wxContourMainFrame::getContourSizeInPixels()
3249 double contourSize = 0;
3251 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects(); if(!currentSelection.empty())
3252 if(!currentSelection.empty())
3254 std::string cloneName = currentSelection [0];
3256 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
3259 // contourSize = manualModel->GetPathSize();
3264 contourSize = manualModel->GetPathSize( spc );
3269 manualBaseModel * wxContourMainFrame::getContour ()
3271 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
3273 if(!currentSelection.empty())
3275 std::string cloneName = currentSelection [0];
3276 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
3281 void wxContourMainFrame::onPrintLabel (wxString label, manualBaseModel* manualModel)
3283 std::string labelAscii(label.ToAscii());
3284 int pos = labelAscii.find(" ");
3288 for (j=0 ; pos != string::npos;j++)
3290 labelAscii.replace( pos, 1, "_" );
3291 pos= labelAscii.find(" ");
3294 manualModel -> SetLabel(labelAscii);
3296 void wxContourMainFrame::onInsertCalculation(manualBaseModel* manualModel)
3299 // double sizeInPixel = manualModel ->GetPathSize( );
3304 double sizeInPixel = manualModel ->GetPathSize( spc );
3306 double onePixelRealSize = interfMainPanel::getInstance()->GetPixelValue();;
3307 double realContourSize = sizeInPixel*onePixelRealSize;
3308 manualModel ->SetRealSize(realContourSize);
3311 double wxContourMainFrame::onePixelSize( double value)
3313 return _onePixelSize = value;
3316 std::string wxContourMainFrame::GetFileLocation()
3318 return _fileLocation;
3321 void wxContourMainFrame::SetFileLocation(std::string newFileLocation)
3323 _fileLocation = newFileLocation;
3324 std::cout<<"GETFILELOCATION:"<<_fileLocation<<std::endl;
3327 kernelManager->setCurrentFileName(_fileLocation);
3329 //------------------------------------------------------------------------------------------------------------
3338 void wxContourMainFrame::FlipSelectedContours(int flipDirection)
3341 (std::vector<std::string>)_theViewPanel->getSceneManager()->getSelectedObjects() ,
3347 void wxContourMainFrame::FlipActualSliceContours(int flipDirection)
3350 (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() ,
3355 void wxContourMainFrame::FlipAllContours(int flipDirection)
3358 kernelManager->GetLstNameThings() ,
3363 void wxContourMainFrame::FlipLstOfContours(std::vector<std::string> lstNameThings, int flipDirection)
3366 getImageData()->GetExtent(ext);
3367 int sizeX = ext[1]-ext[0];
3368 int sizeY = ext[3]-ext[2];
3371 int i,sizeLstNameThings;
3372 int ii,sizeLstPoints;
3374 sizeLstNameThings = lstNameThings.size();
3375 for (i=0 ; i<sizeLstNameThings ; i++)
3377 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
3378 if (flipDirection==0)
3380 manualModel->Transform_Ax_Plus_B(-1,sizeX,1,0 );
3382 manualModel->Transform_Ax_Plus_B(1,0,-1,sizeY );
3384 }// for i list of Things
3386 //-- Static Contours
3388 lstNameThings = kernelManager->GetLstNameThingsStatic();
3389 sizeLstNameThings = lstNameThings.size();
3390 for (i=0 ; i<sizeLstNameThings ; i++)
3392 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
3393 if (flipDirection==0)
3395 manualModel->Transform_Ax_Plus_B(-1,sizeX,1,0 );
3397 manualModel->Transform_Ax_Plus_B(1,0,-1,sizeY );
3399 }// for i list of static things
3402 void wxContourMainFrame::FlipContours(int typeContourFlip, int flipDirection)
3406 if (typeContourFlip==0) //
3408 FlipSelectedContours(flipDirection);
3411 if (typeContourFlip==1) //
3413 FlipActualSliceContours(flipDirection);
3416 if (typeContourFlip==2) //
3418 FlipAllContours(flipDirection);
3423 void wxContourMainFrame::SetXY(int x, int y)
3425 _theViewPanel->SetXY(x,y);
3428 wxVtkBaseView* wxContourMainFrame::GetWxVtkBaseView()
3430 if (_theViewPanel!=NULL)
3432 return _theViewPanel->getWxVtkBaseView();;