From: nds Date: Fri, 18 Mar 2016 04:20:46 +0000 (+0300) Subject: Issue 1299 Angle presentation: 1. flyout point for AIS angle is always positive to... X-Git-Tag: V_2.3.0~376 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6c4c5bf56e0a0a3de9eb00552a06327c0213614d;p=modules%2Fshaper.git Issue 1299 Angle presentation: 1. flyout point for AIS angle is always positive to do not revert the visible arc depending on mouse position; 2. regression correction for edit angle value by double click on the angle; 3. correction for XoZ selected in viewer: additional arc was shown for direct angle. It is corrected by taking into account the normal direction of the current sketch plane. --- diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 869ee082b..236124f63 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -611,7 +611,8 @@ void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMo QList aWidgets = aPanel->modelWidgets(); // Find corresponded widget to activate value editing foreach (ModuleBase_ModelWidget* aWgt, aWidgets) { - if (aWgt->attributeID() == "ConstraintValue") { + if (aWgt->attributeID() == "ConstraintValue" || + aWgt->attributeID() == "AngleValue") { PartSet_WidgetEditor* anEditor = dynamic_cast(aWgt); if (anEditor) anEditor->showPopupEditor(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp index 348abe242..728d7dfd1 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp @@ -190,19 +190,32 @@ double SketchPlugin_ConstraintAngle::calculateAngle() if (aDirAngle < 0) aDirAngle += 2.0 * PI; anAngle = fabs(aDirAngle) * 180.0 / PI; - //anAngle = fabs(aDirA->angle(aDirB)) * 180.0 / PI; + /// an angle value should be corrected by the current angle type + anAngle = getAngleForType(anAngle); + return anAngle; +} + +double SketchPlugin_ConstraintAngle::getAngleForType(double theAngle) +{ + double anAngle = theAngle; + + std::shared_ptr aPlane = SketchPlugin_Sketch::plane(sketch()); + std::shared_ptr aNormal = aPlane->normal(); + bool aPositiveNormal = !(aNormal->x() < 0 || aNormal->y() < 0 || aNormal->z() < 0); + std::shared_ptr aData = data(); std::shared_ptr aTypeAttr = std::dynamic_pointer_cast< ModelAPI_AttributeInteger>(aData->attribute(SketchPlugin_ConstraintAngle::TYPE_ID())); SketcherPrs_Tools::AngleType anAngleType = (SketcherPrs_Tools::AngleType)(aTypeAttr->value()); switch (anAngleType) { case SketcherPrs_Tools::ANGLE_DIRECT: + anAngle = aPositiveNormal ? theAngle : 360 - theAngle; break; case SketcherPrs_Tools::ANGLE_COMPLEMENTARY: - anAngle = 180 - anAngle; + anAngle = 180 - theAngle; break; case SketcherPrs_Tools::ANGLE_BACKWARD: - anAngle = 360 - anAngle; + anAngle = aPositiveNormal ? 360 - theAngle : theAngle; break; default: break; @@ -216,22 +229,8 @@ void SketchPlugin_ConstraintAngle::updateAngleValue() ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID())); double anAngle = aValueAttr->value(); - std::shared_ptr aData = data(); - std::shared_ptr aTypeAttr = std::dynamic_pointer_cast< - ModelAPI_AttributeInteger>(aData->attribute(SketchPlugin_ConstraintAngle::TYPE_ID())); - SketcherPrs_Tools::AngleType anAngleType = (SketcherPrs_Tools::AngleType)(aTypeAttr->value()); - switch (anAngleType) { - case SketcherPrs_Tools::ANGLE_DIRECT: - break; - case SketcherPrs_Tools::ANGLE_COMPLEMENTARY: - anAngle = 180 - anAngle; - break; - case SketcherPrs_Tools::ANGLE_BACKWARD: - anAngle = 360 - anAngle; - break; - default: - break; - } + /// an angle value should be corrected by the current angle type + anAngle = getAngleForType(anAngle); aValueAttr = std::dynamic_pointer_cast< ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); aValueAttr->setValue(anAngle); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintAngle.h b/src/SketchPlugin/SketchPlugin_ConstraintAngle.h index c0f1c712c..d3dd5c8ad 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintAngle.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintAngle.h @@ -78,6 +78,12 @@ class SketchPlugin_ConstraintAngle : public SketchPlugin_ConstraintBase /// Calculate current value of the angle double calculateAngle(); + /// Converts the angle value according to the current angle type and sketch plane normal. + /// The in/out angle is in degree. + /// \param theAngle a source for the calculated angle + /// \param a double angle value + double getAngleForType(double theAngle); + /// Update value of VALUE attribute by the combination of the current angle type and angle value void updateAngleValue(); diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 2d4e5838e..d26d5999c 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -154,6 +154,8 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP gp_Pnt aFlyPnt(aFlyoutPnt->x(), aFlyoutPnt->y(), aFlyoutPnt->z()); gp_XYZ aFlyDir = aFlyPnt.XYZ() - aCenter.XYZ(); double aDist = aFlyDir.Dot(aBisector.XYZ()); + // make a positive distance in order to AIS angle presentation is not reversed + aDist = fabs(aDist); SetFlyout(aDist); // Angle value is in degrees