From 294b8aeb53c3c99c9c49e0244be9a1ab3474f4db Mon Sep 17 00:00:00 2001 From: enk Date: Tue, 2 May 2006 11:35:53 +0000 Subject: [PATCH] Fix for Bug IPAL12307: TC: Scalar Map edition: showing preview modifies Scalar Mode even if one cancel edition --- src/VISUGUI/VisuGUI_ScalarBarDlg.cxx | 54 ++++++++++++++++------------ src/VISUGUI/VisuGUI_ScalarBarDlg.h | 2 ++ 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index e2943bb9..d26d9940 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -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()){ - 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()) + 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(); } /*! diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index 7a6adbf6..63284e83 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -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; }; -- 2.39.2