X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConstructionPlugin%2FConstructionPlugin_Axis.cpp;h=280da1e7fd28869a24c27f8e23cc3189db3f5af1;hb=1b9dd3633d644c358424227423b330e9551be38f;hp=258ed85e94e9404945072a0ce17ab5d145127d76;hpb=509293dabae95f38abae3b8845cc7819736395a0;p=modules%2Fshaper.git diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 258ed85e9..280da1e7f 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -16,6 +16,10 @@ #include #include +#ifdef _DEBUG +#include +#endif + using namespace std; ConstructionPlugin_Axis::ConstructionPlugin_Axis() @@ -25,16 +29,16 @@ 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::execute() +void ConstructionPlugin_Axis::createAxisByTwoPoints() { AttributeSelectionPtr aRef1 = data()->selection(ConstructionPlugin_Axis::POINT_FIRST()); AttributeSelectionPtr aRef2 = data()->selection(ConstructionPlugin_Axis::POINT_SECOND()); @@ -55,11 +59,38 @@ void ConstructionPlugin_Axis::execute() } } -void ConstructionPlugin_Axis::customisePresentation(AISObjectPtr thePrs) +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() +{ + AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD()); + std::string aMethodType = aMethodTypeAttr->value(); + if (aMethodType == "AxisByPointsCase") { + createAxisByTwoPoints(); + } else if (aMethodType == "AxisByCylindricalFaceCase") { + createAxisByCylindricalFace(); + } +} + +bool ConstructionPlugin_Axis::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, + std::shared_ptr theDefaultPrs) { - std::vector aRGB = Config_PropManager::color("Visualization", "construction_axis_color", - ConstructionPlugin_Axis::DEFAULT_COLOR()); - thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]); - thePrs->setLineStyle(3); - thePrs->redisplay(); + bool isCustomized = theDefaultPrs.get() != NULL && + theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs); + + isCustomized = thePrs->setLineStyle(3) || isCustomized; + isCustomized = thePrs->setWidth(2) || isCustomized; + + return isCustomized; }