X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConstructionPlugin%2FConstructionPlugin_Axis.cpp;h=8a6c2a5d0c23fb8ea0dad5ad7b35404771e1c90c;hb=3e7f97125b2198724911564b24b0a30cbd393e3d;hp=5017f496a97af4842da4c557aa6a65478f362dfa;hpb=8579a62492b5e8227d9e256cc9754a31442c05ed;p=modules%2Fshaper.git diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 5017f496a..8a6c2a5d0 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() @@ -44,7 +44,11 @@ void ConstructionPlugin_Axis::createAxisByTwoPoints() AttributeSelectionPtr aRef2 = data()->selection(ConstructionPlugin_Axis::POINT_SECOND()); if ((aRef1.get() != NULL) && (aRef2.get() != NULL)) { GeomShapePtr aShape1 = aRef1->value(); + if (!aShape1.get()) + aShape1 = aRef1->context()->shape(); GeomShapePtr aShape2 = aRef2->value(); + if (!aShape2.get()) + aShape2 = aRef2->context()->shape(); if (aShape1->isVertex() && aShape2->isVertex() && (!aShape1->isEqual(aShape2))) { std::shared_ptr aStart = GeomAlgoAPI_PointBuilder::point(aShape1); std::shared_ptr anEnd = GeomAlgoAPI_PointBuilder::point(aShape2); @@ -52,6 +56,7 @@ void ConstructionPlugin_Axis::createAxisByTwoPoints() std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); ResultConstructionPtr aConstr = document()->createConstruction(data()); + aConstr->setInfinite(true); aConstr->setShape(anEdge); setResult(aConstr); } @@ -59,6 +64,20 @@ 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->setInfinite(true); + aConstr->setShape(anEdge); + setResult(aConstr); + } +} + void ConstructionPlugin_Axis::execute() { AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD()); @@ -66,19 +85,18 @@ void ConstructionPlugin_Axis::execute() 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); - isCustomized = thePrs->setLineStyle(3); + isCustomized = thePrs->setLineStyle(3) || isCustomized; + isCustomized = thePrs->setWidth(2) || isCustomized; return isCustomized; }