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()
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<GeomAPI_Edge> 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());
createAxisByPointAndDirection();
} else if (aMethodType == "AxisByDimensionsCase") {
createAxisByDimensions();
+ } else if(aMethodType == CREATION_METHOD_BY_LINE()) {
+ createAxisByLine();
+
}
}
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()
{
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; }
void createAxisByCylindricalFace();
/// Creates a new axis by point and direction
void createAxisByPointAndDirection();
+ void createAxisByLine();
};
<doublevalue id="DY" label="DY " tooltip="Y dimension" default="0"/>
<doublevalue id="DZ" label="DZ " tooltip="Z dimension" default="10"/>
</box>
+ <box id="by_line" title="By line" icon="icons/Construction/axis_by_line_32x32.png">
+ <shape_selector id="line"
+ label="Line"
+ tooltip="Select line."
+ icon="icons/Construction/edge.png"
+ shape_types="edge">
+ <validator id="GeomValidators_ShapeType" parameters="line"/>
+ </shape_selector>
+ </box>
</toolbox>
</source>