From: Eduardo DAVILA Date: Fri, 21 Jan 2022 16:03:09 +0000 (+0100) Subject: #3383 NDimension changeImage X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=cec3eb994e7ccd4a814559828e973166c2061c65;p=creaContours.git #3383 NDimension changeImage --- diff --git a/bbtk/src/bbCreaContournDimensions.cxx b/bbtk/src/bbCreaContournDimensions.cxx index c53e637..336a763 100644 --- a/bbtk/src/bbCreaContournDimensions.cxx +++ b/bbtk/src/bbCreaContournDimensions.cxx @@ -35,26 +35,35 @@ BBTK_BLACK_BOX_IMPLEMENTATION(nDimensions,bbtk::WxBlackBox); void nDimensions::Process() { - double **vectx = 0, **vecty = 0, **vectz = 0; - std::vector< void * > vectortemp; - std::vector size; - vtkImageData **mask = 0, **value = 0; - vtkImageData* img = bbGetInputIn(); - std::vector selectedimages; - if(img!=NULL && currentimg!=img) - { - wxContourMainFrame::getInstance()->ShowToolsPanel(true); - currentimg=img; - selectedimages.push_back(img); - wxContourMainFrame::getInstance()->configure(selectedimages); - } // if img - - if(currentimg != NULL) - { - int contourtype = bbGetInputContourType(); - //wxContourMainFrame::getInstance()->getValuesXYZ(vectx, vecty, vectz, &size); - //wxContourMainFrame::getInstance()->getMaskValue(mask, value, contourtype); - } // if currentimg +// double **vectx = 0, **vecty = 0, **vectz = 0; +// std::vector< void * > vectortemp; +// std::vector size; +// vtkImageData **mask = 0, **value = 0; + + if (firsttime==true) + { + firsttime=false; + std::vector selectedimages; + if(bbGetInputIn()!=NULL) + { + currentimg = bbGetInputIn(); + selectedimages.push_back( bbGetInputIn() ); + wxContourMainFrame::getInstance()->ShowToolsPanel(true); + wxContourMainFrame::getInstance()->configure(selectedimages); + } // 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() ); // bbSetOutputX(vectx); @@ -108,7 +117,8 @@ printf("EED WARNING Verify that GetDllAppPath in nDimensions::CreateWidget bbCr //----------------------------------------------------------------- void nDimensions::bbUserSetDefaultValues() { - currentimg=NULL; + firsttime = true; + currentimg = NULL; bbSetInputContourType(0); bbSetInputIn(NULL); } diff --git a/bbtk/src/bbCreaContournDimensions.h b/bbtk/src/bbCreaContournDimensions.h index 616a70c..dbd6e6e 100644 --- a/bbtk/src/bbCreaContournDimensions.h +++ b/bbtk/src/bbCreaContournDimensions.h @@ -68,6 +68,7 @@ class /*BBTK_EXPORT*/ nDimensions private: //wxContourMainFrame* frame; vtkImageData* currentimg; + bool firsttime; //wxContourEventHandler * eventHandler; }; diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx index c50fa9b..3961f40 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx @@ -131,6 +131,16 @@ char wxContourMainFrame::COPY = 'C'; _contourextractdata = NULL; } + +void wxContourMainFrame::changeImage(int id, vtkImageData *img) +{ + if ( id<_images.size() ) _images[id]=img; + kernelManager->changeImage(id,img); + _theViewPanel->changeImage(img); +// updateInstantImageData(); + +} + void wxContourMainFrame::configure(std::vector imgs) { _images = imgs; @@ -734,7 +744,6 @@ void wxContourMainFrame::updateInstantImageData() { std::vector inst; _instantPanel->getInstant(inst); - vtkImageData* img = kernelManager->getImageAtInstant(inst); if(img!=NULL) { @@ -894,7 +903,6 @@ void wxContourMainFrame::SetZForAllContours(int pz) sizeLstNameThings = lstNameThings.size(); for (i=0 ; igetOutlineByKeyName(lstNameThings[i]); sizeLstPoints = manualModel->GetSizeLstPoints(); for (ii=0 ; iiGetDimensions(dimRange); - fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] ); - double spaRange[3]; image->GetSpacing(spaRange); - fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] ); - // Normal Contours - lstNameThings = kernelManager->GetLstNameThings(); sizeLstNameThings = lstNameThings.size(); fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings ); - //CMRU 03-09-09----------------------------------------------------------------------------------------------- fprintf(pFileData,"NumberOfContours %d\n", sizeLstNameThings ); //------------------------------------------------------------------------------------------------------------ - - // EED 2017-05-30 double spc[3]; spc[0]=1; spc[1]=1; - spc[2]=1; - + spc[2]=1; for (i=0 ; igetOutlineByKeyName(lstNameThings[i]); - // EED 2017-05-30 // double sizeInPixel = manualModel ->GetPathSize( ); double sizeInPixel = manualModel ->GetPathSize( spc ); - double realContourSize = sizeInPixel*_onePixelSize; manualModel ->SetRealSize(realContourSize); //------------------------------------------------------------------------------------------------------------ - //int size= kernelManager->GetLstNameThings().size(); - kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] ); _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] ); }// for i - //-- Static Contours - // fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] ); // fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] ); - lstNameThings = kernelManager->GetLstNameThingsStatic(); sizeLstNameThings = lstNameThings.size(); fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings ); - //CMRU 03-09-09----------------------------------------------------------------------------------------------- fprintf(pFileData,"NumberOfContoursStatic %d\n", sizeLstNameThings ); //------------------------------------------------------------------------------------------------------------ - for (i=0 ; iSaveThingName( pFile, pFileData, lstNameThings[i] ); @@ -1740,10 +1727,6 @@ void wxContourMainFrame::onSegmentationOneSlice(int isovalue,int sampling,int me void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method ) { - -//printf("EED wxContourMainFrame::SegmentationOneSlice Start=%d %d\n",sampling,method ); -//printf("EED wxContourMainFrame::SegmentationOneSlice %d %d %d \n",x,y,z ); - int typeofcontour = 1; //--Extracting Contour vtkImageData *imagedata = getImageData(); @@ -2234,7 +2217,6 @@ int wxContourMainFrame::getWindowLevel() void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel) { _theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel); - RefreshInterface(); } @@ -3087,7 +3069,6 @@ void wxContourMainFrame::onSnakePressed(){ void wxContourMainFrame::saveFileWithContoursAutomatique() { -printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n"); std::string filename = kernelManager->getCurrentFileName(); if(filename.compare("")!=0){ saveFileWithContours(filename); @@ -3095,22 +3076,19 @@ printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n"); onSave(); } } + void wxContourMainFrame::ShowToolsPanel(bool show) { _pannew->Show(show); } - - void wxContourMainFrame::SetContourGroup(int contourGroup) { _contourGroup = contourGroup; } - wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent) { - if (_viewMaskImagePanel==NULL) { _contourextractdata = new ContourExtractData(true); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h index eabf81e..7c62375 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h @@ -132,7 +132,8 @@ class wxContourMainFrame : public wxPanel { //------------------------------------------------------------------------------------------------------------ // Creational and initialization methods //------------------------------------------------------------------------------------------------------------ - void configure(std::vector imgs); + void changeImage(int id, vtkImageData *img); + void configure(std::vector imgs); bool configurePanels( ); bool addNewPanel(wxPanel* panel); wxAuiNotebook * createNotebook(); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx index 85952db..e8eca00 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx @@ -185,20 +185,17 @@ DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) numViews->push_back(0); theViewPanel = new wxMaracas_N_ViewersWidget( this, showingVID, numViews ); SetVisibleAxis(false); - theViewPanel->SetBackgroundColour(wxColour(0,0,0)); - theViewPanel->SetSize(800,600); theViewPanel->GetWindow(1)->SetSize(800,600); - } //------------------------------------------------------------------------------------------------------------ - void wxContourViewPanel::changeImage(vtkImageData* img){ - + void wxContourViewPanel::changeImage(vtkImageData* img) + { theViewPanel->SetImage(img); - } + wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView() { return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1)); diff --git a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h index 1ea6f26..065908b 100644 --- a/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h +++ b/lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h @@ -357,26 +357,18 @@ private: double last_spacing[3]; bool _useVerticalBar; bool _useHorizontalBar; - wxEvtHandler *_eventHandler; bool _showBeforeContour; bool _showAfterContour; //EED - //------------------------------------------------------------------------------------------------------------ // Private methods //------------------------------------------------------------------------------------------------------------ - - - wxVtkMPR2DView *GetwxVtkMPR2DView(); - - // DECLARE_CLASS(wxContourViewPanel) // any class wishing to process wxWindows events must use this macro //DECLARE_EVENT_TABLE() - }; #endif // __wxContour_ViewPanel__ diff --git a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx index 5671ae0..4a96eae 100644 --- a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx +++ b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx @@ -91,6 +91,23 @@ std::vector KernelManagerContour::getVectImages() return vectimages; } +void KernelManagerContour::changeImage(int id, vtkImageData *img) +{ + if ( id vectspc; + img->GetSpacing(spc); + vectspc.push_back(spc[0]); + vectspc.push_back(spc[1]); + vectspc.push_back(spc[2]); + vectimagesSpacing[id]=vectspc; + std::string imgstring = "Source Image "+intToString(id+1); + ImageSourceThing *imagesourcething = modelManager->getImageSourceThingByKeyName( imgstring ); + imagesourcething->setSourceImage( img ); +} void KernelManagerContour::setVectImages(std::vector vectimg) { @@ -489,14 +506,12 @@ void KernelManagerContour::getConceptsInformation(std::vector& conc modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect); } - vtkImageData* KernelManagerContour::getImageAtInstant(std::vector inst) { int index = inst[5]-1; - if(index < (int)(vectimages.size())&&index!=_currentIndex) { - _currentIndex=index; + _currentIndex = index; return vectimages[index]; } return NULL; @@ -514,29 +529,20 @@ void KernelManagerContour::setCurrentFileName(std::string filenam) std::string KernelManagerContour::parseOsirixFile(std::string filename) { - - #ifdef ParserOsirix_BUILD vtkImageData* sourceimage; std::string xsdfile; - xsdfile = _datadir; - xsdfile.append("\\XML\\osirixschema.xsd"); - sourceimage = getSourceImage(); OsirixParser p(xsdfile.c_str(), sourceimage->GetSpacing(), sourceimage->GetExtent()); - - if(p.ParseFile(filename.c_str())!= 0){ - + if(p.ParseFile(filename.c_str())!= 0) + { } - return p.getContoursFileName(); #else return ""; #endif - - } diff --git a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.h b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.h index 029ecd9..6fd61ce 100644 --- a/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.h +++ b/lib/kernel_ManagerContour_NDimensions/KernelManagerContour.h @@ -57,7 +57,6 @@ class KernelManagerContour{ // Constructors & Destructors //------------------------------------------------------------------------------------------------------------ public: - /** ** With this constructor the setVectImages and initialize environment must be called **/ @@ -68,78 +67,45 @@ public: **/ KernelManagerContour(std::vector images,std::string datadir,std::string tmpdir); ~KernelManagerContour(); - std::vector getVectImages(); - void setVectImages(std::vector vectimg); - + void changeImage(int id, vtkImageData *img); + void setVectImages(std::vector vectimg); void GetSpacing(double *vecspc, int iImage); - - /** ** This method returns the source of the image data selected by the user. */ vtkImageData* getSourceImage(); - - - void initializeEnvironment(std::string datadir); - - /** ** This methods connect the event in the class interfNewContourMenu with the world of the appli **/ - std::string createOutline(manualBaseModel * manModelContour,std::vector instantVector); ///////////////////////////////// - std::string intToString(int num); - std::vector GetLstNameThingsStatic(); - void SaveThingName(FILE* pFile, FILE *pFileData, std::string name ); - std::vector GetLstNameThings(); - bool IsPartOfStaticList(std::string keyName ); - void deleteCModel(std::string theKeyName); - void removeAllOutlines(); - //void setInstance(theInstant); - std::vector getActualInstantOutlines(); - int getNamesWrappingSize(); - std::string getNameWrapping(int i); - void setInstant(Instant* theInstant); void setInstant(std::vector vectInstant); std::string createCopyContourOf ( std::string anExistingKName, std::vector &instantNoTouchData); - Instant * getCurrentInstant(); - manualBaseModel* getOutlineByKeyName(std::string cloneName); - bool onRedo(std::string& filename); - bool onUndo(std::string& filename); - bool onUndoSaveFile(std::string& filename); - std::string saveState(); - void changeContourOfManager(std::string keyName, Instant *instant); - void resetAppend(); - std::string onSpreadAdd( std::vector *vecX, std::vector *vecY, std::vector *vecZ, std::vector instants); - void getMaxMinZ(double *minZ,double *maxZ); - manualBaseModel* GetPoints(int z,int type, std::vector* vecCtrlPointX,std::vector* vecCtrlPointY,std::vector* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector tempVector); - // // Method which creates the model associated with the type in parameter. The possible contour types are: // 0-spline @@ -154,18 +120,11 @@ public: // @param typeContour - int // @return manualBaseModel - Model created based on the type manualBaseModel* factoryManualContourModel(int typeContour); - void CalculeSplinePropagation(); - std::vector getOutlinesNameAtInstant(std::vector tempvector); - std::vector getOutlinesAtInstant(Instant* instant ); - std::vector ExploseEachModel( std::vector lstManConMod ); - - void getConceptsInformation(std::vector& conceptNameVect, std::vector& conceptSizeVect); - vtkImageData* getImageAtInstant(std::vector inst); //------------------------------------------------------------------------------------------------------------ @@ -174,7 +133,6 @@ public: void setCurrentFileName(std::string filenam); std::string getCurrentFileName(); - std::string parseOsirixFile(std::string filename); private: //------------------------------------------------------------------------------------------------------------ @@ -182,23 +140,17 @@ private: //------------------------------------------------------------------------------------------------------------ std::vector vectimages; std::vector > vectimagesSpacing; - ImageSourceThing *imageSource; - //Instant * _actualInstant; //Temporary attribute should be removed OutlineModelManager *modelManager; - std::string filename; - int inredo; int inundo; int _currentIndex; std::string stundoredo; std::string _datadir; - ContourPropagation *_contourPropagation; - OutlineModelManager *getOutlineModelManager(); }; #endif