Salome HOME
Merge branch 'master' of newgeom:newgeom
authornds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 14:08:33 +0000 (18:08 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 14:08:33 +0000 (18:08 +0400)
26 files changed:
src/Model/Model_Data.cpp
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/PartSet/PartSet_ConstraintDistancePrs.cpp
src/PartSet/PartSet_ConstraintDistancePrs.h
src/PartSet/PartSet_ConstraintLengthPrs.cpp
src/PartSet/PartSet_ConstraintLengthPrs.h
src/PartSet/PartSet_ConstraintRadiusPrs.cpp
src/PartSet/PartSet_ConstraintRadiusPrs.h
src/PartSet/PartSet_FeatureArcPrs.cpp
src/PartSet/PartSet_FeatureArcPrs.h
src/PartSet/PartSet_FeatureCirclePrs.cpp
src/PartSet/PartSet_FeatureCirclePrs.h
src/PartSet/PartSet_FeatureLinePrs.cpp
src/PartSet/PartSet_FeatureLinePrs.h
src/PartSet/PartSet_FeaturePointPrs.cpp
src/PartSet/PartSet_FeaturePointPrs.h
src/PartSet/PartSet_FeaturePrs.h
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Constraint.cpp

index 60b7b540e7c4f554d12e3cab5924a5b2f89cf5f4..80eba05b0e5a4cac492a4c0930e6d2e2100fca5e 100644 (file)
@@ -213,6 +213,7 @@ list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = myAttrs.begin();
   for(; anAttrsIter != myAttrs.end(); anAttrsIter++) {
     if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
+      aResult.push_back(anAttrsIter->second);
     }
   }
   return aResult;
index 37ed734c03bc32deea16ecb277ca1e31e696518f..6007743f5248434f95cb489e300ac6031a98987d 100644 (file)
@@ -31,7 +31,7 @@ ModuleBase_WidgetFeature::~ModuleBase_WidgetFeature()
 
 bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature)
 {
-  if (!theFeature && myFeatureKinds.contains(theFeature->getKind().c_str()))
+  if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str()))
     return false;
 
   //bool isBlocked = this->blockSignals(true);
index de33104313347ebb60f5885b84c46d0b7679127e..8dc195a94693f0f3d01c0a3b695152cf1625fda7 100644 (file)
@@ -125,13 +125,6 @@ PartSet_SelectionMode PartSet_ConstraintDistancePrs::getNextMode(const std::stri
   return SM_FirstPoint;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index 30c6923a521eadde2e9d03e973f08c65ed88b9ec..8d711540b00d4319cf07b784da31a6200a2eaa0c 100644 (file)
@@ -55,12 +55,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
 protected:
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
index 67b989c3be4e25f99a25b48471a035cea55c4c83..4607b732b71ee40a33f58e2bbd637193204622fe 100644 (file)
@@ -120,13 +120,6 @@ PartSet_SelectionMode PartSet_ConstraintLengthPrs::getNextMode(const std::string
   return SM_FirstPoint;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index ba1db99f49dcc2e71b70360714b31d1cde399aa5..e00b5494a76c888e2136a9677e1b85a878aee8c6 100644 (file)
@@ -55,12 +55,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
 protected:
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
index 634a44bb699f4dbc7c3850d307f723cdedccd3a3..659eff3f8170c2e0b7c27f699d4c82de2b50a73c 100644 (file)
@@ -148,13 +148,6 @@ PartSet_SelectionMode PartSet_ConstraintRadiusPrs::getNextMode(const std::string
   return SM_FirstPoint;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index 2d1ad727c883bab965214403f30d50553591a712..48585dcb633346e8b4e63e96789b315eff11ca10 100644 (file)
@@ -58,12 +58,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
   /// Project the view point on the feature. The output coordinates belong to the feature
   /// \param theFeature a feature
   /// \param theSketch the sketch feature
index ac90bf55794776ee062132124fe6f9c94338b487..440f5624efbeb8542c7d348a41dabab1c3bcc00c 100644 (file)
@@ -94,35 +94,6 @@ PartSet_SelectionMode PartSet_FeatureArcPrs::getNextMode(const std::string& theA
   return aMode;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureArcPrs::findPoint(FeaturePtr theFeature,
-                                                                        double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-      fabs(aPoint->y() - theY) < Precision::Confusion()) {
-    aPoint2D = aPoint;
-  }
-  if (!aPoint2D) {
-    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
-    if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-        fabs(aPoint->y() - theY) < Precision::Confusion())
-      aPoint2D = aPoint;
-  }
-  if (!aPoint2D) {
-    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_END));
-    if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-        fabs(aPoint->y() - theY) < Precision::Confusion())
-      aPoint2D = aPoint;
-  }
-  return aPoint2D;
-}
-
 void PartSet_FeatureArcPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
                                                   gp_Pnt& thePoint, Handle(V3d_View) theView,
                                                   double& theX, double& theY)
