]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug IPAL12307:
authorenk <enk@opencascade.com>
Tue, 2 May 2006 11:35:53 +0000 (11:35 +0000)
committerenk <enk@opencascade.com>
Tue, 2 May 2006 11:35:53 +0000 (11:35 +0000)
TC: Scalar Map edition: showing preview modifies Scalar Mode even if one cancel edition

src/VISUGUI/VisuGUI_ScalarBarDlg.cxx
src/VISUGUI/VisuGUI_ScalarBarDlg.h

index e2943bb97db8e06972d83ea679caaf408c8a9916..d26d9940367970fe5322d76d92fb38aebd68b4f5 100644 (file)
@@ -549,6 +549,7 @@ void VisuGUI_ScalarBarPane::storeToResources() {
 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
   initFromResources();
   myScalarMap = thePrs;
+  myTitle = thePrs->GetTitle();
   setPosAndSize( thePrs->GetPosX(),
                 thePrs->GetPosY(),
                 thePrs->GetWidth(),
@@ -650,7 +651,10 @@ void VisuGUI_ScalarBarPane::createScalarBar()
   if (myScalarMap == NULL) return;
 
   if (!check()) return;
-
+  myScalarMapPL = VISU_ScalarMapPL::New();
+  if(myScalarMap->GetScalarMapPL())
+    myScalarMapPL->ShallowCopy(myScalarMap->GetScalarMapPL());
+  
   if ( myBusy ) return;
 
   myBusy = true;
@@ -667,31 +671,25 @@ void VisuGUI_ScalarBarPane::createScalarBar()
   myPreviewActor->GetScalarBar()->VisibilityOn();
   myPreviewActor->PickableOff();
   
-  myScalarMap->SetScalarMode(myModeCombo->currentItem());
-  myScalarMap->SetPosition(getX(),getY());
-  myScalarMap->SetSize(getWidth(),getHeight());
-  myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
+  myScalarMapPL->SetScalarMode(myModeCombo->currentItem());
   if(isLogarithmic())
-    myScalarMap->SetScaling(VISU::LOGARITHMIC);
+    myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
   else
-    myScalarMap->SetScaling(VISU::LINEAR);
-  if (RBFrange->isChecked()) {
-    myScalarMap->SetSourceRange();
-  } else {
-    myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
-  }
-  myScalarMap->SetNbColors(sbCol);
-  myScalarMap->SetLabels(sbLab); 
+    myScalarMapPL->SetScaling(VISU::LINEAR);
+  vtkFloatingPointType theRange[2];
+  theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
+  theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
+  myScalarMapPL->SetScalarRange(theRange);
+  myScalarMapPL->SetNbColors(sbCol);
   
-  myScalarMap->GetScalarMapPL()->SetNbColors(sbCol);
-  myScalarMap->GetScalarMapPL()->Update();
-    
-  aScalarBarActor->SetLookupTable(myScalarMap->GetScalarMapPL()->GetBarTable());
+  myScalarMapPL->Update();
+  
+  aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
   
   if (myTextDlg->getTitleText().latin1() != "") 
     aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
   else
-    aScalarBarActor->SetTitle(myScalarMap->GetTitle());
+    aScalarBarActor->SetTitle(myTitle.c_str());
   aScalarBarActor->SetOrientation(getOrientation());
   aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
   aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
@@ -747,18 +745,25 @@ void VisuGUI_ScalarBarPane::deleteScalarBar()
   if ( myBusy ) return;
   
   if (myPreviewActor == 0) return;
-  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()){
-    vf->RemoveActor(myPreviewActor);
-    myPreviewActor->GetScalarBar()->VisibilityOff();
-  }
+  vtkRenderer* aRend       = myPreviewActor->GetRenderer();
+  if(aRend)
+    myPreviewActor->RemoveFromRender(aRend);
+  myPreviewActor->GetScalarBar()->VisibilityOff();
   myPreviewActor->Delete();
   myPreviewActor = 0;
+
+  if (myScalarMapPL){
+    myScalarMapPL->Delete();
+    myScalarMapPL = 0;
+  }
 }
 /*! public: Deleting preview scalar bar
  */
 void VisuGUI_ScalarBarPane::deletePreview()
 {
   deleteScalarBar();
+  if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
+    vf->Repaint();
 }
 /**
  * Store values to presentation object
@@ -908,12 +913,15 @@ void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
   if ( myScalarMap ) {
     if ( RBFrange->isChecked() ) {
       vtkFloatingPointType aRange[2];
+      int aMode = myScalarMap->GetScalarMode();
       myScalarMap->SetScalarMode(theMode);
       myScalarMap->GetScalarMapPL()->GetSourceRange(aRange);
       MinEdit->setText( QString::number( aRange[0] ) );
       MaxEdit->setText( QString::number( aRange[1] ) );
+      myScalarMap->SetScalarMode(aMode);
     }
   }
+  updatePreview();
 }
 
 /*!
index 7a6adbf6334c8c3013a78ad1b8fc22196365c134..63284e83df99756d87c8543b7e180af4c29f303b 100644 (file)
@@ -180,6 +180,8 @@ class VisuGUI_ScalarBarPane : public QVBox
   QCheckBox* myPreviewCheck;
   VISU_ScalarMapAct* myPreviewActor;
   VISU::ScalarMap_i* myScalarMap;
+  VISU_ScalarMapPL* myScalarMapPL;
+  std::string       myTitle;
 
   bool myBusy;
 };