]> Creatis software - creaContours.git/commitdiff
*** empty log message ***
authordonadio <donadio>
Wed, 29 Apr 2009 09:23:03 +0000 (09:23 +0000)
committerdonadio <donadio>
Wed, 29 Apr 2009 09:23:03 +0000 (09:23 +0000)
lib/Interface_Icons_NDimensions/interfMainPanel.cxx
lib/Interface_Icons_NDimensions/interfMainPanel.h
lib/Interface_Icons_NDimensions/interfSegmentationPanels.cxx
lib/Interface_Icons_NDimensions/interfSegmentationPanels.h
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.h

index 14f0f5acb86fe89480b5eede639feea735b3cfc3..4f75c89106ed1713e3d62410da764d71ddcaf666 100644 (file)
@@ -705,17 +705,17 @@ void interfMainPanel::onMirrorChangeWidth(int width)
 }
 
 
-void interfMainPanel::onThreshold(int minVal, int maxVal)
+void interfMainPanel::onThreshold()
 {
-       wxContourMainFrame::getInstance()->onThreshold(minVal, maxVal);
+       wxContourMainFrame::getInstance()->onThreshold();
 }
 
-void interfMainPanel::onThresholdChange(int minVal, int maxVal)
+void interfMainPanel::onThresholdChange()
 {
-       wxContourMainFrame::getInstance()->onThresholdChange(minVal, maxVal);
+       wxContourMainFrame::getInstance()->onThresholdChange();
 }
 
-void interfMainPanel::onThresholdInstantChange(int range[])
+void interfMainPanel::onThresholdInstantChange(double range[])
 {
        panelThreshold->onThresholdInstantChange(range);
 }
index c28928b39e4519d3e97a88293c51f4639b9ab6e3..e9663c27733bbc076e4db51649310d64b7dd79f0 100644 (file)
@@ -136,11 +136,11 @@ public:
 
        void onMirrorChangeWidth(int width);
 
-       void onThreshold(int minVal, int maxVal);
+       void onThreshold();
 
-       void onThresholdChange(int minVal, int maxVal);
+       void onThresholdChange();
 
-       void onThresholdInstantChange(int range[]);
+       void onThresholdInstantChange(double range[]);
 
        void onThresholdRemove();
 
