]> 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>
Fri, 20 Jun 2014 15:25:44 +0000 (19:25 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 20 Jun 2014 15:25:44 +0000 (19:25 +0400)
1. Rename constraint feature presentations
2. Add createPresentation() to each constraint feature prs.

17 files changed:
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_ConstraintDistancePrs.cpp [new file with mode: 0644]
src/PartSet/PartSet_ConstraintDistancePrs.h [new file with mode: 0644]
src/PartSet/PartSet_ConstraintLengthPrs.cpp [new file with mode: 0644]
src/PartSet/PartSet_ConstraintLengthPrs.h [new file with mode: 0644]
src/PartSet/PartSet_ConstraintRadiusPrs.cpp [new file with mode: 0644]
src/PartSet/PartSet_ConstraintRadiusPrs.h [new file with mode: 0644]
src/PartSet/PartSet_FeatureDistancePrs.cpp [deleted file]
src/PartSet/PartSet_FeatureDistancePrs.h [deleted file]
src/PartSet/PartSet_FeatureLengthPrs.cpp [deleted file]
src/PartSet/PartSet_FeatureLengthPrs.h [deleted file]
src/PartSet/PartSet_FeatureRadiusPrs.cpp [deleted file]
src/PartSet/PartSet_FeatureRadiusPrs.h [deleted file]
src/PartSet/PartSet_OperationCreateConstraint.cpp
src/PartSet/PartSet_Presentation.cpp
src/PartSet/PartSet_Tools.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index 37822dd00061988cffb478a38659ce5034cfb77f..495fe7e759a9d08b89728c009216d7a9de7dbd06 100644 (file)
@@ -5,15 +5,15 @@ SET(CMAKE_AUTOMOC ON)
 SET(PROJECT_HEADERS
        PartSet.h
        PartSet_Constants.h
+       PartSet_ConstraintDistancePrs.h
+       PartSet_ConstraintLengthPrs.h
+       PartSet_ConstraintRadiusPrs.h
        PartSet_EditLine.h
        PartSet_FeatureArcPrs.h
        PartSet_FeatureCirclePrs.h
-       PartSet_FeatureDistancePrs.h
        PartSet_FeaturePrs.h
-       PartSet_FeatureLengthPrs.h
        PartSet_FeatureLinePrs.h
        PartSet_FeaturePointPrs.h
-       PartSet_FeatureRadiusPrs.h
        PartSet_Listener.h
        PartSet_Module.h
        PartSet_OperationCreateConstraint.h
@@ -28,15 +28,15 @@ SET(PROJECT_HEADERS
 )
 
 SET(PROJECT_SOURCES
+       PartSet_ConstraintDistancePrs.cpp
+       PartSet_ConstraintLengthPrs.cpp
+       PartSet_ConstraintRadiusPrs.cpp
        PartSet_EditLine.cpp
        PartSet_FeaturePrs.cpp
        PartSet_FeatureArcPrs.cpp
        PartSet_FeatureCirclePrs.cpp
-       PartSet_FeatureDistancePrs.cpp
-       PartSet_FeatureLengthPrs.cpp
        PartSet_FeatureLinePrs.cpp
        PartSet_FeaturePointPrs.cpp
-       PartSet_FeatureRadiusPrs.cpp
        PartSet_Listener.cpp
        PartSet_Module.cpp
        PartSet_OperationCreateConstraint.cpp
diff --git a/src/PartSet/PartSet_ConstraintDistancePrs.cpp b/src/PartSet/PartSet_ConstraintDistancePrs.cpp
new file mode 100644 (file)
index 0000000..29a0d19
--- /dev/null
@@ -0,0 +1,222 @@
+// File:        PartSet_FeaturePrs.h
+// Created:     16 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_ConstraintDistancePrs.h>
+#include <PartSet_Tools.h>
+
+#include <PartSet_FeatureLinePrs.h>
+
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_ConstraintDistance.h>
+
+#include <GeomDataAPI_Point2D.h>
+#include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_Lin2d.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <Precision.hxx>
+
+using namespace std;
+
+PartSet_ConstraintDistancePrs::PartSet_ConstraintDistancePrs(FeaturePtr theSketch)
+: PartSet_FeaturePrs(theSketch)
+{
+}
+
+std::string PartSet_ConstraintDistancePrs::getKind()
+{
+  return SKETCH_CONSTRAINT_DISTANCE_KIND;
+}
+
+bool PartSet_ConstraintDistancePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+{
+  bool aResult = false;
+  if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
+  {
+    // set length feature
+    boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    aRef->setFeature(theFeature);
+
+    // set length value
+    aData = theFeature->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+    PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
+    aResult = true;
+  }
+  return aResult;
+}
+
+PartSet_SelectionMode PartSet_ConstraintDistancePrs::setPoint(double theX, double theY,
+                                                         const PartSet_SelectionMode& theMode)
+{
+  PartSet_SelectionMode aMode = theMode;
+  switch (theMode)
+  {
+    case SM_SecondPoint: {
+      boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+      boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+              boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+      FeaturePtr aFeature;
+      if (anAttr) {
+        aFeature = anAttr->feature();
+        if (aFeature->getKind() != SKETCH_LINE_KIND) {
+          aFeature = FeaturePtr();
+        }
+      }
+      boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
+                                                             (new GeomAPI_Pnt2d(theX, theY));
+      boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
+      boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
+      double aDistance = aPoint->distance(aResult);
+
+      double aStartX, aStartY;
+      PartSet_FeatureLinePrs::getLinePoint(aFeature, LINE_ATTR_START, aStartX, aStartY);
+
+      if (!aFeatureLin->isRight(aPoint))
+        aDistance = -aDistance;
+
+      AttributeDoublePtr aFlyoutAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
+      aFlyoutAttr->setValue(aDistance);
+
+      aMode = SM_DonePoint;
+    }
+    break;
+    default:
+      break;
+  }
+  return aMode;
+}
+
+Handle(AIS_InteractiveObject) PartSet_ConstraintDistancePrs::createPresentation(FeaturePtr theFeature,
+                                                       FeaturePtr theSketch,
+                                                       Handle(AIS_InteractiveObject) thePreviuos)
+{
+  Handle(AIS_InteractiveObject) anAIS = thePreviuos;
+  if (!theFeature || !theSketch)
+    return anAIS;
+  /*
+  boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
+  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+  gp_Pln aPlane(aNormal->x(), aNormal->y(), aNormal->z(), 0);
+
+  aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  if (!anAttr)
+    return thePreviuos;
+  FeaturePtr aFeature = anAttr->feature();
+  if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
+    return thePreviuos;
+
+  boost::shared_ptr<ModelAPI_AttributeDouble> aFlyoutAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
+  double aFlyout = aFlyoutAttr->value();
+
+  aData = aFeature->data();
+  if (!aData->isValid())
+    return thePreviuos;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointStart =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointEnd =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+  gp_Pnt aPoint1, aPoint2;
+  PartSet_Tools::convertTo3D(aPointStart->x(), aPointStart->y(), theSketch, aPoint1);
+  PartSet_Tools::convertTo3D(aPointEnd->x(), aPointEnd->y(), theSketch, aPoint2);
+
+  //Build dimension here
+  gp_Pnt aP1 = aPoint1;
+  gp_Pnt aP2 = aPoint2;
+  if (aFlyout < 0) {
+    aP1 = aPoint2;
+    aP2 = aPoint1;
+  }
+
+  Handle(AIS_InteractiveObject) anAIS = thePreviuos;
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension (aP1, aP2, aPlane);
+
+    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
+    anAspect->MakeArrows3d (Standard_False);
+    anAspect->MakeText3d(false);
+    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
+    anAspect->MakeTextShaded(false);
+    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
+    //if (isUnitsDisplayed)
+    //{
+    //  aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ());
+    //}
+    aDimAIS->SetDimensionAspect (anAspect);
+    aDimAIS->SetFlyout(aFlyout);
+    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
+
+    anAIS = aDimAIS;
+  }
+  else {
+    // update presentation
+    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
+    if (!aDimAIS.IsNull()) {
+      aDimAIS->SetMeasuredGeometry(aPoint1, aPoint2, aPlane);
+      aDimAIS->SetFlyout(aFlyout);
+
+      aDimAIS->Redisplay(Standard_True);
+    }
+  }
+*/
+  return anAIS;
+}
+
+std::string PartSet_ConstraintDistancePrs::getAttribute(const PartSet_SelectionMode& theMode) const
+{
+  return "";
+}
+
+PartSet_SelectionMode PartSet_ConstraintDistancePrs::getNextMode(const std::string& theAttribute) const
+{
+  return SM_FirstPoint;
+}
+
+void PartSet_ConstraintDistancePrs::move(double theDeltaX, double theDeltaY)
+{
+}
+
+double PartSet_ConstraintDistancePrs::distanceToPoint(FeaturePtr theFeature,
+                                                 double theX, double theY)
+{
+  return 0;
+}
+
+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)
+{
+  return boost::shared_ptr<GeomDataAPI_Point2D>();
+}
diff --git a/src/PartSet/PartSet_ConstraintDistancePrs.h b/src/PartSet/PartSet_ConstraintDistancePrs.h
new file mode 100644 (file)
index 0000000..a6fe31e
--- /dev/null
@@ -0,0 +1,90 @@
+// File:        PartSet_ConstraintDistancePrs.h
+// Created:     16 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_ConstraintDistancePrs_H
+#define PartSet_ConstraintDistancePrs_H
+
+#include "PartSet.h"
+
+#include "PartSet_FeaturePrs.h"
+#include "PartSet_Constants.h"
+
+class GeomDataAPI_Point2D;
+class Handle_AIS_InteractiveObject;
+
+/*!
+ \class PartSet_ConstraintDistancePrs
+ * \brief The class to define the circle feature manipulation. It is created for
+ * the feature create operation to move out the feature properties set and use one operation
+ * for any type of features.
+*/
+class PARTSET_EXPORT PartSet_ConstraintDistancePrs : public PartSet_FeaturePrs
+{
+public:
+  /// Returns the feature type processed by this presentation
+  /// \return the feature kind
+  static std::string getKind();
+
+  /// Constructor
+  /// \param theSketch the sketch feature
+  PartSet_ConstraintDistancePrs(FeaturePtr theSketch);
+  /// Destructor
+  virtual ~PartSet_ConstraintDistancePrs() {};
+
+  /// Sets the feature to to a feature attribute depending on the selection mode
+  /// \param theFeature a feature instance
+  /// \param theMode the selection mode
+  /// \return whether the feature is set
+  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+
+  /// Sets the point to the feature in an attribute depending on the selection mode
+  /// \param theX the 2D point horizontal coordinate
+  /// \param theY the 2D point vertical coordinate
+  /// \param theMode the selection mode
+  /// \return the new selection mode
+  virtual PartSet_SelectionMode setPoint(double theX, double theY,
+                                         const PartSet_SelectionMode& theMode);
+
+  /// Creates an AIS presentation if the previous is null or update the given one
+  /// \param theFeature a feature
+  /// \param theSketch a feature sketch
+  /// \param thePrevious a previuos AIS presentation
+  /// \return a created/changed AIS object with the feature parameters
+  static Handle_AIS_InteractiveObject createPresentation(FeaturePtr theFeature,
+                                                         FeaturePtr theSketch,
+                                                         Handle_AIS_InteractiveObject thePreviuos);
+
+  /// Returns the feature attribute name for the selection mode
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
+
+  /// Returns the next selection mode after the attribute
+  /// \param theAttribute the feature attribute name
+  /// \return next attribute selection mode
+  virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
+
+  /// \brief Move the full feature.
+  /// \param theDeltaX the delta for X coordinate is moved
+  /// \param theDeltaY the delta for Y coordinate is moved
+  virtual void move(double theDeltaX, double theDeltaY);
+
+  /// Return the distance between the feature and the point
+  /// \param theFeature feature object
+  /// \param theX the horizontal coordinate of the point
+  /// \param theX the vertical coordinate of the point
+  virtual double distanceToPoint(FeaturePtr theFeature, 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);
+protected:
+  /// Returns the feature point in the selection mode position.
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
+};
+
+#endif
diff --git a/src/PartSet/PartSet_ConstraintLengthPrs.cpp b/src/PartSet/PartSet_ConstraintLengthPrs.cpp
new file mode 100644 (file)
index 0000000..716b435
--- /dev/null
@@ -0,0 +1,228 @@
+// File:        PartSet_FeaturePrs.h
+// Created:     16 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_ConstraintLengthPrs.h>
+#include <PartSet_Tools.h>
+#include <PartSet_Constants.h>
+
+#include <PartSet_FeatureLinePrs.h>
+
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_ConstraintLength.h>
+
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_Lin2d.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_LengthDimension.hxx>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+
+using namespace std;
+
+PartSet_ConstraintLengthPrs::PartSet_ConstraintLengthPrs(FeaturePtr theSketch)
+: PartSet_FeaturePrs(theSketch)
+{
+}
+
+std::string PartSet_ConstraintLengthPrs::getKind()
+{
+  return SKETCH_CONSTRAINT_LENGTH_KIND;
+}
+
+bool PartSet_ConstraintLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+{
+  bool aResult = false;
+  if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
+  {
+    // set length feature
+    boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    aRef->setFeature(theFeature);
+
+    // set length value
+    aData = theFeature->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+    PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
+    aResult = true;
+  }
+  return aResult;
+}
+
+PartSet_SelectionMode PartSet_ConstraintLengthPrs::setPoint(double theX, double theY,
+                                                         const PartSet_SelectionMode& theMode)
+{
+  PartSet_SelectionMode aMode = theMode;
+  switch (theMode)
+  {
+    case SM_SecondPoint: {
+      boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+      boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+              boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+      FeaturePtr aFeature;
+      if (anAttr) {
+        aFeature = anAttr->feature();
+        if (aFeature->getKind() != SKETCH_LINE_KIND) {
+          aFeature = FeaturePtr();
+        }
+      }
+      boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
+                                                             (new GeomAPI_Pnt2d(theX, theY));
+      boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
+      boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
+      double aDistance = aPoint->distance(aResult);
+
+      double aStartX, aStartY;
+      PartSet_FeatureLinePrs::getLinePoint(aFeature, LINE_ATTR_START, aStartX, aStartY);
+
+      if (!aFeatureLin->isRight(aPoint))
+        aDistance = -aDistance;
+
+      AttributeDoublePtr aFlyoutAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
+      aFlyoutAttr->setValue(aDistance);
+
+      aMode = SM_DonePoint;
+    }
+    break;
+    default:
+      break;
+  }
+  return aMode;
+}
+
+Handle(AIS_InteractiveObject) PartSet_ConstraintLengthPrs::createPresentation(FeaturePtr theFeature,
+                                                       FeaturePtr theSketch,
+                                                       Handle(AIS_InteractiveObject) thePreviuos)
+{
+  if (!theFeature || !theSketch)
+    return thePreviuos;
+
+  boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
+  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+  gp_Pln aPlane(aNormal->x(), aNormal->y(), aNormal->z(), 0/*D*/);
+
+  aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  if (!anAttr)
+    return thePreviuos;
+  FeaturePtr aFeature = anAttr->feature();
+  if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
+    return thePreviuos;
+
+  boost::shared_ptr<ModelAPI_AttributeDouble> aFlyoutAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
+  double aFlyout = aFlyoutAttr->value();
+
+  aData = aFeature->data();
+  if (!aData->isValid())
+    return thePreviuos;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointStart =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointEnd =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+  gp_Pnt aPoint1, aPoint2;
+  PartSet_Tools::convertTo3D(aPointStart->x(), aPointStart->y(), theSketch, aPoint1);
+  PartSet_Tools::convertTo3D(aPointEnd->x(), aPointEnd->y(), theSketch, aPoint2);
+
+  //Build dimension here
+  gp_Pnt aP1 = aPoint1;
+  gp_Pnt aP2 = aPoint2;
+  if (aFlyout < 0) {
+    aP1 = aPoint2;
+    aP2 = aPoint1;
+  }
+
+  Handle(AIS_InteractiveObject) anAIS = thePreviuos;
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension (aP1, aP2, aPlane);
+
+    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
+    anAspect->MakeArrows3d (Standard_False);
+    anAspect->MakeText3d(false/*is text 3d*/);
+    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
+    anAspect->MakeTextShaded(false/*is test shaded*/);
+    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
+    /*if (isUnitsDisplayed)
+    {
+      aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ());
+    }*/
+    aDimAIS->SetDimensionAspect (anAspect);
+    aDimAIS->SetFlyout(aFlyout);
+    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
+
+    anAIS = aDimAIS;
+  }
+  else {
+    // update presentation
+    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
+    if (!aDimAIS.IsNull()) {
+      aDimAIS->SetMeasuredGeometry(aPoint1, aPoint2, aPlane);
+      aDimAIS->SetFlyout(aFlyout);
+
+      aDimAIS->Redisplay(Standard_True);
+    }
+  }
+  return anAIS;
+}
+
+std::string PartSet_ConstraintLengthPrs::getAttribute(const PartSet_SelectionMode& theMode) const
+{
+  return "";
+}
+
+PartSet_SelectionMode PartSet_ConstraintLengthPrs::getNextMode(const std::string& theAttribute) const
+{
+  return SM_FirstPoint;
+}
+
+void PartSet_ConstraintLengthPrs::move(double theDeltaX, double theDeltaY)
+{
+}
+
+double PartSet_ConstraintLengthPrs::distanceToPoint(FeaturePtr theFeature,
+                                                 double theX, double theY)
+{
+  return 0;
+}
+
+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)
+{
+  return boost::shared_ptr<GeomDataAPI_Point2D>();
+}
diff --git a/src/PartSet/PartSet_ConstraintLengthPrs.h b/src/PartSet/PartSet_ConstraintLengthPrs.h
new file mode 100644 (file)
index 0000000..5c8f85d
--- /dev/null
@@ -0,0 +1,90 @@
+// File:        PartSet_ConstraintLengthPrs.h
+// Created:     16 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_ConstraintLengthPrs_H
+#define PartSet_ConstraintLengthPrs_H
+
+#include "PartSet.h"
+
+#include "PartSet_FeaturePrs.h"
+#include "PartSet_Constants.h"
+
+class GeomDataAPI_Point2D;
+class Handle_AIS_InteractiveObject;
+
+/*!
+ \class PartSet_ConstraintLengthPrs
+ * \brief The class to define the circle feature manipulation. It is created for
+ * the feature create operation to move out the feature properties set and use one operation
+ * for any type of features.
+*/
+class PARTSET_EXPORT PartSet_ConstraintLengthPrs : public PartSet_FeaturePrs
+{
+public:
+  /// Returns the feature type processed by this presentation
+  /// \return the feature kind
+  static std::string getKind();
+
+  /// Constructor
+  /// \param theSketch the sketch feature
+  PartSet_ConstraintLengthPrs(FeaturePtr theSketch);
+  /// Destructor
+  virtual ~PartSet_ConstraintLengthPrs() {};
+
+  /// Sets the feature to to a feature attribute depending on the selection mode
+  /// \param theFeature a feature instance
+  /// \param theMode the selection mode
+  /// \return whether the feature is set
+  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+
+  /// Sets the point to the feature in an attribute depending on the selection mode
+  /// \param theX the 2D point horizontal coordinate
+  /// \param theY the 2D point vertical coordinate
+  /// \param theMode the selection mode
+  /// \return the new selection mode
+  virtual PartSet_SelectionMode setPoint(double theX, double theY,
+                                         const PartSet_SelectionMode& theMode);
+
+  /// Creates an AIS presentation if the previous is null or update the given one
+  /// \param theFeature a feature
+  /// \param theSketch a feature sketch
+  /// \param thePrevious a previuos AIS presentation
+  /// \return a created/changed AIS object with the feature parameters
+  static Handle_AIS_InteractiveObject createPresentation(FeaturePtr theFeature,
+                                                         FeaturePtr theSketch,
+                                                         Handle_AIS_InteractiveObject thePreviuos);
+
+  /// Returns the feature attribute name for the selection mode
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
+
+  /// Returns the next selection mode after the attribute
+  /// \param theAttribute the feature attribute name
+  /// \return next attribute selection mode
+  virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
+
+  /// \brief Move the full feature.
+  /// \param theDeltaX the delta for X coordinate is moved
+  /// \param theDeltaY the delta for Y coordinate is moved
+  virtual void move(double theDeltaX, double theDeltaY);
+
+  /// Return the distance between the feature and the point
+  /// \param theFeature feature object
+  /// \param theX the horizontal coordinate of the point
+  /// \param theX the vertical coordinate of the point
+  virtual double distanceToPoint(FeaturePtr theFeature, 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);
+protected:
+  /// Returns the feature point in the selection mode position.
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
+};
+
+#endif
diff --git a/src/PartSet/PartSet_ConstraintRadiusPrs.cpp b/src/PartSet/PartSet_ConstraintRadiusPrs.cpp
new file mode 100644 (file)
index 0000000..bee75f1
--- /dev/null
@@ -0,0 +1,228 @@
+// File:        PartSet_FeaturePrs.h
+// Created:     16 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_ConstraintRadiusPrs.h>
+#include <PartSet_Tools.h>
+
+#include <PartSet_FeatureLinePrs.h>
+
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_ConstraintRadius.h>
+
+#include <GeomDataAPI_Point2D.h>
+#include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_Lin2d.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <Precision.hxx>
+
+using namespace std;
+
+PartSet_ConstraintRadiusPrs::PartSet_ConstraintRadiusPrs(FeaturePtr theSketch)
+: PartSet_FeaturePrs(theSketch)
+{
+}
+
+std::string PartSet_ConstraintRadiusPrs::getKind()
+{
+  return SKETCH_CONSTRAINT_RADIUS_KIND;
+}
+
+bool PartSet_ConstraintRadiusPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+{
+  bool aResult = false;
+  if (feature() && theMode == SM_FirstPoint &&
+      (theFeature && theFeature->getKind() == SKETCH_CIRCLE_KIND ||
+       theFeature && theFeature->getKind() == SKETCH_ARC_KIND)) {
+    // set length feature
+    boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+    aRef->setFeature(theFeature);
+
+    // set length value
+    /*aData = theFeature->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
+          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+    */
+    double aLenght = 50;
+    PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
+    aResult = true;
+  }
+  return aResult;
+}
+
+PartSet_SelectionMode PartSet_ConstraintRadiusPrs::setPoint(double theX, double theY,
+                                                         const PartSet_SelectionMode& theMode)
+{
+  PartSet_SelectionMode aMode = theMode;
+  switch (theMode)
+  {
+    case SM_SecondPoint: {
+      boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+      /*boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+              boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+      FeaturePtr aFeature;
+      if (anAttr) {
+        aFeature = anAttr->feature();
+        if (aFeature->getKind() != SKETCH_LINE_KIND) {
+          aFeature = FeaturePtr();
+        }
+      }
+      boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
+                                                             (new GeomAPI_Pnt2d(theX, theY));
+      boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
+      boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
+      double aDistance = aPoint->distance(aResult);
+
+      double aStartX, aStartY;
+      PartSet_FeatureLinePrs::getLinePoint(aFeature, LINE_ATTR_START, aStartX, aStartY);
+
+      if (!aFeatureLin->isRight(aPoint))
+        aDistance = -aDistance;
+        */
+      double aDistance = 40;
+      AttributeDoublePtr aFlyoutAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
+      aFlyoutAttr->setValue(aDistance);
+
+      aMode = SM_DonePoint;
+    }
+    break;
+    default:
+      break;
+  }
+  return aMode;
+}
+
+Handle(AIS_InteractiveObject) PartSet_ConstraintRadiusPrs::createPresentation(FeaturePtr theFeature,
+                                                       FeaturePtr theSketch,
+                                                       Handle(AIS_InteractiveObject) thePreviuos)
+{
+  Handle(AIS_InteractiveObject) anAIS = thePreviuos;
+  if (!theFeature || !theSketch)
+    return anAIS;
+  /*
+  boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
+  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+  gp_Pln aPlane(aNormal->x(), aNormal->y(), aNormal->z(), 0);
+
+  aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  if (!anAttr)
+    return thePreviuos;
+  FeaturePtr aFeature = anAttr->feature();
+  if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
+    return thePreviuos;
+
+  boost::shared_ptr<ModelAPI_AttributeDouble> aFlyoutAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
+  double aFlyout = aFlyoutAttr->value();
+
+  aData = aFeature->data();
+  if (!aData->isValid())
+    return thePreviuos;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointStart =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointEnd =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+  gp_Pnt aPoint1, aPoint2;
+  PartSet_Tools::convertTo3D(aPointStart->x(), aPointStart->y(), theSketch, aPoint1);
+  PartSet_Tools::convertTo3D(aPointEnd->x(), aPointEnd->y(), theSketch, aPoint2);
+
+  //Build dimension here
+  gp_Pnt aP1 = aPoint1;
+  gp_Pnt aP2 = aPoint2;
+  if (aFlyout < 0) {
+    aP1 = aPoint2;
+    aP2 = aPoint1;
+  }
+
+  Handle(AIS_InteractiveObject) anAIS = thePreviuos;
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension (aP1, aP2, aPlane);
+
+    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
+    anAspect->MakeArrows3d (Standard_False);
+    anAspect->MakeText3d(false);
+    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
+    anAspect->MakeTextShaded(false);
+    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
+    //if (isUnitsDisplayed)
+    //{
+    //  aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ());
+    //}
+    aDimAIS->SetDimensionAspect (anAspect);
+    aDimAIS->SetFlyout(aFlyout);
+    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
+
+    anAIS = aDimAIS;
+  }
+  else {
+    // update presentation
+    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
+    if (!aDimAIS.IsNull()) {
+      aDimAIS->SetMeasuredGeometry(aPoint1, aPoint2, aPlane);
+      aDimAIS->SetFlyout(aFlyout);
+
+      aDimAIS->Redisplay(Standard_True);
+    }
+  }
+*/
+  return anAIS;
+}
+
+std::string PartSet_ConstraintRadiusPrs::getAttribute(const PartSet_SelectionMode& theMode) const
+{
+  return "";
+}
+
+PartSet_SelectionMode PartSet_ConstraintRadiusPrs::getNextMode(const std::string& theAttribute) const
+{
+  return SM_FirstPoint;
+}
+
+void PartSet_ConstraintRadiusPrs::move(double theDeltaX, double theDeltaY)
+{
+}
+
+double PartSet_ConstraintRadiusPrs::distanceToPoint(FeaturePtr theFeature,
+                                                 double theX, double theY)
+{
+  return 0;
+}
+
+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)
+{
+  return boost::shared_ptr<GeomDataAPI_Point2D>();
+}
diff --git a/src/PartSet/PartSet_ConstraintRadiusPrs.h b/src/PartSet/PartSet_ConstraintRadiusPrs.h
new file mode 100644 (file)
index 0000000..c71ac90
--- /dev/null
@@ -0,0 +1,90 @@
+// File:        PartSet_ConstraintRadiusPrs.h
+// Created:     16 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_ConstraintRadiusPrs_H
+#define PartSet_ConstraintRadiusPrs_H
+
+#include "PartSet.h"
+
+#include "PartSet_FeaturePrs.h"
+#include "PartSet_Constants.h"
+
+class GeomDataAPI_Point2D;
+class Handle_AIS_InteractiveObject;
+
+/*!
+ \class PartSet_ConstraintRadiusPrs
+ * \brief The class to define the circle feature manipulation. It is created for
+ * the feature create operation to move out the feature properties set and use one operation
+ * for any type of features.
+*/
+class PARTSET_EXPORT PartSet_ConstraintRadiusPrs : public PartSet_FeaturePrs
+{
+public:
+  /// Returns the feature type processed by this presentation
+  /// \return the feature kind
+  static std::string getKind();
+
+  /// Constructor
+  /// \param theSketch the sketch feature
+  PartSet_ConstraintRadiusPrs(FeaturePtr theSketch);
+  /// Destructor
+  virtual ~PartSet_ConstraintRadiusPrs() {};
+
+  /// Sets the feature to to a feature attribute depending on the selection mode
+  /// \param theFeature a feature instance
+  /// \param theMode the selection mode
+  /// \return whether the feature is set
+  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
+
+  /// Sets the point to the feature in an attribute depending on the selection mode
+  /// \param theX the 2D point horizontal coordinate
+  /// \param theY the 2D point vertical coordinate
+  /// \param theMode the selection mode
+  /// \return the new selection mode
+  virtual PartSet_SelectionMode setPoint(double theX, double theY,
+                                         const PartSet_SelectionMode& theMode);
+
+  /// Creates an AIS presentation if the previous is null or update the given one
+  /// \param theFeature a feature
+  /// \param theSketch a feature sketch
+  /// \param thePrevious a previuos AIS presentation
+  /// \return a created/changed AIS object with the feature parameters
+  static Handle_AIS_InteractiveObject createPresentation(FeaturePtr theFeature,
+                                                         FeaturePtr theSketch,
+                                                         Handle_AIS_InteractiveObject thePreviuos);
+
+  /// Returns the feature attribute name for the selection mode
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
+
+  /// Returns the next selection mode after the attribute
+  /// \param theAttribute the feature attribute name
+  /// \return next attribute selection mode
+  virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
+
+  /// \brief Move the full feature.
+  /// \param theDeltaX the delta for X coordinate is moved
+  /// \param theDeltaY the delta for Y coordinate is moved
+  virtual void move(double theDeltaX, double theDeltaY);
+
+  /// Return the distance between the feature and the point
+  /// \param theFeature feature object
+  /// \param theX the horizontal coordinate of the point
+  /// \param theX the vertical coordinate of the point
+  virtual double distanceToPoint(FeaturePtr theFeature, 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);
+protected:
+  /// Returns the feature point in the selection mode position.
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
+};
+
+#endif
diff --git a/src/PartSet/PartSet_FeatureDistancePrs.cpp b/src/PartSet/PartSet_FeatureDistancePrs.cpp
deleted file mode 100644 (file)
index e3e903a..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-// File:        PartSet_FeaturePrs.h
-// Created:     16 Jun 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_FeatureDistancePrs.h>
-#include <PartSet_Tools.h>
-
-#include <PartSet_FeatureLinePrs.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_ConstraintDistance.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeatureDistancePrs::PartSet_FeatureDistancePrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureDistancePrs::getKind()
-{
-  return SKETCH_CONSTRAINT_DISTANCE_KIND;
-}
-
-bool PartSet_FeatureDistancePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
-  bool aResult = false;
-  if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
-  {
-    // set length feature
-    boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
-          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-    aRef->setFeature(theFeature);
-
-    // set length value
-    aData = theFeature->data();
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-
-    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-    PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
-    aResult = true;
-  }
-  return aResult;
-}
-
-PartSet_SelectionMode PartSet_FeatureDistancePrs::setPoint(double theX, double theY,
-                                                         const PartSet_SelectionMode& theMode)
-{
-  PartSet_SelectionMode aMode = theMode;
-  switch (theMode)
-  {
-    case SM_SecondPoint: {
-      boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-      boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-              boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-      FeaturePtr aFeature;
-      if (anAttr) {
-        aFeature = anAttr->feature();
-        if (aFeature->getKind() != SKETCH_LINE_KIND) {
-          aFeature = FeaturePtr();
-        }
-      }
-      boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
-                                                             (new GeomAPI_Pnt2d(theX, theY));
-      boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
-      boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
-      double aDistance = aPoint->distance(aResult);
-
-      double aStartX, aStartY;
-      PartSet_FeatureLinePrs::getLinePoint(aFeature, LINE_ATTR_START, aStartX, aStartY);
-
-      if (!aFeatureLin->isRight(aPoint))
-        aDistance = -aDistance;
-
-      AttributeDoublePtr aFlyoutAttr = 
-          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
-      aFlyoutAttr->setValue(aDistance);
-
-      aMode = SM_DonePoint;
-    }
-    break;
-    default:
-      break;
-  }
-  return aMode;
-}
-
-std::string PartSet_FeatureDistancePrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
-  return "";
-}
-
-PartSet_SelectionMode PartSet_FeatureDistancePrs::getNextMode(const std::string& theAttribute) const
-{
-  return SM_FirstPoint;
-}
-
-void PartSet_FeatureDistancePrs::move(double theDeltaX, double theDeltaY)
-{
-}
-
-double PartSet_FeatureDistancePrs::distanceToPoint(FeaturePtr theFeature,
-                                                 double theX, double theY)
-{
-  return 0;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureDistancePrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureDistancePrs::featurePoint
-                                                     (const PartSet_SelectionMode& theMode)
-{
-  return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
diff --git a/src/PartSet/PartSet_FeatureDistancePrs.h b/src/PartSet/PartSet_FeatureDistancePrs.h
deleted file mode 100644 (file)
index 4f72829..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-// File:        PartSet_FeatureDistancePrs.h
-// Created:     16 Jun 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureDistancePrs_H
-#define PartSet_FeatureDistancePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-
-/*!
- \class PartSet_FeatureDistancePrs
- * \brief The class to define the circle feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeatureDistancePrs : public PartSet_FeaturePrs
-{
-public:
-  /// Returns the feature type processed by this presentation
-  /// \return the feature kind
-  static std::string getKind();
-
-  /// Constructor
-  /// \param theSketch the sketch feature
-  PartSet_FeatureDistancePrs(FeaturePtr theSketch);
-  /// Destructor
-  virtual ~PartSet_FeatureDistancePrs() {};
-
-  /// Sets the feature to to a feature attribute depending on the selection mode
-  /// \param theFeature a feature instance
-  /// \param theMode the selection mode
-  /// \return whether the feature is set
-  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
-  /// Sets the point to the feature in an attribute depending on the selection mode
-  /// \param theX the 2D point horizontal coordinate
-  /// \param theY the 2D point vertical coordinate
-  /// \param theMode the selection mode
-  /// \return the new selection mode
-  virtual PartSet_SelectionMode setPoint(double theX, double theY,
-                                         const PartSet_SelectionMode& theMode);
-
-  /// Returns the feature attribute name for the selection mode
-  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
-  virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
-  /// Returns the next selection mode after the attribute
-  /// \param theAttribute the feature attribute name
-  /// \return next attribute selection mode
-  virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
-  /// \brief Move the full feature.
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  virtual void move(double theDeltaX, double theDeltaY);
-
-  /// Return the distance between the feature and the point
-  /// \param theFeature feature object
-  /// \param theX the horizontal coordinate of the point
-  /// \param theX the vertical coordinate of the point
-  virtual double distanceToPoint(FeaturePtr theFeature, 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);
-protected:
-  /// Returns the feature point in the selection mode position.
-  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
diff --git a/src/PartSet/PartSet_FeatureLengthPrs.cpp b/src/PartSet/PartSet_FeatureLengthPrs.cpp
deleted file mode 100644 (file)
index bd4bdd8..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-// File:        PartSet_FeaturePrs.h
-// Created:     16 Jun 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_FeatureLengthPrs.h>
-#include <PartSet_Tools.h>
-#include <PartSet_Constants.h>
-
-#include <PartSet_FeatureLinePrs.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_ConstraintLength.h>
-
-#include <GeomDataAPI_Point.h>
-#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_LengthDimension.hxx>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeatureLengthPrs::PartSet_FeatureLengthPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureLengthPrs::getKind()
-{
-  return SKETCH_CONSTRAINT_LENGTH_KIND;
-}
-
-bool PartSet_FeatureLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
-  bool aResult = false;
-  if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
-  {
-    // set length feature
-    boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
-          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-    aRef->setFeature(theFeature);
-
-    // set length value
-    aData = theFeature->data();
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-
-    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-    PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
-    aResult = true;
-  }
-  return aResult;
-}
-
-PartSet_SelectionMode PartSet_FeatureLengthPrs::setPoint(double theX, double theY,
-                                                         const PartSet_SelectionMode& theMode)
-{
-  PartSet_SelectionMode aMode = theMode;
-  switch (theMode)
-  {
-    case SM_SecondPoint: {
-      boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-      boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-              boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-      FeaturePtr aFeature;
-      if (anAttr) {
-        aFeature = anAttr->feature();
-        if (aFeature->getKind() != SKETCH_LINE_KIND) {
-          aFeature = FeaturePtr();
-        }
-      }
-      boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
-                                                             (new GeomAPI_Pnt2d(theX, theY));
-      boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
-      boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
-      double aDistance = aPoint->distance(aResult);
-
-      double aStartX, aStartY;
-      PartSet_FeatureLinePrs::getLinePoint(aFeature, LINE_ATTR_START, aStartX, aStartY);
-
-      if (!aFeatureLin->isRight(aPoint))
-        aDistance = -aDistance;
-
-      AttributeDoublePtr aFlyoutAttr = 
-          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
-      aFlyoutAttr->setValue(aDistance);
-
-      aMode = SM_DonePoint;
-    }
-    break;
-    default:
-      break;
-  }
-  return aMode;
-}
-
-Handle(AIS_InteractiveObject) PartSet_FeatureLengthPrs::createPresentation(FeaturePtr theFeature,
-                                                       FeaturePtr theSketch,
-                                                       Handle(AIS_InteractiveObject) thePreviuos)
-{
-  if (!theFeature || !theSketch)
-    return thePreviuos;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
-  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
-  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
-    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
-  gp_Pln aPlane(aNormal->x(), aNormal->y(), aNormal->z(), 0/*D*/);
-
-  aData = theFeature->data();
-  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-  if (!anAttr)
-    return thePreviuos;
-  FeaturePtr aFeature = anAttr->feature();
-  if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
-    return thePreviuos;
-
-  boost::shared_ptr<ModelAPI_AttributeDouble> aFlyoutAttr = 
-          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
-  double aFlyout = aFlyoutAttr->value();
-
-  aData = aFeature->data();
-  if (!aData->isValid())
-    return thePreviuos;
-
-  boost::shared_ptr<GeomDataAPI_Point2D> aPointStart =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-  boost::shared_ptr<GeomDataAPI_Point2D> aPointEnd =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-
-  gp_Pnt aPoint1, aPoint2;
-  PartSet_Tools::convertTo3D(aPointStart->x(), aPointStart->y(), theSketch, aPoint1);
-  PartSet_Tools::convertTo3D(aPointEnd->x(), aPointEnd->y(), theSketch, aPoint2);
-
-  //Build dimension here
-  gp_Pnt aP1 = aPoint1;
-  gp_Pnt aP2 = aPoint2;
-  if (aFlyout < 0) {
-    aP1 = aPoint2;
-    aP2 = aPoint1;
-  }
-
-  Handle(AIS_InteractiveObject) anAIS = thePreviuos;
-  if (anAIS.IsNull())
-  {
-    Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension (aP1, aP2, aPlane);
-
-    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
-    anAspect->MakeArrows3d (Standard_False);
-    anAspect->MakeText3d(false/*is text 3d*/);
-    anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
-    anAspect->MakeTextShaded(false/*is test shaded*/);
-    aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
-    /*if (isUnitsDisplayed)
-    {
-      aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ());
-    }*/
-    aDimAIS->SetDimensionAspect (anAspect);
-    aDimAIS->SetFlyout(aFlyout);
-    aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
-
-    anAIS = aDimAIS;
-  }
-  else {
-    // update presentation
-    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
-    if (!aDimAIS.IsNull()) {
-      aDimAIS->SetMeasuredGeometry(aPoint1, aPoint2, aPlane);
-      aDimAIS->SetFlyout(aFlyout);
-
-      aDimAIS->Redisplay(Standard_True);
-    }
-  }
-  return anAIS;
-}
-
-std::string PartSet_FeatureLengthPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
-  return "";
-}
-
-PartSet_SelectionMode PartSet_FeatureLengthPrs::getNextMode(const std::string& theAttribute) const
-{
-  return SM_FirstPoint;
-}
-
-void PartSet_FeatureLengthPrs::move(double theDeltaX, double theDeltaY)
-{
-}
-
-double PartSet_FeatureLengthPrs::distanceToPoint(FeaturePtr theFeature,
-                                                 double theX, double theY)
-{
-  return 0;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLengthPrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLengthPrs::featurePoint
-                                                     (const PartSet_SelectionMode& theMode)
-{
-  return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
diff --git a/src/PartSet/PartSet_FeatureLengthPrs.h b/src/PartSet/PartSet_FeatureLengthPrs.h
deleted file mode 100644 (file)
index 90b1edd..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-// File:        PartSet_FeatureLengthPrs.h
-// Created:     16 Jun 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureLengthPrs_H
-#define PartSet_FeatureLengthPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-class Handle_AIS_InteractiveObject;
-
-/*!
- \class PartSet_FeatureLengthPrs
- * \brief The class to define the circle feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeatureLengthPrs : public PartSet_FeaturePrs
-{
-public:
-  /// Returns the feature type processed by this presentation
-  /// \return the feature kind
-  static std::string getKind();
-
-  /// Constructor
-  /// \param theSketch the sketch feature
-  PartSet_FeatureLengthPrs(FeaturePtr theSketch);
-  /// Destructor
-  virtual ~PartSet_FeatureLengthPrs() {};
-
-  /// Sets the feature to to a feature attribute depending on the selection mode
-  /// \param theFeature a feature instance
-  /// \param theMode the selection mode
-  /// \return whether the feature is set
-  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
-  /// Sets the point to the feature in an attribute depending on the selection mode
-  /// \param theX the 2D point horizontal coordinate
-  /// \param theY the 2D point vertical coordinate
-  /// \param theMode the selection mode
-  /// \return the new selection mode
-  virtual PartSet_SelectionMode setPoint(double theX, double theY,
-                                         const PartSet_SelectionMode& theMode);
-
-  /// Creates an AIS presentation if the previous is null or update the given one
-  /// \param theFeature a feature
-  /// \param theSketch a feature sketch
-  /// \param thePrevious a previuos AIS presentation
-  /// \return a created/changed AIS object with the feature parameters
-  static Handle_AIS_InteractiveObject createPresentation(FeaturePtr theFeature,
-                                                         FeaturePtr theSketch,
-                                                         Handle_AIS_InteractiveObject thePreviuos);
-
-  /// Returns the feature attribute name for the selection mode
-  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
-  virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
-  /// Returns the next selection mode after the attribute
-  /// \param theAttribute the feature attribute name
-  /// \return next attribute selection mode
-  virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
-  /// \brief Move the full feature.
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  virtual void move(double theDeltaX, double theDeltaY);
-
-  /// Return the distance between the feature and the point
-  /// \param theFeature feature object
-  /// \param theX the horizontal coordinate of the point
-  /// \param theX the vertical coordinate of the point
-  virtual double distanceToPoint(FeaturePtr theFeature, 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);
-protected:
-  /// Returns the feature point in the selection mode position.
-  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
diff --git a/src/PartSet/PartSet_FeatureRadiusPrs.cpp b/src/PartSet/PartSet_FeatureRadiusPrs.cpp
deleted file mode 100644 (file)
index 0c65679..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-// File:        PartSet_FeaturePrs.h
-// Created:     16 Jun 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_FeatureRadiusPrs.h>
-#include <PartSet_Tools.h>
-
-#include <PartSet_FeatureLinePrs.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Circle.h>
-#include <SketchPlugin_Arc.h>
-#include <SketchPlugin_ConstraintRadius.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeatureRadiusPrs::PartSet_FeatureRadiusPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureRadiusPrs::getKind()
-{
-  return SKETCH_CONSTRAINT_RADIUS_KIND;
-}
-
-bool PartSet_FeatureRadiusPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
-  bool aResult = false;
-  if (feature() && theMode == SM_FirstPoint &&
-      (theFeature && theFeature->getKind() == SKETCH_CIRCLE_KIND ||
-       theFeature && theFeature->getKind() == SKETCH_ARC_KIND)) {
-    // set length feature
-    boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
-          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-    aRef->setFeature(theFeature);
-
-    // set length value
-    /*aData = theFeature->data();
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
-          boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-
-    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-    */
-    double aLenght = 50;
-    PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
-    aResult = true;
-  }
-  return aResult;
-}
-
-PartSet_SelectionMode PartSet_FeatureRadiusPrs::setPoint(double theX, double theY,
-                                                         const PartSet_SelectionMode& theMode)
-{
-  PartSet_SelectionMode aMode = theMode;
-  switch (theMode)
-  {
-    case SM_SecondPoint: {
-      boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-      /*boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-              boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-      FeaturePtr aFeature;
-      if (anAttr) {
-        aFeature = anAttr->feature();
-        if (aFeature->getKind() != SKETCH_LINE_KIND) {
-          aFeature = FeaturePtr();
-        }
-      }
-      boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
-                                                             (new GeomAPI_Pnt2d(theX, theY));
-      boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
-      boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
-      double aDistance = aPoint->distance(aResult);
-
-      double aStartX, aStartY;
-      PartSet_FeatureLinePrs::getLinePoint(aFeature, LINE_ATTR_START, aStartX, aStartY);
-
-      if (!aFeatureLin->isRight(aPoint))
-        aDistance = -aDistance;
-        */
-      double aDistance = 40;
-      AttributeDoublePtr aFlyoutAttr = 
-          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
-      aFlyoutAttr->setValue(aDistance);
-
-      aMode = SM_DonePoint;
-    }
-    break;
-    default:
-      break;
-  }
-  return aMode;
-}
-
-std::string PartSet_FeatureRadiusPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
-  return "";
-}
-
-PartSet_SelectionMode PartSet_FeatureRadiusPrs::getNextMode(const std::string& theAttribute) const
-{
-  return SM_FirstPoint;
-}
-
-void PartSet_FeatureRadiusPrs::move(double theDeltaX, double theDeltaY)
-{
-}
-
-double PartSet_FeatureRadiusPrs::distanceToPoint(FeaturePtr theFeature,
-                                                 double theX, double theY)
-{
-  return 0;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureRadiusPrs::findPoint(FeaturePtr theFeature,
-                                                                           double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  return aPoint2D;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureRadiusPrs::featurePoint
-                                                     (const PartSet_SelectionMode& theMode)
-{
-  return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
diff --git a/src/PartSet/PartSet_FeatureRadiusPrs.h b/src/PartSet/PartSet_FeatureRadiusPrs.h
deleted file mode 100644 (file)
index fcdaa64..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-// File:        PartSet_FeatureRadiusPrs.h
-// Created:     16 Jun 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureRadiusPrs_H
-#define PartSet_FeatureRadiusPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-
-/*!
- \class PartSet_FeatureRadiusPrs
- * \brief The class to define the circle feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeatureRadiusPrs : public PartSet_FeaturePrs
-{
-public:
-  /// Returns the feature type processed by this presentation
-  /// \return the feature kind
-  static std::string getKind();
-
-  /// Constructor
-  /// \param theSketch the sketch feature
-  PartSet_FeatureRadiusPrs(FeaturePtr theSketch);
-  /// Destructor
-  virtual ~PartSet_FeatureRadiusPrs() {};
-
-  /// Sets the feature to to a feature attribute depending on the selection mode
-  /// \param theFeature a feature instance
-  /// \param theMode the selection mode
-  /// \return whether the feature is set
-  virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
-  /// Sets the point to the feature in an attribute depending on the selection mode
-  /// \param theX the 2D point horizontal coordinate
-  /// \param theY the 2D point vertical coordinate
-  /// \param theMode the selection mode
-  /// \return the new selection mode
-  virtual PartSet_SelectionMode setPoint(double theX, double theY,
-                                         const PartSet_SelectionMode& theMode);
-
-  /// Returns the feature attribute name for the selection mode
-  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
-  virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
-  /// Returns the next selection mode after the attribute
-  /// \param theAttribute the feature attribute name
-  /// \return next attribute selection mode
-  virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
-  /// \brief Move the full feature.
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  virtual void move(double theDeltaX, double theDeltaY);
-
-  /// Return the distance between the feature and the point
-  /// \param theFeature feature object
-  /// \param theX the horizontal coordinate of the point
-  /// \param theX the vertical coordinate of the point
-  virtual double distanceToPoint(FeaturePtr theFeature, 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);
-protected:
-  /// Returns the feature point in the selection mode position.
-  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
-  virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
index d4e9e51758b96e6851e449b7816c223319a30495..20558f3cbe03b04723886a727847857efdae9964 100644 (file)
@@ -19,9 +19,9 @@
 #include <SketchPlugin_Arc.h>
 */
 
-#include <PartSet_FeatureLengthPrs.h>
-#include <PartSet_FeatureDistancePrs.h>
-#include <PartSet_FeatureRadiusPrs.h>
+#include <PartSet_ConstraintLengthPrs.h>
+#include <PartSet_ConstraintDistancePrs.h>
+#include <PartSet_ConstraintRadiusPrs.h>
 
 #include <SketchPlugin_Constraint.h>
 
@@ -64,9 +64,9 @@ PartSet_OperationCreateConstraint::~PartSet_OperationCreateConstraint()
 bool PartSet_OperationCreateConstraint::canProcessKind(const std::string& theId)
 {
   // changed
-  return theId == PartSet_FeatureLengthPrs::getKind() ||
-         theId == PartSet_FeatureDistancePrs::getKind() ||
-         theId == PartSet_FeatureRadiusPrs::getKind();
+  return theId == PartSet_ConstraintLengthPrs::getKind() ||
+         theId == PartSet_ConstraintDistancePrs::getKind() ||
+         theId == PartSet_ConstraintRadiusPrs::getKind();
 }
 
 bool PartSet_OperationCreateConstraint::canBeCommitted() const
index 5d174047b4f3495dc85ede5968d66a32bb2f4b74..09ecbaa65323d0651c69fb9469cbba672616eb23 100644 (file)
@@ -5,7 +5,9 @@
 #include <PartSet_Presentation.h>
 #include <PartSet_Tools.h>
 
-#include <PartSet_FeatureLengthPrs.h>
+#include <PartSet_ConstraintLengthPrs.h>
+#include <PartSet_ConstraintDistancePrs.h>
+#include <PartSet_ConstraintRadiusPrs.h>
 
 #include <ModelAPI_Feature.h>
 
@@ -28,8 +30,12 @@ Handle(AIS_InteractiveObject) PartSet_Presentation::createPresentation(
   Handle(AIS_InteractiveObject) anAIS;
 
   std::string aKind = theFeature->getKind();
-  if (aKind == PartSet_FeatureLengthPrs::getKind())
-    anAIS = PartSet_FeatureLengthPrs::createPresentation(theFeature, theSketch, thePreviuos);
+  if (aKind == PartSet_ConstraintLengthPrs::getKind())
+    anAIS = PartSet_ConstraintLengthPrs::createPresentation(theFeature, theSketch, thePreviuos);
+  else if (aKind == PartSet_ConstraintDistancePrs::getKind())
+    anAIS = PartSet_ConstraintDistancePrs::createPresentation(theFeature, theSketch, thePreviuos);
+  else if (aKind == PartSet_ConstraintRadiusPrs::getKind())
+    anAIS = PartSet_ConstraintRadiusPrs::createPresentation(theFeature, theSketch, thePreviuos);
   else {
     anAIS = createFeature(theFeature, theShape, thePreviuos);
     if (theFeature->getKind() == SKETCH_KIND)
index a8868beb7998ac9458e458b937e63ce8c6413787..30bdc0b131d3eaa76565709bbf04c106a6bff545 100644 (file)
@@ -25,9 +25,9 @@
 #include <PartSet_FeatureCirclePrs.h>
 #include <PartSet_FeatureArcPrs.h>
 
-#include <PartSet_FeatureLengthPrs.h>
-#include <PartSet_FeatureRadiusPrs.h>
-#include <PartSet_FeatureDistancePrs.h>
+#include <PartSet_ConstraintLengthPrs.h>
+#include <PartSet_ConstraintRadiusPrs.h>
+#include <PartSet_ConstraintDistancePrs.h>
 
 #include <XGUI_ViewerPrs.h>
 
@@ -156,14 +156,14 @@ boost::shared_ptr<PartSet_FeaturePrs> PartSet_Tools::createFeaturePrs(const std:
   else if (theKind == PartSet_FeatureArcPrs::getKind()) {
     aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureArcPrs(theSketch));
   }
-  else if (theKind == PartSet_FeatureLengthPrs::getKind()) {
-    aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureLengthPrs(theSketch));
+  else if (theKind == PartSet_ConstraintLengthPrs::getKind()) {
+    aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_ConstraintLengthPrs(theSketch));
   }
-  else if (theKind == PartSet_FeatureRadiusPrs::getKind()) {
-    aFeaturePrs = boost::shared_ptr<PartSet_FeatureRadiusPrs>(new PartSet_FeatureRadiusPrs(theSketch));
+  else if (theKind == PartSet_ConstraintRadiusPrs::getKind()) {
+    aFeaturePrs = boost::shared_ptr<PartSet_ConstraintRadiusPrs>(new PartSet_ConstraintRadiusPrs(theSketch));
   }
-  else if (theKind == PartSet_FeatureDistancePrs::getKind()) {
-    aFeaturePrs = boost::shared_ptr<PartSet_FeatureDistancePrs>(new PartSet_FeatureDistancePrs(theSketch));
+  else if (theKind == PartSet_ConstraintDistancePrs::getKind()) {
+    aFeaturePrs = boost::shared_ptr<PartSet_ConstraintDistancePrs>(new PartSet_ConstraintDistancePrs(theSketch));
   }
 
 
index e91d65a16bc5491c0473d65a62b2f1fcc3283b15..ed3a1b2a79a6813e46b1bf391598ae21a5b54331 100644 (file)
@@ -361,6 +361,7 @@ boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWork
 // ============================================================================
 void SketchSolver_ConstraintManager::resolveConstraints()
 {
+  return; // myConstrSolver.solve() gives an exception
   std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
     (*aGroupIter)->resolveConstraints();