Salome HOME
Fix for the issue #1605 : optimization of undo/redo and abort processing
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_DimensionStyleListener.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_DimensionStyleListener.h
4 // Created:     31 March 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef SketcherPrs_DimensionStyleListener_H
8 #define SketcherPrs_DimensionStyleListener_H
9
10 #include <Events_Listener.h>
11
12 #include <ModelAPI_AttributeDouble.h>
13
14 #include "SketcherPrs_Tools.h"
15
16 #include <Standard.hxx>
17
18 #include <string>
19
20 /**
21 * \ingroup GUI
22 * A class for representation of linear dimension constraint.
23 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
24 */
25 class SketcherPrs_DimensionStyleListener : public Events_Listener
26 {
27 public:
28   class DimensionValue {
29   public:
30     DimensionValue(double theDoubleValue, bool theHasParameters, const std::string& theTextValue);
31     /// Fills internal fields by the given attribute
32     /// \param theAttributeValue a model attribute
33     void init(const AttributeDoublePtr& theAttributeValue);
34
35   public:
36     double myDoubleValue; ///< the angle value to be shown as custom value of presentation
37     bool myHasParameters; ///< true if the atrribute value has used parameters
38     std::string myTextValue; ///< the angle value depending on angle type
39   };
40
41 public:
42   /// Constructor
43   Standard_EXPORT SketcherPrs_DimensionStyleListener();
44
45   /// Destructor
46   Standard_EXPORT ~SketcherPrs_DimensionStyleListener();
47
48   /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document
49   /// from the message with origin and planes
50   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
51
52   /// Visualizes the dimension text or dimension value depending on the has parameters state
53   /// \param theDimension a modified dimension
54   /// \param theDimensionValue container filled by the model double attribute
55   Standard_EXPORT void updateDimensions(AIS_Dimension* theDimension,
56                                         const DimensionValue& theDimensionValue);
57
58 private:
59   /// Visualizes the dimension text or dimension value depending on the has parameters state
60   /// \param theDimension a modified dimension
61   /// \param theHasParameters if true, the text is shown, else digit
62   /// \param theTextValue a dimension text value
63   /// \param theDoubleValue a dimension digit value
64   void updateDimensions(AIS_Dimension* theDimension,
65                         const bool theHasParameters,
66                         const std::string& theTextValue,
67                         const double theDoubleValue);
68 private:
69   /// Style how the parameter of dimension should be visualized
70   SketcherPrs_ParameterStyleMessage::ParameterStyle myStyle;
71 };
72
73 #endif