1
/***************************************************************************
4
--------------------------------------------------------------------
5
Copyright : (C) 2006 by Ion Vasilief, Tilman Benkert
6
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net
7
Description : Legend marker (extension to QwtPlotMarker)
9
***************************************************************************/
11
/***************************************************************************
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. *
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. *
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 *
28
***************************************************************************/
29
#ifndef LEGENDMARKER_H
30
#define LEGENDMARKER_H
36
#include <qwt_array.h>
41
#include "PlotEnrichement.h"
44
* \brief A piece of text to be drawn on a Plot.
46
* Contrary to its name, Legend is not just used for the plot legend,
47
* but for any kind of text; particularly also for the "Add Text" tool.
48
* Accordingly, it is also referred to as "TextMarker" by other classes.
50
* \section future_plans Future Plans
51
* Rename to TextMarker (or maybe TextEnrichment; see documentation of ImageMarker for details).
53
* \sa ImageMarker, ArrowMarker
55
class Legend: public PlotEnrichement
61
//! The kinds of frame a Legend can draw around the Text.
62
enum FrameStyle{None = 0, Line = 1, Shadow=2};
64
QString text(){return d_text->text();};
65
void setText(const QString& s);
67
//! Bounding rectangle in paint coordinates.
69
//! Bounding rectangle in plot coordinates.
70
virtual QwtDoubleRect boundingRect() const;
72
void setOrigin(const QPoint & p);
74
//! Sets the position of the top left corner in axis coordinates
75
void setOriginCoord(double x, double y);
77
//! Keep the markers on screen each time the scales are modified by adding/removing curves
80
QColor textColor(){return d_text->color();};
81
void setTextColor(const QColor& c);
83
QColor backgroundColor(){return d_text->backgroundBrush().color();};
84
void setBackgroundColor(const QColor& c);
86
int frameStyle(){return d_frame;};
87
void setFrameStyle(int style);
89
QFont font(){return d_text->font();};
90
void setFont(const QFont& font);
92
int angle(){return d_angle;};
93
void setAngle(int ang){d_angle=ang;};
96
void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
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;
105
QwtArray<long> itemsHeight(int y, int symbolLineLength, int &width, int &height) const;
106
int symbolsMaxLineLength() const;
107
QString parse(const QString& str) const;
116
//! Rotation angle: not implemented yet
119
//! Pointer to the QwtText object
122
//! TopLeft position in pixels
125
//!Distance between symbols and legend text
128
//!Distance between frame and content
129
int left_margin, top_margin;
131
int d_shadow_size_x, d_shadow_size_y;