]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #805 In the sketch presentation, show both the parameter and its value: providi...
authornds <nds@opencascade.com>
Thu, 31 Mar 2016 12:09:38 +0000 (15:09 +0300)
committernds <nds@opencascade.com>
Thu, 31 Mar 2016 12:09:38 +0000 (15:09 +0300)
13 files changed:
src/Events/Events_Loop.cpp
src/Events/Events_Loop.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.h
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/SketcherPrs_Tools.h

index d2d96de532ceda5a4c43bb051fadad2a3ebb7f21..b969741898d7840069eb08572de5ea7b4fd6e794 100644 (file)
@@ -113,6 +113,53 @@ void Events_Loop::registerListener(Events_Listener* theListener, const Events_ID
   aListeners.push_back(theListener);
 }
 
+void Events_Loop::removeListener(Events_Listener* theListener)
+{
+  // remove the listener in myListeners map
+  std::map<char*, std::map<void*, std::list<Events_Listener*> > >::const_reverse_iterator
+                                                          anIt = myListeners.rbegin();
+  while(anIt != myListeners.rend()) {
+    std::map<void*, std::list<Events_Listener*> > aLMap = anIt->second;
+    std::map<void*, std::list<Events_Listener*> >::const_reverse_iterator aLIt = aLMap.rbegin();
+    while (aLIt != aLMap.rend()) {
+      std::list<Events_Listener*> aListeners = aLIt->second;
+      std::list<Events_Listener*>::const_reverse_iterator aLsIt = aListeners.rbegin();
+      for (; aLsIt != aListeners.rend(); aLsIt++) {
+        if (*aLsIt == theListener) {
+          aListeners.remove(theListener);
+          aLMap[aLIt->first] = aListeners;
+          myListeners[anIt->first] = aLMap;
+          break;
+        }
+      }
+      if (aListeners.empty()) {
+        aLMap.erase(aLIt->first);
+        myListeners[anIt->first] = aLMap;
+        if (aLMap.empty())
+          break; // avoid incrementation of the iterator if the the container is empty
+      }
+      aLIt++;
+    }
+    if (anIt->second.empty()) {
+      myListeners.erase(anIt->first);
+      if (myListeners.empty())
+        break; // avoid incrementation of the iterator if the the container is empty
+    }
+    anIt++;
+  }
+
+  // remove the listener in myImmediateListeners map
+  std::map<char*, Events_Listener*>::const_reverse_iterator anImIt = myImmediateListeners.rbegin();
+  while(anImIt != myImmediateListeners.rend()) {
+    if (anImIt->second == theListener) {
+      myImmediateListeners.erase(anImIt->first);
+      if (myImmediateListeners.empty())
+        break; // avoid incrementation of the iterator if the the container is empty
+    }
+    anImIt++;
+  }
+}
+
 void Events_Loop::flush(const Events_ID& theID)
 {
   if (!myFlushActive)
index 66ed3070d58e785f994854603de2b46bdb0a0a72..c1c5f2977a0c08edb95c5ca28da2411d2172a23d 100644 (file)
@@ -63,6 +63,10 @@ class Events_Loop
   EVENTS_EXPORT void registerListener(Events_Listener* theListener, const Events_ID theID,
                                       void* theSender = 0, bool theImmediate = false);
 
+  //! Remove the listener from internal maps if it was registered there
+  //! \param theListener a listener
+  EVENTS_EXPORT void removeListener(Events_Listener* theListener);
+
   //! Initializes sending of a group-message by the given ID
   EVENTS_EXPORT void flush(const Events_ID& theID);
 
index d38ee8de64d886cc9483a4c62d2fe1bcb0588ebf..c230c979318de5644f33e05ed4312c4f07914848 100755 (executable)
@@ -145,6 +145,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 
   myHasConstraintShown[PartSet_Tools::Geometrical] = true;
   myHasConstraintShown[PartSet_Tools::Dimensional] = true;
+  myHasConstraintShown[PartSet_Tools::Dimensional] = false;
 
   Config_PropManager::registerProp("Visualization", "operation_parameter_color",
                           "Reference shape wireframe color in operation", Config_Prop::Color,
@@ -401,7 +402,7 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
                                                                     aLast = myHasConstraintShown.end();
   for (; anIt != aLast; anIt++) {
     myHasConstraintShown[anIt.key()];
-    mySketchMgr->onShowConstraintsToggle(anIt.key(), anIt.value());
+    mySketchMgr->updateBySketchParameters(anIt.key(), anIt.value());
   }
 }
 
@@ -790,23 +791,35 @@ void PartSet_Module::onFeatureTriggered()
   ModuleBase_IModule::onFeatureTriggered();
 }
 
