Salome HOME
Remove extra files
[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 * \class SketcherPrs_DimensionStyleListener
22 * \ingroup GUI
23 * A class for representation of linear dimension constraint.
24 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
25 */
26 class SketcherPrs_DimensionStyleListener : public Events_Listener
27 {
28 public:
29   class DimensionValue {
30   public:
31     DimensionValue(double theDoubleValue, bool theHasParameters, const std::string& theTextValue);
32     /// Fills internal fields by the given attribute
33     /// \param theAttributeValue a model attribute
34     void init(const AttributeDoublePtr& theAttributeValue);
35
36   public:
37     double myDoubleValue; ///< the angle value to be shown as custom value of presentation
38     bool myHasParameters; ///< true if the atrribute value has used parameters
39     std::string myTextValue; ///< the angle value depending on angle type
40   };
41
42 public:
43   /// Constructor
44   Standard_EXPORT SketcherPrs_DimensionStyleListener();
45
46   /// Destructor
47   Standard_EXPORT ~SketcherPrs_DimensionStyleListener();
48
49   /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document
50   /// from the message with origin and planes
51   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
52
53   /// Visualizes the dimension text or dimension value depending on the has parameters state
54   /// \param theDimension a modified dimension
55   /// \param theDimensionValue container filled by the model double attribute
56   Standard_EXPORT void updateDimensions(AIS_Dimension* theDimension,
57                                         const DimensionValue& theDimensionValue);
58
59 private:
60   /// Visualizes the dimension text or dimension value depending on the has parameters state
61   /// \param theDimension a modified dimension
62   /// \param theHasParameters if true, the text is shown, else digit
63   /// \param theTextValue a dimension text value
64   /// \param theDoubleValue a dimension digit value
65   void updateDimensions(AIS_Dimension* theDimension,
66                         const bool theHasParameters,
67                         const std::string& theTextValue,
68                         const double theDoubleValue);
69 private:
70   /// Style how the parameter of dimension should be visualized
71   SketcherPrs_ParameterStyleMessage::ParameterStyle myStyle;
72 };
73
74 #endif