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 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