Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISUGUI / VisuGUI_Plot3DDlg.cxx
index 67dbc980c186316a2040b7666c8bbc9c968f100f..04ba4334ef924c468b13079771bde7d30f1a6ca5 100644 (file)
 
 #include "VisuGUI.h"
 #include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
 
 #include "VISU_ViewManager_i.hh"
 #include "VISU_Plot3DPL.hxx"
 
-#include "SALOME_Actor.h"
 #include "SVTK_ViewWindow.h"
 
+#include "SALOME_Actor.h"
+#include "SUIT_Desktop.h"
+
 #include <qlayout.h>
 #include <qvalidator.h>
 #include <qtabwidget.h>
@@ -60,10 +63,8 @@ using namespace std;
 static void renderViewFrame (SVTK_ViewWindow* vw)
 {
   if (vw) {
-//if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
-      vw->getRenderer()->ResetCameraClippingRange();
-      vw->Repaint();
-//}
+    vw->getRenderer()->ResetCameraClippingRange();
+    vw->Repaint();
   }
 }
 
@@ -128,7 +129,7 @@ class TPlane : public SALOME_Actor
 //=======================================================================
 VisuGUI_Plot3DPane::VisuGUI_Plot3DPane (QWidget* parent)
      : QVBox(parent), myInitFromPrs(false), myPreviewActor(NULL),
-       myViewWindow(VISU::GetViewWindow()), myPrs(NULL), myPipeCopy(NULL)
+       myViewWindow(VISU::GetActiveViewWindow<SVTK_ViewWindow>()), myPrs(NULL), myPipeCopy(NULL)
 {
   layout()->setAlignment(Qt::AlignTop);
   setSpacing(6);
@@ -255,6 +256,7 @@ void VisuGUI_Plot3DPane::storePrsParams()
   if (!myPipeCopy)
     myPipeCopy = VISU_Plot3DPL::New();
   if (myPrs) {
+    myPipeCopy->SetIDMapper(myPrs->GetPL()->GetIDMapper());
     myPipeCopy->ShallowCopy(myPrs->GetPL());
     storeToPrsObject(myPrs);
   }
@@ -322,10 +324,14 @@ void VisuGUI_Plot3DPane::onRelativePos(bool isRelativePos)
     storePrsParams();
     myPrs->GetPlot3DPL()->GetMinMaxPosition(minPos, maxPos);
     restorePrsParams();
-    if (isRelativePos) // absolute -> relative
-      pos = (pos - minPos) / (maxPos - minPos);
-    else  // relative -> absolute
-      pos = minPos * (1. - pos) + maxPos * pos;
+    if (-1e-7 < (maxPos - minPos) && (maxPos - minPos) < 1e-7) {
+      pos = 0;
+    } else {
+      if (isRelativePos) // absolute -> relative
+        pos = (pos - minPos) / (maxPos - minPos);
+      else  // relative -> absolute
+        pos = minPos * (1. - pos) + maxPos * pos;
+    }
   }
   if (isRelativePos) {
     minPos = 0.;
@@ -494,8 +500,8 @@ bool VisuGUI_Plot3DPane::check()
 //function : Constructor
 //purpose  :
 //=======================================================================
-VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg(QWidget* parent)
-  : QDialog(parent, "VisuGUI_Plot3DDlg", false, WStyle_Customize |
+VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg (SalomeApp_Module* theModule)
+  : QDialog(VISU::GetDesktop(theModule), "VisuGUI_Plot3DDlg", false, WStyle_Customize |
             WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
   setCaption(tr("TITLE"));
@@ -547,38 +553,11 @@ VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg(QWidget* parent)
 //=======================================================================
 void VisuGUI_Plot3DDlg::accept()
 {
-/*if (!VISU::CheckActiveStudyLock()) {
-    return;
-  }
-  if (myIsoPane->check() && myScalarPane->check()) {
-    if (!isModal()) {
-      VISU::Plot3D_i* prs = myIsoPane->GetPrs();
-      bool isCreation = !VISU::GetActor(prs, myViewWindow);
-      if (storeToPrsObject(prs)) {
-       if (isCreation) { // creation
-         if (myViewWindow) {
-           try {
-              VISU::CreateActor(prs);
-           }
-           catch (...) {
-             reject();
-             return;
-           }
-           myViewWindow->onFitAll();
-         }
-       } else { // edition
-         VISU::RecreateActor(prs);
-          renderViewFrame(myViewWindow);
-       }
-      } else {
-       if (isCreation) {
-          prs->RemoveFromStudy();
-          //study->updateObjBrowser();
-       }
-      }
-}*/
-    QDialog::accept();
-//}
+  if (myIsoPane->check() && myScalarPane->check())
+    {
+      myScalarPane->deletePreview();
+      QDialog::accept();
+    }
 }
 
 //=======================================================================
@@ -588,14 +567,7 @@ void VisuGUI_Plot3DDlg::accept()
 void VisuGUI_Plot3DDlg::reject()
 {
   myIsoPane->check(); // hide preview
-
-/*if (!isModal() && myIsoPane->GetPrs() &&
-      !VISU::GetActor(myIsoPane->GetPrs(), myViewWindow)) {
-    _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule));
-    if (!aStudy->GetProperties()->IsLocked()) {
-      myIsoPane->GetPrs()->RemoveFromStudy();
-      myIsoPane->GetStudyFrame()->getStudy()->updateObjBrowser();
-    }
-}*/
+  myScalarPane->deletePreview();
+  
   QDialog::reject();
 }