index a34a08d6f4747010229d8ded7c63baca17f23ba5..fd0bff9c3755783d43770b24645ca9c73711684b 100644 (file)
@@ -61,13 +61,6 @@ public:
   static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
                                     Handle_V3d_View theView, double& theX, double& theY);
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
-
   /// Computes the feature's radius
   /// \param theFeature an arc feature
   /// \return the double value
index 56e4f93b605b512ce3fa18de999cf42947f574ad..426d9f1e5e42fc9623a5cbba6cf452b60be2a20e 100644 (file)
@@ -92,22 +92,6 @@ PartSet_SelectionMode PartSet_FeatureCirclePrs::getNextMode(const std::string& t
   return aMode;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureCirclePrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
-    aPoint2D = aPoint;
-
-  return aPoint2D;
-}
-
 void PartSet_FeatureCirclePrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
                                                      gp_Pnt& thePoint, Handle(V3d_View) theView,
                                                      double& theX, double& theY)
index 546fb5eb029ed8a5d15194bc44dbede9ae81e621..f9688b103966f7cb261594d72951bb512ec3a16b 100644 (file)
@@ -51,12 +51,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
   /// Project the view point on the feature. The output coordinates belong to the feature
   /// \param theFeature a feature
   /// \param theSketch the sketch feature
index 4aa747a997ce4208246531c72af5c9cd6f21c996..fe4c3a5c56c52798626156523871e9b5218a8f19 100644 (file)
@@ -148,28 +148,6 @@ void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature,
   }
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLinePrs::findPoint(FeaturePtr theFeature,
-                                                                         double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-      fabs(aPoint->y() - theY) < Precision::Confusion())
-    aPoint2D = aPoint;
-  else {
-    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-    if (fabs(aPoint->x() - theX) < Precision::Confusion() &&
-        fabs(aPoint->y() - theY) < Precision::Confusion())
-      aPoint2D = aPoint;
-  }
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomAPI_Lin2d> PartSet_FeatureLinePrs::createLin2d(FeaturePtr theFeature)
 {
   boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin;
index b4a16dc5c36176e784085da6f760be52111640c1..b9f2cfa42d63da47030db603d8d88e10c9dbe141 100644 (file)
@@ -69,13 +69,6 @@ public:
                           const gp_Pnt& thePoint, Handle_V3d_View theView,
                           double& theX, double& theY);
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY);
-
   /// Creates a lin 2d object on a base of the line feature
   /// \param theFeature the line feature
   static boost::shared_ptr<GeomAPI_Lin2d> createLin2d(FeaturePtr theFeature);
index fa33cd40ae3e5d84e0325232e87be91f885e04d6..818206b4787f305cf385dd30ed00b097a655c6a6 100644 (file)
@@ -71,22 +71,6 @@ PartSet_SelectionMode PartSet_FeaturePointPrs::getNextMode(const std::string& th
   return aMode;
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::findPoint(FeaturePtr theFeature,
-                                                                          double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != getKind())
-    return aPoint2D;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
-    aPoint2D = aPoint;
-
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::featurePoint
                                                      (const PartSet_SelectionMode& theMode)
 {
index d43a8227221e3785ef449584ef9ae095aca00d2b..7fec848071d287508078486cdf23f432581fe8f4 100644 (file)
@@ -48,13 +48,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                          double theY);
-
 protected:
   /// Returns the feature point in the selection mode position.
   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
index 87fd3693bc3b4280882fc82e415aeb58194a3a24..9adf4a0a2a34cb6f7c90445f07d13bd59c08be6a 100644 (file)
@@ -59,13 +59,6 @@ public:
   /// \return next attribute selection mode
   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const = 0;
 
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                           double theY) = 0;
-
 protected:
   /// Returns the operation feature
   /// \return the feature
index 27c0e068903862ffdb2c2de754ff04e55ca0d09f..ada0fdf35d619432ee9afd71aa63130b447d485e 100644 (file)
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
 
 #include <GeomAPI_Pnt2d.h>
 
