From 61a00e0ba2de1ad35c4a3aad1a9786ab63933cd0 Mon Sep 17 00:00:00 2001 From: dmv Date: Fri, 18 Jan 2008 12:17:52 +0000 Subject: [PATCH] IPAL 18594 VTK is not updated after Scalar Factor changing --- src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx | 82 ++++++++++++++++-------- src/VISUGUI/VisuGUI_DeformedShapeDlg.h | 3 + 2 files changed, 57 insertions(+), 28 deletions(-) diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index 3dca281f..23e5dd1e 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -59,6 +59,7 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) setCaption(tr("DLG_TITLE")); setSizeGripEnabled(TRUE); myModule = theModule; + isApplyed = false; QVBoxLayout* TopLayout = new QVBoxLayout (this); TopLayout->setSpacing(6); @@ -177,6 +178,31 @@ int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) return anIsOk; } +void VisuGUI_DeformedShapeDlg::updatePrsCopy() +{ + SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(); + VisuGUI* aVisuGUI = dynamic_cast (myModule); + if ( myPrsCopy->GetNumberOfActors() == 0 ) { + PublishInView(aVisuGUI, myPrsCopy, aViewWindow); + aViewWindow->onFitAll(); + int aPos = VISU::GetFreePositionOfDefaultScalarBar(aVisuGUI, aViewWindow); + VISU::AddScalarBarPosition(aVisuGUI, aViewWindow, myPrsCopy, aPos); + } else { + try { + myPrsCopy->UpdateActors(); + } catch (std::runtime_error& exc) { + myPrsCopy->RemoveActors(); + + INFOS(exc.what()); + SUIT_MessageBox::warn1 + (VISU::GetDesktop(myModule), QObject::tr("WRN_VISU"), + QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), + QObject::tr("BUT_OK")); + } + aViewWindow->Repaint(); + } +} + void VisuGUI_DeformedShapeDlg::accept() { VisuGUI_ScalarBarBaseDlg::done( isValid() ); @@ -184,8 +210,12 @@ void VisuGUI_DeformedShapeDlg::accept() void VisuGUI_DeformedShapeDlg::reject() { - if ( myPrsCopy->GetNumberOfActors() != 0 ) - VisuGUI_ScalarBarBaseDlg::done( 1 ); + if (isApplyed) { + if ( myPrsCopy->GetNumberOfActors() != 0 ) + VisuGUI_ScalarBarBaseDlg::done( 1 ); + else + VisuGUI_ScalarBarBaseDlg::reject(); + } else VisuGUI_ScalarBarBaseDlg::reject(); } @@ -199,26 +229,8 @@ bool VisuGUI_DeformedShapeDlg::onApply() { if ( storeToPrsObject( myPrsCopy ) ) { - if ( myPrsCopy->GetNumberOfActors() == 0 ) { - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(); - VisuGUI* aVisuGUI = dynamic_cast (myModule); - PublishInView(aVisuGUI, myPrsCopy, aViewWindow); - aViewWindow->onFitAll(); - int aPos = VISU::GetFreePositionOfDefaultScalarBar(aVisuGUI, aViewWindow); - VISU::AddScalarBarPosition(aVisuGUI, aViewWindow, myPrsCopy, aPos); - } else { - try { - myPrsCopy->UpdateActors(); - } catch (std::runtime_error& exc) { - myPrsCopy->RemoveActors(); - - INFOS(exc.what()); - SUIT_MessageBox::warn1 - (VISU::GetDesktop(myModule), QObject::tr("WRN_VISU"), - QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), - QObject::tr("BUT_OK")); - } - } + updatePrsCopy(); + isApplyed = true; return true; } return false; @@ -259,6 +271,7 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule); aDlg->initFromPrsObject(aPrs3d, true); + aDlg->UseMagn->setChecked(true); VisuGUI_DialogRunner r(aDlg); int dlgResult = r.run( false ); @@ -284,21 +297,29 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) void VisuGUI_DeformedShapeDlg::EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d, Handle(SALOME_InteractiveObject)& theIO) { typedef VISU::DeformedShape_i TPrs3d_i; - + if (TPrs3d_i* aPrs3d = dynamic_cast(thePrs3d)) { VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule); aDlg->initFromPrsObject(aPrs3d, true); + aDlg->updatePrsCopy(); + + //Hide thePrs3d from Viewer + SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(theModule); + if (VISU_Actor* anActor = FindActor(aViewWindow, thePrs3d)) + if (anActor->GetVisibility()) + anActor->VisibilityOff(); + VisuGUI_DialogRunner r(aDlg); int dlgResult = r.run( false ); - + if ( dlgResult != 0 ) aDlg->storeToPrsObject( aPrs3d ); - + try { - aPrs3d->UpdateActors(); + thePrs3d->UpdateActors(); } catch (std::runtime_error& exc) { - aPrs3d->RemoveActors(); + thePrs3d->RemoveActors(); INFOS(exc.what()); SUIT_MessageBox::warn1 @@ -306,7 +327,12 @@ void VisuGUI_DeformedShapeDlg::EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* theP QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), QObject::tr("BUT_OK")); } - delete aDlg; + + if (VISU_Actor* anActor = FindActor(aViewWindow, thePrs3d)) + if (!anActor->GetVisibility()) + anActor->VisibilityOn(); + + delete aDlg; } } diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h index 34bac068..60b4c272 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h @@ -73,6 +73,8 @@ public: static void CreatePrs3d(VisuGUI* theModule); static void EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d, Handle(SALOME_InteractiveObject)& theIO); + void updatePrsCopy(); + protected: virtual QString GetContextHelpFilePath(); int isValid(); @@ -88,6 +90,7 @@ private: VisuGUI_InputPane* myInputPane; SalomeApp_Module* myModule; SALOME::GenericObjPtr myPrsCopy; + bool isApplyed; }; #endif // VISUGUI_DEFORMEDSHAPEDLS_H -- 2.39.2