From 975c481c4d5b3c2def28b6674b9c58e47f25ee95 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 24 Jun 2014 15:44:52 +0400 Subject: [PATCH] refs #80 - Sketch base GUI: create/draw point, circle and arc Parallel, perpendicular features. --- src/ModuleBase/ModuleBase_WidgetFeature.cpp | 2 +- .../PartSet_OperationFeatureCreate.cpp | 13 +++++++++-- .../SketchPlugin_ConstraintLength.cpp | 3 +++ src/SketchPlugin/plugin-Sketch.xml | 22 ++++++++++++++----- src/SketchSolver/SketchSolver_Constraint.cpp | 2 +- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 37ed734c0..6007743f5 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -31,7 +31,7 @@ ModuleBase_WidgetFeature::~ModuleBase_WidgetFeature() bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature) { - if (!theFeature && myFeatureKinds.contains(theFeature->getKind().c_str())) + if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str())) return false; //bool isBlocked = this->blockSignals(true); diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index 516a308d4..fb36405b0 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include #include @@ -55,8 +59,13 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate() bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId) { return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND || - theId == SKETCH_CONSTRAINT_DISTANCE_KIND || theId == SKETCH_CIRCLE_KIND /*|| - theId == SKETCH_ARC_KIND*/; + theId == SKETCH_CIRCLE_KIND /*|| + theId == SKETCH_ARC_KIND*/ || + theId == SKETCH_CONSTRAINT_DISTANCE_KIND || + theId == SKETCH_CONSTRAINT_LENGTH_KIND || + theId == SKETCH_CONSTRAINT_RADIUS_KIND || + theId == SKETCH_CONSTRAINT_PARALLEL_KIND || + theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND; } bool PartSet_OperationFeatureCreate::canBeCommitted() const diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index b5fe8fca3..7218a5341 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -4,6 +4,8 @@ #include "SketchPlugin_ConstraintLength.h" +#include + #include #include @@ -15,6 +17,7 @@ void SketchPlugin_ConstraintLength::initAttributes() { data()->addAttribute(CONSTRAINT_ATTR_VALUE, ModelAPI_AttributeDouble::type()); data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE, ModelAPI_AttributeDouble::type()); + data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type()); data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type()); } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index c741ab09c..b184363a3 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -1,7 +1,7 @@ - + @@ -26,17 +26,29 @@ + + + + + + + - - diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index 1b92bf947..67a177038 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -183,7 +183,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr( theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr]) ); - if (!anAttr || !anAttr->isFeature()) continue; + if (!anAttr || !anAttr->isFeature() || !anAttr->feature()) continue; const std::string& aKind = anAttr->feature()->getKind(); if (aKind.compare(SKETCH_LINE_KIND) == 0) { -- 2.39.2