X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_ConstraintDistance.cpp;h=57f7b627d30fedcb6810a7fcbc69ebe11713f371;hb=2b4f4bf278c841500eb29bb5d204690427b0d56b;hp=6dfa0d0bd008e203e93b4803ccbcc48e6991d051;hpb=72fe2af9c04daae44747cdce2f03ec395a4e5511;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 6dfa0d0bd..57f7b627d 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -1,5 +1,5 @@ // File: SketchPlugin_ConstraintDistance.cpp -// Created: 08 May 2014 +// Created: 23 May 2014 // Author: Artem ZHIDKOV #include "SketchPlugin_ConstraintDistance.h" @@ -10,115 +10,22 @@ SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance() { - myAttrList.push_back(CONSTRAINT_ATTR_DISTANCE); } -void SketchPlugin_ConstraintDistance::execute() -{ -} - - -void SketchPlugin_ConstraintDistance::setAttributes( - const double theDistance, - const boost::shared_ptr theEntityA, - const boost::shared_ptr theEntityB) -{ - // Assign the value of the distance - data()->addAttribute(CONSTRAINT_ATTR_DISTANCE, ModelAPI_AttributeDouble::type()); - boost::dynamic_pointer_cast( - data()->attribute(CONSTRAINT_ATTR_DISTANCE))->setValue(theDistance); - - // Assign parameters of the constraint - std::string aPoints[2] = {CONSTRAINT_ATTR_POINT_A, CONSTRAINT_ATTR_POINT_B}; - std::string anEntities[2] = {CONSTRAINT_ATTR_ENTITY_A, CONSTRAINT_ATTR_ENTITY_B}; - int aCurPt = 0; - int aCurEnt = 0; - std::string aCurAttr; - // add entityA depending on its type - if (theEntityA->getKind() == SketchPlugin_Point().getKind()) - aCurAttr = aPoints[aCurPt++]; - else - aCurAttr = anEntities[aCurEnt++]; - myAttrList.push_back(aCurAttr); - data()->addAttribute(aCurAttr, ModelAPI_AttributeReference::type()); - boost::dynamic_pointer_cast( - data()->attribute(aCurAttr))->setValue(theEntityA); - // add entityB depending on its type - if (theEntityB->getKind() == SketchPlugin_Point().getKind()) - aCurAttr = aPoints[aCurPt++]; - else - aCurAttr = anEntities[aCurEnt++]; - myAttrList.push_back(aCurAttr); - data()->addAttribute(aCurAttr, ModelAPI_AttributeReference::type()); - boost::dynamic_pointer_cast( - data()->attribute(aCurAttr))->setValue(theEntityB); -} - -void SketchPlugin_ConstraintDistance::setAttributes( - const double theDistance, - const boost::shared_ptr thePoint, - const boost::shared_ptr theEntity) +void SketchPlugin_ConstraintDistance::initAttributes() { - // Assign the value of the distance - data()->addAttribute(CONSTRAINT_ATTR_DISTANCE, ModelAPI_AttributeDouble::type()); - boost::dynamic_pointer_cast( - data()->attribute(CONSTRAINT_ATTR_DISTANCE))->setValue(theDistance); - - // Assign reference to the first point - myAttrList.push_back(CONSTRAINT_ATTR_POINT_A); - data()->addAttribute(CONSTRAINT_ATTR_POINT_A, ModelAPI_AttributeRefAttr::type()); - //boost::dynamic_pointer_cast( - // data()->attribute(CONSTRAINT_ATTR_POINT_A))->setValue(thePoint); - - // Assign reference to the entity - std::string aCurAttr; - if (theEntity->getKind() == SketchPlugin_Point().getKind()) - aCurAttr = CONSTRAINT_ATTR_POINT_B; - else - aCurAttr = CONSTRAINT_ATTR_ENTITY_A; - myAttrList.push_back(aCurAttr); - data()->addAttribute(aCurAttr, ModelAPI_AttributeReference::type()); - boost::dynamic_pointer_cast( - data()->attribute(aCurAttr))->setValue(theEntity); + data()->addAttribute(CONSTRAINT_ATTR_VALUE, ModelAPI_AttributeDouble::type()); + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type()); + data()->addAttribute(CONSTRAINT_ATTR_ENTITY_B, ModelAPI_AttributeRefAttr::type()); } -void SketchPlugin_ConstraintDistance::setAttributes( - const double theDistance, - const boost::shared_ptr thePointA, - const boost::shared_ptr thePointB) -{ - // Assign the value of the distance - data()->addAttribute(CONSTRAINT_ATTR_DISTANCE, ModelAPI_AttributeDouble::type()); - boost::dynamic_pointer_cast( - data()->attribute(CONSTRAINT_ATTR_DISTANCE))->setValue(theDistance); - - // Assign reference to the first point - myAttrList.push_back(CONSTRAINT_ATTR_POINT_A); - data()->addAttribute(CONSTRAINT_ATTR_POINT_A, ModelAPI_AttributeRefAttr::type()); - //boost::dynamic_pointer_cast( - // data()->attribute(CONSTRAINT_ATTR_POINT_A))->setValue(thePointA); - - // Assign reference to the second point - myAttrList.push_back(CONSTRAINT_ATTR_POINT_B); - data()->addAttribute(CONSTRAINT_ATTR_POINT_B, ModelAPI_AttributeRefAttr::type()); - //boost::dynamic_pointer_cast( - // data()->attribute(CONSTRAINT_ATTR_POINT_B))->setValue(thePointB); -} - -void SketchPlugin_ConstraintDistance::setAttributes( - const double theRadius, - const boost::shared_ptr theCircle) +void SketchPlugin_ConstraintDistance::execute() { - /// \todo Need to be implemented } -void SketchPlugin_ConstraintDistance::setAttributes( - const double theDistance, - const boost::shared_ptr thePointA, - const boost::shared_ptr thePointB, - const boost::shared_ptr theEntity) +const boost::shared_ptr& SketchPlugin_ConstraintDistance::preview() { - /// \todo Need to be implemented. Possibly need to add points by their attributes + /// \todo Preview for distance constraint + return getPreview(); } -