Salome HOME
Issue 1299 Angle constraint: support of additional and complementary angles
authornds <nds@opencascade.com>
Fri, 11 Mar 2016 11:48:38 +0000 (14:48 +0300)
committernds <nds@opencascade.com>
Fri, 11 Mar 2016 11:48:38 +0000 (14:48 +0300)
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/angle_backward.png [new file with mode: 0755]
src/PartSet/icons/angle_direct.png [new file with mode: 0755]
src/PartSet/icons/angle_supplementary.png [new file with mode: 0755]
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchPlugin/SketchPlugin_ConstraintAngle.h
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/SketcherPrs_Angle.cpp
src/SketcherPrs/SketcherPrs_Angle.h
src/XGUI/XGUI_Workshop.cpp

index 150fffa4f01355654e0636c947055926db0f97f9..da666716b567f7cdd8e91a747b25f7b7ea4ae600 100644 (file)
@@ -2,8 +2,11 @@
  <qresource>
      <file>icons/angle.png</file>
      <file>icons/angle_32x32.png</file>
+     <file>icons/angle_backward.png</file>
      <file>icons/angle_up.png</file>
+     <file>icons/angle_direct.png</file>
      <file>icons/angle_down.png</file>
+     <file>icons/angle_supplementary.png</file>
      <file>icons/arc.png</file>
      <file>icons/arc_base_32x32.png</file>
      <file>icons/arc_3pt_32x32.png</file>
diff --git a/src/PartSet/icons/angle_backward.png b/src/PartSet/icons/angle_backward.png
new file mode 100755 (executable)
index 0000000..827c193
Binary files /dev/null and b/src/PartSet/icons/angle_backward.png differ
diff --git a/src/PartSet/icons/angle_direct.png b/src/PartSet/icons/angle_direct.png
new file mode 100755 (executable)
index 0000000..286604e
Binary files /dev/null and b/src/PartSet/icons/angle_direct.png differ
diff --git a/src/PartSet/icons/angle_supplementary.png b/src/PartSet/icons/angle_supplementary.png
new file mode 100755 (executable)
index 0000000..7588fe7
Binary files /dev/null and b/src/PartSet/icons/angle_supplementary.png differ
index ef711f6a5af03db16b692cfa6eba9e1d02208da9..06ba782385e7f0ccf65ff3cd24516a1374b20262 100644 (file)
@@ -8,6 +8,8 @@
 #include <SketchPlugin_Line.h>
 
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
+
 #include <GeomDataAPI_Point2D.h>
 
 #include <GeomAPI_Dir2d.h>
@@ -38,6 +40,8 @@ void SketchPlugin_ConstraintAngle::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+
+  data()->addAttribute(SketchPlugin_ConstraintAngle::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
 }
 
 void SketchPlugin_ConstraintAngle::colorConfigInfo(std::string& theSection, std::string& theName,
index edc5209a3eec2ad30fa433129c015df5b5c1072a..ed593ab5ebb3ab355a8a40cd0d36a992f8c761a0 100644 (file)
@@ -34,6 +34,13 @@ class SketchPlugin_ConstraintAngle : public SketchPlugin_ConstraintBase
     return MY_KIND;
   }
 
+  /// attribute name of operation type
+  inline static const std::string& TYPE_ID()
+  {
+    static const std::string MY_TYPE_ID("angle_type");
+    return MY_TYPE_ID;
+  }
+
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 5f55de2c64bea4a32f94b157f2a8a9b0bbf2a96c..ff043b78bbabd0b9229b8e5db68a6acfd1052e74 100644 (file)
         <sketch-2dpoint_flyout_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Angle" id="ConstraintValue" default="computed" min="0" max="180" />
         <validator id="PartSet_AngleSelection"/>
+        <module_choice id="angle_type"
+          widget_type="radiobuttons"
+          buttons_dir="horizontal"
+          label="Operation type"
+          tooltip="Type of angle"
+          string_list="Direct Supplementary Backward"
+          icons_list=":icons/angle_direct.png :icons/angle_supplementary.png :icons/angle_backward.png"
+          default="0"
+          />
+
       </feature>
 
       <!--  SketchConstraintParallel  -->
index 30a95f51f061585b07561d0624e28a398b48305c..e56205f147350e237d2900ea49470efc43722b53 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 
 #include <TopExp.hxx>
 #include <BRep_Tool.hxx>
@@ -87,6 +88,10 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
     return; // can not create a good presentation
   }
 
+  std::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = std::dynamic_pointer_cast<
+      ModelAPI_AttributeInteger>(aData->attribute(SketchPlugin_ConstraintAngle::TYPE_ID()));
+  AngleType anAngleType = (AngleType)(aTypeAttr->value());
+
   // Flyout point
   std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = 
     std::dynamic_pointer_cast<GeomDataAPI_Point2D>
@@ -108,7 +113,24 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
 
   TopoDS_Edge aEdge1 = TopoDS::Edge(aTEdge1);
   TopoDS_Edge aEdge2 = TopoDS::Edge(aTEdge2);
-  SetMeasuredGeometry(aEdge1, aEdge2);
+
+  switch (anAngleType) {
+    case ANGLE_DIRECT: {
+      SetMeasuredGeometry(aEdge1, aEdge2);
+    }
+    break;
+    case ANGLE_SUPPLEMENTARY: {
+      SetMeasuredGeometry(aEdge1, aEdge2);
+      }
+      break;
+    case ANGLE_BACKWARD: {
+      SetMeasuredGeometry(aEdge2, aEdge1);
+      }
+      break;
+    default:
+      break;
+  }
+
 
   const gp_Pnt& aCenter = CenterPoint();
   const gp_Pnt& aFirst = FirstPoint();
index 0d87c02e3bc71cf56c8257d7a24d7bbd82be1431..343841feb700cb44ad7f25542a638b59b6f5aae7 100644 (file)
@@ -22,6 +22,14 @@ DEFINE_STANDARD_HANDLE(SketcherPrs_Angle, AIS_AngleDimension)
 */
 class SketcherPrs_Angle : public AIS_AngleDimension
 {
+public:
+  /// Type of angle
+  enum AngleType{
+    ANGLE_DIRECT,   ///< Angle from the first line to the second line
+    ANGLE_SUPPLEMENTARY,  ///< Additional angle to the angle from first to second line
+    ANGLE_BACKWARD ///< Angle from the second line to the first line
+  };
+
 public:
   /// Constructor
   /// \param theConstraint a constraint feature
index aae4d3c750ba328f8e278fb7906bce2811810a7c..73894bc4b4878c30045cd16f82f814ee7ebeb333 100755 (executable)
@@ -885,7 +885,8 @@ void XGUI_Workshop::onValuesChanged()
   if (anActiveWidget) {
     ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
                                                                            (anActiveWidget);
-    aWidgetValidated->clearValidatedCash();
+    if (aWidgetValidated)
+      aWidgetValidated->clearValidatedCash();
   }
 }