X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConstructionPlugin%2FConstructionPlugin_Axis.cpp;h=ae24aaf3c7916561f9de78cd36f8dfdbc6dcbf69;hb=ea551d77decefb9c01f9aeb2caba39bb1613bcad;hp=8e90fae27eb89033d6f4e06ed2c314117a08c096;hpb=aa32d461a6e60409d2473ebffa0e255c860589ab;p=modules%2Fshaper.git diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 8e90fae27..ae24aaf3c 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -29,13 +29,13 @@ ConstructionPlugin_Axis::ConstructionPlugin_Axis() void ConstructionPlugin_Axis::initAttributes() { data()->addAttribute(ConstructionPlugin_Axis::METHOD(), - ModelAPI_AttributeString::type()); + ModelAPI_AttributeString::typeId()); data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(), - ModelAPI_AttributeSelection::type()); + ModelAPI_AttributeSelection::typeId()); data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(), - ModelAPI_AttributeSelection::type()); + ModelAPI_AttributeSelection::typeId()); data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(), - ModelAPI_AttributeSelection::type()); + ModelAPI_AttributeSelection::typeId()); } void ConstructionPlugin_Axis::createAxisByTwoPoints() @@ -59,23 +59,32 @@ void ConstructionPlugin_Axis::createAxisByTwoPoints() } } +void ConstructionPlugin_Axis::createAxisByCylindricalFace() +{ + std::shared_ptr aSelection = data()->selection(CYLINDRICAL_FACE())->value(); + // update arguments due to the selection value + if (aSelection && !aSelection->isNull() && aSelection->isFace()) { + std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::cylinderAxis(aSelection); + + ResultConstructionPtr aConstr = document()->createConstruction(data()); + aConstr->setShape(anEdge); + setResult(aConstr); + } +} + void ConstructionPlugin_Axis::execute() { - AttributePtr anAttr = data()->attribute(ConstructionPlugin_Axis::METHOD()); - AttributeStringPtr aMethodTypeAttr = - std::dynamic_pointer_cast(anAttr); + AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD()); std::string aMethodType = aMethodTypeAttr->value(); if (aMethodType == "AxisByPointsCase") { createAxisByTwoPoints(); } else if (aMethodType == "AxisByCylindricalFaceCase") { - #ifdef _DEBUG - std::cout << "ConstructionPlugin_Axis::execute: " << "AxisByCylindricalFaceCase is not supported yet." << std::endl; - #endif + createAxisByCylindricalFace(); } } bool ConstructionPlugin_Axis::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, - std::shared_ptr theDefaultPrs) + std::shared_ptr theDefaultPrs) { bool isCustomized = theDefaultPrs.get() != NULL && theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs);