LegendWidget.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : LegendWidget.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2007 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : A 2D Plot Legend Widget
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef LEGENDWIDGET_H
00030 #define LEGENDWIDGET_H
00031 
00032 #include "FrameWidget.h"
00033 #include "Graph.h"
00034 
00035 #include <qwt_plot.h>
00036 #include <qwt_text.h>
00037 
00038 #include <QWidget>
00039 
00040 class PlotCurve;
00041 
00042 class LegendWidget: public FrameWidget
00043 {
00044     Q_OBJECT
00045 
00046 public:
00047     LegendWidget(Graph *);
00048     ~LegendWidget();
00049 
00050     void clone(LegendWidget* t);
00051 
00052     QString text(){return d_text->text();};
00053     void setText(const QString& s);
00054 
00055     QColor textColor(){return d_text->color();};
00056     void setTextColor(const QColor& c);
00057 
00058     QFont font(){return d_text->font();};
00059     void setFont(const QFont& font);
00060 
00061     void showTextEditor();
00062     void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
00063 
00064     QString saveToString();
00065     static void restore(Graph *g, const QStringList& lst);
00066 
00067     bool isAutoUpdateEnabled(){return d_auto_update;};
00068     void setAutoUpdate(bool on = true){d_auto_update = on;};
00069 
00070     int angle(){return d_angle;};
00071     void setAngle(int angle);
00072 
00073 private:
00074     PlotCurve* getCurve(const QString& s, int &point);
00075     void drawVector(PlotCurve *c, QPainter *p, int x, int y, int l);
00076     void drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l);
00077     void drawText(QPainter *, const QRect&, QwtArray<long>, int);
00078 
00079     QwtArray<long> itemsHeight(int symbolLineLength, int &width, int &height, int &textWidth, int &textHeight);
00080     int symbolsMaxWidth();
00081     QString parse(const QString& str);
00082 
00083     virtual void paintEvent(QPaintEvent *e);
00084 
00086     QwtText* d_text;
00088     int d_angle;
00090     int h_space;
00092     int left_margin, top_margin;
00094     int line_length;
00096     bool d_auto_update;
00097 
00098 signals:
00099     void enableEditor();
00100 };
00101 
00102 #endif

Generated on Fri Nov 7 03:36:52 2008 for QtiPlot by  doxygen 1.5.6