Salome HOME
#1119 Confirmation box for deleting parts
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Tools.cpp
index c2ccd87488ab57d5f11c986059ef128cd30b3b0c..78b521957ba85a23359bbb5c29d62e09f7e75cd9 100644 (file)
 #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)
@@ -57,8 +64,10 @@ std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
   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>(
@@ -192,7 +201,7 @@ std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const FeaturePtr theLine,
 }
 
 
-static double MyArrowSize = 24.;
+static double MyArrowSize = 20;
 double getArrowSize()
 {
   return MyArrowSize;
@@ -203,6 +212,11 @@ void setArrowSize(double theSize)
   MyArrowSize = theSize;
 }
 
+int getDefaultArrowSize()
+{
+  return 20;
+}
+
 static double MyTextHeight = 16;
 double getTextHeight()
 {
@@ -260,4 +274,16 @@ std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(const ModelAPI_Feature* theConstrain
   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);
+  }
+}
+
 };