+void PartSet_Module::editFeature(FeaturePtr theFeature)
+{
+  storeConstraintsState(theFeature->getKind());
+  ModuleBase_IModule::editFeature(theFeature);
+}
+
 void PartSet_Module::launchOperation(const QString& theCmdId)
+{
+  storeConstraintsState(theCmdId.toStdString());
+  ModuleBase_IModule::launchOperation(theCmdId);
+}
+
+void PartSet_Module::storeConstraintsState(const std::string& theFeatureKind)
 {
   if (myWorkshop->currentOperation() && 
       myWorkshop->currentOperation()->id().toStdString() == SketchPlugin_Sketch::ID()) {
-      const QMap<PartSet_Tools::ConstraintVisibleState, bool>& aShownStates =
-                                                    mySketchMgr->showConstraintStates();
-      myHasConstraintShown = aShownStates;
+    const QMap<PartSet_Tools::ConstraintVisibleState, bool>& aShownStates =
+                                                  mySketchMgr->showConstraintStates();
+    myHasConstraintShown = aShownStates;
   }
-  if (PartSet_SketcherMgr::constraintsIdList().contains(theCmdId)) {
+  if (PartSet_SketcherMgr::constraintsIdList().contains(theFeatureKind.c_str())) {
     // Show constraints if a constraint was anOperation
-    mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Geometrical, true);
-    mySketchMgr->onShowConstraintsToggle(PartSet_Tools::Dimensional, true);
+    mySketchMgr->updateBySketchParameters(PartSet_Tools::Geometrical, true);
+    mySketchMgr->updateBySketchParameters(PartSet_Tools::Dimensional, true);
+    mySketchMgr->updateBySketchParameters(PartSet_Tools::Expressions,
+                                          myHasConstraintShown[PartSet_Tools::Expressions]);
   }
-  ModuleBase_IModule::launchOperation(theCmdId);
 }
 
-
 void PartSet_Module::onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) 
 {
   Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
@@ -911,7 +924,7 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the
   ObjectPtr anObject = aDisplayer->getObject(thePrs);
   if (anObject.get()) {
     bool isConflicting = myOverconstraintListener->isConflictingObject(anObject);
-    // customize sketcy symbol presentation
+    // customize sketch symbol presentation
     if (thePrs.get()) {
       Handle(AIS_InteractiveObject) anAISIO = thePrs->impl<Handle(AIS_InteractiveObject)>();
       if (!anAISIO.IsNull()) {
@@ -939,6 +952,9 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the
         aCustomized = true;
       }
     }
+
+    // customize dimentional constrains
+    sketchMgr()->customizePresentation(anObject);
   }
 
   return aCustomized;
index cb7d8613142fc0a937de8a2a61837af54c0f4828..8a54eff21ecb16afc9bc8e47f2528c7ab842c0ec 100755 (executable)
@@ -91,6 +91,10 @@ public:
   virtual bool createWidgets(ModuleBase_Operation* theOperation,
                              QList<ModuleBase_ModelWidget*>& theWidgets) const;
 
+  /// Launching of a edit operation on the feature 
+  /// \param theFeature feature for editing
+  virtual void editFeature(FeaturePtr theFeature);
+
   /// Creates an operation and send it to loop
   /// \param theCmdId the operation name
   virtual void launchOperation(const QString& theCmdId);
@@ -322,6 +326,11 @@ protected slots:
   void onChoiceChanged(ModuleBase_ModelWidget* theWidget, int theIndex);
 
 protected:
+  /// Sets the constraints states in internal map. If the feature kind is a dimensional constraint
+  /// other dimensions are shown.
+  /// \param theFeatureKindId a feature kind
+  void storeConstraintsState(const std::string& theFeatureKindId);
+
   /// Register validators for this module
   virtual void registerValidators();
 
index 236124f63403168fd4daa1802849363696ff6d4b..1817bc3aa302bdc556539c00c4033fbd2a5c6964 100755 (executable)
@@ -189,6 +189,7 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
 
   myIsConstraintsShown[PartSet_Tools::Geometrical] = true;
   myIsConstraintsShown[PartSet_Tools::Dimensional] = true;
+  myIsConstraintsShown[PartSet_Tools::Expressions] = false;
 }
 
 PartSet_SketcherMgr::~PartSet_SketcherMgr()
