FrameWidget.h
Go to the documentation of this file.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 FRAMEWIDGET_H
00030 #define FRAMEWIDGET_H
00031
00032 #include <QWidget>
00033 #include <QPen>
00034 #include <qwt_plot.h>
00035
00036 class Graph;
00037
00038 class FrameWidget: public QWidget
00039 {
00040 Q_OBJECT
00041
00042 public:
00044 enum Unit{Inch, Millimeter, Centimeter, Point, Pixel, Scale};
00045
00046 FrameWidget(Graph *);
00047
00048 Graph *plot(){return d_plot;};
00049
00051 enum FrameStyle{None = 0, Line = 1, Shadow = 2};
00053 enum AttachPolicy {Page, Scales};
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
00066 QRectF boundingRect() const;
00068 void setCoordinates(double left, double top, double right, double bottom);
00070 void setSize(int w, int h){setSize(QSize(w, h));};
00072 void setSize(const QSize& newSize);
00074 void setRect(int x, int y, int w, int h);
00075
00076 double right(){return d_x_right;};
00077 double bottom(){return d_y_bottom;};
00078
00079 static double xIn(QWidget *w, Unit unit);
00080 static double yIn(QWidget *w, Unit unit);
00081 static double widthIn(QWidget *w, Unit unit);
00082 static double heightIn(QWidget *w, Unit unit);
00084 static void setRect(QWidget *, double x, double y, double w, double h, Unit unit = Pixel);
00085
00086 int frameStyle(){return d_frame;};
00087 void setFrameStyle(int style);
00088
00089 QPen framePen(){return d_frame_pen;};
00090 void setFramePen(const QPen& p){d_frame_pen = p;};
00091
00092 Qt::PenStyle frameLineStyle(){return d_frame_pen.style();};
00093 void setFrameLineStyle(const Qt::PenStyle& s){d_frame_pen.setStyle(s);};
00094
00095 QColor frameColor(){return d_frame_pen.color();};
00096 void setFrameColor(const QColor& c){d_frame_pen.setColor(c);};
00097
00098 double frameWidth(){return d_frame_pen.widthF();};
00099 void setFrameWidth(double w){d_frame_pen.setWidthF(w);};
00100
00101 QColor backgroundColor(){return palette().color(QPalette::Window);};
00102 void setBackgroundColor(const QColor& c){QPalette pal = palette(); pal.setColor(QPalette::Window, c); setPalette(pal);};
00103
00104 QBrush brush(){return d_brush;};
00105 void setBrush(const QBrush& b){d_brush = b;};
00106
00107 int angle(){return d_angle;};
00108 void setAngle(int ang){d_angle = ang;};
00109
00110 void showContextMenu(){emit showMenu();};
00111 void showPropertiesDialog(){emit showDialog();};
00112
00113 virtual void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
00114 void resetOrigin(){setOriginCoord(d_x, d_y);};
00115 void resetCoordinates(){setCoordinates(d_x, d_y, d_x_right, d_y_bottom);};
00116
00117 virtual void updateCoordinates();
00118 virtual QString saveToString();
00119
00120 void setAttachPolicy(AttachPolicy attachTo);
00121 AttachPolicy attachPolicy(){return d_attach_policy;};
00122
00123 signals:
00124 void showDialog();
00125 void showMenu();
00126 void changedCoordinates(const QRectF&);
00127
00128 protected:
00130 double calculateXValue();
00132 double calculateYValue();
00134 double calculateRightValue();
00136 double calculateBottomValue();
00137
00138 virtual void drawFrame(QPainter *p, const QRect& rect);
00139 virtual void paintEvent(QPaintEvent *e);
00140 void mousePressEvent(QMouseEvent *);
00141 void contextMenuEvent(QContextMenuEvent * ){emit showMenu();};
00142
00144 Graph *d_plot;
00145
00147 int d_frame;
00149 QPen d_frame_pen;
00151 QBrush d_brush;
00152
00154 int d_angle;
00155
00157 double d_x;
00159 double d_y;
00161 double d_x_right;
00163 double d_y_bottom;
00165 int d_shadow_width;
00167 AttachPolicy d_attach_policy;
00168 };
00169
00170 #endif