LegendWidget.h
Go to the documentation of this file.
/***************************************************************************
File : LegendWidget.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2007 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : A 2D Plot Legend Widget
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef LEGENDWIDGET_H
#define LEGENDWIDGET_H
#include "FrameWidget.h"
#include "Graph.h"
#include <qwt_plot.h>
#include <qwt_text.h>
#include <QWidget>
class PlotCurve;
class LegendWidget: public FrameWidget
{
Q_OBJECT
public:
LegendWidget(Graph *);
~LegendWidget();
void clone(LegendWidget* t);
QString text(){return d_text->text();};
void setText(const QString& s);
QColor textColor(){return d_text->color();};
void setTextColor(const QColor& c);
QFont font(){return d_text->font();};
void setFont(const QFont& font);
void showTextEditor();
void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
QString saveToString();
static void restore(Graph *g, const QStringList& lst);
bool isAutoUpdateEnabled(){return d_auto_update;};
void setAutoUpdate(bool on = true){d_auto_update = on;};
int angle(){return d_angle;};
void setAngle(int angle);
QSize textSize(QPainter *p, const QwtText& text);
bool hasTeXOutput(){return d_tex_output;};
void setTeXOutput(bool on = true){d_tex_output = on;};
private:
PlotCurve* getCurve(const QString& s, int &point);
void drawVector(PlotCurve *c, QPainter *p, int x, int y, int l);
void drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l);
void drawText(QPainter *, const QRect&, QwtArray<long>, int);
QwtArray<long> itemsHeight(QPainter *p, int symbolLineLength, int frameWidth, int &width, int &height, int &textWidth, int &textHeight);
int symbolsMaxWidth();
QString parse(const QString& str);
virtual void paintEvent(QPaintEvent *e);
QwtText* d_text;
int d_angle;
int h_space;
int left_margin, top_margin;
int line_length;
bool d_auto_update;
bool d_tex_output;
signals:
void enableEditor();
};
#endif
LegendWidget::d_angle
int d_angle
Rotation angle.
Definition: LegendWidget.h:93
LegendWidget::left_margin
int left_margin
Distance between frame and content.
Definition: LegendWidget.h:97
LegendWidget::setText
void setText(const QString &s)
Definition: LegendWidget.cpp:143
FrameWidget::frameWidth
double frameWidth()
Definition: FrameWidget.h:98
LegendWidget::setAutoUpdate
void setAutoUpdate(bool on=true)
Definition: LegendWidget.h:68
LegendWidget::symbolsMaxWidth
int symbolsMaxWidth()
Definition: LegendWidget.cpp:517
LegendWidget::text
QString text()
Definition: LegendWidget.h:52
Graph
A 2D-plotting widget.
Definition: Graph.h:123
LegendWidget::h_space
int h_space
Distance between symbols and legend text.
Definition: LegendWidget.h:95
LegendWidget::drawText
void drawText(QPainter *, const QRect &, QwtArray< long >, int)
Definition: LegendWidget.cpp:260
LegendWidget::isAutoUpdateEnabled
bool isAutoUpdateEnabled()
Definition: LegendWidget.h:67
LegendWidget::drawVector
void drawVector(PlotCurve *c, QPainter *p, int x, int y, int l)
Definition: LegendWidget.cpp:164
LegendWidget::d_text
QwtText * d_text
Pointer to the QwtText object.
Definition: LegendWidget.h:91
LegendWidget::~LegendWidget
~LegendWidget()
Definition: LegendWidget.cpp:880
LegendWidget::parse
QString parse(const QString &str)
Definition: LegendWidget.cpp:577
LegendWidget::setTextColor
void setTextColor(const QColor &c)
Definition: LegendWidget.cpp:148
LegendWidget::angle
int angle()
Definition: LegendWidget.h:70
FrameWidget
Definition: FrameWidget.h:38
FrameWidget.h
LegendWidget::getCurve
PlotCurve * getCurve(const QString &s, int &point)
Definition: LegendWidget.cpp:710
LegendWidget::d_tex_output
bool d_tex_output
Flag telling if the legend contains TeX commands that mustn't be escaped when exporting to ...
Definition: LegendWidget.h:103
LegendWidget
Definition: LegendWidget.h:42
LegendWidget::font
QFont font()
Definition: LegendWidget.h:58
LegendWidget::enableEditor
void enableEditor()
LegendWidget::textColor
QColor textColor()
Definition: LegendWidget.h:55
LegendWidget::setAngle
void setAngle(int angle)
Definition: LegendWidget.cpp:849
LegendWidget::print
void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt])
Definition: LegendWidget.cpp:99
LegendWidget::setFont
void setFont(const QFont &font)
Definition: LegendWidget.cpp:156
LegendWidget::itemsHeight
QwtArray< long > itemsHeight(QPainter *p, int symbolLineLength, int frameWidth, int &width, int &height, int &textWidth, int &textHeight)
Definition: LegendWidget.cpp:392
Graph.h
LegendWidget::LegendWidget
LegendWidget(Graph *)
Definition: LegendWidget.cpp:57
LegendWidget::clone
void clone(LegendWidget *t)
Definition: LegendWidget.cpp:749
LegendWidget::drawSymbol
void drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l)
Definition: LegendWidget.cpp:198
LegendWidget::setTeXOutput
void setTeXOutput(bool on=true)
Definition: LegendWidget.h:76
LegendWidget::showTextEditor
void showTextEditor()
Definition: LegendWidget.cpp:735
LegendWidget::saveToString
QString saveToString()
Definition: LegendWidget.cpp:765
LegendWidget::restore
static void restore(Graph *g, const QStringList &lst)
Definition: LegendWidget.cpp:789
LegendWidget::paintEvent
virtual void paintEvent(QPaintEvent *e)
Definition: LegendWidget.cpp:85
PlotCurve
Abstract 2D plot curve class.
Definition: PlotCurve.h:41
LegendWidget::top_margin
int top_margin
Definition: LegendWidget.h:97
LegendWidget::hasTeXOutput
bool hasTeXOutput()
Definition: LegendWidget.h:75
LegendWidget::textSize
QSize textSize(QPainter *p, const QwtText &text)
Definition: LegendWidget.cpp:864
LegendWidget::line_length
int line_length
Length of the symbol line.
Definition: LegendWidget.h:99
LegendWidget::d_auto_update
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