From: nds Date: Wed, 25 Jun 2014 16:25:26 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~233 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0efdf638cf1e7bc36c6ef9d566a154c087a3eaec;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc 1. Remove feature presentation. Functionality is moved to SketchPlugin and ModelWidget. --- diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 794def403..a111f8161 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -5,15 +5,7 @@ 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_FeaturePrs.h - PartSet_FeatureLinePrs.h - PartSet_FeaturePointPrs.h PartSet_Listener.h PartSet_Module.h PartSet_OperationFeatureCreate.h @@ -26,15 +18,7 @@ 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_FeatureLinePrs.cpp - PartSet_FeaturePointPrs.cpp PartSet_Listener.cpp PartSet_Module.cpp PartSet_OperationFeatureCreate.cpp diff --git a/src/PartSet/PartSet_Constants.h b/src/PartSet/PartSet_Constants.h index f55b58048..17c0f5e5f 100644 --- a/src/PartSet/PartSet_Constants.h +++ b/src/PartSet/PartSet_Constants.h @@ -9,16 +9,6 @@ /// 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 diff --git a/src/PartSet/PartSet_ConstraintDistancePrs.cpp b/src/PartSet/PartSet_ConstraintDistancePrs.cpp deleted file mode 100644 index 8dc195a94..000000000 --- a/src/PartSet/PartSet_ConstraintDistancePrs.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 16 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -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 aData = feature()->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(anArgument)); - aRef->setFeature(theFeature); - } - - if (theMode == SM_SecondPoint) { - // set length value - boost::shared_ptr aPoint_A = getFeaturePoint(feature(), CONSTRAINT_ATTR_ENTITY_A); - boost::shared_ptr 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 aFlyOutAttr = - boost::dynamic_pointer_cast(feature()->data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT)); - aFlyOutAttr->setValue(boost::shared_ptr(new GeomAPI_Pnt2d(theX, theY))); - - boost::shared_ptr aFlyOutPnt = aFlyOutAttr->pnt(); - - aMode = SM_DonePoint; - } - break; - default: - break; - } - return aMode; -} - -boost::shared_ptr PartSet_ConstraintDistancePrs::getFeaturePoint - (FeaturePtr theFeature, - const std::string& theAttribute) -{ - boost::shared_ptr aPointAttr; - - FeaturePtr aFeature = PartSet_Tools::feature(theFeature, theAttribute, SKETCH_POINT_KIND); - if (aFeature) - aPointAttr = boost::dynamic_pointer_cast - (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 PartSet_ConstraintDistancePrs::featurePoint - (const PartSet_SelectionMode& theMode) -{ - return boost::shared_ptr(); -} diff --git a/src/PartSet/PartSet_ConstraintDistancePrs.h b/src/PartSet/PartSet_ConstraintDistancePrs.h deleted file mode 100644 index 8d711540b..000000000 --- a/src/PartSet/PartSet_ConstraintDistancePrs.h +++ /dev/null @@ -1,72 +0,0 @@ -// 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 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 getFeaturePoint(FeaturePtr theFeature, - const std::string& theAttribute); -}; - -#endif diff --git a/src/PartSet/PartSet_ConstraintLengthPrs.cpp b/src/PartSet/PartSet_ConstraintLengthPrs.cpp deleted file mode 100644 index 9e4140291..000000000 --- a/src/PartSet/PartSet_ConstraintLengthPrs.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 16 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -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 aData = feature()->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); - aRef->setFeature(theFeature); - - // set length value - aData = theFeature->data(); - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_START)); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast(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 aData = feature()->data(); - boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); - FeaturePtr aFeature; - if (anAttr) { - aFeature = anAttr->feature(); - if (aFeature->getKind() != SKETCH_LINE_KIND) { - aFeature = FeaturePtr(); - } - } - boost::shared_ptr aPoint = boost::shared_ptr - (new GeomAPI_Pnt2d(theX, theY)); - boost::shared_ptr aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature); - boost::shared_ptr aResult = aFeatureLin->project(aPoint); - double aDistance = aPoint->distance(aResult); - - if (!aFeatureLin->isRight(aPoint)) - aDistance = -aDistance; - - //AttributeDoublePtr aFlyoutAttr = - // boost::dynamic_pointer_cast(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 PartSet_ConstraintLengthPrs::featurePoint - (const PartSet_SelectionMode& theMode) -{ - return boost::shared_ptr(); -} diff --git a/src/PartSet/PartSet_ConstraintLengthPrs.h b/src/PartSet/PartSet_ConstraintLengthPrs.h deleted file mode 100644 index e00b5494a..000000000 --- a/src/PartSet/PartSet_ConstraintLengthPrs.h +++ /dev/null @@ -1,64 +0,0 @@ -// 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 featurePoint(const PartSet_SelectionMode& theMode); -}; - -#endif diff --git a/src/PartSet/PartSet_ConstraintRadiusPrs.cpp b/src/PartSet/PartSet_ConstraintRadiusPrs.cpp deleted file mode 100644 index 92caca86b..000000000 --- a/src/PartSet/PartSet_ConstraintRadiusPrs.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 16 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -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 aData = feature()->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(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 aData = feature()->data(); - - boost::shared_ptr aPoint = boost::shared_ptr - (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(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 aData = theFeature->data(); - boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(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 PartSet_ConstraintRadiusPrs::featurePoint - (const PartSet_SelectionMode& theMode) -{ - return boost::shared_ptr(); -} diff --git a/src/PartSet/PartSet_ConstraintRadiusPrs.h b/src/PartSet/PartSet_ConstraintRadiusPrs.h deleted file mode 100644 index 48585dcb6..000000000 --- a/src/PartSet/PartSet_ConstraintRadiusPrs.h +++ /dev/null @@ -1,77 +0,0 @@ -// 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 - -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 featurePoint(const PartSet_SelectionMode& theMode); -}; - -#endif diff --git a/src/PartSet/PartSet_FeatureArcPrs.cpp b/src/PartSet/PartSet_FeatureArcPrs.cpp deleted file mode 100644 index 440f5624e..000000000 --- a/src/PartSet/PartSet_FeatureArcPrs.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 04 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -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 aData = theFeature->data(); - boost::shared_ptr aCenter = boost::dynamic_pointer_cast - (aData->attribute(ARC_ATTR_CENTER)); - boost::shared_ptr aStart = boost::dynamic_pointer_cast - (aData->attribute(ARC_ATTR_START)); - - boost::shared_ptr aCirc(new GeomAPI_Circ2d(aCenter->pnt(), aStart->pnt())); - boost::shared_ptr aGeomPoint2d(new GeomAPI_Pnt2d(aX, anY)); - boost::shared_ptr aPnt2d = aCirc->project(aGeomPoint2d); - if (aPnt2d) { - theX = aPnt2d->x(); - theY = aPnt2d->y(); - } - } -} - -boost::shared_ptr 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 aData = feature()->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(aPointArg)); - return aPoint; -} - -double PartSet_FeatureArcPrs::radius(FeaturePtr theFeature) -{ - if (!theFeature) - return 0; - - boost::shared_ptr aData = theFeature->data(); - - boost::shared_ptr aCenterAttr = - boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_CENTER)); - boost::shared_ptr aStartAttr = - boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_START)); - - return aCenterAttr->pnt()->distance(aStartAttr->pnt()); -} diff --git a/src/PartSet/PartSet_FeatureArcPrs.h b/src/PartSet/PartSet_FeatureArcPrs.h deleted file mode 100644 index fd0bff9c3..000000000 --- a/src/PartSet/PartSet_FeatureArcPrs.h +++ /dev/null @@ -1,75 +0,0 @@ -// 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 - -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 featurePoint(const PartSet_SelectionMode& theMode); -}; - -#endif diff --git a/src/PartSet/PartSet_FeatureCirclePrs.cpp b/src/PartSet/PartSet_FeatureCirclePrs.cpp deleted file mode 100644 index 426d9f1e5..000000000 --- a/src/PartSet/PartSet_FeatureCirclePrs.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 04 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -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 aData = feature()->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(CIRCLE_ATTR_CENTER)); - boost::shared_ptr 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 aData = theFeature->data(); - boost::shared_ptr aCenter = boost::dynamic_pointer_cast - (aData->attribute(CIRCLE_ATTR_CENTER)); - bool isValid; - double aRadius = PartSet_Tools::featureValue(theFeature, CIRCLE_ATTR_RADIUS, isValid); - - boost::shared_ptr aNormal(new GeomAPI_Dir2d(aX, anY)); - boost::shared_ptr aCirc(new GeomAPI_Circ2d(aCenter->pnt(), aNormal, aRadius)); - boost::shared_ptr aGeomPoint2d(new GeomAPI_Pnt2d(aX, anY)); - boost::shared_ptr aPnt2d = aCirc->project(aGeomPoint2d); - if (aPnt2d) { - theX = aPnt2d->x(); - theY = aPnt2d->y(); - } - } -} - -boost::shared_ptr 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 aData = feature()->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(aPointArg)); - return aPoint; -} diff --git a/src/PartSet/PartSet_FeatureCirclePrs.h b/src/PartSet/PartSet_FeatureCirclePrs.h deleted file mode 100644 index f9688b103..000000000 --- a/src/PartSet/PartSet_FeatureCirclePrs.h +++ /dev/null @@ -1,70 +0,0 @@ -// 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 - -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 featurePoint(const PartSet_SelectionMode& theMode); -}; - -#endif diff --git a/src/PartSet/PartSet_FeatureLinePrs.cpp b/src/PartSet/PartSet_FeatureLinePrs.cpp deleted file mode 100644 index fe4c3a5c5..000000000 --- a/src/PartSet/PartSet_FeatureLinePrs.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 04 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -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 aData = theFeature->data(); - boost::shared_ptr anInitPoint = boost::dynamic_pointer_cast - (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 aPoint = boost::dynamic_pointer_cast - (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 aPoint = boost::shared_ptr(new GeomAPI_Pnt2d(X1, Y1)); - boost::shared_ptr aFeatureLin = PartSet_FeatureLinePrs::createLin2d(theFeature); - - switch (theMode) { - case SM_FirstPoint: { - boost::shared_ptr aResult = aFeatureLin->project(aPoint); - theX = aResult->x(); - theY = aResult->y(); - } - break; - case SM_SecondPoint: { - getLinePoint(feature(), LINE_ATTR_START, X0, Y0); - boost::shared_ptr aCurrentLin = boost::shared_ptr - (new GeomAPI_Lin2d(X0, Y0, X1, Y1)); - boost::shared_ptr aResult = aFeatureLin->intersect(aCurrentLin); - boost::shared_ptr aPoint0 = boost::shared_ptr(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 PartSet_FeatureLinePrs::createLin2d(FeaturePtr theFeature) -{ - boost::shared_ptr 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 - (new GeomAPI_Lin2d(aStartX, aStartY, anEndX, anEndY)); - return aFeatureLin; -} - -boost::shared_ptr 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 aData = feature()->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (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 aData = theFeature->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(theAttribute)); - theX = aPoint->x(); - theY = aPoint->y(); -} diff --git a/src/PartSet/PartSet_FeatureLinePrs.h b/src/PartSet/PartSet_FeatureLinePrs.h deleted file mode 100644 index b9f2cfa42..000000000 --- a/src/PartSet/PartSet_FeatureLinePrs.h +++ /dev/null @@ -1,89 +0,0 @@ -// 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 - -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 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 featurePoint(const PartSet_SelectionMode& theMode); -}; - -#endif diff --git a/src/PartSet/PartSet_FeaturePointPrs.cpp b/src/PartSet/PartSet_FeaturePointPrs.cpp deleted file mode 100644 index 818206b47..000000000 --- a/src/PartSet/PartSet_FeaturePointPrs.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 04 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -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 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 aData = feature()->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(aPointArg)); - return aPoint; -} diff --git a/src/PartSet/PartSet_FeaturePointPrs.h b/src/PartSet/PartSet_FeaturePointPrs.h deleted file mode 100644 index 7fec84807..000000000 --- a/src/PartSet/PartSet_FeaturePointPrs.h +++ /dev/null @@ -1,57 +0,0 @@ -// 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 featurePoint(const PartSet_SelectionMode& theMode); -}; - -#endif diff --git a/src/PartSet/PartSet_FeaturePrs.cpp b/src/PartSet/PartSet_FeaturePrs.cpp deleted file mode 100644 index dfbad61ab..000000000 --- a/src/PartSet/PartSet_FeaturePrs.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// File: PartSet_FeaturePrs.h -// Created: 04 Jun 2014 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -#include - -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; -} diff --git a/src/PartSet/PartSet_FeaturePrs.h b/src/PartSet/PartSet_FeaturePrs.h deleted file mode 100644 index 9adf4a0a2..000000000 --- a/src/PartSet/PartSet_FeaturePrs.h +++ /dev/null @@ -1,76 +0,0 @@ -// 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 featurePoint(const PartSet_SelectionMode& theMode) = 0; - -private: - FeaturePtr mySketch; ///< the sketch of the feature - FeaturePtr myFeature; ///< the feature -}; - -#endif diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index e5a54cb38..794e472d3 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -6,10 +6,6 @@ #include #include -#include -#include -#include -#include #include #include @@ -139,12 +135,8 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); // move to selected line if (feature()->getKind() == SKETCH_LINE_KIND) { - //boost::shared_ptr aLinePrs = - // boost::dynamic_pointer_cast(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); } } } diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h index f4ecd643a..ddb5fe505 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.h +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -12,7 +12,6 @@ #include -class PartSet_FeaturePrs; class GeomDataAPI_Point2D; class QMouseEvent; class QKeyEvent; @@ -130,10 +129,8 @@ protected: bool setWidgetFeature(const FeaturePtr& theFeature); private: - //boost::shared_ptr 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 }; diff --git a/src/PartSet/PartSet_TestOCC.cpp b/src/PartSet/PartSet_TestOCC.cpp index 7e104ca34..75a16c52d 100644 --- a/src/PartSet/PartSet_TestOCC.cpp +++ b/src/PartSet/PartSet_TestOCC.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 8c6f38832..ca6b10adb 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -22,17 +22,11 @@ #include #include #include +#include +#include +#include #include -#include -#include -#include -#include - -#include -#include -#include - #include #include @@ -142,41 +136,6 @@ void PartSet_Tools::convertTo3D(const double theX, const double theY, thePoint = gp_Pnt(aPoint->x(), aPoint->y(), aPoint->z()); } -boost::shared_ptr PartSet_Tools::createFeaturePrs(const std::string& theKind, - FeaturePtr theSketch, - FeaturePtr theFeature) -{ - boost::shared_ptr aFeaturePrs; - - if (theKind == PartSet_FeaturePointPrs::getKind()) { - aFeaturePrs = boost::shared_ptr(new PartSet_FeaturePointPrs(theSketch)); - } - else if (theKind == PartSet_FeatureLinePrs::getKind()) { - aFeaturePrs = boost::shared_ptr(new PartSet_FeatureLinePrs(theSketch)); - } - else if (theKind == PartSet_FeatureCirclePrs::getKind()) { - aFeaturePrs = boost::shared_ptr(new PartSet_FeatureCirclePrs(theSketch)); - } - else if (theKind == PartSet_FeatureArcPrs::getKind()) { - aFeaturePrs = boost::shared_ptr(new PartSet_FeatureArcPrs(theSketch)); - } - else if (theKind == PartSet_ConstraintLengthPrs::getKind()) { - aFeaturePrs = boost::shared_ptr(new PartSet_ConstraintLengthPrs(theSketch)); - } - else if (theKind == PartSet_ConstraintRadiusPrs::getKind()) { - aFeaturePrs = boost::shared_ptr(new PartSet_ConstraintRadiusPrs(theSketch)); - } - else if (theKind == PartSet_ConstraintDistancePrs::getKind()) { - aFeaturePrs = boost::shared_ptr(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& theFeatures) @@ -381,7 +340,7 @@ boost::shared_ptr PartSet_Tools::point3D( 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; } diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 6aebb1032..fa1f31f9d 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -23,7 +23,6 @@ class GeomDataAPI_Point2D; class GeomAPI_Pln; class GeomAPI_Pnt2d; class GeomAPI_Pnt; -class PartSet_FeaturePrs; /*! \class PartSet_Tools @@ -53,14 +52,6 @@ public: 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 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