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 #include "Plot.h"
00038 
00039 class LegendWidget: public QWidget
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044     LegendWidget(Plot *);
00045     ~LegendWidget();
00046 
00047     QwtPlot *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     void setOriginCoord(double x, double y);
00057 
00058     QColor textColor(){return d_text->color();};
00059     void setTextColor(const QColor& c);
00060 
00061     QColor backgroundColor(){return d_text->backgroundBrush().color();};
00062     void setBackgroundColor(const QColor& c);
00063 
00064     int frameStyle(){return d_frame;};
00065     void setFrameStyle(int style);
00066 
00067     QFont font(){return d_text->font();};
00068     void setFont(const QFont& font);
00069 
00070     int angle(){return d_angle;};
00071     void setAngle(int ang){d_angle = ang;};
00072 
00073     double xValue();
00074     double yValue();
00075 
00076     void setSelected(bool on = true);
00077 
00078     void showTextEditor();
00079     void showTextDialog(){emit showDialog();};
00080     void showContextMenu(){emit showMenu();};
00081 
00082     void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
00083     void setSVGMode(bool on = true){d_SVG_mode = on;};
00084 
00085 private:
00086     PlotCurve* getCurve(const QString& s, int &point);
00087     void drawFrame(QPainter *p, const QRect& rect);
00088     void drawVector(PlotCurve *c, QPainter *p, int x, int y, int l);
00089     void drawSymbol(PlotCurve *c, int point, QPainter *p, int x, int y, int l);
00090     void drawText(QPainter *, const QRect&, QwtArray<long>, int);
00091 
00092     QwtArray<long> itemsHeight(int y, int symbolLineLength, int &width, int &height);
00093     int symbolsMaxWidth();
00094     QString parse(const QString& str);
00095     QString parseSVG(const QString& str);
00096 
00097     virtual void paintEvent(QPaintEvent *e);
00098     void mousePressEvent(QMouseEvent *);
00099     void contextMenuEvent(QContextMenuEvent * ){emit showMenu();};
00100 
00102     Plot *d_plot;
00103 
00105     int d_frame;
00106 
00108     int d_angle;
00109 
00111     QwtText* d_text;
00112 
00114     int h_space;
00115 
00117     int left_margin, top_margin;
00118 
00120     int line_length;
00121 
00122     double d_x, d_y;
00123 
00124     SelectionMoveResizer *d_selector;
00125     
00127     bool d_SVG_mode;
00128 
00129 signals:
00130     void showDialog();
00131     void showMenu();
00132     void enableEditor();
00133 };
00134 
00135 #endif

Generated on Thu Feb 7 13:59:27 2008 for QtiPlot by  doxygen 1.5.4