# Hurricane Design Viewer

Graphics.h
1 // -*- C++ -*-
2 //
3 // This file is part of the Coriolis Software.
4 // Copyright (c) UPMC 2008-2018, All Rights Reserved
5 //
6 // +-----------------------------------------------------------------+
7 // | H U R R I C A N E |
8 // | V L S I B a c k e n d D a t a - B a s e |
9 // | |
10 // | Author : Jean-Paul CHAPUT |
11 // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./hurricane/viewer/Graphics.h" |
14 // +-----------------------------------------------------------------+
15
16
17 #ifndef HURRICANE_GRAPHICS_H
18 #define HURRICANE_GRAPHICS_H
19
20
21 #include <string>
22 #include <vector>
23 #include <QFont>
24 #include "hurricane/Observer.h"
25 #include "hurricane/Breakpoint.h"
26 #include "hurricane/TextTranslator.h"
27 #include "hurricane/viewer/DisplayStyle.h"
28 #include "hurricane/viewer/ColorScale.h"
29 #include "hurricane/viewer/BreakpointWidget.h"
30
31 class QColor;
32 class QPen;
33 class QBrush;
34
35
36 namespace Hurricane {
37
38 class Name;
39
40
41 // -------------------------------------------------------------------
42 // Class : "Graphics".
43
44 class Graphics {
45 public:
46 enum NotifyFlags { ChangedDisplayStyles = (1<<0) };
47 public:
48 // Accessors.
49 static Graphics* getGraphics ();
50 static void addObserver ( BaseObserver* );
51 static void removeObserver ( BaseObserver* );
52 static void notify ( unsigned int flags );
53 static bool isEnabled ();
54 static bool isHighDpi ();
55 static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false, int scale=0 );
56 static const QFont getNormalFont ( bool bold=false, bool italic=false, bool underline=false );
57 static const Name& getGroup ( const Name& key );
58 static QColor getColor ( const Name& key, const DisplayStyle::HSVr& darkening=DisplayStyle::HSVr() );
59 static QPen getPen ( const Name& key, const DisplayStyle::HSVr& darkening=DisplayStyle::HSVr() );
60 static QBrush getBrush ( const Name& key, const DisplayStyle::HSVr& darkening=DisplayStyle::HSVr() );
61 static const string& getPattern ( const Name& key );
62 static float getThreshold ( const Name& key );
63 static const DisplayStyle::HSVr& getDarkening ();
64 static const ColorScale& getColorScale ( ColorScale::ScaleType );
65 static QColor darken ( const QColor& );
66 static const TextTranslator& getHtmlTranslator();
67 static string toHtml ( const string& );
68 static int toHighDpi ( int );
69 static bool breakpointStopCb ( const string& message );
70 static void clear ();
71 // Modifiers.
72 static void addStyle ( DisplayStyle* displayStyle );
73 static void setStyle ( const Name& key );
74 static void setStyle ( size_t id );
75 static DisplayStyle* getStyle ( const Name& key );
76 static DisplayStyle* getStyle ();
77 static const vector<DisplayStyle*>& getStyles ();
78 static void enable ();
79 static void disable ();
80 void toJson ( JsonWriter* ) const;
81 // Internals - Attributes.
82 protected:
83 static Graphics* _singleton;
84 Observable _observers;
85 TextTranslator _htmlTranslator;
86 vector<DisplayStyle*> _styles;
87 DisplayStyle* _active;
88 FireColorScale _fireColorScale;
89 RainbowColorScale _rainbowColorScale;
90 TemperatureColorScale _temperatureColorScale;
91 bool _qtEnabled;
92 bool _highDpi;
93
94 // Internals - Constructors & Destructors.
95 Graphics ();
96 Graphics ( const Graphics& );
97 Graphics& operator= ( const Graphics& );
98 ~Graphics ();
99 // Internals - Methods.
100 size_t _findStyle ( const Name& key ) const;
101 void _addStyle ( DisplayStyle* displayStyle );
102 void _setStyle ( const Name& key );
103 void _setStyle ( size_t id );
104 DisplayStyle* _getStyle ( const Name& key );
105 DisplayStyle* _getStyle () const;
106 inline const vector<DisplayStyle*>& _getStyles () const;
107 inline const Name& _getGroup ( const Name& key ) const;
108 inline QColor _getColor ( const Name& key, const DisplayStyle::HSVr& darkening ) const;
109 inline QPen _getPen ( const Name& key, const DisplayStyle::HSVr& darkening ) const;
110 inline QBrush _getBrush ( const Name& key, const DisplayStyle::HSVr& darkening ) const;
111 inline const string& _getPattern ( const Name& key ) const;
112 inline float _getThreshold ( const Name& key ) const;
113 inline const DisplayStyle::HSVr& _getDarkening () const;
114 inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const;
115 void _enable ();
116 void _disable ();
117 inline const TextTranslator& _getHtmlTranslator () const;
118 void _clear ();
119 };
120
121
122 inline const Name& Graphics::_getGroup ( const Name& name ) const
123 { return _active->getGroup(name); }
124
125 inline QColor Graphics::_getColor ( const Name& name, const DisplayStyle::HSVr& darkening ) const
126 { return _active->getColor(name,darkening); }
127
128 inline QPen Graphics::_getPen ( const Name& name, const DisplayStyle::HSVr& darkening ) const
129 { return _active->getPen(name,darkening); }
130
131 inline QBrush Graphics::_getBrush ( const Name& name, const DisplayStyle::HSVr& darkening ) const
132 { return _active->getBrush(name,darkening); }
133
134 inline const string& Graphics::_getPattern ( const Name& name ) const
135 { return _active->getPattern(name); }
136
137 inline float Graphics::_getThreshold ( const Name& name ) const
138 { return _active->getThreshold(name); }
139
140 inline const DisplayStyle::HSVr& Graphics::_getDarkening () const
141 { return _active->getDarkening(); }
142
143 inline const ColorScale& Graphics::_getColorScale ( ColorScale::ScaleType id ) const
144 {
145 switch ( id ) {
146 case ColorScale::Grey:
147 case ColorScale::Fire:
148 return _fireColorScale;
149 break;
150 case ColorScale::Rainbow:
151 return _rainbowColorScale;
152 break;
153 case ColorScale::Temperature:
154 return _temperatureColorScale;
155 break;
156 }
157 return _fireColorScale;
158 }
159
160 inline DisplayStyle* Graphics::_getStyle () const
161 { return _active; }
162
163 inline const vector<DisplayStyle*>& Graphics::_getStyles () const
164 { return _styles; }
165
166 inline const TextTranslator& Graphics::_getHtmlTranslator () const
167 { return _htmlTranslator; }
168
169
170 // -------------------------------------------------------------------
171 // Class : "JsonGraphics".
172
173 class JsonGraphics : public JsonObject {
174 public:
175 static void initialize ();
176 JsonGraphics ( unsigned long flags );
177 ~JsonGraphics ();
178 virtual string getTypeName () const;
179 virtual JsonGraphics* clone ( unsigned long ) const;
180 virtual void toData ( JsonStack& );
181 private:
182 std::string _active;
183 };
184
185
186 } // End of Hurricane namespace.
187
188
189 #endif // __HURRICANE_GRAPHICS__
Hurricane::Graphics::setStyle
static void setStyle(const Name &key)
Hurricane::Graphics::getBrush
static QBrush getBrush(const Name &key, const DisplayStyle::HSVr &darkening=DisplayStyle::HSVr())
Hurricane::Graphics::toHtml
static string toHtml(const string &)
Hurricane::DisplayStyle::getDarkening
const HSVr & getDarkening() const
Definition: DisplayStyle.h:299
Hurricane::Graphics::getDarkening
static const DisplayStyle::HSVr & getDarkening()
Hurricane::Graphics::isEnabled
static bool isEnabled()
Hurricane::DisplayStyle::getPattern
const std::string & getPattern(const Name &key) const
Hurricane::DisplayStyle::getColor
QColor getColor(const Name &key, const HSVr &) const
Hurricane::Graphics::getStyle
static DisplayStyle * getStyle()
Hurricane::Graphics::getGroup
static const Name & getGroup(const Name &key)
Hurricane::Name
Hurricane::Graphics::getThreshold
static float getThreshold(const Name &key)
Hurricane::Graphics::getHtmlTranslator
static const TextTranslator & getHtmlTranslator()
Hurricane::Graphics::getColorScale
static const ColorScale & getColorScale(ColorScale::ScaleType)
Hurricane::Graphics::getPen
static QPen getPen(const Name &key, const DisplayStyle::HSVr &darkening=DisplayStyle::HSVr())
Hurricane::DisplayStyle::getBrush
QBrush getBrush(const Name &key, const HSVr &) const
Hurricane::Graphics::getFixedFont
static const QFont getFixedFont(int weight=QFont::Normal, bool italic=false, bool underline=false, int scale=0)
Hurricane::Graphics
Manage basic graphical configuration (API)
Definition: Graphics.h:44
Hurricane::DisplayStyle::getPen
QPen getPen(const Name &key, const HSVr &) const
Hurricane::DisplayStyle::getGroup
const Name & getGroup(const Name &key) const
Hurricane::Graphics::getColor
static QColor getColor(const Name &key, const DisplayStyle::HSVr &darkening=DisplayStyle::HSVr())
Hurricane::Graphics::addStyle
static void addStyle(DisplayStyle *displayStyle)
Hurricane::Graphics::getGraphics
static Graphics * getGraphics()
Hurricane
Hurricane::Graphics::darken
static QColor darken(const QColor &)
Hurricane::DisplayStyle
A complete set of DrawinStyles to uses with the CellWidget.
Definition: DisplayStyle.h:91
Hurricane::Graphics::getPattern
static const string & getPattern(const Name &key)
Hurricane::DisplayStyle::getThreshold
float getThreshold(const Name &key) const
Hurricane::Graphics::enable
static void enable()

Generated by doxygen 1.8.14 on Tue Jul 21 2020 | Return to top of page

Hurricane Design Viewer | Copyright © 2008-2016 UPMC All rights reserved