Salome HOME
Revert "Merge branch 'Pre_2.8.0_development'"
authorazv <azv@opencascade.com>
Fri, 23 Jun 2017 12:57:29 +0000 (15:57 +0300)
committerazv <azv@opencascade.com>
Fri, 23 Jun 2017 12:57:29 +0000 (15:57 +0300)
This reverts commit bf64d76b7e6021149db8e0e38c2697a9a0c44f1b, reversing
changes made to cacdfa1cd62583b9f40fe6a05e1b9e63f8fe2f03.

# Conflicts:
# src/SketchPlugin/plugin-Sketch.xml

116 files changed:
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI_Ax2.h
src/GeomAPI/GeomAPI_Circ.h
src/GeomAPI/GeomAPI_Dir.h
src/GeomAPI/GeomAPI_Edge.cpp
src/GeomAPI/GeomAPI_Edge.h
src/GeomAPI/GeomAPI_Ellipse.cpp [deleted file]
src/GeomAPI/GeomAPI_Ellipse.h [deleted file]
src/GeomAPI/GeomAPI_Ellipse2d.cpp [deleted file]
src/GeomAPI/GeomAPI_Ellipse2d.h [deleted file]
src/GeomAPI/GeomAPI_Pln.h
src/GeomAPI/GeomAPI_Pnt.h
src/GeomAPI/GeomAPI_Vertex.h
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeSelection.h
src/ModelAPI/ModelAPI_Events.cpp
src/ModelAPI/ModelAPI_Events.h
src/ModelHighAPI/ModelHighAPI_RefAttr.cpp
src/ModelHighAPI/ModelHighAPI_RefAttr.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_CenterPrs.cpp [deleted file]
src/PartSet/PartSet_CenterPrs.h [deleted file]
src/PartSet/PartSet_ExternalPointsMgr.cpp [deleted file]
src/PartSet/PartSet_ExternalPointsMgr.h [deleted file]
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/PythonAPI/model/sketcher/__init__.py
src/PythonAPI/model/sketcher/tests.py [deleted file]
src/PythonAPI/model/sketcher/tools.py
src/PythonAPI/model/tests/tests.py
src/SketchAPI/SketchAPI_Constraint.cpp
src/SketchAPI/SketchAPI_Rectangle.cpp
src/SketchAPI/SketchAPI_Rectangle.h
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchAPI/SketchAPI_Sketch.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.cpp [deleted file]
src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.h [deleted file]
src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.cpp [deleted file]
src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.h [deleted file]
src/SketchPlugin/SketchPlugin_Ellipse.cpp [deleted file]
src/SketchPlugin/SketchPlugin_Ellipse.h [deleted file]
src/SketchPlugin/SketchPlugin_MacroCircle.cpp
src/SketchPlugin/SketchPlugin_MacroEllipse.cpp [deleted file]
src/SketchPlugin/SketchPlugin_MacroEllipse.h [deleted file]
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/Test/TestArcBehavior.py
src/SketchPlugin/Test/TestConstraintDistance.py
src/SketchPlugin/Test/TestConstraintDistanceBehavior.py [deleted file]
src/SketchPlugin/Test/TestConstraintDistanceHorizontal.py [deleted file]
src/SketchPlugin/Test/TestConstraintDistanceVertical.py [deleted file]
src/SketchPlugin/Test/TestConstraintFixed.py
src/SketchPlugin/Test/TestConstraintHorizontalValidator.py [deleted file]
src/SketchPlugin/Test/TestConstraintTangent.py
src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py
src/SketchPlugin/Test/TestCreateArcByTangentEdge.py
src/SketchPlugin/Test/TestCreateArcByThreePoints.py
src/SketchPlugin/Test/TestCreateArcChangeType.py
src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py
src/SketchPlugin/Test/TestCreateCircleByThreePoints.py
src/SketchPlugin/Test/TestCreateCircleChangeType.py
src/SketchPlugin/Test/TestFillet.py
src/SketchPlugin/Test/TestFilletInteracting.py
src/SketchPlugin/Test/TestMoveArc.py [deleted file]
src/SketchPlugin/Test/TestMoveCircle.py [deleted file]
src/SketchPlugin/Test/TestMoveLine.py [deleted file]
src/SketchPlugin/Test/TestMovePoint.py [deleted file]
src/SketchPlugin/Test/TestMovementComplex.py [deleted file]
src/SketchPlugin/icons/distance_h.png [deleted file]
src/SketchPlugin/icons/distance_v.png [deleted file]
src/SketchPlugin/icons/ellipse.png [deleted file]
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/CMakeLists.txt
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Defs.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintDistance.cpp
src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_ConstraintFixed.h
src/SketchSolver/SketchSolver_ConstraintMovement.cpp [deleted file]
src/SketchSolver/SketchSolver_ConstraintMovement.h [deleted file]
src/SketchSolver/SketchSolver_Error.h
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SketchSolver_Manager.cpp
src/SketchSolver/SketchSolver_Manager.h
src/SketchSolver/SketchSolver_Storage.h
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_MenuMgr.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 325e5055d15213afea642371172db3df3879a03a..8e191e4fd53c93614ce1faf0e1a2025ce9b259a6 100644 (file)
@@ -56,8 +56,6 @@ SET(PROJECT_HEADERS
     GeomAPI_Trsf.h
     GeomAPI_Angle2d.h
     GeomAPI_Wire.h
-    GeomAPI_Ellipse.h
-    GeomAPI_Ellipse2d.h
 )
 
 SET(PROJECT_SOURCES
@@ -92,8 +90,6 @@ SET(PROJECT_SOURCES
     GeomAPI_Trsf.cpp
     GeomAPI_Angle2d.cpp
     GeomAPI_Wire.cpp
-    GeomAPI_Ellipse.cpp
-    GeomAPI_Ellipse2d.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 39cd19c3f42e94cd0796d1b3558ff64844f47c86..e7658e88ef24d74ecfe2d5d4d4163e154efb2fa7 100644 (file)
@@ -70,7 +70,4 @@ public:
   std::shared_ptr<GeomAPI_Dir> dir() const;
 };
 
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_Ax2> GeomAx2Ptr;
-
 #endif
index 6f4215965ca75da375b1548f217c13fbbe9d7a4d..218efd9ff474505ba80fd023090c5e36e1b68801 100644 (file)
@@ -37,8 +37,7 @@ class GeomAPI_Circ : public GeomAPI_Interface
 {
  public:
 
-  /** \brief Constructs a circle of radius Radius, where theAx2 locates
-   *  the circle and defines its orientation in 3D space such that:\n
+  /** \brief Constructs a circle of radius Radius, where theAx2 locates the circle and defines its orientation in 3D space such that:\n
    *  - the center of the circle is the origin of theAx2;\n
    *  - the origin, "X Direction" and "Y Direction" of theAx2 define the plane of the circle;\n
    *  - theAx2 is the local coordinate system of the circle.\n
@@ -78,8 +77,5 @@ class GeomAPI_Circ : public GeomAPI_Interface
                                       double& theParameter) const;
 };
 
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_Circ> GeomCirclePtr;
-
 #endif
 
index 7e2a0bda7f0580b04afb36d4f7be963839fdabc0..9462aabed1abbacf6376df973ee043066165b0ae 100644 (file)
@@ -78,8 +78,5 @@ class GeomAPI_Dir : public GeomAPI_Interface
 
 };
 
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_Dir> GeomDirPtr;
-
 #endif
 
index 9927c2ae9cc3bb899fcb53611073f05d3d67b436..c336050f9c08bdd5f35cf56cd3e08e8a090303da 100644 (file)
@@ -24,8 +24,6 @@
 #include<GeomAPI_Circ.h>
 #include<GeomAPI_Dir.h>
 #include<GeomAPI_Lin.h>
-#include<GeomAPI_Ax2.h>
-#include<GeomAPI_Ellipse.h>
 
 #include <BRepAdaptor_Curve.hxx>
 
 #include <Geom_Curve.hxx>
 #include <Geom_Line.hxx>
 #include <Geom_Circle.hxx>
-#include <Geom_Ellipse.hxx>
 #include <GeomAdaptor_Curve.hxx>
 #include <gp_Ax1.hxx>
 #include <gp_Pln.hxx>
-#include <gp_Elips.hxx>
 
 #include <GCPnts_AbscissaPoint.hxx>
 
@@ -100,16 +96,6 @@ bool GeomAPI_Edge::isArc() const
   return false;
 }
 
-bool GeomAPI_Edge::isEllipse() const
-{
-  const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
-  double aFirst, aLast;
-  Handle(Geom_Curve) aCurve = BRep_Tool::Curve((const TopoDS_Edge&)aShape, aFirst, aLast);
-  if (aCurve->IsKind(STANDARD_TYPE(Geom_Ellipse)))
-    return true;
-  return false;
-}
-
 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Edge::firstPoint()
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
@@ -130,14 +116,14 @@ std::shared_ptr<GeomAPI_Pnt> GeomAPI_Edge::lastPoint()
   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
 }
 
-std::shared_ptr<GeomAPI_Circ> GeomAPI_Edge::circle() const
+std::shared_ptr<GeomAPI_Circ> GeomAPI_Edge::circle()
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
   double aFirst, aLast;
   Handle(Geom_Curve) aCurve = BRep_Tool::Curve((const TopoDS_Edge&)aShape, aFirst, aLast);
-  if (!aCurve.IsNull()) {
+  if (aCurve) {
     Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast(aCurve);
-    if (!aCirc.IsNull()) {
+    if (aCirc) {
       gp_Pnt aLoc = aCirc->Location();
       std::shared_ptr<GeomAPI_Pnt> aCenter(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
       gp_Dir anAxis = aCirc->Axis().Direction();
@@ -148,24 +134,7 @@ std::shared_ptr<GeomAPI_Circ> GeomAPI_Edge::circle() const
   return std::shared_ptr<GeomAPI_Circ>(); // not circle
 }
 
-std::shared_ptr<GeomAPI_Ellipse> GeomAPI_Edge::ellipse() const
-{
-  const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
-  double aFirst, aLast;
-  Handle(Geom_Curve) aCurve = BRep_Tool::Curve((const TopoDS_Edge&)aShape, aFirst, aLast);
-  if (!aCurve.IsNull()) {
-    Handle(Geom_Ellipse) aElips = Handle(Geom_Ellipse)::DownCast(aCurve);
-    if (!aElips.IsNull()) {
-      gp_Elips aGpElips = aElips->Elips();
-      std::shared_ptr<GeomAPI_Ellipse> aEllipse(new GeomAPI_Ellipse());
-      aEllipse->setImpl(new gp_Elips(aGpElips));
-      return aEllipse;
-    }
-  }
-  return std::shared_ptr<GeomAPI_Ellipse>(); // not elipse
-}
-
-std::shared_ptr<GeomAPI_Lin> GeomAPI_Edge::line() const
+std::shared_ptr<GeomAPI_Lin> GeomAPI_Edge::line()
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
   double aFirst, aLast;
index 59b36c04207fe3d9b0685942fb42aac4b0a0989f..44c76df82e306eee106ff9722afff13c6f81d00c 100644 (file)
@@ -27,7 +27,6 @@ class GeomAPI_Pln;
 class GeomAPI_Pnt;
 class GeomAPI_Circ;
 class GeomAPI_Lin;
-class GeomAPI_Ellipse;
 
 /**\class GeomAPI_Edge
 * \ingroup DataModel
@@ -57,10 +56,6 @@ public:
   GEOMAPI_EXPORT
   bool isArc() const;
 
-  /// Verifies that the edge is an arc of circle
-  GEOMAPI_EXPORT
-  bool isEllipse() const;
-
   /// Returns the first vertex coordinates of the edge
   GEOMAPI_EXPORT
   std::shared_ptr<GeomAPI_Pnt> firstPoint();
@@ -71,15 +66,11 @@ public:
 
   /// Returns a circle if edge is based on the circle curve
   GEOMAPI_EXPORT
-  std::shared_ptr<GeomAPI_Circ> circle() const;
-
-  /// Returns an ellipse if edge is based on the ellipse curve
-  GEOMAPI_EXPORT
-  std::shared_ptr<GeomAPI_Ellipse> ellipse() const;
+  std::shared_ptr<GeomAPI_Circ> circle();
 
   /// Returns a line if edge is based on the linear curve
   GEOMAPI_EXPORT
-  std::shared_ptr<GeomAPI_Lin> line() const;
+  std::shared_ptr<GeomAPI_Lin> line();
 
   /// Returns true if the current edge is geometrically equal to the given edge
   GEOMAPI_EXPORT
@@ -98,8 +89,5 @@ public:
   double length() const;
 };
 
-//! Pointer on attribute object
-typedef std::shared_ptr<GeomAPI_Edge> GeomEdgePtr;
-
 #endif
 
diff --git a/src/GeomAPI/GeomAPI_Ellipse.cpp b/src/GeomAPI/GeomAPI_Ellipse.cpp
deleted file mode 100644 (file)
index 9c0926a..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        GeomAPI_Ellipse.cpp
-// Created:     25 April 2017
-// Author:      Vitaly Smetannikov
-
-#include "GeomAPI_Ellipse.h"
-#include "GeomAPI_Ax2.h"
-#include "GeomAPI_Pnt.h"
-
-#include <gp_Elips.hxx>
-
-#define MY_ELIPS implPtr<gp_Elips>()
-
-GeomAPI_Ellipse::GeomAPI_Ellipse(const std::shared_ptr<GeomAPI_Ax2>& theAx2,
-                                 double theMajorRadius, double theMinorRadius)
-: GeomAPI_Interface(new gp_Elips(theAx2->impl<gp_Ax2>(), theMajorRadius, theMinorRadius))
-{
-}
-
-std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ellipse::center() const
-{
-  const gp_Pnt& aCenter = MY_ELIPS->Location();
-  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
-}
-
-GeomPointPtr GeomAPI_Ellipse::firstFocus() const
-{
-  const gp_Pnt& aFirst = MY_ELIPS->Focus1();
-  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aFirst.X(), aFirst.Y(), aFirst.Z()));
-}
-
-GeomPointPtr GeomAPI_Ellipse::secondFocus() const
-{
-  const gp_Pnt& aSecond = MY_ELIPS->Focus2();
-  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSecond.X(), aSecond.Y(), aSecond.Z()));
-}
-
-double GeomAPI_Ellipse::minorRadius() const
-{
-  return MY_ELIPS->MinorRadius();
-}
-
-double GeomAPI_Ellipse::majorRadius() const
-{
-  return MY_ELIPS->MajorRadius();
-}
diff --git a/src/GeomAPI/GeomAPI_Ellipse.h b/src/GeomAPI/GeomAPI_Ellipse.h
deleted file mode 100644 (file)
index 02536b2..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        GeomAPI_Ellipse.h
-// Created:     25 April 2017
-// Author:      Vitaly Smetannikov
-
-#ifndef GeomAPI_Ellipse_H_
-#define GeomAPI_Ellipse_H_
-
-#include <GeomAPI_Interface.h>
-#include <memory>
-
-class GeomAPI_Pnt;
-class GeomAPI_Ax2;
-
-
-/**\class GeomAPI_Ellipse
- * \ingroup DataModel
- * \brief Ellipse in 3D
- */
-class GeomAPI_Ellipse : public GeomAPI_Interface
-{
-public:
-
-  /// \brief Constructs an epty ellipse
-  GEOMAPI_EXPORT GeomAPI_Ellipse() : GeomAPI_Interface() {}
-
-  /** \brief Constructs an ellipse with major and minor radiuses,
-   *  where theAx2 locates the ellipse and defines its orientation in 3D space such that:\n
-   *  - the center of the circle is the origin of theAx2;\n
-   *  - the origin, "X Direction" and "Y Direction" of theAx2 define the plane of the circle;\n
-   *  - theAx2 is the local coordinate system of the circle.\n
-   *    Note: It is possible to create a circle where Radius is equal to 0.0. raised if Radius < 0.
-   */
-  GEOMAPI_EXPORT GeomAPI_Ellipse(const std::shared_ptr<GeomAPI_Ax2>& theAx2,
-                                 double theMajorRadius, double theMinorRadius);
-
-  /// Returns center of the ellipse
-  GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> center() const;
-
-  /// Returns first focus of the ellipse
-  GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> firstFocus() const;
-
-  /// Returns second focus of the ellipse
-  GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> secondFocus() const;
-
-  /// Returns minor radius of the ellipse
-  GEOMAPI_EXPORT double minorRadius() const;
-
-  /// Returns major radius of the ellipse
-  GEOMAPI_EXPORT double majorRadius() const;
-
-};
-
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_Ellipse> GeomEllipsePtr;
-
-#endif
diff --git a/src/GeomAPI/GeomAPI_Ellipse2d.cpp b/src/GeomAPI/GeomAPI_Ellipse2d.cpp
deleted file mode 100644 (file)
index d789f71..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        GeomAPI_Ellipse2d.cpp
-// Created:     26 April 2017
-// Author:      Artem ZHIDKOV
-
-#include <GeomAPI_Ellipse2d.h>
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_Pnt2d.h>
-
-#include <gp_Ax22d.hxx>
-#include <gp_Elips2d.hxx>
-#include <Precision.hxx>
-
-#define MY_ELLIPSE implPtr<gp_Elips2d>()
-
-static gp_Elips2d* newEllipse(const gp_Pnt2d& theCenter,
-                              const gp_Dir2d& theXAxis,
-                              const double theMajorRadius,
-                              const double theMinorRadius)
-{
-  if (theMajorRadius < theMinorRadius - Precision::Confusion()) {
-    return newEllipse(theCenter, gp_Dir2d(-theXAxis.Y(), theXAxis.X()),
-                      theMinorRadius, theMajorRadius);
-  }
-
-  gp_Ax22d anAxis(theCenter, theXAxis);
-  return new gp_Elips2d(anAxis, theMajorRadius, theMinorRadius);
-}
-
-static gp_Elips2d* newEllipse(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
-                              const std::shared_ptr<GeomAPI_Pnt2d>& theAxisPoint,
-                              const std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint)
-{
-  const gp_Pnt2d& aCenter = theCenter->impl<gp_Pnt2d>();
-  const gp_Pnt2d& anAxisPnt = theAxisPoint->impl<gp_Pnt2d>();
-  const gp_Pnt2d& aPassedPnt = thePassingPoint->impl<gp_Pnt2d>();
-
-  gp_Dir2d aXAxis(anAxisPnt.XY() - aCenter.XY());
-  double aMajorRadius = anAxisPnt.Distance(aCenter);
-
-  gp_XY aPassedDir = aPassedPnt.XY() - aCenter.XY();
-
-  double X = aPassedDir.Dot(aXAxis.XY()) / aMajorRadius;
-  if (Abs(X) > 1.0 - Precision::Confusion())
-    return 0; // ellipse cannot be created for such parameters
-
-  double Y = aPassedDir.CrossMagnitude(aXAxis.XY());
-  double aMinorRadius = Y / Sqrt(1. - X * X);
-
-  return newEllipse(aCenter, aXAxis, aMajorRadius, aMinorRadius);
-}
-
-
-GeomAPI_Ellipse2d::GeomAPI_Ellipse2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
-                                     const std::shared_ptr<GeomAPI_Dir2d>& theXAxis,
-                                     const double theMajorRadius,
-                                     const double theMinorRadius)
-  : GeomAPI_Interface(newEllipse(theCenter->impl<gp_Pnt2d>(), theXAxis->impl<gp_Dir2d>(),
-                                 theMajorRadius, theMinorRadius))
-{
-}
-
-GeomAPI_Ellipse2d::GeomAPI_Ellipse2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
-                                     const std::shared_ptr<GeomAPI_Pnt2d>& theAxisPoint,
-                                     const std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint)
-  : GeomAPI_Interface(newEllipse(theCenter, theAxisPoint, thePassingPoint))
-{
-}
-
-std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Ellipse2d::center() const
-{
-  const gp_Pnt2d& aCenter = MY_ELLIPSE->Location();
-  return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aCenter.X(), aCenter.Y()));
-}
-
-std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Ellipse2d::firstFocus() const
-{
-  const gp_Pnt2d& aFirst = MY_ELLIPSE->Focus1();
-  return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aFirst.X(), aFirst.Y()));
-}
-
-std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Ellipse2d::secondFocus() const
-{
-  const gp_Pnt2d& aSecond = MY_ELLIPSE->Focus2();
-  return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aSecond.X(), aSecond.Y()));
-}
-
-double GeomAPI_Ellipse2d::minorRadius() const
-{
-  return MY_ELLIPSE->MinorRadius();
-}
-
-double GeomAPI_Ellipse2d::majorRadius() const
-{
-  return MY_ELLIPSE->MajorRadius();
-}
diff --git a/src/GeomAPI/GeomAPI_Ellipse2d.h b/src/GeomAPI/GeomAPI_Ellipse2d.h
deleted file mode 100644 (file)
index ef8840d..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        GeomAPI_Ellipse2d.h
-// Created:     26 April 2017
-// Author:      Artem ZHIDKOV
-
-#ifndef GeomAPI_Ellipse2d_H_
-#define GeomAPI_Ellipse2d_H_
-
-#include <GeomAPI_Interface.h>
-
-class GeomAPI_Pnt2d;
-class GeomAPI_Dir2d;
-
-/**\class GeomAPI_Ellipse2d
- * \ingroup DataModel
- * \brief Ellipse in 2D
- */
-class GeomAPI_Ellipse2d : public GeomAPI_Interface
-{
-public:
-  /// \brief Constructs ellipse by center, X-axis and given radii
-  GEOMAPI_EXPORT GeomAPI_Ellipse2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
-                                   const std::shared_ptr<GeomAPI_Dir2d>& theXAxis,
-                                   const double theMajorRadius,
-                                   const double theMinorRadius);
-
-  /// \brief Constructs ellipse by center and two points lying on the ellipse:
-  ///        first of them defines an axis of the ellipse
-  ///        and another is just placed on the ellipse.
-  GEOMAPI_EXPORT GeomAPI_Ellipse2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
-                                   const std::shared_ptr<GeomAPI_Pnt2d>& theAxisPoint,
-                                   const std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
-
-  /// Returns center of the ellipse
-  GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt2d> center() const;
-
-  /// Returns first focus of the ellipse
-  GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt2d> firstFocus() const;
-
-  /// Returns second focus of the ellipse
-  GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt2d> secondFocus() const;
-
-  /// Returns minor radius of the ellipse
-  GEOMAPI_EXPORT double minorRadius() const;
-
-  /// Returns major radius of the ellipse
-  GEOMAPI_EXPORT double majorRadius() const;
-};
-
-#endif
index 14d886ee3f94c17cab943c3f9e3c5eea4f8dfb8f..4a22b226aac326987c620a4d70cbaf89c80380f0 100644 (file)
@@ -95,8 +95,5 @@ class GeomAPI_Pln : public GeomAPI_Interface
   std::shared_ptr<GeomAPI_Lin> intersect(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
 };
 
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_Pln> GeomPlanePtr;
-
 #endif
 
index 333a2350acf1dfe8c710e469fd0a1015c80a6dde..3af09c1275ed7e7480adab7d5d78390239c5992d 100644 (file)
@@ -91,7 +91,4 @@ class GeomAPI_Pnt : public GeomAPI_Interface
   void translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist);
 };
 
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_Pnt> GeomPointPtr;
-
 #endif
index cee8fd66b36bc45a441ed254c957750c0a48d9fa..62160593b935e3133bf0bb59d7cf44c2f0df4160 100644 (file)
@@ -52,8 +52,5 @@ public:
   bool isEqual(const std::shared_ptr<GeomAPI_Shape> theVert) const;
 };
 
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_Vertex> GeomVertexPtr;
-
 #endif
 
index 2e9c9c18ea45bb286d617a6fe91391e09babce54..c292ee4824f55409256af51df5fa1eff68a28024 100644 (file)
 //
 
 #include <GeomAlgoAPI_EdgeBuilder.h>
-
-#include <Bnd_Box.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepBndLib.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Elips.hxx>
 #include <gp_Pln.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <TopoDS.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+
+#include <gp_Ax2.hxx>
+#include <gp_Circ.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
 
 std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::line(
     std::shared_ptr<GeomAPI_Pnt> theStart, std::shared_ptr<GeomAPI_Pnt> theEnd)
@@ -223,23 +222,3 @@ std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::lineCircleArc(
   }
   return aRes;
 }
-
-std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::ellipse(
-    const std::shared_ptr<GeomAPI_Pnt>& theCenter,
-    const std::shared_ptr<GeomAPI_Dir>& theNormal,
-    const std::shared_ptr<GeomAPI_Dir>& theMajorAxis,
-    const double                        theMajorRadius,
-    const double                        theMinorRadius)
-{
-  const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
-  const gp_Dir& aNormal = theNormal->impl<gp_Dir>();
-  const gp_Dir& aMajorAxis = theMajorAxis->impl<gp_Dir>();
-
-  gp_Elips anEllipse(gp_Ax2(aCenter, aNormal, aMajorAxis), theMajorRadius, theMinorRadius);
-
-  BRepBuilderAPI_MakeEdge anEdgeBuilder(anEllipse);
-  std::shared_ptr<GeomAPI_Edge> aRes(new GeomAPI_Edge);
-  TopoDS_Edge anEdge = anEdgeBuilder.Edge();
-  aRes->setImpl(new TopoDS_Shape(anEdge));
-  return aRes;
-}
index 22c248d97bfd412b237fe6ee8416c7a55ca7fad4..e063e2b29d217d490044c7b56b68318d970108f7 100644 (file)
@@ -72,13 +72,6 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_EdgeBuilder
                                                        std::shared_ptr<GeomAPI_Pnt> theStartPoint,
                                                        std::shared_ptr<GeomAPI_Pnt> theEndPoint,
                                                        std::shared_ptr<GeomAPI_Dir> theNormal);
-
-  /// Creates elliptic edge
-  static std::shared_ptr<GeomAPI_Edge> ellipse(const std::shared_ptr<GeomAPI_Pnt>& theCenter,
-                                               const std::shared_ptr<GeomAPI_Dir>& theNormal,
-                                               const std::shared_ptr<GeomAPI_Dir>& theMajorAxis,
-                                               const double                        theMajorRadius,
-                                               const double                        theMinorRadius);
 };
 
 #endif
index 197b6911d2a5f065d47ed4937a8c20c62132be99..7348703eeb17c95499f749f23305f4cee53a7d7b 100644 (file)
@@ -36,8 +36,6 @@
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_Session.h>
 #include <Events_InfoMessage.h>
-#include <GeomAPI_Edge.h>
-#include <GeomAPI_Vertex.h>
 
 #include <TNaming_Selector.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -56,9 +54,6 @@
 #include <TDF_ChildIterator.hxx>
 #include <TDF_ChildIDIterator.hxx>
 #include <TopoDS_Iterator.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Ellipse.hxx>
-#include <BRep_Builder.hxx>
 
 //#define DEB_NAMING 1
 #ifdef DEB_NAMING
@@ -74,13 +69,6 @@ Standard_GUID kPART_REF_ID("635eacb2-a1d6-4dec-8348-471fae17cb27");
 // selection is invalid after recomputation
 Standard_GUID kINVALID_SELECTION("bce47fd7-80fa-4462-9d63-2f58acddd49d");
 
-// identifier of the selection of the center of circle on edge
-Standard_GUID kCIRCLE_CENTER("d0d0e0f1-217a-4b95-8fbb-0c4132f23718");
-// identifier of the selection of the first focus point of ellipse on edge
-Standard_GUID kELLIPSE_CENTER1("f70df04c-3168-4dc9-87a4-f1f840c1275d");
-// identifier of the selection of the second focus point of ellipse on edge
-Standard_GUID kELLIPSE_CENTER2("1395ae73-8e02-4cf8-b204-06ff35873a32");
-
 // on this label is stored:
 // TNaming_NamedShape - selected shape
 // TNaming_Naming - topological selection information (for the body)
@@ -98,7 +86,6 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
   } else {
     myTmpContext.reset();
     myTmpSubShape.reset();
-    myTmpCenterType = NOT_CENTER;
   }
 
   const std::shared_ptr<GeomAPI_Shape>& anOldShape = value();
@@ -115,9 +102,6 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
   TDF_Label aSelLab = selectionLabel();
   aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
   aSelLab.ForgetAttribute(kINVALID_SELECTION);
-  aSelLab.ForgetAttribute(kCIRCLE_CENTER);
-  aSelLab.ForgetAttribute(kELLIPSE_CENTER1);
-  aSelLab.ForgetAttribute(kELLIPSE_CENTER2);
 
   bool isDegeneratedEdge = false;
   // do not use the degenerated edge as a shape, a null context and shape is used in the case
@@ -161,31 +145,6 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext,
   owner()->data()->sendAttributeUpdated(this);
 }
 
-void Model_AttributeSelection::setValueCenter(
-    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
-    const CenterType theCenterType, const bool theTemporarily)
-{
-  setValue(theContext, theEdge, theTemporarily);
-  if (theTemporarily) {
-    myTmpCenterType = theCenterType;
-  } else { // store in the data structure
-    TDF_Label aSelLab = selectionLabel();
-    switch(theCenterType) {
-    case CIRCLE_CENTER:
-      TDataStd_UAttribute::Set(aSelLab, kCIRCLE_CENTER);
-      break;
-    case ELLIPSE_FIRST_FOCUS:
-      TDataStd_UAttribute::Set(aSelLab, kELLIPSE_CENTER1);
-      break;
-    case ELLIPSE_SECOND_FOCUS:
-      TDataStd_UAttribute::Set(aSelLab, kELLIPSE_CENTER2);
-      break;
-    }
-    owner()->data()->sendAttributeUpdated(this);
-  }
-}
-
-
 void Model_AttributeSelection::removeTemporaryValues()
 {
   if (myTmpContext.get() || myTmpSubShape.get()) {
@@ -194,42 +153,6 @@ void Model_AttributeSelection::removeTemporaryValues()
   }
 }
 
-// returns the center of the edge: circular or elliptical
-GeomShapePtr centerByEdge(GeomShapePtr theEdge, ModelAPI_AttributeSelection::CenterType theType)
-{
-  if (theType != ModelAPI_AttributeSelection::NOT_CENTER && theEdge.get() != NULL) {
-    TopoDS_Shape aShape = theEdge->impl<TopoDS_Shape>();
-    if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE) {
-      TopoDS_Edge anEdge = TopoDS::Edge(aShape);
-      double aFirst, aLast;
-      Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
-      if (!aCurve.IsNull()) {
-        TopoDS_Vertex aVertex;
-        BRep_Builder aBuilder;
-        if (theType == ModelAPI_AttributeSelection::CIRCLE_CENTER) {
-          Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast(aCurve);
-          if (!aCirc.IsNull()) {
-            aBuilder.MakeVertex(aVertex, aCirc->Location(), Precision::Confusion());
-          }
-        } else { // ellipse
-          Handle(Geom_Ellipse) anEll = Handle(Geom_Ellipse)::DownCast(aCurve);
-          if (!anEll.IsNull()) {
-            aBuilder.MakeVertex(aVertex,
-              theType == ModelAPI_AttributeSelection::ELLIPSE_FIRST_FOCUS ?
-              anEll->Focus1() : anEll->Focus2(), Precision::Confusion());
-          }
-        }
-        if (!aVertex.IsNull()) {
-          std::shared_ptr<GeomAPI_Vertex> aResult(new GeomAPI_Vertex);
-          aResult->setImpl(new TopoDS_Vertex(aVertex));
-          return aResult;
-        }
-      }
-    }
-  }
-  return theEdge; // no vertex, so, return the initial edge
-}
-
 std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
 {
   GeomShapePtr aResult;
@@ -238,40 +161,30 @@ std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myTmpContext);
     if(aResulConstruction.get()) {
       // it is just reference to construction.
-      return centerByEdge(myTmpSubShape, myTmpCenterType);
+      return myTmpSubShape;
     }
-    return centerByEdge(myTmpSubShape.get() ? myTmpSubShape : myTmpContext->shape(),
-                        myTmpCenterType);
+    return myTmpSubShape.get() ? myTmpSubShape : myTmpContext->shape();
   }
 
   TDF_Label aSelLab = selectionLabel();
   if (aSelLab.IsAttribute(kINVALID_SELECTION))
     return aResult;
 
-  CenterType aType = NOT_CENTER;
-  if (aSelLab.IsAttribute(kCIRCLE_CENTER))
-    aType = CIRCLE_CENTER;
-  else if (aSelLab.IsAttribute(kELLIPSE_CENTER1))
-    aType = ELLIPSE_FIRST_FOCUS;
-  else if (aSelLab.IsAttribute(kELLIPSE_CENTER2))
-    aType = ELLIPSE_SECOND_FOCUS;
-
-
   if (myRef.isInitialized()) {
     if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // it is just reference to shape, not sub-shape
       ResultPtr aContext = context();
       if (!aContext.get())
         return aResult; // empty result
-      return centerByEdge(aContext->shape(), aType);
+      return aContext->shape();
     }
     if (aSelLab.IsAttribute(kPART_REF_ID)) {
       ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(context());
       if (!aPart.get() || !aPart->isActivated())
-        return aResult; // postponed naming needed
+        return std::shared_ptr<GeomAPI_Shape>(); // postponed naming needed
       Handle(TDataStd_Integer) anIndex;
       if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) {
         if (anIndex->Get()) { // special selection attribute was created, use it
-          return centerByEdge(aPart->selectionValue(anIndex->Get()), aType);
+          return aPart->selectionValue(anIndex->Get());
         } else { // face with name is already in the data model, so try to take it by name
           Handle(TDataStd_Name) aName;
           if (aSelLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
@@ -280,8 +193,8 @@ std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
             if (aPartEnd != std::string::npos && aPartEnd != aSubShapeName.rfind('/')) {
               std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
               int anIndex;
-              std::string aTypeStr; // to reuse already existing selection the type is not needed
-              return centerByEdge(aPart->shapeInPart(aNameInPart, aTypeStr, anIndex), aType);
+              std::string aType; // to reuse already existing selection the type is not needed
+              return aPart->shapeInPart(aNameInPart, aType, anIndex);
             }
           }
         }
@@ -293,7 +206,6 @@ std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
       TopoDS_Shape aSelShape = aSelection->Get();
       aResult = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
       aResult->setImpl(new TopoDS_Shape(aSelShape));
-      return centerByEdge(aResult, aType);
     } else { // for simple construction element: just shape of this construction element
       std::shared_ptr<Model_ResultConstruction> aConstr =
         std::dynamic_pointer_cast<Model_ResultConstruction>(context());
@@ -301,13 +213,13 @@ std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
         Handle(TDataStd_Integer) anIndex;
         if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) {
           if (anIndex->Get() == 0) // it is just reference to construction, nothing is in value
-            return centerByEdge(aResult, aType);
-          return centerByEdge(aConstr->shape(anIndex->Get(), owner()->document()), aType);
+            return aResult;
+          return aConstr->shape(anIndex->Get(), owner()->document());
         }
       }
     }
   }
-  return aResult; // empty case
+  return aResult;
 }
 
 bool Model_AttributeSelection::isInvalid()
index 2d64b6f566f727846da34d775d3458fc61785216..c75766a73d02a81ededb201522fd8e5f09caad06 100644 (file)
@@ -41,8 +41,6 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection
   ResultPtr myTmpContext;
   /// temporarily storages to avoid keeping in the data structure if not needed
   std::shared_ptr<GeomAPI_Shape> myTmpSubShape;
-  /// temporarily storages to avoid keeping in the data structure if not needed
-  CenterType myTmpCenterType;
   /// Reference to the partent attribute, if any (to split selection compounds in issue 1799)
   Model_AttributeSelectionList* myParent;
 public:
@@ -55,13 +53,6 @@ public:
     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
     const bool theTemporarily = false);
 
-  /// Same as SetValue, but it takes an edge (on circular or elliptical curve)
-  /// and stores the vertex of the central point (for ellipse the first or the second focus point)
-  MODEL_EXPORT virtual void setValueCenter(
-    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
-    const CenterType theCenterType,
-    const bool theTemporarily = false);
-
   /// Reset temporary stored values
   virtual void removeTemporaryValues();
 
