Salome HOME
Typo-fix by Kunda
[modules/geom.git] / src / BasicGUI / BasicGUI_PointDlg.cxx
index bee8d70ebd337549fe1b1637d9f1939ad9f7f220..5d7668a8a59bb12a4a6153c44a72877c84d763da 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // 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
@@ -45,6 +45,7 @@
 #include <QRadioButton>
 #include <QMenu>
 #include <QTimer>
+#include <QList>
 
 #include <gp_Pnt.hxx>
 #include <TopoDS_Shape.hxx>
@@ -68,8 +69,6 @@
 #define SPACING 6
 #define MARGIN  9
 
-enum { SelectEdge, SelectWire };
-
 //=================================================================================
 // class    : BasicGUI_PointDlg()
 // purpose  : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
@@ -126,13 +125,17 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren
   GroupXYZ->TextLabel2->setText(tr("GEOM_Y"));
   GroupXYZ->TextLabel3->setText(tr("GEOM_Z"));
 
-  GroupOnCurve = new DlgRef_2Sel1Spin(centralWidget());
+  GroupOnCurve = new DlgRef_2Sel1Spin2Check(centralWidget());
   GroupOnCurve->GroupBox1->setTitle(tr("GEOM_POINT_ON_EDGE"));
   GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE"));
   GroupOnCurve->TextLabel2->setText(tr("GEOM_START_POINT"));
   GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
   GroupOnCurve->PushButton1->setIcon(image2);
   GroupOnCurve->PushButton2->setIcon(image2);
+  GroupOnCurve->TextLabel3->setText(tr("GEOM_PARAMETER"));
+  GroupOnCurve->CheckButton1->setText(tr("GEOM_TAKE_ORIENTATION_INTO_ACCOUNT"));
+  GroupOnCurve->CheckButton2->setAttribute( Qt::WA_DeleteOnClose );
+  GroupOnCurve->CheckButton2->close();
 
   GroupOnSurface = new DlgRef_1Sel2Spin(centralWidget());
   GroupOnSurface->GroupBox1->setTitle(tr("GEOM_POINT_ON_FACE"));
@@ -150,20 +153,15 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(GeometryGUI* theGeometryGUI, QWidget* paren
   GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ"));
 
   /* popup menu for line intersect buttons */
-  myBtnPopup = new QMenu(this);
   QIcon ico_line = QIcon(image6);
   QIcon ico_wire = QIcon(image7);
-  myActions[myBtnPopup->addAction(ico_line, tr("GEOM_EDGE"))] = SelectEdge;
-  myActions[myBtnPopup->addAction(ico_wire, tr("GEOM_WIRE"))] = SelectWire;
 
   GroupLineIntersection = new DlgRef_2Sel(centralWidget());
   GroupLineIntersection->GroupBox1->setTitle(tr("GEOM_LINE_INTERSECTION"));
   GroupLineIntersection->TextLabel1->setText(tr("GEOM_LINE1"));
   GroupLineIntersection->TextLabel2->setText(tr("GEOM_LINE2"));
   GroupLineIntersection->PushButton1->setIcon(image2);
-  GroupLineIntersection->PushButton1->setMenu(myBtnPopup);
   GroupLineIntersection->PushButton2->setIcon(image2);
-  GroupLineIntersection->PushButton2->setMenu(myBtnPopup);
   GroupLineIntersection->LineEdit2->setEnabled(false);
 
   myCoordGrp = new QGroupBox(tr("GEOM_COORDINATES_RES"), centralWidget());
@@ -264,6 +262,7 @@ void BasicGUI_PointDlg::Init()
 
   initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., step, "parametric_precision");
   GroupOnCurve->SpinBox_DX->setValue(0.5);
+  GroupOnCurve->CheckButton1->setChecked(true);
 
   initSpinBox(GroupOnSurface->SpinBox_DX, 0., 1., step, "parametric_precision");
   GroupOnSurface->SpinBox_DX->setValue(0.5);
@@ -281,14 +280,14 @@ void BasicGUI_PointDlg::Init()
 
   connect(myParamCoord,   SIGNAL(buttonClicked(int)), this, SLOT(ClickParamCoord(int)));
 
+  connect(GroupOnCurve->CheckButton1,         SIGNAL(toggled(bool)), this, SLOT(CheckBoxClicked()));
+
   connect(GroupOnCurve->PushButton1,          SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupOnCurve->PushButton2,          SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupOnSurface->PushButton1,        SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupLineIntersection->PushButton1, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupLineIntersection->PushButton2, SIGNAL(pressed()), this, SLOT(SetEditCurrentArgument()));
