]> Creatis software - creaContours.git/blobdiff - lib/Interface_ManagerContour_NDimensions/wxContourMainFrame.cxx
no message
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourMainFrame.cxx
index c6293c330af6fa8f8abf8ab78ca2f2f921a31e26..5596ea4a2b6c5a9c4871ebac77672f5014fe4480 100644 (file)
@@ -55,11 +55,7 @@ char wxContourMainFrame::COPY = 'C';
                _refLineControl                         = NULL;
                _refLineModel                           = NULL;
                _refLineView                            = NULL;
-               _imageReslicer                          = NULL;
-               _thresholdTable                         = NULL;
-               _thresholdMapper                        = NULL;
-               _thresholdActor                         = NULL;
-               _actorPresent                           = false;
+//             _actorPresent                           = false;
 
                // set up default notebook style
 //             m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
@@ -69,6 +65,9 @@ char wxContourMainFrame::COPY = 'C';
                _contourextractdata                     = NULL;
                _viewMaskImage                          = NULL;
                _viewMaskImagePanel                     = NULL;
+               _viewThresholdImage                     = NULL;
+               _viewThresholdImagePanel        = NULL;
+
        }
 
        wxContourMainFrame :: wxContourMainFrame(wxWindow* parent, wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,std::vector<vtkImageData*> images, long style,std::string datadir)         
@@ -83,13 +82,11 @@ char wxContourMainFrame::COPY = 'C';
                _refLineControl                         = NULL;
                _refLineModel                           = NULL;
                _refLineView                            = NULL;
-               _imageReslicer                          = NULL;
-               _thresholdTable                         = NULL;
-               _thresholdMapper                        = NULL;
-               _thresholdActor                         = NULL;
-               _actorPresent                           = false;
+//             _actorPresent                           = false;
                _viewMaskImage                          = NULL;
                _viewMaskImagePanel                     = NULL;
+               _viewThresholdImage                     = NULL;
+               _viewThresholdImagePanel        = NULL;
 
                // set up default notebook style
                m_notebook_style =wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
