]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
IPAL 18594 VTK is not updated after Scalar Factor changing
authordmv <dmv@opencascade.com>
Fri, 18 Jan 2008 12:17:52 +0000 (12:17 +0000)
committerdmv <dmv@opencascade.com>
Fri, 18 Jan 2008 12:17:52 +0000 (12:17 +0000)
src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeDlg.h

index 3dca281f7aeceb2c097469d66c6570ad7c095f10..23e5dd1ea401b2847bec290bb8c790be170509e4 100644 (file)
@@ -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<SVTK_ViewWindow>();
+  VisuGUI* aVisuGUI = dynamic_cast <VisuGUI*>(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<SVTK_ViewWindow>();
-      VisuGUI* aVisuGUI = dynamic_cast <VisuGUI*>(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<TPrs3d_i*>(thePrs3d)) {
     VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule);
     aDlg->initFromPrsObject(aPrs3d, true);
+    aDlg->updatePrsCopy();
+
+    //Hide thePrs3d from Viewer
+    SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(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;    
   }
 }
 
index 34bac0680a810a16725b426ac8a990db925ff431..60b4c272a8cc5fc48338cbaab0a82e9322f77524 100644 (file)
@@ -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<VISU::DeformedShape_i> myPrsCopy;
+    bool                   isApplyed;
 };
 
 #endif // VISUGUI_DEFORMEDSHAPEDLS_H