-
-  connect(myBtnPopup, SIGNAL(triggered(QAction*)), this, SLOT(onBtnPopup(QAction*)));
-
+  
   connect(GroupOnCurve->SpinBox_DX,   SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
   connect(GroupOnSurface->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
   connect(GroupOnSurface->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
@@ -336,7 +335,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
     {
       globalSelection(); // close local contexts, if any
       myNeedType = TopAbs_VERTEX;
-      localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
+      localSelection(myNeedType);
 
       GroupRefPoint->hide();
       GroupOnCurve->hide();
@@ -351,7 +350,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
     {
       globalSelection(); // close local contexts, if any
       myNeedType = TopAbs_VERTEX;
-      localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
+      localSelection(myNeedType);
 
       myEditCurrentArgument = GroupRefPoint->LineEdit1;
       myEditCurrentArgument->setText("");
@@ -370,7 +369,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
     {
       globalSelection(); // close local contexts, if any
       myNeedType = TopAbs_EDGE;
-      localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
+      localSelection(myNeedType);
 
       myEditCurrentArgument = GroupOnCurve->LineEdit1;
       myEditCurrentArgument->setText("");
@@ -391,8 +390,9 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
   case GEOM_POINT_INTINT:
     {
       globalSelection(); // close local contexts, if any
-      myNeedType = TopAbs_EDGE;
-      localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
+      std::list<int> needTypes;
+      needTypes.push_back( TopAbs_EDGE ), needTypes.push_back( TopAbs_WIRE );
+      localSelection(needTypes );
 
       myEditCurrentArgument = GroupLineIntersection->LineEdit1;
       GroupLineIntersection->LineEdit1->setText("");
@@ -416,7 +416,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
     {
       globalSelection(); // close local contexts, if any
       myNeedType = TopAbs_FACE;
-      localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
+      localSelection(myNeedType);
 
       myEditCurrentArgument = GroupOnSurface->LineEdit1;
       myEditCurrentArgument->setText("");
@@ -500,7 +500,14 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
       myLine2.nullify();
   }
 
-  GEOM::GeomObjPtr aSelectedObject = getSelected(myNeedType);
+  GEOM::GeomObjPtr aSelectedObject;
+  if (id == GEOM_POINT_INTINT) {
+    QList<TopAbs_ShapeEnum> needTypes;
+    needTypes << TopAbs_EDGE, needTypes << TopAbs_WIRE;
+    aSelectedObject= getSelected(needTypes);
+  }
+  else 
+    aSelectedObject= getSelected(myNeedType);
   TopoDS_Shape aShape;
   if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) {
     QString aName = GEOMBase::GetName(aSelectedObject.get());
@@ -535,19 +542,13 @@ void BasicGUI_PointDlg::SelectionIntoArgument()
       if (myEditCurrentArgument == GroupLineIntersection->LineEdit1) {
         myLine1 = aSelectedObject;
         if (myLine1 && !myLine2) {
-          GroupLineIntersection->PushButton2->setMenu(0);
           GroupLineIntersection->PushButton2->click();
-          GroupLineIntersection->PushButton2->setDown(true);
-          GroupLineIntersection->PushButton2->setMenu(myBtnPopup);
         }
       }
       else if (myEditCurrentArgument == GroupLineIntersection->LineEdit2) {
         myLine2 = aSelectedObject;
         if (myLine2 && !myLine1) {
-          GroupLineIntersection->PushButton1->setMenu(0);
           GroupLineIntersection->PushButton1->click();
-          GroupLineIntersection->PushButton1->setDown(true);
-          GroupLineIntersection->PushButton1->setMenu(myBtnPopup);
         }
       }
     }
@@ -574,14 +575,14 @@ void BasicGUI_PointDlg::SetEditCurrentArgument()
     GroupRefPoint->LineEdit1->setFocus();
     myEditCurrentArgument = GroupRefPoint->LineEdit1;
     globalSelection(); // close local contexts, if any
-    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
+    localSelection(TopAbs_VERTEX);
   }
   else if (send == GroupOnCurve->PushButton1) {
     GroupOnCurve->LineEdit1->setFocus();
     myEditCurrentArgument = GroupOnCurve->LineEdit1;
     globalSelection(); // close local contexts, if any
     myNeedType = TopAbs_EDGE;
-    localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
+    localSelection(myNeedType);
     GroupOnCurve->PushButton2->setDown(false);
     GroupOnCurve->LineEdit1->setEnabled(true);
     GroupOnCurve->LineEdit2->setEnabled(false);
@@ -591,7 +592,7 @@ void BasicGUI_PointDlg::SetEditCurrentArgument()
     myEditCurrentArgument = GroupOnCurve->LineEdit2;
     globalSelection(); // close local contexts, if any
     myNeedType = TopAbs_VERTEX;
-    localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
+    localSelection(myNeedType);
     GroupOnCurve->PushButton1->setDown(false);
     GroupOnCurve->LineEdit2->setEnabled(true);
     GroupOnCurve->LineEdit1->setEnabled(false);
@@ -601,7 +602,7 @@ void BasicGUI_PointDlg::SetEditCurrentArgument()
     GroupOnSurface->LineEdit1->setFocus();
     myEditCurrentArgument = GroupOnSurface->LineEdit1;
     globalSelection(); // close local contexts, if any
-    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE);
+    localSelection(TopAbs_FACE);
   }
   else if (send == GroupLineIntersection->PushButton1) {
     GroupLineIntersection->LineEdit1->setFocus();
@@ -619,9 +620,9 @@ void BasicGUI_PointDlg::SetEditCurrentArgument()
   }
   send->setDown(true);
 
-  if ((send == GroupLineIntersection->PushButton1 ||
-         send == GroupLineIntersection->PushButton2) && !myBusy)
-    SelectionIntoArgument();
+  //  if ((send == GroupLineIntersection->PushButton1 ||
+  //         send == GroupLineIntersection->PushButton2) && !myBusy)
+  //    SelectionIntoArgument();
 }
 
 
@@ -675,14 +676,14 @@ void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
 // function : CheckBoxClicked()
 // purpose  : Check Boxes Management
 //=================================================================================
-void BasicGUI_PointDlg::CheckBoxClicked(int  State)
+void BasicGUI_PointDlg::CheckBoxClicked()
 {
   displayPreview(true);
 }
 
 
 //=================================================================================
-// funcion  : getParameter()
+// function  : getParameter()
 // purpose  :
 //=================================================================================
 double BasicGUI_PointDlg::getParameter() const
@@ -692,7 +693,7 @@ double BasicGUI_PointDlg::getParameter() const
 
 
 //=================================================================================
-// funcion  : getUParameter()
+// function  : getUParameter()
 // purpose  :
 //=================================================================================
 double BasicGUI_PointDlg::getUParameter() const
@@ -702,7 +703,7 @@ double BasicGUI_PointDlg::getUParameter() const
 
 
 //=================================================================================
-// funcion  : getVParameter()
+// function  : getVParameter()
 // purpose  :
 //=================================================================================
 double BasicGUI_PointDlg::getVParameter() const
@@ -827,7 +828,9 @@ bool BasicGUI_PointDlg::execute(ObjectList& objects)
   case GEOM_POINT_EDGE :
     {
       if (myParamCoord->checkedId() == PARAM_VALUE) {
-        anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter());
+        bool isUseOrientation = GroupOnCurve->CheckButton1->isChecked();
+
+        anObj = anOper->MakePointOnCurve(myEdge.get(), getParameter(), isUseOrientation);
         aParameters<<GroupOnCurve->SpinBox_DX->text();
       }
       else if (myParamCoord->checkedId() == LENGTH_VALUE) {
@@ -939,6 +942,17 @@ void BasicGUI_PointDlg::addSubshapesToStudy()
   }
 }
 
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> BasicGUI_PointDlg::getSourceObjects()
+{
+  QList<GEOM::GeomObjPtr> res;
+  res << myRefPoint << myEdge << myLine1 << myLine2 << myFace;
+  return res;
+}
+
 //=================================================================================
 // function : ClickParamCoord()
 // purpose  :
@@ -968,6 +982,7 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
     GroupOnCurve->LineEdit2->setVisible(isLength);
     GroupOnCurve->TextLabel3->setVisible(isParam || isLength);
     GroupOnCurve->SpinBox_DX->setVisible(isParam || isLength);
+    GroupOnCurve->CheckButton1->setVisible(isParam);
     if (isParam){
       initSpinBox(GroupOnCurve->SpinBox_DX, 0., 1., 0.1, "parametric_precision");
       GroupOnCurve->SpinBox_DX->setValue(0.5);
@@ -980,29 +995,18 @@ void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
     }
   }
   else if (id == GEOM_POINT_SURF) {
-    GroupOnSurface->TextLabel2->setShown(isParam);
-    GroupOnSurface->TextLabel3->setShown(isParam);
-    GroupOnSurface->SpinBox_DX->setShown(isParam);
-    GroupOnSurface->SpinBox_DY->setShown(isParam);
+    GroupOnSurface->TextLabel2->setVisible(isParam);
+    GroupOnSurface->TextLabel3->setVisible(isParam);
+    GroupOnSurface->SpinBox_DX->setVisible(isParam);
+    GroupOnSurface->SpinBox_DY->setVisible(isParam);
   }
 
-  GroupXYZ->setShown(!isParam && !isLength);
+  GroupXYZ->setVisible(!isParam && !isLength);
 
   if (theIsUpdate)
     QTimer::singleShot(50, this, SLOT(updateSize()));
 }
 
-//=================================================================================
-// function : onBtnPopup()
-// purpose  :
-//=================================================================================
-void BasicGUI_PointDlg::onBtnPopup(QAction* a)
-{
-  globalSelection(); // close local contexts, if any
-  myNeedType = myActions[a] == SelectEdge ? TopAbs_EDGE : TopAbs_WIRE;
-  localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
-}
-
 //=================================================================================
 // function : updateSize
 // purpose  : adjust dialog size to minimum