index 0985db34bfca740fd7182a8473c3b8eed7fc44a0..9f039b63b307567e13460c0be843f6bf59434915 100644 (file)
@@ -112,7 +112,6 @@ SET(PROJECT_SOURCES
 
 SET(PROJECT_LIBRARIES
     Config
-    GeomAPI
 )
 SET(CMAKE_SWIG_FLAGS -threads -Wall)
 ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
index 44eace64ffbba7793492591b684aef5ba9d4193e..74802c858a77361e7bc691fa5a97e08701da7549 100644 (file)
@@ -24,8 +24,6 @@
 #include "ModelAPI_Attribute.h"
 #include <ModelAPI_Result.h>
 
-class GeomAPI_Edge;
-
 /**\class ModelAPI_AttributeSelection
  * \ingroup DataModel
  * \brief Attribute that contains reference to the sub-shape of some result, the selected shape.
@@ -34,14 +32,6 @@ class GeomAPI_Edge;
 class ModelAPI_AttributeSelection : public ModelAPI_Attribute
 {
  public:
-   /// Type of the center of the circular of elliptical edge
-   enum CenterType {
-     NOT_CENTER, ///< this is not a center
-     CIRCLE_CENTER, ///< center of the circle
-     ELLIPSE_FIRST_FOCUS, ///< first focus point of the ellipse
-     ELLIPSE_SECOND_FOCUS, ///< second focus point of the ellipse
-   };
-
   /// Defines the result and its selected sub-shape
   /// \param theContext object where the sub-shape was selected
   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
@@ -51,13 +41,6 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute
     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
     const bool theTemporarily = false) = 0;
 
-  /// Same as SetValue, but it takes an edge (on circular or elliptical curve)
-  /// and stores the vertex of the central point (for ellipse the first or the second focus point)
-  virtual void setValueCenter(
-    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
-    const CenterType theCenterType,
-    const bool theTemporarily = false) = 0;
-
   /// Reset temporary stored values
   virtual void removeTemporaryValues() = 0;
 
index 9368211e04a3bc027000042cad93142471b8562e..c660afca2965748dd5c759be5b64ae5ba3e4ed73 100644 (file)
@@ -21,8 +21,6 @@
 #include <ModelAPI.h>
 #include <ModelAPI_Events.h>
 
-#include <GeomAPI_Pnt2d.h>
-
 ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
                                                              const void* theSender)
     : Events_MessageGroup(theID, theSender)
@@ -340,44 +338,3 @@ const std::set<ObjectPtr>& ModelAPI_SolverFailedMessage::objects() const
 {
   return myObjects;
 }
-
-
-// =====   ModelAPI_ObjectMovedMessage   =====
-ModelAPI_ObjectMovedMessage::ModelAPI_ObjectMovedMessage(const void* theSender)
-  : Events_Message(Events_Loop::eventByName(EVENT_OBJECT_MOVED), theSender)
-{
-}
-
-void ModelAPI_ObjectMovedMessage::setMovedObject(const ObjectPtr& theMovedObject)
-{
-  myMovedObject = theMovedObject;
-  myMovedAttribute = AttributePtr();
-}
-
-void ModelAPI_ObjectMovedMessage::setMovedAttribute(const AttributePtr& theMovedAttribute)
-{
-  myMovedAttribute = theMovedAttribute;
-  myMovedObject = ObjectPtr();
-}
-
-void ModelAPI_ObjectMovedMessage::setOriginalPosition(double theX, double theY)
-{
-  myOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
-}
-
-void ModelAPI_ObjectMovedMessage::setOriginalPosition(
-    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
-{
-  myOriginalPosition = thePoint;
-}
-
-void ModelAPI_ObjectMovedMessage::setCurrentPosition(double theX, double theY)
-{
-  myCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
-}
-
-void ModelAPI_ObjectMovedMessage::setCurrentPosition(
-    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
-{
-  myCurrentPosition = thePoint;
-}
index a7718d1de11721eaa0106e359d2666d62bc4b776..1d69e38a961c276967a8ebedb1c5b2e745eb2477 100644 (file)
@@ -36,7 +36,6 @@
 
 class ModelAPI_Document;
 class ModelAPI_ResultParameter;
-class GeomAPI_Pnt2d;
 
 /// Event ID that feature is created (comes with ModelAPI_ObjectUpdatedMessage)
 static const char * EVENT_OBJECT_CREATED = "ObjectCreated";
@@ -468,46 +467,4 @@ private:
   int myDOF;
 };
 
-/// Message sent when feature or attrubute has been moved.
-/// Stores the moving object/attribute, original and new positions of mouse.
-class ModelAPI_ObjectMovedMessage : public Events_Message
-{
-  ObjectPtr myMovedObject;
-  AttributePtr myMovedAttribute;
-
-  std::shared_ptr<GeomAPI_Pnt2d> myOriginalPosition;
-  std::shared_ptr<GeomAPI_Pnt2d> myCurrentPosition;
-
-public:
-  MODELAPI_EXPORT ModelAPI_ObjectMovedMessage(const void* theSender = 0);
-
-  /// Set object which is being moved (if the message already contains attribute it will be cleared)
-  MODELAPI_EXPORT void setMovedObject(const ObjectPtr& theMovedObject);
-  /// Set attribute which is being moved (if the message already contains object it will be cleared)
-  MODELAPI_EXPORT void setMovedAttribute(const AttributePtr& theMovedAttribute);
-
-  /// Return moved object
-  ObjectPtr movedObject() const
-  { return myMovedObject; }
-  /// Return moved attribute
-  AttributePtr movedAttribute() const
-  { return myMovedAttribute; }
-
-  /// Set original mouse position
-  MODELAPI_EXPORT void setOriginalPosition(double theX, double theY);
-  /// Set original mouse position
-  MODELAPI_EXPORT void setOriginalPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
-  /// Return original mouse position
-  const std::shared_ptr<GeomAPI_Pnt2d>& originalPosition() const
-  { return myOriginalPosition; }
-
-  /// Set current mouse position
-  MODELAPI_EXPORT void setCurrentPosition(double theX, double theY);
-  /// Set current mouse position
-  MODELAPI_EXPORT void setCurrentPosition(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
-  /// Return current mouse position
-  const std::shared_ptr<GeomAPI_Pnt2d>& currentPosition() const
-  { return myCurrentPosition; }
-};
-
 #endif
index d018517e23f8262bff3c073c0f4e05bc7dd673e0..ad32819b320aa9528358a2228f7daf5366328466 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeRefAttrList.h>
-#include <ModelAPI_Events.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
 #include "ModelHighAPI_Interface.h"
@@ -82,13 +81,3 @@ bool ModelHighAPI_RefAttr::isEmpty() const
 {
   return !(myAttribute && myObject);
 }
-
-//--------------------------------------------------------------------------------------
-void ModelHighAPI_RefAttr::fillMessage(
-    const std::shared_ptr<ModelAPI_ObjectMovedMessage>& theMessage) const
-{
-  switch (myVariantType) {
-  case VT_ATTRIBUTE: theMessage->setMovedAttribute(myAttribute); return;
-  case VT_OBJECT: theMessage->setMovedObject(myObject); return;
-  }
-}
index feb9edfdc6124f809975c2bcafa78666e8bc51bb..7c1bbd6e817f5f481de0ee07f7ca563d0e602ffd 100644 (file)
@@ -31,7 +31,6 @@ class ModelAPI_Attribute;
 class ModelAPI_AttributeRefAttr;
 class ModelAPI_AttributeRefAttrList;
 class ModelAPI_Object;
-class ModelAPI_ObjectMovedMessage;
 class ModelHighAPI_Interface;
 //--------------------------------------------------------------------------------------
 /**\class ModelHighAPI_RefAttr
@@ -69,10 +68,6 @@ public:
   MODELHIGHAPI_EXPORT
   bool isEmpty() const;
 
-  /// Fill moved message by the attribute or object
-  MODELHIGHAPI_EXPORT
-  void fillMessage(const std::shared_ptr<ModelAPI_ObjectMovedMessage>& theMessage) const;
-
 private:
   enum VariantType { VT_ATTRIBUTE, VT_OBJECT } myVariantType;
   std::shared_ptr<ModelAPI_Attribute> myAttribute;
index 5bf192c975cb0a6c37c7a427e86a3f4ee605ace3..fcba4e0c4b194ca241bfa5dfdd2eee8e9e8897f1 100644 (file)
@@ -413,7 +413,7 @@ void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
   qDebug("ModuleBase_ModelWidget::moveObject");
 #endif
 
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
   Events_Loop::loop()->flush(anEvent);
 
index e690ce0e533785b09e08867c135498d3eb187e72..0dd37b3550efc2c532da7bdea5a515390075ffdf 100755 (executable)
@@ -105,14 +105,11 @@ void ModuleBase_ResultPrs::Compute(
 }
 
 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                            const Standard_Integer theMode)
+                                            const Standard_Integer aMode)
 {
-  if (appendVertexSelection(aSelection, theMode))
-    return;
-
-  if (theMode > TopAbs_SHAPE) {
+  if (aMode > TopAbs_SHAPE) {
     // In order to avoid using custom selection modes
-    if (theMode == ModuleBase_ResultPrs::Sel_Result) {
+    if (aMode == ModuleBase_ResultPrs::Sel_Result) {
       AIS_Shape::ComputeSelection(aSelection, TopAbs_COMPOUND);
     }
     return;
@@ -120,7 +117,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
 
   // TODO: OCCT issue should be created for the COMPOUND processing
   // before it is fixed, the next workaround in necessary
-  if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) {
+  if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPOUND)) {
     const TopoDS_Shape& aShape = Shape();
     TopExp_Explorer aCompExp(aShape, TopAbs_COMPOUND);
     // do not activate in compound mode shapes which do not contain compounds
@@ -128,7 +125,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
       return;
   }
 
-  if (theMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) {
+  if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) {
     // Limit selection area only by actual object (Shape)
     ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
     if (aCompSolid.get()) {
@@ -157,7 +154,7 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
     }
     //AIS_Shape::ComputeSelection(aSelection, 0);
   }
-  AIS_Shape::ComputeSelection(aSelection, theMode);
+  AIS_Shape::ComputeSelection(aSelection, aMode);
 
   if (myAdditionalSelectionPriority > 0) {
     for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
@@ -169,34 +166,6 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
   }
 }
 
-bool ModuleBase_ResultPrs::appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                                 const Standard_Integer theMode)
-{
-  if (Shape().ShapeType() == TopAbs_VERTEX) {
-    const TopoDS_Shape& aShape = Shape();
-
-    int aPriority = StdSelect_BRepSelectionTool::GetStandardPriority(aShape, TopAbs_VERTEX);
-    double aDeflection = Prs3d::GetDeflection(aShape, myDrawer);
-
-    /// The cause of this method is the last parameter of BRep owner setting into True.
-    /// That means that owner should behave like it comes from decomposition. (In this case, OCCT
-    /// visualizes it in Ring style) OCCT version is 7.0.0 with path for SHAPER module.
-    Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(aShape, aPriority, Standard_True);
-    StdSelect_BRepSelectionTool::ComputeSensitive(aShape, aOwner, aSelection,
-                                                  aDeflection, myDrawer->HLRAngle(), 9, 500);
-
-    for (aSelection->Init(); aSelection->More(); aSelection->Next()) {
-      Handle(SelectMgr_EntityOwner) anOwner =
-        Handle(SelectMgr_EntityOwner)
-        ::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
-      anOwner->Set(this);
-    }
-    return true;
-  }
-  return false;
-}
-
-/* OBSOLETE
 void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
                                                 const TopoDS_Shape& theShape)
 {
@@ -214,7 +183,7 @@ void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection
                                       myDrawer->IsAutoTriangulation());
   } catch ( Standard_Failure ) {
   }
-}*/
+}
 
 void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
                                            const SelectMgr_SequenceOfOwner& theOwners)
index af70be9e8aa8b24192577816119c9ec05daa5972..6d46e4ef5c7b85cbef8be991b096f676bbb5b105 100644 (file)
@@ -53,9 +53,9 @@ public:
   /// Highlight the presentation with the given color
   /// \param aPM a presentations manager
   /// \param theStyle a style of presentation
-  /// \param theMode a drawing mode
+  /// \param aMode a drawing mode
   virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& aPM,
-    const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer theMode = 0)
+    const Handle(Graphic3d_HighlightStyle)& theStyle, const Standard_Integer aMode = 0)
   {
     Selectable()->HilightOwnerWithColor(aPM, theStyle, this);
   }
@@ -119,22 +119,14 @@ protected:
 
   /// Redefinition of virtual function
   Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                                const Standard_Integer theMode) ;
+    const Standard_Integer aMode) ;
 
 private:
-  /// If the shape of this presentation is Vertex, it appends custom sensitive and owners for it.
-  /// Owner is a usual Brep owner with "isDecomposite" in true. It is necessary to have "Ring"
-  /// highlight/selected marker.
-  /// \param theSelection a current filled selection
-  /// \param theMode a selection mode
-  /// \return true if the owner is created
-  bool appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection,
-                             const Standard_Integer theMode);
   /// Appens sensitive and owners for wires of the given shape into selection
   /// \param theSelection a current filled selection
   /// \param theShape a shape
-  //void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
-  //                          const TopoDS_Shape& theShape);
+  void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
+                            const TopoDS_Shape& theShape);
 
   /// Reference to result object
   ResultPtr myResult;
index 37575cf725c28525a1f7541c0224ba880c0130a6..b04c3171684c106de5865e2d6be2b853e735bf8b 100644 (file)
@@ -56,8 +56,6 @@ SET(PROJECT_HEADERS
     PartSet_WidgetShapeSelector.h
     PartSet_WidgetSketchCreator.h
     PartSet_WidgetSketchLabel.h
-    PartSet_CenterPrs.h
-    PartSet_ExternalPointsMgr.h
 )
 
 SET(PROJECT_MOC_HEADERS
@@ -76,7 +74,6 @@ SET(PROJECT_MOC_HEADERS
     PartSet_WidgetShapeSelector.h
     PartSet_WidgetSketchCreator.h
     PartSet_WidgetSketchLabel.h
-    PartSet_ExternalPointsMgr.h
 )
 
 SET(PROJECT_SOURCES
@@ -104,8 +101,6 @@ SET(PROJECT_SOURCES
     PartSet_WidgetShapeSelector.cpp
     PartSet_WidgetSketchCreator.cpp
     PartSet_WidgetSketchLabel.cpp
-    PartSet_CenterPrs.cpp
-    PartSet_ExternalPointsMgr.cpp
 )
 
 SET(PROJECT_RESOURCES
diff --git a/src/PartSet/PartSet_CenterPrs.cpp b/src/PartSet/PartSet_CenterPrs.cpp
deleted file mode 100644 (file)
index 065c797..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        PartSet_CenterPrs.cpp
-// Created:     25 April 2017
-// Author:      Vitaly SMETANNIKOV
-
-#include "PartSet_CenterPrs.h"
-
-#include <Geom_CartesianPoint.hxx>
-
-
-IMPLEMENT_STANDARD_RTTIEXT(PartSet_CenterPrs, AIS_Point)
-
-PartSet_CenterPrs::PartSet_CenterPrs(const ObjectPtr& theObject,
-                                     const GeomEdgePtr& theEdge,
-                                     const gp_Pnt& theCenter,
-                                     ModelAPI_AttributeSelection::CenterType theType)
-  : AIS_Point(new Geom_CartesianPoint(theCenter)),
-  myObject(theObject),
-  myEdge(theEdge),
-  myCenterType(theType)
-{
-}
\ No newline at end of file
diff --git a/src/PartSet/PartSet_CenterPrs.h b/src/PartSet/PartSet_CenterPrs.h
deleted file mode 100644 (file)
index 86e54b2..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        PartSet_CenterPrs.h
-// Created:     25 April 2017
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef PartSet_CenterPrs_H
-#define PartSet_CenterPrs_H
-
-#include <ModelAPI_Object.h>
-#include <ModelAPI_AttributeSelection.h>
-#include <GeomAPI_Edge.h>
-
-#include <AIS_Point.hxx>
-#include <Standard_DefineHandle.hxx>
-#include <gp_Pnt.hxx>
-
-DEFINE_STANDARD_HANDLE(PartSet_CenterPrs, AIS_Point)
-
-/**
-* \ingroup GUI
-* A presentation class for displaying of centers of external curcular objects in a sketch
-*/
-class PartSet_CenterPrs: public AIS_Point
-{
-public:
-  /// Constructor
-  /// \param theObject an object with circular edge
-  /// \param theEdge a circular edge
-  /// \param theCenter a center point of the circular edge
-  /// \param theType a type of the center
-  Standard_EXPORT PartSet_CenterPrs(const ObjectPtr& theObject,
-                                    const GeomEdgePtr& theEdge,
-                                    const gp_Pnt& theCenter,
-                                    ModelAPI_AttributeSelection::CenterType theType);
-
-  /// Returns an Object which contains the circular edge
-  ObjectPtr object() const { return myObject; }
-
-  /// Returns a circular edge shape
-  GeomEdgePtr edge() const { return myEdge; }
-
-  /// Returns type of the center
-  ModelAPI_AttributeSelection::CenterType centerType() const { return myCenterType; }
-
-  DEFINE_STANDARD_RTTIEXT(PartSet_CenterPrs, AIS_Point)
-
-private:
-  ObjectPtr myObject;
-  GeomEdgePtr myEdge;
-  ModelAPI_AttributeSelection::CenterType myCenterType;
-};
-
-#endif
diff --git a/src/PartSet/PartSet_ExternalPointsMgr.cpp b/src/PartSet/PartSet_ExternalPointsMgr.cpp
deleted file mode 100644 (file)
index 0f9babd..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        PartSet_ExternalPointsMgr.cpp
-// Created:     26 April 2017
-// Author:      Vitaly SMETANNIKOV
-
-#include "PartSet_ExternalPointsMgr.h"
-#include "PartSet_CenterPrs.h"
-#include "PartSet_Tools.h"
-
-#include <ModelAPI_Tools.h>
-
-#include <ModuleBase_IWorkshop.h>
-#include <ModuleBase_ViewerPrs.h>
-
-#include <GeomAPI_Circ.h>
-#include <GeomAPI_Edge.h>
-#include <GeomAPI_Ellipse.h>
-#include <GeomAPI_Pnt.h>
-#include <GeomAPI_ShapeExplorer.h>
-
-#include <XGUI_Tools.h>
-#include <XGUI_Displayer.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_SelectionMgr.h>
-
-PartSet_ExternalPointsMgr::PartSet_ExternalPointsMgr(ModuleBase_IWorkshop* theWorkshop,
-                                                     const CompositeFeaturePtr& theSketch)
-  : QObject(theWorkshop), myWorkshop(theWorkshop), mySketch(theSketch)
-{
-  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-  connect(aDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
-                      SLOT(onDisplayObject(ObjectPtr, AISObjectPtr)));
-
-  connect(aDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)),
-                      SLOT(onEraseObject(ObjectPtr, AISObjectPtr)));
-
-  updateCenterPresentations();
-}
-
-
-PartSet_ExternalPointsMgr::~PartSet_ExternalPointsMgr()
-{
-  if (myPresentations.isEmpty())
-    return;
-  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-  if (!aWorkshop)
-    return;
-
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-  QMapIterator<ObjectPtr, ListOfAIS> aIt(myPresentations);
-  while (aIt.hasNext()) {
-    aIt.next();
-    ListOfAIS aAISList = aIt.value();
-    foreach (AISObjectPtr aAIS, aAISList) {
-      aDisplayer->eraseAIS(aAIS, false);
-    }
-  }
-}
-
-
-//******************************************************
-QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_ExternalPointsMgr::findCircularEdgesInPlane()
-{
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> aResult;
-  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-  QObjectPtrList aDispObjects = aDisplayer->displayedObjects();
-
-  std::shared_ptr<GeomAPI_Pln> aPlane = plane();
-  foreach(ObjectPtr aObj, aDispObjects) {
-    if (myPresentations.contains(aObj))
-      continue;
-
-    // Do not process objects of the current sketch
-    if (isSketchObject(aObj))
-      continue;
-
-    ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-    if (aResObj.get()) {
-      GeomShapePtr aShape = aResObj->shape();
-      if (aShape.get()) {
-        GeomAPI_ShapeExplorer aExplorer(aShape, GeomAPI_Shape::EDGE);
-        for(; aExplorer.more(); aExplorer.next()) {
-          GeomShapePtr aEdgeShape = aExplorer.current();
-          GeomAPI_Edge anEdge(aEdgeShape);
-          if ((anEdge.isCircle() || anEdge.isArc() || anEdge.isEllipse()) &&
-               anEdge.isInPlane(aPlane)) {
-            bool isContains = false;
-            // Check that edge is not already used.
-            // It is possible that the same edge will be taken from different faces
-            foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aResult) {
-              GeomAPI_Edge aUsedEdge(aPrs->shape());
-              if (aUsedEdge.isEqual(aEdgeShape)) {
-                isContains = true;
-                break;
-              }
-            }
-            if (!isContains) {
-              std::shared_ptr<ModuleBase_ViewerPrs>
-                aPrs(new ModuleBase_ViewerPrs(aResObj, aEdgeShape));
-              aResult.append(aPrs);
-            }
-          }
-        }
-      }
-    }
-  }
-  return aResult;
-}
-
-
-void PartSet_ExternalPointsMgr::updateCenterPresentations()
-{
-  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-  // Return if there is no plane defined
-  if (!plane().get()) {
-    connect(aWorkshop->selector(), SIGNAL(selectionChanged()),
-                                   SLOT(onSelectionChanged()));
-    return;
-  }
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> aEdgesPrs = findCircularEdgesInPlane();
-  foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aEdgesPrs) {
-    GeomEdgePtr aEdge(new GeomAPI_Edge(aPrs->shape()));
-    ListOfAIS aList;
-    if (aEdge->isArc() || aEdge->isCircle()) {
-      GeomCirclePtr aCircle = aEdge->circle();
-      GeomPointPtr aCenter = aCircle->center();
-      Handle(PartSet_CenterPrs) aCentPrs =
-        new PartSet_CenterPrs(aPrs->object(), aEdge, aCenter->impl<gp_Pnt>(),
-                              ModelAPI_AttributeSelection::CIRCLE_CENTER);
-
-      AISObjectPtr anAIS(new GeomAPI_AISObject());
-      anAIS->setImpl(new Handle(AIS_InteractiveObject)(aCentPrs));
-      aList.append(anAIS);
-    } else if (aEdge->isEllipse()) {
-      GeomEllipsePtr aEllipse = aEdge->ellipse();
-      GeomPointPtr aF1 = aEllipse->firstFocus();
-      GeomPointPtr aF2 = aEllipse->secondFocus();
-      Handle(PartSet_CenterPrs) aF1Prs =
-        new PartSet_CenterPrs(aPrs->object(), aEdge, aF1->impl<gp_Pnt>(),
-                              ModelAPI_AttributeSelection::ELLIPSE_FIRST_FOCUS);
-      Handle(PartSet_CenterPrs) aF2Prs =
-        new PartSet_CenterPrs(aPrs->object(), aEdge, aF2->impl<gp_Pnt>(),
-                              ModelAPI_AttributeSelection::ELLIPSE_SECOND_FOCUS);
-
-      AISObjectPtr anAIS1(new GeomAPI_AISObject());
-      anAIS1->setImpl(new Handle(AIS_InteractiveObject)(aF1Prs));
-      aList.append(anAIS1);
-
-      AISObjectPtr anAIS2(new GeomAPI_AISObject());
-      anAIS2->setImpl(new Handle(AIS_InteractiveObject)(aF2Prs));
-      aList.append(anAIS2);
-    }
-    if (myPresentations.contains(aPrs->object()))
-      myPresentations[aPrs->object()].append(aList);
-    else
-      myPresentations[aPrs->object()] = aList;
-    foreach(AISObjectPtr anAIS, aList) {
-      aDisplayer->displayAIS(anAIS, false);
-      aDisplayer->activateAIS(anAIS->impl<Handle(AIS_InteractiveObject)>(), TopAbs_VERTEX, false);
-    }
-  }
-}
-
-std::shared_ptr<GeomAPI_Pln> PartSet_ExternalPointsMgr::plane() const
-{
-  return PartSet_Tools::sketchPlane(mySketch);
-}
-
-void PartSet_ExternalPointsMgr::onDisplayObject(ObjectPtr theObj, AISObjectPtr theAIS)
-{
-  updateCenterPresentations();
-}
-
-void PartSet_ExternalPointsMgr::onEraseObject(ObjectPtr theObj, AISObjectPtr theAIS)
-{
-  if (myPresentations.contains(theObj)) {
-    XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-    XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-    ListOfAIS aList = myPresentations[theObj];
-    foreach(AISObjectPtr aAIS, aList) {
-      aDisplayer->eraseAIS(aAIS, false);
-    }
-    myPresentations.remove(theObj);
-    aDisplayer->updateViewer();
-  }
-}
-
-
-bool PartSet_ExternalPointsMgr::isSketchObject(const ObjectPtr& theRes) const
-{
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theRes);
-  if (!aFeature.get())
-    return false;
-  CompositeFeaturePtr aComp = ModelAPI_Tools::compositeOwner(aFeature);
-  return aComp == mySketch;
-}
-
-void PartSet_ExternalPointsMgr::onSelectionChanged()
-{
-  if (plane().get()) {
-    XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-    disconnect(aWorkshop->selector(), SIGNAL(selectionChanged()),
-               this, SLOT(onSelectionChanged()));
-    updateCenterPresentations();
-  }
-}
diff --git a/src/PartSet/PartSet_ExternalPointsMgr.h b/src/PartSet/PartSet_ExternalPointsMgr.h
deleted file mode 100644 (file)
index 4f13f09..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        PartSet_ExternalPointsMgr.h
-// Created:     26 April 2017
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef PartSet_ExternalPointsMgr_H
-#define PartSet_ExternalPointsMgr_H
-
-
-#include <ModelAPI_CompositeFeature.h>
-#include <ModelAPI_Result.h>
-#include <GeomAPI_Pln.h>
-#include <GeomAPI_AISObject.h>
-
-#include <QObject>
-#include <QMap>
-
-class ModuleBase_ViewerPrs;
-class ModuleBase_IWorkshop;
-
-
-/**
-* \ingroup Modules
-* A class to manage display of presentations of center points of circular
-* edges outside of a current sketcher
-*/
-class PartSet_ExternalPointsMgr: public QObject
-{
-  Q_OBJECT
-public:
-  PartSet_ExternalPointsMgr(ModuleBase_IWorkshop* theWorkshop,
-                            const CompositeFeaturePtr& theSketch);
-
-  virtual ~PartSet_ExternalPointsMgr();
-
-public slots:
-  /**
-  * A slot which processes display of object
-  * \param theObj the displayed object
-  * \param theAIS its presentation
-  */
-  void onDisplayObject(ObjectPtr theObj, AISObjectPtr theAIS);
-
-  /**
-  * A slot which processes erase of object
-  * \param theObj the displayed object
-  * \param theAIS its presentation
-  */
-  void onEraseObject(ObjectPtr theObj, AISObjectPtr theAIS);
-
-  // Called on selection changed
-  void onSelectionChanged();
-
-private:
-  /**
-  * Returns list of presentations which have displayed shapes with circular edges
-  * (circles, arcs) which are in pane of of the given sketch
-  * \param theSketch - the sketch
-  */
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> findCircularEdgesInPlane();
-
-  /// Creates presentations of centers
-  void updateCenterPresentations();
-
-  /// Returns plane of the current sketch
-  GeomPlanePtr plane() const;
-
-  /**
-  * Checks that the given object is an object of the current sketch
-  * \param theRes an object to check
-  * \return True if the given object is a sub-object of the current sketch
-  */
-  bool isSketchObject(const ObjectPtr& theRes) const;
-
-private:
-  /// Workshop
-  ModuleBase_IWorkshop* myWorkshop;
-
-  /// Current sketch
-  CompositeFeaturePtr mySketch;
-
-  /// Type for list of created AIS objects
-  typedef QList<AISObjectPtr> ListOfAIS;
-
-  /// Map of created AIS objects
-  QMap<ObjectPtr, ListOfAIS> myPresentations;
-};
-
-#endif
\ No newline at end of file
index eab2a165ce2f8de27adcd3d4ac2f3b665b6fb99d..9a1ed0282509f107d55a4ace45d3120211f3b4f6 100755 (executable)
@@ -26,7 +26,6 @@
 #include "PartSet_WidgetSketchLabel.h"
 #include "PartSet_WidgetEditor.h"
 #include "PartSet_ResultSketchPrs.h"
-#include "PartSet_ExternalPointsMgr.h"
 
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Displayer.h>
@@ -153,7 +152,7 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
   : QObject(theModule), myModule(theModule), myIsEditLaunching(false), myIsDragging(false),
     myDragDone(false), myIsMouseOverWindow(false),
     myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
-    myIsPopupMenuActive(false), myExternalPointsMgr(0)
+    myIsPopupMenuActive(false)
 {
   ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
@@ -537,11 +536,8 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
     Point aMousePnt;
     get2dPoint(theWnd, theEvent, aMousePnt);
-
-    std::shared_ptr<GeomAPI_Pnt2d> anOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(
-                            new GeomAPI_Pnt2d(myCurrentPoint.myCurX, myCurrentPoint.myCurY));
-    std::shared_ptr<GeomAPI_Pnt2d> aCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(
-                            new GeomAPI_Pnt2d(aMousePnt.myCurX, aMousePnt.myCurY));
+    double dX =  aMousePnt.myCurX - myCurrentPoint.myCurX;
+    double dY =  aMousePnt.myCurY - myCurrentPoint.myCurY;
 
     ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
@@ -576,15 +572,9 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
               std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
             if (aPoint.get() != NULL) {
               bool isImmutable = aPoint->setImmutable(true);
-
-              std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
-                       <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
-              aMessage->setMovedAttribute(aPoint);
-              aMessage->setOriginalPosition(anOriginalPosition);
-              aMessage->setCurrentPosition(aCurrentPosition);
-              Events_Loop::loop()->send(aMessage);
-
+              aPoint->move(dX, dY);
               isModified = true;
+              ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
               aPoint->setImmutable(isImmutable);
             }
           }
@@ -594,13 +584,9 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature) {
-          std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
-                    <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
-          aMessage->setMovedObject(aFeature);
-          aMessage->setOriginalPosition(anOriginalPosition);
-          aMessage->setCurrentPosition(aCurrentPosition);
-          Events_Loop::loop()->send(aMessage);
+          aSketchFeature->move(dX, dY);
           isModified = true;
+          ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
         }
       }
     }
@@ -608,8 +594,8 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     // were changed here
     if (isModified) {
       aCurrentOperation->onValuesChanged();
-      Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
     }
+    Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
     //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
 
     // 5. it is necessary to save current selection in order to restore it after the features moving
@@ -1013,8 +999,6 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   // plane filter
   if (aPln.get())
     aConnector->activateModuleSelectionModes();
-
-  myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
 }
 
 void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
@@ -1024,11 +1008,6 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
   myIsConstraintsShown[PartSet_Tools::Dimensional] = true;
   myIsConstraintsShown[PartSet_Tools::Expressions] = false;
 
-  if (myExternalPointsMgr) {
-    delete myExternalPointsMgr;
-    myExternalPointsMgr = 0;
-  }
-
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
 
   DataPtr aData = myCurrentSketch->data();
index 92c74ef8c5dbaa65bd410f1e4a94b118c7ce13c6..5396144b3aa48a213182cb80a5fdb159532556a0 100644 (file)
@@ -50,7 +50,6 @@ class ModuleBase_ModelWidget;
 class ModuleBase_Operation;
 class XGUI_OperationMgr;
 class XGUI_Workshop;
-class PartSet_ExternalPointsMgr;
 
 class AIS_InteractiveObject;
 
@@ -433,8 +432,6 @@ private:
   bool myPreviousUpdateViewerEnabled;
 
   QMap<PartSet_Tools::ConstraintVisibleState, bool> myIsConstraintsShown;
-
-  PartSet_ExternalPointsMgr* myExternalPointsMgr;
 };
 
 
index 2a5f0f08d0ee6ed45326ecb64c9e6f68b10cfce3..2b5315a8fbcd79168330f5626f9eb962a44b3028 100755 (executable)
@@ -905,29 +905,3 @@ bool PartSet_Tools::isAuxiliarySketchEntity(const ObjectPtr& theObject)
 
   return isAuxiliaryFeature;
 }
-
-
-ResultPtr PartSet_Tools::createFixedByExternalCenter(
-    const ObjectPtr& theObject,
-    const std::shared_ptr<GeomAPI_Edge>& theEdge,
-    ModelAPI_AttributeSelection::CenterType theType,
-    const CompositeFeaturePtr& theSketch,
-    bool theTemporary)
-{
-  FeaturePtr aMyFeature = theSketch->addFeature(SketchPlugin_Point::ID());
-
-  if (aMyFeature) {
-    DataPtr aData = aMyFeature->data();
-    AttributeSelectionPtr anAttr =
-        std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-        (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
-
-    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    if (anAttr.get() && aRes.get()) {
-      anAttr->setValueCenter(aRes, theEdge, theType, theTemporary);
-      aMyFeature->execute();
-      return aMyFeature->lastResult();
-    }
-  }
-  return ResultPtr();
-}
index b7c0a22c921efec6e030b73f6af513d872cd62cb..69b9838d4ff2a3fa6108534ad91531fa44098832 100755 (executable)
@@ -31,7 +31,6 @@
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Attribute.h>
-#include <ModelAPI_AttributeSelection.h>
 
 #include <Events_Message.h>
 
@@ -280,13 +279,6 @@ public:
    * \return boolean result
    */
   static bool isAuxiliarySketchEntity(const ObjectPtr& theObject);
-
-  static ResultPtr createFixedByExternalCenter(const ObjectPtr& theObject,
-                                               const std::shared_ptr<GeomAPI_Edge>& theEdge,
-                                               ModelAPI_AttributeSelection::CenterType theType,
-                                               const CompositeFeaturePtr& theSketch,
-                                               bool theTemporary = false);
-
 };
 
 #endif
index c7dde30bf0c3420ad90d6f24be573fc0a8147186..36b897e5f2f8d003ffb802a1bb6135ba99fdc4dd 100644 (file)
@@ -23,7 +23,6 @@
 #include <PartSet_Module.h>
 #include <PartSet_SketcherReentrantMgr.h>
 #include <PartSet_ExternalObjectsMgr.h>
-#include <PartSet_CenterPrs.h>
 
 #include <XGUI_Tools.h>
 #include <XGUI_Workshop.h>
@@ -77,7 +76,6 @@
 #include <TopoDS.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <BRep_Tool.hxx>
-#include <Geom_Point.hxx>
 
 #include <cfloat>
 #include <climits>
@@ -358,23 +356,10 @@ bool PartSet_WidgetPoint2D::storeValueCustom()
   //                myYSpin->hasVariable() ? myYSpin->text().toStdString() : "");
   //aPoint->setValue(!myXSpin->hasVariable() ? myXSpin->value() : aPoint->x(),
   //                 !myYSpin->hasVariable() ? myYSpin->value() : aPoint->y());
+  aPoint->setValue(myXSpin->value(), myYSpin->value());
 
-  if (myFeature->isMacro()) {
-    // Moving points of macro-features has been processed directly (without solver)
-    aPoint->setValue(myXSpin->value(), myYSpin->value());
-    moveObject(myFeature);
-  } else {
-    if (!aPoint->isInitialized())
-      aPoint->setValue(0., 0.);
-
-    std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage(
-        new ModelAPI_ObjectMovedMessage(this));
-    aMessage->setMovedAttribute(aPoint);
-    aMessage->setOriginalPosition(aPoint->pnt());
-    aMessage->setCurrentPosition(myXSpin->value(), myYSpin->value());
-    Events_Loop::loop()->send(aMessage);
-  }
-
+  // after movement the solver will call the update event: optimization
+  moveObject(myFeature);
   aPoint->setImmutable(isImmutable);
   that->blockSignals(isBlocked);
 
@@ -593,7 +578,6 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo
   if (!aFirstValue.get() && myPreSelected.get()) {
     aFirstValue = myPreSelected;
   }
-
   // if we have selection and use it
   if (aFirstValue.get() && isValidSelectionCustom(aFirstValue) &&
       aFirstValue->shape().get()) { /// Trihedron Axis may be selected, but shape is empty
@@ -709,36 +693,7 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo
       }
     }
   }
-  // The selection could be a center of an external circular object
-  else if (aFirstValue.get() && (!aFirstValue->interactive().IsNull())) {
-    Handle(PartSet_CenterPrs) aAIS =
-        Handle(PartSet_CenterPrs)::DownCast(aFirstValue->interactive());
-    if (!aAIS.IsNull()) {
-      gp_Pnt aPntComp = aAIS->Component()->Pnt();
-      GeomVertexPtr aVertPtr(new GeomAPI_Vertex(aPntComp.X(), aPntComp.Y(), aPntComp.Z()));
-      TopoDS_Shape aShape = aVertPtr->impl<TopoDS_Shape>();
-
-      ResultPtr aFixedObject =
-          PartSet_Tools::findFixedObjectByExternal(aShape, aAIS->object(), mySketch);
-      if (!aFixedObject.get())
-        aFixedObject = PartSet_Tools::createFixedByExternalCenter(aAIS->object(), aAIS->edge(),
-                                                                  aAIS->centerType(), mySketch);
-      if (aFixedObject.get())
-        setConstraintToObject(aFixedObject);
-      // fignal updated should be flushed in order to visualize possible created
-      // external objects e.g. selection of trihedron axis when input end arc point
-      updateObject(feature());
-
-      double aX, aY;
-      if (getPoint2d(aView, aShape, aX, aY)) {
-        // do not create a constraint to the point, which already used by the feature
-        // if the feature contains the point, focus is not switched
-        setPoint(aX, aY);
-      }
-      emit vertexSelected(); // it stops the reentrant operation
-      emit focusOutWidget(this);
-    }
-  }
+  // End of Bug dependent fragment
   else {
     // A case when point is taken from mouse event
     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView());
index 5464d078f641c9910a53557cee5a8a589a629c20..190b7e2a348435f0117c5fa28f9a050a2baa797b 100644 (file)
@@ -48,8 +48,6 @@
 #include <GeomDataAPI_Dir.h>
 #include <GeomAPI_XYZ.h>
 #include <GeomAPI_Face.h>
-#include <GeomAPI_Edge.h>
-#include <GeomAPI_ShapeExplorer.h>
 
 #include <SketchPlugin_Sketch.h>
 #include <SketcherPrs_Tools.h>
@@ -542,9 +540,6 @@ void PartSet_WidgetSketchLabel::activateSelection(bool toActivate)
     QIntList aModes;
     std::shared_ptr<GeomAPI_Pln> aPlane = plane();
     if (aPlane.get()) {
-      //QList<std::shared_ptr<ModuleBase_ViewerPrs>> aEdges = findCircularEdgesInPlane();
-      //foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aEdges) {
-      //}
       myWorkshop->module()->activeSelectionModes(aModes);
     }
     else {
@@ -591,7 +586,7 @@ std::shared_ptr<GeomAPI_Dir>
   std::shared_ptr<GeomAPI_Pnt> anOrigPnt(new GeomAPI_Pnt(aCoords));
   // X axis is preferable to be dirX on the sketch
   const double tol = Precision::Confusion();
-  bool isX = fabs(fabs(anA) - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
+  bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
   std::shared_ptr<GeomAPI_Dir> aTempDir(
       isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
   std::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
@@ -624,47 +619,3 @@ void PartSet_WidgetSketchLabel::onSetPlaneView()
       aModule->onViewTransformed();
   }
 }
-
-
-//******************************************************
-QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_WidgetSketchLabel::findCircularEdgesInPlane()
-{
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> aResult;
-  XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
-  XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-  QObjectPtrList aDispObjects = aDisplayer->displayedObjects();
-
-  std::shared_ptr<GeomAPI_Pln> aPlane = plane();
-  foreach(ObjectPtr aObj, aDispObjects) {
-    ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-    if (aResObj.get()) {
-      GeomShapePtr aShape = aResObj->shape();
-      if (aShape.get()) {
-        GeomAPI_ShapeExplorer aExplorer(aShape, GeomAPI_Shape::EDGE);
-        for(; aExplorer.more(); aExplorer.next()) {
-          GeomShapePtr aEdgeShape = aExplorer.current();
-          GeomAPI_Edge anEdge(aEdgeShape);
-          if ((anEdge.isCircle() || anEdge.isArc() || anEdge.isEllipse()) &&
-               anEdge.isInPlane(aPlane)) {
-            bool isContains = false;
-            // Check that edge is not used.
-            // It is possible that the same edge will be taken from different faces
-            foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aResult) {
-              GeomAPI_Edge aUsedEdge(aPrs->shape());
-              if (aUsedEdge.isEqual(aEdgeShape)) {
-                isContains = true;
-                break;
-              }
-            }
-            if (!isContains) {
-              std::shared_ptr<ModuleBase_ViewerPrs>
-                aPrs(new ModuleBase_ViewerPrs(aResObj, aEdgeShape));
-              aResult.append(aPrs);
-            }
-          }
-        }
-      }
-    }
-  }
-  return aResult;
-}
index 5cc4a10cf76049ac3b633341362dcc22228c420c..515c0377ab415a749f118ff542f1a810c361ca48 100644 (file)
@@ -192,13 +192,6 @@ protected:
   /// \param thePlane a plane
   std::shared_ptr<GeomAPI_Dir> setSketchPlane(std::shared_ptr<GeomAPI_Pln> thePlane);
 
-  /**
-  * Returns list of presentations which have displayed shapes with circular edges
-  * (circles, arcs) which are in pane of of the given sketch
-  * \param theSketch - the sketch
-  */
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> findCircularEdgesInPlane();
-
 private:
   /// class to show/hide preview planes
   PartSet_PreviewPlanes* myPreviewPlanes;
index 8c0319a1ecab2b26d8bd563a03aface7855dc7c8..b015b4278170b469d81fa7d734d14f4812bb448f 100644 (file)
@@ -3,4 +3,3 @@
 
 from SketchAPI import addSketch
 from tools import *
