From: vsv Date: Wed, 17 Dec 2014 08:50:38 +0000 (+0300) Subject: Select sub-shapes for axis creation X-Git-Tag: before_slalome_7.5.1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5119a6154d1737e3a46eda810bedb9436d80ee52;p=modules%2Fshaper.git Select sub-shapes for axis creation --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 69b31a9f0..7315289b3 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -6,7 +6,7 @@ #include "ConstructionPlugin_Axis.h" -#include +#include #include #include @@ -23,30 +23,26 @@ ConstructionPlugin_Axis::ConstructionPlugin_Axis() void ConstructionPlugin_Axis::initAttributes() { - data()->addAttribute(POINT_ATTR_FIRST, ModelAPI_AttributeReference::type()); - data()->addAttribute(POINT_ATTR_SECOND, ModelAPI_AttributeReference::type()); + data()->addAttribute(POINT_ATTR_FIRST, ModelAPI_AttributeSelection::type()); + data()->addAttribute(POINT_ATTR_SECOND, ModelAPI_AttributeSelection::type()); } void ConstructionPlugin_Axis::execute() { - AttributeReferencePtr aRef1 = data()->reference(POINT_ATTR_FIRST); - AttributeReferencePtr aRef2 = data()->reference(POINT_ATTR_SECOND); + AttributeSelectionPtr aRef1 = data()->selection(POINT_ATTR_FIRST); + AttributeSelectionPtr aRef2 = data()->selection(POINT_ATTR_SECOND); if ((aRef1.get() != NULL) && (aRef2.get() != NULL)) { - ResultConstructionPtr aPntObj1 = std::dynamic_pointer_cast(aRef1->value()); - ResultConstructionPtr aPntObj2 = std::dynamic_pointer_cast(aRef2->value()); - if ((aPntObj1.get() != NULL) && (aPntObj2.get() != NULL)) { - GeomShapePtr aShape1 = aPntObj1->shape(); - GeomShapePtr aShape2 = aPntObj2->shape(); - if (aShape1->isVertex() && aShape2->isVertex()) { - std::shared_ptr aStart = GeomAlgoAPI_PointBuilder::point(aShape1); - std::shared_ptr anEnd = GeomAlgoAPI_PointBuilder::point(aShape2); - if (aStart->distance(anEnd) > MINIMAL_LENGTH) { - std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); - - ResultConstructionPtr aConstr = document()->createConstruction(data()); - aConstr->setShape(anEdge); - setResult(aConstr); - } + 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) { + std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); + + ResultConstructionPtr aConstr = document()->createConstruction(data()); + aConstr->setShape(anEdge); + setResult(aConstr); } } } diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml index e6472b6db..2b0659c7d 100644 --- a/src/ConstructionPlugin/axis_widget.xml +++ b/src/ConstructionPlugin/axis_widget.xml @@ -6,12 +6,13 @@ icon=":icons/point.png" tooltip="Select a first point for the axis" shape_types="vertex" + use_subshapes="true" /> - + shape_types="vertex" + use_subshapes="true">