From: nds Date: Sat, 21 Jun 2014 08:52:41 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~271 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9e13b623ba4b01a718693653ff25f2b84dff956d;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc 1. Edit radius feature(change the feature's position in the circle) --- diff --git a/src/PartSet/PartSet_OperationCreateConstraint.cpp b/src/PartSet/PartSet_OperationCreateConstraint.cpp index 576cf4009..a5f54997e 100644 --- a/src/PartSet/PartSet_OperationCreateConstraint.cpp +++ b/src/PartSet/PartSet_OperationCreateConstraint.cpp @@ -19,8 +19,6 @@ #include */ -#include -#include #include #include @@ -64,9 +62,7 @@ PartSet_OperationCreateConstraint::~PartSet_OperationCreateConstraint() bool PartSet_OperationCreateConstraint::canProcessKind(const std::string& theId) { // changed - return theId == PartSet_ConstraintLengthPrs::getKind() || - theId == PartSet_ConstraintDistancePrs::getKind() || - theId == PartSet_ConstraintRadiusPrs::getKind(); + return PartSet_Tools::isConstraintFeature(theId); } bool PartSet_OperationCreateConstraint::canBeCommitted() const diff --git a/src/PartSet/PartSet_OperationEditConstraint.cpp b/src/PartSet/PartSet_OperationEditConstraint.cpp index 0fb85e986..d617b365a 100644 --- a/src/PartSet/PartSet_OperationEditConstraint.cpp +++ b/src/PartSet/PartSet_OperationEditConstraint.cpp @@ -7,7 +7,9 @@ #include #include #include -#include +#include + +#include #include #include @@ -147,6 +149,13 @@ void PartSet_OperationEditConstraint::mouseMoved(QMouseEvent* theEvent, Handle(V double aDeltaY = anY - aCurY; PartSet_Tools::moveFeature(feature(), aDeltaX, aDeltaY);*/ + if (feature()->getKind() == PartSet_ConstraintRadiusPrs::getKind()) { + boost::shared_ptr anArcPrs = + boost::dynamic_pointer_cast(myFeaturePrs); + if (anArcPrs) { + anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY); + } + } myFeaturePrs->setPoint(aX, anY, SM_SecondPoint); diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index ca9a6ac1e..2da18786e 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -242,8 +242,8 @@ std::string PartSet_OperationSketch::getOperationType(FeaturePtr theFeature) { std::string aType = PartSet_OperationEditFeature::Type(); - if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) + if (PartSet_Tools::isConstraintFeature(theFeature->getKind())) { aType = PartSet_OperationEditConstraint::Type(); - + } return aType; } diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 840a64df6..60396b814 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -3,10 +3,9 @@ // Author: Natalia ERMOLAEVA #include +#include #include -#include - #include #include #include @@ -48,7 +47,7 @@ std::map > std::list PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const { std::list aModes; - if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) { + if (PartSet_Tools::isConstraintFeature(theFeature->getKind())) { aModes.clear(); aModes.push_back(AIS_DSM_Text); aModes.push_back(AIS_DSM_Line); diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 45b994e52..8829dce4f 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -348,3 +348,10 @@ boost::shared_ptr PartSet_Tools::point3D( return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir()); } + +bool PartSet_Tools::isConstraintFeature(const std::string& theKind) +{ + return theKind == PartSet_ConstraintLengthPrs::getKind() || + theKind == PartSet_ConstraintDistancePrs::getKind() || + theKind == PartSet_ConstraintRadiusPrs::getKind(); +} \ No newline at end of file diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index d43feb7bf..deb4b4910 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -125,6 +125,11 @@ public: /// \return API object of point 3D static boost::shared_ptr point3D(boost::shared_ptr thePoint2D, FeaturePtr theSketch); + /// Check whether there is a constraint with the feature kind given + /// \param theKind a feature kind + /// \return the boolean value + static bool isConstraintFeature(const std::string& theKind); + private: /// Return the distance between the feature and the point /// \param theFeature feature object