Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_DimensionStyleListener.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SketcherPrs_DimensionStyleListener_H
22 #define SketcherPrs_DimensionStyleListener_H
23
24 #include <Events_Listener.h>
25
26 #include <ModelAPI_AttributeDouble.h>
27
28 #include "SketcherPrs_Tools.h"
29
30 #include <Standard.hxx>
31
32 #include <string>
33
34 /**
35 * \class SketcherPrs_DimensionStyleListener
36 * \ingroup GUI
37 * A class for representation of linear dimension constraint.
38 * It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
39 */
40 class SketcherPrs_DimensionStyleListener : public Events_Listener
41 {
42 public:
43   class DimensionValue {
44   public:
45     DimensionValue(double theDoubleValue, bool theHasParameters, const std::string& theTextValue);
46     /// Fills internal fields by the given attribute
47     /// \param theAttributeValue a model attribute
48     void init(const AttributeDoublePtr& theAttributeValue);
49
50   public:
51     double myDoubleValue; ///< the angle value to be shown as custom value of presentation
52     bool myHasParameters; ///< true if the atrribute value has used parameters
53     std::string myTextValue; ///< the angle value depending on angle type
54   };
55
56 public:
57   /// Constructor
58   Standard_EXPORT SketcherPrs_DimensionStyleListener();
59
60   /// Destructor
61   Standard_EXPORT ~SketcherPrs_DimensionStyleListener();
62
63   /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document
64   /// from the message with origin and planes
65   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
66
67   /// Visualizes the dimension text or dimension value depending on the has parameters state
68   /// \param theDimension a modified dimension
69   /// \param theDimensionValue container filled by the model double attribute
70   Standard_EXPORT void updateDimensions(AIS_Dimension* theDimension,
71                                         const DimensionValue& theDimensionValue);
72
73 private:
74   /// Visualizes the dimension text or dimension value depending on the has parameters state
75   /// \param theDimension a modified dimension
76   /// \param theHasParameters if true, the text is shown, else digit
77   /// \param theTextValue a dimension text value
78   /// \param theDoubleValue a dimension digit value
79   void updateDimensions(AIS_Dimension* theDimension,
80                         const bool theHasParameters,
81                         const std::string& theTextValue,
82                         const double theDoubleValue);
83 private:
84   /// Style how the parameter of dimension should be visualized
85   SketcherPrs_ParameterStyleMessage::ParameterStyle myStyle;
86 };
87
88 #endif