From: eduardo.davila@creatis.insa-lyon.fr Date: Fri, 3 Jan 2025 11:00:56 +0000 (+0100) Subject: #3395 Define max contours bye Instant X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c5fd6baf51bc700f475002b7a0843c3fadea66d8;p=creaContours.git #3395 Define max contours bye Instant --- diff --git a/bbtk/src/bbCreaContournDimensions.cxx b/bbtk/src/bbCreaContournDimensions.cxx index 336a763..75b3b91 100644 --- a/bbtk/src/bbCreaContournDimensions.cxx +++ b/bbtk/src/bbCreaContournDimensions.cxx @@ -39,7 +39,6 @@ void nDimensions::Process() // std::vector< void * > vectortemp; // std::vector size; // vtkImageData **mask = 0, **value = 0; - if (firsttime==true) { firsttime=false; @@ -50,19 +49,16 @@ void nDimensions::Process() selectedimages.push_back( bbGetInputIn() ); wxContourMainFrame::getInstance()->ShowToolsPanel(true); wxContourMainFrame::getInstance()->configure(selectedimages); + wxContourMainFrame::getInstance()->SetMaxContoursByInstant(1); } // if In } else{ - //wxContourMainFrame::getInstance()->getValuesXYZ(vectx, vecty, vectz, &size); //wxContourMainFrame::getInstance()->getMaskValue(mask, value, contourtype); - if ( currentimg!=bbGetInputIn() ) { wxContourMainFrame::getInstance()->changeImage(0, bbGetInputIn() ); currentimg=bbGetInputIn(); } // if currentimg!=In - - } // if firsttime wxContourMainFrame::getInstance()->RefreshInterface(); bbSetOutputwxContourMainFrame( wxContourMainFrame::getInstance() ); diff --git a/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx b/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx index 3dfe221..ae33330 100644 --- a/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx +++ b/bbtk/src/bbcreaContourswxContourMainFrame_tool.cxx @@ -16,7 +16,7 @@ BBTK_BLACK_BOX_IMPLEMENTATION(wxContourMainFrame_tool,bbtk::AtomicBlackBox); //===== void wxContourMainFrame_tool::Process() { - + printf("EED wxContourMainFrame_tool::Process start type=%d \n", bbGetInputType() ); // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -50,10 +50,8 @@ void wxContourMainFrame_tool::Process() // int y = param1[7]; int x = 0; int y = 0; - wxContourMainFrame::getInstance()->onDeleteAllContours(); wxContourMainFrame::getInstance()->onSegmentationAllSlices2(step ,isovalue ,sampling,method,x,y,minZ,maxZ, bbGetInputImage() ); - } else { printf("BBTK warnning!! wxContourMainFrame_tool box. In Type=1 the Param1 es not complite \n"); }// size @@ -93,6 +91,8 @@ void wxContourMainFrame_tool::Process() } // Type 3 } // if wxContourMainFrame::getInstance()!=NULL + printf("EED wxContourMainFrame_tool::Process end\n" ); + } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index 34b3d15..65cba57 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -61,6 +61,7 @@ char wxContourMainFrame::COPY = 'C'; : wxPanel(parent, id, pos, size, style) { m_mgr.SetManagedWindow(this); + _maxContoursByInstant = 1000; _contourGroup = 1; _creatingContoursActive = false; _theViewPanel = NULL; @@ -167,31 +168,31 @@ void wxContourMainFrame::configure(std::vector imgs) } wxContourMainFrame* wxContourMainFrame::getInstance(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector images, long style,std::string datadir ) - { +{ if(instance == NULL) { instance=new wxContourMainFrame(parent, id, title, pos, size, images, style,datadir); } return instance; - } +} std::vector wxContourMainFrame::getVectImages() - { +{ return kernelManager->getVectImages(); - } +} wxContourMainFrame* wxContourMainFrame::getInstance() - { +{ return instance; - } +} void wxContourMainFrame::resetInstance() - { +{ instance->Destroy(); - } +} wxContourMainFrame::~wxContourMainFrame() - { +{ delete _contourextractdata; deleteAllContours(); _pannew->Close(); @@ -212,8 +213,7 @@ wxContourMainFrame::~wxContourMainFrame() //EED???? delete _buttonsBar; //EED???? delete _actualInstant; //EED???? delete _sceneManager; - } - +} //------------------------------------------------------------------------------------------------------------ // Creational and initialization methods using WxAui @@ -227,7 +227,6 @@ wxContourMainFrame::~wxContourMainFrame() return noteBook; } - //------------------------------------------------------------------------------------------------------------ // Creational and initialization methods //------------------------------------------------------------------------------------------------------------ @@ -253,7 +252,6 @@ wxContourMainFrame::~wxContourMainFrame() return configured; } - bool wxContourMainFrame::addNewPanel(wxPanel* panel) { bool configured = panel!=NULL; @@ -270,9 +268,6 @@ wxContourMainFrame::~wxContourMainFrame() //------------------------------------------------------------------------------------------------------------ // Attributes getters and setters //------------------------------------------------------------------------------------------------------------ - - - void wxContourMainFrame :: setInstantChooserPanel( wxInstantChooserPanel * theInstantChooserPanel ) { _instantPanel = theInstantChooserPanel; @@ -318,8 +313,6 @@ wxContourMainFrame::~wxContourMainFrame() // _listViewPanel = theListViewPanel; // } - - void wxContourMainFrame::onCreateContourSpline( ){ //JCP 20-10-08 Undo redo implementation @@ -403,34 +396,43 @@ void wxContourMainFrame :: onCreateContourBullEye(wxPanel* panel ) void wxContourMainFrame::createContour( int typeContour ) { - //Creating the manualContourModel and including in the model - manualBaseModel * manModelContour = kernelManager->factoryManualContourModel(typeContour); std::vector instantVector; _instantPanel->getInstant( instantVector ); - std::vector tempVector; - getInstantVector( tempVector ); - manModelContour->SetLabel2( std::to_string(tempVector[1]) ); + std::vector lstOutlinesNames = kernelManager->getOutlinesNameAtInstant(instantVector); + int sizeLstOutlinesNames = lstOutlinesNames.size(); - std::string theName = kernelManager->createOutline(manModelContour, instantVector); - /*std::vector instantVector; - _instantPanel->getInstant( instantVector ); - std::string theName; - theName= _modelManager->createOutline( manModelContour, instantVector );*/ - bool addedModel = theName.compare("") != 0;//?? - if( addedModel ) - { - double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default - _theViewPanel->getSpacing(spc); - //Adding the manualContourControler to interface objects structure - //Adding the manualViewContour to interface objects structure - //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active. - _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ; - } // if addedModel + if (sizeLstOutlinesNames < _maxContoursByInstant) + { + + //Creating the manualContourModel and including in the model + manualBaseModel * manModelContour = kernelManager->factoryManualContourModel(typeContour); + + + std::vector tempVector; + getInstantVector( tempVector ); + manModelContour->SetLabel2( std::to_string(tempVector[1]) ); + + std::string theName = kernelManager->createOutline(manModelContour, instantVector); + /*std::vector instantVector; + _instantPanel->getInstant( instantVector ); + std::string theName; + theName= _modelManager->createOutline( manModelContour, instantVector );*/ + bool addedModel = theName.compare("") != 0;//?? + if( addedModel ) + { + double spc[3];//Si no hay imagen pero hay contornos que spacing se pone por default + _theViewPanel->getSpacing(spc); + //Adding the manualContourControler to interface objects structure + //Adding the manualViewContour to interface objects structure + //_sceneManager->setControlActiveStateOfALL( false );//This call is being done here because if the ROI is created underneath the previously created ROIS will still be active. + _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeContour) ; + } // if addedModel + } // if < maxContoursByInstant } -manualBaseModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){ - +manualBaseModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel) +{ manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye(); manualBaseModel *manModelContour=NULL; manModelContour = manModelContourBullEye; @@ -458,7 +460,6 @@ manualBaseModel * wxContourMainFrame::factoryManualContourModel(wxPanel* panel){ } // for iSector } // for iCrown } // if _panelBullEyeOptions - return manModelContour; } @@ -527,7 +528,7 @@ void wxContourMainFrame :: deleteContours( std::vector keyNamesVec for (i=0;i)_theViewPanel->getSceneManager()->GetlstContoursNameActualSlice() ); - } + void wxContourMainFrame::onDeleteAllContours(){ //JCP 20-10-08 Undo redo implementation saveState(); deleteAllContours(); } + void wxContourMainFrame::deleteAllContours(){ //JCP 20-10-08 Undo redo implementation @@ -631,20 +633,16 @@ void wxContourMainFrame::setConceptValue( std::string name, int value ) _instantPanel->setConceptValue(name, value); } - ConceptDataWrap* wxContourMainFrame::getLastConceptData() { return _instantPanel->getLastConceptData(); } - bool wxContourMainFrame::getIfConceptCheckedAt( std::string name, int pos ) { return _instantPanel->getIfConceptCheckedAt( name, pos ); } - - void wxContourMainFrame::ShowResultImages(int typeContourGroup, int selection, int minZ, int maxZ) { vtkImageData * mask; @@ -672,7 +670,6 @@ void wxContourMainFrame::ShowResultImages(int typeContourGroup, int selection, i wxPanel *panelViewer1 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, value,&nTypeView); wxPanel *panelViewer2 = new wxMaracas_N_ViewersWidget(noteBookViewerResult, mask,&nTypeView); - noteBookViewerResult->AddPage( panelViewer1, wxT("Image result") ); noteBookViewerResult->AddPage( panelViewer2, wxT("Mask result") ); m_mgr_noteBookViewerResult->Update(); @@ -680,9 +677,6 @@ void wxContourMainFrame::ShowResultImages(int typeContourGroup, int selection, i } // if _frameShowResultImages } - - - void wxContourMainFrame::changeInstant() { std::vector instantVect; @@ -714,13 +708,10 @@ void wxContourMainFrame::changeInstant() updateInstantAxes(); } - - void wxContourMainFrame::updateInstantOutlines() { _theViewPanel->removeSceneContours(); _theViewPanel->addNameWrapperToScene(); - //for( int i=0; igetSceneManager()->addToScene(namesWrapping[i]->getKeyName(), true, true, true, false, false ); @@ -3431,4 +3422,8 @@ void wxContourMainFrame::ResetCamera() GetWxVtkBaseView()->GetRenderer()->ResetCamera(); } +void wxContourMainFrame::SetMaxContoursByInstant(int max) +{ + _maxContoursByInstant = max; +} diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h index 56414a1..12e07e1 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h @@ -331,6 +331,8 @@ class wxContourMainFrame : public wxPanel { void SetXY(int x,int y); void ResetCamera(); + void SetMaxContoursByInstant(int max); + private: //------------------------------------------------------------------------------------------------------------ // Private methods @@ -415,7 +417,10 @@ private: //------------------------------------------------------------------------------------------------------------ wxFrame *_frameShowResultImages; - + +//EED 2025-01-01 + int _maxContoursByInstant; + }; #endif diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx index ea57095..9e7c9ab 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx @@ -716,12 +716,9 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) std::string name = wxContourMainFrame::getInstance()->getNameWrapping(i); _sceneManager->addToScene(name, true, true, true, false, false ); } // for i - _sceneManager->SetLabelNumberOfContours( "contours:"+std::to_string(size) ); - std::vector tempVector; wxContourMainFrame::getInstance()->getInstantVector( tempVector ); - if (_showBeforeContour==true) { size=0; @@ -742,7 +739,6 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) _sceneManager->addToScene(lstNameBefor[i], true, true, false, false, false ); } // for i } // if _before Contour - if (_showAfterContour==true) { size=0; diff --git a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx index 4a96eae..f0fa9d5 100644 --- a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx +++ b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx @@ -470,7 +470,8 @@ manualBaseModel *KernelManagerContour::factoryManualContourModel(int typeContour return manModelContour; } -std::vector KernelManagerContour::getOutlinesNameAtInstant(std::vector tempvector){ +std::vector KernelManagerContour::getOutlinesNameAtInstant(std::vector tempvector) +{ Instant instant(&tempvector); std::vector vectcont = modelManager->getOutlinesAtInstant( &instant ); std::vector vectname; @@ -481,11 +482,13 @@ std::vector KernelManagerContour::getOutlinesNameAtInstant(std::vec return vectname; } -std::vector KernelManagerContour::getOutlinesAtInstant(Instant* instant ){ +std::vector KernelManagerContour::getOutlinesAtInstant(Instant* instant ) +{ return modelManager->getOutlinesAtInstant(instant); } -std::vector KernelManagerContour::ExploseEachModel( std::vector lstManConMod ){ +std::vector KernelManagerContour::ExploseEachModel( std::vector lstManConMod ) +{ std::vector lstTmp; std::vector lstResult; int j,jSize; @@ -502,7 +505,8 @@ std::vector KernelManagerContour::ExploseEachModel( std::vecto return lstResult; } -void KernelManagerContour::getConceptsInformation(std::vector& conceptNameVect, std::vector& conceptSizeVect){ +void KernelManagerContour::getConceptsInformation(std::vector& conceptNameVect, std::vector& conceptSizeVect) +{ modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect); }