Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into Dev_2.8.0
authorazv <azv@opencascade.com>
Thu, 21 Sep 2017 07:06:06 +0000 (10:06 +0300)
committerazv <azv@opencascade.com>
Thu, 21 Sep 2017 07:06:06 +0000 (10:06 +0300)
# Conflicts:
# CMakeCommon/FindTInspector.cmake
# env.sh
# src/GeomAPI/GeomAPI_Edge.cpp
# src/Model/Model_AttributeSelection.cpp
# src/ModelAPI/ModelAPI_Events.cpp
# src/PythonAPI/model/sketcher/tools.py
# src/SketchAPI/SketchAPI_Sketch.cpp
# src/SketchPlugin/CMakeLists.txt
# src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.cpp
# src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.h
# src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.cpp
# src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.h
# src/SketchPlugin/SketchPlugin_Ellipse.cpp
# src/SketchPlugin/SketchPlugin_Ellipse.h
# src/SketchPlugin/SketchPlugin_MacroEllipse.h
# src/SketchSolver/SketchSolver_ConstraintDistance.cpp
# src/SketchSolver/SketchSolver_ConstraintMovement.cpp
# src/SketchSolver/SketchSolver_Manager.cpp
# src/XGUI/XGUI_Workshop.cpp

21 files changed:
1  2 
CMakeLists.txt
src/GeomAPI/GeomAPI_Edge.cpp
src/GeomAPI/GeomAPI_Edge.h
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/ModelAPI/CMakeLists.txt
src/ModuleBase/ModuleBase_WidgetEditor.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PythonAPI/model/sketcher/tools.py
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Manager.cpp
src/SketchSolver/SketchSolver_Manager.h
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp

diff --cc CMakeLists.txt
Simple merge
Simple merge
index 59b36c04207fe3d9b0685942fb42aac4b0a0989f,f4fd1add6163b04950a9f57e8be1c3339bfff4e7..ce0f7b559d18e0f1b9d830af6e6d3d5d94879970
@@@ -96,10 -87,15 +96,18 @@@ public
    /// Returns edge length.
    GEOMAPI_EXPORT
    double length() const;
+   /// Returns true if the edge is closed (like full circle)
+   GEOMAPI_EXPORT
+   bool isClosed() const;
+   /// Returns true if the edge is degenerated (has no 3D curve)
+   GEOMAPI_EXPORT
+   bool isDegenerated() const;
  };
  
 +//! Pointer on attribute object
 +typedef std::shared_ptr<GeomAPI_Edge> GeomEdgePtr;
 +
  #endif
  
