]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
no message
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index 7017b47744d204e1472a795fb877356bad65c384..277a87a0a19ab8134f1543f79c4c2fc46fad0cd4 100644 (file)
@@ -835,10 +835,10 @@ void wxContourMainFrame :: createMirrorContourOf ( std::string anExistingKName,
 
 //EED04
 void wxContourMainFrame ::loadState(std::string filename){
-       
+
        deleteAllContours();
        onLoadContours(filename,false);
-       
+
        /* EED Borrame
        char tmp[255];
        FILE *pFile=fopen(filename.c_str(),"r+");
@@ -997,7 +997,7 @@ void wxContourMainFrame::onLoadContours(std::string fileNameContourROI, bool int
                        openContours(pFile,pFileData,false);
                        openContours(pFile,pFileData,true);     //Load StaticContours
                }
-               
+
                if (version=="1.0.2")
                {
 //EED001
@@ -1224,7 +1224,7 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption)
                        dial->ShowModal();
 
                        int _tmpReadFileTypeOfTransformation = -1;
-                       bool transform = false;
+//EED                  bool transform = false;
 
                        if (dial->GetReturnCode() == wxID_OK)
                        {
@@ -2300,32 +2300,67 @@ void wxContourMainFrame::onChangeInstant(std::string name,int actual){
        _instantPanel->setConceptValue( name, actual );
 }
 
+
 void wxContourMainFrame::resetAppend(){
        kernelManager->resetAppend();
 
 }
 
+
 void wxContourMainFrame::onSpreadAdd(){
        std::vector<double> vecX;
        std::vector<double> vecY;
        std::vector<double> vecZ;
        _theViewPanel->GetPointsOfActualContour(&vecX , &vecY , &vecZ );
-
        std::vector<int> tempVector;
        _instantPanel->getInstant( tempVector );
-
        std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
-
        interfMainPanel::getInstance()->appendStringSpread(val);
+}
+
 
+void wxContourMainFrame::onSpreadAddAll(){
+//EED02
+       std::vector<int> tempVector;
+       _instantPanel->getInstant( tempVector );
+       int minZ,maxZ;
+    minZ       = 0;
+    maxZ       = interfMainPanel::getInstance()->GetImageDataSizeZ();
+       int z;
+       int sizeLstContourThings;
+       for ( z=minZ ; z<=maxZ ; z++ )
+       {
+               tempVector[1]=z;
+               Instant instant(&tempVector);
+               std::vector<ContourThing**> lstContourThings = kernelManager->getOutlinesAtInstant( &instant );
+               sizeLstContourThings = lstContourThings.size();
+               if (sizeLstContourThings>=1)
+        {
+            std::vector<double> vecX;
+            std::vector<double> vecY;
+            std::vector<double> vecZ;
+            ContourThing **contourthing = lstContourThings[0];
+                       manualBaseModel *cModel                         =  (*contourthing)->getModel();
+                       int i,size = cModel->GetNumberOfPointsSpline();
+                       double x,y,z;
+                       for (i=0; i<size; i++)
+                       {
+                               cModel->GetSpline_i_Point(i, &x, &y, &z);
+                               vecX.push_back(x);
+                               vecY.push_back(y);
+                               vecZ.push_back(z);
+                       } // for i
+            std::string val = kernelManager->onSpreadAdd(&vecX , &vecY , &vecZ, tempVector);
+            interfMainPanel::getInstance()->appendStringSpread(val);
+        }// if sizeLstContourThings
+    } // for z
 }
 
-void wxContourMainFrame::onSpreadGo(int type){
 
+void wxContourMainFrame::onSpreadGo(int type){
        //JCP 20-10-08 Undo redo implementation
        saveState();
        //JCP 20-10-08 Undo redo implementation
-
        wxBusyCursor wait;
        std::vector<double> vecCtrlPointX;
        std::vector<double> vecCtrlPointY;
@@ -2947,44 +2982,41 @@ void wxContourMainFrame::getMaskValue(vtkImageData ** mask,vtkImageData ** value
 void wxContourMainFrame::SaveImageResult(std::string directory,std::string namefile, vtkImageData* mask,vtkImageData* value)
 {
 
-       std::string temp = directory + "/" + namefile + "-Value.mhd";
+       double spc[3];
+       kernelManager->GetSpacing(spc,0);   // returns the spacing of the first image
+       
+       std::string temp = directory + "/" + namefile + "-image-Value.mhd";
 
        wxString filename = crea::std2wx(temp);
-       // LG
-       //      filename.Printf(_T(temp.c_str()));
-       //filename.Printf(_T("%s\\%s-Value.mhd",directory.c_str(),namefile.c_str(),z);
-       /*filename.Printf(_T("%s"),directory.c_str());
-       filename.append(_T("\\"));
-       filename.append(_T("%s"),namefile.c_str());
-       filename.append(_T("-Value.mhd"));*/
 
 // Image Value
+       
+       vtkImageChangeInformation *valueChInfo = vtkImageChangeInformation::New();
+       valueChInfo->SetInput(value);
+       valueChInfo->SetSpacingScale(spc);      
        vtkMetaImageWriter *writerValueImage = vtkMetaImageWriter::New( );
-       writerValueImage->SetInput( value );
-       writerValueImage->SetInput( value );
+       writerValueImage->SetInput( valueChInfo->GetOutput() );
        writerValueImage->SetFileName( (const char *)filename.mb_str() );
        writerValueImage->SetFileDimensionality( 3 );
        writerValueImage->SetCompression(false);
        writerValueImage->Write( );
 
 // Image Mask
-       //              filename.Printf("%s\\%s-Mask.mhd",directory.c_str(),namefile.c_str(),z);
-       temp = directory + "/" + namefile + "-Mask.mhd";
+       temp = directory + "/" + namefile + "-image-Mask.mhd";
 
        // LG 14/01/09 : using crea
        filename = crea::std2wx(temp);
        //      filename.Printf(_T(temp.c_str()));
 
-       /*filename.Printf(_T("%s"),directory.c_str());
-       filename.append(_T("\\"));
-       filename.append(_T("%s"),namefile.c_str());
-       filename.append(_T("-Mask.mhd"));*/
 
+       vtkImageChangeInformation *maskChInfo = vtkImageChangeInformation::New();
+       maskChInfo->SetInput(mask);
+       maskChInfo->SetSpacingScale(spc);       
        vtkMetaImageWriter *writerMaskImage = vtkMetaImageWriter::New( );
-       writerMaskImage->SetInput( mask );
+       writerMaskImage->SetInput( maskChInfo->GetOutput() );
        writerMaskImage->SetFileName( (const char *)filename.mb_str() );
        writerMaskImage->SetFileDimensionality( 3 );
-       writerValueImage->SetCompression(false);
+       writerMaskImage->SetCompression(false);
        writerMaskImage->Write( );
 
        interfMainPanel::getInstance()->setStringInfoPanel( _T("") );