]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketcherPrs/SketcherPrs_Tools.cpp
Salome HOME
Preparations for Split operation. It includes:
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Tools.cpp
index 91a8d3df81ce5545857290465ac1e7328219d94d..84d0878f66df2d68817c3f3f12620e322a5bd50b 100644 (file)
@@ -17,7 +17,9 @@
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Events.h>
 
-#include <Events_Error.h>
+#include <ModelGeomAlgo_Point2D.h>
+
+#include <Events_InfoMessage.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Lin2d.h>
 
 #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); // using equal instead of sigma
-
 namespace SketcherPrs_Tools {
 
 AttributePtr getAttribute(ModelAPI_Feature* theFeature, const std::string& theAttrName)
@@ -82,27 +79,8 @@ std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject)
 std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
                                         const std::string& theAttribute)
 {
-  std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
-
-  /// essential check as it is called in openGl thread
-  if (!theFeature || !theFeature->data().get() || !theFeature->data()->isValid())
-    return std::shared_ptr<GeomAPI_Pnt2d>();
-
-  FeaturePtr aFeature;
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(theFeature->data()->attribute(theAttribute));
-  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>(
-        aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
-
-  else if (anAttr->attr()) {
-    aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
-  }
+  std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = ModelGeomAlgo_Point2D::getPointOfRefAttr(
+               theFeature, theAttribute, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID());
   if (aPointAttr.get() != NULL)
     return aPointAttr->pnt();
   return std::shared_ptr<GeomAPI_Pnt2d>();
@@ -304,33 +282,6 @@ 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);
-  }
-}
-
-void setDisplayParameter(AIS_Dimension* theDimension, const std::string& theParameter,
-                         const bool& theToDisplay)
-{
-   if (theToDisplay) {
-    theDimension->DimensionAspect()->MakeUnitsDisplayed(true);
-    theDimension->SetDisplayUnits(TCollection_AsciiString(theParameter.c_str()));
-    theDimension->DimensionAspect()->SetValueStringFormat("");
-  }
-  else {
-    theDimension->DimensionAspect()->MakeUnitsDisplayed(false);
-    theDimension->SetDisplayUnits(TCollection_AsciiString()); // THE_UNDEFINED_UNITS in AIS_Dimension
-    theDimension->DimensionAspect()->SetValueStringFormat("%g");
-  }
-}
-
 void sendExpressionShownEvent(const bool& theState)
 {
   static Events_ID anId = SketcherPrs_ParameterStyleMessage::eventId();
@@ -376,7 +327,7 @@ void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect, double theDimValue
 
 void sendEmptyPresentationError(ModelAPI_Feature* theFeature, const std::string theError)
 {
-  Events_Error::throwException("An empty AIS presentation: SketcherPrs_LengthDimension");
+  Events_InfoMessage("SketcherPrs_Tools", "An empty AIS presentation: SketcherPrs_LengthDimension").send();
   static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
   std::shared_ptr<ModelAPI_Object> aConstraintPtr(theFeature);
   ModelAPI_EventCreator::get()->sendUpdated(aConstraintPtr, anEvent);