index 63614449c11b40b2bd277cceb1e42c5908310cbe,f26270a9fcbe8109f7cbe30112e849caf40dfff4..15d910ede504ec9add4d72d034a11497e94fa5f8
@@@ -760,68 -633,47 +758,68 @@@ void Model_AttributeSelection::selectSu
  {
    if(theSubShapeName.empty() || theType.empty()) return;
  
 -  // check this is Part-name: 2 delimiters in the name
 -  std::size_t aPartEnd = theSubShapeName.find('/');
 -  if (aPartEnd != std::string::npos && aPartEnd != theSubShapeName.rfind('/')) {
 -    std::string aPartName = theSubShapeName.substr(0, aPartEnd);
 -    ObjectPtr aFound = owner()->document()->objectByName(ModelAPI_ResultPart::group(), aPartName);
 -    if (aFound.get()) { // found such part, so asking it for the name
 -      ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aFound);
 -      std::string aNameInPart = theSubShapeName.substr(aPartEnd + 1);
 -      int anIndex;
 -      std::shared_ptr<GeomAPI_Shape> aSelected = aPart->shapeInPart(aNameInPart, theType, anIndex);
 -      if (aSelected.get()) {
 -        setValue(aPart, aSelected);
 -        TDataStd_Integer::Set(selectionLabel(), anIndex);
 -        return;
 +  std::string aSubShapeName = theSubShapeName;
 +  CenterType aCenterType = theType[0] == 'v' || theType[0] == 'V' ? // only for vertex-type
 +    centerTypeByName(aSubShapeName) : NOT_CENTER;
 +  std::string aType = aCenterType == NOT_CENTER ? theType : "EDGE"; // search for edge now
 +
 +  // first iteration is selection by name without center prefix, second - in case of problem,
 +  // try with initial name
 +  for(int aUseCenter = 1; aUseCenter >= 0; aUseCenter--) {
 +    if (aUseCenter == 0 && aCenterType != NOT_CENTER) {
 +      aSubShapeName = theSubShapeName;
 +      aCenterType = NOT_CENTER;
 +      aType = theType;
 +    } else if (aUseCenter != 1) continue;
 +
 +    // check this is Part-name: 2 delimiters in the name
 +    std::size_t aPartEnd = aSubShapeName.find('/');
 +    if (aPartEnd != std::string::npos && aPartEnd != aSubShapeName.rfind('/')) {
 +      std::string aPartName = aSubShapeName.substr(0, aPartEnd);
 +      ObjectPtr aFound = owner()->document()->objectByName(ModelAPI_ResultPart::group(), aPartName);
 +      if (aFound.get()) { // found such part, so asking it for the name
 +        ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aFound);
 +        std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1);
 +        int anIndex;
 +        std::shared_ptr<GeomAPI_Shape> aSelected = aPart->shapeInPart(aNameInPart, aType, anIndex);
 +        if (aSelected.get()) {
 +          if (aCenterType != NOT_CENTER) {
 +            if (!aSelected->isEdge())
 +              continue;
 +            std::shared_ptr<GeomAPI_Edge> aSelectedEdge(new GeomAPI_Edge(aSelected));
 +            setValueCenter(aPart, aSelectedEdge, aCenterType);
 +          } else
 +            setValue(aPart, aSelected);
 +          TDataStd_Integer::Set(selectionLabel(), anIndex);
 +          return;
 +        }
        }
      }
 -  }
  
 -  Model_SelectionNaming aSelNaming(selectionLabel());
 -  std::shared_ptr<Model_Document> aDoc =
 -    std::dynamic_pointer_cast<Model_Document>(owner()->document());
 -  std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected;
 -  ResultPtr aCont;
 -  if (aSelNaming.selectSubShape(theType, theSubShapeName, aDoc, aShapeToBeSelected, aCont)) {
 -    // try to find the last context to find the up to date shape
 -    if (aCont->shape().get() && !aCont->shape()->isNull() &&
 -      aCont->groupName() == ModelAPI_ResultBody::group() && aDoc == owner()->document()) {
 -      const TopoDS_Shape aConShape = aCont->shape()->impl<TopoDS_Shape>();
 -      if (!aConShape.IsNull()) {
 -        Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aConShape, selectionLabel());
 -        if (!aNS.IsNull()) {
 -          aNS = TNaming_Tool::CurrentNamedShape(aNS);
 +    Model_SelectionNaming aSelNaming(selectionLabel());
 +    std::shared_ptr<Model_Document> aDoc =
 +      std::dynamic_pointer_cast<Model_Document>(owner()->document());
 +    std::shared_ptr<GeomAPI_Shape> aShapeToBeSelected;
 +    ResultPtr aCont;
 +    if (aSelNaming.selectSubShape(aType, aSubShapeName, aDoc, aShapeToBeSelected, aCont)) {
 +      // try to find the last context to find the up to date shape
 +      if (aCont->shape().get() && !aCont->shape()->isNull() &&
 +        aCont->groupName() == ModelAPI_ResultBody::group() && aDoc == owner()->document()) {
 +        const TopoDS_Shape aConShape = aCont->shape()->impl<TopoDS_Shape>();
 +        if (!aConShape.IsNull()) {
 +          Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aConShape, selectionLabel());
-           if (!aNS.IsNull()) {
+           if (!aNS.IsNull() && scope().Contains(aNS->Label())) { // scope check is for 2228
 -            TDF_Label aLab = aNS->Label();
 -            while(aLab.Depth() != 7 && aLab.Depth() > 5)
 -              aLab = aLab.Father();
 -            ObjectPtr anObj = aDoc->objects()->object(aLab);
 -            if (anObj.get()) {
 -              ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
 -              if (aRes)
 -                aCont = aRes;
 +            aNS = TNaming_Tool::CurrentNamedShape(aNS);
 +            if (!aNS.IsNull()) {
 +              TDF_Label aLab = aNS->Label();
 +              while(aLab.Depth() != 7 && aLab.Depth() > 5)
 +                aLab = aLab.Father();
 +              ObjectPtr anObj = aDoc->objects()->object(aLab);
 +              if (anObj.get()) {
 +                ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
 +                if (aRes)
 +                  aCont = aRes;
 +              }
              }
            }
          }
Simple merge
Simple merge
Simple merge
Simple merge
index f3dcdb37a819049f03f325aa1c3e9e48d3783369,de3032f54d16bae221e821bfa78cb0d68c397e36..5c1903a062196d3e71b4565a7f993cd9e097b01b
@@@ -71,24 -69,14 +69,28 @@@ 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])
+     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 signedDistancePointLine(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 aCross / aLineLen
 +
 +def distancePointLine(thePoint, theLine):
 +    return math.fabs(signedDistancePointLine(thePoint, theLine))
 +
  def lastSubFeature(theSketch, theKind):
      """
      obtains last feature of given kind from the sketch
index e5b9bc0ca868d214cbaf3e16e0ac86e002f9c4d7,ba06dbe55faa650a1fec3ded65150e0f93f9d63d..7c89b5e5c2f6270098d37e92824cdda19841089f
@@@ -31,9 -31,8 +31,10 @@@ SET(PROJECT_HEADER
      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
      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
@@@ -76,9 -72,8 +76,10 @@@ SET(PROJECT_SOURCE
      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
      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
@@@ -212,21 -199,6 +212,23 @@@ ADD_UNIT_TESTS(TestSketchPointLine.p
                 TestTrimCircleAndArc01.py
                 TestTrimLine01.py
                 TestTrimLine02.py
+                Test2229.py
+                Test2239.py
 +               TestDistanceSignedVsUnsigned01.py
 +               TestDistanceSignedVsUnsigned02.py
 +               TestDistanceSignedVsUnsigned03.py
 +               TestDistanceSignedVsUnsigned04.py
 +               TestDistanceSignedVsUnsigned05.py
 +               TestSignedDistancePointPoint.py
 +               TestSignedDistancePointLine.py
  )
 +
 +if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE})
 +  ADD_UNIT_TESTS(
 +               TestMovePoint.py
 +               TestMoveLine.py
 +               TestMoveCircle.py
 +               TestMoveArc.py
 +               TestMovementComplex.py
 +  )
 +endif()
Simple merge
index 506c8e46d99a9341a1dc2c983eae606e5f88f27c,70161208fb1c1333f59889e5c1f7622ddcb46127..4921a4d0322ae32e01d8d6d9c60174739ff59aae
@@@ -189,10 -196,11 +196,11 @@@ void SketchSolver_Manager::processEvent
  }
  
  // ============================================================================
 -//  Function: changeConstraintOrEntity
 +//  Function: updateFeature
- //  Purpose:  create/update constraint or feature in appropriate group
+ //  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.
index 105cc0e97ae1b503195b9efddd7b7969107ffbd9,45c1a4284bbaff4df86690f1669785e1dd0cb923..d3509c7078f33cee6d7ab049de1f4a3adf2b3e9d
@@@ -64,30 -61,11 +64,31 @@@ 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);
+   bool updateFeature(std::shared_ptr<SketchPlugin_Feature> theFeature, bool theMoved = false);
  
 +  /** \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);
 +
    /** \brief Removes a constraint from the manager
     *  \param[in] theConstraint constraint to be removed
     *  \return \c true if the constraint removed successfully
Simple merge
Simple merge