using namespace std;
-static const double defaultAxisSize = 50;
+static const double defaultAxisSize = 100;
ConstructionPlugin_Axis::ConstructionPlugin_Axis()
{
aPnt->translate(aPln->direction(), defaultAxisSize);
}
- std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aProjPnt, aPnt);
+ std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aPnt, aProjPnt);
ResultConstructionPtr aConstr = document()->createConstruction(data());
aConstr->setInfinite(true);
// By line and point.
data()->addAttribute(LINE(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(POINT(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(PERPENDICULAR(), ModelAPI_AttributeBoolean::typeId());
// By other plane.
data()->addAttribute(CREATION_METHOD_BY_OTHER_PLANE_OPTION(), ModelAPI_AttributeString::typeId());
data()->addAttribute(PLANE(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(DISTANCE(), ModelAPI_AttributeDouble::typeId());
- data()->addAttribute(DISTANCE_REVERSE(), ModelAPI_AttributeBoolean::typeId());
+ data()->addAttribute(REVERSE(), ModelAPI_AttributeBoolean::typeId());
data()->addAttribute(COINCIDENT_POINT(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(AXIS(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(ANGLE(), ModelAPI_AttributeDouble::typeId());
aLineShape = anEdgeSelection->context()->shape();
}
std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
- std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
- GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2);
-
// Get point.
AttributeSelectionPtr aPointSelection = selection(POINT());
}
std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aPointShape));
- GeomShapePtr aRes = faceByThreeVertices(aV1, aV2, aVertex);
+ // Get perpendicular flag.
+ bool anIsPerpendicular= boolean(PERPENDICULAR())->value();
+
+ GeomShapePtr aRes;
+ if(anIsPerpendicular) {
+ std::shared_ptr<GeomAPI_Lin> aLin = anEdge->line();
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
+ std::shared_ptr<GeomAPI_Pln> aNewPln(new GeomAPI_Pln(aPnt, aLin->direction()));
+ int aSize = aLin->distance(aPnt);
+ aSize *= 2.0;
+ aRes = GeomAlgoAPI_FaceBuilder::squareFace(aNewPln, aSize);
+ } else {
+ std::shared_ptr<GeomAPI_Vertex> aV1, aV2;
+ GeomAlgoAPI_ShapeTools::findBounds(anEdge, aV1, aV2);
+ aRes = faceByThreeVertices(aV1, aV2, aVertex);
+ }
return aRes;
}
return ATTR_ID;
}
+ /// Attribute name for perpendicular flag.
+ inline static const std::string& PERPENDICULAR()
+ {
+ static const std::string ATTR_ID("perpendicular");
+ return ATTR_ID;
+ }
+
/// Attribute name for selected plane.
inline static const std::string& PLANE()
{
return ATTR_ID;
}
- /// Attribute name for reverse in distance from other case
- inline static const std::string& DISTANCE_REVERSE()
+ /// Attribute name for reverse flag.
+ inline static const std::string& REVERSE()
{
- static const std::string ATTR_DISTANCE_REVERSE_ID("distance_reverse");
- return ATTR_DISTANCE_REVERSE_ID;
+ static const std::string ATTR_ID("reverse");
+ return ATTR_ID;
}
/// Attribute name for coincident point.
shape_types="vertex">
<validator id="ConstructionPlugin_ValidatorPlaneLinePoint" parameters="line"/>
</shape_selector>
+ <boolvalue id="perpendicular"
+ label="Perpendicular "
+ tooltip="Makes the plane perpendicular to the selected line."
+ default="false"/>
</box>
<box id="by_other_plane"
title="By other plane"
label="Distance"
tooltip="Distance from selected face to plane."
icon="icons/Construction/distance_value.png"
- default="10"/>
- <boolvalue id="distance_reverse"
+ min="0"
+ default="10">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
+ <boolvalue id="reverse"
label="Reverse"
- tooltip="Distance from plane."
+ tooltip="Checked means on the other side of the selected plane."
default="false"/>
</box>
<box id="by_coincident_to_point"