-from tests import *
diff --git a/src/PythonAPI/model/sketcher/tests.py b/src/PythonAPI/model/sketcher/tests.py
deleted file mode 100644 (file)
index ea69081..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-from ModelAPI import *
-from GeomDataAPI import *
-import ModelHighAPI
-import math
-from salome.shaper.model.sketcher import tools
-
-TOLERANCE = 1.e-7
-
-def assertPoint(thePoint, theCoords):
-    """ Verifies coordinates of the point
-    """
-    aPoint = tools.toList(thePoint)
-    assert aPoint[0] == theCoords[0] and aPoint[1] == theCoords[1], "Wrong '{}' point {}, expected {}".format(thePoint.id(), aPoint, theCoords)
-
-
-def assertLine(theLine, theStart, theEnd):
-    """ Verifies coordinates of line extremities
-    """
-    aLine = tools.toSketchFeature(theLine)
-
-    aStartPnt = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
-    aEndPnt = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
-    if len(theStart):
-        assertPoint(aStartPnt, theStart)
-    if len(theEnd):
-        assertPoint(aEndPnt, theEnd)
-
-
-def assertCircle(theCircle, theCenter, theRadius):
-    """ Verifies attributes of circle
-    """
-    aCircle = tools.toSketchFeature(theCircle)
-
-    aCenter = geomDataAPI_Point2D(aCircle.attribute("circle_center"))
-    if len(theCenter):
-        assertPoint(aCenter, theCenter)
-
-    aRadius = aCircle.real("circle_radius")
-    assert aRadius.value() == theRadius, "Wrong circle radius {}, expected {}".format(aRadius.value(), theRadius)
-
-
-def assertArc(theArc, theCenter, theStart, theEnd):
-    """ Verifies coordinates of arc points and the consistency of the arc.
-        Some of points may be empty lists.
-    """
-    anArc = tools.toSketchFeature(theArc)
-
-    aCenterPnt = geomDataAPI_Point2D(anArc.attribute("center_point"))
-    aStartPnt = geomDataAPI_Point2D(anArc.attribute("start_point"))
-    aEndPnt = geomDataAPI_Point2D(anArc.attribute("end_point"))
-    if len(theCenter):
-        assertPoint(aCenterPnt, theCenter)
-    if len(theStart):
-        assertPoint(aStartPnt, theStart)
-    if len(theEnd):
-        assertPoint(aEndPnt, theEnd)
-
-    assertArcValidity(anArc)
-
-
-def assertArcValidity(theArc):
-    """ Tests whether the arc is correctly defined
-    """
-    anArc = tools.toSketchFeature(theArc)
-
-    aCenterPnt = geomDataAPI_Point2D(anArc.attribute("center_point"))
-    aStartPnt = geomDataAPI_Point2D(anArc.attribute("start_point"))
-    aEndPnt = geomDataAPI_Point2D(anArc.attribute("end_point"))
-    aRadius = anArc.real("radius")
-    aDistCS = tools.distancePointPoint(aCenterPnt, aStartPnt)
-    aDistCE = tools.distancePointPoint(aCenterPnt, aEndPnt)
-    assert math.fabs(aDistCS - aDistCE) < TOLERANCE, "Wrong arc: center-start distance {}, center-end distance {}".format(aDistCS, aDistCE)
-    assert math.fabs(aRadius.value() - aDistCS) < TOLERANCE, "Wrong arc: radius is {}, expected {}".format(aRadius.value(), aDistCS)
index e93fec49cda0fe4247cce01accb5155b426f2e16..de3032f54d16bae221e821bfa78cb0d68c397e36 100644 (file)
@@ -19,9 +19,7 @@
 ##
 
 import ModelHighAPI
