X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConstructionPlugin%2FConstructionPlugin_Axis.cpp;h=e3d7eb34c4f58e7f2edf07b540e17386bf62c61a;hb=a731f82dccbfdb67cbf8e8d617222a4d3e32018a;hp=f0e45a5bf0bb9bc8cedc988e6cc0a6612ec6ca6b;hpb=3190305afd2b86b05365e51589822856d6937a1b;p=modules%2Fshaper.git diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index f0e45a5bf..e3d7eb34c 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -6,16 +6,21 @@ #include "ConstructionPlugin_Axis.h" +#include + #include #include +#include #include #include #include -using namespace std; +#ifdef _DEBUG +#include +#endif -static const double MINIMAL_LENGTH = 1.e-5; +using namespace std; ConstructionPlugin_Axis::ConstructionPlugin_Axis() { @@ -23,21 +28,27 @@ ConstructionPlugin_Axis::ConstructionPlugin_Axis() void ConstructionPlugin_Axis::initAttributes() { - data()->addAttribute(POINT_ATTR_FIRST, ModelAPI_AttributeSelection::type()); - data()->addAttribute(POINT_ATTR_SECOND, ModelAPI_AttributeSelection::type()); + data()->addAttribute(ConstructionPlugin_Axis::METHOD(), + ModelAPI_AttributeString::typeId()); + data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(), + ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(), + ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(ConstructionPlugin_Axis::CYLINDRICAL_FACE(), + ModelAPI_AttributeSelection::typeId()); } -void ConstructionPlugin_Axis::execute() +void ConstructionPlugin_Axis::createAxisByTwoPoints() { - AttributeSelectionPtr aRef1 = data()->selection(POINT_ATTR_FIRST); - AttributeSelectionPtr aRef2 = data()->selection(POINT_ATTR_SECOND); + AttributeSelectionPtr aRef1 = data()->selection(ConstructionPlugin_Axis::POINT_FIRST()); + AttributeSelectionPtr aRef2 = data()->selection(ConstructionPlugin_Axis::POINT_SECOND()); if ((aRef1.get() != NULL) && (aRef2.get() != NULL)) { GeomShapePtr aShape1 = aRef1->value(); GeomShapePtr aShape2 = aRef2->value(); if (aShape1->isVertex() && aShape2->isVertex() && (!aShape1->isEqual(aShape2))) { std::shared_ptr aStart = GeomAlgoAPI_PointBuilder::point(aShape1); std::shared_ptr anEnd = GeomAlgoAPI_PointBuilder::point(aShape2); - if (aStart->distance(anEnd) > MINIMAL_LENGTH) { + if (aStart->distance(anEnd) > ConstructionPlugin_Axis::MINIMAL_LENGTH()) { std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); ResultConstructionPtr aConstr = document()->createConstruction(data()); @@ -48,9 +59,26 @@ void ConstructionPlugin_Axis::execute() } } -void ConstructionPlugin_Axis::customisePresentation(AISObjectPtr thePrs) +void ConstructionPlugin_Axis::execute() +{ + 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 + } +} + +bool ConstructionPlugin_Axis::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, + std::shared_ptr theDefaultPrs) { - thePrs->setColor(0, 0, 0); - thePrs->setLineStyle(3); - thePrs->redisplay(); -} \ No newline at end of file + bool isCustomized = theDefaultPrs.get() != NULL && + theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs); + + isCustomized = thePrs->setLineStyle(3); + + return isCustomized; +}