index b4e169642ec5c8c7ed80fdad89aed8dc525a3e34..615f852eabaf99152b6523a98d1cb1dff91fe57e 100644 (file)
@@ -319,10 +319,7 @@ void interfThresholdPanel::onThresholdChange(wxCommandEvent& event)
 {
        if (_thresholdGo)
        {
-               int minVal = _mBarThreshold->GetStart();
-               int maxVal = _mBarThreshold->GetEnd();
-
-               interfMainPanel::getInstance()->onThresholdChange(minVal, maxVal);
+               interfMainPanel::getInstance()->onThresholdChange();
 
                //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
        }
@@ -332,27 +329,30 @@ void interfThresholdPanel::onThresholdGo(wxCommandEvent& event)
 {
        if (!_thresholdGo)
        {
-               int minVal = _mBarThreshold->GetStart();
-               int maxVal = _mBarThreshold->GetEnd();
-
-               interfMainPanel::getInstance()->onThreshold(minVal, maxVal);
+               interfMainPanel::getInstance()->onThreshold();
                _thresholdGo=true;
        }
 }
 
 void interfThresholdPanel::onThresholdRemove(wxCommandEvent& event)
 {
-       interfMainPanel::getInstance()->onThresholdRemove( );
-       _thresholdGo=false;
+       if (_thresholdGo)
+       {       
+               interfMainPanel::getInstance()->onThresholdRemove( );
+               _thresholdGo=false;             
+       }
 }
 
 void interfThresholdPanel::onThresholdStop()
 {
-       interfMainPanel::getInstance()->onThresholdRemove( );
-       _thresholdGo=false;
+       if (_thresholdGo)
+       {       
+               interfMainPanel::getInstance()->onThresholdRemove( );
+               _thresholdGo=false;             
+       }
 }
 
-void interfThresholdPanel::onThresholdInstantChange(int range[])
+void interfThresholdPanel::onThresholdInstantChange(double range[])
 {
        range[0] = _mBarThreshold->GetStart();
        range[1] = _mBarThreshold->GetEnd();
index 72399b12d9415c94f42a4e2bc94da0393ccaab75..f52a776830be2a140d43cfc8db39ec19754a2b00 100644 (file)
@@ -109,7 +109,7 @@ public:
        ~interfThresholdPanel();
        
        void onThresholdStop();
-       void onThresholdInstantChange(int range[]);
+       void onThresholdInstantChange(double range[]);
 
 private:
 
index e391f7c5c4bff9168b51e5f5b314d7ef77fa6c2a..30cafdf91220e9193cbf66038d781874208c3a4a 100644 (file)
@@ -58,6 +58,9 @@ char wxContourMainFrame::COPY = 'C';
                _refLineControl                         = NULL;
                _refLineModel                           = NULL;
                _refLineView                            = NULL;
+               _imageReslicer                          = NULL;
+               _thresholdTable                         = NULL;
+               _thresholdMapper                        = NULL;
                _thresholdActor                         = NULL;
                _actorPresent                           = false;
 
@@ -79,6 +82,9 @@ char wxContourMainFrame::COPY = 'C';
                _refLineControl                         = NULL;
                _refLineModel                           = NULL;
                _refLineView                            = NULL;
+               _imageReslicer                          = NULL;
+               _thresholdTable                         = NULL;
+               _thresholdMapper                        = NULL;
                _thresholdActor                         = NULL;
                _actorPresent                           = false;
 
@@ -594,7 +600,7 @@ void wxContourMainFrame::changeInstant()
                kernelManager->setInstant(instantVect);
                //_modelManager->setInstant( _actualInstant );
                
-           updateActor();
+           onThresholdChange();
                updateInstantOutlines();
                updateInstantImageData();
                updateInstantAxes();
@@ -638,83 +644,6 @@ void wxContourMainFrame::updateInstantAxes()
 {
 }
 
-void wxContourMainFrame :: updateActor()
-{
-               if (_actorPresent)
-               {
-                       int minMax[2];
-                       _pannew->onThresholdInstantChange(minMax);
-
-                       int     z = _theViewPanel->GetZ();
-
-                       vtkImageData * img = getImageData();
-                       vtkImageReslice *imageReslice = vtkImageReslice::New();
-
-                       imageReslice->SetInput( img );
-                       imageReslice->SetInformationInput(img);
-                       imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
-                       imageReslice->SetResliceAxesOrigin(0,0,z);
-                       imageReslice->SetOutputDimensionality(2);
-                       imageReslice->SetInterpolationModeToLinear();
-
-                       img = imageReslice->GetOutput();
-                       img->Update();
-                       img->UpdateInformation();
-
-//EED???                       wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-                       
-                       double range[2];
-                       img->GetScalarRange(range);
-
-                       int min = floor (range[0]);
-                       int max = ceil (range[1]);
-
-                       //Lookup Table
-                       vtkLookupTable *lookup = vtkLookupTable::New();
-                       lookup->SetNumberOfTableValues(max+1);
-                       lookup->SetTableRange(range); 
-                       lookup->SetAlphaRange(0, 1);
-                       lookup->SetValueRange(0, 1);
-                       lookup->SetSaturationRange(0, 0); 
-                       lookup->SetRampToLinear( );
-
-                       //Assign a fake color for the upper image, and set the white as transparent
-                       int i;
-                       int minVal = minMax[0];
-                       int maxVal = minMax[1];
-
-                       for(i = min; i <= max; i++)
-                       {
-                               if( i >= minVal && i <= maxVal )
-                               {
-                                       lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
-                               }
-                               else if( i >= min && i < minVal )
-                               {
-                                       lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                               }
-                               else if( i > maxVal && i < max )
-                               {
-                                       lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                               }
-                               else
-                               {
-                                       lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                               }
-                       }
-                               
-                       lookup->Build( );
-
-                       vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
-                       mapperImage->SetLookupTable( lookup );
-                       mapperImage->SetInput( img );
-                       //mapperImage->SetOutputFormatToRGBA( );
-
-                       _thresholdActor->SetInput( mapperImage->GetOutput() );
-                       printf("EED wxContourMainFrame::updateActor %d \n" , z);        
-                       _thresholdActor->SetPosition( 0,0, 900-1 );
-               }
-}
 
 void wxContourMainFrame::onChangeDeep(int val){
        _instantPanel->setConceptValue( "Axe Depth", (int)val );        
@@ -880,7 +809,8 @@ void wxContourMainFrame::onSave(){
                saveFileWithContours( fileNameContourROI );
        }
 }
-void wxContourMainFrame::saveFileWithContours( std::string filename ){
+void wxContourMainFrame::saveFileWithContours( std::string filename )
+{
 
        FILE *pFile=fopen(filename.c_str(),"w+");
        std::vector< std::string > lstNameThings;
@@ -1212,7 +1142,7 @@ const double propagationScaling = atof( crea::wx2std(prop).c_str() );
 
 
        vtkPolyData* polyDataResult =  cntVTK->GetOutput();
-       std::cout<<"Points "<<polyDataResult->GetNumberOfPoints()<<std::endl;
+       //std::cout<<"Points "<<polyDataResult->GetNumberOfPoints()<<std::endl;
        polyDataResult->Update( );
        polyDataResult->UpdateInformation();
 
@@ -1294,9 +1224,9 @@ myfile.open ("C:/Creatis/example2.txt");
                {
                vecX.push_back( p[0] );
                myfile <<p[0]<<","<<p[1]<<"\n";
-               std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
-               std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
-               std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
+               //std::cout<<" x Anterior "<<xAct<<" x actual "<<x<<std::endl;
+               //std::cout<<" y Anterior "<<yAct<<" y actual "<<y<<std::endl;
+               //std::cout<<" x "<<p[0]<<" y "<<p[1]<<std::endl;
                vecY.push_back( p[1] );
                vecZ.push_back( 900 );
                xAct=x;
@@ -1309,7 +1239,7 @@ myfile.open ("C:/Creatis/example2.txt");
        while(!vecXo.empty())
        {
                vecX.push_back(vecXo.back());
-               std::cout<<" x Siguiente "<<vecXo.back();
+               //std::cout<<" x Siguiente "<<vecXo.back();
                vecXo.pop_back();
                vecZ.push_back( 900 );
        }
@@ -1794,171 +1724,151 @@ void wxContourMainFrame::onMirror()
        //_refName = "";
 }
 
-void wxContourMainFrame::onThreshold(int minVal, int maxVal)
+void wxContourMainFrame::onThreshold()
 {
+       int     z = _theViewPanel->GetZ();
+       double range[2];
+
+       vtkImageData * img = getImageData();
+       img->GetScalarRange(range);
+
+       int minTot = floor (range[0]);
+       int maxTot = ceil (range[1]);
+
+       double minMax[2];
+       _pannew->onThresholdInstantChange(minMax);
+       int minVal = floor (minMax[0]);
+       int maxVal = floor (minMax[1]);
+
        if (!_actorPresent)
        {
-               int     z = _theViewPanel->GetZ();
-
-               vtkImageData * img = getImageData();
-               vtkImageReslice *imageReslice = vtkImageReslice::New();
+               if (_imageReslicer==NULL)
+               {
+                       _imageReslicer = vtkImageReslice::New();
+                       _imageReslicer->SetInput( img );
+                       _imageReslicer->SetInformationInput(img);
+                       _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
+                       _imageReslicer->SetOutputDimensionality(2);
+                       _imageReslicer->SetInterpolationModeToLinear();
+               }
 
-               imageReslice->SetInput( img );
-               imageReslice->SetInformationInput(img);
-               imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
-               imageReslice->SetResliceAxesOrigin(0,0,z);
-               imageReslice->SetOutputDimensionality(2);
-               imageReslice->SetInterpolationModeToLinear();
+               _imageReslicer->SetResliceAxesOrigin(0,0,z);
 
-               img = imageReslice->GetOutput();
+               img = _imageReslicer->GetOutput();
                img->Update();
                img->UpdateInformation();
 
                wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-               
-               double range[2];
-               img->GetScalarRange(range);
-
-               int min = floor (range[0]);
-               int max = ceil (range[1]);
 
-               //Lookup Table
-               vtkLookupTable *lookup = vtkLookupTable::New();
-               lookup->SetNumberOfTableValues(max+1);
-               lookup->SetTableRange(range); 
-               lookup->SetAlphaRange(0, 1);
-               lookup->SetValueRange(0, 1);
-               lookup->SetSaturationRange(0, 0); 
-               lookup->SetRampToLinear( );
+               if (_thresholdTable==NULL)
+               {
+                       //Lookup Table
+                       _thresholdTable = vtkLookupTable::New();
+                       _thresholdTable->SetNumberOfTableValues(maxTot+1);
+                       _thresholdTable->SetTableRange(range); 
+                       _thresholdTable->SetAlphaRange(0, 1);
+                       _thresholdTable->SetValueRange(0, 1);
+                       _thresholdTable->SetSaturationRange(0, 0); 
+                       _thresholdTable->SetRampToLinear( );
+               }
 
                //Assign a fake color for the upper image, and set the white as transparent
                int i;
-               for(i = min; i <= max; i++)
+               for(i = minTot; i <= maxTot; i++)
                {
                        if( i >= minVal && i <= maxVal )
                        {
-                               lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+                               _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
                        }
-                       else if( i >= min && i < minVal )
+                       else if( i >= minTot && i < minVal )
                        {
-                               lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
                        }
-                       else if( i > maxVal && i < max )
+                       else if( i > maxVal && i < maxTot )
                        {
-                               lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
                        }
                        else
                        {
-                               lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
                        }
                }
-                       
-               lookup->Build( );
-
-               vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
-               mapperImage->SetLookupTable( lookup );
-               mapperImage->SetInput( img );
-               //mapperImage->SetOutputFormatToRGBA( );
+               _thresholdTable->Build( );
+       
+               if (_thresholdMapper==NULL)
+               {
+                       _thresholdMapper = vtkImageMapToColors::New( );
+               }
+               
+               _thresholdMapper->SetLookupTable( _thresholdTable );
+               _thresholdMapper->SetInput( img );
 
                if (_thresholdActor==NULL)
                {
                        _thresholdActor = vtkImageActor::New( );
                        _thresholdActor->SetOpacity( 0.6 );
-                       _thresholdActor->InterpolateOn(  ); 
+                       _thresholdActor->InterpolateOn(  );
+                       _thresholdActor->SetPosition( 0,0, 900-1 );
                }
-printf("EED wxContourMainFrame::onThreshold \n");      
-               _thresholdActor->SetPosition( 0,0, z+1 );
-               _thresholdActor->SetInput( mapperImage->GetOutput() );
+               
+               _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
 
                baseView->GetRenderer()->AddActor( _thresholdActor );
                _actorPresent = true;
        }
 
-       RefreshInterface();
-/*
-       vtkImageViewer2* viewer = vtkImageViewer2::New();        
-       viewer->SetInput( upperImageActor->GetInput() ); 
-       viewer->SetColorLevel((range[1]-range[0])/2);
-       viewer->SetColorWindow(range[1]);
-       viewer->GetRenderer()->AddActor( upperImageActor );
-       viewer->Render();
-*/
-
-}
-
-void wxContourMainFrame::onThresholdChange(int minVal, int maxVal)
-{
-       if (_actorPresent)
+       else
        {
-               int     z = _theViewPanel->GetZ();
-
-               vtkImageData * img = getImageData();
-               vtkImageReslice *imageReslice = vtkImageReslice::New();
-
-               imageReslice->SetInput( img );
-               imageReslice->SetInformationInput(img);
-               imageReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
-               imageReslice->SetResliceAxesOrigin(0,0,z);
-               imageReslice->SetOutputDimensionality(2);
-               imageReslice->SetInterpolationModeToLinear();
-
-               img = imageReslice->GetOutput();
+               _imageReslicer->SetResliceAxesOrigin(0,0,z);
+               img = _imageReslicer->GetOutput();
                img->Update();
                img->UpdateInformation();
 
-//EED??                wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-               
-               double range[2];
-               img->GetScalarRange(range);
-
-               int min = floor (range[0]);
-               int max = ceil (range[1]);
-
-               //Lookup Table
-               vtkLookupTable *lookup = vtkLookupTable::New();
-               lookup->SetNumberOfTableValues(max+1);
-               lookup->SetTableRange(range); 
-               lookup->SetAlphaRange(0, 1);
-               lookup->SetValueRange(0, 1);
-               lookup->SetSaturationRange(0, 0); 
-               lookup->SetRampToLinear( );
-
                //Assign a fake color for the upper image, and set the white as transparent
                int i;
-               for(i = min; i <= max; i++)
+               for(i = minTot; i <= maxTot; i++)
                {
                        if( i >= minVal && i <= maxVal )
                        {
-                               lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+                               _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
                        }
-                       else if( i >= min && i < minVal )
+                       else if( i >= minTot && i < minVal )
                        {
-                               lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
                        }
-                       else if( i > maxVal && i < max )
+                       else if( i > maxVal && i < maxTot )
                        {
-                               lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
                        }
                        else
                        {
-                               lookup->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
+                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
                        }
                }
-                       
-               lookup->Build( );
 
-               vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( );
-               mapperImage->SetLookupTable( lookup );
-               mapperImage->SetInput( img );
-               //mapperImage->SetOutputFormatToRGBA( );
+               _thresholdTable->Build( );
+               _thresholdMapper->SetLookupTable( _thresholdTable );
+               _thresholdMapper->SetInput( img );
+               _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+       }
+                       /*
+                               vtkImageViewer2* viewer = vtkImageViewer2::New();        
+                               viewer->SetInput( upperImageActor->GetInput() ); 
+                               viewer->SetColorLevel((range[1]-range[0])/2);
+                               viewer->SetColorWindow(range[1]);
+                               viewer->GetRenderer()->AddActor( upperImageActor );
+                               viewer->Render();
+                       */
+       _theViewPanel->RefreshInterface();
+}
 
-               _thresholdActor->SetInput( mapperImage->GetOutput() );
-printf("EED wxContourMainFrame::onThresholdChange \n");        
-               _thresholdActor->SetPosition( 0,0, z+1 );
 
+void wxContourMainFrame::onThresholdChange()
+{
+       if (_actorPresent)
+       {
+               onThreshold();
        }
-
-       RefreshInterface();
 }
 
 void wxContourMainFrame::onThresholdInterpolation(bool interpolate)
@@ -1975,7 +1885,7 @@ void wxContourMainFrame::onThresholdInterpolation(bool interpolate)
                        _thresholdActor->InterpolateOff( );
                }
 
-               RefreshInterface();
+               _theViewPanel->RefreshInterface();
        }
 }
 
@@ -1986,7 +1896,7 @@ void wxContourMainFrame::onThresholdChangeOpacity (int opacity)
                _thresholdActor->SetOpacity(opacity*0.1);
        }
 
