From: dbv Date: Fri, 15 Jul 2016 14:05:33 +0000 (+0300) Subject: Issue #1650: Added option to create axis by line. X-Git-Tag: V_2.5.0~188 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7c81df16a543490eae8942e285504220b31ba1be;p=modules%2Fshaper.git Issue #1650: Added option to create axis by line. --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 90d9dcf31..876b79897 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -68,6 +68,9 @@ void ConstructionPlugin_Axis::initAttributes() ModelAPI_AttributeDouble::typeId()); data()->addAttribute(ConstructionPlugin_Axis::DZ(), ModelAPI_AttributeDouble::typeId()); + + /// Attributes for axis by line. + data()->addAttribute(LINE(), ModelAPI_AttributeSelection::typeId()); } void ConstructionPlugin_Axis::createAxisByTwoPoints() @@ -162,6 +165,22 @@ void ConstructionPlugin_Axis::createAxisByDimensions() setResult(aConstr); } +void ConstructionPlugin_Axis::createAxisByLine() +{ + // Get edge. + AttributeSelectionPtr anEdgeSelection = selection(LINE()); + GeomShapePtr aLineShape = anEdgeSelection->value(); + if(!aLineShape.get()) { + aLineShape = anEdgeSelection->context()->shape(); + } + std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); + + ResultConstructionPtr aConstr = document()->createConstruction(data()); + aConstr->setInfinite(true); + aConstr->setShape(anEdge); + setResult(aConstr); +} + void ConstructionPlugin_Axis::execute() { AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD()); @@ -174,6 +193,9 @@ void ConstructionPlugin_Axis::execute() createAxisByPointAndDirection(); } else if (aMethodType == "AxisByDimensionsCase") { createAxisByDimensions(); + } else if(aMethodType == CREATION_METHOD_BY_LINE()) { + createAxisByLine(); + } } diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.h b/src/ConstructionPlugin/ConstructionPlugin_Axis.h index 63f8e01a7..c0116e81c 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.h @@ -41,6 +41,14 @@ class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomP static const std::string METHOD_ATTR("CreationMethod"); return METHOD_ATTR; } + + /// Attribute name for creation method. + inline static const std::string& CREATION_METHOD_BY_LINE() + { + static const std::string METHOD_ATTR("by_line"); + return METHOD_ATTR; + } + /// attribute name for first point inline static const std::string& POINT_FIRST() { @@ -99,6 +107,13 @@ class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomP return ATTR_Z_DIRECTION; } + /// Attribute name for line. + inline static const std::string& LINE() + { + static const std::string ATTR_ID("line"); + return ATTR_ID; + } + /// Returns a minimal length for axis inline static const double MINIMAL_LENGTH() { return 1.e-5; } @@ -127,6 +142,7 @@ class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomP void createAxisByCylindricalFace(); /// Creates a new axis by point and direction void createAxisByPointAndDirection(); + void createAxisByLine(); }; diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml index 654420e6b..243d0c794 100644 --- a/src/ConstructionPlugin/axis_widget.xml +++ b/src/ConstructionPlugin/axis_widget.xml @@ -37,6 +37,15 @@ + + + + +