Salome HOME
EDF 2281 : Add 2 primitives for hexa mesh
[modules/geom.git] / src / AdvancedGUI / AdvancedGUI_PipeTShapeDlg.cxx
index 7f22c4fdd8908ed273549253fc209f95eb2d1b59..bbf214274172ac34c353e8c4407142b2d12dc09e 100644 (file)
@@ -1,20 +1,20 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "AdvancedGUI_PipeTShapeDlg.h"
@@ -217,6 +217,8 @@ void AdvancedGUI_PipeTShapeDlg::Init() {
     CssAcceptable = "QDoubleSpinBox, QPushButton {background-color: rgb(85, 170, 127)}";
     CssRefused = "QDoubleSpinBox, QPushButton {background-color: rgb(255, 0, 0)}";
 
+    showOnlyPreviewControl();
+
        // Signal/slot connections
        connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
        connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@@ -249,7 +251,7 @@ void AdvancedGUI_PipeTShapeDlg::Init() {
 
        initName(tr("GEOM_PIPE_TSHAPE"));
     updateTshapeScreenshotLabel();
-       DisplayPreview();
+    processPreview();
 }
 
 //=================================================================================
@@ -271,7 +273,7 @@ void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions() {
                 MainTubeGroupParams->SpinBox_DZ->setToolTip("");
                 MainTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
                 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
-                DisplayPreview();
+               processPreview();
             }
         }
     }
@@ -285,7 +287,7 @@ void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions() {
                 IncidentTubeGroupParams->SpinBox_DZ->setToolTip("");
                 IncidentTubeGroupParams->SpinBox_DZ->setStyleSheet("background-color: rgb(255, 255, 255);");
                 CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
-                DisplayPreview();
+               processPreview();
             }
         }
     }
@@ -369,7 +371,7 @@ void AdvancedGUI_PipeTShapeDlg::SetPosition(bool isChecked) {
                disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
                JunctionPointsSel->LineEdit4->setText("");
                JunctionPointsSel->LineEdit5->setText("");
-               DisplayPreview();
+               processPreview();
        }
 }
 
@@ -381,7 +383,7 @@ void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox(double newValue)
 {
     if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
         CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
-    DisplayPreview();
+    processPreview();
 }
 
 //=================================================================================
@@ -467,7 +469,7 @@ void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument() {
 
        if (myOkPoint1 && myOkPoint2 && myOkPoint3) {
         CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
-               DisplayPreview();
+       processPreview();
     }
 
 //     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First());
@@ -568,6 +570,7 @@ void AdvancedGUI_PipeTShapeDlg::SetDoubleSpinBoxStep(double step) {
 // purpose  :
 //=================================================================================
 void AdvancedGUI_PipeTShapeDlg::ClickOnOk() {
+  setIsApplyAndClose( true );
        if (ClickOnApply())
                ClickOnCancel();
 }
@@ -596,7 +599,7 @@ void AdvancedGUI_PipeTShapeDlg::ActivateThisDialog() {
        //                      currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
     if (myOkPoint1 && myOkPoint2 && myOkPoint3)
         CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
-       DisplayPreview();
+    processPreview();
 }
 
 //=================================================================================
@@ -649,7 +652,7 @@ void AdvancedGUI_PipeTShapeDlg::ChamferOrFillet(bool) {
         updateTshapeScreenshotLabel();
         if (myOkPoint1 && myOkPoint2 && myOkPoint3)
             CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
-               DisplayPreview();
+               processPreview();
        } else if (send == FilletGroupParams->GroupBox1) {
                if (send->isChecked()) {
                        disconnect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, 0);
@@ -662,7 +665,7 @@ void AdvancedGUI_PipeTShapeDlg::ChamferOrFillet(bool) {
         updateTshapeScreenshotLabel();
         if (myOkPoint1 && myOkPoint2 && myOkPoint3)
             CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
-               DisplayPreview();
+               processPreview();
        }
 
 }
@@ -695,7 +698,7 @@ void AdvancedGUI_PipeTShapeDlg::DisplayPreview(const bool activate, const bool u
                        GEOM::GEOM_Object_var obj = *it;
                        displayPreview(obj, true, activate, false, lineWidth, displayMode, color);
                        if (toRemoveFromEngine)
-                               obj->Destroy();
+                               obj->UnRegister();
                }
                HexMeshCheckBox->setChecked(hexMeshState);
        } catch (const SALOME::SALOME_Exception& e) {
@@ -973,3 +976,14 @@ void AdvancedGUI_PipeTShapeDlg::restoreSubShapes(SALOMEDS::Study_ptr theStudy, S
        }
 
 }
+
+//=================================================================================
+// function : processPreview()
+// purpose  : Display preview if CheckBoxPreview is checked
+//=================================================================================
+void AdvancedGUI_PipeTShapeDlg::processPreview() {
+  if(mainFrame()->CheckBoxPreview->isChecked())
+    DisplayPreview();
+  else
+    erasePreview(true);
+}