@@ -898,6 +899,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
   myIsMouseOverWindow = false;
   myIsConstraintsShown[PartSet_Tools::Geometrical] = true;
   myIsConstraintsShown[PartSet_Tools::Dimensional] = true;
+  myIsConstraintsShown[PartSet_Tools::Expressions] = false;
 
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
 
@@ -1536,6 +1538,15 @@ void PartSet_SketcherMgr::widgetStateChanged(int thePreviousState)
   }
 }
 
+void PartSet_SketcherMgr::customizePresentation(const ObjectPtr& theObject)
+{
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                                           (getCurrentOperation());
+  if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
+                      PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)))
+    SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
+}
+
 ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
 {
   return myModule->workshop()->currentOperation();
@@ -1643,24 +1654,45 @@ void PartSet_SketcherMgr::restoreSelection()
 void PartSet_SketcherMgr::onShowConstraintsToggle(int theType, bool theState)
 {
   PartSet_Tools::ConstraintVisibleState aType = (PartSet_Tools::ConstraintVisibleState)theType;
-  if (myIsConstraintsShown.contains(aType) && myIsConstraintsShown[aType] == theState)
-    return;
-  if (myCurrentSketch.get() == NULL)
-    return;
 
-  myIsConstraintsShown[aType] = theState;
+  updateBySketchParameters(aType, theState);
+}
 
-  ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+void PartSet_SketcherMgr::updateBySketchParameters(
+                                   const PartSet_Tools::ConstraintVisibleState& theType,
+                                   bool theState)
+{
+  if (myCurrentSketch.get() == NULL)
+    return;
 
-  for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
-    FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
-    bool aProcessed = false;
-    bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, aType, aProcessed);
-    if (aProcessed)
-      aSubFeature->setDisplayed(aConstraintDisplayed);
+  bool aPrevState = myIsConstraintsShown[theType];
+  myIsConstraintsShown[theType] = theState;
+
+  switch (theType) {
+    case PartSet_Tools::Geometrical:
+    case PartSet_Tools::Dimensional: {
+      if (aPrevState != theState) {
+        ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+        XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+        for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+          FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
+          bool aProcessed = false;
+          bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, theType, aProcessed);
+          if (aProcessed)
+            aSubFeature->setDisplayed(aConstraintDisplayed);
+        }
+        Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+      }
+    }
+    break;
+    case PartSet_Tools::Expressions: {
+      /// call all sketch features redisplay, the expression state will be corrected in customize
+      /// of distance presentation
+      Events_ID anEventId = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      PartSet_Tools::sendSubFeaturesEvent(myCurrentSketch, anEventId);
+    }
+    break;
   }
-  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
 }
 
 XGUI_Workshop* PartSet_SketcherMgr::workshop() const