@@ -55,8 +59,13 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
 bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
 {
   return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND ||
-         theId == SKETCH_CONSTRAINT_DISTANCE_KIND || theId == SKETCH_CIRCLE_KIND /*||
-         theId == SKETCH_ARC_KIND*/;
+         theId == SKETCH_CIRCLE_KIND /*||
+         theId == SKETCH_ARC_KIND*/ ||
+         theId == SKETCH_CONSTRAINT_DISTANCE_KIND ||
+         theId == SKETCH_CONSTRAINT_LENGTH_KIND ||
+         theId == SKETCH_CONSTRAINT_RADIUS_KIND ||
+         theId == SKETCH_CONSTRAINT_PARALLEL_KIND ||
+         theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND;
 }
 
 bool PartSet_OperationFeatureCreate::canBeCommitted() const
index 17f5be33b69f38b28bbbe07c0dacc1a483517f83..8c6f38832bfc3005773af18777ff8073b43750c3 100644 (file)
@@ -302,13 +302,14 @@ void PartSet_Tools::createConstraint(FeaturePtr theSketch,
 }
 
 void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
-                                   const std::string& theAttribute, double theX, double theY)
+                                   const std::string& theAttribute,
+                                   double theClickedX, double theClickedY)
 {
   // find a feature point by the selection mode
   //boost::shared_ptr<GeomDataAPI_Point2D> aPoint = featurePoint(theMode);
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+  boost::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint =
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
-  if (!aPoint)
+  if (!aFeaturePoint)
     return;
 
   // get all sketch features. If the point with the given coordinates belong to any sketch feature,
@@ -319,28 +320,28 @@ void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
 
   std::list<FeaturePtr > aFeatures = aRefList->list();
   std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+  std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes;
+  boost::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = boost::shared_ptr<GeomAPI_Pnt2d>
+                                                     (new GeomAPI_Pnt2d(theClickedX, theClickedY));
   for (; anIt != aLast; anIt++)
   {
     FeaturePtr aFeature = *anIt;
-    boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;// = aFeature->findPoint(theX, theY);
+    // find the given point in the feature attributes
+    anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+    std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
+                                                                      aLast = anAttiributes.end();
+    boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
+    for (;anIt!=aLast && !aFPoint; anIt++) {
+      boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
+                                          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+      if (aCurPoint && aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion())
+        aFPoint = aCurPoint;
+    }
     if (aFPoint)
-      PartSet_Tools::createConstraint(theSketch, aFPoint, aPoint);
+      PartSet_Tools::createConstraint(theSketch, aFPoint, aFeaturePoint);
   }
 }
 
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_Tools::findPoint(FeaturePtr theFeature,
-                                                                double theX, double theY)
-{
-  boost::shared_ptr<PartSet_FeaturePrs> aFeaturePrs = PartSet_Tools::createFeaturePrs(
-                                           theFeature->getKind(), FeaturePtr(), theFeature);
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (aFeaturePrs)
-    aPoint2D = aFeaturePrs->findPoint(theFeature, theX, theY);
-
-  return aPoint2D;
-}
-
 boost::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(FeaturePtr theSketch)
 {
   boost::shared_ptr<GeomAPI_Pln> aPlane;
index 7f407ac8c5427a37e32a8d0acf810593d5379389..6aebb10322b3bdb86b80bbe937fefed7b9f539b8 100644 (file)
@@ -114,17 +114,10 @@ public:
   /// \param theSketch a sketch feature
   /// \param theFeature a source feature
   /// \param theAttribute a name of the requried attribute attribute
-  /// \param theX the horizontal coordnate of the point
-  /// \param theY the vertical coordnate of the point
+  /// \param theClickedX the horizontal coordnate of the point
+  /// \param theClickedY the vertical coordnate of the point
   static void setConstraints(FeaturePtr theSketch, FeaturePtr theFeature,
-                             const std::string& theAttribute, double theX, double theY);
-
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  static boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
-                                                          double theY);
+                             const std::string& theAttribute, double theClickedX, double theClickedY);
 
   /// Create a sketch plane instance
   /// \param theSketch a sketch feature
index 599cb72e954d034d58537f0eb8dabf97ea51b4b2..6e37f0cbe1094964f924c483b40a5a6007198842 100644 (file)
@@ -43,16 +43,15 @@ void SketchPlugin_ConstraintDistance::execute()
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr_B = 
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
 
-  AttributeDoublePtr anAttribute =
+  AttributeDoublePtr anAttr_Value =
       boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
-
-  if (anAttr_A && anAttr_B && anAttribute->value() == 0)
+  if (anAttr_A && anAttr_B && !anAttr_Value->isInitialized())
   {
     FeaturePtr aFeature_A = anAttr_A->feature();
     FeaturePtr aFeature_B = anAttr_B->feature();
 
     double aValue = 40; // TODO
-    anAttribute->setValue(aValue);
+    anAttr_Value->setValue(aValue);
   }
 }
 
