]> Creatis software - creaContours.git/commitdiff
#3383 NDimension changeImage
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 21 Jan 2022 16:03:09 +0000 (17:03 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 21 Jan 2022 16:03:09 +0000 (17:03 +0100)
bbtk/src/bbCreaContournDimensions.cxx
bbtk/src/bbCreaContournDimensions.h
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h
lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx
lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h
lib/kernel_ManagerContour_NDimensions/KernelManagerContour.cxx
lib/kernel_ManagerContour_NDimensions/KernelManagerContour.h

index c53e63787fbe754b63256fd65eda03cc327366d1..336a7637b53964296a4f5c239c662f6fe72dc369 100644 (file)
@@ -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<int> size;
-       vtkImageData **mask = 0, **value = 0;
-       vtkImageData* img = bbGetInputIn();
-       std::vector<vtkImageData*> 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<int> size;
+//        vtkImageData **mask = 0, **value = 0;
+
+    if (firsttime==true)
+    {
+        firsttime=false;
+        std::vector<vtkImageData*> 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);
 }
index 616a70ccd8c06e2635cf4f77fcfb7beab8e78b1f..dbd6e6e20f3f0d04bef5ded590cc319b249cbf56 100644 (file)
@@ -68,6 +68,7 @@ class /*BBTK_EXPORT*/ nDimensions
 private:
        //wxContourMainFrame* frame;
        vtkImageData* currentimg;
+    bool firsttime;
        //wxContourEventHandler * eventHandler;
 };
 
index c50fa9b4f3356b0f3c2aa4548369f7e37b9754de..3961f40d8aedb16ddd4220f21bcdfc18d447cb66 100644 (file)
@@ -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<vtkImageData*> imgs)
 {
        _images = imgs;
@@ -734,7 +744,6 @@ void wxContourMainFrame::updateInstantImageData()
 {
        std::vector<int> 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 ; i<sizeLstNameThings ; i++)
        {
-printf("EED wxContourMainFrame::SetZForAllContours contour=%d \n", i );
                manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
                sizeLstPoints = manualModel->GetSizeLstPoints();
                for (ii=0 ; ii<sizeLstPoints ; ii++)
@@ -1066,70 +1074,49 @@ void wxContourMainFrame::saveFileWithContours( std::string filename )
        fprintf(pFileData,"--CreaContour--\n");
        fprintf(pFileData,"Version %s\n", "1.0.3" );
        fprintf(pFileData,"OnePixelSize %f\n", _onePixelSize);
-
 //------------------------------------------------------------------------------------------------------------
-
        vtkImageData *image = _images[0];
-
        int dimRange[3];
        image->GetDimensions(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 ; i<sizeLstNameThings ; i++)
        {
 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
                manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(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 ; i<sizeLstNameThings ; i++)
        {
                kernelManager->SaveThingName( 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);
index eabf81e44f1967fece7939429d95e1fcaa3a7e83..7c6237531a89240e1e89d660f6bd617f27278114 100644 (file)
@@ -132,7 +132,8 @@ class wxContourMainFrame : public wxPanel {
        //------------------------------------------------------------------------------------------------------------
        // Creational and initialization methods
        //------------------------------------------------------------------------------------------------------------
-       void configure(std::vector<vtkImageData*> imgs);
+    void changeImage(int id, vtkImageData *img);
+    void configure(std::vector<vtkImageData*> imgs);
        bool configurePanels( );
        bool addNewPanel(wxPanel* panel);
        wxAuiNotebook * createNotebook();
index 85952db7722110586daf1ed22d76099a95e6f558..e8eca002e5f3e8844f9488b72897a30425799e9c 100644 (file)
@@ -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));
index 1ea6f2679af5a1a94340fc6952cd9ba0aa97d610..065908bcbc6640454b578507439ba619580977b6 100644 (file)
@@ -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__
 
index 5671ae0e6a204767b5a24c7e99d77f8819614f23..4a96eae2505cb2f510c1575b14bb4a5e088d9a76 100644 (file)
@@ -91,6 +91,23 @@ std::vector<vtkImageData*> KernelManagerContour::getVectImages()
        return vectimages;
 }
 
+void KernelManagerContour::changeImage(int id, vtkImageData *img)
+{
+    if ( id<vectimages.size() )
+    {
+        vectimages[id]=img;
+    }
+    double spc[3];
+    std::vector<double> 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<vtkImageData*> vectimg)
 {
@@ -489,14 +506,12 @@ void KernelManagerContour::getConceptsInformation(std::vector<std::string>& conc
        modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect);
 }
 
-
 vtkImageData* KernelManagerContour::getImageAtInstant(std::vector<int> 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
-
-
 }
 
 
index 029ecd9a6ec1c21027028ce7f0f641cd7080a3ad..6fd61ce41519791247b374f83ffc84dc272c1694 100644 (file)
@@ -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<vtkImageData*> images,std::string datadir,std::string tmpdir);
        ~KernelManagerContour();
-
        std::vector<vtkImageData*> getVectImages();
-       void setVectImages(std::vector<vtkImageData*> vectimg);
-
+    void changeImage(int id, vtkImageData *img);
+    void setVectImages(std::vector<vtkImageData*> 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<int> instantVector);
        /////////////////////////////////
-
        std::string intToString(int num);
-
        std::vector<std::string> GetLstNameThingsStatic();
-
        void SaveThingName(FILE* pFile, FILE *pFileData, std::string name );
-
        std::vector<std::string> GetLstNameThings();
-
        bool IsPartOfStaticList(std::string keyName );
-
        void deleteCModel(std::string theKeyName);
-
        void removeAllOutlines();
-
        //void setInstance(theInstant);
-
        std::vector<NameWrapper *> getActualInstantOutlines();
-
        int getNamesWrappingSize();
-
        std::string getNameWrapping(int i);
-
        void setInstant(Instant* theInstant);
        void setInstant(std::vector<int> vectInstant);
        std::string createCopyContourOf ( std::string anExistingKName, std::vector<int> &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<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ, std::vector<int> instants);
-
        void getMaxMinZ(double *minZ,double *maxZ);
-
        manualBaseModel* GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> 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<std::string> getOutlinesNameAtInstant(std::vector<int> tempvector);
-
        std::vector<ContourThing**> getOutlinesAtInstant(Instant* instant );
-
        std::vector<manualBaseModel*> ExploseEachModel( std::vector<manualBaseModel*> lstManConMod );
-
-
        void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect);
-
        vtkImageData* getImageAtInstant(std::vector<int> 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<vtkImageData*>                              vectimages;
        std::vector<std::vector<double> >               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