]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
#3381 Clean Code Segmentation VTK
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index 1ce584994fc26d25f27de8c341be8249d293c964..6e93fadb4224064ba277a8404199059646aae5ef 100644 (file)
@@ -1177,10 +1177,11 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption)
 //                     wxBoxSizer              *dialSizer = new wxBoxSizer(wxVERTICAL);
                        wxFlexGridSizer *dialSizer = new wxFlexGridSizer(1);
 
-                       wxString lstOptOperation[2];
-                       lstOptOperation[0]=_T("By Dimension");
-                       lstOptOperation[1]=_T("By Spacing");
-                       wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,90), 2 , lstOptOperation,  2, wxRA_SPECIFY_COLS);
+                       wxString lstOptOperation[3];
+                       lstOptOperation[0]=_T("By Dimension (XY)");
+                       lstOptOperation[1]=_T("By Spacing   (XY)");
+                       lstOptOperation[2]=_T("By Spacing   (XYZ)");
+                       wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(370,200), 3 , lstOptOperation,  3, wxRA_SPECIFY_ROWS);
 
                        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 );
@@ -1192,7 +1193,7 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption)
                        dial->Layout();
                        dial->ShowModal();
 
-                       int _tmpReadFileTypeOfTransformation = -1;
+                       _tmpReadFileTypeOfTransformation = -1;
 //EED                  bool transform = false;
 
                        if (dial->GetReturnCode() == wxID_OK)
@@ -1210,7 +1211,7 @@ void wxContourMainFrame::readDimSpc(FILE *pFile, bool interactiveOption)
 //AD:04-06-09
 void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool staticContour )
 {
-
+printf ("EED wxContourMainFrame::openContours Start \n");
        char tmp[255];
 
        vtkImageData    *image = _images[0];
@@ -1328,14 +1329,22 @@ void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool static
                 //nothing to do..
             } else if (_tmpReadFileTypeOfTransformation==0){
                 double transX, transY;
-                transX = (double) imageDim[0]/_tmpReadFileImageDim[0];
-                transY = (double) imageDim[1]/_tmpReadFileImageDim[1];
-                manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
+                transX = (double) imageDim[0]/_tmpReadFileImageDim[0];                    // X
+                transY = (double) imageDim[1]/_tmpReadFileImageDim[1];                    // Y
+                manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);                
             } else if (_tmpReadFileTypeOfTransformation==1) {
                 double transX, transY;
-                transX = (double) _tmpReadFileImageSpac[0]/imageDim[0];
-                transY = (double) _tmpReadFileImageSpac[1]/imageDim[1];
+                transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0];                  // X
+                transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1];                  // Y
+                manModelContour->Transform_Ax_Plus_B(transX,0,transY,0); 
+            } else if (_tmpReadFileTypeOfTransformation==2) {  // with Z include
+                double transX, transY;
+                transX = (double) _tmpReadFileImageSpac[0]/imageSpac[0];                   // X
+                transY = (double) _tmpReadFileImageSpac[1]/imageSpac[1];                   // Y 
+                instantVector[1]=instantVector[1]*_tmpReadFileImageSpac[2]/imageSpac[2];   // Z
                 manModelContour->Transform_Ax_Plus_B(transX,0,transY,0);
+            }else {
+                   printf ("EED Warnning! wxContourMainFrame::openContours _tmpReadFileTypeOfTransformation not set. \n");
             }
 
                        fscanf(pFile,"%s",tmp); // TypeView
@@ -1364,6 +1373,8 @@ void wxContourMainFrame::openContours( FILE *pFile, FILE *pFileData, bool static
 
 /*     }    */
 
+printf ("EED wxContourMainFrame::openContours END \n");
+
 }
 
 void wxContourMainFrame::RefreshInterface()
@@ -1733,8 +1744,8 @@ 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 );
+//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
@@ -1883,39 +1894,32 @@ myfile.close();
        std::vector<double> vecCtrlPointY;
        std::vector<double> vecCtrlPointZ;
 
-printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() );
-
-int numberOfPointsInCell;
-int numberOfcells=polyDataResult->GetNumberOfCells();
-for (int jj=0; jj<numberOfcells ; jj++)
-{
-       vtkCell* vtkcell = polyDataResult->GetCell( jj );
-       numberOfPointsInCell=vtkcell->GetNumberOfPoints();
-       printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d  points=%d \n",jj,numberOfPointsInCell );
-}// for jj
-
-printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n");
-
-polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
+//printf("EED wxContourMainFrame::SegmentationOneSlice GetNumberOfLines=%d \n",polyDataResult->GetNumberOfLines() );
+//int numberOfPointsInCell;
+//int numberOfcells=polyDataResult->GetNumberOfCells();
+//for (int jj=0; jj<numberOfcells ; jj++)
+//{
+//     vtkCell* vtkcell = polyDataResult->GetCell( jj );
+//     numberOfPointsInCell=vtkcell->GetNumberOfPoints();
+//     printf("EED wxContourMainFrame::SegmentationOneSlice cell=%d  points=%d \n",jj,numberOfPointsInCell );
+//}// for jj
+// printf("EED wxContourMainFrame::SegmentationOneSlice PrintSelf \n");
+// polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
 
 
        if (polyDataResult->GetNumberOfCells()>0)
        {
                double *p;
-       printf("EED wxContourMainFrame::SegmentationOneSlice A \n");
                vtkCell* vtkcell = polyDataResult->GetCell( 0 );
-       printf("EED wxContourMainFrame::SegmentationOneSlice B \n");
        //      int ii,size=polyDataResult->GetNumberOfPoints();
                int ii,size=vtkcell->GetNumberOfPoints();
-       printf("EED wxContourMainFrame::SegmentationOneSlice C \n");
                int id;
                for (ii=0;ii<size;ii++)
                {
        //              id      = polyDataResult->GetLines()->GetData()->GetValue(ii);
        //              p       = polyDataResult->GetPoint(id);
                        p       = vtkcell->GetPoints()->GetPoint(ii);
-
-       printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d  px=%f py=%f\n",ii,id, p[0],p[1]);
+//     printf("EED wxContourMainFrame::SegmentationOneSlice (%d) id=%d  px=%f py=%f\n",ii,id, p[0],p[1]);
        //              double x=p[0];
        //              double y=p[1];
                        vecX.push_back( p[0] );
@@ -1924,10 +1928,8 @@ polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
                        vecZ.push_back( -900 );
        //                      vecZ.push_back( p[2] );
                }
-
                ExtractControlPoints2D *extractcontrolpoints2d = new ExtractControlPoints2D();
                extractcontrolpoints2d->SetContour( &vecX , &vecY , &vecZ );
-
        //PROOFS
                /*if (methodRadiobox->GetSelection()==0){
                        extractcontrolpoints2d->GetInitialControlPoints( &vecCtrlPointX , &vecCtrlPointY , &vecCtrlPointZ );
@@ -1981,8 +1983,7 @@ polyDataResult->PrintSelf( std::cout, vtkIndent(0) );
                        }       // if addedModel
                } // if sizeCtrPt
        } // if NumberOfCells > 0
-
-printf("EED wxContourMainFrame::SegmentationOneSlice  End\n");
+//printf("EED wxContourMainFrame::SegmentationOneSlice  End\n");
 }
 
 int wxContourMainFrame::GetImageDataSizeZ()
@@ -3178,6 +3179,18 @@ wxPanel *wxContourMainFrame::getColorLayerImageViewPanel(wxWindow *parent)
        return _viewColorLayerImagePanel;
 }
 
+void wxContourMainFrame::SetColorLayerImage(vtkImageData* img)
+{
+       if (_viewColorLayerImagePanel!=NULL) 
+       {
+               if (img!=NULL)
+               {
+                       _viewColorLayerImagePanel->SetActive(true);
+                       _viewColorLayerImagePanel->SetImage( img );
+//                     RefreshInterface();
+               } // img
+       } // _viewColorLayerImagePanel
+}
 
 wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
 {
@@ -3185,13 +3198,14 @@ wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
        {
                double range[2];
                _theViewPanel->getImageData()->GetScalarRange(range);
-               int min = (int)floor (range[0]);
-               int max = (int)ceil (range[1]);
-               int start= (max+min)/2 - (max-min)*0.25; 
-               int end= (max+min)/2 + (max-min)*0.25; 
-               _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max, start, end , 1);
-               _viewThresholdImage = new ThresholdImageView();
+               int min                                         = (int)floor (range[0]);
+               int max                                         = (int)ceil (range[1]);
+               int start                                       = (max+min)/2 - (max-min)*0.25; 
+               int end                                         = (max+min)/2 + (max-min)*0.25; 
+               _viewThresholdImagePanel        = new ThresholdImageViewPanel( parent, min, max, start, end , 1);
+               _viewThresholdImage             = new ThresholdImageView();
                _viewThresholdImage->SetminMaxValue(start,end);
+//             _viewThresholdImage->SetminMaxValue(range[0],range[1]);
                _viewThresholdImage->SetImage( _theViewPanel->getImageData() );
                std::vector<int> colorbarposition;
                colorbarposition.push_back( 10 );
@@ -3406,6 +3420,15 @@ void wxContourMainFrame::SetXY(int x, int y)
        _theViewPanel->SetXY(x,y);
 }
 
+wxVtkBaseView* wxContourMainFrame::GetWxVtkBaseView()
+{
+       if (_theViewPanel!=NULL)
+       {
+               return _theViewPanel->getWxVtkBaseView();;
+       } else {
+               return NULL;
+       }
+}