Salome HOME
updated copyright message
[modules/geom.git] / src / AdvancedGUI / AdvancedGUI_PipeTShapeDlg.cxx
index 3c2ede934249ad16d1ca25c1e72002d9393bd236..49bd6013a8ea9c6690206b3a3bf1e7c90f13d9a7 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "AdvancedGUI_PipeTShapeDlg.h"
 
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(AdvancedGEOM)
+
 #include <DlgRef.h>
 #include <GeometryGUI.h>
 #include <GEOMBase.h>
@@ -319,8 +323,25 @@ void AdvancedGUI_PipeTShapeDlg::Init()
   // ChamferOrFillet
   connect(ChamferGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
   connect(FilletGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(ChamferOrFillet(bool)));
-  // Preview
-  //connect(PreviewPushButton, SIGNAL(clicked()), this, SLOT(DisplayPreview()));
+  // Thickness reduction:
+  //   Left
+  connect(LReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
+  connect(LReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(LReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(LReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(LReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  //   Right
+  connect(RReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
+  connect(RReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(RReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(RReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(RReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  //   Incident pipe
+  connect(IReductionGroupParams->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(processPreview()));
+  connect(IReductionGroupParams->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(IReductionGroupParams->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(IReductionGroupParams->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(IReductionGroupParams->SpinBox4, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
   // Position
   connect(JunctionPointsSel->GroupBox1, SIGNAL(toggled(bool)), this, SLOT(SetPosition(bool)));
   connect(JunctionPointsSel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
@@ -399,7 +420,7 @@ void AdvancedGUI_PipeTShapeDlg::ApplyNewDimensions()
 // function : UpdatePicture()
 // purpose  :
 //=================================================================================
-void AdvancedGUI_PipeTShapeDlg::UpdatePicture (QWidget* old, QWidget* now)
+void AdvancedGUI_PipeTShapeDlg::UpdatePicture (QWidget* /*old*/, QWidget* now)
 {
   if (ChamferGroupParams->GroupBox1->isChecked())
     if (now == MainTubeGroupParams->SpinBox_DX)
@@ -483,7 +504,7 @@ void AdvancedGUI_PipeTShapeDlg::SetPosition (bool isChecked)
 // function : ValueChangedInSpinBox()
 // purpose  :
 //=================================================================================
-void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox (double newValue)
+void AdvancedGUI_PipeTShapeDlg::ValueChangedInSpinBox (double /*newValue*/)
 {
   if (JunctionPointsSel->GroupBox1->isChecked() && myOkPoint1 && myOkPoint2 && myOkPoint3)
     CheckCompatiblePosition(myPoint1, myPoint2, myPoint3, 0.01);
@@ -534,7 +555,7 @@ void AdvancedGUI_PipeTShapeDlg::SelectionIntoArgument()
 
           if (aFindedObject->_is_nil()) { // Object not found in study
             GEOM::GEOM_IShapesOperations_var aShapesOp =
-              getGeomEngine()->GetIShapesOperations(getStudyId());
+              getGeomEngine()->GetIShapesOperations();
             aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
           }
           else {
@@ -621,7 +642,7 @@ void AdvancedGUI_PipeTShapeDlg::SetEditCurrentArgument()
   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
   //globalSelection(GEOM_POINT);
   globalSelection(); // close local contexts, if any
-  localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+  localSelection( TopAbs_VERTEX );
   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
           this, SLOT(SelectionIntoArgument()));
 }
@@ -680,6 +701,8 @@ bool AdvancedGUI_PipeTShapeDlg::ClickOnApply()
 
   initName();
 
+  if (!isApplyAndClose())
+    processPreview();
   return true;
 }
 
@@ -824,7 +847,7 @@ void AdvancedGUI_PipeTShapeDlg::DisplayPreview (const bool activate, const bool
 //=================================================================================
 GEOM::GEOM_IOperations_ptr AdvancedGUI_PipeTShapeDlg::createOperation()
 {
-  return getGeomEngine()->GetIAdvancedOperations(getStudyId());
+  return getGeomEngine()->GetPluginOperations("AdvancedEngine");
 }
 
 //=================================================================================
@@ -850,18 +873,45 @@ bool AdvancedGUI_PipeTShapeDlg::isValid (QString& msg)
     ok = LReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
     ok = LReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
     ok = LReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
+    if(MainTubeGroupParams->SpinBox_DX->value() == LReductionGroupParams->SpinBox1->value()) {
+      msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_L") + "\n";
+      ok = false;
+    }
+    if(MainTubeGroupParams->SpinBox_DX->value() + MainTubeGroupParams->SpinBox_DY->value() ==
+       LReductionGroupParams->SpinBox1->value() + LReductionGroupParams->SpinBox2->value()) {
+      msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_L") + "\n";
+      ok = false;
+    }
   }
   if (RReductionGroupParams->GroupBox1->isChecked()) {
     ok = RReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
     ok = RReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
     ok = RReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
     ok = RReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
+    if(MainTubeGroupParams->SpinBox_DX->value() == RReductionGroupParams->SpinBox1->value()) {
+      msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_R") + "\n";
+      ok = false;
+    }
+    if(MainTubeGroupParams->SpinBox_DX->value() + MainTubeGroupParams->SpinBox_DY->value() ==
+       RReductionGroupParams->SpinBox1->value() + RReductionGroupParams->SpinBox2->value()) {
+      msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_R") + "\n";
+      ok = false;
+    }
   }
   if (IReductionGroupParams->GroupBox1->isChecked()) {
     ok = IReductionGroupParams->SpinBox1->isValid(msg, !IsPreview()) && ok;
     ok = IReductionGroupParams->SpinBox2->isValid(msg, !IsPreview()) && ok;
     ok = IReductionGroupParams->SpinBox3->isValid(msg, !IsPreview()) && ok;
     ok = IReductionGroupParams->SpinBox4->isValid(msg, !IsPreview()) && ok;
+    if(IncidentTubeGroupParams->SpinBox_DX->value() == IReductionGroupParams->SpinBox1->value()) {
+      msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_RADII_I") + "\n";
+      ok = false;
+    }
+    if(IncidentTubeGroupParams->SpinBox_DX->value() + IncidentTubeGroupParams->SpinBox_DY->value() ==
+       IReductionGroupParams->SpinBox1->value() + IReductionGroupParams->SpinBox2->value()) {
+      msg += tr("GEOM_PIPETSHAPE_ERR_EQUAL_EXT_RADII_I") + "\n";
+      ok = false;
+    }
   }
 
   ok = fabs(MainTubeGroupParams->SpinBox_DX->value()) > Precision::Confusion() && ok;
@@ -1011,7 +1061,7 @@ bool AdvancedGUI_PipeTShapeDlg::executeNoCheck (ObjectList& objects)
   //   GEOM::GEOM_Object_var anObj;
   GEOM::ListOfGO_var anObj;
 
-  GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation());
+  GEOM::IAdvancedOperations_var anOper = GEOM::IAdvancedOperations::_narrow(getOperation());
 
   //@@ retrieve input values from the widgets here @@//
   CORBA::Double theR1 = MainTubeGroupParams->SpinBox_DX->value();
@@ -1151,7 +1201,7 @@ bool AdvancedGUI_PipeTShapeDlg::executeNoCheck (ObjectList& objects)
     }
 
     if (aParameters.count() > 0)
-      anObj[0]->SetParameters(aParameters.join(":").toLatin1().constData());
+      anObj[0]->SetParameters(aParameters.join(":").toUtf8().constData());
   }
 
   objects.push_back(anObj[0]._retn());
@@ -1167,8 +1217,7 @@ bool AdvancedGUI_PipeTShapeDlg::executeNoCheck (ObjectList& objects)
 // function : restoreSubShapes
 // purpose  :
 //=================================================================================
-void AdvancedGUI_PipeTShapeDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
-                                                  SALOMEDS::SObject_ptr theSObject)
+void AdvancedGUI_PipeTShapeDlg::restoreSubShapes (SALOMEDS::SObject_ptr theSObject)
 {
   SALOMEDS::GenericAttribute_var anAttr;
   if (!theSObject->FindAttribute(anAttr, "AttributeIOR"))
@@ -1186,7 +1235,7 @@ void AdvancedGUI_PipeTShapeDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
   ObjectList::iterator it = pipeTShapeGroupObjects.begin();
 
   for (int i = 0; it != pipeTShapeGroupObjects.end(); it++, i++) {
-    getGeomEngine()->AddInStudy(theStudy, (*it), tr((*it)->GetName()).toStdString().c_str(), theFather);
+    getGeomEngine()->AddInStudy((*it), tr((*it)->GetName()).toStdString().c_str(), theFather);
   }
 }
 
@@ -1202,6 +1251,18 @@ void AdvancedGUI_PipeTShapeDlg::processPreview()
     erasePreview(true);
 }
 
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> AdvancedGUI_PipeTShapeDlg::getSourceObjects()
+{
+  QList<GEOM::GeomObjPtr> res;
+  GEOM::GeomObjPtr aGeomObjPtr1(myPoint1), aGeomObjPtr2(myPoint2), aGeomObjPtr3(myPoint3);
+  res << aGeomObjPtr1 << aGeomObjPtr2 << aGeomObjPtr3;
+  return res;
+}
+
 //=================================================================================
 // function : AdvancedGUI_4Spin
 // purpose  :