]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
*** empty log message ***
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index 7d2b6948bca4bda0f50ace80c3aa2154452aac8e..89f6c39f741d38bc0ee2f9cefcff02aec367c6c9 100644 (file)
@@ -99,7 +99,6 @@ char wxContourMainFrame::COPY = 'C';
 
                if(images.size() > 0)
                {
-                       
                        this->setVectImages(images);
                }
 
@@ -109,6 +108,7 @@ void wxContourMainFrame::setVectImages(std::vector<vtkImageData*> imgs)
 {
 
        _images = imgs;
+
        #if defined(__GNUC__)
                std::string str_home(getenv("HOME"));
        #elif defined(_WIN32)
@@ -756,43 +756,21 @@ void wxContourMainFrame ::loadState(std::string filename){
 
        fscanf(pFile,"%s",tmp); // Version
        fscanf(pFile,"%s",tmp); // 1.0.2 || 1.0.1 || 1.0.0
-       std::string version(tmp);
 
        deleteAllContours();
 
-       //AD:02-06-09
-       if (version=="1.0.2")
-       {
-               loadContours(pFile);
-       }
-       
-       //AD:02-06-09
-       else if (version=="1.0.1")
-       {
-               loadContours(pFile);
-       }
-       
-       //AD:02-06-09
-       else if (version=="1.0.0")
-       {
-               loadContours(pFile);
-       }
+       loadContours(pFile, false);
+       loadContours(pFile, true);      
 
        fclose(pFile);
 }
 
-void wxContourMainFrame ::loadContours( FILE *pFile )
+void wxContourMainFrame ::loadContours( FILE *pFile, bool staticContour )
 {
        char tmp[255];
-       fscanf(pFile,"%s",tmp); // NumberOfContours 
-       fscanf(pFile,"%s",tmp); // ##
-       int numberOfContours = atoi(tmp);  
 
-       std::vector<int> instantVector;
-       int typeContourModel;
-       manualContourModel *manModelContour;
-       int typeView;
-       
+       if (staticContour==false)
+       {
        fscanf(pFile,"%s",tmp); // ImageDimensions
        fscanf(pFile,"%s",tmp); // X
        fscanf(pFile,"%s",tmp); // Y
@@ -802,6 +780,16 @@ void wxContourMainFrame ::loadContours( FILE *pFile )
        fscanf(pFile,"%s",tmp); // X
        fscanf(pFile,"%s",tmp); // Y
        fscanf(pFile,"%s",tmp); // Z
+       }
+       
+       fscanf(pFile,"%s",tmp); // NumberOfContours 
+       fscanf(pFile,"%s",tmp); // ##
+       int numberOfContours = atoi(tmp);  
+
+       std::vector<int> instantVector;
+       int typeContourModel;
+       manualContourModel *manModelContour;
+       int typeView;
 
        int i;
        for (i=0;i<numberOfContours;i++)
@@ -844,6 +832,12 @@ void wxContourMainFrame ::loadContours( FILE *pFile )
                        //_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.
                        _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
                }       
+               
+               if (staticContour==true)
+               {
+                       Instant instant(&instantVector);
+                       kernelManager->changeContourOfManager( theName , &instant );
+               }
        }// for  numberOfContours
 }
 
@@ -865,19 +859,21 @@ void wxContourMainFrame::onLoad()
                //AD:02-06-09
                if (version=="1.0.2")
                {
-                       openContours(pFile,2);
+                       openContours(pFile,2,false);
+                       openContours(pFile,2,true);     //Load StaticContours
                }
                
                //AD:02-06-09
                else if (version=="1.0.1")
                {
-                       openContours(pFile,1);
+                       openContours(pFile,1,false); //Skips ImageDimensions and ImageSpacing
+                       openContours(pFile,1,true); //Load StaticContours, skips ImageDimensions and ImageSpacing
                }
                
                //AD:02-06-09
                else if (version=="1.0.0")
                {
-                       openContours(pFile,0);
+                       openContours(pFile,1,false); //Skips ImageDimensions and ImageSpacing
                }
 
                fclose(pFile);
@@ -907,12 +903,7 @@ void wxContourMainFrame::saveFileWithContours( std::string filename )
 
        fprintf(pFile,"--CreaContour--\n");
        fprintf(pFile,"Version %s\n", "1.0.2" );
-
-       // Normal Contours
-       lstNameThings           = kernelManager->GetLstNameThings();
-       sizeLstNameThings       = lstNameThings.size(); 
-       fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
-
+       
        vtkImageData *image = _images[0];
 
        int dimRange[3];
@@ -925,13 +916,24 @@ void wxContourMainFrame::saveFileWithContours( std::string filename )
 
        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 );
+
        for (i=0 ; i<sizeLstNameThings ; i++) 
        {
                kernelManager->SaveThingName( pFile, lstNameThings[i] );
                _theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
        }// for i
 
-       //-- Contours Statics 
+       //-- 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 );
@@ -944,18 +946,10 @@ void wxContourMainFrame::saveFileWithContours( std::string filename )
 }
 
 //AD:04-06-09
-void wxContourMainFrame::openContours( FILE *pFile, int version )
+void wxContourMainFrame::openContours( FILE *pFile, int version, bool staticContour )
 {
        char tmp[255];
-       fscanf(pFile,"%s",tmp); // NumberOfContours 
-       fscanf(pFile,"%s",tmp); // ##
-       int numberOfContours = atoi(tmp);  
-
-       std::vector<int> instantVector;
-       int typeContourModel;
-       manualContourModel *manModelContour;
-       int typeView;
-
+       
        vtkImageData *image = _images[0];
        int imageDim[3];
        double imageSpac[3];
@@ -986,12 +980,21 @@ void wxContourMainFrame::openContours( FILE *pFile, int version )
                fscanf(pFile,"%s",tmp); // Z
                tempSpac[2] = atof(tmp);
                
-               //Compare Spacing and Dims in X and Y (Necessary in Z?) - Just for Version 3
+               //Compare Spacing and Dims in X and Y (Necessary in Z?) - Just for Version 2
                if (imageDim[0]!=tempDim[0] || imageDim[1]!=tempDim[1] || imageSpac[0]!=tempSpac[0] || imageSpac[1]!=tempSpac[1])
                {
                        compatible = false;
                }
        }
+       
+       fscanf(pFile,"%s",tmp); // NumberOfContours 
+       fscanf(pFile,"%s",tmp); // ##
+       int numberOfContours = atoi(tmp);  
+
+       std::vector<int> instantVector;
+       int typeContourModel;
+       manualContourModel *manModelContour;
+       int typeView;
 
        if (compatible==true)
        {
@@ -1039,7 +1042,7 @@ void wxContourMainFrame::openContours( FILE *pFile, int version )
                                _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
                        }       
 
-                       if (version==0) //StaticContours (will appear in all slices)
+                       if (staticContour) //StaticContours (will appear in all slices)
                        {
                                Instant instant(&instantVector);
                                kernelManager->changeContourOfManager( theName , &instant );
@@ -1139,7 +1142,7 @@ void wxContourMainFrame::openContours( FILE *pFile, int version )
                                _theViewPanel->getSceneManager()->configureViewControlTo( theName, manModelContour,spc , typeView) ;
                        }       
 
-                       if (version==0) //StaticContours (will appear in all slices)
+                       if (staticContour) //StaticContours (will appear in all slices)
                        {
                                Instant instant(&instantVector);
                                kernelManager->changeContourOfManager( theName , &instant );