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->setVectImages(images);
131 _contourextractdata = NULL;
134 void wxContourMainFrame::setVectImages(std::vector<vtkImageData*> imgs)
138 std::string str_home(getenv("USERPROFILE"));
139 #elif defined(__GNUC__)
140 std::string str_home(getenv("HOME"));
142 std::string strCreaContourDataTmp = str_home + "/.creaContourDataTemp/";
143 std::vector<std::string> conceptNameVect;
144 std::vector<int> conceptSizeVect;
145 notebook = this->createNotebook();
146 kernelManager = new KernelManagerContour( imgs , _datadir+"/data/" , strCreaContourDataTmp );
147 _instantPanel = new wxInstantChooserPanel( notebook, "Instant Chooser", true, false, "c" );
148 _theViewPanel = new wxContourViewPanel( kernelManager->getSourceImage(), notebook );
149 //-------------------------------------------------------------
150 kernelManager->getConceptsInformation(conceptNameVect, conceptSizeVect);
151 _instantPanel->addConcepts(conceptNameVect, conceptSizeVect);
152 double val = _theViewPanel->getCurrentDeep();
153 _instantPanel->setConceptValue( "Axe Depth", (int)val );
154 //JCP _instantPanel->setConceptValue("time", num de imagenes);
155 ConceptDataWrap * data = _instantPanel->getConceptDataOf( "Axe Depth" );
156 //*******************changeInstant();
157 _theViewPanel->setVerticalConcept( "Axe Depth", data->getMinValue(), data->getMaxValue(), data->getMinShowedValue(), data->getMaxShowedValue(), data->getActualValue() );
158 this->configurePanels( );
162 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 )
166 instance=new wxContourMainFrame(parent, id, title, pos, size, images, style,datadir);
171 std::vector<vtkImageData*> wxContourMainFrame::getVectImages()
173 return kernelManager->getVectImages();
176 wxContourMainFrame* wxContourMainFrame::getInstance()
181 void wxContourMainFrame::resetInstance()
186 wxContourMainFrame::~wxContourMainFrame()
188 delete _contourextractdata;
191 interfMainPanel::resetInstance();
192 delete kernelManager;
194 //_pannew->Destroy();
200 //El problema al cerrar la aplicacion puede estar asociado
201 //a que wxAUINotebook esta en la aplicacion
202 //principal (wxContourGUIExample)tambien
203 //EED???? delete _theViewPanel;
204 //EED???? delete _instantPanel;
205 //EED???? delete _buttonsBar;
206 //EED???? delete _actualInstant;
207 //EED???? delete _sceneManager;
211 //------------------------------------------------------------------------------------------------------------
212 // Creational and initialization methods using WxAui
213 //------------------------------------------------------------------------------------------------------------
215 wxAuiNotebook * wxContourMainFrame::createNotebook()
217 wxSize client_size = GetClientSize();
218 wxAuiNotebook* noteBook = new wxAuiNotebook(this, -1, wxPoint(client_size.x, client_size.y), wxSize(430,200), m_notebook_style);
219 wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
224 //------------------------------------------------------------------------------------------------------------
225 // Creational and initialization methods
226 //------------------------------------------------------------------------------------------------------------
227 bool wxContourMainFrame::configurePanels( )
229 bool configured = _theViewPanel!=NULL;
231 configured &= _theViewPanel!=NULL;
232 if( _theViewPanel!=NULL )
234 notebook->AddPage( _theViewPanel, wxT(" View ") );
239 notebook->AddPage( _instantPanel, wxT("Instant Page") );
242 m_mgr.AddPane(notebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false));
244 SetMinSize(wxSize(300,300));
250 bool wxContourMainFrame::addNewPanel(wxPanel* panel)
252 bool configured = panel!=NULL;
253 configured &= panel!=NULL;
257 notebook->AddPage( panel, wxT(" Viewer "), true );
263 //------------------------------------------------------------------------------------------------------------
264 // Attributes getters and setters
265 //------------------------------------------------------------------------------------------------------------
269 void wxContourMainFrame :: setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel )
271 _instantPanel = theInstantChooserPanel;
274 // void wxContourMainFrame :: setButtonsBar( wxContour_ButtonsBar * theButtonsBar )
276 // _buttonsBar = theButtonsBar;
279 // void wxContourMainFrame :: setGrid( wxContour_Grid * theGridPanel )
281 // _gridPanel = theGridPanel;
284 // void wxContourMainFrame :: setDrawToolsPanel( wxContour_DrawToolsPanel * theDrawToolsPanel )
286 // _drawToolsPanel = theDrawToolsPanel;
289 // void wxContourMainFrame :: setOperationsToolsPanel( wxContour_OperationsToolsPanel * theOperationsToolsPanel )
291 // _operationsToolsPanel = theOperationsToolsPanel;
294 // void wxContourMainFrame :: setAutomaticFormsPanel( wxContour_AutomaticFormsToolsPanel * theAutoFormsPanel )
296 // _autoFormsPanel = theAutoFormsPanel;
299 // void wxContourMainFrame :: setStandardToolsPanel( wxContour_StandardToolsPanel * theStandardToolsPanel )
301 // _standardToolsPanel= theStandardToolsPanel;
304 // void wxContourMainFrame :: setEditionToolsPanel( wxContour_EdtionToolsPanel * theEditionToolsPanel )
306 // _editionToolsPanel = theEditionToolsPanel;
309 // void wxContourMainFrame :: setListViewPanel( wxContour_ListViewPanel * theListViewPanel )
311 // _listViewPanel = theListViewPanel;
316 void wxContourMainFrame::onCreateContourSpline( ){
318 //JCP 20-10-08 Undo redo implementation
320 //JCP 20-10-08 Undo redo implementation
325 void wxContourMainFrame::onCreateContourRectangle( )
327 //JCP 20-10-08 Undo redo implementation
329 //JCP 20-10-08 Undo redo implementation
333 void wxContourMainFrame::onCreateContourCircle( )
335 //JCP 20-10-08 Undo redo implementation
337 //JCP 20-10-08 Undo redo implementation
341 void wxContourMainFrame::onCreateContourLine( )
343 //JCP 20-10-08 Undo redo implementation
345 //JCP 20-10-08 Undo redo implementation
349 // RaC 09-09 --------------------------------------
350 void wxContourMainFrame::onCreateContourPoints( )
352 //JCP 20-10-08 Undo redo implementation
354 //JCP 20-10-08 Undo redo implementation
357 // RaC 09-09 --------------------------------------
359 // RaC 10-09 --------------------------------------
360 void wxContourMainFrame::onCreateContourPolygon( )
362 //JCP 20-10-08 Undo redo implementation
364 //JCP 20-10-08 Undo redo implementation
367 // RaC 10-09 --------------------------------------
369 //------------------------------------------------------------------------------------------------------------
371 void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel )
373 //Creating the manualBaseModel and including in the model
374 manualBaseModel * manModelContour = factoryManualContourModel(panel );
376 std::vector<int> instantVector;
377 _instantPanel->getInstant( instantVector );
378 std::string theName = kernelManager->createOutline(manModelContour, instantVector);
380 /*std::vector<int> instantVector;
381 _instantPanel->getInstant( instantVector );
383 theName= _modelManager->createOutline( manModelContour, instantVector );*/
384 bool addedModel = theName.compare("") != 0;//??
388 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
389 _theViewPanel->getSpacing(spc);
390 //Adding the manualContourControler to interface objects structure
391 //Adding the manualViewContour to interface objects structure
392 //_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.
393 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , 4) ;
397 void wxContourMainFrame::createContour( int typeContour )
399 //Creating the manualContourModel and including in the model
400 manualBaseModel * manModelContour = kernelManager->factoryManualContourModel(typeContour);
401 std::vector<int> instantVector;
402 _instantPanel->getInstant( instantVector );
404 std::vector<int> tempVector;
405 getInstantVector( tempVector );
406 manModelContour->SetLabel2( std::to_string(tempVector[1]) );
408 std::string theName = kernelManager->createOutline(manModelContour, instantVector);
409 /*std::vector<int> instantVector;
410 _instantPanel->getInstant( instantVector );
412 theName= _modelManager->createOutline( manModelContour, instantVector );*/
413 bool addedModel = theName.compare("") != 0;//??
416 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
417 _theViewPanel->getSpacing(spc);
418 //Adding the manualContourControler to interface objects structure
419 //Adding the manualViewContour to interface objects structure
420 //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active.
421 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ;
425 manualBaseModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){
427 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
428 manualBaseModel *manModelContour=NULL;
429 manModelContour = manModelContourBullEye;
431 int iCrown,sizeCrowns,iSector,sizeSectors;
432 double radioA,radioB,ang,angDelta ;
433 sizeCrowns = ((PanelBullEyeOptions*)panel)->GetNumberOfCrowns();
434 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
436 sizeSectors = ((PanelBullEyeOptions*)panel)->GetNumberOfSections(iCrown);
437 radioB = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown);
438 if (iCrown==sizeCrowns-1)
442 radioA = ((PanelBullEyeOptions*)panel)->GetRadioOfCrown(iCrown+1);
446 for ( iSector=0 ; iSector<sizeSectors ; iSector++ )
448 ang = ((PanelBullEyeOptions*)panel)->GetAngOfCrownSection(iCrown,iSector);
449 angDelta= ((PanelBullEyeOptions*)panel)->GetAngDeltaOfCrownSection(iCrown);
450 manModelContourBullEye->AddSector(radioA,radioB,ang,angDelta);
453 } // if _panelBullEyeOptions
455 return manModelContour;
458 void wxContourMainFrame :: saveState()
460 std::string temp = kernelManager->saveState();
461 saveFileWithContours(temp);
464 void wxContourMainFrame::onDeleteContour()
466 //JCP 20-10-08 Undo redo implementation
468 //JCP 20-10-08 Undo redo implementation
470 std::vector<std::string> lstKeyNameToBeErase;
471 lstKeyNameToBeErase = _theViewPanel->getSceneManager()->getSelectedObjects();
472 deleteContours( lstKeyNameToBeErase );
474 int i,size=_sceneManager->getSelectedObjects().size();
477 std::string keyName = _sceneManager->getSelectedObjects()[i];
478 int ispartofstaticlist = this->_modelManager->IsPartOfStaticList( keyName );
479 if ( ispartofstaticlist>=0 )
481 std::vector<int> tempVector;
482 _instantPanel->getInstant( tempVector );
483 Instant instant(&tempVector);
484 this->_modelManager->ChangeContourOfList(keyName, &instant);
488 std::vector<std::string> lstKeyName;
489 std::vector<std::string> lstKeyNameActualSlice;
490 std::vector<std::string> lstKeyNameToBeErase;
492 lstKeyNameToBeErase = _sceneManager->getSelectedObjects();
493 lstKeyNameActualSlice = _sceneManager->GetlstContoursNameActualSlice();
494 int k,kSize=lstKeyNameToBeErase.size();
495 int j,jSize=lstKeyNameActualSlice.size();
497 for (k=0;k<kSize; k++)
500 for (j=0;j<jSize; j++)
502 if (lstKeyNameToBeErase[k]==lstKeyNameActualSlice[j])
509 lstKeyName.push_back( lstKeyNameToBeErase[k] );
513 deleteContours( lstKeyName );
517 void wxContourMainFrame :: deleteContours( std::vector<std::string> keyNamesVector )
519 int i,size=keyNamesVector.size();
522 deleteContour( keyNamesVector[i] );
526 void wxContourMainFrame :: deleteContour( std::string theKeyName )
529 manualContourModel * cModel;
530 manualViewBaseContour * cViewer;
531 manualContourBaseControler * cControler;
533 ContourWrap_ViewControl *conwrapviewControl = _theViewPanel->getSceneManager()->getContourWrap_ViewControlOf( theKeyName );
534 cControler = conwrapviewControl->getControler();*/
537 bool isedit = _theViewPanel->isEditableCControler(theKeyName);
538 bool ispartofstaticlst = kernelManager->IsPartOfStaticList(theKeyName);
540 if (isedit && ispartofstaticlst)
542 _theViewPanel->removeFromScene(theKeyName);
544 kernelManager->deleteCModel(theKeyName);
545 //_theViewPanel->getSceneManager()->removeFromScene( theKeyName );
546 //cViewer = conwrapviewControl->getViewer();
547 //_theViewPanel->getSceneManager()->removeWrap( theKeyName );
548 //cControler* conwrapviewControl->getControler();
551 // delete cControler;
556 void wxContourMainFrame::onDeleteContoursActSlice()
558 //JCP 20-10-08 Undo redo implementation
560 //JCP 20-10-08 Undo redo implementation
562 std::vector<int> tempVector;
563 getInstantVector( tempVector );
564 deleteContours( getOutlinesName( tempVector[1] ) );
565 // deleteContours( (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() );
568 void wxContourMainFrame::onDeleteAllContours(){
569 //JCP 20-10-08 Undo redo implementation
573 void wxContourMainFrame::deleteAllContours(){
574 //JCP 20-10-08 Undo redo implementation
577 std::vector<int> tempVector;
578 _instantPanel->getInstant( tempVector );
580 //JCP --08-09-2008 When using a diferent interface the _mbarrangeDeleteAll might not be initialize
581 // the values in GetStart and GetEnd will then not be initialize also.
582 // We use instead the values given when initializing the _deletepanel.
584 //int minZ = _mbarrangeDeleteAll->GetStart();
585 //int maxZ = _mbarrangeDeleteAll->GetEnd();
589 maxZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
593 _theViewPanel->getSceneManager()->removeSceneContours( );
594 _theViewPanel->getSceneManager()->removeAllOutlines();
595 kernelManager->removeAllOutlines();
598 if ( (minZ==0) && (maxZ==_mbarrangeDeleteAll->GetMax() ))
600 _theViewPanel->getSceneManager()->removeSceneContours( );
601 _modelManager->removeAllOutlines();
602 _theViewPanel->getSceneManager()->removeAllOutlines();
605 for ( z=minZ ; z<=maxZ ; z++)
608 Instant instant(&tempVector);
609 std::vector<ContourThing**> lstContourThings = this->_modelManager->getOutlinesAtInstant( &instant );
611 sizeLstContourThings = lstContourThings.size();
612 for (ii=0 ; ii<sizeLstContourThings ; ii++)
614 ContourThing **contourthing = lstContourThings[ii];
615 deleteContour( (*contourthing)->getName() );
622 void wxContourMainFrame::setConceptValue( std::string name, int value )
624 _instantPanel->setConceptValue(name, value);
628 ConceptDataWrap* wxContourMainFrame::getLastConceptData()
630 return _instantPanel->getLastConceptData();
634 bool wxContourMainFrame::getIfConceptCheckedAt( std::string name, int pos )
636 return _instantPanel->getIfConceptCheckedAt( name, pos );
641 void wxContourMainFrame::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ)
644 vtkImageData * value;
645 this->getMaskValue(&mask, &value, typeContourGroup, selection, minZ, maxZ);
647 std::vector<int> nTypeView;
648 nTypeView.push_back(5);
649 nTypeView.push_back(1);
650 nTypeView.push_back(2);
651 nTypeView.push_back(0);
653 if (_frameShowResultImages==NULL)
655 // wxFrame *_frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600), wxDEFAULT_FRAME_STYLE|wxSTAY_ON_TOP);
656 _frameShowResultImages = new wxFrame(this, -1,_T("Result image extracted.."),wxDefaultPosition,wxSize(600,600),
657 wxFRAME_TOOL_WINDOW|wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN |wxFRAME_FLOAT_ON_PARENT | wxRESIZE_BORDER );
659 wxAuiManager *m_mgr_noteBookViewerResult = new wxAuiManager();
660 m_mgr_noteBookViewerResult->SetManagedWindow(_frameShowResultImages);
662 wxAuiNotebook* noteBookViewerResult = new wxAuiNotebook(_frameShowResultImages, -1, wxPoint(600, 600), wxSize(430,200), m_notebook_style);
663 m_mgr_noteBookViewerResult->AddPane(noteBookViewerResult, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false));
665 wxPanel *panelViewer1 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView);
666 wxPanel *panelViewer2 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView);
669 noteBookViewerResult->AddPage( panelViewer1, wxT("Image result") );
670 noteBookViewerResult->AddPage( panelViewer2, wxT("Mask result") );
671 m_mgr_noteBookViewerResult->Update();
672 _frameShowResultImages->Show();
673 } // if _frameShowResultImages
679 void wxContourMainFrame::changeInstant()
681 std::vector<int> instantVect;
682 _instantPanel->getInstant( instantVect );
683 int actualSlice = instantVect[1];
684 kernelManager->setInstant(instantVect);
685 // Refresh Mask image
686 if(_viewMaskImage!=NULL)
688 _viewMaskImage->SetZ(actualSlice);
689 if (_viewMaskImagePanel->IsVisible()==true)
691 vtkImageData *mask, *value;
692 getMaskValue(&mask,&value, _contourGroup , 0, -1, -1);
693 _viewMaskImage->onThreshold();
695 } // if _viewMaskImage
696 // Refresh Threshold image
697 if(_viewThresholdImage!=NULL)
699 _viewThresholdImage->SetZ(actualSlice);
700 if (_viewThresholdImagePanel->IsVisible()==true)
702 _viewThresholdImage->onThreshold();
704 } // if _viewThresholdImage
705 updateInstantOutlines();
706 updateInstantImageData();
712 void wxContourMainFrame::updateInstantOutlines()
714 _theViewPanel->removeSceneContours();
715 _theViewPanel->addNameWrapperToScene();
717 //for( int i=0; i<size; i++)
719 // _theViewPanel->getSceneManager()->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false );
723 int wxContourMainFrame::getNamesWrappingSize()
725 return kernelManager->getNamesWrappingSize();
728 std::string wxContourMainFrame::getNameWrapping(int i)
730 return kernelManager->getNameWrapping(i);
733 void wxContourMainFrame::updateInstantImageData()
735 std::vector<int> inst;
736 _instantPanel->getInstant(inst);
738 vtkImageData* img = kernelManager->getImageAtInstant(inst);
741 _theViewPanel->changeImage(img);
744 int z = _instantPanel->getConceptDataOf("Axe Depth")->getActualValue();
745 _theViewPanel->setImageSlice(z);
749 void wxContourMainFrame::updateInstantAxes()
754 void wxContourMainFrame::onChangeDeep(int val){
755 _instantPanel->setConceptValue( "Axe Depth", (int)val );
760 void wxContourMainFrame::onCopy(){
761 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
762 std::vector<int> tempVector;
763 _instantPanel->getInstant( tempVector );
764 _performingOperation->reset();
765 _performingOperation->setStartCommand( COPY );
766 _performingOperation->setStartOperationInstantVector( tempVector );
767 _performingOperation->setKeyNamesOperationElems( currentSelection );
770 void wxContourMainFrame::onPaste()
772 char theStartCommand = _performingOperation->getStartCommand();
773 if ( theStartCommand == COPY )
775 //JCP 20-10-08 Undo redo implementation
777 //JCP 20-10-08 Undo redo implementation
778 std::vector<int> tempVector;
779 _instantPanel->getInstant( tempVector );
780 _performingOperation->setEndOperationInstantVector ( tempVector );
781 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
782 int i,size = elems.size();
783 for( i=0; i<size; i++ )
785 createCopyContourOf( elems[i], tempVector, i>0 );
790 void wxContourMainFrame::onUndo()
792 std::string filename;
793 if(kernelManager->onUndoSaveFile(filename)){
794 saveFileWithContours(filename);
796 if(kernelManager->onUndo(filename)){
800 void wxContourMainFrame::onRedo(){
801 std::string filename;
802 if(kernelManager->onRedo(filename)){
807 void wxContourMainFrame :: createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append )
809 std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
810 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
811 _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
814 ///AD: 03-09 Copy the object and apply the given transformation
815 void wxContourMainFrame :: createMirrorContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData, bool append )
817 std::string cloneName = kernelManager->createCopyContourOf( anExistingKName, instantNoTouchData );
818 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);
820 manualPoint * refPoint1 = _refLineModel->GetManualPoint(0);
821 manualPoint * refPoint2 = _refLineModel->GetManualPoint(1);
823 double pnt1X = refPoint1->GetX();
824 double pnt1Y = refPoint1->GetY();
825 // double pnt1Z = refPoint1->GetZ();
826 double pnt2X = refPoint2->GetX();
827 double pnt2Y = refPoint2->GetY();
828 // double pnt2Z = refPoint2->GetZ();
830 double angle = (atan2(pnt2Y - pnt1Y, pnt2X - pnt1X) * 180 / 3.1415926535897932384626433832795)+90;
831 vtkTransform *t = vtkTransform::New();
835 t->Translate(-pnt1X, -pnt1Y, 0);
839 t->Translate(pnt1X, pnt1Y, 0);
842 int i,size=manualModel->GetSizeLstPoints();
845 manualPoint * mp = manualModel->GetManualPoint(i);
851 t->TransformPoint( vecIn, vecOut );
852 mp->SetPointX( vecOut[0] );
853 mp->SetPointY( vecOut[1] );
854 mp->SetPointZ( vecOut[2] );
857 _theViewPanel->getSceneManager()->createCopyContourOf( anExistingKName, cloneName, manualModel , append );
860 void wxContourMainFrame ::loadState(std::string filename)
863 onLoadContours(filename,false);
866 void wxContourMainFrame::onLoad()
868 std::string fileNameContourROI = GetFileLocation();
869 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
870 if(GetFileLocation().empty())
872 //------------------------------------------------------------------------------------------------------------
873 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
874 #if wxMAJOR_VERSION <= 2
875 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxOPEN );
877 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxFD_OPEN );
879 if (dialog.ShowModal() == wxID_OK)
881 fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
884 onLoadContours(fileNameContourROI,true);
887 void wxContourMainFrame::SetZForAllContours(int pz)
890 std::vector< std::string > lstNameThings;
891 int i,sizeLstNameThings;
892 int ii,sizeLstPoints;
893 lstNameThings = kernelManager->GetLstNameThings();
894 sizeLstNameThings = lstNameThings.size();
895 for (i=0 ; i<sizeLstNameThings ; i++)
897 printf("EED wxContourMainFrame::SetZForAllContours contour=%d \n", i );
898 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
899 sizeLstPoints = manualModel->GetSizeLstPoints();
900 for (ii=0 ; ii<sizeLstPoints ; ii++)
902 manualModel->GetManualPoint(ii)->SetPointZ(-900);
903 }// for ii list of points
904 }// for i list of Things
908 lstNameThings = kernelManager->GetLstNameThingsStatic();
909 sizeLstNameThings = lstNameThings.size();
910 for (i=0 ; i<sizeLstNameThings ; i++)
912 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
913 sizeLstPoints = manualModel->GetSizeLstPoints();
914 for (ii=0 ; ii<sizeLstPoints ; ii++)
916 manualModel->GetManualPoint(ii)->SetPointZ(-900);
917 }// for ii list of points
918 }// for i list of static things
921 void wxContourMainFrame::onLoadContours(std::string fileNameContourROI, bool interactiveInterface)
925 FILE *pFile =fopen(fileNameContourROI.c_str(),"r+");
926 //CMRU 03-09-09- ----------------------------------------------------------------------------------------------
929 //------------------------------------------------------------------------------------------------------------
930 fileNameContourROI.append("data");
931 FILE *pFileData=fopen(fileNameContourROI.c_str(),"r+");
932 if(pFileData != NULL)
934 fscanf(pFileData,"%s",tmpD); // --CreaContour--
935 fscanf(pFileData,"%s",tmpD); // Version
936 fscanf(pFileData,"%s",tmpD); // 1.0.3 || 1.0.2 || 1.0.1 || 1.0.0
938 fscanf(pFileData,"%s",tmpD); // onePixelSize
939 fscanf(pFileData,"%s",tmpD); // #
940 _onePixelSize = atof(tmpD);
941 fscanf(pFileData,"%s",tmpD); // NumberOfContours
942 fscanf(pFileData,"%s",tmpD); // #
944 fscanf(pFile,"%s",tmp); // --CreaContour--
945 fscanf(pFile,"%s",tmp); // Version
946 fscanf(pFile,"%s",tmp); // 1.0.3 || 1.0.2 || 1.0.1 || 1.0.0
947 std::string version(tmp);
949 _tmpReadFileTypeOfTransformation=-1;
950 if (version=="1.0.3")
952 readDimSpc(pFile,interactiveInterface); // DimSpc interactive ON
953 openContours(pFile,pFileData,false);
954 openContours(pFile,pFileData,true); //Load StaticContours
956 if (version=="1.0.2")
959 readDimSpc(pFile,interactiveInterface); // DimSpc interactive ON
960 openContours(pFile,pFileData,false);
961 readDimSpc(pFile,false); // DimSpc interactive OFF
962 openContours(pFile,pFileData,true); // Load StaticContours
963 SetZForAllContours(-900);
964 } else if (version=="1.0.1") { //AD:02-06-09
965 openContours(pFile,pFileData,false); //Skips ImageDimensions and ImageSpacing
966 openContours(pFile,pFileData,true); //Load StaticContours, skips ImageDimensions and ImageSpacing
967 } else if (version=="1.0.0") { //AD:02-06-09
968 openContours(pFile,pFileData,false); //Skips ImageDimensions and ImageSpacing
971 if(pFileData != NULL)
976 _theViewPanel->getSceneManager()->removeSceneContours();
981 void wxContourMainFrame::onImport()
983 std::string filename, filenamecontours;
984 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
985 #if wxMAJOR_VERSION <= 2
986 wxFileDialog dialog(NULL, _T("Choose a XML Osirix File"), _T(""), _T(""), _T("*.xml"), wxOPEN );
988 wxFileDialog dialog(NULL, _T("Choose a XML Osirix File"), _T(""), _T(""), _T("*.xml"), wxFD_OPEN );
990 if (dialog.ShowModal() == wxID_OK)
992 filename = dialog.GetPath().mb_str();
993 filenamecontours = kernelManager->parseOsirixFile(filename);
995 if(filenamecontours.compare("") != 0)
997 onLoadContours(filenamecontours,true);
1002 void wxContourMainFrame::onTest()
1004 std::string filename, filenamecontours;
1005 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1006 #if wxMAJOR_VERSION <= 2
1007 wxFileDialog dialog(NULL, _T("Choose a File"), _T(""), _T(""), _T("*.*"), wxOPEN );
1009 wxFileDialog dialog(NULL, _T("Choose a File"), _T(""), _T(""), _T("*.*"), wxFD_OPEN );
1011 if (dialog.ShowModal() == wxID_OK)
1013 filename = dialog.GetPath().mb_str();
1014 std::cout << "This is the filename: " << filename << std::endl;
1019 void wxContourMainFrame::onSave()
1021 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1022 if(GetFileLocation().empty())
1024 //------------------------------------------------------------------------------------------------------------
1025 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1026 #if wxMAJOR_VERSION <= 2
1027 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxSAVE );
1029 wxFileDialog dialog(NULL, _T("Choose a file"), _T(""), _T(""), _T("*.roi"), wxFD_SAVE );
1031 if (dialog.ShowModal() == wxID_OK)
1033 std::string fileNameContourROI = (const char *)(dialog.GetPath().mb_str());
1034 kernelManager->setCurrentFileName(fileNameContourROI);
1035 saveFileWithContours( fileNameContourROI );
1037 } else {//CMRU 03-09-09-----------------------------------------------------------------------------------------------
1038 std::cout<<"Nombre del archivo: "<<GetFileLocation()<<std::endl;
1039 std::string fileNameContourROI = GetFileLocation();
1040 std::cout<<"Nombre del archivo: "<<fileNameContourROI<<std::endl;
1041 kernelManager->setCurrentFileName(fileNameContourROI);
1042 saveFileWithContours( fileNameContourROI);
1044 //------------------------------------------------------------------------------------------------------------
1048 void wxContourMainFrame::saveFileWithContours( std::string filename )
1051 FILE *pFile=fopen(filename.c_str(),"w+");
1053 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1054 filename.append("data");
1055 std::cout<<"Nombre del archivo: "<<filename<<std::endl;
1056 FILE *pFileData=fopen(filename.c_str(),"w+");
1057 //------------------------------------------------------------------------------------------------------------
1059 std::vector< std::string > lstNameThings;
1060 int i,sizeLstNameThings;
1062 fprintf(pFile,"--CreaContour--\n");
1063 fprintf(pFile,"Version %s\n", "1.0.3" );
1065 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1066 fprintf(pFileData,"--CreaContour--\n");
1067 fprintf(pFileData,"Version %s\n", "1.0.3" );
1068 fprintf(pFileData,"OnePixelSize %f\n", _onePixelSize);
1070 //------------------------------------------------------------------------------------------------------------
1072 vtkImageData *image = _images[0];
1075 image->GetDimensions(dimRange);
1077 fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
1080 image->GetSpacing(spaRange);
1082 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 );
1090 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1091 fprintf(pFileData,"NumberOfContours %d\n", sizeLstNameThings );
1092 //------------------------------------------------------------------------------------------------------------
1101 for (i=0 ; i<sizeLstNameThings ; i++)
1103 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1104 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
1107 // double sizeInPixel = manualModel ->GetPathSize( );
1108 double sizeInPixel = manualModel ->GetPathSize( spc );
1110 double realContourSize = sizeInPixel*_onePixelSize;
1111 manualModel ->SetRealSize(realContourSize);
1112 //------------------------------------------------------------------------------------------------------------
1114 //int size= kernelManager->GetLstNameThings().size();
1116 kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
1117 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
1120 //-- Static Contours
1122 // fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
1123 // fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
1125 lstNameThings = kernelManager->GetLstNameThingsStatic();
1126 sizeLstNameThings = lstNameThings.size();
1127 fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
1129 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
1130 fprintf(pFileData,"NumberOfContoursStatic %d\n", sizeLstNameThings );
1131 //------------------------------------------------------------------------------------------------------------
1133 for (i=0 ; i<sizeLstNameThings ; i++)
1135 kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
1136 _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
1144 void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption)
1148 double imageSpac[3];
1149 vtkImageData *image = _images[0];
1150 image->GetDimensions(imageDim);
1151 image->GetSpacing(imageSpac);
1153 fscanf(pFile,"%s",tmp); // ImageDimensions
1154 fscanf(pFile,"%s",tmp); // X
1155 _tmpReadFileImageDim[0] = atoi(tmp);
1156 fscanf(pFile,"%s",tmp); // Y
1157 _tmpReadFileImageDim[1] = atoi(tmp);
1158 fscanf(pFile,"%s",tmp); // Z
1159 _tmpReadFileImageDim[2] = atoi(tmp);
1161 fscanf(pFile,"%s",tmp); // ImageSpacing
1162 fscanf(pFile,"%s",tmp); // X
1163 _tmpReadFileImageSpac[0] = atof(tmp);
1164 fscanf(pFile,"%s",tmp); // Y
1165 _tmpReadFileImageSpac[1] = atof(tmp);
1166 fscanf(pFile,"%s",tmp); // Z
1167 _tmpReadFileImageSpac[2] = atof(tmp);
1170 if (interactiveOption==true)
1172 //Compare Spacing and Dims in X and Y (Necessary in Z?) - Just for Version 2
1173 if (imageDim[0]!=_tmpReadFileImageDim[0] || imageDim[1]!=_tmpReadFileImageDim[1] || imageSpac[0]!=_tmpReadFileImageSpac[0] || imageSpac[1]!=_tmpReadFileImageSpac[1])
1175 wxDialog* dial = new wxDialog (this,-1,_T("Tools"),wxDefaultPosition, wxSize(460,360));
1176 wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
1177 // wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL);
1178 wxFlexGridSizer *dialSizer = new wxFlexGridSizer(1);
1180 wxString lstOptOperation[2];
1181 lstOptOperation[0]=_T("By Dimension");
1182 lstOptOperation[1]=_T("By Spacing");
1183 wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,90), 2 , lstOptOperation, 2, wxRA_SPECIFY_COLS);
1185 dialSizer->Add( new wxStaticText(dial,-1,_T("The image resolution is not compatible with the ")) , 0, wxGROW );
1186 dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW );
1187 dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
1188 dialSizer->Add(radioOpts,0,wxGROW);
1189 dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
1190 dialSizer->Add(buttonsSizer,0,wxGROW);
1191 dial->SetSizer(dialSizer, true);
1195 int _tmpReadFileTypeOfTransformation = -1;
1196 //EED bool transform = false;
1198 if (dial->GetReturnCode() == wxID_OK)
1200 _tmpReadFileTypeOfTransformation = radioOpts->GetSelection();
1204 } // if interactiveOption
1211 void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool staticContour )
1216 vtkImageData *image = _images[0];
1219 double imageSpac[3];
1220 image->GetDimensions(imageDim);
1221 image->GetSpacing(imageSpac);
1224 fscanf(pFile,"%s",tmp); // NumberOfContours
1225 fscanf(pFile,"%s",tmp); // ##
1226 int numberOfContours = atoi(tmp);
1228 std::vector<int> instantVector;
1229 int typeContourModel;
1230 manualBaseModel *manModelContour;
1234 if (compatible==true)
1237 for (i=0;i<numberOfContours;i++)
1239 instantVector.clear();
1240 fscanf(pFile,"%s",tmp); // Instant
1242 fscanf(pFile,"%s",tmp); // 1
1243 instantVector.push_back( atoi(tmp) );
1244 fscanf(pFile,"%s",tmp); // 2
1245 instantVector.push_back( atoi(tmp) );
1246 fscanf(pFile,"%s",tmp); // 3
1247 instantVector.push_back( atoi(tmp) );
1248 fscanf(pFile,"%s",tmp); // 4
1249 instantVector.push_back( atoi(tmp) );
1250 fscanf(pFile,"%s",tmp); // 5
1251 instantVector.push_back( atoi(tmp) );
1252 fscanf(pFile,"%s",tmp); // 6
1253 instantVector.push_back( atoi(tmp) );
1256 fscanf(pFile,"%s",tmp); // TypeContourModel
1257 fscanf(pFile,"%s",tmp); // ##
1258 typeContourModel = atoi(tmp);
1260 manModelContour = kernelManager->factoryManualContourModel(typeContourModel);
1261 manModelContour->Open(pFile);
1262 if(pFileData != NULL)
1264 manModelContour->OpenData(pFileData);
1267 fscanf(pFile,"%s",tmp); // TypeView
1268 fscanf(pFile,"%s",tmp); // ##
1269 typeView = atoi(tmp);
1271 std::string theName;
1272 theName = kernelManager->createOutline( manModelContour, instantVector );
1273 bool addedModel = theName.compare("") != 0;
1276 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1277 _theViewPanel->getSpacing(spc);
1278 //Adding the manualContourControler to interface objects structure
1279 //Adding the manualViewContour to interface objects structure
1280 //_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.
1281 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
1284 if (staticContour) //StaticContours (will appear in all slices)
1286 Instant instant(&instantVector);
1287 kernelManager->changeContourOfManager( theName , &instant );
1290 }// for numberOfContours
1293 else if (compatible==false)
1298 for (i=0;i<numberOfContours;i++)
1300 instantVector.clear();
1301 fscanf(pFile,"%s",tmp); // Instant
1303 fscanf(pFile,"%s",tmp); // 1
1304 instantVector.push_back( atoi(tmp) );
1305 fscanf(pFile,"%s",tmp); // 2
1306 instantVector.push_back( atoi(tmp) );
1307 fscanf(pFile,"%s",tmp); // 3
1308 instantVector.push_back( atoi(tmp) );
1309 fscanf(pFile,"%s",tmp); // 4
1310 instantVector.push_back( atoi(tmp) );
1311 fscanf(pFile,"%s",tmp); // 5
1312 instantVector.push_back( atoi(tmp) );
1313 fscanf(pFile,"%s",tmp); // 6
1314 instantVector.push_back( atoi(tmp) );
1316 fscanf(pFile,"%s",tmp); // TypeContourModel
1317 fscanf(pFile,"%s",tmp); // ##
1318 typeContourModel = atoi(tmp);
1320 manModelContour = kernelManager->factoryManualContourModel(typeContourModel);
1321 manModelContour->Open(pFile);
1322 if(pFileData != NULL)
1324 manModelContour->OpenData(pFileData);
1327 if (_tmpReadFileTypeOfTransformation==-1){
1329 } else if (_tmpReadFileTypeOfTransformation==0){
1330 double transX, transY;
1331 transX = (double) imageDim[0]/_tmpReadFileImageDim[0];
1332 transY = (double) imageDim[1]/_tmpReadFileImageDim[1];
1333 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
1334 } else if (_tmpReadFileTypeOfTransformation==1) {
1335 double transX, transY;
1336 transX = (double) _tmpReadFileImageSpac[0]/imageDim[0];
1337 transY = (double) _tmpReadFileImageSpac[1]/imageDim[1];
1338 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
1341 fscanf(pFile,"%s",tmp); // TypeView
1342 fscanf(pFile,"%s",tmp); // ##
1343 typeView = atoi(tmp);
1345 std::string theName;
1346 theName = kernelManager->createOutline( manModelContour, instantVector );
1347 bool addedModel = theName.compare("") != 0;
1350 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1351 _theViewPanel->getSpacing(spc);
1352 //Adding the manualContourControler to interface objects structure
1353 //Adding the manualViewContour to interface objects structure
1354 //_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.
1355 _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
1358 if (staticContour) //StaticContours (will appear in all slices)
1360 Instant instant(&instantVector);
1361 kernelManager->changeContourOfManager( theName , &instant );
1363 }// for numberOfContours
1369 void wxContourMainFrame::RefreshInterface()
1372 _theViewPanel->RefreshInterface();
1373 //wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)this->_theViewPanel->getWxVtkBaseView();
1374 //wxvtk2dbaseview->Refresh();
1377 vtkImageData* wxContourMainFrame::getImageData()
1379 return _theViewPanel->getImageData();
1382 void wxContourMainFrame::onSegmentationOneSliceITK(wxString distance, wxString sigma, wxString alfa, wxString beta, wxString propagation, wxString iterations, wxString inflation)
1384 //JCP 20-10-08 Undo redo implementation
1386 //JCP 20-10-08 Undo redo implementation
1389 int x = _theViewPanel->GetX();
1390 int y = _theViewPanel->GetY();
1391 int z = _theViewPanel->GetZ();
1392 SegmentationOneSliceITK( x,y,z,distance, sigma, alfa, beta, propagation, iterations, inflation);
1396 void wxContourMainFrame::SegmentationOneSliceITK(int x, int y, int z, wxString distanc, wxString sigm, wxString alf, wxString bet, wxString prop, wxString iter, wxString inflation)
1398 int typeofcontour = 1;
1400 vtkImageData *imagedata = getImageData();
1402 //Tipo de pixeles a utilizar internamente en ITK
1403 typedef float InternalPixelType;
1404 const unsigned int Dimension = 2;
1405 typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
1407 //Tipo de pixeles de salida 1
1408 typedef unsigned char OutputPixelType;
1409 typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
1411 //Tipo de pixeles de salida 2
1412 typedef unsigned short OutputPixelType2;
1413 typedef itk::Image< OutputPixelType2, Dimension > OutputImageType2;
1415 //DefiniciÛn del thresholder
1416 typedef itk::BinaryThresholdImageFilter<
1418 OutputImageType > ThresholdingFilterType;
1420 //DefiniciÛn del primer filtro de conversiÛn de pixeles
1421 typedef itk::CastImageFilter<
1422 OutputImageType, OutputImageType2 > CastFilterType;
1424 //DefiniciÛn del segundo tipo de conversiÛn de pixeles
1425 typedef itk::CastImageFilter<
1426 OutputImageType2, InternalImageType > CastFilterType2;
1428 //Tercer tipo de conversiÛn
1429 typedef itk::RescaleIntensityImageFilter<
1431 OutputImageType > CastFilterType3;
1433 //Cuarto tipo de conversiÛn
1434 typedef itk::RescaleIntensityImageFilter<
1436 OutputImageType > CastFilterType4;
1438 ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();
1440 thresholder->SetLowerThreshold( 0.0 );
1441 thresholder->SetUpperThreshold( 128 );
1443 thresholder->SetOutsideValue( 255 );
1444 thresholder->SetInsideValue( 0 );
1446 //DefinciÛn de conexiÛnes entre VTK e ITK y el writer
1447 typedef itk::VTKImageToImageFilter<OutputImageType2> ConnectorType;
1448 typedef itk::ImageToVTKImageFilter<OutputImageType> ConnectorType2;
1449 //EED10JUIN2011 typedef itk::ImageFileWriter< OutputImageType > WriterType;
1451 ConnectorType::Pointer connector= ConnectorType::New();
1452 ConnectorType2::Pointer connector2= ConnectorType2::New();
1455 CastFilterType::Pointer filter=CastFilterType::New();
1456 CastFilterType2::Pointer filter2=CastFilterType2::New();
1458 connector->SetInput( imagedata );
1459 filter2->SetInput(connector->GetOutput());
1461 typedef itk::CurvatureAnisotropicDiffusionImageFilter<
1463 InternalImageType > SmoothingFilterType;
1465 SmoothingFilterType::Pointer smoothing = SmoothingFilterType::New();
1467 typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<
1469 InternalImageType > GradientFilterType;
1471 typedef itk::SigmoidImageFilter<
1473 InternalImageType > SigmoidFilterType;
1475 GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();
1477 SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
1479 sigmoid->SetOutputMinimum( 0.0 );
1480 sigmoid->SetOutputMaximum( 255.0 );
1483 typedef itk::FastMarchingImageFilter<
1485 InternalImageType > FastMarchingFilterType;
1488 FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();
1490 printf("EED wxContourMainFrame::SegmentationOneSliceITK Skypping this code. Not compiling GeodesicActiveContourLevelSetImageFilter in fedora 17 with ITK 3.20.1 \n ");
1492 > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - > - Not compiling GeodesicActiveContourLevelSetImageFilter in fedora 17 with ITK 3.20.1
1495 typedef itk::GeodesicActiveContourLevelSetImageFilter< InternalImageType,
1496 InternalImageType > GeodesicActiveContourFilterType;
1497 GeodesicActiveContourFilterType::Pointer geodesicActiveContour =
1498 GeodesicActiveContourFilterType::New();
1500 typedef itk::ZeroCrossingImageFilter<
1502 InternalImageType > ZeroCrossingFilterType;
1503 ZeroCrossingFilterType::Pointer zeroCrossing =
1504 ZeroCrossingFilterType::New();
1506 const double propagationScaling = atof( crea::wx2std(prop).c_str() );
1508 geodesicActiveContour->SetPropagationScaling( propagationScaling );
1509 geodesicActiveContour->SetCurvatureScaling( 1.0 );
1510 geodesicActiveContour->SetAdvectionScaling( 1.0 );
1512 geodesicActiveContour->SetMaximumRMSError( 0.02 );
1513 int it=atoi( crea::wx2std(iter).c_str() );
1514 geodesicActiveContour->SetNumberOfIterations( it );
1516 smoothing->SetInput( filter2->GetOutput() );
1517 gradientMagnitude->SetInput( smoothing->GetOutput() );
1518 sigmoid->SetInput( gradientMagnitude->GetOutput() );
1519 fastMarching->SetInput( sigmoid->GetOutput() );
1520 geodesicActiveContour->SetInput( fastMarching->GetOutput() );
1521 geodesicActiveContour->SetFeatureImage( sigmoid->GetOutput() );
1523 zeroCrossing->SetInput( geodesicActiveContour->GetOutput() );
1524 //thresholder->SetInput( zeroCrossing->GetOutput() );
1525 thresholder->SetInput( geodesicActiveContour->GetOutput() );
1526 connector2->SetInput( thresholder->GetOutput() );
1528 < - < - < - < - < - < - < - < - < - < - < - < - < - < - < - < - < - < - < - < -
1534 smoothing->SetTimeStep( 0.125 );
1535 smoothing->SetNumberOfIterations( 5 );
1536 smoothing->SetConductanceParameter( 9.0 );
1539 const double sigma = atof( crea::wx2std(sigm).c_str() );
1540 gradientMagnitude->SetSigma( sigma );
1542 const double alpha = atof( crea::wx2std(alf).c_str() );
1543 const double beta = atof( crea::wx2std(bet).c_str() );
1545 sigmoid->SetAlpha( alpha );
1546 sigmoid->SetBeta( beta );
1548 typedef FastMarchingFilterType::NodeContainer NodeContainer;
1549 typedef FastMarchingFilterType::NodeType NodeType;
1551 NodeContainer::Pointer seeds = NodeContainer::New();
1553 InternalImageType::IndexType seedPosition;
1554 seedPosition[0] = x;
1555 seedPosition[1] = y;
1557 const double initialDistance = atof( crea::wx2std(distanc).c_str() );
1561 const double seedValue = - initialDistance;
1563 node.SetValue( seedValue );
1564 node.SetIndex( seedPosition );
1566 seeds->Initialize();
1567 seeds->InsertElement( 0, node );
1569 fastMarching->SetTrialPoints( seeds );
1571 fastMarching->SetSpeedConstant( 1.0 );
1573 fastMarching->SetOutputSize(
1574 connector->GetOutput()->GetBufferedRegion().GetSize() );
1576 fastMarching->SetStoppingValue( 800 );
1580 connector2->Update();
1581 vtkImageData *idata = connector2->GetOutput();
1583 vtkMarchingContourFilter* cntVTK = vtkMarchingContourFilter::New( );
1585 cntVTK->SetNumberOfContours( 1 );
1586 cntVTK->SetValue( 0, 255 );
1587 //EED 2017-01-01 Migration VTK7
1588 #if VTK_MAJOR_VERSION <= 5
1589 cntVTK->SetInput( idata );
1591 cntVTK->UpdateInformation();
1593 cntVTK->SetInputData( idata );
1596 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
1598 //EED 2017-01-01 Migration VTK7
1599 #if VTK_MAJOR_VERSION <= 5
1600 cpd->SetInput( cntVTK->GetOutput( ) );
1602 cpd->UpdateInformation();
1604 cpd->SetInputData( cntVTK->GetOutput( ) );
1608 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
1609 conn->SetExtractionModeToLargestRegion( );
1610 //EED 2017-01-01 Migration VTK7
1611 #if VTK_MAJOR_VERSION <= 5
1612 conn->SetInput( cpd->GetOutput( ) );
1614 conn->UpdateInformation();
1616 conn->SetInputData( cpd->GetOutput( ) );
1620 vtkStripper* vtkstripper = vtkStripper::New( );
1622 //EED 2017-01-01 Migration VTK7
1623 #if VTK_MAJOR_VERSION <= 5
1624 vtkstripper->SetInput( conn->GetOutput() );
1625 vtkstripper->Update();
1626 vtkstripper->UpdateInformation();
1628 vtkstripper->SetInputData( conn->GetOutput() );
1632 vtkPolyData* polyDataResult = cntVTK->GetOutput();
1633 //std::cout<<"Points "<<polyDataResult->GetNumberOfPoints()<<std::endl;
1635 //EED 2017-01-01 Migration VTK7
1636 #if VTK_MAJOR_VERSION <= 5
1637 polyDataResult->Update( );
1638 polyDataResult->UpdateInformation();
1646 myfile.open ("C:/Creatis/example.txt");
1648 polyDataResult->Print(myfile);
1649 myfile << "-------------------------------------\n";
1650 polyDataResult->GetLines()->Print(myfile);
1658 //--Calculating control points
1660 std::vector<double> vecX;
1661 std::vector<double> vecY;
1662 std::vector<double> vecXo;
1663 std::vector<double> vecYo;
1664 std::vector<double>::iterator vecXoi;
1665 std::vector<double>::iterator vecYoi;
1666 std::vector<double> vecZ;
1668 std::vector<double> vecCtrlPointX;
1669 std::vector<double> vecCtrlPointY;
1670 std::vector<double> vecCtrlPointZ;
1676 int ii,size=polyDataResult->GetNumberOfPoints();
1678 myfile.open ("C:/Creatis/example2.txt");
1680 size=polyDataResult->GetNumberOfPoints();
1681 for (ii=0;ii<size;ii++)
1688 p = polyDataResult->GetPoint(ii);
1691 /*if(fabs(yAct-y)>20)
1693 if((xAct-x)>1 || (xAct-x)<-1)
1695 vecX.push_back( p[0] );
1696 vecY.push_back( p[1] );
1697 myfile <<p[0]<<","<<p[1]<<"\n";
1698 std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
1699 std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
1700 std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
1701 vecZ.push_back( 900 );
1707 vecXo.push_back(p[0]);
1708 vecYo.push_back(p[1]);
1712 else*/ if(fabs(xAct-x)>11)
1714 vecXo.push_back(p[0]);
1715 vecYo.push_back(p[1]);
1717 vecX.push_back( p[0] );
1718 myfile <<p[0]<<","<<p[1]<<"\n";
1719 //std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
1720 //std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
1721 //std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
1722 vecY.push_back( p[1] );
1724 vecZ.push_back( -900 );
1732 while(!vecXo.empty())
1734 vecX.push_back(vecXo.back());
1735 //std::cout<<" x Siguiente "<<vecXo.back();
1738 vecZ.push_back( -900 );
1740 while(!vecYo.empty())
1742 vecY.push_back(vecYo.back());
1747 /*for(int l=0;l<vecX.size();l++)
1751 vecXo.push_back(p[0]);
1752 vecYo.push_back(p[1]);
1763 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
1765 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
1769 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1771 else if (method==1){
1772 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1774 else if (method==2){
1775 extractcontrolpoints2d->SetSamplingControlPoints( 15 );
1776 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
1778 //--Adding contour to the system
1780 std::vector<int> actualInstantVector;
1781 _instantPanel->getInstant( actualInstantVector );
1782 actualInstantVector[1]=z;
1784 int j,sizeCtrPt = vecCtrlPointX.size();
1786 manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour );
1787 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 );
1789 for (j=0 ; j<sizeCtrPt ; j++)
1791 manModelContour->AddPoint( vecCtrlPointX[j] , vecCtrlPointY[j] , vecCtrlPointZ[j] );
1793 std::string theName;
1794 //theName = _modelManager->createOutline( manModelContour, actualInstantVector );
1795 theName = kernelManager->createOutline( manModelContour, actualInstantVector );
1796 bool addedModel = theName.compare("") != 0;
1799 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
1800 _theViewPanel->getSpacing(spc);
1801 //Adding the manualContourControler to interface objects structure
1802 //Adding the manualViewContour to interface objects structure
1803 //_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.
1804 _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
1805 //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
1812 WriterType::Pointer writer = WriterType::New();
1813 CastFilterType3::Pointer caster = CastFilterType3::New();
1815 caster->SetInput( gradientMagnitude->GetOutput() );
1816 writer->SetInput( caster->GetOutput() );
1817 writer->SetFileName("Gradient Magnitude.png");
1818 caster->SetOutputMinimum( 0 );
1819 caster->SetOutputMaximum( 255 );
1822 CastFilterType3::Pointer caster2 = CastFilterType3::New();
1823 WriterType::Pointer writer2 = WriterType::New();
1825 caster2->SetInput( sigmoid->GetOutput() );
1826 writer2->SetInput( caster2->GetOutput() );
1827 writer2->SetFileName("Sigmoid.png");
1828 caster2->SetOutputMinimum( 0 );
1829 caster2->SetOutputMaximum( 255 );
1832 CastFilterType3::Pointer caster3 = CastFilterType3::New();
1833 WriterType::Pointer writer3 = WriterType::New();
1835 caster3->SetInput( fastMarching->GetOutput() );
1836 writer3->SetInput( caster3->GetOutput() );
1837 writer3->SetFileName("FastMarching.bmp");
1838 caster3->SetOutputMinimum( 0 );
1839 caster3->SetOutputMaximum( 255 );
1842 CastFilterType3::Pointer caster4 = CastFilterType3::New();
1843 WriterType::Pointer writer4 = WriterType::New();
1845 caster4->SetInput( geodesicActiveContour->GetOutput() );
1846 writer4->SetInput( caster4->GetOutput() );
1847 writer4->SetFileName("GeodesicActiveContour.png");
1848 caster4->SetOutputMinimum( 0 );
1849 caster4->SetOutputMaximum( 255 );
1852 CastFilterType3::Pointer caster5 = CastFilterType3::New();
1853 WriterType::Pointer writer5 = WriterType::New();
1855 caster5->SetInput( zeroCrossing->GetOutput() );
1856 writer5->SetInput( caster5->GetOutput() );
1857 writer5->SetFileName("ZeroCrossing.bmp");
1858 caster5->SetOutputMinimum( 0 );
1859 caster5->SetOutputMaximum( 255 );
1863 catch( itk::ExceptionObject & excep )
1865 std::cerr << "Exception caught !" << std::endl;
1866 std::cerr << excep << std::endl;
1870 void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int method){
1872 //JCP 20-10-08 Undo redo implementation
1874 //JCP 20-10-08 Undo redo implementation
1877 int x = _theViewPanel->GetX();
1878 int y = _theViewPanel->GetY();
1879 int z = _theViewPanel->GetZ();
1880 SegmentationOneSlice( x,y,z,isovalue, sampling, method );
1885 void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method )
1888 printf("EED wxContourMainFrame::SegmentationOneSlice Start=%d %d\n",sampling,method );
1889 printf("EED wxContourMainFrame::SegmentationOneSlice %d %d %d \n",x,y,z );
1891 int typeofcontour = 1;
1892 //--Extracting Contour
1893 vtkImageData *imagedata = getImageData();
1895 vtkImageReslice *imageReslice = vtkImageReslice::New();
1898 imagedata->GetSpacing(spc);
1903 //EED 2017-01-01 Migration VTK7
1904 #if VTK_MAJOR_VERSION <= 5
1905 imageReslice->SetInput( imagedata );
1907 imageReslice->SetInputData( imagedata );
1909 imageReslice->SetInformationInput(imagedata);
1910 imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
1911 imageReslice->SetResliceAxesOrigin(0,0,z*spc[2]);
1912 imageReslice->SetOutputDimensionality(2);
1913 imageReslice->SetInterpolationModeToLinear();
1915 //EED 2017-01-01 Migration VTK7
1916 #if VTK_MAJOR_VERSION <= 5
1919 imageReslice->Update();
1922 imagedata = imageReslice->GetOutput();
1923 //EED 2017-01-01 Migration VTK7
1924 #if VTK_MAJOR_VERSION <= 5
1925 imagedata->Update();
1926 imagedata->UpdateInformation();
1931 vtkContourFilter* cntVTK = vtkContourFilter::New( );
1932 //EED 2017-01-01 Migration VTK7
1933 #if VTK_MAJOR_VERSION <= 5
1934 cntVTK->SetInput( imagedata );
1936 cntVTK->SetInputData( imagedata );
1939 cntVTK->SetNumberOfContours( 1 );
1940 //cntVTK->SetValue( 0, vmin );
1941 // cntVTK->SetValue( 0, (range[1]*thr/100) );
1942 cntVTK->SetValue( 1, isovalue );
1943 // cntVTK->SetValue( 1, vmax );
1945 cntVTK->UpdateInformation();
1947 vtkCleanPolyData* cpd = vtkCleanPolyData::New( );
1948 //EED 2017-01-01 Migration VTK7
1949 #if VTK_MAJOR_VERSION <= 5
1950 cpd->SetInput( cntVTK->GetOutput( ) );
1952 cpd->SetInputData( cntVTK->GetOutput( ) );
1954 cpd->ConvertLinesToPointsOff( );
1956 cpd->UpdateInformation();
1958 vtkPolyDataConnectivityFilter* conn = vtkPolyDataConnectivityFilter::New( );
1960 // conn->SetExtractionModeToPointSeededRegions();
1961 // conn->SetExtractionModeToCellSeededRegions();
1962 // conn->SetExtractionModeToSpecifiedRegions();
1963 // conn->SetExtractionModeToLargestRegion();
1964 // conn->SetExtractionModeToAllRegions();
1966 conn->SetExtractionModeToClosestPointRegion();
1968 //conn->SetMaxRecursionDepth( 3000 );
1970 //EED 2017-01-01 Migration VTK7
1971 #if VTK_MAJOR_VERSION <= 5
1972 conn->SetInput( cpd->GetOutput( ) );
1974 conn->SetInputData( cpd->GetOutput( ) );
1977 conn->SetClosestPoint( x, y, 0 );
1979 conn->UpdateInformation();
1981 vtkCleanPolyData* cpd2 = vtkCleanPolyData::New( );
1982 //EED 2017-01-01 Migration VTK7
1983 #if VTK_MAJOR_VERSION <= 5
1984 cpd2->SetInput( conn->GetOutput( ) );
1986 cpd2->SetInputData( conn->GetOutput( ) );
1989 cpd2->UpdateInformation();
1991 vtkStripper* vtkstripper = vtkStripper::New( );
1992 vtkstripper->SetJoinContiguousSegments(true);
1993 vtkstripper->SetMaximumLength(20000);
1994 //EED 2017-01-01 Migration VTK7
1995 #if VTK_MAJOR_VERSION <= 5
1996 vtkstripper->SetInput( cpd2->GetOutput() );
1998 vtkstripper->SetInputData( cpd2->GetOutput() );
1999 // vtkstripper->SetInputData( cntVTK->GetOutput() );
2002 vtkstripper->Update();
2003 vtkstripper->UpdateInformation();
2006 vtkPolyData* polyDataResult = vtkstripper->GetOutput();
2008 //EED 2017-01-01 Migration VTK7
2009 #if VTK_MAJOR_VERSION <= 5
2010 polyDataResult->Update( );
2011 polyDataResult->UpdateInformation();
2018 myfile.open ("c:/temp/example.txt");
2020 polyDataResult->Print(myfile);
2021 myfile << "-------------------------------------\n";
2022 polyDataResult->GetLines()->Print(myfile);
2030 //--Calculating control points
2031 std::vector<double> vecX;
2032 std::vector<double> vecY;
2033 std::vector<double> vecZ;
2034 std::vector<double> vecCtrlPointX;
2035 std::vector<double> vecCtrlPointY;
2036 std::vector<double> vecCtrlPointZ;
2038 printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() );
2040 int numberOfPointsInCell;
2041 int numberOfcells=polyDataResult->GetNumberOfCells();
2042 for (int jj=0; jj<numberOfcells ; jj++)
2044 vtkCell* vtkcell = polyDataResult->GetCell( jj );
2045 numberOfPointsInCell=vtkcell->GetNumberOfPoints();
2046 printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d points=%d \n",jj,numberOfPointsInCell );
2049 printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n");
2051 polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
2054 if (polyDataResult->GetNumberOfCells()>0)
2057 printf("EED wxContourMainFrame::SegmentationOneSlice A \n");
2058 vtkCell* vtkcell = polyDataResult->GetCell( 0 );
2059 printf("EED wxContourMainFrame::SegmentationOneSlice B \n");
2060 // int ii,size=polyDataResult->GetNumberOfPoints();
2061 int ii,size=vtkcell->GetNumberOfPoints();
2062 printf("EED wxContourMainFrame::SegmentationOneSlice C \n");
2064 for (ii=0;ii<size;ii++)
2066 // id = polyDataResult->GetLines()->GetData()->GetValue(ii);
2067 // p = polyDataResult->GetPoint(id);
2068 p = vtkcell->GetPoints()->GetPoint(ii);
2070 printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d px=%f py=%f\n",ii,id, p[0],p[1]);
2073 vecX.push_back( p[0] );
2074 vecY.push_back( p[1] );
2076 vecZ.push_back( -900 );
2077 // vecZ.push_back( p[2] );
2080 ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
2081 extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
2084 /*if (methodRadiobox->GetSelection()==0){
2085 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2087 if (methodRadiobox->GetSelection()==1){
2088 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2090 if (methodRadiobox->GetSelection()==2){
2091 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
2092 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2097 extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2098 } else if (method==1){
2099 extractcontrolpoints2d->GetControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2100 } else if (method==2){
2101 extractcontrolpoints2d->SetSamplingControlPoints( sampling );
2102 extractcontrolpoints2d->GetSamplingControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
2105 //--Adding contour to the system
2106 std::vector<int> actualInstantVector;
2107 _instantPanel->getInstant( actualInstantVector );
2108 actualInstantVector[1]=z;
2110 int j,sizeCtrPt = vecCtrlPointX.size();
2111 manualBaseModel *manModelContour = kernelManager->factoryManualContourModel( typeofcontour );
2112 manModelContour->SetNumberOfPointsSpline( ((sizeCtrPt/100)+1)*100 *2 );
2113 manModelContour->SetLabel2( std::to_string(z) );
2116 for (j=0 ; j<sizeCtrPt ; j++)
2118 manModelContour->AddPoint( vecCtrlPointX[j] / spc[0], vecCtrlPointY[j] / spc[1], vecCtrlPointZ[j] );
2120 std::string theName;
2121 //theName = _modelManager->createOutline( manModelContour, actualInstantVector );
2122 theName = kernelManager->createOutline( manModelContour, actualInstantVector );
2123 bool addedModel = theName.compare("") != 0;
2126 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2127 _theViewPanel->getSpacing(spc);
2128 //Adding the manualContourControler to interface objects structure
2129 //Adding the manualViewContour to interface objects structure
2130 //_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.
2131 _theViewPanel->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
2132 //_theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc, typeofcontour ) ;
2135 } // if NumberOfCells > 0
2137 printf("EED wxContourMainFrame::SegmentationOneSlice End\n");
2140 int wxContourMainFrame::GetImageDataSizeZ()
2142 return _theViewPanel->GetImageDataSizeZ();
2145 void wxContourMainFrame::GetImageDataRange(double *range)
2147 _theViewPanel->GetImageDataRange(range);
2150 void wxContourMainFrame::onSegmentationAllSlice(int minZ,int maxZ,int isovalue,int sampling,int method)
2152 //JCP 20-10-08 Undo redo implementation
2154 //JCP 20-10-08 Undo redo implementation
2157 int x = _theViewPanel->GetX();
2158 int y = _theViewPanel->GetY();
2162 double totalZ = maxZ-minZ+1;
2163 for( z=minZ ; z<=maxZ ; z++ )
2165 porcent = 100.0* (z-minZ)/totalZ;
2166 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ,z );
2167 interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(tmpString);
2168 //_staticTextSegmentation->SetLabel(tmpString);
2169 SegmentationOneSlice( x,y,z,isovalue, sampling,method );
2171 interfMainPanel::getInstance()->setLabelSegmentationPanelVTK(_T(" "));
2176 //Creates a reference line to be used as the axis of the mirroring
2177 void wxContourMainFrame::referenceLine()
2179 if (_refLineControl==NULL)
2184 vtkImageData *vtkimagedata = _theViewPanel->getImageData();
2185 vtkimagedata->GetSpacing(spc);
2187 wxVtkBaseView * viewer2D = _theViewPanel->getWxVtkBaseView();
2189 _refLineControl = new manualLineControler();
2190 _refLineModel = new manualContourModelLine();
2191 _refLineView = new manualViewLine();
2192 _refLineView->SetModel( _refLineModel );
2193 _refLineView->SetWxVtkBaseView( viewer2D );
2194 _refLineView->SetRange( 2 );
2195 _refLineView->SetZ( 1200 );
2197 _refLineView->SetSpacing(spc);
2199 _refLineView->SetColorNormalContour(0, 0, 1);
2200 _refLineView->SetColorEditContour(0, 0.5, 0.5);
2201 _refLineView->SetWidthLine(4);
2203 _refLineControl->SetModelView( _refLineModel , _refLineView );
2204 vtkInteractorStyleBaseView* style = (vtkInteractorStyleBaseView*)viewer2D->GetInteractorStyleBaseView();
2205 style->AddInteractorStyleMaracas( _refLineControl );
2206 _refLineModel->SetCloseContour(false);
2207 _refLineControl->CreateNewManualContour();
2209 //AD: Inicializar el mirroring con una linea ya pintada
2211 double z = _refLineControl->GetZ();
2214 image->GetDimensions(imageDim);
2215 double x = (double) imageDim[0]/2;
2216 double y1 = (double) (imageDim[1]/2)+15;
2217 double y2 = (double) (imageDim[1]/2)-15;
2219 _refLineControl->AddPoint(x,y1,z);
2220 _refLineControl->AddPoint(x,y2,z);
2221 _refLineControl->SetCompleteCreation(true);
2223 _refLineModel->AddPoint(x,y1,z);
2224 _refLineModel->AddPoint(x,y2,z);
2225 _refLineModel->UpdateSpline();
2227 _refLineView->UpdateViewPoint(0);
2228 _refLineView->UpdateViewPoint(1);
2231 _refLineControl->SetActive(true);
2232 _refLineView->RefreshContour();
2236 //Hides the referenceLine
2237 void wxContourMainFrame::refLineHide()
2239 if (_refLineControl!=NULL)
2241 if (_refLineControl->GetActive())
2243 _refLineView->RemoveCompleteContourActor();
2244 _refLineControl->SetEditable(false);
2245 _refLineControl->SetActive(false);
2252 //Shows the referenceLine
2253 void wxContourMainFrame::refLineShow()
2255 if (_refLineControl!=NULL)
2257 if (_refLineControl->GetActive()==false)
2259 wxVtkBaseView * viewer2D = _theViewPanel->getWxVtkBaseView();
2261 _refLineView->SetModel( _refLineModel );
2262 _refLineView->SetWxVtkBaseView( viewer2D );
2263 _refLineView->SetRange( 2 );
2264 _refLineView->SetZ( 1200 );
2266 _refLineControl->SetModelView( _refLineModel , _refLineView );
2267 vtkInteractorStyleBaseView* style = (vtkInteractorStyleBaseView*)viewer2D->GetInteractorStyleBaseView();
2268 style->AddInteractorStyleMaracas( _refLineControl );
2269 _refLineControl->CreateNewManualContour();
2270 _refLineControl->SetActive(true);
2271 _refLineView->RefreshContour();
2278 void wxContourMainFrame::refLineChangeWidth(int width)
2280 _refLineView->SetWidthLine(width);
2281 _refLineView->RefreshContour();
2287 void wxContourMainFrame::onMirror()
2290 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
2291 std::vector<std::string> filterCurrentSelection;
2293 std::vector<int> tempVector;
2294 _instantPanel->getInstant( tempVector );
2295 _performingOperation->reset();
2296 _performingOperation->setStartCommand( COPY );
2297 _performingOperation->setStartOperationInstantVector( tempVector );
2298 _performingOperation->setKeyNamesOperationElems( currentSelection );
2300 char theStartCommand = _performingOperation->getStartCommand();
2301 if ( theStartCommand == COPY )
2303 //JCP 20-10-08 Undo redo implementation
2305 //JCP 20-10-08 Undo redo implementation
2306 std::vector<int> tempVector;
2307 _instantPanel->getInstant( tempVector );
2308 _performingOperation->setEndOperationInstantVector ( tempVector );
2309 std::vector<std::string> elems = _performingOperation->getKeyNamesOperationElems();
2310 int i,size = elems.size();
2311 for( i=0; i<size; i++ )
2313 createMirrorContourOf( elems[i], tempVector, i>0 );
2317 //deleteContour( _refName );
2322 void wxContourMainFrame::showAxis(bool show)
2324 _theViewPanel->SetVisibleAxis(show);
2325 _theViewPanel->Refresh();
2329 void wxContourMainFrame::onRigidPressed(){
2330 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
2331 int elementsSelected = currentSelection.size();
2333 if ( elementsSelected >= 1 ){
2334 //JCP 20-10-08 Undo redo implementation
2336 //JCP 20-10-08 Undo redo implementation
2338 std::vector<int> tempVector;
2339 _instantPanel->getInstant( tempVector );
2340 Instant instant(&tempVector);
2342 int i , size=currentSelection.size();
2343 for ( i=0 ; i<size ; i++ )
2345 kernelManager->changeContourOfManager(currentSelection[i], &instant);
2350 void wxContourMainFrame::onWidthOfContour(double width){
2352 _theViewPanel->removeSceneContours();
2353 _theViewPanel->SetWidthContour(width);
2355 //_theViewPanel->getSceneManager()->SetWidthContour( width );
2360 int wxContourMainFrame::getColorWindow()
2364 vtkImageData * img = getImageData();
2365 img->GetScalarRange(range);
2367 std::cout<<"Val 1: "<<range[0]<<" Val 2: "<<range[1]<<std::endl;
2369 return (int)range[1];
2371 return _theViewPanel->getColorWindow();
2374 int wxContourMainFrame::getWindowLevel()
2378 vtkImageData * img = getImageData();
2379 img->GetScalarRange(range);
2381 std::cout<<"Val 1: "<<range[0]<<" Val 2: "<<range[1]<<std::endl;
2383 return (int)range[1];
2385 return _theViewPanel->getWindowLevel();
2388 void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
2390 _theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
2395 void wxContourMainFrame::onInterpolation(bool interpolate)
2397 _theViewPanel->onInterpolation(interpolate);
2401 void wxContourMainFrame::onBeforeAfterContour(bool before,bool after)
2403 _theViewPanel->onBeforeAfterContour(before,after);
2407 void wxContourMainFrame::onJumpSlice(int step, int shift)
2409 std::vector<int> tempVector;
2410 _instantPanel->getInstant( tempVector );
2412 int pos = tempVector[1];
2413 int maxZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
2414 pos=(pos/ss)*ss+step+shift;
2415 if ((pos>=0) && (pos<maxZ))
2418 _instantPanel->setInstant( tempVector );
2423 void wxContourMainFrame::onShowTextContour(bool show)
2425 _theViewPanel->onShowTextContour(show);
2429 void wxContourMainFrame::onChangeInstant(std::string name,int actual)
2431 _instantPanel->setConceptValue( name, actual );
2434 void wxContourMainFrame::resetAppend()
2436 kernelManager->resetAppend();
2439 void wxContourMainFrame::onSpreadAdd()
2441 std::vector<double> vecX;
2442 std::vector<double> vecY;
2443 std::vector<double> vecZ;
2444 _theViewPanel->GetPointsOfActualContour(&vecX , &vecY , &vecZ );
2445 std::vector<int> tempVector;
2446 _instantPanel->getInstant( tempVector );
2447 std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
2448 interfMainPanel::getInstance()->appendStringSpread(val);
2452 void wxContourMainFrame::onSpreadAddAll()
2455 std::vector<int> tempVector;
2456 _instantPanel->getInstant( tempVector );
2459 maxZ = interfMainPanel::getInstance()->GetImageDataSizeZ();
2461 int sizeLstContourThings;
2462 for ( z=minZ ; z<=maxZ ; z++ )
2465 Instant instant(&tempVector);
2466 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
2467 sizeLstContourThings = lstContourThings.size();
2468 if (sizeLstContourThings>=1)
2470 std::vector<double> vecX;
2471 std::vector<double> vecY;
2472 std::vector<double> vecZ;
2473 ContourThing **contourthing = lstContourThings[0];
2474 manualBaseModel *cModel = (*contourthing)->getModel();
2475 int i,size = cModel->GetNumberOfPointsSpline();
2477 for (i=0; i<size; i++)
2479 cModel->GetSpline_i_Point(i, &x, &y, &z);
2484 std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
2485 interfMainPanel::getInstance()->appendStringSpread(val);
2486 }// if sizeLstContourThings
2491 void wxContourMainFrame::onSpreadGo(int type)
2493 //JCP 20-10-08 Undo redo implementation
2495 //JCP 20-10-08 Undo redo implementation
2497 std::vector<double> vecCtrlPointX;
2498 std::vector<double> vecCtrlPointY;
2499 std::vector<double> vecCtrlPointZ;
2503 std::vector<int> tempVector;
2504 _instantPanel->getInstant( tempVector );
2507 kernelManager->getMaxMinZ(&minZ,&maxZ);
2508 //JSTG_16-07-08_----------------------------------------------------------------
2509 //_contourPropagation->setInterpolationNumber(maxZ-minZ+1);
2510 kernelManager->CalculeSplinePropagation();
2512 double totalZ = maxZ-minZ+1;
2515 //--------------------------------------------------------------------
2516 for ( z=(int)minZ ; z<=(int)maxZ ; z++ )
2518 porcent = 100.0* (z-minZ)/totalZ;
2519 int numero = (int)(z-minZ+1)/(int)totalZ;
2520 std::string stringtemp = " "+kernelManager->intToString(porcent)+"% "+kernelManager->intToString(numero)+" "+kernelManager->intToString(z);
2522 interfMainPanel::getInstance()->setStringSpread(stringtemp);
2524 int typeofcontour = 1;
2525 std::string theName;
2526 manualBaseModel* manModelContour = kernelManager->GetPoints(z, type, &vecCtrlPointX,&vecCtrlPointY,&vecCtrlPointZ, theName,typeofcontour, tempVector);
2528 if( manModelContour!=NULL ){
2529 double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default
2530 this->_theViewPanel->getSpacing(spc);
2531 //Adding the manualContourControler to interface objects structure
2532 //Adding the manualViewContour to interface objects structure
2533 //_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.
2534 _theViewPanel->configureViewControlTo( theName, manModelContour,spc,typeofcontour ) ;
2539 int numero = (int)(z-minZ+1)/(int)totalZ;
2540 std::string stringtemp = " "+kernelManager->intToString(porcent)+"% "+kernelManager->intToString(numero)+" "+kernelManager->intToString(z);
2542 interfMainPanel::getInstance()->setStringSpread(stringtemp);
2544 //RefreshInterface();
2547 void wxContourMainFrame::getInstantVector(std::vector<int>& tempVector)
2549 _instantPanel->getInstant( tempVector );
2552 std::vector<std::string> wxContourMainFrame::getOutlinesName(int slide)
2554 std::vector<int> tempVector;
2555 _instantPanel->getInstant(tempVector);
2556 //Asignation of slide number should be different ex by name
2557 tempVector[1]=slide;
2558 return kernelManager->getOutlinesNameAtInstant(tempVector);
2562 void wxContourMainFrame::SetScalarRange(int grayRangeMin, int grayRangeMax)
2564 _contourextractdata->SetScalarRange(grayRangeMin,grayRangeMax);
2568 void wxContourMainFrame::onInformationContourLabels(int typeContourGroup,int selection,int minimumZ,int maximumZ,int grayRangeMin, int grayRangeMax)
2571 wxString tempString;
2572 int maxContourGroup = 0;
2574 _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
2576 std::vector<manualBaseModel*> lstManConMod;
2577 std::vector<manualBaseModel*> lstManConModTmp;
2578 std::vector<manualBaseModel*> lstManConModExp;
2579 std::vector<double> pLstValue;
2580 std::vector<double> pLstValuePosX;
2581 std::vector<double> pLstValuePosY;
2582 std::vector<double> pLstValuePosZ;
2585 int resultGrayRangeCount;
2588 double resultAverage;
2589 double resultStandardeviation;
2591 std::vector<int> tempVector;
2592 _instantPanel->getInstant( tempVector );
2595 int ii,sizeLstContourThings;
2604 if (selection==0 ) // actual slice
2606 int actualSlice = tempVector[1];
2609 } else { // slice range
2615 totalZ = maxZ-minZ+1;
2617 _contourextractdata->InitVolumeStatistics();
2620 for ( z=minZ ; z<=maxZ ; z++ )
2623 porcent = 100.0* (z-minZ)/totalZ;
2624 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
2626 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
2627 //_staticTextInformation->SetLabel(tmpString);
2629 //Extraction data from contours of each slice
2630 _contourextractdata->SetZtoBeAnalys(z);
2633 Instant instant(&tempVector);
2634 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
2635 sizeLstContourThings = lstContourThings.size();
2637 lstManConMod.clear();
2638 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2640 ContourThing **contourthing = lstContourThings[ii];
2641 lstManConMod.push_back( (*contourthing)->getModel() );
2644 lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
2646 tempString.Printf(_T("%d - %d"),z, sizeLstContourThings);
2647 interfMainPanel::getInstance()->setRowLabelInfoPanel(z, tempString);
2648 //_grid->SetRowLabelValue(z, tempString );
2650 int iContourGroup,sizeContourGroup;
2651 if (typeContourGroup==3) // contour separete
2653 sizeContourGroup=lstManConModExp.size();
2654 if ( maxContourGroup<sizeContourGroup )
2656 maxContourGroup=sizeContourGroup;
2658 } else { // contour AND OR XOR
2665 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
2666 lstManConModTmp.clear();
2670 if (typeContourGroup==3) // contour separete
2672 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
2673 } else { // contour AND OR XOR
2674 lstManConModTmp = lstManConModExp;
2677 _contourextractdata->SetLstManualContourModel( lstManConModTmp );
2678 _contourextractdata->SetScalarRange(grayRangeMin,grayRangeMax);
2681 pLstValuePosX.clear();
2682 pLstValuePosY.clear();
2683 pLstValuePosZ.clear();
2687 _contourextractdata->GetValuesInsideCrown( &numberOfPixels,
2693 resultSize=numberOfPixels;
2694 // Statistics of each slice.
2695 _contourextractdata->Statistics( &pLstValue,
2698 &resultGrayRangeCount,
2703 &resultStandardeviation);
2705 if (interfMainPanel::getInstance()->getNumberColsInformationPanel()<_numberOfVariablesStatistics*(iContourGroup+1) )
2707 interfMainPanel::getInstance()->appendColsInformationPanel(_numberOfVariablesStatistics);
2710 tmpIntA=_numberOfVariablesStatistics*iContourGroup ;
2712 tempString.Printf(_T("%d"),numberOfPixels);
2714 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA, tempString);
2716 tempString.Printf(_T("%d"),resultGrayRangeCount);
2717 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+1, tempString);
2719 tempString.Printf(_T("%f"),resultMin);
2720 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+2, tempString);
2722 tempString.Printf(_T("%f"),resultMax);
2723 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+3, tempString);
2725 tempString.Printf(_T("%f"),resultAverage);
2726 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+4, tempString);
2728 tempString.Printf(_T("%f"),resultStandardeviation);
2729 interfMainPanel::getInstance()->setCellValueInfoPanel(z, tmpIntA+5, tempString);
2732 } // for iContourGroup
2735 // Print Volume Statistics
2738 int vol_rCountRange;
2740 double vol_minValue;
2741 double vol_maxValue;
2743 double vol_standardeviation;
2745 if (selection!=0 ) // actual slice
2748 _contourextractdata->GetVolumeStatistics(&vol_rCountRange, &vol_rsize,
2749 &vol_minValue, &vol_maxValue,
2750 &vol_average, &vol_standardeviation);
2752 interfMainPanel::getInstance()->setRowLabelInfoPanel(maxZ+2, _T("Total:"));
2754 tempString.Printf(_T("%d"),vol_rsize);
2755 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 0, tempString);
2757 tempString.Printf(_T("%d"),vol_rCountRange);
2758 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 1, tempString);
2760 tempString.Printf(_T("%f"),vol_minValue);
2761 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 2, tempString);
2763 tempString.Printf(_T("%f"),vol_maxValue);
2764 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 3, tempString);
2766 tempString.Printf(_T("%f"),vol_average);
2767 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 4, tempString);
2769 tempString.Printf(_T("%f"),vol_standardeviation);
2770 interfMainPanel::getInstance()->setCellValueInfoPanel(maxZ+2, 5, tempString);
2772 //-----------------------------------------
2775 wxString tmpTitleString;
2777 for ( iTitleGroup=0 ; iTitleGroup<maxContourGroup ; iTitleGroup++ )
2779 tmpIntB =_numberOfVariablesStatistics*iTitleGroup;
2780 tmpTitleString.Printf(_T("%d-Size Data"),iTitleGroup);
2781 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString);
2783 interfMainPanel::getInstance()->setColLableInfoPanel(tmpIntB + 0, tmpTitleString );
2784 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 1, _T("Size Range") );
2785 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 2, _T("Min") );
2786 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 3, _T("Max") );
2787 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 4, _T("Average") );
2788 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 5, _T("St.Dev.") );
2789 interfMainPanel::getInstance()->setColLableInfoPanel( tmpIntB + 6, _T(" ") );
2791 interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
2795 void wxContourMainFrame::onSaveResults(std::string directory,std::string namefile, std::string filename,
2796 int typeContourGroup, int selection, int minZ, int maxZ, bool XYZValues, bool contourImage, bool statistics)
2800 SaveValuesXYZ( directory , namefile, typeContourGroup );
2805 vtkImageData * mask;
2806 vtkImageData * value;
2807 this->getMaskValue(&mask, &value, typeContourGroup,selection,minZ,maxZ);
2808 this->SaveImageResult( directory , namefile, mask, value);
2813 std::ostringstream name;
2814 name << filename << ".xls";
2817 FILE *pFile=fopen(name.str().c_str(),"w+");
2823 // int sizeZ = _theViewPanel->GetImageDataSizeZ();
2824 // int maxY=sizeZ+2;
2826 maxX= interfMainPanel::getInstance()->getNumberColsInformationPanel();//this->_grid->GetNumberCols();
2829 int iTitle,sizeTitle = (maxX / _numberOfVariablesStatistics);
2830 for ( iTitle=0; iTitle<sizeTitle ; iTitle++)
2832 // fprintf(pFile,"-- \t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle,tmpString.c_str() );
2833 fprintf(pFile,"slice\t %d-Size \t SizeRange \t Min \t Max \t Ave \t StDv \t" , iTitle );
2835 fprintf(pFile,"\n\n" );
2839 if (selection==0 ) // actual slice
2841 std::vector<int> tempVector;
2842 _instantPanel->getInstant( tempVector );
2843 int actualSlice = tempVector[1];
2849 for ( j=minZ; j<=maxZ ; j++)
2851 fprintf(pFile,"%d\t" , j );
2852 for (i=0 ; i<maxX ; i++){
2853 tmpString = interfMainPanel::getInstance()->getCellValue(j, i);//_grid->GetCellValue( j , i );
2854 fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
2856 fprintf(pFile,"\n" );
2860 // Total of stadistics.....
2863 fprintf(pFile,"\n Total:\t" );
2864 for (i=0 ; i<maxX ; i++){
2865 tmpString = interfMainPanel::getInstance()->getCellValue(maxZ+2, i);//_grid->GetCellValue( maxZ+2 , i );
2866 fprintf(pFile,"%s\t" , (const char *)(tmpString.mb_str()) );
2868 fprintf(pFile,"\n" );
2876 void wxContourMainFrame::SaveValuesXYZ(std::string directory,std::string namefile,int typeContourGroup)
2880 //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
2881 _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
2883 std::vector<manualBaseModel*> lstManConMod;
2884 std::vector<manualBaseModel*> lstManConModTmp;
2885 std::vector<manualBaseModel*> lstManConModExp;
2886 std::vector<double> pLstValue;
2887 std::vector<double> pLstValuePosX;
2888 std::vector<double> pLstValuePosY;
2889 std::vector<double> pLstValuePosZ;
2891 std::vector<int> tempVector;
2892 _instantPanel->getInstant( tempVector );
2894 int sizeZ = _theViewPanel->getSceneManager()->GetImageDataSizeZ();
2896 int ii,sizeLstContourThings;
2903 minZ = 0;// _mbarrange->GetStart();
2904 maxZ = sizeZ;//_mbarrange->GetEnd();
2905 totalZ = maxZ-minZ+1;
2909 for ( z=0 ; z<sizeZ ; z++)
2912 porcent = 100.0* (z-minZ)/totalZ;
2914 tmpString.Printf(_T("Saving Values"));
2915 tmpString.Printf(_T(" %d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
2916 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
2917 //_staticTextInformation->SetLabel(tmpString);
2920 //Extraction data from contours of each slice
2921 _contourextractdata->SetZtoBeAnalys( z);
2924 Instant instant(&tempVector);
2925 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant(&instant);//this->_modelManager->getOutlinesAtInstant( &instant );
2926 sizeLstContourThings = lstContourThings.size();
2928 lstManConMod.clear();
2929 for (ii=0 ; ii<sizeLstContourThings ; ii++)
2931 ContourThing **contourthing = lstContourThings[ii];
2932 lstManConMod.push_back( (*contourthing)->getModel() );
2934 lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
2939 int iContourGroup,sizeContourGroup;
2940 if (typeContourGroup==3) // contour separete
2942 sizeContourGroup=lstManConModExp.size();
2943 } else { // contour AND OR XOR
2947 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
2948 lstManConModTmp.clear();
2949 if (typeContourGroup==3) // contour separete
2951 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
2952 } else { // contour AND OR XOR
2953 lstManConModTmp = lstManConModExp;
2956 _contourextractdata->SetLstManualContourModel( lstManConModTmp );
2959 pLstValuePosX.clear();
2960 pLstValuePosY.clear();
2961 pLstValuePosZ.clear();
2963 _contourextractdata->GetValuesInsideCrown( &numberOfPixels,
2969 std::string temp = directory + "/" + namefile + "-slice";
2970 temp = temp + kernelManager->intToString(z) + "-cont" + kernelManager->intToString(iContourGroup);
2971 temp = temp + ".txt";
2973 // LG 14/01/09 : using crea
2974 wxString filename = crea::std2wx(temp);
2975 /*filename.Printf(_T("%s"),directory.c_str());
2976 filename.append(_T("\\"));
2977 filename.append(_T("%s"),namefile.c_str());
2978 filename.append(_T("-slice"));
2979 filename.append(_T("%d"),z);
2980 filename.append(_T("-cont"));
2981 filename.append(_T("%d"),iContourGroup);
2982 filename.append(_T(".txt"));*/
2983 // filename.Printf(temp.c_str());
2987 FILE *pFile=fopen((const char *)filename.mb_str(),"w+");
2988 fprintf(pFile,"value \t x \t y \t z\n" );
2989 int iLstValue,sizeLstValue=pLstValue.size();
2990 for (iLstValue=0 ; iLstValue<sizeLstValue ; iLstValue++ )
2992 fprintf(pFile,"%f\t %f\t %f\t %f\n", (float)pLstValue[iLstValue] , (float)pLstValuePosX[iLstValue], (float)pLstValuePosY[iLstValue], (float)z );
2995 } // for iContourGroup
2997 interfMainPanel::getInstance()->setStringInfoPanel(_T(""));
2998 //_staticTextInformation->SetLabel( _T("") );
3002 void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value,int typeContourGroup, int selection, int minZ, int maxZ){
3005 //int typeContourGroup = this->_radiolstboxContourGroup->GetSelection();
3006 if (typeContourGroup==3)
3010 _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
3012 std::vector<manualBaseModel*> lstManConMod;
3013 std::vector<manualBaseModel*> lstManConModTmp;
3014 std::vector<manualBaseModel*> lstManConModExp;
3016 std::vector<int> tempVector;
3017 _instantPanel->getInstant( tempVector );
3019 vtkImageData *imagedata = _theViewPanel->getImageData();
3021 imagedata->GetExtent(ext);
3022 int sizeZimage = ext[5]-ext[4]+1;
3024 int ii,sizeLstContourThings;
3032 if (selection==0 ) // actual slice
3034 int actualSlice = tempVector[1];
3042 // cleanning image before range
3043 for (z=0; z<minZ; z++){
3044 _contourextractdata->ResetImageResult(z);
3046 // cleanning image after range
3047 for (z=maxZ+1; z<sizeZimage; z++){
3048 _contourextractdata->ResetImageResult(z);
3053 for ( z=minZ ; z<=maxZ ; z++)
3056 porcent = 100.0* (z-minZ)/totalZ;
3057 tmpString.Printf(_T("Saving Values"));
3058 tmpString.Printf(_T("%d %c %d/%d %d"), (int)porcent , 37 , z-minZ+1, (int)totalZ ,z);
3059 interfMainPanel::getInstance()->setStringInfoPanel(tmpString);
3061 //Extraction data from contours of each slice
3062 _contourextractdata->SetZtoBeAnalys( z);
3065 Instant instant(&tempVector);
3066 std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
3067 sizeLstContourThings = lstContourThings.size();
3069 lstManConMod.clear();
3070 for (ii=0 ; ii<sizeLstContourThings ; ii++)
3072 ContourThing **contourthing = lstContourThings[ii];
3073 lstManConMod.push_back( (*contourthing)->getModel() );
3075 lstManConModExp = kernelManager->ExploseEachModel( lstManConMod );
3078 int iContourGroup,sizeContourGroup;
3079 if (typeContourGroup==3) // contour separete
3081 sizeContourGroup=lstManConModExp.size();
3082 } else { // contour AND OR XOR
3086 for( iContourGroup=0 ; iContourGroup<sizeContourGroup ; iContourGroup++ ){
3087 lstManConModTmp.clear();
3088 if (typeContourGroup==3) // contour separete
3090 lstManConModTmp.push_back( lstManConModExp[iContourGroup]);
3091 } else { // contour AND OR XOR
3092 lstManConModTmp = lstManConModExp;
3095 _contourextractdata->SetLstManualContourModel( lstManConModTmp );
3096 _contourextractdata->CalculateImageResult(); // with actual Z
3098 } // for iContourGroup
3101 (*value) = _contourextractdata->GetVtkImageValueResult();
3102 (*mask) = _contourextractdata->GetVtkImageMaskResult();
3106 std::string wxContourMainFrame::GetStringTypeImage( vtkImageData* image)
3108 std::string result="";
3109 if ( image->GetScalarType()==VTK_CHAR )
3112 } else if ( image->GetScalarType()==VTK_UNSIGNED_CHAR ){
3114 } else if ( image->GetScalarType()==VTK_FLOAT ){
3116 } else if ( image->GetScalarType()==VTK_DOUBLE ){
3118 } else if ( image->GetScalarType()==VTK_INT ){
3120 } else if ( image->GetScalarType()==VTK_UNSIGNED_INT ){
3122 } else if ( image->GetScalarType()==VTK_SHORT ){
3124 } else if ( image->GetScalarType()==VTK_UNSIGNED_SHORT ){
3126 } else if ( image->GetScalarType()==VTK_LONG ){
3128 } else if ( image->GetScalarType()==VTK_UNSIGNED_LONG ){
3134 void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value)
3136 std::string stringType;
3138 kernelManager->GetSpacing(spc,0); // returns the spacing of the first image
3139 stringType = GetStringTypeImage(value);
3140 std::string temp = directory + "/" + namefile + "-image-Value-"+stringType+".mhd";
3142 wxString filename = crea::std2wx(temp);
3146 vtkImageChangeInformation *valueChInfo = vtkImageChangeInformation::New();
3147 //EED 2017-01-01 Migration VTK7
3148 #if VTK_MAJOR_VERSION <= 5
3149 valueChInfo->SetInput(value);
3151 valueChInfo->SetInputData(value);
3153 valueChInfo->SetSpacingScale(spc);
3154 valueChInfo->Update();
3155 vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
3157 //EED 2017-01-01 Migration VTK7
3158 #if VTK_MAJOR_VERSION <= 5
3159 writerValueImage->SetInput( valueChInfo->GetOutput() );
3161 writerValueImage->SetInputData( valueChInfo->GetOutput() );
3163 writerValueImage->SetFileName( (const char *)filename.mb_str() );
3164 writerValueImage->SetFileDimensionality( 3 );
3165 writerValueImage->SetCompression(false);
3166 writerValueImage->Write( );
3169 stringType = GetStringTypeImage(mask);
3170 temp = directory + "/" + namefile + "-image-Mask-"+stringType+".mhd";
3172 // LG 14/01/09 : using crea
3173 filename = crea::std2wx(temp);
3174 // filename.Printf(_T(temp.c_str()));
3177 vtkImageChangeInformation *maskChInfo = vtkImageChangeInformation::New();
3178 //EED 2017-01-01 Migration VTK7
3179 #if VTK_MAJOR_VERSION <= 5
3180 maskChInfo->SetInput(mask);
3182 maskChInfo->SetInputData(mask);
3184 maskChInfo->SetSpacingScale(spc);
3185 maskChInfo->Update();
3186 vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
3188 //EED 2017-01-01 Migration VTK7
3189 #if VTK_MAJOR_VERSION <= 5
3190 writerMaskImage->SetInput( maskChInfo->GetOutput() );
3192 writerMaskImage->SetInputData( maskChInfo->GetOutput() );
3195 writerMaskImage->SetFileName( (const char *)filename.mb_str() );
3196 writerMaskImage->SetFileDimensionality( 3 );
3197 writerMaskImage->SetCompression(false);
3198 writerMaskImage->Write( );
3200 interfMainPanel::getInstance()->setStringInfoPanel( _T("") );
3206 void wxContourMainFrame::onChangeInstantInstantPanel(std::string name,int value, int minshow, int maxshow){
3207 if( name.compare( _theViewPanel->getVerticalConceptName() ) == 0){
3208 _theViewPanel->setActualVertical( value);
3210 else if( name.compare( _theViewPanel->getHorizontalConceptName() ) == 0|| _instantPanel->getIfConceptCheckedAt( name, 0 ) ) {
3211 _theViewPanel->setHorizontalConcept( name, minshow, maxshow, minshow, maxshow, value);
3217 void wxContourMainFrame::onSnakePressed(){
3218 std::vector<double> vecX;
3219 std::vector<double> vecY;
3220 std::vector<double> vecZ;
3221 _theViewPanel->GetPointsOfActualContour( &vecX , &vecY , &vecZ );
3223 if (vecX.size()!=0){
3224 std::vector<int> tempVector;
3225 _instantPanel->getInstant( tempVector );
3226 int i,size=vecZ.size();
3227 int actualSlice = tempVector[1];
3228 for ( i=0 ; i<size ; i++ )
3230 vecZ[i] = actualSlice;
3233 wxDialog* dialog = new wxDialog(this, -1, wxString(_T("Snake")));
3234 wxPanel* panel = new wxPanel(dialog,-1);
3235 // wxStaticText* sttext = new wxStaticText(panel, -1, wxString(_T("Panel para snake")));
3236 new wxStaticText(panel, -1, wxString(_T("Panel para snake")));
3237 dialog->ShowModal();
3242 void wxContourMainFrame::saveFileWithContoursAutomatique()
3244 printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n");
3245 std::string filename = kernelManager->getCurrentFileName();
3246 if(filename.compare("")!=0){
3247 saveFileWithContours(filename);
3252 void wxContourMainFrame::ShowToolsPanel(bool show)
3254 _pannew->Show(show);
3259 void wxContourMainFrame::SetContourGroup(int contourGroup)
3261 _contourGroup = contourGroup;
3265 wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
3268 if (_viewMaskImagePanel==NULL)
3270 _contourextractdata = new ContourExtractData(true);
3271 _contourextractdata->SetImage( _theViewPanel->getImageData() );
3273 // _theViewPanel->getImageData()->GetScalarRange(range);
3274 //int min = (int)floor (range[0]);
3275 //int max = (int)ceil (range[1]);
3281 _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , -1,-1, 0);
3282 _viewMaskImage = new ThresholdImageView();
3283 _viewMaskImage->SetImage( _contourextractdata->GetVtkImageMaskResult() );
3284 _viewMaskImage->SetminMaxValue( min, max);
3285 _viewMaskImage->SetBaseColor( 0,0,1 );
3288 std::vector<int> colorbarposition;
3289 colorbarposition.push_back( -999 );
3290 colorbarposition.push_back( -999 );
3291 _viewMaskImage->SetColorBarPosition( colorbarposition );
3293 _viewMaskImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() );
3294 _viewMaskImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() );
3296 _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage );
3297 _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
3298 _viewMaskImage->onThresholdChangeOpacity( 25 );
3300 return _viewMaskImagePanel;
3304 wxPanel *wxContourMainFrame::getColorLayerImageViewPanel(wxWindow *parent)
3306 if (_viewColorLayerImagePanel==NULL)
3309 _theViewPanel->getImageData()->GetScalarRange(range);
3310 int min = (int)floor (range[0]);
3311 int max = (int)ceil (range[1]);
3312 _viewColorLayerImagePanel = new ColorLayerImageViewPanel( parent, min, max, 100, 1);
3313 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , _theViewPanel->getWxVtkBaseView() );
3314 // std::vector<double> range = bbGetInputlstRangeForColorBar();
3315 // clivp->GetColorLayerImageViewManager()->SetRangeForColorBar( range );
3316 std::vector<int> colorbarposition;
3317 colorbarposition.push_back( 50 );
3318 colorbarposition.push_back( 105 );
3319 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetColorBarPosition( colorbarposition );
3320 // std::vector<double> base_color;
3321 // _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseColors( base_color );
3322 // std::vector<double> grey_level_boundaries;
3323 // clivp->GetColorLayerImageViewManager()->SetGreyLevelBoundaries( grey_level_boundaries );
3324 std::vector<double> transparence_level_boundaries;
3325 transparence_level_boundaries.push_back(0);
3326 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetBaseTransparence( transparence_level_boundaries );
3327 _viewColorLayerImagePanel->GetColorLayerImageViewManager()->SetPlainOrGradientColor( false );
3328 // _viewColorLayerImagePanel->SetFittingMode( 3 );
3330 return _viewColorLayerImagePanel;
3334 wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
3336 if (_viewThresholdImagePanel==NULL)
3339 _theViewPanel->getImageData()->GetScalarRange(range);
3340 int min = (int)floor (range[0]);
3341 int max = (int)ceil (range[1]);
3342 int start= (max+min)/2 - (max-min)*0.25;
3343 int end= (max+min)/2 + (max-min)*0.25;
3344 _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max, start, end , 1);
3345 _viewThresholdImage = new ThresholdImageView();
3346 _viewThresholdImage->SetminMaxValue(start,end);
3347 _viewThresholdImage->SetImage( _theViewPanel->getImageData() );
3348 std::vector<int> colorbarposition;
3349 colorbarposition.push_back( 10 );
3350 colorbarposition.push_back( 105 );
3351 _viewThresholdImage->SetColorBarPosition( colorbarposition );
3353 _viewThresholdImage->SetSpcBase( _theViewPanel->getImageData()->GetSpacing() );
3354 _viewThresholdImage->SetNewSpacingLayer( _theViewPanel->getImageData()->GetSpacing() );
3356 _viewThresholdImage->SetBaseColor( 1,0,0 );
3357 _viewThresholdImagePanel->SetThresholdImageView( _viewThresholdImage );
3358 _viewThresholdImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
3359 _viewThresholdImage->onThresholdChangeOpacity( 25 );
3362 return _viewThresholdImagePanel;
3365 //CMRU 17-08-09-----------------------------------------------------------------------------------------------
3366 int wxContourMainFrame::getType ()
3369 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
3371 if(!currentSelection.empty())
3373 std::string cloneName = currentSelection [0];
3374 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);
3375 tipo = manualModel-> GetTypeModel();
3380 double wxContourMainFrame::getContourSizeInPixels()
3382 double contourSize = 0;
3384 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects(); if(!currentSelection.empty())
3385 if(!currentSelection.empty())
3387 std::string cloneName = currentSelection [0];
3389 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
3392 // contourSize = manualModel->GetPathSize();
3397 contourSize = manualModel->GetPathSize( spc );
3402 manualBaseModel * wxContourMainFrame::getContour ()
3404 std::vector<std::string> currentSelection = _theViewPanel->getSelectedObjects();
3406 if(!currentSelection.empty())
3408 std::string cloneName = currentSelection [0];
3409 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(cloneName);//_modelManager->getOutlineByKeyName( cloneName )->getModel();
3414 void wxContourMainFrame::onPrintLabel (wxString label, manualBaseModel* manualModel)
3416 std::string labelAscii(label.ToAscii());
3417 int pos = labelAscii.find(" ");
3421 for (j=0 ; pos != string::npos;j++)
3423 labelAscii.replace( pos, 1, "_" );
3424 pos= labelAscii.find(" ");
3427 manualModel -> SetLabel(labelAscii);
3429 void wxContourMainFrame::onInsertCalculation(manualBaseModel* manualModel)
3432 // double sizeInPixel = manualModel ->GetPathSize( );
3437 double sizeInPixel = manualModel ->GetPathSize( spc );
3439 double onePixelRealSize = interfMainPanel::getInstance()->GetPixelValue();;
3440 double realContourSize = sizeInPixel*onePixelRealSize;
3441 manualModel ->SetRealSize(realContourSize);
3444 double wxContourMainFrame::onePixelSize( double value)
3446 return _onePixelSize = value;
3449 std::string wxContourMainFrame::GetFileLocation()
3451 return _fileLocation;
3454 void wxContourMainFrame::SetFileLocation(std::string newFileLocation)
3456 _fileLocation = newFileLocation;
3457 std::cout<<"GETFILELOCATION:"<<_fileLocation<<std::endl;
3460 kernelManager->setCurrentFileName(_fileLocation);
3462 //------------------------------------------------------------------------------------------------------------
3471 void wxContourMainFrame::FlipSelectedContours(int flipDirection)
3474 (std::vector<std::string>)_theViewPanel->getSceneManager()->getSelectedObjects() ,
3480 void wxContourMainFrame::FlipActualSliceContours(int flipDirection)
3483 (std::vector<std::string>)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() ,
3488 void wxContourMainFrame::FlipAllContours(int flipDirection)
3491 kernelManager->GetLstNameThings() ,
3496 void wxContourMainFrame::FlipLstOfContours(std::vector<std::string> lstNameThings, int flipDirection)
3499 getImageData()->GetExtent(ext);
3500 int sizeX = ext[1]-ext[0];
3501 int sizeY = ext[3]-ext[2];
3504 int i,sizeLstNameThings;
3505 int ii,sizeLstPoints;
3507 sizeLstNameThings = lstNameThings.size();
3508 for (i=0 ; i<sizeLstNameThings ; i++)
3510 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
3511 if (flipDirection==0)
3513 manualModel->Transform_Ax_Plus_B(-1,sizeX,1,0 );
3515 manualModel->Transform_Ax_Plus_B(1,0,-1,sizeY );
3517 }// for i list of Things
3519 //-- Static Contours
3521 lstNameThings = kernelManager->GetLstNameThingsStatic();
3522 sizeLstNameThings = lstNameThings.size();
3523 for (i=0 ; i<sizeLstNameThings ; i++)
3525 manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
3526 if (flipDirection==0)
3528 manualModel->Transform_Ax_Plus_B(-1,sizeX,1,0 );
3530 manualModel->Transform_Ax_Plus_B(1,0,-1,sizeY );
3532 }// for i list of static things
3535 void wxContourMainFrame::FlipContours(int typeContourFlip, int flipDirection)
3539 if (typeContourFlip==0) //
3541 FlipSelectedContours(flipDirection);
3544 if (typeContourFlip==1) //
3546 FlipActualSliceContours(flipDirection);
3549 if (typeContourFlip==2) //
3551 FlipAllContours(flipDirection);
3556 void wxContourMainFrame::SetXY(int x, int y)
3558 _theViewPanel->SetXY(x,y);