-from GeomDataAPI import *
-from ModelAPI import *
-import math
+import GeomDataAPI
 
 def addPolyline(sketch, *coords):
     """Add a poly-line to sketch.
@@ -71,45 +69,19 @@ def dof(sketch):
     return int(filter(str.isdigit, aSketch.string("SolverDOF").value()))
 
 def distancePointPoint(thePoint1, thePoint2):
-    aPnt1 = toList(thePoint1)
-    aPnt2 = toList(thePoint2)
-    return math.hypot(aPnt1[0] - aPnt2[0], aPnt1[1] - aPnt2[1])
-
-def distancePointLine(thePoint, theLine):
-    aPoint = toList(thePoint)
-    aLine = toSketchFeature(theLine)
-
-    aLineStart = geomDataAPI_Point2D(aLine.attribute("StartPoint")).pnt().xy()
-    aLineEnd = geomDataAPI_Point2D(aLine.attribute("EndPoint")).pnt().xy()
-    aLineDir = aLineEnd.decreased(aLineStart)
-    aLineLen = aLineEnd.distance(aLineStart)
-    aCross = (aPoint[0] - aLineStart.x()) * aLineDir.y() - (aPoint[1] - aLineStart.y()) * aLineDir.x()
-    return math.fabs(aCross / aLineLen)
+    aGeomPnt1 = thePoint1
+    aGeomPnt2 = thePoint2
+    if issubclass(type(thePoint1), GeomDataAPI.GeomDataAPI_Point2D):
+        aGeomPnt1 = thePoint1.pnt()
+    if issubclass(type(thePoint2), GeomDataAPI.GeomDataAPI_Point2D):
+        aGeomPnt2 = thePoint2.pnt()
+    return aGeomPnt1.distance(aGeomPnt2)
 
 def lastSubFeature(theSketch, theKind):
     """
     obtains last feature of given kind from the sketch
     """
-    aSketch = featureToCompositeFeature(toSketchFeature(theSketch))
-    for anIndex in range(aSketch.numberOfSubs() - 1, -1, -1):
-        aSub = aSketch.subFeature(anIndex)
+    for anIndex in range(theSketch.numberOfSubs() - 1, -1, -1):
+        aSub = theSketch.subFeature(anIndex)
         if (aSub.getKind() == theKind):
             return aSub
-
-def toSketchFeature(theEntity):
-    """ Converts entity to sketch feature if possible
-    """
-    if issubclass(type(theEntity), ModelHighAPI.ModelHighAPI_Interface):
-        return theEntity.feature()
-    else:
-        return theEntity
-
-def toList(thePoint):
-    if issubclass(type(thePoint), list):
-        return thePoint
-    elif issubclass(type(thePoint), GeomDataAPI_Point2D):
-        return [thePoint.x(), thePoint.y()]
-    else:
-        aFeature = toSketchFeature(thePoint)
-        aPoint = geomDataAPI_Point2D(aFeature.attribute("PointCoordinates"))
-        return [aPoint.x(), aPoint.y()]
index 9b1d6c713a04188c1ef77873ffd035464f68c389..f75e4ae0fea8a95887d2336784a33b630c01816f 100644 (file)
@@ -23,6 +23,9 @@ from GeomAPI import *
 from GeomDataAPI import *
 from ModelAPI import ModelAPI_Feature
 import math
+from salome.shaper.model import sketcher
+
+TOLERANCE = 1.e-7
 
 aShapeTypes = {
   GeomAPI_Shape.SOLID:  "GeomAPI_Shape.SOLID",
@@ -174,3 +177,15 @@ def testNbSubFeatures(theComposite, theKindOfSub, theExpectedCount):
     if aFeature is not None and aFeature.getKind() == theKindOfSub:
        count += 1
   assert (count == theExpectedCount), "Number of sub-features of type {}: {}, expected {}".format(theKindOfSub, count, theExpectedCount)
+
+def assertSketchArc(theArcFeature):
+  """ Tests whether the arc is correctly defined
+  """
+  aCenterPnt = geomDataAPI_Point2D(theArcFeature.attribute("center_point"))
+  aStartPnt = geomDataAPI_Point2D(theArcFeature.attribute("start_point"))
+  aEndPnt = geomDataAPI_Point2D(theArcFeature.attribute("end_point"))
+  aRadius = theArcFeature.real("radius")
+  aDistCS = sketcher.tools.distancePointPoint(aCenterPnt, aStartPnt)
+  aDistCE = sketcher.tools.distancePointPoint(aCenterPnt, aEndPnt)
+  assert math.fabs(aDistCS - aDistCE) < TOLERANCE, "Wrong arc: center-start distance {}, center-end distance {}".format(aDistCS, aDistCE)
+  assert math.fabs(aRadius.value() -aDistCS) < TOLERANCE, "Wrong arc: radius is {0}, expected {1}".format(aRadius.value(), aDistCS)
index d655ff2af0ca8c2a4837ebf5595d5d935521981f..b777eaddeecc77df2e07e95d17b28ae53f8305b6 100644 (file)
@@ -28,8 +28,6 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintCollinear.h>
 #include <SketchPlugin_ConstraintDistance.h>
-#include <SketchPlugin_ConstraintDistanceHorizontal.h>
-#include <SketchPlugin_ConstraintDistanceVertical.h>
 #include <SketchPlugin_ConstraintEqual.h>
 #include <SketchPlugin_ConstraintHorizontal.h>
 #include <SketchPlugin_ConstraintLength.h>
@@ -84,14 +82,6 @@ static const std::string& constraintTypeToSetter(const std::string& theType)
     static const std::string DISTANCE_SETTER("setDistance");
     return DISTANCE_SETTER;
   }
-  if (theType == SketchPlugin_ConstraintDistanceHorizontal::ID()) {
-    static const std::string DISTANCE_SETTER("setHorizontalDistance");
-    return DISTANCE_SETTER;
-  }
-  if (theType == SketchPlugin_ConstraintDistanceVertical::ID()) {
-    static const std::string DISTANCE_SETTER("setVerticalDistance");
-    return DISTANCE_SETTER;
-  }
   if (theType == SketchPlugin_ConstraintEqual::ID()) {
     static const std::string EQUAL_SETTER("setEqual");
     return EQUAL_SETTER;
index 135285e6a0b3cc78b71deb244eaaf721ee27156c..6fa94f420bf68679c530d5bb735b3d8d46c4a886 100644 (file)
@@ -78,13 +78,3 @@ void SketchAPI_Rectangle::setByPoints(
 }
 
 //--------------------------------------------------------------------------------------
-
-std::list<std::shared_ptr<SketchAPI_SketchEntity> > SketchAPI_Rectangle::lines() const
-{
-  std::list<FeaturePtr> aFeatures;
-  std::list<ObjectPtr> aList = linesList()->list();
-  std::list<ObjectPtr>::const_iterator anIt = aList.begin();
-  for (; anIt != aList.end(); ++anIt)
-    aFeatures.push_back(ModelAPI_Feature::feature(*anIt));
-  return SketchAPI_SketchEntity::wrap(aFeatures);
-}
index b9fe8fced01cea8cf62f0b39a67c34861c4cf269..fb63cec63ddcbe897365a72e58fedf133e1e3eda 100644 (file)
@@ -65,9 +65,6 @@ public:
   SKETCHAPI_EXPORT
   void setByPoints(const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
                    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
-
-  /// List of lines composing rectangle
-  SKETCHAPI_EXPORT std::list<std::shared_ptr<SketchAPI_SketchEntity> > lines() const;
 };
 
 //! Pointer on Rectangle object
index daefc491e84a85f9fb5d2aa2e4e0fe60553aa750..b3b26c0d0dce7468c026f8837b7d5bf6bb5c61e7 100644 (file)
@@ -25,8 +25,6 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintCollinear.h>
 #include <SketchPlugin_ConstraintDistance.h>
-#include <SketchPlugin_ConstraintDistanceHorizontal.h>
-#include <SketchPlugin_ConstraintDistanceVertical.h>
 #include <SketchPlugin_ConstraintEqual.h>
 #include <SketchPlugin_Fillet.h>
 #include <SketchPlugin_ConstraintHorizontal.h>
@@ -43,7 +41,6 @@
 #include <SketchPlugin_ConstraintVertical.h>
 #include <SketcherPrs_Tools.h>
 //--------------------------------------------------------------------------------------
-#include <ModelAPI_Events.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelHighAPI_Double.h>
 #include "SketchAPI_Rotation.h"
 #include "SketchAPI_Translation.h"
 //--------------------------------------------------------------------------------------
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_XY.h>
-#include <cmath>
-//--------------------------------------------------------------------------------------
 SketchAPI_Sketch::SketchAPI_Sketch(
     const std::shared_ptr<ModelAPI_Feature> & theFeature)
 : ModelHighAPI_Interface(theFeature)
@@ -638,34 +631,6 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setDistance(
   return InterfacePtr(new ModelHighAPI_Interface(aFeature));
 }
 
-std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setHorizontalDistance(
-    const ModelHighAPI_RefAttr & thePoint1,
-    const ModelHighAPI_RefAttr & thePoint2,
-    const ModelHighAPI_Double & theValue)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature =
-      compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceHorizontal::ID());
-  fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
-  fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
-  fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
-  aFeature->execute();
-  return InterfacePtr(new ModelHighAPI_Interface(aFeature));
-}
-
-std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setVerticalDistance(
-    const ModelHighAPI_RefAttr & thePoint1,
-    const ModelHighAPI_RefAttr & thePoint2,
-    const ModelHighAPI_Double & theValue)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature =
-      compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceVertical::ID());
-  fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
-  fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
-  fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
-  aFeature->execute();
-  return InterfacePtr(new ModelHighAPI_Interface(aFeature));
-}
-
 std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setEqual(
     const ModelHighAPI_RefAttr & theObject1,
     const ModelHighAPI_RefAttr & theObject2)
@@ -810,127 +775,6 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setVertical(
 
 //--------------------------------------------------------------------------------------
 
-static std::shared_ptr<GeomAPI_Pnt2d> pointCoordinates(const AttributePtr& thePoint)
-{
-  AttributePoint2DPtr aPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(thePoint);
-  if (aPnt)
-    return aPnt->pnt();
-  return std::shared_ptr<GeomAPI_Pnt2d>();
-}
-
-static std::shared_ptr<GeomAPI_Pnt2d> middlePointOnLine(const FeaturePtr& theFeature)
-{
-  AttributePoint2DPtr aStartAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      theFeature->attribute(SketchPlugin_Line::START_ID()));
-  AttributePoint2DPtr aEndAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      theFeature->attribute(SketchPlugin_Line::END_ID()));
-
-  if (!aStartAttr || !aEndAttr)
-    return std::shared_ptr<GeomAPI_Pnt2d>();
-
-  std::shared_ptr<GeomAPI_XY> aStartPoint = aStartAttr->pnt()->xy();
-  std::shared_ptr<GeomAPI_XY> aEndPoint = aEndAttr->pnt()->xy();
-  return std::shared_ptr<GeomAPI_Pnt2d>(
-      new GeomAPI_Pnt2d(aStartPoint->added(aEndPoint)->multiplied(0.5)));
-}
-
-static std::shared_ptr<GeomAPI_Pnt2d> pointOnCircle(const FeaturePtr& theFeature)
-{
-  AttributePoint2DPtr aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      theFeature->attribute(SketchPlugin_Circle::CENTER_ID()));
-  AttributeDoublePtr aRadius = theFeature->real(SketchPlugin_Circle::RADIUS_ID());
-
-  if (!aCenter || !aRadius)
-    return std::shared_ptr<GeomAPI_Pnt2d>();
-
-  return std::shared_ptr<GeomAPI_Pnt2d>(
-      new GeomAPI_Pnt2d(aCenter->x() + aRadius->value(), aCenter->y()));
-}
-
-static std::shared_ptr<GeomAPI_Pnt2d> middlePointOnArc(const FeaturePtr& theFeature)
-{
-  static const double PI = 3.141592653589793238463;
-
-  AttributePoint2DPtr aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      theFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
-  AttributePoint2DPtr aStartAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      theFeature->attribute(SketchPlugin_Arc::START_ID()));
-  AttributePoint2DPtr aEndAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      theFeature->attribute(SketchPlugin_Arc::END_ID()));
-
-  if (!aCenterAttr || !aStartAttr || !aEndAttr)
-    return std::shared_ptr<GeomAPI_Pnt2d>();
-
-  std::shared_ptr<GeomAPI_Dir2d> aStartDir(new GeomAPI_Dir2d(
-      aStartAttr->x() - aCenterAttr->x(), aStartAttr->y() - aCenterAttr->y()));
-  std::shared_ptr<GeomAPI_Dir2d> aEndDir(new GeomAPI_Dir2d(
-      aEndAttr->x() - aCenterAttr->x(), aEndAttr->y() - aCenterAttr->y()));
-
-  double anAngle = aStartDir->angle(aEndDir);
-  bool isReversed = theFeature->boolean(SketchPlugin_Arc::REVERSED_ID())->value();
-  if (isReversed && anAngle > 0.)
-    anAngle -= 2.0 * PI;
-  else if (!isReversed && anAngle <= 0.)
-    anAngle += 2.0 * PI;
-
-  double cosA = cos(anAngle);
-  double sinA = sin(anAngle);
-
-  // rotate start dir to find middle point on arc
-  double aRadius = aStartAttr->pnt()->distance(aCenterAttr->pnt());
-  double x = aCenterAttr->x() + aRadius * (aStartDir->x() * cosA - aStartDir->y() * sinA);
-  double y = aCenterAttr->y() + aRadius * (aStartDir->x() * sinA + aStartDir->y() * cosA);
-
-  return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(x, y));
-}
-
-static std::shared_ptr<GeomAPI_Pnt2d> middlePoint(const ObjectPtr& theObject)
-{
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-  if (aFeature) {
-    const std::string& aFeatureKind = aFeature->getKind();
-    if (aFeatureKind == SketchPlugin_Point::ID())
-      return pointCoordinates(aFeature->attribute(SketchPlugin_Point::COORD_ID()));
-    else if (aFeatureKind == SketchPlugin_Line::ID())
-      return middlePointOnLine(aFeature);
-    else if (aFeatureKind == SketchPlugin_Circle::ID())
-      return pointOnCircle(aFeature);
-    else if (aFeatureKind == SketchPlugin_Arc::ID())
-      return middlePointOnArc(aFeature);
-  }
-  // do not move other types of features
-  return std::shared_ptr<GeomAPI_Pnt2d>();
-}
-
-void SketchAPI_Sketch::move(const ModelHighAPI_RefAttr& theMovedEntity,
-                            const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint)
-{
-  std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage(new ModelAPI_ObjectMovedMessage);
-  theMovedEntity.fillMessage(aMessage);
-
-  std::shared_ptr<GeomAPI_Pnt2d> anOriginalPosition;
-  if (aMessage->movedAttribute())
-    anOriginalPosition = pointCoordinates(aMessage->movedAttribute());
-  else
-    anOriginalPosition = middlePoint(aMessage->movedObject());
-
-  if (!anOriginalPosition)
-    return; // something has gone wrong, do not process movement
-
-  aMessage->setOriginalPosition(anOriginalPosition);
-  aMessage->setCurrentPosition(theTargetPoint);
-  Events_Loop::loop()->send(aMessage);
-}
-
-void SketchAPI_Sketch::move(const ModelHighAPI_RefAttr& theMovedEntity,
-                            double theTargetX, double theTargetY)
-{
-  std::shared_ptr<GeomAPI_Pnt2d> aTargetPoint(new GeomAPI_Pnt2d(theTargetX, theTargetY));
-  move(theMovedEntity, aTargetPoint);
-}
-
-//--------------------------------------------------------------------------------------
-
 std::shared_ptr<GeomAPI_Pnt2d> SketchAPI_Sketch::to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint)
 {
   FeaturePtr aBase = feature();
index f178514441a2c97ea09592e7098bd7b0d329c067..b62e9c3af6edb2d679861497bac4d0baf31e2a1d 100644 (file)
@@ -333,20 +333,6 @@ public:
       const ModelHighAPI_RefAttr & thePointOrLine,
       const ModelHighAPI_Double & theValue);
 
-  /// Set horizontal distance
-  SKETCHAPI_EXPORT
-  std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
-      const ModelHighAPI_RefAttr & thePoint1,
-      const ModelHighAPI_RefAttr & thePoint2,
-      const ModelHighAPI_Double & theValue);
-
-  /// Set vertical distance
-  SKETCHAPI_EXPORT
-  std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
-      const ModelHighAPI_RefAttr & thePoint1,
-      const ModelHighAPI_RefAttr & thePoint2,
-      const ModelHighAPI_Double & theValue);
-
   /// Set equal
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelHighAPI_Interface> setEqual(
@@ -421,16 +407,6 @@ public:
       const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
       const ModelHighAPI_Double & theValue);
 
-  /// Move point or sketch feature
-  SKETCHAPI_EXPORT
-  void move(const ModelHighAPI_RefAttr& theMovedEntity,
-            const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
-
-  /// Move point or sketch feature
-  SKETCHAPI_EXPORT
-  void move(const ModelHighAPI_RefAttr& theMovedEntity,
-            double theTargetX, double theTargetY);
-
   SKETCHAPI_EXPORT
   std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
 
index bacf4249a679c2940aae88099ebad870875e9464..82e27cd77e41a9efeee2f3899f5003402c08016a 100644 (file)
@@ -31,9 +31,8 @@ SET(PROJECT_HEADERS
     SketchPlugin_ConstraintCoincidence.h
     SketchPlugin_ConstraintCollinear.h
     SketchPlugin_ConstraintDistance.h
-    SketchPlugin_ConstraintDistanceHorizontal.h
-    SketchPlugin_ConstraintDistanceVertical.h
     SketchPlugin_ConstraintEqual.h
+    SketchPlugin_Fillet.h
     SketchPlugin_ConstraintHorizontal.h
     SketchPlugin_ConstraintLength.h
     SketchPlugin_ConstraintMiddle.h
@@ -44,16 +43,13 @@ SET(PROJECT_HEADERS
     SketchPlugin_ConstraintRigid.h
     SketchPlugin_ConstraintTangent.h
     SketchPlugin_ConstraintVertical.h
-    SketchPlugin_Ellipse.h
     SketchPlugin_ExternalValidator.h
     SketchPlugin_Feature.h
-    SketchPlugin_Fillet.h
     SketchPlugin_IntersectionPoint.h
     SketchPlugin_Line.h
     SketchPlugin_MacroArc.h
     SketchPlugin_MacroArcReentrantMessage.h
     SketchPlugin_MacroCircle.h
-    SketchPlugin_MacroEllipse.h
     SketchPlugin_MultiRotation.h
     SketchPlugin_MultiTranslation.h
     SketchPlugin_Plugin.h
@@ -76,9 +72,8 @@ SET(PROJECT_SOURCES
     SketchPlugin_ConstraintCoincidence.cpp
     SketchPlugin_ConstraintCollinear.cpp
     SketchPlugin_ConstraintDistance.cpp
-    SketchPlugin_ConstraintDistanceHorizontal.cpp
-    SketchPlugin_ConstraintDistanceVertical.cpp
     SketchPlugin_ConstraintEqual.cpp
+    SketchPlugin_Fillet.cpp
     SketchPlugin_ConstraintHorizontal.cpp
     SketchPlugin_ConstraintLength.cpp
     SketchPlugin_ConstraintMiddle.cpp
@@ -89,15 +84,12 @@ SET(PROJECT_SOURCES
     SketchPlugin_ConstraintRigid.cpp
     SketchPlugin_ConstraintTangent.cpp
     SketchPlugin_ConstraintVertical.cpp
-    SketchPlugin_Ellipse.cpp
     SketchPlugin_ExternalValidator.cpp
     SketchPlugin_Feature.cpp
-    SketchPlugin_Fillet.cpp
     SketchPlugin_IntersectionPoint.cpp
     SketchPlugin_Line.cpp
     SketchPlugin_MacroArc.cpp
     SketchPlugin_MacroCircle.cpp
-    SketchPlugin_MacroEllipse.cpp
     SketchPlugin_MultiRotation.cpp
     SketchPlugin_MultiTranslation.cpp
     SketchPlugin_Plugin.cpp
@@ -163,15 +155,11 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                TestConstraintCollinear.py
                TestConstraintLength.py
                TestConstraintDistance.py
-               TestConstraintDistanceHorizontal.py
-               TestConstraintDistanceVertical.py
-               TestConstraintDistanceBehavior.py
                TestConstraintParallel.py
                TestConstraintPerpendicular.py
                TestConstraintRadius.py
                TestConstraintFixed.py
                TestConstraintHorizontal.py
-               TestConstraintHorizontalValidator.py
                TestConstraintVertical.py
                TestConstraintEqual.py
                TestConstraintTangent.py
@@ -210,10 +198,4 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                TestTrimCircle05.py
                TestTrimCircleAndArc01.py
                TestTrimLine01.py
-               TestTrimLine02.py
-               TestMovePoint.py
-               TestMoveLine.py
-               TestMoveCircle.py
-               TestMoveArc.py
-               TestMovementComplex.py
-)
+               TestTrimLine02.py)
index f4a02ca4102db7db10e294f8ec4b8e4089fc8500..4d299b6b01d848532fdda463e70a51b18271ccd6 100644 (file)
@@ -178,32 +178,6 @@ double SketchPlugin_ConstraintDistance::calculateCurrentDistance()
   return aDistance;
 }
 
-bool SketchPlugin_ConstraintDistance::areAttributesInitialized()
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-  std::shared_ptr<GeomDataAPI_Point2D> aPointA =
-      SketcherPrs_Tools::getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A(), aPlane);
-  std::shared_ptr<GeomDataAPI_Point2D> aPointB =
-      SketcherPrs_Tools::getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-  if (!aPointA && !aPointB)
-    return false;
-  else if (aPointA || aPointB) {
-    FeaturePtr aLine;
-    if (!aPointA)
-      aLine = SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
-    else if (!aPointB)
-      aLine = SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
-    else // both points are initialized
-      return true;
-
-    if (!aLine || aLine->getKind() != SketchPlugin_Line::ID())
-      return false;
-  }
-  return true;
-}
-
 void SketchPlugin_ConstraintDistance::attributeChanged(const std::string& theID)
 {
   if (theID == SketchPlugin_Constraint::ENTITY_A() ||
index c2dc3ee409e95ec77131d4488abee32c29f2cdb4..8c96dfa2953824610abfb7d840a889686219ff23 100644 (file)
@@ -85,10 +85,7 @@ class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
 
 protected:
   /// Returns the current distance between the feature attributes
-  virtual double calculateCurrentDistance();
-
-  /// Check the attributes related to distanced points/features are initialized
-  bool areAttributesInitialized();
+  double calculateCurrentDistance();
 
 private:
   bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.cpp
deleted file mode 100644 (file)
index 4d92164..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:    SketchPlugin_ConstraintDistanceHorizontal.cpp
-// Created: 2 May 2017
-// Author:  Artem ZHIDKOV
-
-#include <SketchPlugin_ConstraintDistanceHorizontal.h>
-
-#include <SketcherPrs_Tools.h>
-#include <SketcherPrs_Factory.h>
-
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_XY.h>
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_AttributeDouble.h>
-
-const double tolerance = 1e-7;
-
-
-SketchPlugin_ConstraintDistanceHorizontal::SketchPlugin_ConstraintDistanceHorizontal()
-  : SketchPlugin_ConstraintDistance()
-{
-}
-
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceHorizontal::initAttributes()
-{
-  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
-}
-
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceHorizontal::execute()
-{
-  AttributeDoublePtr anAttrValue = real(SketchPlugin_Constraint::VALUE());
-  if (anAttrValue->isInitialized() || !areAttributesInitialized())
-    return;
-
-  double aDistance = calculateCurrentDistance();
-  anAttrValue->setValue(aDistance);
-}
-
-//*************************************************************************************
-AISObjectPtr SketchPlugin_ConstraintDistanceHorizontal::getAISObject(AISObjectPtr thePrevious)
-{
-  if (!sketch())
-    return thePrevious;
-
-  AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
-                                                                      sketch()->coordinatePlane(),
-                                                                      thePrevious);
-  return anAIS;
-}
-
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceHorizontal::move(double theDeltaX, double theDeltaY)
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  if (!aData->isValid())
-    return;
-
-  // Recalculate a shift of flyout point in terms of local coordinates
-  std::shared_ptr<GeomAPI_XY> aDir(new GeomAPI_XY(theDeltaX, theDeltaY));
-  std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-  std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
-      data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
-  std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
-      data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-  if (!aPointA || !aPointB)
-    return;
-
-  std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
-  std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
-  std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
-  double dX = aDir->dot(aLineDir->xy());
-  double dY = -aDir->cross(aLineDir->xy());
-
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  myFlyoutUpdate = true;
-  if (aPoint->isInitialized()) {
-    aPoint->setValue(aPoint->x() + dX, aPoint->y() + dY);
-  } else {
-    aPoint->setValue(dX, dY);
-  }
-  myFlyoutUpdate = false;
-}
-
-double SketchPlugin_ConstraintDistanceHorizontal::calculateCurrentDistance()
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-  std::shared_ptr<GeomDataAPI_Point2D> aPointA =
-    SketcherPrs_Tools::getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A(), aPlane);
-  std::shared_ptr<GeomDataAPI_Point2D> aPointB =
-      SketcherPrs_Tools::getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-  return aPointB->x() - aPointA->x();
-}
-
-void SketchPlugin_ConstraintDistanceHorizontal::attributeChanged(const std::string& theID)
-{
-  if (theID == SketchPlugin_Constraint::ENTITY_A() ||
-      theID == SketchPlugin_Constraint::ENTITY_B())
-  {
-    AttributeDoublePtr aValueAttr = real(SketchPlugin_Constraint::VALUE());
-    if (!aValueAttr->isInitialized() && areAttributesInitialized()) {
-      // only if it is not initialized, try to compute the current value
-      double aDistance = calculateCurrentDistance();
-      aValueAttr->setValue(aDistance);
-    }
-  } else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) {
-    myFlyoutUpdate = true;
-    // Recalculate flyout point in local coordinates of the distance constraint:
-    // the X coordinate is a length of projection of the flyout point on the
-    //                  line binding two distanced points
-    //                  or a line of projection of the distanced point onto the distanced segment
-    // the Y coordinate is a distance from the flyout point to the line
-    std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-    std::shared_ptr<GeomAPI_Pnt2d> aFlyoutPnt = aFlyoutAttr->pnt();
-
-    std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-    std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
-        data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
-    std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
-        data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-    std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
-    std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
-    if (aEndPnt->distance(aStartPnt) < tolerance)
-      return;
-
-    std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
-    std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aStartPnt);
-
-    double X = aFlyoutDir->dot(aLineDir->xy());
-    double Y = -aFlyoutDir->cross(aLineDir->xy());
-    aFlyoutAttr->setValue(X, Y);
-    myFlyoutUpdate = false;
-  }
-}
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.h b/src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.h
deleted file mode 100644 (file)
index 98ef117..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:    SketchPlugin_ConstraintDistanceHorizontal.h
-// Created: 2 May 2017
-// Author:  Artem ZHIDKOV
-
-#ifndef SketchPlugin_ConstraintDistanceHorizontal_H_
-#define SketchPlugin_ConstraintDistanceHorizontal_H_
-
-#include <SketchPlugin.h>
-#include <SketchPlugin_ConstraintDistance.h>
-
-/** \class SketchPlugin_ConstraintDistanceHorizontal
- *  \ingroup Plugins
- *  \brief Feature for creation of a new constraint which defines a horizontal distance between two points.
- *
- *  This constraint has three attributes:
- *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
- */
-class SketchPlugin_ConstraintDistanceHorizontal : public SketchPlugin_ConstraintDistance
-{
-public:
-  /// Distance constraint kind
-  inline static const std::string& ID()
-  {
-    static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistanceHorizontal");
-    return MY_CONSTRAINT_DISTANCE_ID;
-  }
-
-  /// \brief Returns the kind of a feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
-  {
-    static std::string MY_KIND = SketchPlugin_ConstraintDistanceHorizontal::ID();
-    return MY_KIND;
-  }
-
-  /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
-
-  /// \brief Request for initialization of data model of the feature: adding all attributes
-  SKETCHPLUGIN_EXPORT virtual void initAttributes();
-
-  /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
-
-  /// Moves the feature
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
-  /// Called on change of any argument-attribute of this object
-  /// \param theID identifier of changed attribute
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
-  /// \brief Use plugin manager for features creation
-  SketchPlugin_ConstraintDistanceHorizontal();
-
-protected:
-  /// Returns the current distance between the feature attributes
-  virtual double calculateCurrentDistance();
-
-private:
-  bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
-};
-
-#endif
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.cpp
deleted file mode 100644 (file)
index 6691ee5..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:    SketchPlugin_ConstraintDistanceVertical.cpp
-// Created: 10 May 2017
-// Author:  Artem ZHIDKOV
-
-#include <SketchPlugin_ConstraintDistanceVertical.h>
-
-#include <SketcherPrs_Tools.h>
-#include <SketcherPrs_Factory.h>
-
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_XY.h>
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_AttributeDouble.h>
-
-const double tolerance = 1e-7;
-
-
-SketchPlugin_ConstraintDistanceVertical::SketchPlugin_ConstraintDistanceVertical()
-  : SketchPlugin_ConstraintDistance()
-{
-}
-
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceVertical::initAttributes()
-{
-  data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
-}
-
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceVertical::execute()
-{
-  AttributeDoublePtr anAttrValue = real(SketchPlugin_Constraint::VALUE());
-  if (anAttrValue->isInitialized() || !areAttributesInitialized())
-    return;
-
-  double aDistance = calculateCurrentDistance();
-  anAttrValue->setValue(aDistance);
-}
-
-//*************************************************************************************
-AISObjectPtr SketchPlugin_ConstraintDistanceVertical::getAISObject(AISObjectPtr thePrevious)
-{
-  if (!sketch())
-    return thePrevious;
-
-  AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
-                                                                      sketch()->coordinatePlane(),
-                                                                      thePrevious);
-  return anAIS;
-}
-
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceVertical::move(double theDeltaX, double theDeltaY)
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  if (!aData->isValid())
-    return;
-
-  // Recalculate a shift of flyout point in terms of local coordinates
-  std::shared_ptr<GeomAPI_XY> aDir(new GeomAPI_XY(theDeltaX, theDeltaY));
-  std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-  std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
-      data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
-  std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
-      data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-  if (!aPointA || !aPointB)
-    return;
-
-  std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
-  std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
-  std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
-  double dX = aDir->dot(aLineDir->xy());
-  double dY = -aDir->cross(aLineDir->xy());
-
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-  myFlyoutUpdate = true;
-  if (aPoint->isInitialized()) {
-    aPoint->setValue(aPoint->x() + dX, aPoint->y() + dY);
-  } else {
-    aPoint->setValue(dX, dY);
-  }
-  myFlyoutUpdate = false;
-}
-
-double SketchPlugin_ConstraintDistanceVertical::calculateCurrentDistance()
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-  std::shared_ptr<GeomDataAPI_Point2D> aPointA =
-    SketcherPrs_Tools::getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A(), aPlane);
-  std::shared_ptr<GeomDataAPI_Point2D> aPointB =
-      SketcherPrs_Tools::getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-  return aPointB->y() - aPointA->y();
-}
-
-void SketchPlugin_ConstraintDistanceVertical::attributeChanged(const std::string& theID)
-{
-  if (theID == SketchPlugin_Constraint::ENTITY_A() ||
-      theID == SketchPlugin_Constraint::ENTITY_B())
-  {
-    AttributeDoublePtr aValueAttr = real(SketchPlugin_Constraint::VALUE());
-    if (!aValueAttr->isInitialized() && areAttributesInitialized()) {
-      // only if it is not initialized, try to compute the current value
-      double aDistance = calculateCurrentDistance();
-      aValueAttr->setValue(aDistance);
-    }
-  } else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) {
-    myFlyoutUpdate = true;
-    // Recalculate flyout point in local coordinates of the distance constraint:
-    // the X coordinate is a length of projection of the flyout point on the
-    //                  line binding two distanced points
-    //                  or a line of projection of the distanced point onto the distanced segment
-    // the Y coordinate is a distance from the flyout point to the line
-    std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-    std::shared_ptr<GeomAPI_Pnt2d> aFlyoutPnt = aFlyoutAttr->pnt();
-
-    std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
-    std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
-        data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
-    std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
-        data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
-    std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
-    std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
-    if (aEndPnt->distance(aStartPnt) < tolerance)
-      return;
-
-    std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
-    std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aStartPnt);
-
-    double X = aFlyoutDir->dot(aLineDir->xy());
-    double Y = -aFlyoutDir->cross(aLineDir->xy());
-    aFlyoutAttr->setValue(X, Y);
-    myFlyoutUpdate = false;
-  }
-}
diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.h b/src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.h
deleted file mode 100644 (file)
index 7847700..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:    SketchPlugin_ConstraintDistanceVertical.h
-// Created: 10 May 2017
-// Author:  Artem ZHIDKOV
-
-#ifndef SketchPlugin_ConstraintDistanceVertical_H_
-#define SketchPlugin_ConstraintDistanceVertical_H_
-
-#include <SketchPlugin.h>
-#include <SketchPlugin_ConstraintDistance.h>
-
-/** \class SketchPlugin_ConstraintDistanceVertical
- *  \ingroup Plugins
- *  \brief Feature for creation of a new constraint which defines a vertical distance between two points.
- *
- *  This constraint has three attributes:
- *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
- */
-class SketchPlugin_ConstraintDistanceVertical : public SketchPlugin_ConstraintDistance
-{
-public:
-  /// Distance constraint kind
-  inline static const std::string& ID()
-  {
-    static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistanceVertical");
-    return MY_CONSTRAINT_DISTANCE_ID;
-  }
-
-  /// \brief Returns the kind of a feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
-  {
-    static std::string MY_KIND = SketchPlugin_ConstraintDistanceVertical::ID();
-    return MY_KIND;
-  }
-
-  /// \brief Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
-
-  /// \brief Request for initialization of data model of the feature: adding all attributes
-  SKETCHPLUGIN_EXPORT virtual void initAttributes();
-
-  /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
-
-  /// Moves the feature
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
-  /// Called on change of any argument-attribute of this object
-  /// \param theID identifier of changed attribute
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
-  /// \brief Use plugin manager for features creation
-  SketchPlugin_ConstraintDistanceVertical();
-
-protected:
-  /// Returns the current distance between the feature attributes
-  virtual double calculateCurrentDistance();
-
-private:
-  bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
-};
-
-#endif
diff --git a/src/SketchPlugin/SketchPlugin_Ellipse.cpp b/src/SketchPlugin/SketchPlugin_Ellipse.cpp
deleted file mode 100644 (file)
index d9f61e1..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        SketchPlugin_Ellipse.cpp
-// Created:     26 April 2017
-// Author:      Artem ZHIDKOV
-
-#include <SketchPlugin_Ellipse.h>
-#include <SketchPlugin_Sketch.h>
-
-#include <GeomAlgoAPI_EdgeBuilder.h>
-#include <GeomAPI_Edge.h>
-#include <GeomAPI_Ellipse.h>
-#include <GeomDataAPI_Point2D.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Validator.h>
-
-static const double tolerance = 1e-7;
-
-
-SketchPlugin_Ellipse::SketchPlugin_Ellipse()
-: SketchPlugin_SketchEntity()
-{
-}
-
-void SketchPlugin_Ellipse::initDerivedClassAttributes()
-{
-  data()->addAttribute(CENTER_ID(), GeomDataAPI_Point2D::typeId());
-  data()->addAttribute(FOCUS_ID(), GeomDataAPI_Point2D::typeId());
-  data()->addAttribute(MAJOR_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(MINOR_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
-
-  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
-  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
-}
-
-void SketchPlugin_Ellipse::execute()
-{
-  SketchPlugin_Sketch* aSketch = sketch();
-  if(!aSketch) {
-    return;
-  }
-
-  // Compute a ellipse in 3D view.
-  std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CENTER_ID()));
-  std::shared_ptr<GeomDataAPI_Point2D> aFocusAttr =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(FOCUS_ID()));
-  AttributeDoublePtr aMajorRadiusAttr = real(MAJOR_RADIUS_ID());
-  AttributeDoublePtr aMinorRadiusAttr = real(MINOR_RADIUS_ID());
-  if (!aCenterAttr->isInitialized() ||
-      !aFocusAttr->isInitialized() ||
-      !aMajorRadiusAttr->isInitialized() ||
-      !aMinorRadiusAttr->isInitialized()) {
-    return;
-  }
-
-  double aMajorRadius = aMajorRadiusAttr->value();
-  double aMinorRadius = aMinorRadiusAttr->value();
-  if(aMajorRadius < tolerance || aMinorRadius < tolerance) {
-    return;
-  }
-
-  // Make a visible point.
-  SketchPlugin_Sketch::createPoint2DResult(this, aSketch, CENTER_ID(), 0);
-
-  std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aSketch->attribute(SketchPlugin_Sketch::NORM_ID()));
-
-  // Make a visible ellipse.
-  std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
-  std::shared_ptr<GeomAPI_Pnt> aFocus(aSketch->to3D(aFocusAttr->x(), aFocusAttr->y()));
-  std::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
-  std::shared_ptr<GeomAPI_Dir> aMajorAxis(new GeomAPI_Dir(aFocus->x() - aCenter->x(),
-      aFocus->y() - aCenter->y(), aFocus->z() - aCenter->z()));
-
-  std::shared_ptr<GeomAPI_Shape> anEllipseShape =
-      GeomAlgoAPI_EdgeBuilder::ellipse(aCenter, aNormal, aMajorAxis, aMajorRadius, aMinorRadius);
-
-  std::shared_ptr<ModelAPI_ResultConstruction> aResult = document()->createConstruction(data(), 1);
-  aResult->setShape(anEllipseShape);
-  aResult->setIsInHistory(false);
-  setResult(aResult, 1);
-}
-
-void SketchPlugin_Ellipse::move(double theDeltaX, double theDeltaY)
-{
-  std::shared_ptr<ModelAPI_Data> aData = data();
-  if(!aData->isValid()) {
-    return;
-  }
-
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(CENTER_ID()));
-  if(aPoint->isInitialized()) {
-    aPoint->move(theDeltaX, theDeltaY);
-  }
-}
-
-bool SketchPlugin_Ellipse::isFixed() {
-  return data()->selection(EXTERNAL_ID())->context().get() != NULL;
-}
-
-void SketchPlugin_Ellipse::attributeChanged(const std::string& theID) {
-  // the second condition for unability to move external segments anywhere
-  if (theID == EXTERNAL_ID() || isFixed()) {
-    std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
-    if (!aSelection) {
-      // empty shape in selection shows that the shape is equal to context
-      ResultPtr anExtRes = selection(EXTERNAL_ID())->context();
-      if (anExtRes)
-        aSelection = anExtRes->shape();
-    }
-    // update arguments due to the selection value
-    if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
-      std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
-      std::shared_ptr<GeomAPI_Ellipse> anEllipse = anEdge->ellipse();
-
-      std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
-          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_ID()));
-      aCenterAttr->setValue(sketch()->to2D(anEllipse->center()));
-
-      std::shared_ptr<GeomDataAPI_Point2D> aFocusAttr =
-          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(FOCUS_ID()));
-      aFocusAttr->setValue(sketch()->to2D(anEllipse->firstFocus()));
-
-      real(MAJOR_RADIUS_ID())->setValue(anEllipse->majorRadius());
-      real(MINOR_RADIUS_ID())->setValue(anEllipse->minorRadius());
-    }
-  }
-}
diff --git a/src/SketchPlugin/SketchPlugin_Ellipse.h b/src/SketchPlugin/SketchPlugin_Ellipse.h
deleted file mode 100644 (file)
index fc4b77c..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        SketchPlugin_Ellipse.h
-// Created:     26 April 2017
-// Author:      Artem ZHIDKOV
-
-#ifndef SketchPlugin_Ellipse_H_
-#define SketchPlugin_Ellipse_H_
-
-#include <SketchPlugin.h>
-#include <SketchPlugin_SketchEntity.h>
-
-/**\class SketchPlugin_Ellipse
- * \ingroup Plugins
- * \brief Feature for creation of the new ellipse in Sketch.
- */
-class SketchPlugin_Ellipse: public SketchPlugin_SketchEntity
-{
- public:
-  /// Ellipse feature kind
-  inline static const std::string& ID()
-  {
-    static const std::string ID("SketchEllipse");
-    return ID;
-  }
-
-  /// 2D point - center of the ellipse
-  inline static const std::string& CENTER_ID()
-  {
-    static const std::string ID("ellipse_center");
-    return ID;
-  }
-
-  /// 2D point - focus of the ellipse
-  inline static const std::string& FOCUS_ID()
-  {
-    static const std::string ID("ellipse_focus");
-    return ID;
-  }
-
-  /// Major radius of the ellipse
-  inline static const std::string& MAJOR_RADIUS_ID()
-  {
-    static const std::string ID("ellipse_major_radius");
-    return ID;
-  }
-
-  /// Minor radius of the ellipse
-  inline static const std::string& MINOR_RADIUS_ID()
-  {
-    static const std::string ID("ellipse_minor_radius");
-    return ID;
-  }
-
-  /// Returns the kind of a feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
-  {
-    static std::string MY_KIND = SketchPlugin_Ellipse::ID();
-    return MY_KIND;
-  }
-
-  /// Returns true is sketch element is under the rigid constraint
-  SKETCHPLUGIN_EXPORT virtual bool isFixed();
-
-  /// Called on change of any argument-attribute of this object
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
-  /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
-
-  /// Moves the feature
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
-  /// Use plugin manager for features creation
-  SketchPlugin_Ellipse();
-
-protected:
-  /// \brief Initializes attributes of derived class.
-  virtual void initDerivedClassAttributes();
-};
-
-#endif
index 7c87681327cbb1a8398b22d461b4de1b1a293c07..2b6829c729a7f62aa6058e1698f71e9dd6e1ad25 100644 (file)
@@ -392,6 +392,7 @@ AISObjectPtr SketchPlugin_MacroCircle::getAISObject(AISObjectPtr thePrevious)
 }
 
 void SketchPlugin_MacroCircle::attributeChanged(const std::string& theID) {
+  double aRadius = 0.0;
   // If circle type switched reset all attributes.
   if(theID == CIRCLE_TYPE()) {
     SketchPlugin_Tools::resetAttribute(this, CENTER_POINT_ID());
diff --git a/src/SketchPlugin/SketchPlugin_MacroEllipse.cpp b/src/SketchPlugin/SketchPlugin_MacroEllipse.cpp
deleted file mode 100644 (file)
index 37ea7aa..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        SketchPlugin_MacroEllipse.cpp
-// Created:     26 April 2017
-// Author:      Artem ZHIDKOV
-
-#include <SketchPlugin_MacroEllipse.h>
-
-#include <SketchPlugin_Ellipse.h>
-#include <SketchPlugin_Tools.h>
-#include <SketchPlugin_Sketch.h>
-
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_EventReentrantMessage.h>
-#include <ModelAPI_Session.h>
-#include <ModelAPI_Validator.h>
-#include <ModelAPI_Events.h>
-
-#include <GeomDataAPI_Point2D.h>
-
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Ellipse2d.h>
-#include <GeomAPI_Vertex.h>
-
-#include <GeomAlgoAPI_CompoundBuilder.h>
-#include <GeomAlgoAPI_EdgeBuilder.h>
-#include <GeomAlgoAPI_PointBuilder.h>
-
-
-SketchPlugin_MacroEllipse::SketchPlugin_MacroEllipse()
-: SketchPlugin_SketchEntity(),
-  myMajorRadius(0.0),
-  myMinorRadius(0.0)
-{
-}
-
-void SketchPlugin_MacroEllipse::initAttributes()
-{
-  data()->addAttribute(CENTER_POINT_ID(), GeomDataAPI_Point2D::typeId());
-  data()->addAttribute(CENTER_POINT_REF_ID(), ModelAPI_AttributeRefAttr::typeId());
-  data()->addAttribute(MAJOR_AXIS_POINT_ID(), GeomDataAPI_Point2D::typeId());
-  data()->addAttribute(MAJOR_AXIS_POINT_REF_ID(), ModelAPI_AttributeRefAttr::typeId());
-  data()->addAttribute(PASSED_POINT_ID(), GeomDataAPI_Point2D::typeId());
-  data()->addAttribute(PASSED_POINT_REF_ID(), ModelAPI_AttributeRefAttr::typeId());
-
-  data()->addAttribute(MAJOR_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(MINOR_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::typeId());
-
-  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CENTER_POINT_REF_ID());
-  ModelAPI_Session::get()->validators()->
-      registerNotObligatory(getKind(), MAJOR_AXIS_POINT_REF_ID());
-  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PASSED_POINT_REF_ID());
-}
-
-void SketchPlugin_MacroEllipse::execute()
-{
-  FeaturePtr anEllipse = createEllipseFeature();
-  constraintsForEllipse(anEllipse);
-
-  // message to init reentrant operation
-  static Events_ID anId = ModelAPI_EventReentrantMessage::eventId();
-  ReentrantMessagePtr aMessage(new ModelAPI_EventReentrantMessage(anId, this));
-  aMessage->setCreatedFeature(anEllipse);
-  Events_Loop::loop()->send(aMessage);
-}
-
-void SketchPlugin_MacroEllipse::attributeChanged(const std::string& theID)
-{
-  static const int NB_POINTS = 3;
-  std::string aPointAttrName[NB_POINTS] = { CENTER_POINT_ID(),
-                                            MAJOR_AXIS_POINT_ID(),
-                                            PASSED_POINT_ID() };
-  std::string aPointRefName[NB_POINTS] = { CENTER_POINT_REF_ID(),
-                                           MAJOR_AXIS_POINT_REF_ID(),
-                                           PASSED_POINT_REF_ID() };
-
-  int aNbInitialized = 0;
-  std::shared_ptr<GeomAPI_Pnt2d> anEllipsePoints[NB_POINTS];
-
-  for (int aPntIndex = 0; aPntIndex < NB_POINTS; ++aPntIndex) {
-    AttributePtr aPointAttr = attribute(aPointAttrName[aPntIndex]);
-    if (!aPointAttr->isInitialized())
-      continue;
-
-    AttributeRefAttrPtr aPointRef = refattr(aPointRefName[aPntIndex]);
-    // calculate ellipse parameters
-    std::shared_ptr<GeomAPI_Pnt2d> aPassedPoint;
-    std::shared_ptr<GeomAPI_Shape> aTangentCurve;
-    SketchPlugin_Tools::convertRefAttrToPointOrTangentCurve(
-        aPointRef, aPointAttr, aTangentCurve, aPassedPoint);
-
-    anEllipsePoints[aNbInitialized++] = aPassedPoint;
-  }
-
-  std::shared_ptr<GeomAPI_Ellipse2d> anEllipse;
-  if (aNbInitialized == 2) {
-    std::shared_ptr<GeomAPI_Dir2d> aXDir(new GeomAPI_Dir2d(
-        anEllipsePoints[1]->x() - anEllipsePoints[0]->x(),
-        anEllipsePoints[1]->y() - anEllipsePoints[0]->y()));
-    double aMajorRad = anEllipsePoints[1]->distance(anEllipsePoints[0]);
-    anEllipse = std::shared_ptr<GeomAPI_Ellipse2d>(
-        new GeomAPI_Ellipse2d(anEllipsePoints[0], aXDir, aMajorRad, 0.5 * aMajorRad));
-  } else if (aNbInitialized == 3) {
-    anEllipse = std::shared_ptr<GeomAPI_Ellipse2d>(
-        new GeomAPI_Ellipse2d(anEllipsePoints[0], anEllipsePoints[1], anEllipsePoints[2]));
-  }
-
-  if (!anEllipse || anEllipse->implPtr<void>() == 0)
-    return;
-
-  myCenter = anEllipse->center();
-  myFocus = anEllipse->firstFocus();
-  myMajorRadius = anEllipse->majorRadius();
-  myMinorRadius = anEllipse->minorRadius();
-
-  AttributeDoublePtr aMajorRadiusAttr = real(MAJOR_RADIUS_ID());
-  AttributeDoublePtr aMinorRadiusAttr = real(MINOR_RADIUS_ID());
-
-  bool aWasBlocked = data()->blockSendAttributeUpdated(true);
-  // center attribute is used in processEvent() to set reference to reentrant arc
-  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_POINT_ID()))->setValue(myCenter);
-  aMajorRadiusAttr->setValue(myMajorRadius);
-  aMinorRadiusAttr->setValue(myMinorRadius);
-  data()->blockSendAttributeUpdated(aWasBlocked, false);
-}
-
-std::string SketchPlugin_MacroEllipse::processEvent(
-                                              const std::shared_ptr<Events_Message>& theMessage)
-{
-  std::string aFilledAttributeName;
-
-  ReentrantMessagePtr aReentrantMessage =
-        std::dynamic_pointer_cast<ModelAPI_EventReentrantMessage>(theMessage);
-  if (aReentrantMessage) {
-    FeaturePtr aCreatedFeature = aReentrantMessage->createdFeature();
-    ObjectPtr anObject = aReentrantMessage->selectedObject();
-    AttributePtr anAttribute = aReentrantMessage->selectedAttribute();
-    std::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = aReentrantMessage->clickedPoint();
-
-    if (aClickedPoint && (anObject || anAttribute)) {
-      aFilledAttributeName = CENTER_POINT_ID();
-      std::string aReferenceAttributeName = CENTER_POINT_REF_ID();
-
-      // fill 2d point attribute
-      AttributePoint2DPtr aPointAttr =
-          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(aFilledAttributeName));
-      aPointAttr->setValue(aClickedPoint);
-
-      // fill reference attribute
-      AttributeRefAttrPtr aRefAttr =
-          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(attribute(aReferenceAttributeName));
-      if (anAttribute) {
-        if (!anAttribute->owner() || !anAttribute->owner()->data()->isValid()) {
-          if (aCreatedFeature && anAttribute->id() == CENTER_POINT_ID())
-            anAttribute = aCreatedFeature->attribute(SketchPlugin_Ellipse::CENTER_ID());
-        }
-        aRefAttr->setAttr(anAttribute);
-      }
-      else if (anObject.get()) {
-        // if presentation of previous reentrant macro arc is used, the object is invalid,
-        // we should use result of previous feature of the message(Arc)
-        if (!anObject->data()->isValid())
-          anObject = aCreatedFeature->lastResult();
-        aRefAttr->setObject(anObject);
-      }
-    }
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-  }
-  return aFilledAttributeName;
-}
-
-void SketchPlugin_MacroEllipse::constraintsForEllipse(FeaturePtr theEllipseFeature)
-{
-  // Create constraints.
-  SketchPlugin_Tools::createConstraint(
-      this, CENTER_POINT_REF_ID(),
-      theEllipseFeature->attribute(SketchPlugin_Ellipse::CENTER_ID()),
-      ObjectPtr(), false);
-  SketchPlugin_Tools::createConstraint(
-      this, MAJOR_AXIS_POINT_REF_ID(), AttributePtr(),
-      theEllipseFeature->lastResult(), true);
-  SketchPlugin_Tools::createConstraint(
-      this, PASSED_POINT_REF_ID(), AttributePtr(),
-      theEllipseFeature->lastResult(), true);
-}
-
-FeaturePtr SketchPlugin_MacroEllipse::createEllipseFeature()
-{
-  FeaturePtr aEllipseFeature = sketch()->addFeature(SketchPlugin_Ellipse::ID());
-
-  AttributePoint2DPtr aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aEllipseFeature->attribute(SketchPlugin_Ellipse::CENTER_ID()));
-  aCenterAttr->setValue(myCenter->x(), myCenter->y());
-
-  AttributePoint2DPtr aFocusAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aEllipseFeature->attribute(SketchPlugin_Ellipse::FOCUS_ID()));
-  aFocusAttr->setValue(myFocus->x(), myFocus->y());
-
-  aEllipseFeature->real(SketchPlugin_Ellipse::MAJOR_RADIUS_ID())->setValue(myMajorRadius);
-  aEllipseFeature->real(SketchPlugin_Ellipse::MINOR_RADIUS_ID())->setValue(myMinorRadius);
-
-  aEllipseFeature->boolean(SketchPlugin_Ellipse::AUXILIARY_ID())->setValue(
-      boolean(AUXILIARY_ID())->value());
-
-  aEllipseFeature->execute();
-  return aEllipseFeature;
-}
-
-AISObjectPtr SketchPlugin_MacroEllipse::getAISObject(AISObjectPtr thePrevious)
-{
-  SketchPlugin_Sketch* aSketch = sketch();
-  if (!aSketch || !myCenter || myMajorRadius == 0)
-    return AISObjectPtr();
-
-  std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-
-  // Compute a ellipse in 3D view.
-  std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(myCenter->x(), myCenter->y()));
-  std::shared_ptr<GeomAPI_Pnt> aFocus(aSketch->to3D(myFocus->x(), myFocus->y()));
-  std::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
-  std::shared_ptr<GeomAPI_Dir> aMajorAxis(new GeomAPI_Dir(aFocus->x() - aCenter->x(),
-      aFocus->y() - aCenter->y(), aFocus->z() - aCenter->z()));
-
-  std::shared_ptr<GeomAPI_Shape> anEllipseShape =
-      GeomAlgoAPI_EdgeBuilder::ellipse(aCenter, aNormal, aMajorAxis, myMajorRadius, myMinorRadius);
-  GeomShapePtr aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter);
-  if (!anEllipseShape.get() || !aCenterPointShape.get())
-    return AISObjectPtr();
-
-  std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
-  aShapes.push_back(anEllipseShape);
-  aShapes.push_back(aCenterPointShape);
-
-  std::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
-  AISObjectPtr anAIS = thePrevious;
-  if (!anAIS)
-    anAIS.reset(new GeomAPI_AISObject());
-  anAIS->createShape(aCompound);
-  return anAIS;
-}
diff --git a/src/SketchPlugin/SketchPlugin_MacroEllipse.h b/src/SketchPlugin/SketchPlugin_MacroEllipse.h
deleted file mode 100644 (file)
index d31d0d5..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:        SketchPlugin_MacroEllipse.h
-// Created:     26 April 2017
-// Author:      Artem ZHIDKOV
-
-#ifndef SketchPlugin_MacroEllipse_H_
-#define SketchPlugin_MacroEllipse_H_
-
-#include <ModelAPI_IReentrant.h>
-#include <SketchPlugin.h>
-#include <SketchPlugin_SketchEntity.h>
-#include <GeomAPI_IPresentable.h>
-
-////class GeomAPI_Circ2d;
-class GeomAPI_Pnt2d;
-
-/**\class SketchPlugin_MacroEllipse
- * \ingroup Plugins
- * \brief Feature for creation of the new ellipse in Sketch.
- */
-class SketchPlugin_MacroEllipse: public SketchPlugin_SketchEntity,
-                                 public GeomAPI_IPresentable,
-                                 public ModelAPI_IReentrant
-{
- public:
-  /// Ellipse feature kind
-  inline static const std::string& ID()
-  {
-    static const std::string ID("SketchMacroEllipse");
-    return ID;
-  }
-
-  /// 2D point - center of the ellipse.
-  inline static const std::string& CENTER_POINT_ID()
-  {
-    static const std::string ID("center_point");
-    return ID;
-  }
-
-  /// Reference for center point selection.
-  inline static const std::string& CENTER_POINT_REF_ID()
-  {
-    static const std::string ID("center_point_ref");
-    return ID;
-  }
-
-  /// 2D point - major axis point of the ellipse.
-  inline static const std::string& MAJOR_AXIS_POINT_ID()
-  {
-    static const std::string ID("major_axis_point");
-    return ID;
-  }
-
-  /// Reference for major axis point selection.
-  inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
-  {
-    static const std::string ID("major_axis_point_ref");
-    return ID;
-  }
-
-  /// 2D point - passed point of the ellipse
-  inline static const std::string& PASSED_POINT_ID()
-  {
-    static const std::string ID("passed_point");
-    return ID;
-  }
-
-  /// Reference for passed point selection.
-  inline static const std::string& PASSED_POINT_REF_ID()
-  {
-    static const std::string ID("passed_point_ref");
-    return ID;
-  }
-
-  /// Major radius of the ellipse
-  inline static const std::string& MAJOR_RADIUS_ID()
-  {
-    static const std::string ID("ellipse_major_radius");
-    return ID;
-  }
-
-  /// Minor radius of the ellipse
-  inline static const std::string& MINOR_RADIUS_ID()
-  {
-    static const std::string ID("ellipse_minor_radius");
-    return ID;
-  }
-
-  /// Returns the kind of a feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
-  {
-    static std::string MY_KIND = SketchPlugin_MacroEllipse::ID();
-    return MY_KIND;
-  }
-
-  /// \brief Request for initialization of data model of the feature: adding all attributes.
-  SKETCHPLUGIN_EXPORT virtual void initAttributes();
-
-  /// Called on change of any argument-attribute of this object
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
-  /// Returns the AIS preview
-  virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
-
-  /// Creates a new part document if needed
-  SKETCHPLUGIN_EXPORT virtual void execute();
-
-  /// Moves the feature
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
-  {}
-
-  /// Reimplemented from ModelAPI_Feature::isMacro().
-  /// \returns true
-  SKETCHPLUGIN_EXPORT virtual bool isMacro() const
-  {return true;}
-
-  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
-  {return false;}
-
-  /// Apply information of the message to current object. It fills reference object,
-  /// tangent type and tangent point refence in case of tangent arc
-  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
-
-  /// Use plugin manager for features creation
-  SketchPlugin_MacroEllipse();
-
-private:
-  void constraintsForEllipse(FeaturePtr theEllipseFeature);
-
-  FeaturePtr createEllipseFeature();
-
-private:
-  std::shared_ptr<GeomAPI_Pnt2d> myCenter;
-  std::shared_ptr<GeomAPI_Pnt2d> myFocus;
-  double                         myMajorRadius;
-  double                         myMinorRadius;
-};
-
-#endif
index 0a1c026780f159025a7b7ca0653c3a74ebde224a..515cc685deb68622074d8105d937b7e6526623eb 100644 (file)
@@ -30,8 +30,6 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintCollinear.h>
 #include <SketchPlugin_ConstraintDistance.h>
-#include <SketchPlugin_ConstraintDistanceHorizontal.h>
-#include <SketchPlugin_ConstraintDistanceVertical.h>
 #include <SketchPlugin_ConstraintEqual.h>
 #include <SketchPlugin_Fillet.h>
 #include <SketchPlugin_ConstraintHorizontal.h>
@@ -52,8 +50,6 @@
 #include <SketchPlugin_Split.h>
 #include <SketchPlugin_Validators.h>
 #include <SketchPlugin_ExternalValidator.h>
-#include <SketchPlugin_Ellipse.h>
-#include <SketchPlugin_MacroEllipse.h>
 
 #include <Events_Loop.h>
 #include <GeomDataAPI_Dir.h>
@@ -130,7 +126,6 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                               new SketchPlugin_ArcEndPointValidator);
   aFactory->registerValidator("SketchPlugin_ArcEndPointIntersectionValidator",
                               new SketchPlugin_ArcEndPointIntersectionValidator);
-  aFactory->registerValidator("SketchPlugin_HasNoConstraint", new SketchPlugin_HasNoConstraint);
 
   // register this plugin
   ModelAPI_Session::get()->registerPlugin(this);
@@ -192,10 +187,6 @@ FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new SketchPlugin_ConstraintCollinear);
   } else if (theFeatureID == SketchPlugin_ConstraintDistance::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintDistance);
-  } else if (theFeatureID == SketchPlugin_ConstraintDistanceHorizontal::ID()) {
-    return FeaturePtr(new SketchPlugin_ConstraintDistanceHorizontal);
-  } else if (theFeatureID == SketchPlugin_ConstraintDistanceVertical::ID()) {
-    return FeaturePtr(new SketchPlugin_ConstraintDistanceVertical);
   } else if (theFeatureID == SketchPlugin_ConstraintLength::ID()) {
     return FeaturePtr(new SketchPlugin_ConstraintLength);
   } else if (theFeatureID == SketchPlugin_ConstraintParallel::ID()) {
@@ -234,10 +225,6 @@ FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new SketchPlugin_MacroArc);
   } else if (theFeatureID == SketchPlugin_MacroCircle::ID()) {
     return FeaturePtr(new SketchPlugin_MacroCircle);
-  } else if (theFeatureID == SketchPlugin_Ellipse::ID()) {
-    return FeaturePtr(new SketchPlugin_Ellipse);
-  } else if (theFeatureID == SketchPlugin_MacroEllipse::ID()) {
-    return FeaturePtr(new SketchPlugin_MacroEllipse);
   }
   // feature of such kind is not found
   return FeaturePtr();
@@ -280,7 +267,6 @@ std::shared_ptr<ModelAPI_FeatureStateMessage> SketchPlugin_Plugin
       aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);
       aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane);
       aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane);
-      aMsg->setState(SketchPlugin_Ellipse::ID(), aHasSketchPlane);
       aMsg->setState(SketchPlugin_Projection::ID(), aHasSketchPlane);
       aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane);
       aMsg->setState(SketchPlugin_ConstraintCollinear::ID(), aHasSketchPlane);
@@ -304,8 +290,6 @@ std::shared_ptr<ModelAPI_FeatureStateMessage> SketchPlugin_Plugin
       aMsg->setState(SketchPlugin_Trim::ID(), aHasSketchPlane);
       aMsg->setState(SketchPlugin_MacroArc::ID(), aHasSketchPlane);
       aMsg->setState(SketchPlugin_MacroCircle::ID(), aHasSketchPlane);
-      aMsg->setState(SketchPlugin_ConstraintDistanceHorizontal::ID(), aHasSketchPlane);
-      aMsg->setState(SketchPlugin_ConstraintDistanceVertical::ID(), aHasSketchPlane);
       // SketchRectangle is a python feature, so its ID is passed just as a string
       aMsg->setState("SketchRectangle", aHasSketchPlane);
     }
index e16da117c74984d1221a4e4cd0f35e346a83cd0f..d7aaa53e99dcefc0dafd37e93d16fa837a174afe 100755 (executable)
@@ -1506,46 +1506,3 @@ bool SketchPlugin_ArcEndPointIntersectionValidator::isValid(
 
   return false;
 }
-
-bool SketchPlugin_HasNoConstraint::isValid(const AttributePtr& theAttribute,
-                                           const std::list<std::string>& theArguments,
-                                           Events_InfoMessage& theError) const
-{
-  std::set<std::string> aFeatureKinds;
-  for (std::list<std::string>::const_iterator anArgIt = theArguments.begin();
-       anArgIt != theArguments.end(); anArgIt++) {
-    aFeatureKinds.insert(*anArgIt);
-  }
-
-  if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
-    theError = "The attribute with the %1 type is not processed";
-    theError.arg(theAttribute->attributeType());
-    return false;
-  }
-
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>
-                                                                      (theAttribute);
-  bool isObject = aRefAttr->isObject();
-  if (!isObject) {
-    theError = "It uses an empty object";
-    return false;
-  }
-  ObjectPtr anObject = aRefAttr->object();
-  FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-  if (!aFeature.get()) {
-    theError = "The feature of the checked attribute is empty";
-    return false;
-  }
-
-  FeaturePtr aCurrentFeature = ModelAPI_Feature::feature(aRefAttr->owner());
-
-  std::set<AttributePtr> aRefsList = anObject->data()->refsToMe();
-  std::set<AttributePtr>::const_iterator anIt = aRefsList.begin();
-  for (; anIt != aRefsList.end(); anIt++) {
-    FeaturePtr aRefFeature = ModelAPI_Feature::feature((*anIt)->owner());
-    if (aRefFeature.get() && aCurrentFeature != aRefFeature &&
-        aFeatureKinds.find(aRefFeature->getKind()) != aFeatureKinds.end())
-      return false; // constraint is found, that means that the check is not valid
-  }
-  return true;
-}
index ccfe6432824aaef8313f9d54c8e26a5ef0e1ddea..398fd16baf5c29f8f1b2f9368b92fc5eca8b52a7 100644 (file)
@@ -427,24 +427,4 @@ class SketchPlugin_ArcEndPointIntersectionValidator: public ModelAPI_AttributeVa
                        Events_InfoMessage& theError) const;
 };
 
-/**\class SketchPlugin_HasNoConstraint
- * \ingroup Validators
- * \brief Validator for checking whether the feature has constraint.
- *
- * Checks that feature of the attribute does not have constraint with some kinds.
- * The kinds of constraints should be described in parameters of the validator
- * Validator processes the ModelAPI_AttributeRefAttr attribute kind
- */
-class SketchPlugin_HasNoConstraint: public ModelAPI_AttributeValidator
-{
- public:
-  //! returns true if attribute is valid
-  //! \param theAttribute the checked attribute
-  //! \param theArguments arguments of the attribute
-  //! \param theError error message
-  virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments,
-                       Events_InfoMessage& theError) const;
-};
-
 #endif
index 263e89a76abcf696a01c32113e797255af0c88e6..4c60d369677553c70c04aafe06639d44a7c977b5 100644 (file)
@@ -163,12 +163,12 @@ for aDelta in range(0, 20):
   aSession.startOperation()
   anArcStartPoint.setValue(sx, sy+aDelta) # move start point
   aSession.finishOperation()
-  model.assertArcValidity(aSketchArc)
+  model.assertSketchArc(aSketchArc)
 for aDelta in range(20, -1, -1):
   aSession.startOperation()
   anArcStartPoint.setValue(sx, sy+aDelta) # move start point
   aSession.finishOperation()
-  model.assertArcValidity(aSketchArc)
+  model.assertSketchArc(aSketchArc)
 #=========================================================================
 # Test that movement of end point of arc does not break the arc
 #=========================================================================
@@ -180,9 +180,9 @@ for aDelta in range(0, 20):
   aSession.startOperation()
   anArcEndPoint.setValue(sx+aDelta, sy) # move end point
   aSession.finishOperation()
-  model.assertArcValidity(aSketchArc)
+  model.assertSketchArc(aSketchArc)
 for aDelta in range(20, -1, -1):
   aSession.startOperation()
   anArcEndPoint.setValue(sx+aDelta, sy) # move end point
   aSession.finishOperation()
-  model.assertArcValidity(aSketchArc)
+  model.assertSketchArc(aSketchArc)
index 46ce2e4d1cba0c4bf6125b3f467242c37fda21dd..b776b267b3ec22581c21622c3b4c5effdacb0c8b 100644 (file)
@@ -51,6 +51,23 @@ from salome.shaper import model
 __updated__ = "2014-10-28"
 
 
+def distancePointLine(point, line):
+    """
+    subroutine to calculate distance between point and line
+    result of calculated distance is has 10**-5 precision
+    """
+    aStartPoint = geomDataAPI_Point2D(line.attribute("StartPoint"))
+    aEndPoint = geomDataAPI_Point2D(line.attribute("EndPoint"))
+    # orthogonal direction
+    aDirX = -(aEndPoint.y() - aStartPoint.y())
+    aDirY = (aEndPoint.x() - aStartPoint.x())
+    aLen = math.sqrt(aDirX**2 + aDirY**2)
+    aDirX = aDirX / aLen
+    aDirY = aDirY / aLen
+    aVecX = point.x() - aStartPoint.x()
+    aVecY = point.y() - aStartPoint.y()
+    return round(math.fabs(aVecX * aDirX + aVecY * aDirY), 5)
+
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
 #=========================================================================
@@ -146,7 +163,7 @@ assert (model.dof(aSketchFeature) == 6)
 # Add distance between point and line
 #=========================================================================
 PT_LINE_DIST = 50.
-aDist = model.distancePointLine(aSketchPointCoords, aSketchLine)
+aDist = distancePointLine(aSketchPointCoords, aSketchLine)
 aSession.startOperation()
 aConstraint = aSketchFeature.addFeature("SketchConstraintDistance")
 aDistance = aConstraint.real("ConstraintValue")
@@ -177,7 +194,7 @@ assert (model.dof(aSketchFeature) == 5)
 aSession.startOperation()
 aDistance.setValue(PT_LINE_DIST)
 aSession.finishOperation()
-assert (math.fabs(model.distancePointLine(aSketchPointCoords, aSketchLine) - PT_LINE_DIST) < 1.e-10)
+assert (math.fabs(distancePointLine(aSketchPointCoords, aSketchLine) - PT_LINE_DIST) < 1.e-10)
 assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Set distance between line boundaries
diff --git a/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py b/src/SketchPlugin/Test/TestConstraintDistanceBehavior.py
deleted file mode 100644 (file)
index 35ab149..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-from salome.shaper import model
-from SketchAPI import *
-import math
-
-TOLERANCE = 1.e-7
-
-model.begin()
-partSet = model.moduleDocument()
-Part_1 = model.addPart(partSet)
-Part_1_doc = Part_1.document()
-DistanceParam = model.addParameter(Part_1_doc, "distance", "10.")
-Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
-SketchRectangle_1 = Sketch_1.addRectangle(20., 20., 70., 50.)
-[SketchLine_1, SketchLine_2, SketchLine_3, SketchLine_4] = SketchRectangle_1.lines()
-firstPoint = SketchAPI_Line(SketchLine_2).startPoint()
-secondPoint = SketchAPI_Line(SketchLine_3).endPoint()
-model.do()
-
-# =============================================================================
-# Test 1.
-# =============================================================================
-# horizontal distance constraint
-SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(firstPoint, secondPoint, "distance")
-model.do()
-
-# changing the parameter
-for param in range(-30, 31, 2):
-    DistanceParam.setValue(param)
-    model.do()
-    dist = secondPoint.x() - firstPoint.x()
-    assert math.fabs(dist - param) < TOLERANCE, "Incorrect horizontal distance {}, expected {}".format(dist, param)
-
-model.testNbSubFeatures(Sketch_1, "SketchLine", 4)
-model.testNbSubFeatures(Sketch_1, "SketchConstraintDistanceHorizontal", 1)
-
-# remove horizontal distance constraint
-Part_1_doc.removeFeature(SketchConstraintDistanceHorizontal_1.feature())
-model.do()
-
-# =============================================================================
-# Test 2.
-# =============================================================================
-# Vertical distance constraint
-SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(firstPoint, secondPoint, "distance")
-model.do()
-
-# changing the parameter
-for param in range(-30, 31, 2):
-    DistanceParam.setValue(param)
-    model.do()
-    dist = secondPoint.y() - firstPoint.y()
-    assert math.fabs(dist - param) < TOLERANCE, "Incorrect vertical distance {}, expected {}".format(dist, param)
-
-model.testNbSubFeatures(Sketch_1, "SketchLine", 4)
-model.testNbSubFeatures(Sketch_1, "SketchConstraintDistanceVertical", 1)
-
-# remove verticel distance constraint
-Part_1_doc.removeFeature(SketchConstraintDistanceVertical_1.feature())
-model.do()
-
-# =============================================================================
-# Test 3.
-# =============================================================================
-# distance constraint
-SketchConstraintDistance_1 = Sketch_1.setDistance(firstPoint, secondPoint, "distance")
-model.do()
-
-# changing the parameter
-for param in range(-30, 31, 2):
-    DistanceParam.setValue(param)
-    model.do()
-    if param <= 0:
-        assert SketchConstraintDistance_1.feature().error() != '', "ERROR: Sketch should not be valid due to negative distance value"
-    else:
-        dist = model.distancePointPoint(firstPoint, secondPoint)
-        assert math.fabs(dist - math.fabs(param)) < TOLERANCE, "Incorrect distance {}, expected {}".format(dist, math.fabs(param))
-
-model.testNbSubFeatures(Sketch_1, "SketchLine", 4)
-model.testNbSubFeatures(Sketch_1, "SketchConstraintDistance", 1)
-# leave distance constraint alive
-
-model.end()
diff --git a/src/SketchPlugin/Test/TestConstraintDistanceHorizontal.py b/src/SketchPlugin/Test/TestConstraintDistanceHorizontal.py
deleted file mode 100644 (file)
index 2427874..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    TestConstraintDistanceHorizontal.py
-    Unit test of SketchPlugin_ConstraintDistanceHorizontal class
-
-    SketchPlugin_ConstraintDistanceHorizontal
-        static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
-        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
-"""
-
-from GeomDataAPI import *
-from ModelAPI import *
-import math
-from salome.shaper import model
-
-#=========================================================================
-# Initialization of the test
-#=========================================================================
-
-__updated__ = "2017-05-10"
-
-
-def horizontalDistance(point1, point2):
-    """
-    subroutine to calculate signed distance between two points
-    """
-    return point2.x() - point1.x()
-
-aSession = ModelAPI_Session.get()
-aDocument = aSession.moduleDocument()
-#=========================================================================
-# Creation of a sketch
-#=========================================================================
-aSession.startOperation()
-aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
-origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
-origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
-dirx.setValue(1, 0, 0)
-norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
-norm.setValue(0, 0, 1)
-aSession.finishOperation()
-#=========================================================================
-# Create two movable and one fixed point
-#=========================================================================
-aSession.startOperation()
-aPoint1 = aSketchFeature.addFeature("SketchPoint")
-aPoint1Coords = geomDataAPI_Point2D(aPoint1.attribute("PointCoordinates"))
-aPoint1Coords.setValue(50., 50.)
-aSession.finishOperation()
-aSession.startOperation()
-aPoint2 = aSketchFeature.addFeature("SketchPoint")
-aPoint2Coords = geomDataAPI_Point2D(aPoint2.attribute("PointCoordinates"))
-aPoint2Coords.setValue(70., 70.)
-aSession.finishOperation()
-aSession.startOperation()
-anOriginResult = modelAPI_Result(aDocument.objectByName("Construction", "Origin"))
-anOriginShape = anOriginResult.shape()
-anExtPoint = aSketchFeature.addFeature("SketchPoint")
-anExtCoords = geomDataAPI_Point2D(anExtPoint.attribute("PointCoordinates"))
-anExtCoords.setValue(0., 0.)
-anExtPoint.selection("External").setValue(anOriginResult, anOriginShape)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 4)
-
-#=========================================================================
-# Create a constraint to keep horizontal distance between movable points
-#=========================================================================
-DISTANCE1 = 25.
-aSession.startOperation()
-aHDist1 = aSketchFeature.addFeature("SketchConstraintDistanceHorizontal")
-aDistance = aHDist1.real("ConstraintValue")
-refattrA = aHDist1.refattr("ConstraintEntityA")
-refattrB = aHDist1.refattr("ConstraintEntityB")
-assert (not aDistance.isInitialized())
-assert (not refattrA.isInitialized())
-assert (not refattrB.isInitialized())
-refattrA.setObject(aPoint1.lastResult())
-refattrB.setObject(aPoint2.lastResult())
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 3)
-# set flyout point then abort operation, after that check the Distance is correct
-aSession.startOperation()
-aFlyoutPoint = geomDataAPI_Point2D(aHDist1.attribute("ConstraintFlyoutValuePnt"))
-aFlyoutPoint.setValue(50.0, 100.0)
-aSession.abortOperation()
-assert (refattrA.isInitialized())
-assert (refattrB.isInitialized())
-assert (aDistance.isInitialized())
-aSession.startOperation()
-aDistance.setValue(DISTANCE1)
-aSession.finishOperation()
-assert math.fabs(horizontalDistance(aPoint1Coords, aPoint2Coords) - DISTANCE1) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(aPoint1Coords, aPoint2Coords), DISTANCE1)
-assert (model.dof(aSketchFeature) == 3)
-#=========================================================================
-# Change a distance value
-#=========================================================================
-d = DISTANCE1 + 20.
-dStep = -5.
-while d >= -30.:
-    aSession.startOperation()
-    DISTANCE1 = d
-    aDistance.setValue(DISTANCE1)
-    aSession.finishOperation()
-    assert math.fabs(horizontalDistance(aPoint1Coords, aPoint2Coords) - DISTANCE1) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(aPoint1Coords, aPoint2Coords), DISTANCE1)
-    d += dStep
-assert (model.dof(aSketchFeature) == 3)
-
-#=========================================================================
-# Create a constraint to keep horizontal distance between fixed and movable points
-#=========================================================================
-DISTANCE2 = 50.
-aSession.startOperation()
-aHDist2 = aSketchFeature.addFeature("SketchConstraintDistanceHorizontal")
-aDistance = aHDist2.real("ConstraintValue")
-refattrA = aHDist2.refattr("ConstraintEntityA")
-refattrB = aHDist2.refattr("ConstraintEntityB")
-assert (not aDistance.isInitialized())
-assert (not refattrA.isInitialized())
-assert (not refattrB.isInitialized())
-refattrA.setObject(anExtPoint.lastResult())
-refattrB.setAttr(aPoint1Coords)
-aDistance.setValue(DISTANCE2)
-aSession.finishOperation()
-assert math.fabs(horizontalDistance(anExtCoords, aPoint1Coords) - DISTANCE2) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(anExtCoords, aPoint1Coords), DISTANCE2)
-assert math.fabs(aPoint1Coords.x() - DISTANCE2) < 1.e-5, "Wrong point coordinates ({}, {}), expected x = {}".format(aPoint1Coords.x(), aPoint1Coords.y(), DISTANCE2)
-assert (model.dof(aSketchFeature) == 2)
-#=========================================================================
-# Change a distance value (check previous constraint is applied too)
-#=========================================================================
-d = DISTANCE2
-dStep = -5.
-while d >= -50.:
-    aSession.startOperation()
-    DISTANCE2 = d
-    aDistance.setValue(DISTANCE2)
-    aSession.finishOperation()
-    assert math.fabs(horizontalDistance(anExtCoords, aPoint1Coords) - DISTANCE2) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(anExtCoords, aPoint1Coords), DISTANCE2)
-    assert math.fabs(aPoint1Coords.x() - DISTANCE2) < 1.e-5, "Wrong point coordinates ({}, {}), expected x = {}".format(aPoint1Coords.x(), aPoint1Coords.y(), DISTANCE2)
-    assert math.fabs(horizontalDistance(aPoint1Coords, aPoint2Coords) - DISTANCE1) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(aPoint1Coords, aPoint2Coords), DISTANCE1)
-    d += dStep
-assert (model.dof(aSketchFeature) == 2)
-
-#=========================================================================
-# Remove first distance
-#=========================================================================
-aStoredCoords = [aPoint2Coords.x(), aPoint2Coords.y()]
-aSession.startOperation()
-aDocument.removeFeature(aHDist1)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 3)
-aSession.startOperation()
-DISTANCE2 = 20.
-aDistance.setValue(DISTANCE2)
-aSession.finishOperation()
-assert math.fabs(horizontalDistance(anExtCoords, aPoint1Coords) - DISTANCE2) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(anExtCoords, aPoint1Coords), DISTANCE2)
-assert math.fabs(aPoint1Coords.x() - DISTANCE2) < 1.e-5, "Wrong point coordinates ({}, {}), expected x = {}".format(aPoint1Coords.x(), aPoint1Coords.y(), DISTANCE2)
-assert aPoint2Coords.x() == aStoredCoords[0] and aPoint2Coords.y() == aStoredCoords[1]
-
-#=========================================================================
-# Create line and set horizontal distance between line boundaries
-#=========================================================================
-aSession.startOperation()
-aLine = aSketchFeature.addFeature("SketchLine")
-aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
-aEndPoint = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
-aStartPoint.setValue(50., 0.)
-aEndPoint.setValue(100., 20.)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 7)
-
-DISTANCE3 = 50.
-aSession.startOperation()
-aHDist3 = aSketchFeature.addFeature("SketchConstraintDistanceHorizontal")
-aDistance = aHDist3.real("ConstraintValue")
-refattrA = aHDist3.refattr("ConstraintEntityA")
-refattrB = aHDist3.refattr("ConstraintEntityB")
-assert (not aDistance.isInitialized())
-assert (not refattrA.isInitialized())
-assert (not refattrB.isInitialized())
-refattrA.setAttr(aStartPoint)
-refattrB.setAttr(aEndPoint)
-aDistance.setValue(DISTANCE3)
-aSession.finishOperation()
-assert math.fabs(horizontalDistance(aStartPoint, aEndPoint) - DISTANCE3) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(aStartPoint, aEndPoint), DISTANCE3)
-assert (model.dof(aSketchFeature) == 6)
-#=========================================================================
-# Change a distance value
-#=========================================================================
-d = DISTANCE3
-dStep = -5.
-while d >= -50.:
-    aSession.startOperation()
-    DISTANCE3 = d
-    aDistance.setValue(DISTANCE3)
-    aSession.finishOperation()
-    assert math.fabs(horizontalDistance(aStartPoint, aEndPoint) - DISTANCE3) < 1.e-5, "Distance values are different: {0} != {1}".format(horizontalDistance(aStartPoint, aEndPoint), DISTANCE3)
-    d += dStep
-assert (model.dof(aSketchFeature) == 6)
-
-#=========================================================================
-# End of test
-#=========================================================================
-
-assert(model.checkPythonDump())
diff --git a/src/SketchPlugin/Test/TestConstraintDistanceVertical.py b/src/SketchPlugin/Test/TestConstraintDistanceVertical.py
deleted file mode 100644 (file)
index 8910edc..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    TestConstraintDistanceVertical.py
-    Unit test of SketchPlugin_ConstraintDistanceVertical class
-
-    SketchPlugin_ConstraintDistanceVertical
-        static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
-        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
-"""
-
-from GeomDataAPI import *
-from ModelAPI import *
-import math
-from salome.shaper import model
-
-#=========================================================================
-# Initialization of the test
-#=========================================================================
-
-__updated__ = "2017-05-10"
-
-
-def verticalDistance(point1, point2):
-    """
-    subroutine to calculate signed distance between two points
-    """
-    return point2.y() - point1.y()
-
-aSession = ModelAPI_Session.get()
-aDocument = aSession.moduleDocument()
-#=========================================================================
-# Creation of a sketch
-#=========================================================================
-aSession.startOperation()
-aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
-origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
-origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
-dirx.setValue(1, 0, 0)
-norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
-norm.setValue(0, 0, 1)
-aSession.finishOperation()
-#=========================================================================
-# Create two movable and one fixed point
-#=========================================================================
-aSession.startOperation()
-aPoint1 = aSketchFeature.addFeature("SketchPoint")
-aPoint1Coords = geomDataAPI_Point2D(aPoint1.attribute("PointCoordinates"))
-aPoint1Coords.setValue(50., 50.)
-aSession.finishOperation()
-aSession.startOperation()
-aPoint2 = aSketchFeature.addFeature("SketchPoint")
-aPoint2Coords = geomDataAPI_Point2D(aPoint2.attribute("PointCoordinates"))
-aPoint2Coords.setValue(70., 70.)
-aSession.finishOperation()
-aSession.startOperation()
-anOriginResult = modelAPI_Result(aDocument.objectByName("Construction", "Origin"))
-anOriginShape = anOriginResult.shape()
-anExtPoint = aSketchFeature.addFeature("SketchPoint")
-anExtCoords = geomDataAPI_Point2D(anExtPoint.attribute("PointCoordinates"))
-anExtCoords.setValue(0., 0.)
-anExtPoint.selection("External").setValue(anOriginResult, anOriginShape)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 4)
-
-#=========================================================================
-# Create a constraint to keep vertical distance between movable points
-#=========================================================================
-DISTANCE1 = 25.
-aSession.startOperation()
-aVDist1 = aSketchFeature.addFeature("SketchConstraintDistanceVertical")
-aDistance = aVDist1.real("ConstraintValue")
-refattrA = aVDist1.refattr("ConstraintEntityA")
-refattrB = aVDist1.refattr("ConstraintEntityB")
-assert (not aDistance.isInitialized())
-assert (not refattrA.isInitialized())
-assert (not refattrB.isInitialized())
-refattrA.setObject(aPoint1.lastResult())
-refattrB.setObject(aPoint2.lastResult())
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 3)
-# set flyout point then abort operation, after that check the Distance is correct
-aSession.startOperation()
-aFlyoutPoint = geomDataAPI_Point2D(aVDist1.attribute("ConstraintFlyoutValuePnt"))
-aFlyoutPoint.setValue(50.0, 100.0)
-aSession.abortOperation()
-assert (refattrA.isInitialized())
-assert (refattrB.isInitialized())
-assert (aDistance.isInitialized())
-aSession.startOperation()
-aDistance.setValue(DISTANCE1)
-aSession.finishOperation()
-assert math.fabs(verticalDistance(aPoint1Coords, aPoint2Coords) - DISTANCE1) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(aPoint1Coords, aPoint2Coords), DISTANCE1)
-assert (model.dof(aSketchFeature) == 3)
-#=========================================================================
-# Change a distance value
-#=========================================================================
-d = DISTANCE1 + 20.
-dStep = -5.
-while d >= -30.:
-    aSession.startOperation()
-    DISTANCE1 = d
-    aDistance.setValue(DISTANCE1)
-    aSession.finishOperation()
-    assert math.fabs(verticalDistance(aPoint1Coords, aPoint2Coords) - DISTANCE1) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(aPoint1Coords, aPoint2Coords), DISTANCE1)
-    d += dStep
-assert (model.dof(aSketchFeature) == 3)
-
-#=========================================================================
-# Create a constraint to keep vertical distance between fixed and movable points
-#=========================================================================
-DISTANCE2 = 50.
-aSession.startOperation()
-aVDist2 = aSketchFeature.addFeature("SketchConstraintDistanceVertical")
-aDistance = aVDist2.real("ConstraintValue")
-refattrA = aVDist2.refattr("ConstraintEntityA")
-refattrB = aVDist2.refattr("ConstraintEntityB")
-assert (not aDistance.isInitialized())
-assert (not refattrA.isInitialized())
-assert (not refattrB.isInitialized())
-refattrA.setObject(anExtPoint.lastResult())
-refattrB.setAttr(aPoint1Coords)
-aDistance.setValue(DISTANCE2)
-aSession.finishOperation()
-assert math.fabs(verticalDistance(anExtCoords, aPoint1Coords) - DISTANCE2) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(anExtCoords, aPoint1Coords), DISTANCE2)
-assert math.fabs(aPoint1Coords.y() - DISTANCE2) < 1.e-5, "Wrong point coordinates ({}, {}), expected y = {}".format(aPoint1Coords.x(), aPoint1Coords.y(), DISTANCE2)
-assert (model.dof(aSketchFeature) == 2)
-#=========================================================================
-# Change a distance value (check previous constraint is applied too)
-#=========================================================================
-d = DISTANCE2
-dStep = -5.
-while d >= -50.:
-    aSession.startOperation()
-    DISTANCE2 = d
-    aDistance.setValue(DISTANCE2)
-    aSession.finishOperation()
-    assert math.fabs(verticalDistance(anExtCoords, aPoint1Coords) - DISTANCE2) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(anExtCoords, aPoint1Coords), DISTANCE2)
-    assert math.fabs(aPoint1Coords.y() - DISTANCE2) < 1.e-5, "Wrong point coordinates ({}, {}), expected y = {}".format(aPoint1Coords.x(), aPoint1Coords.y(), DISTANCE2)
-    assert math.fabs(verticalDistance(aPoint1Coords, aPoint2Coords) - DISTANCE1) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(aPoint1Coords, aPoint2Coords), DISTANCE1)
-    d += dStep
-assert (model.dof(aSketchFeature) == 2)
-
-#=========================================================================
-# Remove first distance
-#=========================================================================
-aStoredCoords = [aPoint2Coords.x(), aPoint2Coords.y()]
-aSession.startOperation()
-aDocument.removeFeature(aVDist1)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 3)
-aSession.startOperation()
-DISTANCE2 = 20.
-aDistance.setValue(DISTANCE2)
-aSession.finishOperation()
-assert math.fabs(verticalDistance(anExtCoords, aPoint1Coords) - DISTANCE2) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(anExtCoords, aPoint1Coords), DISTANCE2)
-assert math.fabs(aPoint1Coords.y() - DISTANCE2) < 1.e-5, "Wrong point coordinates ({}, {}), expected y = {}".format(aPoint1Coords.x(), aPoint1Coords.y(), DISTANCE2)
-assert aPoint2Coords.x() == aStoredCoords[0] and aPoint2Coords.y() == aStoredCoords[1]
-
-#=========================================================================
-# Create line and set vertical distance between line boundaries
-#=========================================================================
-aSession.startOperation()
-aLine = aSketchFeature.addFeature("SketchLine")
-aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
-aEndPoint = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
-aStartPoint.setValue(50., 0.)
-aEndPoint.setValue(100., 20.)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 7)
-
-DISTANCE3 = 50.
-aSession.startOperation()
-aVDist3 = aSketchFeature.addFeature("SketchConstraintDistanceVertical")
-aDistance = aVDist3.real("ConstraintValue")
-refattrA = aVDist3.refattr("ConstraintEntityA")
-refattrB = aVDist3.refattr("ConstraintEntityB")
-assert (not aDistance.isInitialized())
-assert (not refattrA.isInitialized())
-assert (not refattrB.isInitialized())
-refattrA.setAttr(aStartPoint)
-refattrB.setAttr(aEndPoint)
-aDistance.setValue(DISTANCE3)
-aSession.finishOperation()
-assert math.fabs(verticalDistance(aStartPoint, aEndPoint) - DISTANCE3) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(aStartPoint, aEndPoint), DISTANCE3)
-assert (model.dof(aSketchFeature) == 6)
-#=========================================================================
-# Change a distance value
-#=========================================================================
-d = DISTANCE3
-dStep = -5.
-while d >= -50.:
-    aSession.startOperation()
-    DISTANCE3 = d
-    aDistance.setValue(DISTANCE3)
-    aSession.finishOperation()
-    assert math.fabs(verticalDistance(aStartPoint, aEndPoint) - DISTANCE3) < 1.e-5, "Distance values are different: {0} != {1}".format(verticalDistance(aStartPoint, aEndPoint), DISTANCE3)
-    d += dStep
-assert (model.dof(aSketchFeature) == 6)
-
-#=========================================================================
-# End of test
-#=========================================================================
-
-assert(model.checkPythonDump())
index db20680aa714465bfbadd81d379bedb5e9432668..8b67e708ceec64d8647e3d3cb513b72d49787dca 100644 (file)
@@ -169,141 +169,6 @@ assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLi
 assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
 assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
 assert (model.dof(aSketchFeature) == 6)
-
-#=========================================================================
-# Create circle, fix it and check the circle is not moved
-#=========================================================================
-aCenter = [10., 10.]
-aRadius = 5.
-aSession.startOperation()
-aCircle = aSketchFeature.addFeature("SketchCircle")
-aCircleCenter = geomDataAPI_Point2D(aCircle.attribute("circle_center"))
-aCircleRadius = aCircle.real("circle_radius")
-aCircleCenter.setValue(aCenter[0], aCenter[1])
-aCircleRadius.setValue(aRadius)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 9)
-# fixed constraints
-aSession.startOperation()
-aRigidConstraint = aSketchFeature.addFeature("SketchConstraintRigid")
-aRigidConstraint.refattr("ConstraintEntityA").setObject(aCircle.lastResult())
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 6)
-# move center of circle
-aSession.startOperation()
-aCircleCenter.setValue(aCenter[0] + 1., aCenter[1] - 1.)
-aSession.finishOperation()
-assert (aCircleCenter.x() == aCenter[0] and aCircleCenter.y() == aCenter[1])
-assert (aCircleRadius.value() == aRadius)
-assert (model.dof(aSketchFeature) == 6)
-# change radius of circle
-aSession.startOperation()
-aCircleRadius.setValue(aRadius + 3.)
-aSession.finishOperation()
-assert (aCircleCenter.x() == aCenter[0] and aCircleCenter.y() == aCenter[1])
-assert (aCircleRadius.value() == aRadius)
-assert (model.dof(aSketchFeature) == 6)
-
-#=========================================================================
-# Remove Fixed constraint and check the circle can be moved
-#=========================================================================
-aSession.startOperation()
-aDocument.removeFeature(aRigidConstraint)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 9)
-# move center of circle
-aCenter = [aCenter[0] + 1., aCenter[1] - 1.]
-aSession.startOperation()
-aCircleCenter.setValue(aCenter[0], aCenter[1])
-aSession.finishOperation()
-assert (aCircleCenter.x() == aCenter[0] and aCircleCenter.y() == aCenter[1])
-assert (aCircleRadius.value() == aRadius)
-assert (model.dof(aSketchFeature) == 9)
-# change radius of circle
-aRadius = aRadius + 3.
-aSession.startOperation()
-aCircleRadius.setValue(aRadius)
-aSession.finishOperation()
-assert (aCircleCenter.x() == aCenter[0] and aCircleCenter.y() == aCenter[1])
-assert (aCircleRadius.value() == aRadius)
-assert (model.dof(aSketchFeature) == 9)
-
-#=========================================================================
-# Create arc, fix it and check it is not moved
-#=========================================================================
-aCenter = [10., 10.]
-aStart = [5., 10.]
-aEnd = [10., 15.]
-aSession.startOperation()
-anArc = aSketchFeature.addFeature("SketchArc")
-anArcCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
-anArcStart = geomDataAPI_Point2D(anArc.attribute("start_point"))
-anArcEnd = geomDataAPI_Point2D(anArc.attribute("end_point"))
-anArcCenter.setValue(aCenter[0], aCenter[1])
-anArcStart.setValue(aStart[0], aStart[1])
-anArcEnd.setValue(aEnd[0], aEnd[1])
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 14)
-# fixed constraints
-aSession.startOperation()
-aRigidConstraint = aSketchFeature.addFeature("SketchConstraintRigid")
-aRigidConstraint.refattr("ConstraintEntityA").setObject(anArc.lastResult())
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 9)
-# move center of arc
-aSession.startOperation()
-anArcCenter.setValue(aCenter[0] + 1., aCenter[1] - 1.)
-aSession.finishOperation()
-assert (anArcCenter.x() == aCenter[0] and anArcCenter.y() == aCenter[1])
-assert (anArcStart.x() == aStart[0] and anArcStart.y() == aStart[1])
-assert (anArcEnd.x() == aEnd[0] and anArcEnd.y() == aEnd[1])
-assert (model.dof(aSketchFeature) == 9)
-# move start point of arc
-aSession.startOperation()
-anArcStart.setValue(aStart[0] + 1., aStart[1] - 1.)
-aSession.finishOperation()
-assert (anArcCenter.x() == aCenter[0] and anArcCenter.y() == aCenter[1])
-assert (anArcStart.x() == aStart[0] and anArcStart.y() == aStart[1])
-assert (anArcEnd.x() == aEnd[0] and anArcEnd.y() == aEnd[1])
-assert (model.dof(aSketchFeature) == 9)
-# move end point of arc
-aSession.startOperation()
-anArcEnd.setValue(aEnd[0] + 1., aEnd[1] - 1.)
-aSession.finishOperation()
-assert (anArcCenter.x() == aCenter[0] and anArcCenter.y() == aCenter[1])
-assert (anArcStart.x() == aStart[0] and anArcStart.y() == aStart[1])
-assert (anArcEnd.x() == aEnd[0] and anArcEnd.y() == aEnd[1])
-assert (model.dof(aSketchFeature) == 9)
-
-#=========================================================================
-# Remove Fixed constraint and check the arc can be moved
-#=========================================================================
-aSession.startOperation()
-aDocument.removeFeature(aRigidConstraint)
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 14)
-# move center of arc
-aCenter = [anArcCenter.x(), anArcCenter.y()]
-aSession.startOperation()
-anArcCenter.setValue(aCenter[0] + 1., aCenter[1] - 1.)
-aSession.finishOperation()
-assert (anArcCenter.x() != aCenter[0] or anArcCenter.y() != aCenter[1])
-assert (model.dof(aSketchFeature) == 14)
-# move start point of arc
-aStart = [anArcStart.x(), anArcStart.y()]
-aSession.startOperation()
-anArcStart.setValue(aStart[0] + 1., aStart[1] - 1.)
-aSession.finishOperation()
-assert (anArcStart.x() != aStart[0] or anArcStart.y() != aStart[1])
-assert (model.dof(aSketchFeature) == 14)
-# move end point of arc
-aEnd = [anArcEnd.x(), anArcEnd.y()]
-aSession.startOperation()
-anArcEnd.setValue(aEnd[0] + 1., aEnd[1] - 1.)
-aSession.finishOperation()
-assert (anArcEnd.x() != aEnd[0] or anArcEnd.y() != aEnd[1])
-assert (model.dof(aSketchFeature) == 14)
-
 #=========================================================================
 # End of test
 #=========================================================================
diff --git a/src/SketchPlugin/Test/TestConstraintHorizontalValidator.py b/src/SketchPlugin/Test/TestConstraintHorizontalValidator.py
deleted file mode 100644 (file)
index 103d7db..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    TestConstraintHorizontalValidator.py
-    It tests validation of horizontal and vertical segments in H and V constraints to avoid
-    selection segments that already have one of these constraint"
-"""
-
-#=========================================================================
-# of the test
-#=========================================================================
-from salome.shaper import model
-from ModelAPI import *
-import math
-#=========================================================================
-# Creation of a part
-#=========================================================================
-model.begin()
-partSet = model.moduleDocument()
-Part_1 = model.addPart(partSet)
-Part_1_doc = Part_1.document()
-#=========================================================================
-# Creation of a sketch
-#=========================================================================
-Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
-SketchLine_1 = Sketch_1.addLine(20, 20, 40, 80)
-SketchLine_2 = Sketch_1.addLine(40, 80, 60, 40)
-SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
-SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
-SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
-model.do()
-#=========================================================================
-# Checking that sketch and constraints become invalid when to one line
-# two horizontal/vertical constraints are applied in any combination
-#=========================================================================
-aFactory = ModelAPI_Session.get().validators()
-assert(aFactory.validate(Sketch_1.feature()))
-assert(Sketch_1.feature().error() != '')
-#=========================================================================
-# Remove duplicated Vertical constraints
-#=========================================================================
-Part_1_doc.removeFeature(SketchConstraintVertical_1.feature())
-assert(aFactory.validate(Sketch_1.feature()))
-model.do()
-#=========================================================================
-# Checking that after excess constraints are removed or undone,
-# sketch becomes valid.
-#=========================================================================
-assert(aFactory.validate(Sketch_1.feature()))
-assert(Sketch_1.feature().error() == '')
-
-assert(model.checkPythonDump())
index 3f3ac2e7ed9382800fe81551d4df974ab3b58e94..09649edfa275b2fc3fc652991af53ced7bc343b1 100644 (file)
@@ -40,6 +40,23 @@ from salome.shaper import model
 
 __updated__ = "2015-03-17"
 
