From aa1e867b683884e6d9caa57eda49614b36d509ac Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 11 Mar 2016 14:48:38 +0300 Subject: [PATCH] Issue 1299 Angle constraint: support of additional and complementary angles --- src/PartSet/PartSet_icons.qrc | 3 +++ src/PartSet/icons/angle_backward.png | Bin 0 -> 1093 bytes src/PartSet/icons/angle_direct.png | Bin 0 -> 640 bytes src/PartSet/icons/angle_supplementary.png | Bin 0 -> 792 bytes .../SketchPlugin_ConstraintAngle.cpp | 4 +++ .../SketchPlugin_ConstraintAngle.h | 7 +++++ src/SketchPlugin/plugin-Sketch.xml | 10 ++++++++ src/SketcherPrs/SketcherPrs_Angle.cpp | 24 +++++++++++++++++- src/SketcherPrs/SketcherPrs_Angle.h | 8 ++++++ src/XGUI/XGUI_Workshop.cpp | 3 ++- 10 files changed, 57 insertions(+), 2 deletions(-) create mode 100755 src/PartSet/icons/angle_backward.png create mode 100755 src/PartSet/icons/angle_direct.png create mode 100755 src/PartSet/icons/angle_supplementary.png diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index 150fffa4f..da666716b 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -2,8 +2,11 @@ icons/angle.png icons/angle_32x32.png + icons/angle_backward.png icons/angle_up.png + icons/angle_direct.png icons/angle_down.png + icons/angle_supplementary.png icons/arc.png icons/arc_base_32x32.png icons/arc_3pt_32x32.png diff --git a/src/PartSet/icons/angle_backward.png b/src/PartSet/icons/angle_backward.png new file mode 100755 index 0000000000000000000000000000000000000000..827c193ec9358aae6569aba034443df70e9b79f2 GIT binary patch literal 1093 zcmV-L1iJf)P)s^0UyaOFKL7#<& z|J*zX?kL3D;CH7Qvz`H};Ak0SUxc^Uv#w)w!NeypK^l#@oe~Rz!8{djK-Df6HH9j6 zHYy`v|7J;U@BV1#-tCb09vlN~r*&mDfIu&}NM8xp$%Gj*|l0EW5)3uBaYdOMpf21;Q8nfyO$g{5^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B+x7Zq0&c%vtRxK%N#)nJd+)3?(cruXL=POX8{jX}wXz(yruSwR>v>i+K1gnZ z$Q2ll##2uHa4306D7nw-p954wLmoJ~;8ZjLe&Y$~6&_8$Zd2xHg3v7pVdF?oWy%D^ zVP(pCJK|kXw-yq*;4%=2CIA4LB_%$0pnRrd_Fo#|TL(neKx(w!62LHAx)3zm5mrLg zCdg=oJFj7EP62>CVe-n3umnyFgL(*iqcsO`dbQG(O0iU#^q}i5ZzvR}!f9e~d|*5^ zJw0u#wROl-RGKx|)$;k*UI>L-VEF({Y=dh-Fup_Bj&U!Xya{biL&>v3%05M8PewTI zg`pC65bBseP3br%H%acG(|N7E7j;R^ #include +#include + #include #include @@ -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, diff --git a/src/SketchPlugin/SketchPlugin_ConstraintAngle.h b/src/SketchPlugin/SketchPlugin_ConstraintAngle.h index edc5209a3..ed593ab5e 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintAngle.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintAngle.h @@ -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(); diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 5f55de2c6..ff043b78b 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -206,6 +206,16 @@ + + diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 30a95f51f..e56205f14 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -87,6 +88,10 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP return; // can not create a good presentation } + std::shared_ptr aTypeAttr = std::dynamic_pointer_cast< + ModelAPI_AttributeInteger>(aData->attribute(SketchPlugin_ConstraintAngle::TYPE_ID())); + AngleType anAngleType = (AngleType)(aTypeAttr->value()); + // Flyout point std::shared_ptr aFlyoutAttr = std::dynamic_pointer_cast @@ -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(); diff --git a/src/SketcherPrs/SketcherPrs_Angle.h b/src/SketcherPrs/SketcherPrs_Angle.h index 0d87c02e3..343841feb 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.h +++ b/src/SketcherPrs/SketcherPrs_Angle.h @@ -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 diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index aae4d3c75..73894bc4b 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -885,7 +885,8 @@ void XGUI_Workshop::onValuesChanged() if (anActiveWidget) { ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast (anActiveWidget); - aWidgetValidated->clearValidatedCash(); + if (aWidgetValidated) + aWidgetValidated->clearValidatedCash(); } } -- 2.39.2