X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FAdvancedGUI%2FAdvancedGUI_PipeTShapeDlg.cxx;h=17eae604c718af3c272dd23ae243145fa5c37608;hb=7f46e5fa52cfe13e206ab10e628556e7e393aaf5;hp=2c476cc74697cc3ab1c3d8fcd28d344c58d70271;hpb=004197ec827d52331f0d529202eb4e52a1c4388f;p=modules%2Fgeom.git diff --git a/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx b/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx index 2c476cc74..17eae604c 100644 --- a/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx +++ b/src/AdvancedGUI/AdvancedGUI_PipeTShapeDlg.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 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" @@ -207,7 +207,7 @@ void AdvancedGUI_PipeTShapeDlg::Init() { ChamferGroupParams->SpinBox_DX->setValue(20); ChamferGroupParams->SpinBox_DY->setValue(10); FilletGroupParams->SpinBox_DX->setValue(20); - + CssNormal = QString("QDoubleSpinBox {"); CssNormal.append(MainTubeGroupParams->SpinBox_DZ->styleSheet()); CssNormal.append("}"); @@ -216,7 +216,9 @@ void AdvancedGUI_PipeTShapeDlg::Init() { CssNormal.append("}"); 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(); } //================================================================================= @@ -258,7 +260,7 @@ void AdvancedGUI_PipeTShapeDlg::Init() { //================================================================================= void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions() { QPushButton* send = (QPushButton*) sender(); - + bool ok = false; double newVal; if (send == JunctionPointsSel->PushButton4) { @@ -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(); } } @@ -379,9 +381,9 @@ void AdvancedGUI_PipeTShapeDlg::SetPosition(bool isChecked) { //================================================================================= void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox(double newValue) { - if (myOkPoint1 && myOkPoint2 && myOkPoint3) + if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3) CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01); - DisplayPreview(); + processPreview(); } //================================================================================= @@ -410,10 +412,9 @@ void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument() { // nbSel == 1 if (aSelList.Extent() == 1) { - Standard_Boolean aRes = Standard_False; Handle(SALOME_InteractiveObject) anIO = aSelList.First(); - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes); - if (!CORBA::is_nil(aSelectedObject) && aRes) { + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO); + if (!CORBA::is_nil(aSelectedObject)) { QString aName = GEOMBase::GetName(aSelectedObject); TopoDS_Shape aShape; if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { @@ -427,7 +428,7 @@ void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument() { //Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study + if (aFindedObject->_is_nil()) { // Object not found in study GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); @@ -468,12 +469,11 @@ void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument() { if (myOkPoint1 && myOkPoint2 && myOkPoint3) { CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01); - DisplayPreview(); + processPreview(); } -// Standard_Boolean testResult = Standard_False; -// GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); -// if (!testResult || aSelectedObject->_is_nil()) +// GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First()); +// if (aSelectedObject->_is_nil()) // return; // // myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); @@ -530,7 +530,7 @@ void AdvancedGUI_PipeTShapeDlg::SetEditCurrentArgument() { JunctionPointsSel->LineEdit1->setEnabled(false); JunctionPointsSel->PushButton2->setDown(false); JunctionPointsSel->LineEdit2->setEnabled(false); - } + } // enable line edit myEditCurrentArgument->setEnabled(true); @@ -541,7 +541,7 @@ void AdvancedGUI_PipeTShapeDlg::SetEditCurrentArgument() { JunctionPointsSel->LineEdit4->setText(""); JunctionPointsSel->LineEdit5->setText(""); - + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); // globalSelection(GEOM_POINT); globalSelection(); // close local contexts, if any @@ -570,6 +570,7 @@ void AdvancedGUI_PipeTShapeDlg::SetDoubleSpinBoxStep(double step) { // purpose : //================================================================================= void AdvancedGUI_PipeTShapeDlg::ClickOnOk() { + setIsApplyAndClose( true ); if (ClickOnApply()) ClickOnCancel(); } @@ -598,7 +599,7 @@ void AdvancedGUI_PipeTShapeDlg::ActivateThisDialog() { // currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); if (myOkPoint1 && myOkPoint2 && myOkPoint3) CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01); - DisplayPreview(); + processPreview(); } //================================================================================= @@ -651,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); @@ -664,7 +665,7 @@ void AdvancedGUI_PipeTShapeDlg::ChamferOrFillet(bool) { updateTshapeScreenshotLabel(); if (myOkPoint1 && myOkPoint2 && myOkPoint3) CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01); - DisplayPreview(); + processPreview(); } } @@ -697,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) { @@ -764,10 +765,10 @@ bool AdvancedGUI_PipeTShapeDlg::CheckCompatiblePosition(GEOM::GEOM_Object_var th CORBA::Double theL1 = MainTubeGroupParams->SpinBox_DZ->value(); CORBA::Double theL2 = IncidentTubeGroupParams->SpinBox_DZ->value(); - + JunctionPointsSel->LineEdit4->setText(""); JunctionPointsSel->LineEdit5->setText(""); - + MainTubeGroupParams->SpinBox_DZ->setToolTip(""); IncidentTubeGroupParams->SpinBox_DZ->setToolTip(""); @@ -791,7 +792,7 @@ bool AdvancedGUI_PipeTShapeDlg::CheckCompatiblePosition(GEOM::GEOM_Object_var th double d12 = P1.Distance(P2); double d13 = P1.Distance(P3); double d23 = P2.Distance(P3); - + if (Abs(d12) <= Precision::Confusion()) { // SetErrorCode("Junctions points P1 and P2 are identical"); return false; @@ -857,7 +858,7 @@ bool AdvancedGUI_PipeTShapeDlg::CheckCompatiblePosition(GEOM::GEOM_Object_var th } bool AdvancedGUI_PipeTShapeDlg::execute(ObjectList& objects) { - + if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3) CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01); @@ -975,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); +}