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 <QWidget>
00033 #include <qwt_plot.h>
00034 #include <qwt_text.h>
00035 
00036 #include "Graph.h"
00037 
00038 class LegendWidget: public QWidget
00039 {
00040     Q_OBJECT
00041 
00042 public:
00043     LegendWidget(Graph *);
00044     ~LegendWidget();
00045 
00046     void clone(LegendWidget* t);
00047     Graph *plot(){return d_plot;};
00048 
00050     enum FrameStyle{None = 0, Line = 1, Shadow = 2};
00051 
00052     QString text(){return d_text->text();};
00053     void setText(const QString& s);
00054 
00056     double xValue(){return d_x;};
00058     double yValue(){return d_y;};
00060     void setOriginCoord(double x, double y);
00062     void setOrigin(int x, int y){move(QPoint(x, y));};
00063     void move(const QPoint& pos);
00064 
00065     QColor textColor(){return d_text->color();};
00066     void setTextColor(const QColor& c);
00067 
00068     QColor backgroundColor(){return d_text->backgroundBrush().color();};
00069     void setBackgroundColor(const QColor& c);
00070 
00071     int frameStyle(){return d_frame;};
00072     void setFrameStyle(int style);
00073 
00074     QFont font(){return d_text->font();};
00075     void setFont(const QFont& font);
00076 
00077     int angle(){return d_angle;};
00078     void setAngle(int ang){d_angle = ang;};
00079 
00080     void showTextEditor();
00081     void showTextDialog(){emit showDialog();};
00082     void showContextMenu(){emit showMenu();};
00083 
00084     void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
00085     void resetOrigin(){setOriginCoord(d_x, d_y);};
00086     void updateCoordinates();
00087 
00088 private:
00090     double calculateXValue();
00092     double calculateYValue();
00093 
00094     PlotCurve* getCurve(const QString& s, int &point);
00095     void drawFrame(QPainter *p, const QRect& rect);
00096     void drawVector(PlotCurve *c, QPainter *p, int x, int y, int l);
00097     void drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l);
00098     void drawText(QPainter *, const QRect&, QwtArray<long>, int);
00099 
00100     QwtArray<long> itemsHeight(int y, int symbolLineLength, int &width, int &height);
00101     int symbolsMaxWidth();
00102     QString parse(const QString& str);
00103 
00104     virtual void paintEvent(QPaintEvent *e);
00105     void mousePressEvent(QMouseEvent *);
00106     void contextMenuEvent(QContextMenuEvent * ){emit showMenu();};
00107 
00109     Graph *d_plot;
00110 
00112     int d_frame;
00113 
00115     int d_angle;
00116 
00118     QwtText* d_text;
00119 
00121     int h_space;
00122 
00124     int left_margin, top_margin;
00125 
00127     int line_length;
00128 
00130     double d_x;
00132     double d_y;
00133 
00134 signals:
00135     void showDialog();
00136     void showMenu();
00137     void enableEditor();
00138 };
00139 
00140 #endif

Generated on Tue Jun 17 08:36:13 2008 for QtiPlot by  doxygen 1.5.5