index a7118e899e09b4035258cbe6fa80edb2e264179b..aa99353aa9e911718f42fb5c5d5eb16a98969393 100644 (file)
@@ -247,14 +247,24 @@ public:
   /// \param thePreviousState the previous widget value state
   void widgetStateChanged(int thePreviousState);
 
+  /// If the current operation is a dimention one, the style of dimension visualization is send for
+  /// the current object
+  /// \param theObject an object to be customized
+  void customizePresentation(const ObjectPtr& theObject);
+
+  /// Update sketch presentations according to the the state
+  /// \param theType a type of sketch visualization style
+  /// \param theState a boolean state
+  void updateBySketchParameters(const PartSet_Tools::ConstraintVisibleState& theType,
+                                bool theState);
+
 public slots:
   /// Process sketch plane selected event
   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
+private slots:
   /// Toggle show constraints
   void onShowConstraintsToggle(int theType, bool theState);
-
-private slots:
   /// Process the enter mouse to the view port. If the current operation is a create of
   /// a nested sketch feature, it updates internal flags to display the feature on mouse move
   void onEnterViewPort();
index 1b2ed450a257721d1c81a00949224764e7c092fe..27921bf5e60b2a5dcac162d4259caacdf234a315 100755 (executable)
@@ -890,3 +890,18 @@ AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj,
   }
   return anAttribute;
 }
+
+void PartSet_Tools::sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite,
+                                         const Events_ID theEventId)
+{
+  if (!theComposite.get())
+    return;
+
+  static Events_Loop* aLoop = Events_Loop::loop();
+  for (int i = 0; i < theComposite->numberOfSubs(); i++) {
+    FeaturePtr aSubFeature = theComposite->subFeature(i);
+    static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+    aECreator->sendUpdated(aSubFeature, theEventId);
+  }
+  Events_Loop::loop()->flush(theEventId);
+}
index 316d484a4e16730680d97453cd37a8b7a7f294f1..e4b034f3cc5b52ad0f8741837317d4cd78e29209 100755 (executable)
@@ -19,6 +19,8 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Attribute.h>
 
+#include <Events_Message.h>
+
 #include <TopoDS_Shape.hxx>
 
 #include <memory>
@@ -47,6 +49,7 @@ public:
   {
     Geometrical = 0, // all constrains excepting dimensional
     Dimensional,     // lenght, distance, radius and angle constraints
+    Expressions,     // parameter text should be shown in dimensional constraint
     Any              // both, geometrical and dimensional, types of constraints
   };
 
@@ -249,6 +252,10 @@ public:
   * \param theStartCoin the coincedence feature
   */
   static std::shared_ptr<GeomAPI_Pnt2d> getCoincedencePoint(FeaturePtr theStartCoin);
+
+  /// Sends redisplay event for all sub-features of the composite. Flush it.
+  static void sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite,
+                                   const Events_ID theId);
 };
 
 #endif
index d424aa7e7b5868c604a08475eee6e34b9829cc1b..76a50444c1f38320639616171ec2d4c513835498 100644 (file)
@@ -104,6 +104,7 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
   QMap<PartSet_Tools::ConstraintVisibleState, QString> aStates;
   aStates[PartSet_Tools::Geometrical] = tr("Show geometrical constraints");
   aStates[PartSet_Tools::Dimensional] = tr("Show dimensional constraints");
+  aStates[PartSet_Tools::Expressions] = tr("Show existing expressions");
 
   QMap<PartSet_Tools::ConstraintVisibleState, QString>::const_iterator anIt = aStates.begin(),
                                                         aLast = aStates.end();
index b6df9e517274bfc4ccec6a73535835ae3da0baad..0ec0382e49a01bbdb995b6f679bd6aeef76dd035 100644 (file)
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Circle.h>
 
+#include <SketcherPrs_Tools.h>
+
 #include <Events_Error.h>
