17 #ifndef HURRICANE_DISPLAYSTYLE_H
18 #define HURRICANE_DISPLAYSTYLE_H
25 #include "hurricane/Commons.h"
26 #include "hurricane/Name.h"
27 #include "hurricane/viewer/ScreenUtilities.h"
32 class RawDrawingStyle;
33 typedef std::shared_ptr<RawDrawingStyle> DrawingStyle;
34 typedef std::vector <DrawingStyle> DrawingStyles;
43 DrawingGroup (
const Name& name );
45 DrawingGroup* getClone ();
49 inline const Name& getName ()
const;
50 inline const DrawingStyles& getDrawingStyles ()
const;
51 size_t findIndex (
const Name& key )
const;
52 DrawingStyle find (
const Name& key )
const;
53 DrawingStyle addDrawingStyle (
const Name& key
54 ,
const std::string& pattern
62 void addDrawingStyle ( DrawingStyle );
63 void toJson ( JsonWriter* )
const;
66 DrawingStyles _drawingStyles;
68 DrawingGroup (
const DrawingGroup& );
69 DrawingGroup& operator= (
const DrawingGroup& );
77 class JsonDrawingGroup :
public JsonObject {
79 static void initialize ();
80 JsonDrawingGroup (
unsigned long flags );
82 virtual string getTypeName ()
const;
83 virtual JsonDrawingGroup* clone (
unsigned long )
const;
84 virtual void toData ( JsonStack& );
95 inline HSVr (
float hue=1.0,
float saturation=1.0,
float value=1.0 );
96 inline bool isId ()
const;
97 inline float getHue ()
const;
98 inline float getSaturation ()
const;
99 inline float getValue ()
const;
100 inline void setHue (
float );
101 inline void setSaturation (
float );
102 inline void setValue (
float );
103 inline void toJson ( JsonWriter* )
const;
104 inline std::string _getString ()
const;
113 static const Name Viewer;
114 static const Name Fallback;
115 static const Name Background;
116 static const Name Foreground;
118 static const Name Phantom;
119 static const Name Boundaries;
120 static const Name Marker;
121 static const Name SelectionDraw;
122 static const Name SelectionFill;
123 static const Name Grid;
124 static const Name Spot;
125 static const Name Ghost;
126 static const Name TextRuler;
127 static const Name TextCell;
128 static const Name TextInstance;
129 static const Name TextComponent;
130 static const Name TextReference;
131 static const Name Undef;
132 static const Name UnmatchedGroup;
134 static QColor
darken (
const QColor& color,
const DisplayStyle::HSVr& darkening );
161 ,
const std::string& pattern
167 ,
bool goMatched =
true
169 DrawingGroup* findGroup (
const Name& groupKey );
170 void findOrCreate (
const Name& groupKey,
size_t& gi );
171 void toJson ( JsonWriter* )
const;
176 std::string _description;
177 std::vector<DrawingGroup*> _groups;
184 ,
size_t& si )
const;
194 static void initialize ();
195 JsonDisplayStyle (
unsigned long flags );
196 ~JsonDisplayStyle ();
197 virtual string getTypeName ()
const;
198 virtual JsonDisplayStyle* clone (
unsigned long )
const;
206 class JsonHSVr :
public JsonObject {
208 static void initialize ();
209 JsonHSVr (
unsigned long flags );
211 virtual string getTypeName ()
const;
212 virtual JsonHSVr* clone (
unsigned long )
const;
213 virtual void toData ( JsonStack& );
220 class RawDrawingStyle {
223 static DrawingStyle create (
const Name& name
224 ,
const std::string& pattern =
"FFFFFFFFFFFFFFFF"
229 ,
float threshold =1.0
230 ,
bool goMatched =
true
236 inline bool isGoMatched ()
const;
237 inline const Name& getName ()
const;
238 inline const std::string& getPattern ()
const;
239 QColor getColor (
const DisplayStyle::HSVr& )
const;
240 QPen getPen (
const DisplayStyle::HSVr& )
const;
241 QBrush getBrush (
const DisplayStyle::HSVr& )
const;
242 inline float getThreshold ()
const;
243 void toJson ( JsonWriter* )
const;
251 std::string _pattern;
259 RawDrawingStyle (
const Name& name
260 ,
const std::string& pattern
268 RawDrawingStyle (
const RawDrawingStyle& );
271 RawDrawingStyle& operator= (
const RawDrawingStyle& );
278 class JsonDrawingStyle :
public JsonObject {
280 static void initialize ();
281 JsonDrawingStyle (
unsigned long flags );
282 ~JsonDrawingStyle ();
283 virtual string getTypeName ()
const;
284 virtual JsonDrawingStyle* clone (
unsigned long )
const;
285 virtual void toData ( JsonStack& );
292 inline bool RawDrawingStyle::isGoMatched ()
const {
return _goMatched; }
293 inline const Name& RawDrawingStyle::getName ()
const {
return _name; }
294 inline const std::string& RawDrawingStyle::getPattern ()
const {
return _pattern; }
295 inline float RawDrawingStyle::getThreshold ()
const {
return _threshold; }
304 inline DisplayStyle::HSVr::HSVr (
float hue,
float saturation,
float value )
305 : _hue(hue), _saturation(saturation), _value(value) { }
307 inline const Name& DrawingGroup::getName ()
const {
return _name; }
308 inline const DrawingStyles& DrawingGroup::getDrawingStyles ()
const {
return _drawingStyles; }
310 inline bool DisplayStyle::HSVr::isId ()
const {
return (_hue==1.0) and (_saturation==1.0) and (_value==1.0); }
311 inline
float DisplayStyle::HSVr::getHue ()
const {
return _hue; }
312 inline float DisplayStyle::HSVr::getSaturation ()
const {
return _saturation; }
313 inline float DisplayStyle::HSVr::getValue ()
const {
return _value; }
314 inline void DisplayStyle::HSVr::setHue (
float hue ) { _hue=hue; }
315 inline void DisplayStyle::HSVr::setSaturation (
float saturation ) { _saturation=saturation; }
316 inline void DisplayStyle::HSVr::setValue (
float value ) { _value=value; }
318 inline std::string DisplayStyle::HSVr::_getString ()
const
320 std::string s =
"<HSVr " + getString(_hue)
321 +
" " + getString(_saturation)
322 +
" " + getString(_value) +
">";
326 inline void DisplayStyle::HSVr::toJson ( JsonWriter* w )
const
329 jsonWrite( w,
"@typename",
"HSVr" );
330 jsonWrite( w,
"_hue" , _hue );
331 jsonWrite( w,
"_saturation", _saturation );
332 jsonWrite( w,
"_value" , _value );
339 GETSTRING_VALUE_SUPPORT(Hurricane::DisplayStyle::HSVr);
A complete set of DrawinStyles to uses with the CellWidget.
Definition: DisplayStyle.h:91
QColor getColor(const Name &key, const HSVr &) const
void inheritFrom(const DisplayStyle *base)
const std::string & getDescription() const
Definition: DisplayStyle.h:300
const Name & getName() const
Definition: DisplayStyle.h:297
QPen getPen(const Name &key, const HSVr &) const
void setDarkening(const HSVr &)
static QColor darken(const QColor &color, const DisplayStyle::HSVr &darkening)
const std::string & getPattern(const Name &key) const
const HSVr & getDarkening() const
Definition: DisplayStyle.h:299
DisplayStyle(const Name &name)
float getThreshold(const Name &key) const
DrawingStyle find(const Name &key) const
QBrush getBrush(const Name &key, const HSVr &) const
const std::vector< DrawingGroup * > & getDrawingGroups() const
Definition: DisplayStyle.h:298
void setDescription(const std::string &description)
Definition: DisplayStyle.h:301
void addDrawingStyle(const Name &groupKey, const Name &key, const std::string &pattern, int red, int green, int blue, int borderWidth, float threshold, bool goMatched=true)
const Name & getGroup(const Name &key) const