index 4ec9e30ce42a328991b6d668f193a562094b3d5a..6e48926c662b7f26eeedfd4cedab1b415ce5d7b6 100644 (file)
@@ -5,6 +5,8 @@
 #include "SketchPlugin_ConstraintLength.h"
 #include <SketchPlugin_Line.h>
 
+#include <GeomDataAPI_Point2D.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 
@@ -22,6 +24,7 @@ void SketchPlugin_ConstraintLength::initAttributes()
 {
   data()->addAttribute(CONSTRAINT_ATTR_VALUE,    ModelAPI_AttributeDouble::type());
   data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
   data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
 }
 
@@ -107,3 +110,14 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintLength::getAISShape(
   return anAIS;
 }
 
+void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = data();
+  if (!aData->isValid())
+    return;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+}
+
index 28e3627c3b742f6e334a6cce9fa1cb8c01e86f1c..52012c4194eb8a87983cf8a89549d4e59bf6e8f4 100644 (file)
@@ -41,6 +41,11 @@ public:
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
 
+  /// Moves the feature
+  /// \param theDeltaX the delta for X coordinate is moved
+  /// \param theDeltaY the delta for Y coordinate is moved
+  SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintLength();
 };
index ee98b3724008d796b41ef343b869f095b54f229b..8f8df83040257ecee86f031dfbde797eabb7c462 100644 (file)
@@ -42,14 +42,16 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
     // compute a start point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
       boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(LINE_ATTR_START));
-    boost::shared_ptr<GeomAPI_Pnt> aStart(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
     // compute an end point in 3D view
     boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
       boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(LINE_ATTR_END));
-    boost::shared_ptr<GeomAPI_Pnt> anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
-    // make linear edge
-    boost::shared_ptr<GeomAPI_Shape> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
-    setPreview(anEdge);
+    if (aStartAttr->isInitialized() && anEndAttr->isInitialized()) {
+      boost::shared_ptr<GeomAPI_Pnt> aStart(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
+      boost::shared_ptr<GeomAPI_Pnt> anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
+      // make linear edge
+      boost::shared_ptr<GeomAPI_Shape> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
+      setPreview(anEdge);
+    }
   }
   return getPreview();
 }
index dc6b959aa2f0eb423a1ddce9fdba71e1152d1f33..8cff21c494fe019dc8d8894c5632cbaf29f95dec 100644 (file)
@@ -1,7 +1,7 @@
 <plugin>
   <workbench id="Sketch">
     <group id="Basic">
-      <feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
+      <feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
         <label title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/> 
       <!--icon=":pictures/x_point.png"-->
       </feature>
         <label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
         <feature_selector id="ConstraintEntityA" keysequence="SketchPoint" internal="1"/>
         <feature_selector id="ConstraintEntityB" keysequence="SketchPoint" internal="1"/>
-        <point_selector id="ConstraintFlyoutValuePnt" title="Flyout point" tooltip="Flyout" internal="1"/>
-        <doublevalue_editor id="ConstraintValue" min="0" step="1.0" tooltip="Constraint value"/>
+        <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
+        <doublevalue_editor id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintLength" title="Length of a line" tooltip="Create constraint for the given length of a line segment">
         <label title="Select a line entity on which to calculate lenght" tooltip="Select a line entity on which to calculate lenght"/>
+        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
+        <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
+        <doublevalue_editor id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintRadius" title="Radius of a circle or an arc" tooltip="Create constraint for the given radius of a circle or an arc">
         <label title="Select two points on a circle or an arc of circle on which to calculate radius" tooltip="Select two points on a circle or an arc of circle on which to calculate radius"/>
+        <feature_selector id="ConstraintEntityA" keysequence="SketchPoint" internal="1"/>
+        <point_selector id="CirclePoint" internal="1"/>
+        <doublevalue_editor id="ConstraintValue"/>
+      </feature>
+      <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines">
+        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
+        <feature_selector id="ConstraintEntityB" keysequence="SketchLine" internal="1"/>
+      </feature>
+      <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines">
+        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
+        <feature_selector id="ConstraintEntityB" keysequence="SketchLine" internal="1"/>
       </feature>
-      <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines" internal="1"/>
-      <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines" internal="1"/>
     </group>
   </workbench>
 </plugin>
index 1b92bf9470a579a40d4822933defd1918fdbce08..67a177038088fffb546b35af925fa8483aab67e6 100644 (file)
@@ -183,7 +183,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
-      if (!anAttr || !anAttr->isFeature()) continue;
+      if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue;
       const std::string& aKind = anAttr->feature()->getKind();
       if (aKind.compare(SKETCH_LINE_KIND) == 0)
       {