+#include <Events_Loop.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAPI_Pnt.h>
@@ -51,6 +54,27 @@ SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theCo
 
   SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight());
   SetDimensionAspect(myAspect);
+
+  Events_Loop* aLoop = Events_Loop::loop();
+  const Events_ID kDocCreatedEvent =
+                SketcherPrs_ParameterStyleMessage::eventId();
+  aLoop->registerListener(this, kDocCreatedEvent, NULL, false);
+}
+
+SketcherPrs_LengthDimension::~SketcherPrs_LengthDimension()
+{
+  Events_Loop* aLoop = Events_Loop::loop();
+  aLoop->removeListener(this);
+}
+
+void SketcherPrs_LengthDimension::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+  const Events_ID kParameterStyleEvent = SketcherPrs_ParameterStyleMessage::eventId();
+  if (theMessage->eventID() == kParameterStyleEvent) {
+    std::shared_ptr<SketcherPrs_ParameterStyleMessage> aMessage = std::dynamic_pointer_cast<
+                                            SketcherPrs_ParameterStyleMessage>(theMessage);
+    myStyle = aMessage->style();
+  }
 }
 
 bool SketcherPrs_LengthDimension::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
@@ -102,8 +126,16 @@ void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManage
   myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER);
 
   AttributeDoublePtr aValue = myConstraint->data()->real(SketchPlugin_Constraint::VALUE());
-  SketcherPrs_Tools::setDisplaySpecialSymbol(this, aValue->usedParameters().size() > 0);
-
+  bool aHasParameters = aValue->usedParameters().size() > 0;
+  if (aHasParameters) {
+    bool isParameterValueStyle = myStyle == SketcherPrs_ParameterStyleMessage::ParameterValue;
+    SketcherPrs_Tools::setDisplaySpecialSymbol(this, isParameterValueStyle);
+    SketcherPrs_Tools::setDisplayParameter(this, aValue->text(), !isParameterValueStyle);
+  }
+  else {
+    SketcherPrs_Tools::setDisplaySpecialSymbol(this, false);
+    SketcherPrs_Tools::setDisplayParameter(this, aValue->text(), false);
+  }
   AIS_LengthDimension::Compute(thePresentationManager, thePresentation, theMode);
 }
 
index cfd5d4881f8947188ded63360de8a132c5fe2025..c0716bc5825c8802fb4a4c339e827b8b1158c165 100644 (file)
 #include <AIS_LengthDimension.hxx>
 #include <Standard_DefineHandle.hxx>
 
+#include <SketcherPrs_Tools.h>
+
+#include <Events_Listener.h>
+
 
 DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
 
@@ -21,7 +25,7 @@ DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
 * A class for representation of linear dimension constraint.
 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
 */
-class SketcherPrs_LengthDimension : public AIS_LengthDimension
+class SketcherPrs_LengthDimension : public AIS_LengthDimension, public Events_Listener
 {
 public:
   /// Constructor
@@ -30,8 +34,15 @@ public:
   Standard_EXPORT SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint, 
                         const std::shared_ptr<GeomAPI_Ax3>& thePlane);
 
+  /// Destructor
+  Standard_EXPORT ~SketcherPrs_LengthDimension();
+
   DEFINE_STANDARD_RTTI(SketcherPrs_LengthDimension)
 
+  /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document
+  /// from the message with origin and planes
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
   /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
   /// \param theConstraint a constraint feature
   /// \param thePlane a coordinate plane of current sketch
@@ -59,6 +70,9 @@ private:
   std::shared_ptr<GeomAPI_Ax3> myPlane;
 
   Handle(Prs3d_DimensionAspect) myAspect;
+
+  /// Style how the parameter of dimension should be visualized
+  SketcherPrs_ParameterStyleMessage::ParameterStyle myStyle;
 };
 
 #endif
\ No newline at end of file
index d481dcbe7fc946ae64f438118e7a66662c9bb73d..922916847c39eb887d43cd2cd958d6cf2a586fba 100644 (file)
@@ -293,4 +293,30 @@ void setDisplaySpecialSymbol(AIS_Dimension* theDimension, const bool& theToDispl
   }
 }
 
