]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Sat, 21 Jun 2014 08:52:41 +0000 (12:52 +0400)
committernds <natalia.donis@opencascade.com>
Sat, 21 Jun 2014 08:52:41 +0000 (12:52 +0400)
1. Edit radius feature(change the feature's position in the circle)

src/PartSet/PartSet_OperationCreateConstraint.cpp
src/PartSet/PartSet_OperationEditConstraint.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h

index 576cf40098248ca91c21d8918177375d54d62600..a5f54997e252171af91fd78de1d0d90930497737 100644 (file)
@@ -19,8 +19,6 @@
 #include <SketchPlugin_Arc.h>
 */
 
-#include <PartSet_ConstraintLengthPrs.h>
-#include <PartSet_ConstraintDistancePrs.h>
 #include <PartSet_ConstraintRadiusPrs.h>
 
 #include <SketchPlugin_Constraint.h>
@@ -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
index 0fb85e9866328e813e99686279eb2d29ef7e03ba..d617b365aa4f6efbb4be8ca54a7fdc818c9a7356 100644 (file)
@@ -7,7 +7,9 @@
 #include <PartSet_OperationSketch.h>
 #include <PartSet_EditLine.h>
 #include <PartSet_FeaturePrs.h>
-#include <SketchPlugin_ConstraintLength.h>
+#include <PartSet_ConstraintRadiusPrs.h>
+
+#include <SketchPlugin_Constraint.h>
 
 #include <ModuleBase_OperationDescription.h>
 #include <Model_Events.h>
@@ -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<PartSet_ConstraintRadiusPrs> anArcPrs =
+                              boost::dynamic_pointer_cast<PartSet_ConstraintRadiusPrs>(myFeaturePrs);
+      if (anArcPrs) {
+        anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
+      }
+    }
     myFeaturePrs->setPoint(aX, anY, SM_SecondPoint);
 
 
index ca9a6ac1e3757a2e43c5cd993005a78c14e44a1d..2da18786e8835ea8c220f5dd8cbe9143270a03bb 100644 (file)
@@ -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;
 }
index 840a64df6f031a5bc90e4f8ccb2399b11ee8bb4d..60396b8146cb94edf019f9132ee383942275f1b5 100644 (file)
@@ -3,10 +3,9 @@
 // Author:      Natalia ERMOLAEVA
 
 #include <PartSet_OperationSketchBase.h>
+#include <PartSet_Tools.h>
 
 #include <SketchPlugin_Feature.h>
-#include <SketchPlugin_ConstraintLength.h>
-
 #include <V3d_View.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_DimensionSelectionMode.hxx>
@@ -48,7 +47,7 @@ std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
 std::list<int> PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const
 {
   std::list<int> 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);
index 45b994e524126691a086cd1816b4c9d6b57ac00f..8829dce4f4b6cf02f8250ad15fdbb9a23727f24b 100644 (file)
@@ -348,3 +348,10 @@ boost::shared_ptr<GeomAPI_Pnt> 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
index d43feb7bfc329a18620783226076a6bc78336fcd..deb4b4910756739355f004ce456af0dbe9ce8321 100644 (file)
@@ -125,6 +125,11 @@ public:
   /// \return API object of point 3D
   static boost::shared_ptr<GeomAPI_Pnt> point3D(boost::shared_ptr<GeomAPI_Pnt2d> 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