+def distancePointLine(point, line):
+    """
+    subroutine to calculate distance between point and line
+    result of calculated distance is has 10**-5 precision
+    """
+    aStartPoint = geomDataAPI_Point2D(line.attribute("StartPoint"))
+    aEndPoint = geomDataAPI_Point2D(line.attribute("EndPoint"))
+    # orthogonal direction
+    aDirX = -(aEndPoint.y() - aStartPoint.y())
+    aDirY = (aEndPoint.x() - aStartPoint.x())
+    aLen = math.sqrt(aDirX**2 + aDirY**2)
+    aDirX = aDirX / aLen
+    aDirY = aDirY / aLen
+    aVecX = point.x() - aStartPoint.x()
+    aVecY = point.y() - aStartPoint.y()
+    return round(math.fabs(aVecX * aDirX + aVecY * aDirY), 5)
+
 def checkArcLineTangency(theArc, theLine):
     """
     subroutine to check that the line is tangent to arc/circle
@@ -51,7 +68,7 @@ def checkArcLineTangency(theArc, theLine):
         aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
         aStartPnt = geomDataAPI_Point2D(theArc.attribute("start_point"))
         aRadius = model.distancePointPoint(aStartPnt, aCenter)
-    aDist = model.distancePointLine(aCenter, theLine)
+    aDist = distancePointLine(aCenter, theLine)
     assert math.fabs(aDist - aRadius) < 2.e-5, "aDist = {0}, aRadius = {1}".format(aDist, aRadius)
 
 def checkArcArcTangency(theArc1, theArc2):
index 0e44647749bcb621f235025a4c94a29aa0ccf221..097e636b2a1177df781d1eb4dbdbb7abd2672b4f 100644 (file)
@@ -52,10 +52,22 @@ def verifyLastArc(theSketch, theCenter, theStart, theEnd):
     subroutine to verify position of last arc in the sketch
     """
     aLastArc = model.lastSubFeature(theSketch, "SketchArc")
-    model.assertArc(aLastArc, theCenter, theStart, theEnd)
+    aCenterPnt = geomDataAPI_Point2D(aLastArc.attribute("center_point"))
+    aStartPnt = geomDataAPI_Point2D(aLastArc.attribute("start_point"))
+    aEndPnt = geomDataAPI_Point2D(aLastArc.attribute("end_point"))
+    if len(theCenter):
+        verifyPointCoordinates(aCenterPnt, theCenter[0], theCenter[1])
+    if len(theStart):
+        verifyPointCoordinates(aStartPnt, theStart[0], theStart[1])
+    if len(theEnd):
+        verifyPointCoordinates(aEndPnt, theEnd[0], theEnd[1])
+    model.assertSketchArc(aLastArc)
+
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.id(), thePoint.x(), thePoint.y(), theX, theY)
 
 def verifyPointOnLine(thePoint, theLine):
-    aDistance = model.distancePointLine(thePoint, theLine)
+    aDistance = distancePointLine(thePoint, theLine)
     assert aDistance < TOLERANCE, "Point is not on Line, distance: {0}".format(aDistance)
 
 def verifyPointOnCircle(thePoint, theCircular):
@@ -70,6 +82,14 @@ def verifyPointOnCircle(thePoint, theCircular):
         return
     assert math.fabs(model.distancePointPoint(aCenterPoint, thePoint) - aRadius) < TOLERANCE
 
+def distancePointLine(thePoint, theLine):
+    aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy()
+    aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy()
+    aLineDir = aLineEnd.decreased(aLineStart)
+    aLineLen = aLineEnd.distance(aLineStart)
+    aPntDir = thePoint.pnt().xy().decreased(aLineStart)
+    return math.fabs(aPntDir.cross(aLineDir) / aLineLen)
+
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -223,7 +243,7 @@ aEndRef.setObject(aLine.lastResult())
 aEnd.setValue(aLineStart[0], aLineStart[1])
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 8), "Number of subs {}".format(aSketchFeature.numberOfSubs())
-model.assertPoint(aPointCoord, aPointCoordinates)
+verifyPointCoordinates(aPointCoord, aPointCoordinates[0], aPointCoordinates[1])
 verifyLastArc(aSketchFeature, [aPrevArcStart.x(), aPrevArcStart.y()], aPointCoordinates, [])
 model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 3)
 
@@ -259,8 +279,11 @@ aEnd.setValue(aLineEndPoint.pnt())
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 12), "Number of subs {}".format(aSketchFeature.numberOfSubs())
 # check connected features do not change their positions
-model.assertArc(aPrevArc, aPrevArcCenterXY, aPrevArcStartXY, aPrevArcEndXY)
-model.assertLine(aLine, aLineStart, aLineEnd)
+verifyPointCoordinates(aPrevArcCenter, aPrevArcCenterXY[0], aPrevArcCenterXY[1])
+verifyPointCoordinates(aPrevArcStart, aPrevArcStartXY[0], aPrevArcStartXY[1])
+verifyPointCoordinates(aPrevArcEnd, aPrevArcEndXY[0], aPrevArcEndXY[1])
+verifyPointCoordinates(aLineStartPoint, aLineStart[0], aLineStart[1])
+verifyPointCoordinates(aLineEndPoint, aLineEnd[0], aLineEnd[1])
 # verify newly created arc
 anArc = model.lastSubFeature(aSketchFeature, "SketchArc")
 aCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
index 448f9ea3d6fd4ff02638f749a47b0c0c21f73ab2..6f296a03d91c5d046a78265137e49f62bbc9d452 100644 (file)
@@ -52,7 +52,19 @@ def verifyLastArc(theSketch, theCenter, theStart, theEnd):
     subroutine to verify position of last arc in the sketch
     """
     aLastArc = model.lastSubFeature(theSketch, "SketchArc")
-    model.assertArc(aLastArc, theCenter, theStart, theEnd)
+    aCenterPnt = geomDataAPI_Point2D(aLastArc.attribute("center_point"))
+    aStartPnt = geomDataAPI_Point2D(aLastArc.attribute("start_point"))
+    aEndPnt = geomDataAPI_Point2D(aLastArc.attribute("end_point"))
+    if len(theCenter):
+        verifyPointCoordinates(aCenterPnt, theCenter[0], theCenter[1])
+    if len(theStart):
+        verifyPointCoordinates(aStartPnt, theStart[0], theStart[1])
+    if len(theEnd):
+        verifyPointCoordinates(aEndPnt, theEnd[0], theEnd[1])
+    model.assertSketchArc(aLastArc)
+
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.id(), thePoint.x(), thePoint.y(), theX, theY)
 
 def verifyTangent(theFeature1, theFeature2):
     anArcs = []
@@ -87,11 +99,19 @@ def verifyArcLineTangent(theArc, theLine):
     aStart  = geomDataAPI_Point2D(theArc.attribute("start_point"))
     aRadius = model.distancePointPoint(aStart, aCenter)
 
-    aDistCL = model.distancePointLine(aCenter, theLine)
+    aDistCL = distancePointLine(aCenter, theLine)
     assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Arc and line do not tangent"
 
+def distancePointLine(thePoint, theLine):
+    aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy()
+    aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy()
+    aLineDir = aLineEnd.decreased(aLineStart)
+    aLineLen = aLineEnd.distance(aLineStart)
+    aPntDir = thePoint.pnt().xy().decreased(aLineStart)
+    return math.fabs(aPntDir.cross(aLineDir) / aLineLen)
+
 def verifyPointOnLine(thePoint, theLine):
-    aDistance = model.distancePointLine(thePoint, theLine)
+    aDistance = distancePointLine(thePoint, theLine)
     assert aDistance < TOLERANCE, "Point is not on Line, distance: {0}".format(aDistance)
 
 
index f6240ab205e4a91bc8c30484dc08213dc40abcb5..0844028d99bce4045ce2a3fac6d98586f6bf7a64 100644 (file)
@@ -48,10 +48,13 @@ def verifyLastArc(theSketch, theX, theY, theR):
     """
     aLastArc = model.lastSubFeature(theSketch, "SketchArc")
     aCenter = geomDataAPI_Point2D(aLastArc.attribute("center_point"))
-    model.assertPoint(aCenter, [theX, theY])
+    verifyPointCoordinates(aCenter, theX, theY)
     aRadius = aLastArc.real("radius")
     assert aRadius.value() == theR, "Wrong radius {0}, expected {1}".format(aRadius.value(), theR)
 
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.attributeType(), thePoint.x(), thePoint.y(), theX, theY)
+
 def verifyPointOnArc(thePoint, theArc):
     aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
     aDistCP = model.distancePointPoint(aCenter, thePoint)
@@ -75,9 +78,17 @@ def verifyTangentCircular(theDistBetweenCenters, theRadius1, theRadius2):
 def verifyTangentArcLine(theArc, theLine):
     aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
     aRadius = theArc.real("radius").value()
-    aDistCL = model.distancePointLine(aCenter, theLine)
+    aDistCL = distancePointLine(aCenter, theLine)
     assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Circle and line are not tangent"
 
+def distancePointLine(thePoint, theLine):
+    aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy()
+    aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy()
+    aLineDir = aLineEnd.decreased(aLineStart)
+    aLineLen = aLineEnd.distance(aLineStart)
+    aPntDir = thePoint.pnt().xy().decreased(aLineStart)
+    return math.fabs(aPntDir.cross(aLineDir) / aLineLen)
+
 
 #=========================================================================
 # Start of test
@@ -167,9 +178,9 @@ anArcPnt3.setValue(aLineStart[0], aLineStart[1])
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 7)
 # check the points do not change their positions
-model.assertPoint(aPrevCenter, aPrevCenterXY)
-model.assertPoint(aPointCoord, aPointCoodinates)
-model.assertPoint(aStartPnt, aLineStart)
+verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
+verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
+verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
 # check newly created arc passes through the points
 anArc = model.lastSubFeature(aSketchFeature, "SketchArc")
 verifyPointOnArc(aPrevCenter, anArc)
@@ -198,9 +209,9 @@ anArcPnt3.setValue(20, 25)
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 9)
 # check the points do not change their positions
-model.assertPoint(aPrevCenter, aPrevCenterXY)
-model.assertPoint(aPointCoord, aPointCoodinates)
-model.assertPoint(aStartPnt, aLineStart)
+verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
+verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
+verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
 # check sub-features
 model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 3)
 model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 1)
index 851241a02a20a1cac14eceaade0c995cd3a1b65e..88ad0c60ed677acca958c6631e3f3f9dd2cb62a3 100644 (file)
@@ -88,7 +88,19 @@ def verifyLastArc(theSketch, theCenter, theStart, theEnd):
     subroutine to verify position of last arc in the sketch
     """
     aLastArc = model.lastSubFeature(theSketch, "SketchArc")
-    model.assertArc(aLastArc, theCenter, theStart, theEnd)
+    aCenterPnt = geomDataAPI_Point2D(aLastArc.attribute("center_point"))
+    aStartPnt = geomDataAPI_Point2D(aLastArc.attribute("start_point"))
+    aEndPnt = geomDataAPI_Point2D(aLastArc.attribute("end_point"))
+    if len(theCenter):
+        verifyPointCoordinates(aCenterPnt, theCenter[0], theCenter[1])
+    if len(theStart):
+        verifyPointCoordinates(aStartPnt, theStart[0], theStart[1])
+    if len(theEnd):
+        verifyPointCoordinates(aEndPnt, theEnd[0], theEnd[1])
+    model.assertSketchArc(aLastArc)
+
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.id(), thePoint.x(), thePoint.y(), theX, theY)
 
 
 #=========================================================================
index 6fbb6b34a77c87078acfee9dae969f3244fd27c6..9be701d66e20aa0a0eb53d957622e7f10a26cf36 100644 (file)
@@ -47,10 +47,16 @@ def verifyLastCircle(theSketch, theX, theY, theR):
     subroutine to verify position of last circle in the sketch
     """
     aLastCircle = model.lastSubFeature(theSketch, "SketchCircle")
-    model.assertCircle(aLastCircle, [theX, theY], theR)
+    aCenter = geomDataAPI_Point2D(aLastCircle.attribute("circle_center"))
+    verifyPointCoordinates(aCenter, theX, theY)
+    aRadius = aLastCircle.real("circle_radius")
+    assert aRadius.value() == theR, "Wrong radius {0}, expected {1}".format(aRadius.value(), theR)
+
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.id(), thePoint.x(), thePoint.y(), theX, theY)
 
 def verifyPointOnLine(thePoint, theLine):
-    aDistance = model.distancePointLine(thePoint, theLine)
+    aDistance = distancePointLine(thePoint, theLine)
     assert aDistance < TOLERANCE, "Point is not on Line, distance: {0}".format(aDistance)
 
 def verifyTangentCircles(theCircle1, theCircle2):
@@ -63,6 +69,14 @@ def verifyTangentCircles(theCircle1, theCircle2):
     aRDiff = math.fabs(aRadius1 - aRadius2)
     assert math.fabs(aRSum - aDistCC) < TOLERANCE or math.fabs(aRDiff - aDistCC) < TOLERANCE, "Circles do not tangent"
 
+def distancePointLine(thePoint, theLine):
+    aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy()
+    aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy()
+    aLineDir = aLineEnd.decreased(aLineStart)
+    aLineLen = aLineEnd.distance(aLineStart)
+    aPntDir = thePoint.pnt().xy().decreased(aLineStart)
+    return math.fabs(aPntDir.cross(aLineDir) / aLineLen)
+
 
 #=========================================================================
 # Start of test
@@ -168,7 +182,7 @@ aPassed.setValue(aPrevCenter.pnt())
 aRadius = model.distancePointPoint(aPrevCenter, aPointCoord)
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 6)
-model.assertPoint(aPointCoord, aPointCoordinates)
+verifyPointCoordinates(aPointCoord, aPointCoordinates[0], aPointCoordinates[1])
 verifyLastCircle(aSketchFeature, aPointCoord.x(), aPointCoord.y(), aRadius)
 model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 2)
 
@@ -209,13 +223,14 @@ aRadius = model.distancePointPoint(aCenter, aPassed)
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 10)
 # check connected features do not change their positions
-model.assertPoint(aPrevCenter, aPrevCenterXY)
+verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
 assert(aPrevCircle.real("circle_radius").value() == aPrevRadius)
-model.assertLine(aLine, aLineStart, aLineEnd)
+verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
+verifyPointCoordinates(aEndPnt, aLineEnd[0], aLineEnd[1])
 # verify newly created circle
 aCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 aCenter = geomDataAPI_Point2D(aCircle.attribute("circle_center"))
-model.assertPoint(aCenter, anExpectedCenter)
+verifyPointCoordinates(aCenter, anExpectedCenter[0], anExpectedCenter[1])
 verifyPointOnLine(aCenter, aLine)
 verifyTangentCircles(aCircle, aPrevCircle)
 model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 3)
index 558f2f86f86b6341bc7cea0043c38b14aff7884c..321e37ab9d87c0addd56d7a5d52bbec0d165fcc7 100644 (file)
@@ -47,7 +47,13 @@ def verifyLastCircle(theSketch, theX, theY, theR):
     subroutine to verify position of last circle in the sketch
     """
     aLastCircle = model.lastSubFeature(theSketch, "SketchCircle")
-    model.assertCircle(aLastCircle, [theX, theY], theR)
+    aCenter = geomDataAPI_Point2D(aLastCircle.attribute("circle_center"))
+    verifyPointCoordinates(aCenter, theX, theY)
+    aRadius = aLastCircle.real("circle_radius")
+    assert aRadius.value() == theR, "Wrong radius {0}, expected {1}".format(aRadius.value(), theR)
+
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.attributeType(), thePoint.x(), thePoint.y(), theX, theY)
 
 def verifyPointOnCircle(thePoint, theCircle):
     aCircleCenter = geomDataAPI_Point2D(theCircle.attribute("circle_center"))
@@ -80,9 +86,17 @@ def verifyTangentCircular(theDistBetweenCenters, theRadius1, theRadius2):
 def verifyTangentCircleLine(theCircle, theLine):
     aCenter = geomDataAPI_Point2D(theCircle.attribute("circle_center"))
     aRadius = theCircle.real("circle_radius").value()
-    aDistCL = model.distancePointLine(aCenter, theLine)
+    aDistCL = distancePointLine(aCenter, theLine)
     assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Circle and line are not tangent"
 
+def distancePointLine(thePoint, theLine):
+    aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy()
+    aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy()
+    aLineDir = aLineEnd.decreased(aLineStart)
+    aLineLen = aLineEnd.distance(aLineStart)
+    aPntDir = thePoint.pnt().xy().decreased(aLineStart)
+    return math.fabs(aPntDir.cross(aLineDir) / aLineLen)
+
 
 #=========================================================================
 # Start of test
@@ -172,9 +186,9 @@ aCirclePnt3.setValue(aLineStart[0], aLineStart[1])
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 7)
 # check the points do not change their positions
-model.assertPoint(aPrevCenter, aPrevCenterXY)
-model.assertPoint(aPointCoord, aPointCoordinates)
-model.assertPoint(aStartPnt, aLineStart)
+verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
+verifyPointCoordinates(aPointCoord, aPointCoordinates[0], aPointCoordinates[1])
+verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
 # check newly created circle passes through the points
 aCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 verifyPointOnCircle(aPrevCenter, aCircle)
@@ -221,10 +235,13 @@ aCirclePnt3.setValue(anArcCenter[0] + anArcRadius, anArcCenter[1])
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 12)
 # check the tangent entities do not change their positions
-model.assertPoint(aPrevCenter, aPrevCenterXY)
+verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
 assert (aPrevCircle.real("circle_radius").value() == aPrevCircleRadius)
-model.assertLine(aLine, aLineStart, aLineEnd)
-model.assertArc(anArc, anArcCenter, anArcStart, anArcEnd)
+verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
+verifyPointCoordinates(aEndPnt, aLineEnd[0], aLineEnd[1])
+verifyPointCoordinates(anArcCenterPnt, anArcCenter[0], anArcCenter[1])
+verifyPointCoordinates(anArcStartPnt, anArcStart[0], anArcStart[1])
+verifyPointCoordinates(anArcEndPnt, anArcEnd[0], anArcEnd[1])
 # check newly created circle passes through the points
 aCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 verifyTangentCircles(aCircle, aPrevCircle)
index 5a4677d6794175b9a49bd397b480294373a6a332..882e686d8989b2f5c30f2a90f94d568b5a7ccab9 100644 (file)
@@ -72,7 +72,13 @@ def verifyLastCircle(theSketch, theX, theY, theR):
     subroutine to verify position of last circle in the sketch
     """
     aLastCircle = model.lastSubFeature(theSketch, "SketchCircle")