-       RefreshInterface();
+       _theViewPanel->RefreshInterface();
 }
 
 void wxContourMainFrame::onThresholdRemove()
@@ -1998,7 +1908,7 @@ void wxContourMainFrame::onThresholdRemove()
                _actorPresent = false;
        }
 
-       RefreshInterface();
+       _theViewPanel->RefreshInterface();
 }
 
 void wxContourMainFrame::showAxis(bool show)
index 5733100aae36feb7e057dbb8b69bb192986886bf..b86de8da0dbb17cc77b83a3994a9d6368110f307 100644 (file)
@@ -222,7 +222,6 @@ class wxContourMainFrame : public wxPanel {
        void updateInstantOutlines();
        void updateInstantImageData();
        void updateInstantAxes();
-       void updateActor();
 
        void onChangeDeep(int val);
 
@@ -260,8 +259,8 @@ class wxContourMainFrame : public wxPanel {
 
        //AD
        void onMirror();
-       void onThreshold(int minVal, int maxVal);
-       void onThresholdChange(int minVal, int maxVal);
+       void onThreshold();
+       void onThresholdChange();
        void onThresholdInterpolation(bool interpolate);
        void onThresholdChangeOpacity (int opacity);
        void onThresholdRemove();
@@ -344,8 +343,12 @@ private:
     long m_notebook_theme;
     int _numberOfVariablesStatistics;
        
+       vtkImageReslice * _imageReslicer;
+       vtkLookupTable * _thresholdTable;
+       vtkImageMapToColors * _thresholdMapper;
        vtkImageActor * _thresholdActor;
 
+
        bool _actorPresent;
 
        //OutlineModelManager * _modelManager;