Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / VISUGUI / VisuGUI_CutPlanesDlg.cxx
index 0614b3c4c96e49f86fc89af2b31e190ee486b211..c4072907cd942daefde932fd03132643960e4129 100644 (file)
@@ -62,8 +62,8 @@ using namespace std;
 
 //extern VisuGUI *visuGUI;
 
-VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewManager* theMgr*/)
-     : QFrame(theParent), myPreviewActor(0)//, myMgr(theMgr)
+VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
+     : QFrame(theParent), myPreviewActor(0)
 {
   QGridLayout* TopLayout = new QGridLayout( this );
   TopLayout->setSpacing( 6 );
@@ -166,6 +166,7 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewMan
 
 VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane()
 {
+  cout<<"### VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane"<<endl;
   deletePlanes();
   if (myCutPlanes)
     myCutPlanes->Destroy();
@@ -198,11 +199,11 @@ void VisuGUI_CutPlanesPane::createPlanes()
   if (myPreviewActor != 0) return;
 
   vtkAppendPolyData* aPolyData = myCutPlanes->GetCutPlanesPL()->GetAppendPolyData();
-  vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
   if (!aPolyData->GetOutput()->GetNumberOfCells()) {
     onPreviewCheck(false);
     return;
   }
+  vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
   aPlaneMapper->SetInput(aPolyData->GetOutput());
   aPlaneMapper->ScalarVisibilityOff();
 
@@ -454,22 +455,15 @@ void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview)
 //###################################################################
 
 
-
 /*!
   Constructor
 */
-VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (QWidget* parent, bool theIsCreation, bool theIsModal)
-     : QDialog(parent, "VisuGUI_CutPlanesDlg", theIsModal, WStyle_Customize |
-               WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
-       //,myMgr(VisuGUI::application()->activeViewManager())
+VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule)
+     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutPlanesDlg", false,
+               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  //myStudyWnd = myMgr->getActiveView();
-  if (!theIsModal) {
-    setWFlags(getWFlags() | WDestructiveClose);
-  }
   setCaption("Cut Planes Definition");
   setSizeGripEnabled(true);
-  myIsCreation = theIsCreation;
 
   QVBoxLayout* TopLayout = new QVBoxLayout (this);
   TopLayout->setSpacing(6);
@@ -516,49 +510,34 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (QWidget* parent, bool theIsCreation,
   //        this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
 }
 
-void VisuGUI_CutPlanesDlg::accept() {
+void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::CutPlanes_i* thePrs)
+{
+  myPrs = thePrs;
+  myScalarPane->initFromPrsObject(thePrs);
+  myCutPane->initFromPrsObject(thePrs);
+}
+
+int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::CutPlanes_i* thePrs)
+{
+  return (myScalarPane->storeToPrsObject(thePrs) &&
+          myCutPane->storeToPrsObject(thePrs));
+}
+
+void VisuGUI_CutPlanesDlg::accept()
+{
+  //if ( !VisuGUI::CheckActiveStudyLock() ) {
+  //  reject();
+  //  return;
+  //}
   if (myScalarPane->check())
-    QDialog::accept();
-/*jfa tmp:
-  if (myScalarPane->check()) {
-    if (!isModal()) {
-      if (storeToPrsObject(myPrs)) {
-       if (myIsCreation) {
-         if (VISU::GetViewWindow() != NULL) {
-           try {
-           visuGUI->CreateActor(myPrs);
-           }
-           catch (...) {
-             reject();
-             return;
-           }
-           VISU::GetViewWindow()->onFitAll();
-         }
-       } else {
-         visuGUI->RecreateActor(myPrs);
-         if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
-            if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
-             vf->getRenderer()->ResetCameraClippingRange();
-             vf->Repaint();
-           }
-         }
-       }
-      } else {
-       if (myIsCreation) {
-         visuGUI->DeletePresentation(myPrs);
-       }
-      }
+    {
+      myScalarPane->deletePreview();
+      QDialog::accept();
     }
-    QDialog::accept();
-  }
-*/
 }
 
 void VisuGUI_CutPlanesDlg::reject() {
-  //jfa tmp:if (myIsCreation && (!isModal())) {
-  //jfa tmp:  visuGUI->DeletePresentation(myPrs);
-  //jfa tmp:  VisuGUI::application()->objectBrowser()->updateTree();
-  //jfa tmp:}
+  myScalarPane->deletePreview();
   QDialog::reject();
 }