-    model.assertCircle(aLastCircle, [theX, theY], theR)
+    aCenter = geomDataAPI_Point2D(aLastCircle.attribute("circle_center"))
+    verifyPointCoordinates(aCenter, theX, theY)
+    aRadius = aLastCircle.real("circle_radius")
+    assert aRadius.value() == theR, "Wrong radius {0}, expected {1}".format(aRadius.value(), theR)
+
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.attributeType(), thePoint.x(), thePoint.y(), theX, theY)
 
 
 #=========================================================================
index a8b1f08b3a1ea82e8c37d56ee83d81b1c6a495fd..3e0f6617c32a345dbab7473f233034f2b715df63 100644 (file)
@@ -125,7 +125,7 @@ def checkSmoothness(theSketch):
 
 def checkArcLineSmoothness(theArc, theLine):
     aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
-    aDistance = model.distancePointLine(aCenter, theLine)
+    aDistance = distancePointLine(aCenter, theLine)
     aRadius = arcRadius(theArc)
     assert(math.fabs(aRadius - aDistance) < TOLERANCE)
 
@@ -162,6 +162,16 @@ def arcRadius(theArc):
     aStart = geomDataAPI_Point2D(theArc.attribute("start_point"))
     return model.distancePointPoint(aCenter, aStart)
 
+def distancePointLine(thePoint, theLine):
+    aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint"))
+    aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint"))
+    aLength = model.distancePointPoint(aLineStart, aLineEnd)
+
+    aDir1x, aDir1y = aLineEnd.x() - aLineStart.x(), aLineEnd.y() - aLineStart.y()
+    aDir2x, aDir2y = thePoint.x() - aLineStart.x(), thePoint.y() - aLineStart.y()
+    aCross = aDir1x * aDir2y - aDir1y * aDir2x
+    return math.fabs(aCross) / aLength
+
 
 #=========================================================================
 # Initialization of the test
index 60783ed527bff4b6f0af2ba9c270341a679160df..04160ace6312d62e5c7a2d6c9a121c93fa864b94 100644 (file)
@@ -35,7 +35,7 @@ __updated__ = "2017-03-06"
 
 def isArcLineSmooth(theArc, theLine, theTolerance):
   aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
-  aDistance = model.distancePointLine(aCenter, theLine)
+  aDistance = distancePointLine(aCenter, theLine)
   aRadius = arcRadius(theArc)
   return math.fabs(aRadius - aDistance) < theTolerance
 
@@ -54,6 +54,15 @@ def arcRadius(theArc):
   aStart = geomDataAPI_Point2D(theArc.attribute("start_point"))
   return model.distancePointPoint(aCenter, aStart)
 
+def distancePointLine(thePoint, theLine):
+  aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint"))
+  aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint"))
+  aLength = model.distancePointPoint(aLineStart, aLineEnd)
+  aDir1x, aDir1y = aLineEnd.x() - aLineStart.x(), aLineEnd.y() - aLineStart.y()
+  aDir2x, aDir2y = thePoint.x() - aLineStart.x(), thePoint.y() - aLineStart.y()
+  aCross = aDir1x * aDir2y - aDir1y * aDir2x
+  return math.fabs(aCross) / aLength
+
 
 
 class TestFilletInteracting(unittest.TestCase):
diff --git a/src/SketchPlugin/Test/TestMoveArc.py b/src/SketchPlugin/Test/TestMoveArc.py
deleted file mode 100644 (file)
index 4419d85..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    Test movement of the sketch arc of circle
-"""
-
-import unittest
-from GeomDataAPI import geomDataAPI_Point2D
-from salome.shaper import model
-
-__updated__ = "2017-05-11"
-
-class TestMoveArc(unittest.TestCase):
-  def setUp(self):
-    model.begin()
-    self.myDocument = model.moduleDocument()
-    self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
-    self.myCenter = [50., 50.]
-    self.myStart = [70., 50.]
-    self.myEnd = [50., 70.]
-    self.myArc = self.mySketch.addArc(self.myCenter[0], self.myCenter[1], self.myStart[0], self.myStart[1], self.myEnd[0], self.myEnd[1], False)
-    self.myDOF = 5
-    model.do()
-    self.checkDOF()
-
-  def tearDown(self):
-    model.assertArcValidity(self.myArc)
-    self.checkDOF()
-    model.end()
-    assert(model.checkPythonDump())
-
-  def checkDOF(self):
-    self.assertEqual(model.dof(self.mySketch), self.myDOF)
-
-  def checkPointCoordinates(self, thePoint, theCoordinates):
-    self.assertAlmostEqual(thePoint.x(), theCoordinates[0])
-    self.assertAlmostEqual(thePoint.y(), theCoordinates[1])
-
-  def checkPointOnArc(self, theCoordinates):
-    distPC = model.distancePointPoint(self.myArc.center(),  theCoordinates)
-    radius = model.distancePointPoint(self.myArc.center(), self.myArc.startPoint())
-    self.assertAlmostEqual(distPC, radius)
-
-  def checkArcRadius(self):
-    radius = model.distancePointPoint(self.myArc.center(), self.myArc.startPoint())
-    self.assertAlmostEqual(radius, self.myRadius)
-
-  def fixArcRadius(self):
-    self.myRadius = 20.
-    self.mySketch.setRadius(self.myArc.results()[1], self.myRadius)
-    self.myDOF -= 1
-    model.do()
-    self.checkDOF()
-
-  def fixPoint(self, thePoint):
-    self.mySketch.setFixed(thePoint)
-    self.myDOF -= 2
-    model.do()
-    self.checkDOF()
-
-  def fixArc(self):
-    self.mySketch.setFixed(self.myArc.results()[1])
-    self.myDOF -= 5
-    model.do()
-    self.checkDOF()
-
-
-  def test_move_center_of_free_arc(self):
-    """ Test 1. Movement of center of a free arc
-    """
-    newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
-    self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), newPosition)
-
-  def test_move_start_of_free_arc(self):
-    """ Test 2. Movement of start point of a free arc
-    """
-    newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
-    self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), newPosition)
-
-  def test_move_end_of_free_arc(self):
-    """ Test 3. Movement of end point of a free arc
-    """
-    newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
-    self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.endPoint(), newPosition)
-
-  def test_move_free_arc(self):
-    """ Test 4. Movement of a free arc dragging the edge
-    """
-    newPosition = [100., 80.]
-    self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointOnArc(newPosition)
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-
-  def test_move_center_of_arc_fixed_center(self):
-    """ Test 5. Movement of center of the arc with fixed center (nothing should be changed)
-    """
-    self.fixPoint(self.myArc.center())
-
-    newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
-    self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-
-  def test_move_start_of_arc_fixed_center(self):
-    """ Test 6. Movement of start point of the arc with fixed center
-    """
-    self.fixPoint(self.myArc.center())
-
-    newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
-    self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), newPosition)
-
-  def test_move_end_of_arc_fixed_center(self):
-    """ Test 7. Movement of end point of the arc with fixed center
-    """
-    self.fixPoint(self.myArc.center())
-
-    newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
-    self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.endPoint(), newPosition)
-
-  def test_move_arc_fixed_center(self):
-    """ Test 8. Movement of the arc with fixed center dragging the edge
-    """
-    self.fixPoint(self.myArc.center())
-
-    newPosition = [100., 80.]
-    self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointOnArc(newPosition)
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-
-  def test_move_center_of_arc_fixed_start(self):
-    """ Test 9. Movement of center of the arc with fixed start point
-    """
-    self.fixPoint(self.myArc.startPoint())
-
-    newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
-    self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), newPosition)
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-
-  def test_move_start_of_arc_fixed_start(self):
-    """ Test 10. Movement of start point of the arc with fixed start point (nothing should be changed)
-    """
-    self.fixPoint(self.myArc.startPoint())
-
-    newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
-    self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-
-  def test_move_end_of_arc_fixed_start(self):
-    """ Test 11. Movement of end point of the arc with fixed start point
-    """
-    self.fixPoint(self.myArc.startPoint())
-
-    newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
-    self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
-    self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
-
-  def test_move_arc_fixed_start(self):
-    """ Test 12. Movement of the arc with fixed start point dragging the edge
-    """
-    self.fixPoint(self.myArc.startPoint())
-
-    newPosition = [100., 80.]
-    self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
-    self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
-
-  def test_move_center_of_arc_fixed_end(self):
-    """ Test 13. Movement of center of the arc with fixed end point
-    """
-    self.fixPoint(self.myArc.endPoint())
-
-    newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
-    self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), newPosition)
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-
-  def test_move_start_of_arc_fixed_end(self):
-    """ Test 14. Movement of start point of the arc with fixed end point
-    """
-    self.fixPoint(self.myArc.endPoint())
-
-    newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
-    self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-    self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
-    self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
-
-  def test_move_end_of_arc_fixed_end(self):
-    """ Test 15. Movement of end point of the arc with fixed end point (nothing should be changed)
-    """
-    self.fixPoint(self.myArc.endPoint())
-
-    newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
-    self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-
-  def test_move_arc_fixed_end(self):
-    """ Test 16. Movement of the arc with fixed end point dragging the edge
-    """
-    self.fixPoint(self.myArc.endPoint())
-
-    newPosition = [100., 80.]
-    self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-    self.assertNotEqual(self.myArc.center().x(), self.myCenter[0])
-    self.assertNotEqual(self.myArc.center().y(), self.myCenter[1])
-
-  def test_move_center_of_arc_fixed_radius(self):
-    """ Test 17. Movement of center of the arc with fixed radius
-    """
-    self.fixArcRadius()
-
-    newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
-    self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), newPosition)
-    self.checkArcRadius()
-
-  def test_move_start_of_arc_fixed_radius(self):
-    """ Test 18. Movement of start point of the arc with fixed radius
-    """
-    self.fixArcRadius()
-
-    newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
-    self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkArcRadius()
-
-  def test_move_end_of_arc_fixed_radius(self):
-    """ Test 19. Movement of end point of the arc with fixed radius
-    """
-    self.fixArcRadius()
-
-    newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
-    self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkArcRadius()
-
-  def test_move_arc_fixed_radius(self):
-    """ Test 20. Movement of the arc with fixed radius dragging the edge
-    """
-    self.fixArcRadius()
-
-    newPosition = [100., 80.]
-    self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkArcRadius()
-
-  def test_move_center_of_fixed_arc(self):
-    """ Test 21. Movement of center of fully fixed arc (nothing should be changed)
-    """
-    self.fixArc()
-
-    newPosition = [self.myCenter[0] + 10., self.myCenter[1] - 15.]
-    self.mySketch.move(self.myArc.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-
-  def test_move_start_of_fixed_arc(self):
-    """ Test 22. Movement of start point of fully fixed arc (nothing should be changed)
-    """
-    self.fixArc()
-
-    newPosition = [self.myStart[0] - 10., self.myStart[1] + 5.]
-    self.mySketch.move(self.myArc.startPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-
-  def test_move_end_of_fixed_arc(self):
-    """ Test 23. Movement of end point of fully fixed arc (nothing should be changed)
-    """
-    self.fixArc()
-
-    newPosition = [self.myEnd[0] + 10., self.myEnd[1] + 5.]
-    self.mySketch.move(self.myArc.endPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-
-  def test_move_fixed_arc(self):
-    """ Test 24. Movement of fully fixed arc (nothing should be changed)
-    """
-    self.fixArc()
-
-    newPosition = [100., 80.]
-    self.mySketch.move(self.myArc.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myArc.center(), self.myCenter)
-    self.checkPointCoordinates(self.myArc.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myArc.endPoint(), self.myEnd)
-
-
-if __name__ == '__main__':
-  unittest.main()
diff --git a/src/SketchPlugin/Test/TestMoveCircle.py b/src/SketchPlugin/Test/TestMoveCircle.py
deleted file mode 100644 (file)
index 54a9b58..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    Test movement of the sketch circle
-"""
-
-import unittest
-from GeomDataAPI import geomDataAPI_Point2D
-from salome.shaper import model
-
-__updated__ = "2017-05-11"
-
-class TestMoveCircle(unittest.TestCase):
-  def setUp(self):
-    model.begin()
-    self.myDocument = model.moduleDocument()
-    self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
-    self.myCenter = [70., 50.]
-    self.myRadius = 20.
-    self.myCircle = self.mySketch.addCircle(self.myCenter[0], self.myCenter[1], self.myRadius)
-    self.myDOF = 3
-    model.do()
-    self.checkDOF()
-
-  def tearDown(self):
-    self.checkDOF()
-    model.end()
-    assert(model.checkPythonDump())
-
-  def checkDOF(self):
-    self.assertEqual(model.dof(self.mySketch), self.myDOF)
-
-  def checkPointCoordinates(self, thePoint, theCoordinates):
-    self.assertAlmostEqual(thePoint.x(), theCoordinates[0])
-    self.assertAlmostEqual(thePoint.y(), theCoordinates[1])
-
-  def checkPointOnCircle(self, theCoordinates):
-    self.assertAlmostEqual(model.distancePointPoint(self.myCircle.center(),  theCoordinates), self.myCircle.radius().value())
-
-  def fixCircleRadius(self):
-    self.mySketch.setRadius(self.myCircle.results()[1], self.myRadius)
-    self.myDOF -= 1
-    model.do()
-    self.checkDOF()
-
-  def fixCircleCenter(self):
-    self.mySketch.setFixed(self.myCircle.center())
-    self.myDOF -= 2
-    model.do()
-    self.checkDOF()
-
-
-  def test_move_center_free_circle(self):
-    """ Test 1. Movement of central point of a free circle
-    """
-    newPosition = [self.myCenter[0] + 20., self.myCenter[1] + 10.]
-    self.mySketch.move(self.myCircle.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myCircle.center(), newPosition)
-    self.assertAlmostEqual(self.myCircle.radius().value(), self.myRadius)
-
-  def test_move_free_circle(self):
-    """ Test 2. Movement of a free circle dragging the edge
-    """
-    newPosition = [120., 90.]
-    self.mySketch.move(self.myCircle.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myCircle.center(), self.myCenter)
-    self.checkPointOnCircle(newPosition)
-    self.assertNotEqual(self.myCircle.radius().value(), self.myRadius)
-
-  def test_move_center_circle_fixed_radius(self):
-    """ Test 3. Movement of central point of a circle with fixed radius
-    """
-    self.fixCircleRadius()
-
-    newPosition = [self.myCenter[0] + 20., self.myCenter[1] + 10.]
-    self.mySketch.move(self.myCircle.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myCircle.center(), newPosition)
-    self.assertAlmostEqual(self.myCircle.radius().value(), self.myRadius)
-
-  def test_move_circle_fixed_radius(self):
-    """ Test 4. Movement of a circle with fixed radius
-    """
-    self.fixCircleRadius()
-
-    newPosition = [120., 90.]
-    self.mySketch.move(self.myCircle.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.assertAlmostEqual(self.myCircle.radius().value(), self.myRadius)
-    self.assertNotEqual(self.myCircle.center().x(), self.myCenter[0])
-    self.assertNotEqual(self.myCircle.center().y(), self.myCenter[1])
-
-  def test_move_center_circle_fixed_center(self):
-    """ Test 5. Movement of central point of a circle with fixed center (nothing should be changed)
-    """
-    self.fixCircleCenter()
-
-    newPosition = [self.myCenter[0] + 20., self.myCenter[1] + 10.]
-    self.mySketch.move(self.myCircle.center(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myCircle.center(), self.myCenter)
-    self.assertAlmostEqual(self.myCircle.radius().value(), self.myRadius)
-
-  def test_move_circle_fixed_center(self):
-    """ Test 6. Movement of a circle with fixed center
-    """
-    self.fixCircleCenter()
-
-    newPosition = [120., 90.]
-    self.mySketch.move(self.myCircle.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointOnCircle(newPosition)
-    self.assertNotEqual(self.myCircle.radius().value(), self.myRadius)
-
-  def test_move_fixed_circle(self):
-    """ Test 7. Trying to move fully fixed circle
-    """
-    self.fixCircleCenter()
-    self.fixCircleRadius()
-
-    newPosition = [120., 90.]
-    self.mySketch.move(self.myCircle.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myCircle.center(), self.myCenter)
-    self.assertAlmostEqual(self.myCircle.radius().value(), self.myRadius)
-
-
-if __name__ == '__main__':
-  unittest.main()
diff --git a/src/SketchPlugin/Test/TestMoveLine.py b/src/SketchPlugin/Test/TestMoveLine.py
deleted file mode 100644 (file)
index 3d4efa1..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    Test movement of the sketch line
-"""
-
-import unittest
-from GeomDataAPI import geomDataAPI_Point2D
-from salome.shaper import model
-
-__updated__ = "2017-05-11"
-
-class TestMoveLine(unittest.TestCase):
-  def setUp(self):
-    model.begin()
-    self.myDocument = model.moduleDocument()
-    self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
-    self.myStart = [70., 50.]
-    self.myEnd = [100., 20.]
-    self.myLine = self.mySketch.addLine(self.myStart[0], self.myStart[1], self.myEnd[0], self.myEnd[1])
-    self.myDOF = 4
-    model.do()
-    self.checkDOF()
-
-  def tearDown(self):
-    self.checkDOF()
-    model.end()
-    assert(model.checkPythonDump())
-
-  def checkDOF(self):
-    self.assertEqual(model.dof(self.mySketch), self.myDOF)
-
-  def checkPointCoordinates(self, thePoint, theCoordinates):
-    self.assertAlmostEqual(thePoint.x(), theCoordinates[0])
-    self.assertAlmostEqual(thePoint.y(), theCoordinates[1])
-
-  def checkPointOnLine(self, theCoordinates):
-    self.assertAlmostEqual(model.distancePointLine(theCoordinates, self.myLine), 0.)
-
-  def test_move_start_of_free_line(self):
-    """ Test 1. Movement of start point of a free line
-    """
-    newPosition = [self.myStart[0] + 20., self.myStart[1] + 10.]
-    self.mySketch.move(self.myLine.startPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myLine.startPoint(), newPosition)
-    self.checkPointCoordinates(self.myLine.endPoint(), self.myEnd)
-
-  def test_move_end_of_free_line(self):
-    """ Test 2. Movement of end point of a free line
-    """
-    newPosition = [self.myEnd[0] + 20., self.myEnd[1] + 10.]
-    self.mySketch.move(self.myLine.endPoint(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myLine.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myLine.endPoint(), newPosition)
-
-  def test_move_free_line(self):
-    """ Test 3. Movement of free line
-    """
-    diff = [self.myEnd[0] - self.myStart[0], self.myEnd[1] - self.myStart[1]]
-
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myLine.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointOnLine(newPosition)
-
-    # additionally check the line keeps geometry (relative positions of extremities)
-    startPoint = self.myLine.startPoint()
-    endPoint = [startPoint.x() + diff[0], startPoint.y() + diff[1]]
-    self.checkPointCoordinates(self.myLine.endPoint(), endPoint)
-
-  def test_move_line_start_fixed(self):
-    """ Test 4. Movement of a line, which start point is fixed
-    """
-    fixed = self.mySketch.setFixed(self.myLine.startPoint())
-    self.myDOF -= 2
-    model.do()
-    self.checkDOF()
-
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myLine.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myLine.startPoint(), self.myStart)
-    self.assertNotEqual(self.myLine.endPoint().x(), self.myEnd[0])
-    self.assertNotEqual(self.myLine.endPoint().y(), self.myEnd[1])
-
-  def test_move_line_end_fixed(self):
-    """ Test 5. Movement of a line, which end point is fixed
-    """
-    fixed = self.mySketch.setFixed(self.myLine.endPoint())
-    self.myDOF -= 2
-    model.do()
-    self.checkDOF()
-
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myLine.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.assertNotEqual(self.myLine.startPoint().x(), self.myStart[0])
-    self.assertNotEqual(self.myLine.startPoint().y(), self.myStart[1])
-    self.checkPointCoordinates(self.myLine.endPoint(), self.myEnd)
-
-  def test_move_line_fully_fixed(self):
-    """ Test 6. Movement of fully fixed line (should not change its coordinates)
-    """
-    fixed = self.mySketch.setFixed(self.myLine.defaultResult())
-    self.myDOF -= 4
-    model.do()
-
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myLine.defaultResult(), newPosition[0], newPosition[1])
-    model.do()
-    self.checkPointCoordinates(self.myLine.startPoint(), self.myStart)
-    self.checkPointCoordinates(self.myLine.endPoint(), self.myEnd)
-
-
-if __name__ == '__main__':
-  unittest.main()
diff --git a/src/SketchPlugin/Test/TestMovePoint.py b/src/SketchPlugin/Test/TestMovePoint.py
deleted file mode 100644 (file)
index 60b0a43..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    Test movement of the sketch point
-"""
-
-import unittest
-from GeomDataAPI import geomDataAPI_Point2D
-from salome.shaper import model
-
-__updated__ = "2017-05-11"
-
-class TestMovePoint(unittest.TestCase):
-  def setUp(self):
-    model.begin()
-    self.myDocument = model.moduleDocument()
-    self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
-    self.myOrigin = self.mySketch.addPoint(model.selection("VERTEX", "Origin"))
-    self.myPoint = self.mySketch.addPoint(70, 50)
-    self.myPointCoordinates = geomDataAPI_Point2D(self.myPoint.coordinates())
-    self.myDOF = 2
-    model.do()
-    self.checkDOF()
-
-  def tearDown(self):
-    self.checkDOF()
-    model.end()
-    assert(model.checkPythonDump())
-
-  def checkDOF(self):
-    self.assertEqual(model.dof(self.mySketch), self.myDOF)
-
-  def test_move_free_point(self):
-    """ Test 1. Movement of free point
-    """
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
-    model.do()
-    self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
-    self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
-
-  def test_move_fixed_x(self):
-    """ Test 2. Movement of partially fixed point (fixed x coordinate)
-    """
-    DISTANCE = 50.
-    horizDistance = self.mySketch.setHorizontalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
-    self.myDOF -= 1
-    model.do()
-    self.checkDOF()
-
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
-    model.do()
-    self.assertAlmostEqual(self.myPointCoordinates.x(), DISTANCE)
-    self.assertAlmostEqual(self.myPointCoordinates.y(), newPosition[1])
-
-  def test_move_fixed_y(self):
-    """ Test 3. Movement of partially fixed point (fixed y coordinate)
-    """
-    DISTANCE = 50.
-    vertDistance = self.mySketch.setVerticalDistance(self.myOrigin.result(), self.myPoint.coordinates(), DISTANCE)
-    self.myDOF -= 1
-    model.do()
-    self.checkDOF()
-
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
-    model.do()
-    self.assertAlmostEqual(self.myPointCoordinates.x(), newPosition[0])
-    self.assertAlmostEqual(self.myPointCoordinates.y(), DISTANCE)
-
-  def test_move_fully_fixed(self):
-    """ Test 4. Movement of fully fixed point (should not be changed)
-    """
-    coord = [self.myPointCoordinates.x(), self.myPointCoordinates.y()]
-
-    fixed = self.mySketch.setFixed(self.myPoint.result())
-    self.myDOF -= 2
-    model.do()
-    self.checkDOF()
-
-    newPosition = [100., 100.]
-    self.mySketch.move(self.myPoint, newPosition[0], newPosition[1])
-    model.do()
-    self.assertAlmostEqual(self.myPointCoordinates.x(), coord[0])
-    self.assertAlmostEqual(self.myPointCoordinates.y(), coord[1])
-
-
-if __name__ == '__main__':
-  unittest.main()
diff --git a/src/SketchPlugin/Test/TestMovementComplex.py b/src/SketchPlugin/Test/TestMovementComplex.py
deleted file mode 100644 (file)
index 6fe6afe..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-## Copyright (C) 2017  CEA/DEN, EDF R&D
-##
-## 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, 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
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
-
-"""
-    Test moving the entities in the complex sketch by the example of a clamp
-"""
-
-from salome.shaper import model
-from SketchAPI import *
-from GeomAPI import *
-import math
-
-TOLERANCE = 1.e-7
-
-model.begin()
-partSet = model.moduleDocument()
-Part_1 = model.addPart(partSet)
-Part_1_doc = Part_1.document()
-
-# Create sketch representing main part of clamp
-Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
-SketchLine_1 = Sketch_1.addLine(20, 165, 175, 165)
-SketchLine_2 = Sketch_1.addLine(175, 165, 175, 120)
-SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
-SketchLine_3 = Sketch_1.addLine(175, 120, 80, 20)
-SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
-SketchLine_4 = Sketch_1.addLine(80, 20, 20, 20)
-SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
-SketchLine_5 = Sketch_1.addLine(20, 20, 20, 165)
-SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
-SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
-SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 155)
-SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
-SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_2.result(), SketchLine_1.result())
-SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_4.result())
-SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result())
-SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 45)
-SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_4.startPoint(), SketchLine_1.result(), 145)
-SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_4.startPoint(), SketchLine_3.startPoint(), 95)
-SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
-SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchPoint_1.coordinates(), SketchLine_5.endPoint(), 20)
-SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchPoint_1.coordinates(), SketchLine_5.endPoint(), 165)
-model.do()
-
-# =============================================================================
-# Test 1. Create fillet and move fillet arc
-# =============================================================================
-Sketch_1.setFillet(SketchLine_5.startPoint())
-SketchArc_1 = SketchAPI_Arc(model.lastSubFeature(Sketch_1, "SketchArc"))
-model.do()
-anArcCenter = [SketchArc_1.center().x(), SketchArc_1.center().y()]
-anArcStart  = [SketchArc_1.startPoint().x(), SketchArc_1.startPoint().y()]
-anArcEnd    = [SketchArc_1.endPoint().x(), SketchArc_1.endPoint().y()]
-# move arc dragging center
-delta = [1., 1.]
-for i in range(1, 10):
-    anArcCenter = [anArcCenter[0] + delta[0], anArcCenter[1] + delta[1]]
-    Sketch_1.move(SketchArc_1.center(), anArcCenter[0], anArcCenter[1])
-    model.do()
-    model.assertArcValidity(SketchArc_1)
-    model.assertPoint(SketchArc_1.center(), anArcCenter)
-    assert(SketchArc_1.startPoint().x() == anArcStart[0])
-    assert(SketchArc_1.endPoint().y() == anArcEnd[1])
-    if i == 5:
-        delta = [-1., -1.]
-# move arc dragging start point
-delta = [1., 1.]
-aPosition = anArcStart
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchArc_1.startPoint(), aPosition[0], aPosition[1])
-    model.do()
-    model.assertArcValidity(SketchArc_1)
-    assert(SketchArc_1.startPoint().x() == anArcStart[0])
-    assert(SketchArc_1.endPoint().y() == anArcEnd[1])
-    if i == 5:
-        delta = [-1., -1.]
-# move arc dragging end point
-delta = [1., 1.]
-aPosition = anArcEnd
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchArc_1.endPoint(), aPosition[0], aPosition[1])
-    model.do()
-    model.assertArcValidity(SketchArc_1)
-    assert(SketchArc_1.startPoint().x() == anArcStart[0])
-    assert(SketchArc_1.endPoint().y() == anArcEnd[1])
-    if i == 5:
-        delta = [-1., -1.]
-
-# =============================================================================
-# Test 2. Create circle and move it near its potential position
-# =============================================================================
-aCircleCenter = [0, 0]
-aCircleRadius = 5
-SketchCircle_1 = Sketch_1.addCircle(aCircleCenter[0], aCircleCenter[1], aCircleRadius)
-model.do()
-# move center
-delta = [3., 2.]
-for i in range(1, 15):
-    aCircleCenter = [aCircleCenter[0] + delta[0], aCircleCenter[1] + delta[1]]
-    Sketch_1.move(SketchCircle_1.center(), aCircleCenter[0], aCircleCenter[1])
-    model.do()
-    model.assertPoint(SketchCircle_1.center(), aCircleCenter)
-    assert(SketchCircle_1.radius().value() == aCircleRadius)
-# move circle by dragging edge
-aPosition = [aCircleCenter[0] + aCircleRadius, aCircleCenter[1]]
-delta = [1., 1.]
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchCircle_1.defaultResult(), aPosition[0], aPosition[1])
-    model.do()
-    model.assertPoint(SketchCircle_1.center(), aCircleCenter)
-    assert(math.fabs(SketchCircle_1.radius().value() - model.distancePointPoint(aPosition, aCircleCenter)) < TOLERANCE)
-
-# =============================================================================
-# Test 3. Constrain center of circle and move it again
-# =============================================================================
-SketchConstraintDistanceHorizontal_3 = Sketch_1.setHorizontalDistance(SketchCircle_1.center(), SketchArc_1.startPoint(), -30)
-model.do()
-# move center
-delta = [1., 1.]
-aCircleCenter = [SketchCircle_1.center().x(), SketchCircle_1.center().y()]
-aPosition = aCircleCenter
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchCircle_1.center(), aPosition[0], aPosition[1])
-    model.do()
-    assert(SketchCircle_1.center().x() == aCircleCenter[0])
-    if i == 5:
-        delta = [-1., -1.]
-# move circle by dragging edge
-aCircleCenter = [SketchCircle_1.center().x(), SketchCircle_1.center().y()]
-aPosition = [aCircleCenter[0] + aCircleRadius, aCircleCenter[1]]
-delta = [1., 1.]
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchCircle_1.defaultResult(), aPosition[0], aPosition[1])
-    model.do()
-    model.assertPoint(SketchCircle_1.center(), aCircleCenter)
-    assert(math.fabs(SketchCircle_1.radius().value() - model.distancePointPoint(aPosition, aCircleCenter)) < TOLERANCE)
-# set radius of the circle
-aCircleRadius = 17.5
-SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], aCircleRadius)
-model.do()
-# move center
-delta = [1., 1.]
-aCircleCenter = [SketchCircle_1.center().x(), SketchCircle_1.center().y()]
-aPosition = aCircleCenter
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchCircle_1.center(), aPosition[0], aPosition[1])
-    model.do()
-    assert(SketchCircle_1.center().x() == aCircleCenter[0])
-    assert(SketchCircle_1.radius().value() == aCircleRadius)
-    if i == 5:
-        delta = [-1., -1.]
-# move circle by dragging edge
-aCircleCenter = [SketchCircle_1.center().x(), SketchCircle_1.center().y()]
-aPosition = [aCircleCenter[0] + aCircleRadius, aCircleCenter[1]]
-delta = [1., 1.]
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchCircle_1.defaultResult(), aPosition[0], aPosition[1])
-    model.do()
-    assert(SketchCircle_1.center().x() == aCircleCenter[0])
-    assert(SketchCircle_1.radius().value() == aCircleRadius)
-
-# =============================================================================
-# Test 4. Set centers of circle and arc coincident and move circle
-# =============================================================================
-SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchArc_1.center())
-model.do()
-assert(model.dof(Sketch_1) == 0)
-# move circle
-aCircleCenter = [SketchCircle_1.center().x(), SketchCircle_1.center().y()]
-aPosition = [aCircleCenter[0], aCircleCenter[1] + aCircleRadius]
-delta = [0., 1.]
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchCircle_1.defaultResult(), aPosition[0], aPosition[1])
-    model.do()
-    model.assertPoint(SketchCircle_1.center(), aCircleCenter)
-    assert(SketchCircle_1.radius().value() == aCircleRadius)
-assert(model.dof(Sketch_1) == 0)
-
-# Extrude main part of clamp
-Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchArc_1_2f-SketchCircle_1_2r")], model.selection(), 10, 0)
-model.do()
-
-
-# Create sketch representing orthogonal part of clamp
-Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
-SketchRectangle_1 = Sketch_2.addRectangle(20, 0, 100, 50)
-[SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9] = SketchRectangle_1.lines()
-SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"))
-SketchLine_10 = SketchProjection_1.createdFeature()
-SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_7).startPoint(), SketchAPI_Line(SketchLine_10).startPoint())
-SketchConstraintEqual_1 = Sketch_2.setEqual(SketchLine_8.result(), SketchLine_10.result())
-SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_7.result(), 80)
-model.do()
-assert(model.dof(Sketch_2) == 0)
-
-# Create auxiliary lines for further holes
-SketchLine_11 = Sketch_2.addLine(20, 10, 175, 10)
-SketchLine_11.setAuxiliary(True)
-SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_11.startPoint(), SketchLine_7.result())
-SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_9.result())
-SketchConstraintParallel_2 = Sketch_2.setParallel(SketchLine_11.result(), SketchLine_8.result())
-SketchLine_12 = Sketch_2.addLine(150, 0, 150, 80)
-SketchLine_12.setAuxiliary(True)
-SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_12.startPoint(), SketchLine_6.result())
-SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchLine_8.result())
-SketchConstraintPerpendicular_2 = Sketch_2.setPerpendicular(SketchLine_11.result(), SketchLine_12.result())
-model.do()
-assert(model.dof(Sketch_2) == 2)
-
-# =============================================================================
-# Test 5. Create circular hole and move it
-# =============================================================================
-SketchCircle_2 = Sketch_2.addCircle(50, 10, 10)
-SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchLine_11.result())
-model.do()
-# move center
-delta = [2., 1.]
-aCircleCenter = [SketchCircle_2.center().x(), SketchCircle_2.center().y()]
-aCircleRadius = SketchCircle_2.radius().value()
-for i in range(1, 10):
-    aCircleCenter = [aCircleCenter[0] + delta[0], aCircleCenter[1] + delta[1]]
-    Sketch_2.move(SketchCircle_2.center(), aCircleCenter[0], aCircleCenter[1])
-    model.do()
-    model.assertPoint(SketchCircle_2.center(), aCircleCenter)
-    assert(aCircleRadius == SketchCircle_2.radius().value())
-# move circle by dragging edge
-aCircleCenter = [SketchCircle_2.center().x(), SketchCircle_2.center().y()]
-aPosition = [aCircleCenter[0] + aCircleRadius, aCircleCenter[1]]
-delta = [0., 1.]
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_1.move(SketchCircle_2.defaultResult(), aPosition[0], aPosition[1])
-    model.do()
-    model.assertPoint(SketchCircle_2.center(), aCircleCenter)
-    assert(math.fabs(SketchCircle_2.radius().value() - model.distancePointPoint(aPosition, aCircleCenter)) < TOLERANCE)
-
-SketchConstraintDistanceHorizontal_4 = Sketch_2.setHorizontalDistance(SketchLine_11.startPoint(), SketchCircle_2.center(), 21.5)
-model.do()
-assert(model.dof(Sketch_2) == 3)
-
-# =============================================================================
-# Test 6. Create oval hole and move it
-# =============================================================================
-anArcRadius = 5
-anArcCenter = [SketchLine_11.endPoint().x() + anArcRadius, SketchCircle_2.center().y()]
-SketchArc_2 = Sketch_2.addArc(anArcCenter[0], anArcCenter[1], anArcCenter[0], anArcCenter[1] + anArcRadius, anArcCenter[0], anArcCenter[1] - anArcRadius, True)
-SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchArc_2.center(), SketchLine_11.result())
-SketchLine_13 = Sketch_2.addLine(anArcCenter[0], anArcCenter[1] + anArcRadius, SketchLine_12.startPoint().x(), anArcCenter[1] + anArcRadius)
-SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchArc_2.startPoint(), SketchLine_13.startPoint())
-SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_12.result())
-SketchConstraintPerpendicular_3 = Sketch_2.setPerpendicular(SketchLine_13.result(), SketchLine_12.result())
-SketchLine_14 = Sketch_2.addLine(anArcCenter[0], anArcCenter[1] - anArcRadius, SketchLine_12.startPoint().x(), anArcCenter[1] - anArcRadius)
-SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_14.startPoint())
-SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_12.result())
-SketchConstraintPerpendicular_4 = Sketch_2.setPerpendicular(SketchLine_14.result(), SketchLine_12.result())
-SketchConstraintTangent_1 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_13.result())
-SketchConstraintTangent_2 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_14.result())
-model.do()
-assert(model.dof(Sketch_2) == 5)
-# move center of arc
-delta = [-2., 1.]
-anArcCenter = [SketchArc_2.center().x(), SketchArc_2.center().y()]
-for i in range(1, 10):
-    anArcCenter = [anArcCenter[0] + delta[0], anArcCenter[1] + delta[1]]
-    Sketch_2.move(SketchArc_2.center(), anArcCenter[0], anArcCenter[1])
-    model.do()
-    model.assertArc(SketchArc_2, anArcCenter, [], [])
-
-# Complete the oval hole
-SketchConstraintMirror_1_objects = [SketchLine_13.result(), SketchArc_2.results()[1], SketchLine_14.result()]
-SketchConstraintMirror_1 = Sketch_2.addMirror(SketchLine_12.result(), SketchConstraintMirror_1_objects)
-[SketchLine_15, SketchArc_3, SketchLine_16] = SketchConstraintMirror_1.mirrored()
-model.do()
-
-# =============================================================================
-# Test 7. Set arc and circle equal radii and move arc
-# =============================================================================
-SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_2.results()[1], SketchArc_2.results()[1])
-model.do()
-# move center of arc
-delta = [-1., -1.]
-anArcCenter = [SketchArc_2.center().x(), SketchArc_2.center().y()]
-aCircleCenter = [SketchCircle_2.center().x(), SketchCircle_2.center().y()]
-for i in range(1, 10):
-    anArcCenter = [anArcCenter[0] + delta[0], anArcCenter[1] + delta[1]]
-    Sketch_2.move(SketchArc_2.center(), anArcCenter[0], anArcCenter[1])
-    model.do()
-    model.assertArc(SketchArc_2, anArcCenter, [], [])
-    model.assertPoint(SketchCircle_2.center(), [aCircleCenter[0], anArcCenter[1]])
-    anArcRadius = model.distancePointPoint(SketchArc_2.center(), SketchArc_2.startPoint())
-    assert(math.fabs(SketchCircle_2.radius().value() - anArcRadius) < TOLERANCE)
-# move arc by dragging edge
-aCircleCenter = [SketchCircle_2.center().x(), SketchCircle_2.center().y()]
-anArcCenter = [SketchArc_2.center().x(), SketchArc_2.center().y()]
-aPosition = [anArcCenter[0] + anArcRadius, anArcCenter[1]]
-delta = [1., 1.]
-for i in range(1, 10):
-    aPosition = [aPosition[0] + delta[0], aPosition[1] + delta[1]]
-    Sketch_2.move(SketchArc_2.defaultResult(), aPosition[0], aPosition[1])
-    model.do()
-    model.assertArc(SketchArc_2, anArcCenter, [], [])
-    model.assertPoint(SketchCircle_2.center(), aCircleCenter)
-    anArcRadius = model.distancePointPoint(SketchArc_2.center(), SketchArc_2.startPoint())
-    assert(math.fabs(SketchCircle_2.radius().value() - anArcRadius) < TOLERANCE)
-    if i == 5:
-        delta = [-1., -1.]
-
-# Fix all DOF in Sketch_2
-SketchConstraintDistance_2 = Sketch_2.setDistance(SketchArc_2.center(), SketchLine_9.result(), 21.5)
-SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_13.result(), 3.5)
-SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], 6.5)
-SketchConstraintDistance_3 = Sketch_2.setDistance(SketchCircle_2.center(), SketchLine_8.result(), 30)
-model.do()
-
-Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchCircle_2_2r-SketchArc_2_2r-SketchLine_13r-SketchLine_14f-SketchLine_15f-SketchArc_3_2r-SketchLine_16r")], model.selection(), -165, 155)
-Boolean_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")])
-
-Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Boolean_1_1/Modified_8"))
-SketchLine_17 = Sketch_3.addLine(145, 0, 165, 0)
-SketchPoint_2 = Sketch_3.addPoint(model.selection("VERTEX", "Boolean_1_1/Modified_7&Boolean_1_1/Modified_6&Boolean_1_1/Modified_2"))
-SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchPoint_2.result())
-SketchLine_18 = Sketch_3.addLine(165, 0, 165, -20)
-SketchLine_19 = Sketch_3.addLine(165, -20, 145, -20)
-SketchLine_20 = Sketch_3.addLine(145, -20, 145, 0)
-SketchConstraintCoincidence_24 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_17.startPoint())
-SketchConstraintCoincidence_25 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint())
-SketchConstraintCoincidence_26 = Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
-SketchConstraintCoincidence_27 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchLine_20.startPoint())
-SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_17.result())
-SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_18.result())
-SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_19.result())
-SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_20.result())
-SketchArc_4 = Sketch_3.addArc(145, -20, 165, -20, 145, 0, False)
-SketchConstraintCoincidence_28 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchArc_4.center())
-SketchConstraintCoincidence_29 = Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchArc_4.startPoint())
-SketchConstraintCoincidence_30 = Sketch_3.setCoincident(SketchArc_4.endPoint(), SketchLine_20.endPoint())
-SketchConstraintRadius_3 = Sketch_3.setRadius(SketchArc_4.results()[1], 20)
-SketchArc_5 = Sketch_3.addArc(145, -20, 155, -20, 145, -10, False)
-SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchArc_5.center())
-SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchLine_20.result(), SketchArc_5.endPoint())
-SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchArc_5.startPoint(), SketchLine_19.result())
-SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "Boolean_1_1/Modified_12&Boolean_1_1/Modified_11"))
-SketchConstraintTangent_5 = Sketch_3.setTangent(SketchArc_5.results()[1], SketchLine_21.result())
-model.do()
-
-ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_17r-SketchLine_18r-SketchArc_4_2r")], model.selection(), model.selection("FACE", "Boolean_1_1/Modified_5"), 0, model.selection(), 0, [model.selection("SOLID", "Boolean_1_1")])
-ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_19r-SketchLine_20r-SketchArc_4_2f-SketchArc_5_2r")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_7"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
-model.do()
-
-model.end()
-
-model.testNbResults(ExtrusionFuse_1, 1)
-model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.SOLID, [1])
-model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.FACE, [30])
-model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.EDGE, [140])
-model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.VERTEX, [280])
-model.testResultsVolumes(ExtrusionFuse_1, [260653.824775497108930721879005432])
-
-assert(model.checkPythonDump())
diff --git a/src/SketchPlugin/icons/distance_h.png b/src/SketchPlugin/icons/distance_h.png
deleted file mode 100644 (file)
index b88db21..0000000
Binary files a/src/SketchPlugin/icons/distance_h.png and /dev/null differ
diff --git a/src/SketchPlugin/icons/distance_v.png b/src/SketchPlugin/icons/distance_v.png
deleted file mode 100644 (file)
index 027a384..0000000
Binary files a/src/SketchPlugin/icons/distance_v.png and /dev/null differ
diff --git a/src/SketchPlugin/icons/ellipse.png b/src/SketchPlugin/icons/ellipse.png
deleted file mode 100644 (file)
index 6f31163..0000000
Binary files a/src/SketchPlugin/icons/ellipse.png and /dev/null differ
index b6c74bff67806359fc7bfdcc74a36c4eb29c5af6..d5b54374a8d3cf23466780e3e88683a88812ca6c 100644 (file)
@@ -28,7 +28,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                 SketchCircle SketchMacroCircle SketchArc SketchMacroArc
                 SketchRectangle
                 SketchProjection