@@ -513,11 +510,6 @@ void wxContourMainFrame :: deleteContour( std::string theKeyName ){
                //cViewer               = conwrapviewControl->getViewer();
                //_theViewPanel->getSceneManager()->removeWrap( theKeyName );
                //cControler* conwrapviewControl->getControler();                       
-//EED Borrame
-//FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
-//fprintf(ff,"EED wxContourEventHandler::deleteContours() \n" );
-//fprintf(ff,"    %s %p\n",keyNamesVector[i].c_str(),  cControler );
-//fclose(ff);
        //      delete cModel;
        //      delete cViewer;
        //      delete cControler;
@@ -637,19 +629,13 @@ void wxContourMainFrame::changeInstant()
 {
                std::vector<int> instantVect;
                _instantPanel->getInstant( instantVect );
-//             Instant * theInstant = new Instant ( &instantVect );
-               
-               //Setting the actual instant
-               //_actualInstant = theInstant;
+               int actualSlice = instantVect[1];
 
                kernelManager->setInstant(instantVect);
-               //_modelManager->setInstant( _actualInstant );
-               
-       
-               if(_viewMaskImage!=NULL){
-                       int actualSlice = instantVect[1];
-                       _viewMaskImage->SetZ(actualSlice);
                        
+           // Refresh Mask image
+               if(_viewMaskImage!=NULL){
+                       _viewMaskImage->SetZ(actualSlice);                      
                        if (_viewMaskImagePanel->IsVisible()==true)
                        {
                                vtkImageData *mask, *value;
@@ -658,7 +644,14 @@ void wxContourMainFrame::changeInstant()
                        }
                }
        
-           onThresholdChange();
+       // Refresh Threshold image
+               if(_viewThresholdImage!=NULL){
+                       _viewThresholdImage->SetZ(actualSlice);                 
+                       if (_viewThresholdImagePanel->IsVisible()==true){
+                               _viewThresholdImage->onThreshold();
+                       }
+               }
+       
                updateInstantOutlines();
                updateInstantImageData();
                updateInstantAxes();
@@ -2031,192 +2024,6 @@ void wxContourMainFrame::onMirror()
        //_refName = "";
 }
 
-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)
-       {
-               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();
-               }
-
-               _imageReslicer->SetResliceAxesOrigin(0,0,z);
-
-               img = _imageReslicer->GetOutput();
-               img->Update();
-               img->UpdateInformation();
-
-               wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-
-               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 = minTot; i <= maxTot; i++)
-               {
-                       if( i >= minVal && i <= maxVal )
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
-                       }
-                       else if( i >= minTot && i < minVal )
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                       }
-                       else if( i > maxVal && i < maxTot )
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                       }
-                       else
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                       }
-               }
-               _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->SetPosition( 0,0, 900-1 );
-               }
-               
-               _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
-
-               baseView->GetRenderer()->AddActor( _thresholdActor );
-               _actorPresent = true;
-       }
-
-       else
-       {
-               _imageReslicer->SetResliceAxesOrigin(0,0,z);
-               img = _imageReslicer->GetOutput();
-               img->Update();
-               img->UpdateInformation();
-
-               //Assign a fake color for the upper image, and set the white as transparent
-               int i;
-               for(i = minTot; i <= maxTot; i++)
-               {
-                       if( i >= minVal && i <= maxVal )
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
-                       }
-                       else if( i >= minTot && i < minVal )
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                       }
-                       else if( i > maxVal && i < maxTot )
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                       }
-                       else
-                       {
-                               _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-                       }
-               }
-
-               _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();
-}
-
-
-void wxContourMainFrame::onThresholdChange()
-{
-       if (_actorPresent)
-       {
-               onThreshold();
-       }
-}
-
-void wxContourMainFrame::onThresholdInterpolation(bool interpolate)
-{
-       if (_thresholdActor!=NULL)
-       {
-               if (interpolate)
-               {
-                       _thresholdActor->InterpolateOn( );
-               }
-
-               else
-               {
-                       _thresholdActor->InterpolateOff( );
-               }
-
-               _theViewPanel->RefreshInterface();
-       }
-}
-
-void wxContourMainFrame::onThresholdChangeOpacity (int opacity)
-{
-       if (_actorPresent)
-       {
-               _thresholdActor->SetOpacity(opacity*0.1);
-       }
-
-       _theViewPanel->RefreshInterface();
-}
-
-void wxContourMainFrame::onThresholdRemove()
-{
-       if (_actorPresent)
-       {
-               wxVtkBaseView * baseView = _theViewPanel->getWxVtkBaseView();
-               baseView->GetRenderer()->RemoveActor( _thresholdActor );
-               _actorPresent = false;
-       }
-
-       _theViewPanel->RefreshInterface();
-}
 
 void wxContourMainFrame::showAxis(bool show)
 {
@@ -3022,16 +2829,14 @@ void wxContourMainFrame::ShowToolsPanel(bool show){
 }
 
 
-//EED01Juillet2009
-/*
-void wxContourMainFrame::GenerateContourExtractData()
+
+void wxContourMainFrame::SetContourGroup(int contourGroup)
 {
-       if (_contourextractdata==NULL) { }
+       _contourGroup = contourGroup;
 }
-*/ 
 
 
-wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
+wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
 {
        
        if      (_viewMaskImagePanel==NULL)
@@ -3039,31 +2844,46 @@ wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
                _contourextractdata = new ContourExtractData(true);
                _contourextractdata->SetImage( _theViewPanel->getImageData() );
                
-               double range[2];
-               _theViewPanel->getImageData()->GetScalarRange(range);
+//             double range[2];
+//             _theViewPanel->getImageData()->GetScalarRange(range);
                //int min = (int)floor (range[0]);
                //int max = (int)ceil (range[1]);
-               int min = 0;
-               int max = 255;
+               int min = 254;
+               int max = 256;
                
-               _viewMaskImagePanel = new ThresholdImageViewPanel( parent, min, max , 0);
-                       _viewMaskImage = new ThresholdImageView();
-                       _viewMaskImage->SetImage(_contourextractdata->GetVtkImageMaskResult() );
-                       _viewMaskImage->SetminMaxValue( 254, 256);
-                       _viewMaskImage->SetBaseColor( 0,0,1 );
-                       _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage );
-                       _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
+               _viewMaskImagePanel = new ThresholdImageViewPanel( parent, -1, -1 , 0);
+               _viewMaskImage = new ThresholdImageView();
+               _viewMaskImage->SetImage(_contourextractdata->GetVtkImageMaskResult() );
+               _viewMaskImage->SetminMaxValue( min, max);
+               _viewMaskImage->SetBaseColor( 0,0,1 );
+               _viewMaskImagePanel->SetThresholdImageView( _viewMaskImage );
+               _viewMaskImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
                
        }
        return _viewMaskImagePanel;
 }
 
-void wxContourMainFrame::SetContourGroup(int contourGroup)
+wxPanel *wxContourMainFrame::getThresholdImageViewPanel(wxWindow *parent)
 {
-       printf("EED wxContourMainFrame::SetContourGroup \n");
-       _contourGroup = contourGroup;
+       if      (_viewThresholdImagePanel==NULL)
+       {
+               double range[2];
+               _theViewPanel->getImageData()->GetScalarRange(range);
+               int min = (int)floor (range[0]);
+               int max = (int)ceil (range[1]);         
+               _viewThresholdImagePanel = new ThresholdImageViewPanel( parent, min, max , 1);
+               _viewThresholdImage = new ThresholdImageView();
+               _viewThresholdImage->SetImage( _theViewPanel->getImageData() );
+               _viewThresholdImage->SetminMaxValue( min, max);
+               _viewThresholdImage->SetBaseColor( 1,0,0 );
+               _viewThresholdImagePanel->SetThresholdImageView( _viewThresholdImage );
+               _viewThresholdImage->SetwxVtkBaseView( _theViewPanel->getWxVtkBaseView() );
+       }
+       return _viewThresholdImagePanel;
 }
 
 
 
 
+
+