]> Creatis software - creaContours.git/commitdiff
Transform Roi
authordonadio <donadio>
Fri, 5 Jun 2009 17:30:16 +0000 (17:30 +0000)
committerdonadio <donadio>
Fri, 5 Jun 2009 17:30:16 +0000 (17:30 +0000)
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx

index a8734c04804d7caf2854568d71f51f36d7ff6870..b95f0c460aacfaf6c93af09b9b4cb37202d5f07c 100644 (file)
@@ -1049,7 +1049,7 @@ void wxContourMainFrame::openContours( FILE *pFile, int version )
 
        else if (compatible==false)
        {
-               wxDialog* dial = new wxDialog (this,-1,_T("Tools"),wxDefaultPosition, wxSize(250,160));
+               wxDialog* dial = new wxDialog (this,-1,_T("Tools"),wxDefaultPosition, wxSize(260,160));
                wxSizer* buttonsSizer = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
                wxBoxSizer *dialSizer = new wxBoxSizer(wxVERTICAL);
 
@@ -1058,7 +1058,7 @@ void wxContourMainFrame::openContours( FILE *pFile, int version )
                lstOptOperation[1]=_T("By Spacing");
                wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,45), 2 , lstOptOperation,  2, wxRA_SPECIFY_COLS);         
                
-               dialSizer->Add( new wxStaticText(dial,-1,_T("The actual image is not compatible with the "))  , 0, wxGROW );
+               dialSizer->Add( new wxStaticText(dial,-1,_T("The image resolution is not compatible with the "))  , 0, wxGROW );
                dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?"))  , 0, wxGROW );  
                dialSizer->Add( new wxStaticText(dial,-1,_T(" "))  , 0, wxGROW );               
                dialSizer->Add(radioOpts,0,wxGROW);
@@ -1068,69 +1068,86 @@ void wxContourMainFrame::openContours( FILE *pFile, int version )
                dial->Layout();
                dial->ShowModal();
                
+               int typeOfTransformation = -1;
+               bool transform = false;
+
                if (dial->GetReturnCode() == wxID_OK)
                {
                        int typeOfTransformation = radioOpts->GetSelection();
-                       
-                       int i;
-                       for (i=0;i<numberOfContours;i++)
-                       {
-                               instantVector.clear();
-                               fscanf(pFile,"%s",tmp); // Instant
-
-                               fscanf(pFile,"%s",tmp); // 1
-                               instantVector.push_back( atoi(tmp) );
-                               fscanf(pFile,"%s",tmp); // 2
-                               instantVector.push_back( atoi(tmp) );
-                               fscanf(pFile,"%s",tmp); // 3
-                               instantVector.push_back( atoi(tmp) );
-                               fscanf(pFile,"%s",tmp); // 4
-                               instantVector.push_back( atoi(tmp) );
-                               fscanf(pFile,"%s",tmp); // 5
-                               instantVector.push_back( atoi(tmp) );
-                               fscanf(pFile,"%s",tmp); // 6
-                               instantVector.push_back( atoi(tmp) );
-
-
-                               fscanf(pFile,"%s",tmp); // TypeContourModel
-                               fscanf(pFile,"%s",tmp); // ##
-                               typeContourModel = atoi(tmp);
-
-                               manModelContour =  kernelManager->factoryManualContourModel(typeContourModel);
+                       transform = true;
+
+               }
+       
+               int i;
+               for (i=0;i<numberOfContours;i++)
+               {
+                       instantVector.clear();
+                       fscanf(pFile,"%s",tmp); // Instant
+
+                       fscanf(pFile,"%s",tmp); // 1
+                       instantVector.push_back( atoi(tmp) );
+                       fscanf(pFile,"%s",tmp); // 2
+                       instantVector.push_back( atoi(tmp) );
+                       fscanf(pFile,"%s",tmp); // 3
+                       instantVector.push_back( atoi(tmp) );
+                       fscanf(pFile,"%s",tmp); // 4
+                       instantVector.push_back( atoi(tmp) );
+                       fscanf(pFile,"%s",tmp); // 5
+                       instantVector.push_back( atoi(tmp) );
+                       fscanf(pFile,"%s",tmp); // 6
+                       instantVector.push_back( atoi(tmp) );
+
+                       fscanf(pFile,"%s",tmp); // TypeContourModel
+                       fscanf(pFile,"%s",tmp); // ##
+                       typeContourModel = atoi(tmp);
+
+                       manModelContour =  kernelManager->factoryManualContourModel(typeContourModel);
+                       manModelContour->Open(pFile);
                                
+                       if (transform)
+                       {
                                if (typeOfTransformation==0)
                                {
-                                       manModelContour->OpenAndTransformDimension(pFile, imageDim, tempDim);
+                                       double transX, transY;
+                                       transX = (double) imageDim[0]/tempDim[0];
+                                       transY = (double) imageDim[1]/tempDim[1];
+
+                                       manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
                                }
+
                                else if (typeOfTransformation==1)
                                {
-                                       manModelContour->OpenAndTransformSpacing(pFile, imageSpac, tempSpac);
+                                       double transX, transY;
+                                       transX = (double) tempSpac[0]/imageSpac[0];
+                                       transY = (double) tempSpac[1]/imageSpac[1];
+
+                                       manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
                                }
+                       }
 
-                               fscanf(pFile,"%s",tmp); // TypeView
-                               fscanf(pFile,"%s",tmp); // ##
-                               typeView = atoi(tmp);  
+                       fscanf(pFile,"%s",tmp); // TypeView
+                       fscanf(pFile,"%s",tmp); // ##
+                       typeView = atoi(tmp);  
 
-                               std::string theName;
-                               theName = kernelManager->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           
-                                       //_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 (version==0) //StaticContours (will appear in all slices)
-                               {
-                                       Instant instant(&instantVector);
-                                       kernelManager->changeContourOfManager( theName , &instant );
-                               }
-                       }// for  numberOfContours       
-               }
+                       std::string theName;
+                       theName = kernelManager->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           
+                               //_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 (version==0) //StaticContours (will appear in all slices)
+                       {
+                               Instant instant(&instantVector);
+                               kernelManager->changeContourOfManager( theName , &instant );
+                       }
+               }// for  numberOfContours       
        }
 }