]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 5.1.3 Sketcher: angle dimension (issue #3061)
authorazv <azv@opencascade.com>
Thu, 12 Dec 2019 10:37:52 +0000 (13:37 +0300)
committerazv <azv@opencascade.com>
Thu, 12 Dec 2019 10:37:52 +0000 (13:37 +0300)
Make Angle constraint reentant.

src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchPlugin/SketchPlugin_ConstraintAngle.h

index 890df386f942eb1a02c80f498688d806391b3328..10d27ee1c24069b400354b80b2b4404678d6f05b 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_EventReentrantMessage.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
@@ -130,6 +131,11 @@ void SketchPlugin_ConstraintAngle::execute()
       GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   if(!aFlyOutAttr->isInitialized())
     compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
+
+  static Events_ID anId = ModelAPI_EventReentrantMessage::eventId();
+  std::shared_ptr<ModelAPI_EventReentrantMessage> aMessage(
+      new ModelAPI_EventReentrantMessage(anId, this));
+  Events_Loop::loop()->send(aMessage);
 }
 
 AISObjectPtr SketchPlugin_ConstraintAngle::getAISObject(AISObjectPtr thePrevious)
@@ -144,6 +150,24 @@ AISObjectPtr SketchPlugin_ConstraintAngle::getAISObject(AISObjectPtr thePrevious
   return anAIS;
 }
 
+// LCOV_EXCL_START
+std::string SketchPlugin_ConstraintAngle::processEvent(
+    const std::shared_ptr<Events_Message>& theMessage)
+{
+  std::string aFilledAttributeName;
+
+  std::shared_ptr<ModelAPI_EventReentrantMessage> aReentrantMessage =
+      std::dynamic_pointer_cast<ModelAPI_EventReentrantMessage>(theMessage);
+  if (aReentrantMessage.get()) {
+    aFilledAttributeName = ENTITY_A();
+    refattr(ENTITY_A())->setObject(aReentrantMessage->selectedObject());
+    std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(SELECTED_FIRST_POINT_ID()))
+        ->setValue(aReentrantMessage->clickedPoint());
+  }
+  return aFilledAttributeName;
+}
+// LCOV_EXCL_STOP
+
 void SketchPlugin_ConstraintAngle::attributeChanged(const std::string& theID)
 {
   if (myFlyoutUpdate)
index bc13f731ded8d33f459f3c8f62b938f21b77e8f7..9305e1c20b79c791b863dba631dc975439fc0e48 100644 (file)
 #define SketchPlugin_ConstraintAngle_H_
 
 #include "SketchPlugin.h"
-#include <SketchPlugin_Sketch.h>
+#include "SketchPlugin_Sketch.h"
 #include "SketchPlugin_ConstraintBase.h"
 
+#include <ModelAPI_IReentrant.h>
+
 /** \class SketchPlugin_ConstraintAngle
  *  \ingroup Plugins
  *  \brief Feature for creation of a new constraint fix angle between two lines
@@ -31,7 +33,8 @@
  *  This constraint has two attributes:
  *  SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
  */
-class SketchPlugin_ConstraintAngle : public SketchPlugin_ConstraintBase
+class SketchPlugin_ConstraintAngle : public SketchPlugin_ConstraintBase,
+                                     public ModelAPI_IReentrant
 {
 public:
   /// Angle constraint kind
@@ -135,6 +138,10 @@ public:
   /// Returns the AIS preview
   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
+  /// Apply information of the message to current object.
+  /// It fills selected point and the first object.
+  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintAngle();