1. Remove feature presentation. Functionality is moved to SketchPlugin and ModelWidget.
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_FeaturePrs.h
- PartSet_FeatureLinePrs.h
- PartSet_FeaturePointPrs.h
PartSet_Listener.h
PartSet_Module.h
PartSet_OperationFeatureCreate.h
)
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_FeatureLinePrs.cpp
- PartSet_FeaturePointPrs.cpp
PartSet_Listener.cpp
PartSet_Module.cpp
PartSet_OperationFeatureCreate.cpp
/// This file contains various constants used in the PartSet module
-/// Types of viewer selection in an operation
-enum PartSet_SelectionMode
-{
- SM_FirstPoint,
- SM_SecondPoint,
- SM_ThirdPoint,
- SM_LastPoint,
- SM_DonePoint
-};
-
////const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
////const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
+++ /dev/null
-// 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_Point.h>
-#include <SketchPlugin_ConstraintDistance.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pln.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 <AIS_LengthDimension.hxx>
-
-#include <Precision.hxx>
-#include <gp_Pln.hxx>
-
-using namespace std;
-
-PartSet_ConstraintDistancePrs::PartSet_ConstraintDistancePrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_ConstraintDistancePrs::getKind()
-{
- return SKETCH_CONSTRAINT_DISTANCE_KIND;
-}
-
-PartSet_SelectionMode PartSet_ConstraintDistancePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- if (!feature() || !theFeature)
- return aMode;
-
- std::string anArgument;
- if (theMode == SM_FirstPoint) {
- anArgument = CONSTRAINT_ATTR_ENTITY_A;
- aMode = SM_SecondPoint;
- }
- else if (theMode == SM_SecondPoint) {
- anArgument = CONSTRAINT_ATTR_ENTITY_B;
- aMode = SM_LastPoint;
- }
- if (theFeature->getKind() == SKETCH_POINT_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(anArgument));
- aRef->setFeature(theFeature);
- }
-
- if (theMode == SM_SecondPoint) {
- // set length value
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(feature(), CONSTRAINT_ATTR_ENTITY_A);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(feature(), CONSTRAINT_ATTR_ENTITY_B);
-
- if (aPoint_A && aPoint_B) {
- double aLenght = aPoint_A->pnt()->distance(aPoint_B->pnt());
- PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
- }
- }
-
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_ConstraintDistancePrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_LastPoint: {
- boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(feature()->data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
- aFlyOutAttr->setValue(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
-
- boost::shared_ptr<GeomAPI_Pnt2d> aFlyOutPnt = aFlyOutAttr->pnt();
-
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::getFeaturePoint
- (FeaturePtr theFeature,
- const std::string& theAttribute)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
-
- FeaturePtr aFeature = PartSet_Tools::feature(theFeature, theAttribute, SKETCH_POINT_KIND);
- if (aFeature)
- aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aFeature->data()->attribute(POINT_ATTR_COORD));
- return aPointAttr;
-}
-
-std::string PartSet_ConstraintDistancePrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- return "";
-}
-
-PartSet_SelectionMode PartSet_ConstraintDistancePrs::getNextMode(const std::string& theAttribute) const
-{
- return SM_FirstPoint;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
+++ /dev/null
-// 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 PartSet_SelectionMode 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;
-
-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);
-
-private:
- /// Find the feature point
- /// \param theFeature the constraint feature
- /// \param theAttribute a distance constraint attribute name of feature
- /// \return the point in the feature
- static boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(FeaturePtr theFeature,
- const std::string& theAttribute);
-};
-
-#endif
+++ /dev/null
-// 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 <GeomAPI_Pln.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;
-}
-
-PartSet_SelectionMode PartSet_ConstraintLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- 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);
- aMode = SM_LastPoint;
- }
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_ConstraintLengthPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_LastPoint: {
- 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);
-
- 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_ConstraintLengthPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- return "";
-}
-
-PartSet_SelectionMode PartSet_ConstraintLengthPrs::getNextMode(const std::string& theAttribute) const
-{
- return SM_FirstPoint;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
+++ /dev/null
-// 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 PartSet_SelectionMode 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;
-
-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
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 16 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_ConstraintRadiusPrs.h>
-#include <PartSet_Tools.h>
-
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_FeatureArcPrs.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_Point.h>
-#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pln.h>
-#include <GeomAPI_Dir.h>
-
-#include <GeomAlgoAPI_EdgeBuilder.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 <AIS_RadiusDimension.hxx>
-#include <Precision.hxx>
-#include <gp_Circ.hxx>
-#include <V3d_View.hxx>
-
-using namespace std;
-
-PartSet_ConstraintRadiusPrs::PartSet_ConstraintRadiusPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_ConstraintRadiusPrs::getKind()
-{
- return SKETCH_CONSTRAINT_RADIUS_KIND;
-}
-
-PartSet_SelectionMode PartSet_ConstraintRadiusPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- if (!feature() || theMode != SM_FirstPoint || !theFeature) {
- return aMode;
- }
- std::string aKind = theFeature->getKind();
- if (aKind == SKETCH_CIRCLE_KIND || aKind == 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);
-
- double aLength = 50;
- bool isValid;
- if (aKind == SKETCH_CIRCLE_KIND) {
- aLength = PartSet_Tools::featureValue(theFeature, CIRCLE_ATTR_RADIUS, isValid);
- }
- else if (aKind == SKETCH_ARC_KIND) {
- aLength = PartSet_FeatureArcPrs::radius(theFeature);
- }
-
- PartSet_Tools::setFeatureValue(feature(), aLength, CONSTRAINT_ATTR_VALUE);
- aMode = SM_LastPoint;
- }
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_ConstraintRadiusPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_LastPoint: {
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
- (new GeomAPI_Pnt2d(theX, theY));
-
- //PartSet_Tools::setFeaturePoint(feature(), theX, theY, SKETCH_CONSTRAINT_ATTR_CIRCLE_POINT);
-
- //double aDistance = 40;
- //AttributeDoublePtr aFlyoutAttr =
- // boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
- //aFlyoutAttr->setValue(aDistance);
-
- aMode = SM_LastPoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-void PartSet_ConstraintRadiusPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
- gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
- if (!anAttr)
- return;
- FeaturePtr aFeature = anAttr->feature();
- if (!aFeature)
- return;
-
- gp_Circ aCircle;
- gp_Pnt anAnchorPoint;
- if (aFeature->getKind() == SKETCH_CIRCLE_KIND) {
- PartSet_FeatureCirclePrs::projectPointOnFeature(aFeature, theSketch, thePoint, theView, theX, theY);
- }
- else if (aFeature->getKind() == SKETCH_ARC_KIND) {
- PartSet_FeatureArcPrs::projectPointOnFeature(aFeature, theSketch, thePoint, theView, theX, theY);
- }
- // TODO: a bug in AIS_RadiusDimension:
- // The anchor point can't be myCirc.Location() - an exception is raised.
- // But we need exactly this case...
- // We want to show a radius dimension starting from the circle centre and
- // ending at the user-defined point.
- // Also, if anchor point coincides with myP2, the radius dimension is not displayed at all.
- double aDelta = 1/1000.0;
- theX += aDelta;
- theY += aDelta;
-}
-
-std::string PartSet_ConstraintRadiusPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- return "";
-}
-
-PartSet_SelectionMode PartSet_ConstraintRadiusPrs::getNextMode(const std::string& theAttribute) const
-{
- return SM_FirstPoint;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
+++ /dev/null
-// 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"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class Handle_AIS_InteractiveObject;
-class Handle_V3d_View;
-
-/*!
- \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 PartSet_SelectionMode 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;
-
- /// Project the view point on the feature. The output coordinates belong to the feature
- /// \param theFeature a feature
- /// \param theSketch the sketch feature
- /// \param thePoint a viewer point
- /// \param theView the OCC view
- /// \theX the output horizontal coordinate of a projected point
- /// \theY the output vertical coordinate of a projected point
- static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
- Handle_V3d_View theView, 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
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeatureArcPrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Arc.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Circ2d.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <V3d_View.hxx>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeatureArcPrs::PartSet_FeatureArcPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureArcPrs::getKind()
-{
- return SKETCH_ARC_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeatureArcPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, ARC_ATTR_CENTER);
- aMode = SM_SecondPoint;
- }
- break;
- case SM_SecondPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, ARC_ATTR_START);
- aMode = SM_ThirdPoint;
- }
- break;
- case SM_ThirdPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, ARC_ATTR_END);
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-std::string PartSet_FeatureArcPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = ARC_ATTR_CENTER;
- break;
- case SM_SecondPoint:
- aAttribute = ARC_ATTR_START;
- break;
- case SM_ThirdPoint:
- aAttribute = ARC_ATTR_END;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeatureArcPrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == ARC_ATTR_CENTER)
- aMode = SM_SecondPoint;
- else if (theAttribute == ARC_ATTR_START)
- aMode = SM_ThirdPoint;
- else if (theAttribute == ARC_ATTR_END)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-void PartSet_FeatureArcPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
- gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- FeaturePtr aSketch = theSketch;
- if (aSketch) {
- double aX, anY;
- PartSet_Tools::convertTo2D(thePoint, aSketch, theView, aX, anY);
-
- // circle origin point and radius
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aCenter = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(ARC_ATTR_CENTER));
- boost::shared_ptr<GeomDataAPI_Point2D> aStart = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(ARC_ATTR_START));
-
- boost::shared_ptr<GeomAPI_Circ2d> aCirc(new GeomAPI_Circ2d(aCenter->pnt(), aStart->pnt()));
- boost::shared_ptr<GeomAPI_Pnt2d> aGeomPoint2d(new GeomAPI_Pnt2d(aX, anY));
- boost::shared_ptr<GeomAPI_Pnt2d> aPnt2d = aCirc->project(aGeomPoint2d);
- if (aPnt2d) {
- theX = aPnt2d->x();
- theY = aPnt2d->y();
- }
- }
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureArcPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = ARC_ATTR_CENTER;
- break;
- case SM_SecondPoint:
- aPointArg = ARC_ATTR_START;
- break;
- case SM_ThirdPoint:
- aPointArg = ARC_ATTR_END;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
-
-double PartSet_FeatureArcPrs::radius(FeaturePtr theFeature)
-{
- if (!theFeature)
- return 0;
-
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
-
- return aCenterAttr->pnt()->distance(aStartAttr->pnt());
-}
+++ /dev/null
-// File: PartSet_FeatureArcPrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureArcPrs_H
-#define PartSet_FeatureArcPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class Handle_V3d_View;
-
-/*!
- \class PartSet_FeatureArcPrs
- * \brief The class to define the circle arc 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_FeatureArcPrs : 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_FeatureArcPrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeatureArcPrs() {};
-
- /// 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;
-
- /// Project the view point on the feature. The output coordinates belong to the feature
- /// \param theFeature a feature
- /// \param theSketch the sketch feature
- /// \param thePoint a viewer point
- /// \param theView the OCC view
- /// \theX the output horizontal coordinate of a projected point
- /// \theY the output vertical coordinate of a projected point
- static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
- Handle_V3d_View theView, double& theX, double& theY);
-
- /// Computes the feature's radius
- /// \param theFeature an arc feature
- /// \return the double value
- static double radius(FeaturePtr theFeature);
-
-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
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Circle.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Circ2d.h>
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_Dir.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <V3d_View.hxx>
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeatureCirclePrs::PartSet_FeatureCirclePrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureCirclePrs::getKind()
-{
- return SKETCH_CIRCLE_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeatureCirclePrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, CIRCLE_ATTR_CENTER);
- aMode = SM_SecondPoint;
- }
- break;
- case SM_SecondPoint: {
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(CIRCLE_ATTR_CENTER));
- boost::shared_ptr<GeomAPI_Pnt2d> aCoordPoint(new GeomAPI_Pnt2d(theX, theY));
- double aRadius = aCoordPoint->distance(aPoint->pnt());
- PartSet_Tools::setFeatureValue(feature(), aRadius, CIRCLE_ATTR_RADIUS);
-
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-std::string PartSet_FeatureCirclePrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = CIRCLE_ATTR_CENTER;
- break;
- case SM_SecondPoint:
- aAttribute = CIRCLE_ATTR_RADIUS;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeatureCirclePrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == CIRCLE_ATTR_CENTER)
- aMode = SM_SecondPoint;
- else if (theAttribute == CIRCLE_ATTR_RADIUS)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-void PartSet_FeatureCirclePrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
- gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- FeaturePtr aSketch = theSketch;
- if (aSketch) {
- double aX, anY;
- PartSet_Tools::convertTo2D(thePoint, aSketch, theView, aX, anY);
-
- // circle origin point and radius
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aCenter = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(CIRCLE_ATTR_CENTER));
- bool isValid;
- double aRadius = PartSet_Tools::featureValue(theFeature, CIRCLE_ATTR_RADIUS, isValid);
-
- boost::shared_ptr<GeomAPI_Dir2d> aNormal(new GeomAPI_Dir2d(aX, anY));
- boost::shared_ptr<GeomAPI_Circ2d> aCirc(new GeomAPI_Circ2d(aCenter->pnt(), aNormal, aRadius));
- boost::shared_ptr<GeomAPI_Pnt2d> aGeomPoint2d(new GeomAPI_Pnt2d(aX, anY));
- boost::shared_ptr<GeomAPI_Pnt2d> aPnt2d = aCirc->project(aGeomPoint2d);
- if (aPnt2d) {
- theX = aPnt2d->x();
- theY = aPnt2d->y();
- }
- }
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureCirclePrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = CIRCLE_ATTR_CENTER;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
+++ /dev/null
-// File: PartSet_FeatureCirclePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureCirclePrs_H
-#define PartSet_FeatureCirclePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class Handle_V3d_View;
-
-/*!
- \class PartSet_FeatureCirclePrs
- * \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_FeatureCirclePrs : 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_FeatureCirclePrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeatureCirclePrs() {};
-
- /// 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;
-
- /// Project the view point on the feature. The output coordinates belong to the feature
- /// \param theFeature a feature
- /// \param theSketch the sketch feature
- /// \param thePoint a viewer point
- /// \param theView the OCC view
- /// \theX the output horizontal coordinate of a projected point
- /// \theY the output vertical coordinate of a projected point
- static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
- Handle_V3d_View theView, 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
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeatureLinePrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_ConstraintCoincidence.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Constraint.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pnt2d.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <Precision.hxx>
-#include <V3d_View.hxx>
-
-using namespace std;
-
-PartSet_FeatureLinePrs::PartSet_FeatureLinePrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureLinePrs::getKind()
-{
- return SKETCH_LINE_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_START);
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
- aMode = SM_SecondPoint;
- }
- break;
- case SM_SecondPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- if (feature() && theFeature && theMode == SM_FirstPoint)
- {
- // use the last point of the previous feature as the first of the new one
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> anInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(LINE_ATTR_END));
- PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START);
- PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END);
-
- aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(LINE_ATTR_START));
- PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
- aMode = SM_SecondPoint;
- }
- return aMode;
-}
-
-std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = LINE_ATTR_START;
- break;
- case SM_SecondPoint:
- aAttribute = LINE_ATTR_END;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeatureLinePrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == LINE_ATTR_START)
- aMode = SM_SecondPoint;
- else if (theAttribute == LINE_ATTR_END)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature,
- const PartSet_SelectionMode& theMode,
- const gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- if (theFeature && theFeature->getKind() == getKind()) {
- double X0, X1;
- double Y0, Y1;
-
- PartSet_Tools::convertTo2D(thePoint, sketch(), theView, X1, Y1);
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(X1, Y1));
- boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(theFeature);
-
- switch (theMode) {
- case SM_FirstPoint: {
- boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
- theX = aResult->x();
- theY = aResult->y();
- }
- break;
- case SM_SecondPoint: {
- getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
- boost::shared_ptr<GeomAPI_Lin2d> aCurrentLin = boost::shared_ptr<GeomAPI_Lin2d>
- (new GeomAPI_Lin2d(X0, Y0, X1, Y1));
- boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->intersect(aCurrentLin);
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint0 = boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(X0, Y0));
- if (aResult->distance(aPoint0) < Precision::Confusion()) { // the start point is nearest to the line
- // if the first point of a line belongs to the given line
- // we need to project the second point on the same line
- aResult = aFeatureLin->project(aPoint);
- }
- theX = aResult->x();
- theY = aResult->y();
- }
- break;
- default:
- break;
- }
- }
-}
-
-boost::shared_ptr<GeomAPI_Lin2d> PartSet_FeatureLinePrs::createLin2d(FeaturePtr theFeature)
-{
- boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin;
- if (!theFeature || theFeature->getKind() != PartSet_FeatureLinePrs::getKind())
- return aFeatureLin;
-
- double aStartX, aStartY, anEndX, anEndY;
- getLinePoint(theFeature, LINE_ATTR_START, aStartX, aStartY);
- getLinePoint(theFeature, LINE_ATTR_END, anEndX, anEndY);
-
- aFeatureLin = boost::shared_ptr<GeomAPI_Lin2d>
- (new GeomAPI_Lin2d(aStartX, aStartY, anEndX, anEndY));
- return aFeatureLin;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLinePrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = LINE_ATTR_START;
- break;
- case SM_SecondPoint:
- aPointArg = LINE_ATTR_END;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
-
-void PartSet_FeatureLinePrs::getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
- double& theX, double& theY)
-{
- if (!theFeature || theFeature->getKind() != PartSet_FeatureLinePrs::getKind())
- return;
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
- theX = aPoint->x();
- theY = aPoint->y();
-}
+++ /dev/null
-// File: PartSet_FeatureLinePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureLinePrs_H
-#define PartSet_FeatureLinePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class GeomAPI_Lin2d;
-class Handle_V3d_View;
-
-/*!
- \class PartSet_FeatureLinePrs
- * \brief The class to define the line 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_FeatureLinePrs : 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_FeatureLinePrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeatureLinePrs() {};
-
- /// 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);
-
- /// 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 PartSet_SelectionMode setFeature(FeaturePtr theFeature, 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;
-
- /// Project the point on a feature
- /// \param theFeature the feature to be projected on
- /// \param theMode the selection mode
- /// \param thePoint the clicked point
- /// \param theView the viewer
- /// \param theX the output horizontal coordinate
- /// \param theY the output vertical coordinate
- void projectPointOnLine(FeaturePtr theFeature, const PartSet_SelectionMode& theMode,
- const gp_Pnt& thePoint, Handle_V3d_View theView,
- 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);
- /// \brief Get the line point 2d coordinates.
- /// \param theFeature the line feature
- /// \param theAttribute the start or end attribute of the line
- /// \param theX the horizontal coordinate
- /// \param theY the vertical coordinate
- static void getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
- 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
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeaturePointPrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Point.h>
-
-#include <GeomAPI_Pnt2d.h>
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeaturePointPrs::PartSet_FeaturePointPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeaturePointPrs::getKind()
-{
- return SKETCH_POINT_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeaturePointPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, POINT_ATTR_COORD);
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-std::string PartSet_FeaturePointPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = POINT_ATTR_COORD;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeaturePointPrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == POINT_ATTR_COORD)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = POINT_ATTR_COORD;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
+++ /dev/null
-// File: PartSet_FeaturePointPrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeaturePointPrs_H
-#define PartSet_FeaturePointPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-
-/*!
- \class PartSet_FeaturePointPrs
- * \brief The class to define the point 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_FeaturePointPrs : 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_FeaturePointPrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeaturePointPrs() {};
-
- /// 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;
-
-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
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeaturePrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeaturePrs::PartSet_FeaturePrs(FeaturePtr theFeature)
-: mySketch(theFeature)
-{
-}
-
-PartSet_FeaturePrs::~PartSet_FeaturePrs()
-{
-}
-
-void PartSet_FeaturePrs::init(FeaturePtr theFeature)
-{
- myFeature = theFeature;
-}
-
-FeaturePtr PartSet_FeaturePrs::sketch() const
-{
- return mySketch;
-}
-
-FeaturePtr PartSet_FeaturePrs::feature() const
-{
- return myFeature;
-}
-
-PartSet_SelectionMode PartSet_FeaturePrs::setFeature(FeaturePtr theFeature,
- const PartSet_SelectionMode& theMode)
-{
- return SM_FirstPoint;
-}
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeaturePrs_H
-#define PartSet_FeaturePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-
-/*!
- \class PartSet_FeaturePrs
- * \brief The abstract class to define the specific 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_FeaturePrs
-{
-public:
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_FeaturePrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeaturePrs();
-
- /// Initializes some fields of feature accorging to the source feature
- /// Saves the fiature as the presentation internal feature
- /// \param theFeature the presentation feature
- void init(FeaturePtr theFeature);
-
- /// Returns the operation sketch feature
- /// \returns the sketch instance
- FeaturePtr sketch() const;
-
- /// 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) = 0;
-
- /// 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
- /// \return the new selection mode
- virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, 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 = 0;
-
- /// 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 = 0;
-
-protected:
- /// Returns the operation feature
- /// \return the feature
- FeaturePtr feature() const;
-
- /// 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) = 0;
-
-private:
- FeaturePtr mySketch; ///< the sketch of the feature
- FeaturePtr myFeature; ///< the feature
-};
-
-#endif
#include <PartSet_Tools.h>
#include <PartSet_OperationSketch.h>
-#include <PartSet_FeaturePointPrs.h>
-#include <PartSet_FeatureLinePrs.h>
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_FeatureArcPrs.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Point.h>
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
// move to selected line
if (feature()->getKind() == SKETCH_LINE_KIND) {
- //boost::shared_ptr<PartSet_FeatureLinePrs> aLinePrs =
- // boost::dynamic_pointer_cast<PartSet_FeatureLinePrs>(myFeaturePrs);
- //if (aLinePrs) {
- // FeaturePtr aFeature = aPrs.feature();
- //aLinePrs->projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
- //}
+ //FeaturePtr aFeature = aPrs.feature();
+ //projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
}
}
}
#include <QObject>
-class PartSet_FeaturePrs;
class GeomDataAPI_Point2D;
class QMouseEvent;
class QKeyEvent;
bool setWidgetFeature(const FeaturePtr& theFeature);
private:
- //boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
FeaturePtr myInitFeature; ///< the initial feature
FeaturePtr mySketch; ///< the sketch of the feature
- //PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
};
#include <XGUI_Displayer.h>
#include <XGUI_ViewerPrs.h>
#include <XGUI_ViewerProxy.h>
-#include <PartSet_FeaturePrs.h>
#include <PartSet_Tools.h>
#include <PartSet_OperationSketchBase.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintRadius.h>
#include <SketchPlugin_Constraint.h>
-#include <PartSet_FeatureLinePrs.h>
-#include <PartSet_FeaturePointPrs.h>
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_FeatureArcPrs.h>
-
-#include <PartSet_ConstraintLengthPrs.h>
-#include <PartSet_ConstraintRadiusPrs.h>
-#include <PartSet_ConstraintDistancePrs.h>
-
#include <XGUI_ViewerPrs.h>
#include <V3d_View.hxx>
thePoint = gp_Pnt(aPoint->x(), aPoint->y(), aPoint->z());
}
-boost::shared_ptr<PartSet_FeaturePrs> PartSet_Tools::createFeaturePrs(const std::string& theKind,
- FeaturePtr theSketch,
- FeaturePtr theFeature)
-{
- boost::shared_ptr<PartSet_FeaturePrs> aFeaturePrs;
-
- if (theKind == PartSet_FeaturePointPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeaturePointPrs(theSketch));
- }
- else if (theKind == PartSet_FeatureLinePrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureLinePrs(theSketch));
- }
- else if (theKind == PartSet_FeatureCirclePrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureCirclePrs(theSketch));
- }
- else if (theKind == PartSet_FeatureArcPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureArcPrs(theSketch));
- }
- else if (theKind == PartSet_ConstraintLengthPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_ConstraintLengthPrs(theSketch));
- }
- else if (theKind == PartSet_ConstraintRadiusPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_ConstraintRadiusPrs>(new PartSet_ConstraintRadiusPrs(theSketch));
- }
- else if (theKind == PartSet_ConstraintDistancePrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_ConstraintDistancePrs>(new PartSet_ConstraintDistancePrs(theSketch));
- }
-
-
- if (theFeature && aFeaturePrs)
- aFeaturePrs->init(theFeature);
-
- return aFeaturePrs;
-}
-
FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView,
FeaturePtr theSketch,
const std::list<XGUI_ViewerPrs>& theFeatures)
bool PartSet_Tools::isConstraintFeature(const std::string& theKind)
{
- return theKind == PartSet_ConstraintLengthPrs::getKind() ||
- theKind == PartSet_ConstraintDistancePrs::getKind() ||
- theKind == PartSet_ConstraintRadiusPrs::getKind();
+ return theKind == SKETCH_CONSTRAINT_DISTANCE_KIND ||
+ theKind == SKETCH_CONSTRAINT_LENGTH_KIND ||
+ theKind == SKETCH_CONSTRAINT_RADIUS_KIND;
}
class GeomAPI_Pln;
class GeomAPI_Pnt2d;
class GeomAPI_Pnt;
-class PartSet_FeaturePrs;
/*!
\class PartSet_Tools
static void convertTo3D(const double theX, const double theY, FeaturePtr theSketch,
gp_Pnt& thePoint);
- /// Creates the feature presentation
- /// \param theKind a feature kind
- /// \param theSketch the sketch of the feature
- /// \param theFeature the feature
- static boost::shared_ptr<PartSet_FeaturePrs> createFeaturePrs(const std::string& theKind,
- FeaturePtr theSketch,
- FeaturePtr theFeature = FeaturePtr());
-
/// Returns a feature that is under the mouse point
/// \param thePoint a screen point
/// \param theView a 3D view