-                SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintDistanceHorizontal SketchConstraintDistanceVertical
+                SketchConstraintLength SketchConstraintRadius SketchConstraintDistance
                 SketchConstraintParallel SketchConstraintPerpendicular
                 SketchConstraintRigid SketchConstraintHorizontal SketchConstraintVertical
                 SketchConstraintEqual SketchConstraintTangent
@@ -359,97 +359,6 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
       </feature>
     </group>
 
-<excluded>
-    <group id="Elliptic geometry">
-      <!-- SketchEllipse is a hidden feature. It is created inside SketchMacroEllipse. -->
-      <feature id="SketchEllipse"
-               title="Ellipse"
-               tooltip="Create ellipse"
-               icon="icons/Sketch/ellipse.png"
-               internal="1">
-        <sketch-2dpoint_selector id="ellipse_center"
-                                 title="Center"
-                                 tooltip="Center coordinates"
-                                 accept_expressions="0"
-                                 enable_value="enable_by_preferences"/>
-        <sketch-2dpoint_selector id="ellipse_focus"
-                                 title="Focus"
-                                 tooltip="Focus coordinates"
-                                 accept_expressions="0"
-                                 enable_value="enable_by_preferences"/>
-        <labelvalue id="ellipse_major_radius"
-                    icon="icons/Sketch/radius.png"
-                    label="Major radius:"
-                    tooltip="Set major radius"
-                    default="computed"
-                    accept_expressions="0"
-                    enable_value="enable_by_preferences">
-        </labelvalue>
-        <labelvalue id="ellipse_minor_radius"
-                    icon="icons/Sketch/radius.png"
-                    label="Minor radius:"
-                    tooltip="Set minor radius"
-                    default="computed"
-                    accept_expressions="0"
-                    enable_value="enable_by_preferences">
-        </labelvalue>
-        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
-      </feature>
-      <!-- SketchMacroEllipse -->
-      <feature id="SketchMacroEllipse"
-               icon="icons/Sketch/ellipse.png"
-               title="Ellipse"
-               tooltip="Create ellipse">
-        <sketch-2dpoint_selector id="center_point"
-                                 reference_attribute="center_point_ref"
-                                 title="Center point"
-                                 tooltip="Center point coordinates"
-                                 accept_expressions="0"
-                                 enable_value="enable_by_preferences"/>
-        <sketch-2dpoint_selector id="major_axis_point"
-                                 reference_attribute="major_axis_point_ref"
-                                 title="Major axis point"
-                                 tooltip="Major axis point coordinates"
-                                 accept_expressions="0"
-                                 enable_value="enable_by_preferences"/>
-        <sketch-2dpoint_selector id="passed_point"
-                                 reference_attribute="passed_point_ref"
-                                 title="Passed point"
-                                 tooltip="Passed point coordinates"
-                                 accept_expressions="0"
-                                 enable_value="enable_by_preferences">
-<!--          <validator id="SketchPlugin_CirclePassedPointValidator"/> -->
-        </sketch-2dpoint_selector>
-<!--        <validator id="GeomValidators_Different" parameters="center_point_ref,passed_point_ref"/> -->
-        <labelvalue id="ellipse_major_radius"
-                    icon="icons/Sketch/radius.png"
-                    label="Major radius:"
-                    tooltip="Set major radius"
-                    default="computed"
-                    accept_expressions="0"
-                    obligatory="0"
-                    enable_value="enable_by_preferences">
-          <validator id="GeomValidators_Positive"/>
-        </labelvalue>
-        <labelvalue id="ellipse_minor_radius"
-                    icon="icons/Sketch/radius.png"
-                    label="Minor radius:"
-                    tooltip="Set minor radius"
-                    default="computed"
-                    accept_expressions="0"
-                    obligatory="0"
-                    enable_value="enable_by_preferences">
-          <validator id="GeomValidators_Positive"/>
-        </labelvalue>
-        <boolvalue id="Auxiliary"
-                   tooltip="Construction element"
-                   label="Auxiliary"
-                   default="false"
-                   obligatory="0"/>
-      </feature>
-    </group>
-</excluded>
-
     <group id="Projection">
       <!-- Intersection Point -->
       <!-- feature
@@ -656,71 +565,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         <validator id="PartSet_DistanceSelection"/>
       </feature>
 
-      <!--  SketchConstraintDistanceHorizontal  -->
-      <feature
-        id="SketchConstraintDistanceHorizontal"
-        title="Horizontal Distance"
-        tooltip="Set horizontal distance between two points"
-        icon="icons/Sketch/distance_h.png">
-        <label title="Select points for distance definition."/>
-        <sketch_shape_selector
-              id="ConstraintEntityA"
-              label="First point"
-              tooltip="Select point."
-              shape_types="vertex">
-          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
-          <validator id="PartSet_DifferentObjects"/>
-          <validator id="GeomValidators_ShapeType" parameters="vertex"/>
-        </sketch_shape_selector>
-        <sketch_shape_selector
-          id="ConstraintEntityB"
-          label="Second point"
-          tooltip="Select point."
-          shape_types="vertex">
-          <validator id="PartSet_DifferentObjects"/>
-          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
-          <validator id="GeomValidators_ShapeType" parameters="vertex"/>
-        </sketch_shape_selector>
-        <sketch-2dpoint_flyout_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
-
-        <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed"/>
-
-        <validator id="PartSet_DistanceSelection"/>
-      </feature>
-
-      <!--  SketchConstraintDistanceVertical  -->
-      <feature
-        id="SketchConstraintDistanceVertical"
-        title="Vertical Distance"
-        tooltip="Set vertical distance between two points"
-        icon="icons/Sketch/distance_v.png">
-        <label title="Select points for distance definition."/>
-        <sketch_shape_selector
-              id="ConstraintEntityA"
-              label="First point"
-              tooltip="Select point."
-              shape_types="vertex">
-          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
-          <validator id="PartSet_DifferentObjects"/>
-          <validator id="GeomValidators_ShapeType" parameters="vertex"/>
-        </sketch_shape_selector>
-        <sketch_shape_selector
-          id="ConstraintEntityB"
-          label="Second point"
-          tooltip="Select point."
-          shape_types="vertex">
-          <validator id="PartSet_DifferentObjects"/>
-          <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
-          <validator id="GeomValidators_ShapeType" parameters="vertex"/>
-        </sketch_shape_selector>
-        <sketch-2dpoint_flyout_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
-
-        <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed"/>
-
-        <validator id="PartSet_DistanceSelection"/>
-      </feature>
-
-      <!--  SketchConstraintLength  -->
+    <!--  SketchConstraintLength  -->
       <feature id="SketchConstraintLength" title="Length" tooltip="Set fixed length of a line segment" icon="icons/Sketch/length.png">
         <label title="Select a line on which to calculate length" tooltip="Select a line on which to calculate length"/>
         <shape_selector id="ConstraintEntityA" label="Line" tooltip="Select a line" shape_types="edge" >
@@ -782,7 +627,6 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         <sketch_shape_selector id="ConstraintEntityA"
             label="Line" tooltip="Select a line" shape_types="edge" use_external="false">
           <validator id="GeomValidators_ShapeType" parameters="line"/>
-          <validator id="SketchPlugin_HasNoConstraint" parameters="SketchConstraintHorizontal, SketchConstraintVertical"/>
         </sketch_shape_selector>
         <validator id="PartSet_HVDirSelection"/>
       </feature>
@@ -792,7 +636,6 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         <sketch_shape_selector id="ConstraintEntityA"
             label="Line" tooltip="Select a line" shape_types="edge" use_external="false">
           <validator id="GeomValidators_ShapeType" parameters="line"/>
-          <validator id="SketchPlugin_HasNoConstraint" parameters="SketchConstraintHorizontal, SketchConstraintVertical"/>
         </sketch_shape_selector>
         <validator id="PartSet_HVDirSelection"/>
       </feature>
index 5dab71a4f86d93d4dd22b49ce7b8e601995e3f04..50c4fab20984fd6f7618c88917ae74472182d5a7 100644 (file)
@@ -55,7 +55,6 @@ SET(SKETCHSOLVER_CONSTRAINT_HEADERS
     SketchSolver_ConstraintMulti.h
     SketchSolver_ConstraintMultiRotation.h
     SketchSolver_ConstraintMultiTranslation.h
-    SketchSolver_ConstraintMovement.h
 )
 
 SET(SKETCHSOLVER_SOURCES
@@ -79,7 +78,6 @@ SET(SKETCHSOLVER_CONSTRAINT_SOURCES
     SketchSolver_ConstraintMulti.cpp
     SketchSolver_ConstraintMultiRotation.cpp
     SketchSolver_ConstraintMultiTranslation.cpp
-    SketchSolver_ConstraintMovement.cpp
 )
 
 SET(SKETCHSOLVER_LIBRARIES
index 0f31d2e2c7de02d706d70b2bd5273a063c2a7a36..981769fc20bb5bd31023c78f741738b0769a2124 100644 (file)
@@ -40,7 +40,6 @@ typedef int ConstraintID;
 // Predefined values for identifiers
 const ConstraintID CID_UNKNOWN  =  0;
 const ConstraintID CID_MOVEMENT = -1;
-const ConstraintID CID_FICTIVE = 1024;
 
 /// Types of entities
 enum SketchSolver_EntityType {
@@ -64,8 +63,6 @@ enum SketchSolver_ConstraintType {
   CONSTRAINT_DISTANCE,         // base distance if we don't know the measured objects yet
   CONSTRAINT_PT_PT_DISTANCE,
   CONSTRAINT_PT_LINE_DISTANCE,
-  CONSTRAINT_HORIZONTAL_DISTANCE,
-  CONSTRAINT_VERTICAL_DISTANCE,
   CONSTRAINT_RADIUS,
   CONSTRAINT_ANGLE,
   CONSTRAINT_FIXED,
index 9c4cad57d2a7488cc3fba558c3f5ab04b63cbd6a..38b60f7fef31009e8b4725e8c251fb53af5c7466 100644 (file)
@@ -27,8 +27,7 @@ PlaneGCSSolver_Solver::PlaneGCSSolver_Solver()
     myDiagnoseBeforeSolve(false),
     myInitilized(false),
     myConfCollected(false),
-    myDOF(0),
-    myFictiveConstraint(0)
+    myDOF(0)
 {
 }
 
@@ -44,8 +43,6 @@ void PlaneGCSSolver_Solver::clear()
   myConstraints.clear();
   myConflictingIDs.clear();
   myDOF = 0;
-
-  removeFictiveConstraint();
 }
 
 void PlaneGCSSolver_Solver::addConstraint(GCSConstraintPtr theConstraint)
@@ -112,7 +109,6 @@ void PlaneGCSSolver_Solver::removeParameters(const GCS::SET_pD& theParams)
 void PlaneGCSSolver_Solver::initialize()
 {
   Events_LongOp::start(this);
-  addFictiveConstraintIfNecessary();
   if (myDiagnoseBeforeSolve)
     diagnose();
   myEquationSystem->declareUnknowns(myParameters);
@@ -138,8 +134,6 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve()
   if (myInitilized) {
     aResult = (GCS::SolveStatus)myEquationSystem->solve();
   } else {
-    addFictiveConstraintIfNecessary();
-
     if (myDiagnoseBeforeSolve)
       diagnose();
     aResult = (GCS::SolveStatus)myEquationSystem->solve(myParameters);
@@ -163,7 +157,6 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve()
     aStatus = STATUS_OK;
   }
 
-  removeFictiveConstraint();
   myInitilized = false;
   return aStatus;
 }
@@ -205,34 +198,3 @@ void PlaneGCSSolver_Solver::diagnose()
   myDOF = myEquationSystem->diagnose();
   myDiagnoseBeforeSolve = false;
 }
-
-void PlaneGCSSolver_Solver::addFictiveConstraintIfNecessary()
-{
-  if (!myConstraints.empty() &&
-      myConstraints.find(CID_MOVEMENT) == myConstraints.end())
-    return;
-
-  if (myFictiveConstraint)
-    return; // no need several fictive constraints
-
-  double* aParam = createParameter();
-  double* aFictiveParameter = new double(0.0);
-
-  myFictiveConstraint = new GCS::ConstraintEqual(aFictiveParameter, aParam);
-  myFictiveConstraint->setTag(CID_FICTIVE);
-  myEquationSystem->addConstraint(myFictiveConstraint);
-}
-
-void PlaneGCSSolver_Solver::removeFictiveConstraint()
-{
-  if (myFictiveConstraint) {
-    myEquationSystem->removeConstraint(myFictiveConstraint);
-    myParameters.pop_back();
-
-    GCS::VEC_pD aParams = myFictiveConstraint->params();
-    for (GCS::VEC_pD::iterator anIt = aParams.begin(); anIt != aParams.end(); ++ anIt)
-      delete *anIt;
-    delete myFictiveConstraint;
-    myFictiveConstraint = 0;
-  }
-}
index 572f2df25ecce3fd5dd38b47e2d6a401c9ebc45f..2e49798a1c90b052a563a735d35c8cfe921f57f1 100644 (file)
@@ -81,11 +81,6 @@ public:
 private:
   void collectConflicting();
 
-  /// \brief Add fictive constraint if the sketch contains temporary constraints only
-  void addFictiveConstraintIfNecessary();
-  /// \brief Remove previously added fictive constraint
-  void removeFictiveConstraint();
-
 private:
   typedef std::map<ConstraintID, std::set<GCSConstraintPtr> > ConstraintMap;
 
@@ -101,8 +96,6 @@ private:
   bool                         myConfCollected;
 
   int                          myDOF;            ///< degrees of freedom
-
-  GCS::Constraint*             myFictiveConstraint;
 };
 
 typedef std::shared_ptr<PlaneGCSSolver_Solver> SolverPtr;
index 16122052155c527b9c72a2177db06753c79a556c..56567d292dfbb4a444b6c7c2f3d0349a3cdeafc0 100644 (file)
@@ -66,9 +66,12 @@ void PlaneGCSSolver_Storage::addConstraint(
   constraintsToSolver(theSolverConstraint, mySketchSolver);
 }
 
-void PlaneGCSSolver_Storage::addMovementConstraint(
+void PlaneGCSSolver_Storage::addTemporaryConstraint(
     const ConstraintWrapperPtr& theSolverConstraint)
 {
+  if (myConstraintMap.empty())
+    return; // no need to process temporary constraints if there is no active constraint
+
   // before adding movement constraint to solver, re-check its DOF
   if (mySketchSolver->dof() == 0)
     mySketchSolver->diagnose();
index 48526b9c734cd83d524f8b790a35c0a981061680..28eaed091781ecfedfcb86e64ba02d9827b82c8d 100644 (file)
@@ -44,10 +44,10 @@ public:
   virtual void addConstraint(ConstraintPtr        theConstraint,
                              ConstraintWrapperPtr theSolverConstraint);
 
-  /// \brief Add a movement constraint which will be destroyed
+  /// \brief Add list of temporary constraints which will be destroyed
   ///        after the next solving of the set of constraints.
   /// \param theSolverConstraint [in]  solver's constraint
-  virtual void addMovementConstraint(const ConstraintWrapperPtr& theSolverConstraint);
+  virtual void addTemporaryConstraint(const ConstraintWrapperPtr& theSolverConstraint);
 
 
   /// \brief Convert feature to the form applicable for specific solver and map it
index a4e461ada6afe7a04c830f84d2eedcdf19a214eb..51460d9af8bf662181de4d1825cb2c8a7b6acee3 100644 (file)
@@ -42,8 +42,6 @@
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintCollinear.h>
 #include <SketchPlugin_ConstraintDistance.h>
-#include <SketchPlugin_ConstraintDistanceHorizontal.h>
-#include <SketchPlugin_ConstraintDistanceVertical.h>
 #include <SketchPlugin_ConstraintEqual.h>
 #include <SketchPlugin_ConstraintLength.h>
 #include <SketchPlugin_ConstraintMiddle.h>
@@ -78,11 +76,6 @@ static ConstraintWrapperPtr
   createConstraintDistancePointLine(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
                                     std::shared_ptr<PlaneGCSSolver_PointWrapper>  thePoint,
                                     std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
-static ConstraintWrapperPtr
-  createConstraintHVDistance(const SketchSolver_ConstraintType& theType,
-                             std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
-                             std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint1,
-                             std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint2);
 static ConstraintWrapperPtr
   createConstraintRadius(std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
                          std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity);
@@ -125,9 +118,7 @@ SolverConstraintPtr PlaneGCSSolver_Tools::createConstraint(ConstraintPtr theCons
     return SolverConstraintPtr(new SketchSolver_ConstraintCoincidence(theConstraint));
   } else if (theConstraint->getKind() == SketchPlugin_ConstraintCollinear::ID()) {
     return SolverConstraintPtr(new SketchSolver_ConstraintCollinear(theConstraint));
-  } else if (theConstraint->getKind() == SketchPlugin_ConstraintDistance::ID() ||
-             theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID() ||
-             theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID()) {
+  } else if (theConstraint->getKind() == SketchPlugin_ConstraintDistance::ID()) {
     return SolverConstraintPtr(new SketchSolver_ConstraintDistance(theConstraint));
   } else if (theConstraint->getKind() == SketchPlugin_ConstraintEqual::ID()) {
     return SolverConstraintPtr(new SketchSolver_ConstraintEqual(theConstraint));
@@ -152,18 +143,11 @@ SolverConstraintPtr PlaneGCSSolver_Tools::createConstraint(ConstraintPtr theCons
   return SolverConstraintPtr(new SketchSolver_Constraint(theConstraint));
 }
 
-std::shared_ptr<SketchSolver_ConstraintMovement> PlaneGCSSolver_Tools::createMovementConstraint(
+std::shared_ptr<SketchSolver_ConstraintFixed> PlaneGCSSolver_Tools::createMovementConstraint(
     FeaturePtr theMovedFeature)
 {
-  return std::shared_ptr<SketchSolver_ConstraintMovement>(
-      new SketchSolver_ConstraintMovement(theMovedFeature));
-}
-
-std::shared_ptr<SketchSolver_ConstraintMovement> PlaneGCSSolver_Tools::createMovementConstraint(
-    AttributePtr theMovedAttribute)
-{
-  return std::shared_ptr<SketchSolver_ConstraintMovement>(
-      new SketchSolver_ConstraintMovement(theMovedAttribute));
+  return std::shared_ptr<SketchSolver_ConstraintFixed>(
+      new SketchSolver_ConstraintFixed(theMovedFeature));
 }
 
 
@@ -202,10 +186,6 @@ ConstraintWrapperPtr PlaneGCSSolver_Tools::createConstraint(
                                                 aPoint1,
                                                 GCS_EDGE_WRAPPER(theEntity1));
     break;
-  case CONSTRAINT_HORIZONTAL_DISTANCE:
-  case CONSTRAINT_VERTICAL_DISTANCE:
-    aResult = createConstraintHVDistance(theType, GCS_SCALAR_WRAPPER(theValue), aPoint1, aPoint2);
-    break;
   case CONSTRAINT_RADIUS:
     aResult = createConstraintRadius(GCS_SCALAR_WRAPPER(theValue),
                                      GCS_EDGE_WRAPPER(theEntity1));
@@ -399,32 +379,6 @@ ConstraintWrapperPtr createConstraintDistancePointLine(
   return aResult;
 }
 
-ConstraintWrapperPtr createConstraintHVDistance(
-    const SketchSolver_ConstraintType& theType,
-    std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
-    std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint1,
-    std::shared_ptr<PlaneGCSSolver_PointWrapper> thePoint2)
-{
-  GCSPointPtr aPoint1 = thePoint1->point();
-  GCSPointPtr aPoint2 = thePoint2->point();
-
-  double *aParam1, *aParam2;
-  if (theType == CONSTRAINT_HORIZONTAL_DISTANCE) {
-    aParam1 = aPoint1->x;
-    aParam2 = aPoint2->x;
-  } else if (theType == CONSTRAINT_VERTICAL_DISTANCE) {
-    aParam1 = aPoint1->y;
-    aParam2 = aPoint2->y;
-  }
-
-  GCSConstraintPtr aNewConstr(new GCS::ConstraintDifference(aParam1, aParam2, theValue->scalar()));
-
-  std::shared_ptr<PlaneGCSSolver_ConstraintWrapper> aResult(
-      new PlaneGCSSolver_ConstraintWrapper(aNewConstr, theType));
-  aResult->setValueParameter(theValue);
-  return aResult;
-}
-
 ConstraintWrapperPtr createConstraintRadius(
     std::shared_ptr<PlaneGCSSolver_ScalarWrapper> theValue,
     std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity)
index 69cc966803ecd95cb9b401e6a815ece98358aaf4..e06acb15923efe5dbb251b1a576ac0443a7144d8 100644 (file)
@@ -22,7 +22,7 @@
 #define PlaneGCSSolver_Tools_H_
 
 #include <SketchSolver_Constraint.h>
-#include <SketchSolver_ConstraintMovement.h>
+#include <SketchSolver_ConstraintFixed.h>
 #include <SketchPlugin_Constraint.h>
 
 #include <GeomAPI_Lin2d.h>
@@ -39,11 +39,8 @@ namespace PlaneGCSSolver_Tools
   SolverConstraintPtr createConstraint(ConstraintPtr theConstraint);
 
   /// \brief Creates temporary constraint to fix the feature after movement
-  std::shared_ptr<SketchSolver_ConstraintMovement>
+  std::shared_ptr<SketchSolver_ConstraintFixed>
       createMovementConstraint(FeaturePtr theMovedFeature);
-  /// \brief Creates temporary constraint to fix the attribute after movement
-  std::shared_ptr<SketchSolver_ConstraintMovement>
-      createMovementConstraint(AttributePtr theMovedAttribute);
 
   /// \brief Creates new constraint using given parameters
   /// \param theConstraint [in]  original constraint
index 4a78cc548d772a7ea1c7bde38680abc5018b83cd..f0e6365ccb029128e38035e37dfb8519ade143a7 100644 (file)
@@ -134,10 +134,6 @@ void SketchSolver_Constraint::process()
   ConstraintWrapperPtr aNewConstraint = PlaneGCSSolver_Tools::createConstraint(
       myBaseConstraint, aConstrType,
       aValue, anAttributes[0], anAttributes[1], anAttributes[2], anAttributes[3]);
-  if (!aNewConstraint) {
-    myErrorMsg = SketchSolver_Error::WRONG_CONSTRAINT_TYPE();
-    return;
-  }
   myStorage->addConstraint(myBaseConstraint, aNewConstraint);
 
   adjustConstraint();
index 901053c6d7a90d70d09cefaad4169ce0efea0f39..3a6a0fa48b7d4080b42927d911fda6bfb634f3d7 100644 (file)
@@ -22,9 +22,6 @@
 #include <SketchSolver_Error.h>
 #include <SketchSolver_Manager.h>
 
-#include <SketchPlugin_ConstraintDistanceHorizontal.h>
-#include <SketchPlugin_ConstraintDistanceVertical.h>
-
 #include <GeomAPI_Dir2d.h>
 #include <GeomAPI_Lin2d.h>
 #include <GeomAPI_Pnt2d.h>
@@ -43,14 +40,9 @@ void SketchSolver_ConstraintDistance::getAttributes(
     return;
   }
 
-  if (theAttributes[1]) {
-    if (myBaseConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID())
-      myType = CONSTRAINT_HORIZONTAL_DISTANCE;
-    else if (myBaseConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
-      myType = CONSTRAINT_VERTICAL_DISTANCE;
-    else
-      myType = CONSTRAINT_PT_PT_DISTANCE;
-  } else if (theAttributes[2] && theAttributes[2]->type() == ENTITY_LINE)
+  if (theAttributes[1])
+    myType = CONSTRAINT_PT_PT_DISTANCE;
+  else if (theAttributes[2] && theAttributes[2]->type() == ENTITY_LINE)
     myType = CONSTRAINT_PT_LINE_DISTANCE;
   else
     theAttributes.clear();
index 677ef229dea43e7d7c723006b5b3329b56624a96..5cf488270f0752ccc37cd40497c540761e1a4dbd 100644 (file)
 #include <GeomDataAPI_Point2D.h>
 #include <SketchPlugin_Feature.h>
 
-/// \brief Get list of parameters of current entity
+#include <cmath>
+
+// Verify the points are equal
+static bool isEqual(const GCS::Point& thePoint1, const GCS::Point& thePoint2);
+// Verify the entities are equal
+static bool isEqual(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2);
+// Convert entity to the list of parameters
 static GCS::VEC_pD toParameters(const EntityWrapperPtr& theEntity);
 
 
@@ -40,30 +46,42 @@ SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(ConstraintPtr theCons
   myType = CONSTRAINT_FIXED;
 }
 
+SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(FeaturePtr theFeature)
+  : SketchSolver_Constraint(),
+    myBaseFeature(theFeature)
+{
+  myType = CONSTRAINT_FIXED;
+}
+
 void SketchSolver_ConstraintFixed::blockEvents(bool isBlocked)
 {
-  SketchSolver_Constraint::blockEvents(isBlocked);
+  if (myBaseFeature)
+    myBaseFeature->data()->blockSendAttributeUpdated(isBlocked);
+  if (myBaseConstraint)
+    SketchSolver_Constraint::blockEvents(isBlocked);
 }
 
 void SketchSolver_ConstraintFixed::process()
 {
   cleanErrorMsg();
-  if (!myBaseConstraint || !myStorage) {
+  if ((!myBaseConstraint && !myBaseFeature) || !myStorage) {
     // Not enough parameters are assigned
     return;
   }
 
-  EntityWrapperPtr aBaseEntity = entityToFix();
-  if (!aBaseEntity)
+  EntityWrapperPtr aBaseEntity;
+  getAttributes(aBaseEntity, myFixedEntity);
+  if (!aBaseEntity) {
+    moveFeature(); // remove myFixed entity
     myErrorMsg = SketchSolver_Error::ALREADY_FIXED();
+  }
   if (!myErrorMsg.empty())
     return;
 
-  ConstraintWrapperPtr aConstraint = fixFeature(aBaseEntity);
-  myStorage->addConstraint(myBaseConstraint, aConstraint);
+  fixFeature(aBaseEntity);
 }
 
-ConstraintWrapperPtr SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr theFeature)
+void SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr theFeature)
 {
   GCS::VEC_pD aParameters = toParameters(theFeature);
 
@@ -77,28 +95,93 @@ ConstraintWrapperPtr SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr t
         GCSConstraintPtr(new GCS::ConstraintEqual(&myFixedValues[i], *anIt)));
   }
 
-  return ConstraintWrapperPtr(
+  myConstraint = ConstraintWrapperPtr(
       new PlaneGCSSolver_ConstraintWrapper(aConstraints, getType()));
+
+  if (myBaseConstraint)
+    myStorage->addConstraint(myBaseConstraint, myConstraint);
+  else
+    myStorage->addTemporaryConstraint(myConstraint);
+}
+
+void SketchSolver_ConstraintFixed::getAttributes(EntityWrapperPtr& theBaseEntity,
+                                                 EntityWrapperPtr& theFixedEntity)
+{
+  if (myBaseFeature) {
+    // if the feature is copy, do not move it
+    std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+        std::dynamic_pointer_cast<SketchPlugin_Feature>(myBaseFeature);
+    if (aSketchFeature && aSketchFeature->isCopy()) {
+      myStorage->setNeedToResolve(true);
+      return;
+    }
+
+    bool fixFullFeature = false;
+    theBaseEntity = EntityWrapperPtr();
+    theFixedEntity = EntityWrapperPtr();
+
+    // The feature is fixed.
+    PlaneGCSSolver_FeatureBuilder aBuilder;
+    std::list<AttributePtr> aBaseAttr = myBaseFeature->data()->attributes(std::string());
+    std::list<AttributePtr>::const_iterator anIt = aBaseAttr.begin();
+    for (; anIt != aBaseAttr.end(); ++anIt) {
+      EntityWrapperPtr anEntity = aBuilder.createAttribute(*anIt);
+      EntityWrapperPtr aBaseEntity = myStorage->entity(*anIt);
+      if (!anEntity || !aBaseEntity)
+        continue;
+
+      if (!fixFullFeature && anEntity->type() == ENTITY_POINT &&
+          !isEqual(anEntity, aBaseEntity)) {
+        if (theFixedEntity)
+          fixFullFeature = true;
+        theFixedEntity = anEntity;
+        theBaseEntity = aBaseEntity;
+      }
+    }
+
+    if (fixFullFeature) {
+      theFixedEntity = aBuilder.createFeature(myBaseFeature);
+      theBaseEntity = myStorage->entity(myBaseFeature);
+      if (isEqual(theBaseEntity, theFixedEntity))
+        theBaseEntity = EntityWrapperPtr(); // do not want to fix already fixed entity
+    }
+
+  } else if (myBaseConstraint) {
+    // Constraint Fixed is added by user.
+    // Get the attribute of constraint (it should be alone in the list of constraints).
+    EntityWrapperPtr aValue;
+    std::vector<EntityWrapperPtr> anAttributes;
+    SketchSolver_Constraint::getAttributes(aValue, anAttributes);
+    std::vector<EntityWrapperPtr>::const_iterator anIt = anAttributes.begin();
+    for (; anIt != anAttributes.end(); ++anIt)
+      if (*anIt)
+        theBaseEntity = *anIt;
+  } else
+    myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
 }
 
-EntityWrapperPtr SketchSolver_ConstraintFixed::entityToFix()
+void SketchSolver_ConstraintFixed::moveFeature()
 {
-  // Constraint Fixed is added by user.
-  // Get the attribute of constraint (it should be alone in the list of constraints).
-  EntityWrapperPtr aValue;
-  std::vector<EntityWrapperPtr> anAttributes;
-  SketchSolver_Constraint::getAttributes(aValue, anAttributes);
-  std::vector<EntityWrapperPtr>::const_iterator anIt = anAttributes.begin();
-  for (; anIt != anAttributes.end(); ++anIt)
-    if (*anIt)
-      return *anIt;
-  return EntityWrapperPtr();
+  if (!myFixedEntity)
+    return;
+
+  GCS::VEC_pD aFixedParams = toParameters(myFixedEntity);
+  for (int i = 0; i < aFixedParams.size() && i < myFixedValues.size(); ++i)
+    myFixedValues[i] = *(aFixedParams[i]);
+
+  // Remove fixed entity due to its parameters already copied into the constraint
+  PlaneGCSSolver_EntityDestroyer aDestroyer;
+  aDestroyer.remove(myFixedEntity);
+  std::dynamic_pointer_cast<PlaneGCSSolver_Storage>(myStorage)->removeParameters(
+      aDestroyer.parametersToRemove());
+
+  myFixedEntity = EntityWrapperPtr();
 }
 
 
 
 
-// ==================     Auxiliary functions     ==================
+// ====================   Auxiliary functions   ===============================
 GCS::VEC_pD toParameters(const EntityWrapperPtr& theEntity)
 {
   GCS::VEC_pD aParameters;
@@ -148,3 +231,23 @@ GCS::VEC_pD toParameters(const EntityWrapperPtr& theEntity)
 
   return aParameters;
 }
+
+bool isEqual(const GCS::Point& thePoint1, const GCS::Point& thePoint2)
+{
+  return fabs((*thePoint1.x) - (*thePoint2.x)) <= tolerance &&
+         fabs((*thePoint1.y) - (*thePoint2.y)) <= tolerance;
+}
+
+bool isEqual(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2)
+{
+  GCS::VEC_pD aParamList1 = toParameters(theEntity1);
+  GCS::VEC_pD aParamList2 = toParameters(theEntity2);
+
+  GCS::VEC_pD::const_iterator anIt1 = aParamList1.begin();
+  GCS::VEC_pD::const_iterator anIt2 = aParamList2.begin();
+  for (; anIt1 != aParamList1.end() && anIt2 != aParamList2.end(); ++anIt1, ++anIt2)
+    if (fabs((**anIt1) - (**anIt2)) > tolerance)
+      return false;
+
+  return anIt1 == aParamList1.end() && anIt2 == aParamList2.end();
+}
index 1d005c1b55b9d764125e644620524b04144cbcbf..7d437fb556de2f9e801f650499935a8612f29e81 100644 (file)
 /** \class   SketchSolver_ConstraintFixed
  *  \ingroup Plugins
  *  \brief   Stores data of the Fixed constraint
+ *
+ *  Fixed constraint may have NULL basic SketchPlugin constraint,
+ *  because the Fixed constraint may be temporary for correct moving of objects.
  */
 class SketchSolver_ConstraintFixed : public SketchSolver_Constraint
 {
 public:
   /// Creates constraint to manage the given constraint from plugin
   SketchSolver_ConstraintFixed(ConstraintPtr theConstraint);
+  /// Creates temporary constraint based on feature (useful while the feature is being moved)
+  SketchSolver_ConstraintFixed(FeaturePtr theFeature);
 
   /// \brief Block or unblock events from this constraint
   virtual void blockEvents(bool isBlocked);
 
+  /// \brief Set coordinates of fixed feature to the values where it has been dragged.
+  ///        Useful when the feature is being moved.
+  void moveFeature();
+
 protected:
   /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
   virtual void process();
 
   /// \brief Generate list of attributes of constraint in order useful for constraints
-  /// \param[out] theValue      numerical characteristic of constraint (e.g. distance)
-  /// \param[out] theAttributes list of attributes to be filled
-  virtual void getAttributes(EntityWrapperPtr& , std::vector<EntityWrapperPtr>& )
-  {}
-
-  /// \brief Obtain entity to be fixed
-  EntityWrapperPtr entityToFix();
+  /// \param[out] theBaseEntity  the entity which coordinates should be fixed
+  /// \param[out] theFixedEntity the entity containing fixed values
+  virtual void getAttributes(EntityWrapperPtr& theBaseEntity,
+                             EntityWrapperPtr& theFixedEntity);
 
-  /// \brief Create Fixed constraint for the feature basing on its type
+  /// \brief Fixed feature basing on its type
   /// \param theFeature [in]  feature, converted to solver specific format
-  /// \return Fixed constraint
-  ConstraintWrapperPtr fixFeature(EntityWrapperPtr theFeature);
+  virtual void fixFeature(EntityWrapperPtr theFeature);
 
-protected:
+private:
+  FeaturePtr myBaseFeature; ///< fixed feature (when it is set, myBaseConstraint should be NULL)
+
+  ConstraintWrapperPtr myConstraint;
   std::vector<double> myFixedValues;
+  EntityWrapperPtr    myFixedEntity;
 };
 
 #endif
diff --git a/src/SketchSolver/SketchSolver_ConstraintMovement.cpp b/src/SketchSolver/SketchSolver_ConstraintMovement.cpp
deleted file mode 100644 (file)
index 94c6d7a..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-#include <SketchSolver_ConstraintMovement.h>
-#include <SketchSolver_Error.h>
-#include <SketchSolver_Manager.h>
-
-#include <PlaneGCSSolver_EdgeWrapper.h>
-#include <PlaneGCSSolver_PointWrapper.h>
-
-#include <SketchPlugin_Arc.h>
-#include <SketchPlugin_Circle.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Point.h>
-
-#include <GeomDataAPI_Point2D.h>
-
-#include <GeomAPI_Pnt2d.h>
-
-
-SketchSolver_ConstraintMovement::SketchSolver_ConstraintMovement(FeaturePtr theFeature)
-  : SketchSolver_ConstraintFixed(ConstraintPtr()),
-    myMovedFeature(theFeature),
-    mySimpleMove(true)
-{
-}
-
-SketchSolver_ConstraintMovement::SketchSolver_ConstraintMovement(AttributePtr thePoint)
-  : SketchSolver_ConstraintFixed(ConstraintPtr()),
-    myDraggedPoint(thePoint),
-    mySimpleMove(true)
-{
-  myMovedFeature = ModelAPI_Feature::feature(thePoint->owner());
-}
-
-void SketchSolver_ConstraintMovement::blockEvents(bool isBlocked)
-{
-  if (myMovedFeature)
-    myMovedFeature->data()->blockSendAttributeUpdated(isBlocked);
-}
-
-void SketchSolver_ConstraintMovement::process()
-{
-  cleanErrorMsg();
-  if (!myMovedFeature || !myStorage) {
-    // Not enough parameters are initialized
-    return;
-  }
-
-  mySolverConstraint = initMovement();
-  if (!myErrorMsg.empty() || !mySolverConstraint) {
-    // Nothing to move, clear the feature to avoid changing its group
-    // after removing the Movement constraint.
-    myMovedFeature = FeaturePtr();
-    return;
-  }
-  myStorage->addMovementConstraint(mySolverConstraint);
-}
-
-
-static bool isSimpleMove(FeaturePtr theMovedFeature, AttributePtr theDraggedPoint)
-{
-  bool isSimple = true;
-  if (theMovedFeature->getKind() == SketchPlugin_Circle::ID())
-    isSimple = (theDraggedPoint.get() != 0);
-  else if (theMovedFeature->getKind() == SketchPlugin_Arc::ID()) {
-    isSimple = (theDraggedPoint.get() != 0 &&
-                theDraggedPoint->id() == SketchPlugin_Arc::CENTER_ID());
-  }
-  return isSimple;
-}
-
-ConstraintWrapperPtr SketchSolver_ConstraintMovement::initMovement()
-{
-  ConstraintWrapperPtr aConstraint;
-
-  // if the feature is copy, do not move it
-  std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
-      std::dynamic_pointer_cast<SketchPlugin_Feature>(myMovedFeature);
-  if (!aSketchFeature || aSketchFeature->isCopy()) {
-    myStorage->setNeedToResolve(true);
-    return aConstraint;
-  }
-
-  EntityWrapperPtr anEntity =
-      myDraggedPoint ? myStorage->entity(myDraggedPoint) : myStorage->entity(myMovedFeature);
-  if (!anEntity) {
-    myStorage->update(myMovedFeature, true);
-    anEntity =
-        myDraggedPoint ? myStorage->entity(myDraggedPoint) : myStorage->entity(myMovedFeature);
-    if (!anEntity)
-      return aConstraint;
-  }
-
-  mySimpleMove = isSimpleMove(myMovedFeature, myDraggedPoint);
-
-  if (mySimpleMove)
-    aConstraint = fixFeature(anEntity);
-  else {
-    if (myDraggedPoint) // start or end point of arc has been moved
-      aConstraint = fixArcExtremity(anEntity);
-    else // arc or circle has been moved
-      aConstraint = fixPointOnCircle(anEntity);
-  }
-
-  return aConstraint;
-}
-
-ConstraintWrapperPtr SketchSolver_ConstraintMovement::fixArcExtremity(
-    const EntityWrapperPtr& theArcExtremity)
-{
-  static const int nbParams = 4;
-  myFixedValues.reserve(nbParams); // moved point and center of arc
-
-  EdgeWrapperPtr aCircularEntity = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(
-      myStorage->entity(myMovedFeature));
-  std::shared_ptr<GCS::Arc> anArc =
-      std::dynamic_pointer_cast<GCS::Arc>(aCircularEntity->entity());
-
-  PointWrapperPtr aPoint =
-      std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theArcExtremity);
-
-  double* aParams[nbParams] = { aPoint->point()->x, aPoint->point()->y,
-                                anArc->center.x, anArc->center.y };
-
-  std::list<GCSConstraintPtr> aConstraints;
-  for (int i = 0; i < nbParams; ++i) {
-    myFixedValues.push_back(*aParams[i]);
-    GCSConstraintPtr aNewConstraint(new GCS::ConstraintEqual(&myFixedValues[i], aParams[i]));
-    aNewConstraint->rescale(0.01);
-    aConstraints.push_back(aNewConstraint);
-  }
-
-  return ConstraintWrapperPtr(
-      new PlaneGCSSolver_ConstraintWrapper(aConstraints, getType()));
-}
-
-ConstraintWrapperPtr SketchSolver_ConstraintMovement::fixPointOnCircle(
-    const EntityWrapperPtr& theCircular)
-{
-  static const double scale = 0.01;
-  static const int nbParams = 4;
-  myFixedValues.reserve(nbParams); // moved point and center of arc/circle
-
-  EdgeWrapperPtr aCircularEntity =
-      std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(theCircular);
-  std::shared_ptr<GCS::Circle> aCircular =
-      std::dynamic_pointer_cast<GCS::Circle>(aCircularEntity->entity());
-
-  // initialize fixed values
-  myFixedValues.push_back(*aCircular->center.x + *aCircular->rad);
-  myFixedValues.push_back(*aCircular->center.y);
-  myFixedValues.push_back(*aCircular->center.x);
-  myFixedValues.push_back(*aCircular->center.y);
-
-  // create a moved point
-  GCS::Point aPointOnCircle;
-  aPointOnCircle.x = &myFixedValues[0];
-  aPointOnCircle.y = &myFixedValues[1];
-
-  std::list<GCSConstraintPtr> aConstraints;
-  // point-on-circle
-  GCSConstraintPtr aNewConstraint(
-      new GCS::ConstraintP2PDistance(aPointOnCircle, aCircular->center, aCircular->rad));
-  aNewConstraint->rescale(scale);
-  aConstraints.push_back(aNewConstraint);
-  // fixed center (x)
-  aNewConstraint = GCSConstraintPtr(
-      new GCS::ConstraintEqual(&myFixedValues[2], aCircular->center.x));
-  aNewConstraint->rescale(scale);
-  aConstraints.push_back(aNewConstraint);
-  // fixed center (y)
-  aNewConstraint = GCSConstraintPtr(
-      new GCS::ConstraintEqual(&myFixedValues[3], aCircular->center.y));
-  aNewConstraint->rescale(scale);
-  aConstraints.push_back(aNewConstraint);
-
-  return ConstraintWrapperPtr(
-      new PlaneGCSSolver_ConstraintWrapper(aConstraints, getType()));
-}
-
-
-void SketchSolver_ConstraintMovement::startPoint(
-    const std::shared_ptr<GeomAPI_Pnt2d>& theStartPoint)
-{
-  myStartPoint = theStartPoint;
-  if (!mySimpleMove) {
-    myFixedValues[0] = myStartPoint->x();
-    myFixedValues[1] = myStartPoint->y();
-  }
-}
-
-void SketchSolver_ConstraintMovement::moveTo(
-    const std::shared_ptr<GeomAPI_Pnt2d>& theDestinationPoint)
-{
-  double aDelta[2] = { theDestinationPoint->x() - myStartPoint->x(),
-                       theDestinationPoint->y() - myStartPoint->y() };
-
-  int aMaxSize = mySimpleMove ? (int)myFixedValues.size() : 2;
-  for (int i = 0; i < aMaxSize; ++i)
-    myFixedValues[i] += aDelta[i % 2];
-}
diff --git a/src/SketchSolver/SketchSolver_ConstraintMovement.h b/src/SketchSolver/SketchSolver_ConstraintMovement.h
deleted file mode 100644 (file)
index 8614f30..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2017  CEA/DEN, EDF R&D
-//
-// 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, 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
-// 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
-//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-//
-
-// File:    SketchSolver_ConstraintMovement.h
-// Created: 15 Jun 2015
-// Author:  Artem ZHIDKOV
-
-#ifndef SketchSolver_ConstraintMovement_H_
-#define SketchSolver_ConstraintMovement_H_
-
-#include <SketchSolver_ConstraintFixed.h>
-
-class GeomAPI_Pnt2d;
-
-/** \class   SketchSolver_ConstraintMovement
- *  \ingroup Plugins
- *  \brief   Stores data to the Fixed constraint for the moved feature only
- */
-class SketchSolver_ConstraintMovement : public SketchSolver_ConstraintFixed
-{
-public:
-  /// Creates movement constraint based on feature
-  SketchSolver_ConstraintMovement(FeaturePtr theFeature);
-
-  /// Creates movement constraint based on point
-  SketchSolver_ConstraintMovement(AttributePtr thePoint);
-
-  /// \brief Set coordinates of the start point of the movement
-  void startPoint(const std::shared_ptr<GeomAPI_Pnt2d>& theStartPoint);
-
-  /// \brief Set coordinates of fixed feature to the values where it has been dragged.
-  ///        Useful when the feature is being moved.
-  void moveTo(const std::shared_ptr<GeomAPI_Pnt2d>& theDestinationPoint);
-
-  /// \brief Block or unblock events from this constraint
-  virtual void blockEvents(bool isBlocked);
-
-  /// \brief Returns moved feature
-  FeaturePtr movedFeature() const
-  { return myMovedFeature; }
-
-protected:
-  /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints
-  virtual void process();
-
-  /// \brief Create Fixed constraint for the feature basing on its type and moved point
-  /// \return Fixed constraint
-  ConstraintWrapperPtr initMovement();
-
-  /// \brief Create constraint to fix moved arc extremity
-  ConstraintWrapperPtr fixArcExtremity(const EntityWrapperPtr& theArcExtremity);
-
-  /// \brief Creat constraint to fix moved point on circle/arc
-  ConstraintWrapperPtr fixPointOnCircle(const EntityWrapperPtr& theCircular);
-
-private:
-  FeaturePtr       myMovedFeature; ///< fixed feature (if set, myBaseConstraint should be NULL)
-  AttributePtr     myDraggedPoint; ///< one of the feature points which has been moved
-  std::shared_ptr<GeomAPI_Pnt2d> myStartPoint; ///< start point of the movement
-
-  bool mySimpleMove; ///< simple move, thus all parameters should be increased by movement delta
-};
-
-#endif
index 3093e7bc9ac20f73330e224af1021104ef8d2178..4b4347f364de9bb44e3126b8abd90088fe296134 100644 (file)
@@ -103,12 +103,6 @@ class SketchSolver_Error
     static const std::string MY_ERROR_VALUE("Caution: SolveSpace crash! Constraints are wrong");
     return MY_ERROR_VALUE;
   }
-  /// Constraint has wrong type
-  inline static const std::string& WRONG_CONSTRAINT_TYPE()
-  {
-    static const std::string MY_ERROR_VALUE("Unsupported type of constraint");
-    return MY_ERROR_VALUE;
-  }
 };
 
 #endif
index 93bbfa69d406369bea25307cbe7a7ea0eb3d498e..f437103ac38527035421f86396b2fe5c6c0d26fd 100644 (file)
@@ -70,7 +70,7 @@ static void sendMessage(const char* theMessageName,
 
 
 // ========================================================
-// =========       SketchSolver_Group       ===============
+// =========  SketchSolver_Group  ===============
 // ========================================================
 
 SketchSolver_Group::SketchSolver_Group(const CompositeFeaturePtr& theWorkplane)
@@ -129,56 +129,32 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature)
   return myStorage->update(theFeature);
 }
 
-template <class Type>
-static SolverConstraintPtr move(StoragePtr theStorage,
-                                SolverPtr theSketchSolver,
-                                int theSketchDOF,
-                                bool theEventsBlocked,
-                                Type theFeatureOrPoint,
-                                const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
-                                const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
+bool SketchSolver_Group::moveFeature(FeaturePtr theFeature)
 {
-  bool isEntityExists = (theStorage->entity(theFeatureOrPoint).get() != 0);
-  if (theSketchDOF == 0 && isEntityExists) {
+  bool isFeatureExists = (myStorage->entity(theFeature).get() != 0);
+  if (myDOF == 0 && isFeatureExists) {
     // avoid moving elements of fully constrained sketch
-    theStorage->refresh();
-    return SolverConstraintPtr();
+    myStorage->refresh();
+    return true;
   }
 
   // Create temporary Fixed constraint
-  std::shared_ptr<SketchSolver_ConstraintMovement> aConstraint =
-      PlaneGCSSolver_Tools::createMovementConstraint(theFeatureOrPoint);
-  if (aConstraint) {
-    SolverConstraintPtr(aConstraint)->process(theStorage, theEventsBlocked);
-    if (aConstraint->error().empty()) {
-      aConstraint->startPoint(theFrom);
-      theSketchSolver->initialize();
-      aConstraint->moveTo(theTo);
-      theStorage->setNeedToResolve(true);
-    } else
-      theStorage->notify(aConstraint->movedFeature());
+  std::shared_ptr<SketchSolver_ConstraintFixed> aConstraint =
+      PlaneGCSSolver_Tools::createMovementConstraint(theFeature);
+  if (!aConstraint)
+    return false;
+  SolverConstraintPtr(aConstraint)->process(myStorage, myIsEventsBlocked);
+  if (aConstraint->error().empty()) {
+    setTemporary(aConstraint);
+    if (!myStorage->isEmpty())
+      myStorage->setNeedToResolve(true);
+
+    mySketchSolver->initialize();
+    aConstraint->moveFeature();
   }
 
-  return aConstraint;
-}
-
-bool SketchSolver_Group::moveFeature(FeaturePtr theFeature,
-                                     const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
-                                     const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
-{
-  SolverConstraintPtr aConstraint =
-      move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked, theFeature, theFrom, theTo);
-  setTemporary(aConstraint);
-  return true;
-}
-
-bool SketchSolver_Group::movePoint(AttributePtr theAttribute,
-                                   const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
-                                   const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
-{
-  SolverConstraintPtr aConstraint =
-      move(myStorage, mySketchSolver, myDOF, myIsEventsBlocked, theAttribute, theFrom, theTo);
-  setTemporary(aConstraint);
+  // notify all observers that theFeature has been changed
+  myStorage->notify(theFeature);
   return true;
 }
 
@@ -396,8 +372,7 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
 // ============================================================================
 void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint)
 {
-  if (theConstraint)
-    myTempConstraints.insert(theConstraint);
+  myTempConstraints.insert(theConstraint);
 }
 
 // ============================================================================
index 4a65bf258f37c50a4d26bee21eec46add297d355..9a78d9a2c6fa8404c7883067af9742b15d38297e 100644 (file)
@@ -31,8 +31,6 @@
 #include <memory>
 #include <map>
 
-class GeomAPI_Pnt2d;
-
 typedef std::map<ConstraintPtr, SolverConstraintPtr> ConstraintConstraintMap;
 
 /** \class   SketchSolver_Group
@@ -74,25 +72,11 @@ class SketchSolver_Group
   bool updateFeature(FeaturePtr theFeature);
 
   /** \brief Updates the data corresponding the specified feature moved in GUI.
-   *         Special kind of Fixed constraints is created.
+   *         Additional Fixed constraints are created.
    *  \param[in] theFeature the feature to be updated
-   *  \param[in] theFrom    start point of the movement
-   *  \param[in] theTo      final point of the movement
-   *  \return \c true, if the feature is really moved
-   */
-  bool moveFeature(FeaturePtr theFeature,
-                   const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
-                   const std::shared_ptr<GeomAPI_Pnt2d>& theTo);
-  /** \brief Updates the data corresponding the specified point moved in GUI.
-   *         Special kind of Fixed constraints is created.
-   *  \param[in] thePoint the attribute to be updated
-   *  \param[in] theFrom  start point of the movement
-   *  \param[in] theTo    final point of the movement
-   *  \return \c true, if the attribute is really moved
+   *  \return \c true, if the feature is moved
    */
-  bool movePoint(AttributePtr thePoint,
-                 const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
-                 const std::shared_ptr<GeomAPI_Pnt2d>& theTo);
+  bool moveFeature(FeaturePtr theFeature);
 
   /// Returns the current workplane
   inline const CompositeFeaturePtr& getWorkplane() const
index d253916c981ded6b8df351a2d92e0c8323a5000b..e20ef48c1c23dfda07ff25011b5a695c742cc457 100644 (file)
 #include "SketchSolver_Error.h"
 
 #include <Events_Loop.h>
-#include <GeomDataAPI_Point2D.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
-#include <SketchPlugin_Constraint.h>
 #include <SketchPlugin_Sketch.h>
 
 /// Global constraint manager object
@@ -68,6 +66,8 @@ SketchSolver_Manager::SketchSolver_Manager()
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_MOVED));
 
+  ////Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
+  ////Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_REPAIRED));
   Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_SKETCH_PREPARED));
 }
 
