Edit feature: creation a specific presentation in the tools in order to use it in the edit operation.
{
}
+std::string PartSet_FeatureArcPrs::getKind()
+{
+ return SKETCH_ARC_KIND;
+}
+
PartSet_SelectionMode PartSet_FeatureArcPrs::setPoint(double theX, double theY,
const PartSet_SelectionMode& theMode)
{
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);
myPointSelectionMode(SM_FirstPoint)
{
std::string aKind = theId.toStdString();
-
- if (aKind == SKETCH_POINT_KIND) {
- myFeaturePrs = new PartSet_FeaturePointPrs(theFeature);
- }
- if (aKind == SKETCH_LINE_KIND) {
- myFeaturePrs = new PartSet_FeatureLinePrs(theFeature);
- }
- else if (aKind == SKETCH_CIRCLE_KIND) {
- myFeaturePrs = new PartSet_FeatureCirclePrs(theFeature);
- }
- else if (aKind == SKETCH_ARC_KIND) {
- myFeaturePrs = new PartSet_FeatureArcPrs(theFeature);
- }
+ myFeaturePrs = PartSet_Tools::createFeaturePrs(aKind, theFeature);
}
PartSet_OperationCreateFeature::~PartSet_OperationCreateFeature()
{
- delete myFeaturePrs;
}
bool PartSet_OperationCreateFeature::canProcessKind(const std::string& theId)
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
// move to selected line
if (feature()->getKind() == SKETCH_LINE_KIND) {
- PartSet_FeatureLinePrs* aLinePrs = dynamic_cast<PartSet_FeatureLinePrs*>(myFeaturePrs);
+ 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);
case SM_SecondPoint:
case SM_ThirdPoint: {
if (feature()->getKind() == SKETCH_ARC_KIND) {
- PartSet_FeatureArcPrs* anArcPrs = dynamic_cast<PartSet_FeatureArcPrs*>(myFeaturePrs);
+ boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
+ boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
if (anArcPrs) {
anArcPrs->projectPointOnArc(aPoint, theView, aX, anY);
}
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
if (myPointSelectionMode == SM_ThirdPoint) {
if (feature()->getKind() == SKETCH_ARC_KIND) {
- PartSet_FeatureArcPrs* anArcPrs = dynamic_cast<PartSet_FeatureArcPrs*>(myFeaturePrs);
+ boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
+ boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
if (anArcPrs) {
anArcPrs->projectPointOnArc(aPoint, theView, aX, anY);
}
const bool isToEmitSignal = true);
private:
- PartSet_FeaturePrs* myFeaturePrs; ///< the feature presentation
+ boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
FeaturePtr myInitFeature; ///< the initial feature
PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
};
#include <PartSet_FeatureLinePrs.h>
#include <PartSet_FeaturePointPrs.h>
#include <PartSet_FeatureCirclePrs.h>
+#include <PartSet_FeatureArcPrs.h>
#include <XGUI_ViewerPrs.h>
}
}
+boost::shared_ptr<PartSet_FeaturePrs> PartSet_Tools::createFeaturePrs(const std::string& theKind,
+ FeaturePtr theSketch,
+ FeaturePtr theFeature)
+{
+ PartSet_FeaturePrs* aFeaturePrs;
+
+ if (theKind == PartSet_FeaturePointPrs::getKind()) {
+ aFeaturePrs = new PartSet_FeaturePointPrs(theSketch);
+ }
+ else if (theKind == PartSet_FeatureLinePrs::getKind()) {
+ aFeaturePrs = new PartSet_FeatureLinePrs(theSketch);
+ }
+ else if (theKind == PartSet_FeatureCirclePrs::getKind()) {
+ aFeaturePrs = new PartSet_FeatureCirclePrs(theSketch);
+ }
+ else if (theKind == PartSet_FeatureArcPrs::getKind()) {
+ aFeaturePrs = new PartSet_FeatureArcPrs(theSketch);
+ }
+ if (theFeature)
+ aFeaturePrs->init(theFeature, FeaturePtr());
+
+ return boost::shared_ptr<PartSet_FeaturePrs>(aFeaturePrs);
+}
+
FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView,
FeaturePtr theSketch,
const std::list<XGUI_ViewerPrs>& theFeatures)
class Handle_V3d_View;
class XGUI_ViewerPrs;
class GeomDataAPI_Point2D;
+class PartSet_FeaturePrs;
/*!
\class PartSet_Tools
static void projectPointOnLine(double theX1, double theY1, double theX2, double theY2,
double thePointX, double thePointY, double& theX, double& theY);
+ /// 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