+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();
+  std::shared_ptr<SketcherPrs_ParameterStyleMessage> aMessage = std::shared_ptr
+    <SketcherPrs_ParameterStyleMessage>(new SketcherPrs_ParameterStyleMessage(anId, 0));
+  aMessage->setStyle(theState ? SketcherPrs_ParameterStyleMessage::ParameterText
+                              : SketcherPrs_ParameterStyleMessage::ParameterValue);
+  Events_Loop::loop()->send(aMessage);
+  Events_Loop::loop()->flush(anId);
+}
+
 };
index f6f8c3ac7c1c82bd801d822a8a1531226d6c8761..b41d8b4982d46787554225e5fb53ac307b5f5e5f 100644 (file)
 #include <ModelAPI_Feature.h>
 #include <string>
 
+#include <Events_Loop.h>
+#include <Events_Message.h>
+
 class GeomDataAPI_Point2D;
 class AIS_Dimension;
 
 //#define MyTextHeight 20
 
+/// Message that document (Part, PartSet) was created
+class SketcherPrs_ParameterStyleMessage : public Events_Message
+{
+public:
+  enum ParameterStyle {
+    ParameterValue, /// using symbol with the parameter value
+    ParameterText /// using parameter text
+  };
+
+public:
+  /// Creates an empty message
+  SKETCHERPRS_EXPORT SketcherPrs_ParameterStyleMessage(const Events_ID theID,
+                                                    const void* theSender = 0)
+  : Events_Message(theID, theSender) {}
+  /// The virtual destructor
+  SKETCHERPRS_EXPORT virtual ~SketcherPrs_ParameterStyleMessage() {}
+  /// Static. Returns EventID of the message.
+  SKETCHERPRS_EXPORT static Events_ID eventId()
+  {
+    static const char * MY_EVENT_PARAMETER_STYLE_ID("ParameterStyle");
+    return Events_Loop::eventByName(MY_EVENT_PARAMETER_STYLE_ID);
+  }
+  /// Returns a document stored in the message
+  SKETCHERPRS_EXPORT ParameterStyle style() const { return myStyle; }
+  /// Sets a document to the message
+  SKETCHERPRS_EXPORT void setStyle(ParameterStyle theStyle) { myStyle = theStyle; }
+private:
+  ParameterStyle myStyle; /// style of the parameter visualization
+};
+
 namespace SketcherPrs_Tools {
 
   /// Enumeration with modes for activation of selection custom presentations
@@ -48,6 +81,9 @@ namespace SketcherPrs_Tools {
     ANGLE_BACKWARD ///< Angle from the second line to the first line
   };
 
+  /// Event ID about expression visual state has been changed, the symbol with a digit
+  /// or parameter text is shown
+
   /// Returns attribute object referenced by feature
   /// \param theFeature a feature
   /// \param theAttrName an attribute name
@@ -124,6 +160,20 @@ namespace SketcherPrs_Tools {
   /// \param theToDisplay a boolean value
   SKETCHERPRS_EXPORT void setDisplaySpecialSymbol(AIS_Dimension* theDimension,
                                                   const bool& theToDisplay);
+
+  /// Display the parameter value instead of dimention digit
+  /// \param theDimension a dimension constraint
+  /// \param theParameter a parameter value
+  /// \param theToDisplay a boolean value
+  SKETCHERPRS_EXPORT void setDisplayParameter(AIS_Dimension* theDimension,
+                                              const std::string& theParameter,
+                                              const bool& theToDisplay);
+
+  /// Sends event about expression visualization type is changed for dimension presentations
+  /// Sends event to redisplay all sub-features of composite feature
+  /// \param theState a new state
+  SKETCHERPRS_EXPORT void sendExpressionShownEvent(const bool& theState);
+
 };
 
 #endif