@@ -106,13 +106,20 @@ void SketchSolver_Manager::processEvent(
   myIsComputed = true;
 
   if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)
-      || theMessage->eventID() == anUpdateEvent) {
+      || theMessage->eventID() == anUpdateEvent
+      || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) {
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     std::set<ObjectPtr> aFeatures = anUpdateMsg->objects();
 
     isUpdateFlushed = stopSendUpdate();
 
+    isMovedEvt = theMessage->eventID()
+          == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
+
+    // Shows that the message has at least one feature applicable for solver
+    bool hasProperFeature = false;
+
     // update sketch features only
     std::set<ObjectPtr>::iterator aFeatIter;
     for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
@@ -121,28 +128,11 @@ void SketchSolver_Manager::processEvent(
       if (!aFeature || aFeature->isMacro())
         continue;
 
-      updateFeature(aFeature);
+      hasProperFeature = updateFeature(aFeature, isMovedEvt) || hasProperFeature;
     }
 
-  } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) {
-    std::shared_ptr<ModelAPI_ObjectMovedMessage> aMoveMsg =
-        std::dynamic_pointer_cast<ModelAPI_ObjectMovedMessage>(theMessage);
-
-    ObjectPtr aMovedObject = aMoveMsg->movedObject();
-    std::shared_ptr<GeomDataAPI_Point2D> aMovedPoint =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aMoveMsg->movedAttribute());
-
-    const std::shared_ptr<GeomAPI_Pnt2d>& aFrom = aMoveMsg->originalPosition();
-    const std::shared_ptr<GeomAPI_Pnt2d>& aTo = aMoveMsg->currentPosition();
-
-    if (aMovedObject) {
-      FeaturePtr aMovedFeature = ModelAPI_Feature::feature(aMovedObject);
-      std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
-          std::dynamic_pointer_cast<SketchPlugin_Feature>(aMovedFeature);
-      if (aSketchFeature && !aSketchFeature->isMacro())
-        needToResolve = moveFeature(aSketchFeature, aFrom, aTo);
-    } else if (aMovedPoint)
-      needToResolve = moveAttribute(aMovedPoint, aFrom, aTo);
+    if (isMovedEvt && hasProperFeature)
+      needToResolve = true;
 
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
     std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
@@ -189,10 +179,11 @@ void SketchSolver_Manager::processEvent(
 }
 
 // ============================================================================
-//  Function: updateFeature
-//  Purpose:  create/update constraint or feature in appropriate group
+//  Function: changeConstraintOrEntity
+//  Purpose:  create/update the constraint or the feature and place it into appropriate group
 // ============================================================================
-bool SketchSolver_Manager::updateFeature(const std::shared_ptr<SketchPlugin_Feature>& theFeature)
+bool SketchSolver_Manager::updateFeature(std::shared_ptr<SketchPlugin_Feature> theFeature,
+                                         bool theMoved)
 {
   // Check feature validity and find a group to place it.
   // If the feature is not valid, the returned group will be empty.
@@ -208,52 +199,13 @@ bool SketchSolver_Manager::updateFeature(const std::shared_ptr<SketchPlugin_Feat
   bool isOk = false;
   if (aConstraint)
     isOk = aGroup->changeConstraint(aConstraint);
+  else if (theMoved)
+    isOk = aGroup->moveFeature(theFeature);
   else
     isOk = aGroup->updateFeature(theFeature);
   return isOk;
 }
 
-// ============================================================================
-//  Function: moveFeature
-//  Purpose:  move given feature in appropriate group
-// ============================================================================
-bool SketchSolver_Manager::moveFeature(
-    const std::shared_ptr<SketchPlugin_Feature>& theMovedFeature,
-    const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
-    const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
-{
-  SketchGroupPtr aGroup = findGroup(theMovedFeature);
-  if (!aGroup)
-    return false;
-
-  aGroup->blockEvents(true);
-  return aGroup->moveFeature(theMovedFeature, theFrom, theTo);
-}
-
-// ============================================================================
-//  Function: moveAttribute
-//  Purpose:  move given attribute in appropriate group
-// ============================================================================
-bool SketchSolver_Manager::moveAttribute(
-    const std::shared_ptr<GeomDataAPI_Point2D>& theMovedAttribute,
-    const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
-    const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
-{
-  FeaturePtr anOwner = ModelAPI_Feature::feature(theMovedAttribute->owner());
-  std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
-      std::dynamic_pointer_cast<SketchPlugin_Feature>(anOwner);
-  SketchGroupPtr aGroup;
-  if (aSketchFeature)
-    aGroup = findGroup(aSketchFeature);
-  if (!aGroup) {
-    theMovedAttribute->setValue(theTo);
-    return false;
-  }
-
-  aGroup->blockEvents(true);
-  return aGroup->movePoint(theMovedAttribute, theFrom, theTo);
-}
-
 // ============================================================================
 //  Function: findGroup
 //  Purpose:  search groups of entities interacting with given feature
index 105cc0e97ae1b503195b9efddd7b7969107ffbd9..45c1a4284bbaff4df86690f1669785e1dd0cb923 100644 (file)
 #include <SketchSolver_Group.h>
 
 #include <Events_Listener.h>
+#include <SketchPlugin_Constraint.h>
 
 #include <list>
 #include <set>
 
-class GeomAPI_Pnt2d;
-class GeomDataAPI_Point2D;
-class SketchPlugin_Constraint;
-
 /** \class   SketchSolver_Manager
  *  \ingroup Plugins
  *  \brief   Listens the changes of SketchPlugin features and transforms the Constraint
@@ -64,29 +61,10 @@ protected:
 
   /** \brief Adds or updates a constraint or an entity in the suitable group
    *  \param[in] theFeature sketch feature to be changed
+   *  \param[in] theMoved   \c true if the feature has been moved in the viewer
    *  \return \c true if the feature changed successfully
    */
-  bool updateFeature(const std::shared_ptr<SketchPlugin_Feature>& theFeature);
-
-  /** \brief Move feature
-   *  \param[in] theMovedFeature dragged sketch feature
-   *  \param[in] theFromPoint    original position of the feature
-   *  \param[in] theToPoint      prefereble position of the feature (current position of the mouse)
-   *  \return \c true if the feature has been changed successfully
-   */
-  bool moveFeature(const std::shared_ptr<SketchPlugin_Feature>& theMovedFeature,
-                   const std::shared_ptr<GeomAPI_Pnt2d>& theFromPoint,
-                   const std::shared_ptr<GeomAPI_Pnt2d>& theToPoint);
-
-  /** \brief Move feature using its moved attribute
-   *  \param[in] theMovedAttribute dragged point attribute of sketch feature
-   *  \param[in] theFromPoint      original position of the moved point
-   *  \param[in] theToPoint        prefereble position (current position of the mouse)
-   *  \return \c true if the attribute owner has been changed successfully
-   */
-  bool moveAttribute(const std::shared_ptr<GeomDataAPI_Point2D>& theMovedAttribute,
-                     const std::shared_ptr<GeomAPI_Pnt2d>& theFromPoint,
-                     const std::shared_ptr<GeomAPI_Pnt2d>& theToPoint);
+  bool updateFeature(std::shared_ptr<SketchPlugin_Feature> theFeature, bool theMoved = false);
 
   /** \brief Removes a constraint from the manager
    *  \param[in] theConstraint constraint to be removed
index 8017703488077d7add53fd5d4859fd7eb992a3e6..f4f6e7254cd7a504a1f11a8679dca39809ef6707 100644 (file)
@@ -57,10 +57,10 @@ public:
   virtual void addConstraint(ConstraintPtr        theConstraint,
                              ConstraintWrapperPtr theSolverConstraint);
 
-  /// \brief Add a movement constraint which will be destroyed
+  /// \brief Add list of temporary constraints which will be destroyed
   ///        after the next solving of the set of constraints.
   /// \param theSolverConstraint [in]  solver's constraint
-  virtual void addMovementConstraint(const ConstraintWrapperPtr& theSolverConstraint) = 0;
+  virtual void addTemporaryConstraint(const ConstraintWrapperPtr& theSolverConstraint) = 0;
 
   /// \brief Change mapping feature from SketchPlugin and
   ///        the entity applicable for corresponding solver.
index 5e5c60465379a607308c023fc738da9d62df5df5..6a64f6eba70228097a59fc4ca9981e825b886503 100644 (file)
@@ -25,8 +25,6 @@
 #include <SketchPlugin_Constraint.h>
 #include <SketchPlugin_ConstraintLength.h>
 #include <SketchPlugin_ConstraintDistance.h>
-#include <SketchPlugin_ConstraintDistanceHorizontal.h>
-#include <SketchPlugin_ConstraintDistanceVertical.h>
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Circle.h>
@@ -185,9 +183,7 @@ bool SketcherPrs_LengthDimension::readyToDisplay(ModelAPI_Feature* theConstraint
     thePnt2 = thePlane->to3D(aEndPoint->x(), aEndPoint->y())->impl<gp_Pnt>();
     return true;
 
-  } else if (theConstraint->getKind() == SketchPlugin_ConstraintDistance::ID() ||
-             theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID() ||
-             theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID()) {
+  } else if (theConstraint->getKind() == SketchPlugin_ConstraintDistance::ID()) {
     // The constraint is distance
     std::shared_ptr<GeomDataAPI_Point2D> aPoint_A = SketcherPrs_Tools::getFeaturePoint(
         aData, SketchPlugin_Constraint::ENTITY_A(), thePlane);
index 47c1be475e771f287436cfff9e7e07312f45a41b..e22a952e244ceb7183b17139a3c239845ba8687a 100644 (file)
@@ -702,7 +702,7 @@ QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
 void XGUI_ContextMenuMgr::onRename()
 {
   QObjectPtrList anObjects = myWorkshop->selector()->selection()->selectedObjects();
-  if (!myWorkshop->operationMgr()->abortAllOperations())
+  if (!myWorkshop->abortAllOperations())
     return;
   // restore selection in case if dialog box was shown
   myWorkshop->objectBrowser()->setObjectsSelected(anObjects);
index 73d0447b008c5fc2582677a5377734377c16396b..fdb129faa151144ab62b56f27fda7406159d83d4 100755 (executable)
@@ -99,8 +99,7 @@ void XGUI_MenuMgr::addFeature(const std::shared_ptr<Config_FeatureMessage>& theM
     }
     if (aNestedActions.contains(FEATURE_WHEN_NESTED_ABORT)) {
       QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll);
-      QObject::connect(anAction, SIGNAL(triggered()),
-                       anOperationMgr, SLOT(onAbortAllOperations()));
+      QObject::connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(abortAllOperations()));
       aNestedActList << anAction;
     }
   }
@@ -210,8 +209,7 @@ QAction* XGUI_MenuMgr::buildAction(const std::shared_ptr<Config_FeatureMessage>&
     }
     if (aNestedActions.contains(FEATURE_WHEN_NESTED_ABORT)) {
       QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll);
-      QObject::connect(anAction, SIGNAL(triggered()),
-                       anOperationMgr, SLOT(onAbortAllOperations()));
+      QObject::connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(abortAllOperations()));
       aNestedActList << anAction;
     }
     anAction = aSalomeConnector->addFeatureOfNested(theWchName.c_str(), aFeatureInfo,
index 02186143c9def04d27e45cbfa4b8ccddc40e49b3..a0a879c7aaa353aa6c05b6b2f8b705322175c9be 100644 (file)
@@ -211,12 +211,7 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
   return isStarted;
 }
 
-void XGUI_OperationMgr::onAbortAllOperations()
-{
-  abortAllOperations();
-}
-
-bool XGUI_OperationMgr::abortAllOperations(const XGUI_MessageKind& theMessageKind)
+bool XGUI_OperationMgr::abortAllOperations()
 {
   bool aResult = true;
   if(!hasOperation())
@@ -224,29 +219,18 @@ bool XGUI_OperationMgr::abortAllOperations(const XGUI_MessageKind& theMessageKin
 
   if (operationsCount() == 1) {
     ModuleBase_Operation* aCurrentOperation = currentOperation();
-    if (canStopOperation(aCurrentOperation, theMessageKind)) {
+    if (canStopOperation(aCurrentOperation)) {
       abortOperation(aCurrentOperation);
     }
     else
       aResult = false;
   }
   else {
-    if (theMessageKind == XGUI_AbortOperationMessage) {
-      aResult = QMessageBox::question(qApp->activeWindow(),
-                                      tr("Abort operation"),
-                                      tr("All active operations will be aborted."),
-                                      QMessageBox::Ok | QMessageBox::Cancel,
-                                      QMessageBox::Cancel) == QMessageBox::Ok;
-    }
-    else if (theMessageKind == XGUI_InformationMessage) {
-      QString aMessage = tr("Please validate all your active operations before saving.");
-      QMessageBox::question(qApp->activeWindow(),
-                            tr("Validate operation"),
-                            aMessage,
-                            QMessageBox::Ok,
-                            QMessageBox::Ok);
-      aResult = false; // do not perform abort
-    }
+    aResult = QMessageBox::question(qApp->activeWindow(),
+                                    tr("Abort operation"),
+                                    tr("All active operations will be aborted."),
+                                    QMessageBox::Ok | QMessageBox::Cancel,
+                                    QMessageBox::Cancel) == QMessageBox::Ok;
     while(aResult && hasOperation()) {
       abortOperation(currentOperation());
     }
@@ -260,7 +244,7 @@ bool XGUI_OperationMgr::commitAllOperations()
   while (hasOperation()) {
     ModuleBase_Operation* anOperation = currentOperation();
     if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled()) {
-      anOperationProcessed = commitOperation();
+      anOperationProcessed = onCommitOperation();
     } else {
       abortOperation(anOperation);
       anOperationProcessed = true;
@@ -314,35 +298,33 @@ void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperati
   onValidateOperation();
 }
 
-bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation,
-                                         const XGUI_OperationMgr::XGUI_MessageKind& theMessageKind)
+bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation)
 {
   //in case of nested (sketch) operation no confirmation needed
   if (isGrantedOperation(theOperation->id()))
     return true;
   if (theOperation && theOperation->isModified()) {
-    if (theMessageKind == XGUI_AbortOperationMessage) {
-      QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
-      int anAnswer = QMessageBox::question(qApp->activeWindow(),
-                                           tr("Abort operation"),
-                                           aMessage,
-                                           QMessageBox::Ok | QMessageBox::Cancel,
-                                           QMessageBox::Cancel);
-      return anAnswer == QMessageBox::Ok;
-    }
-    else if (theMessageKind == XGUI_InformationMessage) {
-      QString aMessage = tr("Please validate your %1 before saving.").arg(theOperation->id());
-      QMessageBox::question(qApp->activeWindow(),
-                            tr("Validate operation"),
-                            aMessage,
-                            QMessageBox::Ok,
-                            QMessageBox::Ok);
-      return false;
-    }
+    QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
+    int anAnswer = QMessageBox::question(qApp->activeWindow(),
+                                         tr("Abort operation"),
+                                         aMessage,
+                                         QMessageBox::Ok | QMessageBox::Cancel,
+                                         QMessageBox::Cancel);
+    return anAnswer == QMessageBox::Ok;
   }
   return true;
 }
 
+bool XGUI_OperationMgr::commitOperation()
+{
+  //if (hasOperation() && currentOperation()->isValid()) {
+  //  onCommitOperation();
+  //  return true;
+  //}
+  //return false;
+  return onCommitOperation();
+}
+
 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
 {
   theOperation->resume();
@@ -440,7 +422,7 @@ void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
   }
 }
 
-bool XGUI_OperationMgr::commitOperation()
+bool XGUI_OperationMgr::onCommitOperation()
 {
   bool isCommitted = false;
   ModuleBase_Operation* anOperation = currentOperation();
index 00d941981479e68337b4ac30d16b61a8d254c81e..56286cc1fece6026f805b72ea65f5eca9925decf 100755 (executable)
@@ -48,15 +48,7 @@ class XGUI_ShortCutListener;
 class XGUI_EXPORT XGUI_OperationMgr : public QObject
 {
 Q_OBJECT
-public:
-  /// Enumeration of kind of message that is used when trying to stop the active operation
-  enum XGUI_MessageKind
-  {
-    XGUI_AbortOperationMessage, //< warns and give possibility to abort current operation
-    XGUI_InformationMessage //< ask to apply the current operation before performing something
-  };
-
-public:
+ public:
   /// Constructor
   /// \param theParent the parent
   /// \param theWorkshop a reference to workshop
@@ -95,9 +87,7 @@ public:
   /// Returns true if the operation can be aborted. If the operation is modified,
   /// the warning message box is shown.
   /// \param theOperation an operation which is checked on stop
-  /// \param theMessageKind a kind of message in warning message box
-  bool canStopOperation(ModuleBase_Operation* theOperation,
-                        const XGUI_MessageKind& theMessageKind = XGUI_AbortOperationMessage);
+  bool canStopOperation(ModuleBase_Operation* theOperation);
 
   /// Find and return operation by its Id.
   ModuleBase_Operation* findOperation(const QString& theId) const;
@@ -134,7 +124,8 @@ public:
   /// \param theOperation an aborted operation
   void abortOperation(ModuleBase_Operation* theOperation);
 
-  bool abortAllOperations(const XGUI_MessageKind& theMessageKind = XGUI_AbortOperationMessage);
+  /// Slot that commits the current operation.
+  bool onCommitOperation();
 
 public slots:
   /// Slot that aborts the current operation.
@@ -144,10 +135,7 @@ public slots:
   /// Commit all operations
   bool commitAllOperations();
   /// Abort all operations
-  void onAbortAllOperations();
-
-protected slots:
-
+  bool abortAllOperations();
 
 signals:
   /// Signal about an operation is stopped. It is emitted after the stop() of operation is done.
index 32d60c7805dcf49a17c1585c610ce841c1bbf259..0c5fcd7cf7bdc598ff054a3567b8041a4d4731fc 100644 (file)
@@ -169,9 +169,7 @@ bool canRename(const ObjectPtr& theObject, const QString& theName)
 XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop)
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
-  if (aConnector)
-    return aConnector->workshop();
-  return 0;
+  return aConnector->workshop();
 }
 
 }
index b08c24cd73015b39db537c8596c3b772a710f8cc..ec7da2e25e629aef667d9df4ca2785edef7b3b87 100755 (executable)
@@ -508,7 +508,7 @@ void XGUI_Workshop::onAcceptActionClicked()
                                                     (anOperationMgr->currentOperation());
     if (aFOperation) {
       //if (errorMgr()->canProcessClick(anAction, aFOperation->feature()))
-      myOperationMgr->commitOperation();
+      myOperationMgr->onCommitOperation();
     }
   }
 }
@@ -776,6 +776,12 @@ void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>&
   QApplication::restoreOverrideCursor();
 }
 
+//******************************************************
+bool XGUI_Workshop::abortAllOperations()
+{
+  return myOperationMgr->abortAllOperations();
+}
+
 //******************************************************
 void XGUI_Workshop::operationStarted(ModuleBase_Operation* theOperation)
 {
@@ -791,7 +797,7 @@ void XGUI_Workshop::operationStarted(ModuleBase_Operation* theOperation)
 //******************************************************
 void XGUI_Workshop::onOpen()
 {
-  if(!myOperationMgr->abortAllOperations())
+  if(!abortAllOperations())
     return;
   //save current file before close if modified
   SessionPtr aSession = ModelAPI_Session::get();
@@ -921,7 +927,7 @@ void XGUI_Workshop::onTrihedronVisibilityChanged(bool theState)
 //******************************************************
 bool XGUI_Workshop::onSave()
 {
-  if(!myOperationMgr->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
+  if(!abortAllOperations())
     return false;
   if (myCurrentDir.isEmpty()) {
     return onSaveAs();
@@ -938,7 +944,7 @@ bool XGUI_Workshop::onSave()
 //******************************************************
 bool XGUI_Workshop::onSaveAs()
 {
-  if(!myOperationMgr->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
+  if(!abortAllOperations())
     return false;
   QFileDialog dialog(desktop());
   dialog.setWindowTitle(tr("Select directory to save files..."));
@@ -1466,7 +1472,7 @@ void XGUI_Workshop::deleteObjects()
   }
 
   QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
-  if (!myOperationMgr->abortAllOperations())
+  if (!abortAllOperations())
     return;
 
   bool hasResult = false;
@@ -1533,7 +1539,7 @@ void addRefsToFeature(const FeaturePtr& theFeature,
 //**************************************************************
 void XGUI_Workshop::cleanHistory()
 {
-  if (!myOperationMgr->abortAllOperations())
+  if (!abortAllOperations())
     return;
 
   QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
@@ -1659,7 +1665,7 @@ void XGUI_Workshop::cleanHistory()
 //**************************************************************
 void XGUI_Workshop::moveObjects()
 {
-  if (!myOperationMgr->abortAllOperations())
+  if (!abortAllOperations())
     return;
 
   SessionPtr aMgr = ModelAPI_Session::get();
@@ -1900,7 +1906,7 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   if (aColor.size() != 3)
     return;
 
-  if (!myOperationMgr->abortAllOperations())
+  if (!abortAllOperations())
   return;
   // 2. show the dialog to change the value
   XGUI_ColorDialog* aDlg = new XGUI_ColorDialog(desktop());
@@ -1990,7 +1996,7 @@ void XGUI_Workshop::changeDeflection(const QObjectPtrList& theObjects)
   if (aDeflection < 0)
     return;
 
-  if (!myOperationMgr->abortAllOperations())
+  if (!abortAllOperations())
   return;
   // 2. show the dialog to change the value
   XGUI_DeflectionDialog* aDlg = new XGUI_DeflectionDialog(desktop());
index e275f8408c154679f69abc3b74e416202ab8ba58..0f0c350fd4cd455a1662df74bce6472c3e2881c8 100755 (executable)
@@ -265,11 +265,20 @@ Q_OBJECT
   */
   void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
 
+  /**
+   * If there is an active (uncommitted) operation shows a prompt to abort it
+   * and performs abortion if user agreed. Returns true if
+   * - operation aborted successfully
+   * - there is no active operation
+   */
+  bool abortAllOperations();
+
   /// Updates workshop state according to the started operation, e.g. visualizes the property panel
   /// and connect to it.
   /// \param theOpertion a started operation
   void operationStarted(ModuleBase_Operation* theOperation);
 
+
   //! Delete features. Delete the referenced features. There can be a question with a list of
   //! referenced objects.
   //! \param theFeatures a list of objects to be deleted