QtiPlot  0.9.8.2
LegendWidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : LegendWidget.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2007 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : A 2D Plot Legend Widget
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef LEGENDWIDGET_H
30 #define LEGENDWIDGET_H
31 
32 #include "FrameWidget.h"
33 #include "Graph.h"
34 
35 #include <qwt_plot.h>
36 #include <qwt_text.h>
37 
38 #include <QWidget>
39 
40 class PlotCurve;
41 
43 {
44  Q_OBJECT
45 
46 public:
48  ~LegendWidget();
49 
50  void clone(LegendWidget* t);
51 
52  QString text(){return d_text->text();};
53  void setText(const QString& s);
54 
55  QColor textColor(){return d_text->color();};
56  void setTextColor(const QColor& c);
57 
58  QFont font(){return d_text->font();};
59  void setFont(const QFont& font);
60 
61  void showTextEditor();
62  void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
63 
64  QString saveToString();
65  static void restore(Graph *g, const QStringList& lst);
66 
68  void setAutoUpdate(bool on = true){d_auto_update = on;};
69 
70  int angle(){return d_angle;};
71  void setAngle(int angle);
72 
73  QSize textSize(QPainter *p, const QwtText& text);
74 
75  bool hasTeXOutput(){return d_tex_output;};
76  void setTeXOutput(bool on = true){d_tex_output = on;};
77 
78 private:
79  PlotCurve* getCurve(const QString& s, int &point);
80  void drawVector(PlotCurve *c, QPainter *p, int x, int y, int l);
81  void drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l);
82  void drawText(QPainter *, const QRect&, QwtArray<long>, int);
83 
84  QwtArray<long> itemsHeight(QPainter *p, int symbolLineLength, int frameWidth, int &width, int &height, int &textWidth, int &textHeight);
85  int symbolsMaxWidth();
86  QString parse(const QString& str);
87 
88  virtual void paintEvent(QPaintEvent *e);
89 
91  QwtText* d_text;
93  int d_angle;
95  int h_space;
104 
105 signals:
106  void enableEditor();
107 };
108 
109 #endif
int d_angle
Rotation angle.
Definition: LegendWidget.h:93
int left_margin
Distance between frame and content.
Definition: LegendWidget.h:97
void setText(const QString &s)
Definition: LegendWidget.cpp:143
double frameWidth()
Definition: FrameWidget.h:98
void setAutoUpdate(bool on=true)
Definition: LegendWidget.h:68
int symbolsMaxWidth()
Definition: LegendWidget.cpp:517
QString text()
Definition: LegendWidget.h:52
A 2D-plotting widget.
Definition: Graph.h:123
int h_space
Distance between symbols and legend text.
Definition: LegendWidget.h:95
void drawText(QPainter *, const QRect &, QwtArray< long >, int)
Definition: LegendWidget.cpp:260
bool isAutoUpdateEnabled()
Definition: LegendWidget.h:67
void drawVector(PlotCurve *c, QPainter *p, int x, int y, int l)
Definition: LegendWidget.cpp:164
QwtText * d_text
Pointer to the QwtText object.
Definition: LegendWidget.h:91
~LegendWidget()
Definition: LegendWidget.cpp:880
QString parse(const QString &str)
Definition: LegendWidget.cpp:577
void setTextColor(const QColor &c)
Definition: LegendWidget.cpp:148
int angle()
Definition: LegendWidget.h:70
Definition: FrameWidget.h:38
PlotCurve * getCurve(const QString &s, int &point)
Definition: LegendWidget.cpp:710
bool d_tex_output
Flag telling if the legend contains TeX commands that mustn&#39;t be escaped when exporting to ...
Definition: LegendWidget.h:103
Definition: LegendWidget.h:42
QFont font()
Definition: LegendWidget.h:58
void enableEditor()
QColor textColor()
Definition: LegendWidget.h:55
void setAngle(int angle)
Definition: LegendWidget.cpp:849
void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt])
Definition: LegendWidget.cpp:99
void setFont(const QFont &font)
Definition: LegendWidget.cpp:156
QwtArray< long > itemsHeight(QPainter *p, int symbolLineLength, int frameWidth, int &width, int &height, int &textWidth, int &textHeight)
Definition: LegendWidget.cpp:392
LegendWidget(Graph *)
Definition: LegendWidget.cpp:57
void clone(LegendWidget *t)
Definition: LegendWidget.cpp:749
void drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l)
Definition: LegendWidget.cpp:198
void setTeXOutput(bool on=true)
Definition: LegendWidget.h:76
void showTextEditor()
Definition: LegendWidget.cpp:735
QString saveToString()
Definition: LegendWidget.cpp:765
static void restore(Graph *g, const QStringList &lst)
Definition: LegendWidget.cpp:789
virtual void paintEvent(QPaintEvent *e)
Definition: LegendWidget.cpp:85
Abstract 2D plot curve class.
Definition: PlotCurve.h:41
int top_margin
Definition: LegendWidget.h:97
bool hasTeXOutput()
Definition: LegendWidget.h:75
QSize textSize(QPainter *p, const QwtText &text)
Definition: LegendWidget.cpp:864
int line_length
Length of the symbol line.
Definition: LegendWidget.h:99
bool d_auto_update
Flag telling if the legend should be updated each time a curve is added/removed from the parent plot...
Definition: LegendWidget.h:101