#include <BRep_Tool.hxx>
#include <Precision.hxx>
+#include <AIS_Dimension.hxx>
+
+// it is not possible to use 0x2211 as summ symbol because it is not supported by
+// debian Linux platform
+static const Standard_ExtCharacter MyEmptySymbol(' ');
+static const Standard_ExtCharacter MySigmaSymbol(0x03A3);
+
namespace SketcherPrs_Tools {
ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName)
FeaturePtr aFeature;
std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
ModelAPI_AttributeRefAttr>(theFeature->data()->attribute(theAttribute));
- if (anAttr)
- aFeature = ModelAPI_Feature::feature(anAttr->object());
+ if(!anAttr.get()) {
+ return std::shared_ptr<GeomAPI_Pnt2d>();
+ }
+ aFeature = ModelAPI_Feature::feature(anAttr->object());
if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
}
//*************************************************************************************
+/// Find an attribute of the given object which corresponds to a vetrex
+/// defined by a shape
+/// \param theObject an object
+/// \param theShape a vertex
+/// \param thePlane a projection plane (sketcher plane)
std::shared_ptr<GeomDataAPI_Point2D> findGeomPoint(ObjectPtr theObject,
const TopoDS_Shape& theShape,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
ObjectPtr anObject = anAttr->object();
aFeature = ModelAPI_Feature::feature(anObject);
if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) {
+ // Attribute refers to a point
aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
}
else {
+ // if the attribute refers on another object
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aRes.get()) {
GeomShapePtr aShape = aRes->shape();
}
}
else if (anAttr->attr()) {
+ // If attribute is a point
aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
}
}
}
-static double MyArrowSize = 24.;
+static double MyArrowSize = 20;
double getArrowSize()
{
return MyArrowSize;
MyArrowSize = theSize;
}
+int getDefaultArrowSize()
+{
+ return 20;
+}
+
static double MyTextHeight = 16;
double getTextHeight()
{
FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
std::shared_ptr<GeomAPI_Pnt2d> aCenter;
- if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ if (aFeature->getKind() == SketchPlugin_Arc::ID()) { // arc
aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aFeature->attribute(SketchPlugin_Arc::CENTER_ID()))->pnt();
- } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+ } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aFeature->attribute(SketchPlugin_Circle::CENTER_ID()))->pnt();
- } else
+ } else
return std::shared_ptr<GeomAPI_Pnt>();
std::shared_ptr<GeomAPI_Pnt2d> anOrigin(new GeomAPI_Pnt2d(0.0, 0.0));
return thePlane->to3D(aFlyoutPnt->x(), aFlyoutPnt->y());
}
+void setDisplaySpecialSymbol(AIS_Dimension* theDimension, const bool& theToDisplay)
+{
+ if (theToDisplay) {
+ theDimension->SetSpecialSymbol(MySigmaSymbol);
+ theDimension->SetDisplaySpecialSymbol(AIS_DSS_Before);
+ }
+ else {
+ theDimension->SetSpecialSymbol(MyEmptySymbol);
+ theDimension->SetDisplaySpecialSymbol(AIS_DSS_No);
+ }
+}
+
};