00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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