scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Legend.h
Go to the documentation of this file.
1 
11 
29 #ifndef LEGENDMARKER_H
30 #define LEGENDMARKER_H
31 
32 #include <qfont.h>
33 #include <qpen.h>
34 
35 #include <qwt_plot.h>
36 #include <qwt_array.h>
37 #include <qwt_text.h>
38 
39 #include "Graph.h"
40 #include "Plot.h"
41 #include "PlotEnrichement.h"
42 
55 class Legend: public PlotEnrichement
56 {
57 public:
58  Legend(Plot *);
59  ~Legend();
60 
62  enum FrameStyle{None = 0, Line = 1, Shadow=2};
63 
64  QString text(){return d_text->text();};
65  void setText(const QString& s);
66 
68  QRect rect() const;
70  virtual QwtDoubleRect boundingRect() const;
71 
72  void setOrigin(const QPoint & p);
73 
75  void setOriginCoord(double x, double y);
76 
78  void updateOrigin();
79 
80  QColor textColor(){return d_text->color();};
81  void setTextColor(const QColor& c);
82 
83  QColor backgroundColor(){return d_text->backgroundBrush().color();};
84  void setBackgroundColor(const QColor& c);
85 
86  int frameStyle(){return d_frame;};
87  void setFrameStyle(int style);
88 
89  QFont font(){return d_text->font();};
90  void setFont(const QFont& font);
91 
92  int angle(){return d_angle;};
93  void setAngle(int ang){d_angle=ang;};
94 
95 private:
96  void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
97 
98  void drawFrame(QPainter *p, int type, const QRect& rect) const;
99  void drawSymbols(QPainter *p, const QRect& rect,
100  QwtArray<long> height, int symbolLineLength) const;
101  void drawLegends(QPainter *p, const QRect& rect,
102  QwtArray<long> height, int symbolLineLength) const;
103  void drawVector(QPainter *p, int x, int y, int l, int curveIndex) const;
104 
105  QwtArray<long> itemsHeight(int y, int symbolLineLength, int &width, int &height) const;
106  int symbolsMaxLineLength() const;
107  QString parse(const QString& str) const;
108 
109 protected:
112 
114  int d_frame;
115 
117  int d_angle;
118 
120  QwtText* d_text;
121 
123  QPoint d_pos;
124 
126  int hspace;
127 
130 
132 };
133 
134 #endif
Legend::drawFrame
void drawFrame(QPainter *p, int type, const QRect &rect) const
Definition: Legend.cpp:197
Plot.h
Legend::d_angle
int d_angle
Rotation angle: not implemented yet.
Definition: Legend.h:117
Legend::Line
@ Line
Definition: Legend.h:62
Legend::d_pos
QPoint d_pos
TopLeft position in pixels.
Definition: Legend.h:123
Legend::text
QString text()
Definition: Legend.h:64
Legend::~Legend
~Legend()
Definition: Legend.cpp:508
str
#define str(x)
Definition: PythonScripting.cpp:41
PlotEnrichement.h
Legend::d_shadow_size_y
int d_shadow_size_y
Definition: Legend.h:131
Legend::parse
QString parse(const QString &str) const
Definition: Legend.cpp:482
Legend::symbolsMaxLineLength
int symbolsMaxLineLength() const
Definition: Legend.cpp:440
Legend::d_text
QwtText * d_text
Pointer to the QwtText object.
Definition: Legend.h:120
Legend::hspace
int hspace
Distance between symbols and legend text.
Definition: Legend.h:126
Legend::left_margin
int left_margin
Distance between frame and content.
Definition: Legend.h:129
Legend::drawLegends
void drawLegends(QPainter *p, const QRect &rect, QwtArray< long > height, int symbolLineLength) const
Definition: Legend.cpp:356
Legend::setOriginCoord
void setOriginCoord(double x, double y)
Sets the position of the top left corner in axis coordinates.
Definition: Legend.cpp:175
Legend::Shadow
@ Shadow
Definition: Legend.h:62
Legend::updateOrigin
void updateOrigin()
Keep the markers on screen each time the scales are modified by adding/removing curves.
Definition: Legend.cpp:153
Legend::top_margin
int top_margin
Definition: Legend.h:129
Legend::frameStyle
int frameStyle()
Definition: Legend.h:86
Legend::setAngle
void setAngle(int ang)
Definition: Legend.h:93
Legend::setTextColor
void setTextColor(const QColor &c)
Definition: Legend.cpp:134
Legend::setFont
void setFont(const QFont &font)
Definition: Legend.cpp:189
Legend::setFrameStyle
void setFrameStyle(int style)
Definition: Legend.cpp:90
Legend::backgroundColor
QColor backgroundColor()
Definition: Legend.h:83
Legend::draw
void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const
Definition: Legend.cpp:65
Plot
Plot window class.
Definition: Plot.h:44
Legend::setText
void setText(const QString &s)
Definition: Legend.cpp:85
Legend::font
QFont font()
Definition: Legend.h:89
Legend::boundingRect
virtual QwtDoubleRect boundingRect() const
Bounding rectangle in plot coordinates.
Definition: Legend.cpp:120
Legend::rect
QRect rect() const
Bounding rectangle in paint coordinates.
Definition: Legend.cpp:106
Graph.h
Legend::d_frame
int d_frame
Frame type.
Definition: Legend.h:114
Legend::d_shadow_size_x
int d_shadow_size_x
Definition: Legend.h:131
PlotEnrichement
Draw images on a QwtPlot.
Definition: PlotEnrichement.h:63
Legend::setOrigin
void setOrigin(const QPoint &p)
Definition: Legend.cpp:142
Legend::angle
int angle()
Definition: Legend.h:92
Legend::setBackgroundColor
void setBackgroundColor(const QColor &c)
Definition: Legend.cpp:98
Legend::textColor
QColor textColor()
Definition: Legend.h:80
Legend::Legend
Legend(Plot *)
Definition: Legend.cpp:45
Legend::itemsHeight
QwtArray< long > itemsHeight(int y, int symbolLineLength, int &width, int &height) const
Definition: Legend.cpp:391
Legend::drawVector
void drawVector(QPainter *p, int x, int y, int l, int curveIndex) const
Definition: Legend.cpp:224
Legend::drawSymbols
void drawSymbols(QPainter *p, const QRect &rect, QwtArray< long > height, int symbolLineLength) const
Definition: Legend.cpp:258
Legend::None
@ None
Definition: Legend.h:62
Legend::FrameStyle
FrameStyle
The kinds of frame a Legend can draw around the Text.
Definition: Legend.h:62
Legend
A piece of text to be drawn on a Plot.
Definition: Legend.h:56
Legend::d_plot
Plot * d_plot
Parent plot.
Definition: Legend.h:111