LegendMarker.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : LegendMarker.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
00007     Description          : Legend marker (extension to QwtPlotMarker)
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 LEGENDMARKER_H
00030 #define LEGENDMARKER_H
00031 
00032 #include <qfont.h>
00033 #include <qpen.h>
00034 
00035 #include <qwt_plot.h>
00036 #include <qwt_array.h>
00037 #include <qwt_text.h>
00038 
00039 #include "Graph.h"
00040 #include "Plot.h"
00041 #include "PlotEnrichement.h"
00042 
00055 class LegendMarker: public PlotEnrichement
00056 {
00057 public:
00058     LegendMarker(Plot *);
00059     ~LegendMarker();
00060 
00062     enum FrameStyle{None = 0, Line = 1, Shadow=2};
00063 
00064     QString text(){return d_text->text();};
00065     void setText(const QString& s);
00066 
00068     QRect rect() const;
00070     virtual QwtDoubleRect boundingRect() const;
00071 
00072     void setOrigin(const QPoint & p);
00073 
00075     void setOriginCoord(double x, double y);
00076 
00078     void updateOrigin();
00079 
00080     QColor textColor(){return d_text->color();};
00081     void setTextColor(const QColor& c);
00082 
00083     QColor backgroundColor(){return d_text->backgroundBrush().color();};
00084     void setBackgroundColor(const QColor& c);
00085 
00086     int frameStyle(){return d_frame;};
00087     void setFrameStyle(int style);
00088 
00089     QFont font(){return d_text->font();};
00090     void setFont(const QFont& font);
00091 
00092     int angle(){return d_angle;};
00093     void setAngle(int ang){d_angle=ang;};
00094 
00095 private:
00096     void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
00097 
00098     void drawFrame(QPainter *p, int type, const QRect& rect) const;
00099     void drawSymbols(QPainter *p, const QRect& rect,
00100                     QwtArray<long> height, int symbolLineLength) const;
00101     void drawLegends(QPainter *p, const QRect& rect,
00102                     QwtArray<long> height, int symbolLineLength) const;
00103     void drawVector(QPainter *p, int x, int y, int l, int curveIndex) const;
00104 
00105     QwtArray<long> itemsHeight(int y, int symbolLineLength, int &width, int &height) const;
00106     int symbolsMaxLineLength() const;
00107     QString parse(const QString& str) const;
00108 
00109 protected:
00111     Plot *d_plot;
00112 
00114     int d_frame;
00115 
00117     int d_angle;
00118 
00120     QwtText* d_text;
00121 
00123     QPoint d_pos;
00124 
00126     int hspace;
00127 
00129     int left_margin, top_margin;
00130 };
00131 
00132 #endif

Generated on Mon Oct 15 06:11:41 2007 for QtiPlot by  doxygen 1.5.3