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 <qwt_plot.h>
00034
00035 #include "Graph.h"
00036
00037 class FrameWidget: public QWidget
00038 {
00039 Q_OBJECT
00040
00041 public:
00042 enum Unit{Inch, Millimeter, Centimeter, Point, Pixel, Scale};
00043
00044 FrameWidget(Graph *);
00045
00046 Graph *plot(){return d_plot;};
00047
00049 enum FrameStyle{None = 0, Line = 1, Shadow = 2};
00050
00052 double xValue(){return d_x;};
00054 double yValue(){return d_y;};
00056 void setOriginCoord(double x, double y);
00058 void setOrigin(int x, int y){move(QPoint(x, y));};
00059 void move(const QPoint& pos);
00060
00062 QRectF boundingRect() const;
00064 void setCoordinates(double left, double top, double right, double bottom);
00066 void setSize(int w, int h){setSize(QSize(w, h));};
00068 void setSize(const QSize& newSize);
00070 void setRect(int x, int y, int w, int h);
00071
00072 double right(){return d_x_right;};
00073 double bottom(){return d_y_bottom;};
00074
00075 static double xIn(QWidget *w, Unit unit);
00076 static double yIn(QWidget *w, Unit unit);
00077 static double widthIn(QWidget *w, Unit unit);
00078 static double heightIn(QWidget *w, Unit unit);
00080 static void setRect(QWidget *, double x, double y, double w, double h, Unit unit = Pixel);
00081
00082 int frameStyle(){return d_frame;};
00083 void setFrameStyle(int style);
00084
00085 QPen framePen(){return d_frame_pen;};
00086 void setFramePen(const QPen& p){d_frame_pen = p;};
00087
00088 Qt::PenStyle frameLineStyle(){return d_frame_pen.style();};
00089 void setFrameLineStyle(const Qt::PenStyle& s){d_frame_pen.setStyle(s);};
00090
00091 QColor frameColor(){return d_frame_pen.color();};
00092 void setFrameColor(const QColor& c){d_frame_pen.setColor(c);};
00093
00094 QColor frameWidth(){return d_frame_pen.width();};
00095 void setFrameWidth(int w){d_frame_pen.setWidth(w);};
00096
00097 QColor backgroundColor(){return palette().color(QPalette::Window);};
00098 void setBackgroundColor(const QColor& c){QPalette pal = palette(); pal.setColor(QPalette::Window, c); setPalette(pal);};
00099
00100 QBrush brush(){return d_brush;};
00101 void setBrush(const QBrush& b){d_brush = b;};
00102
00103 int angle(){return d_angle;};
00104 void setAngle(int ang){d_angle = ang;};
00105
00106 void showContextMenu(){emit showMenu();};
00107 void showPropertiesDialog(){emit showDialog();};
00108
00109 virtual void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
00110 void resetOrigin(){setOriginCoord(d_x, d_y);};
00111 void resetCoordinates(){setCoordinates(d_x, d_y, d_x_right, d_y_bottom);};
00112
00113 virtual void updateCoordinates();
00114 virtual QString saveToString();
00115
00116 signals:
00117 void showDialog();
00118 void showMenu();
00119 void changedCoordinates(const QRectF&);
00120
00121 protected:
00123 double calculateXValue();
00125 double calculateYValue();
00127 double calculateRightValue();
00129 double calculateBottomValue();
00130
00131 void drawFrame(QPainter *p, const QRect& rect);
00132 virtual void paintEvent(QPaintEvent *e);
00133 void mousePressEvent(QMouseEvent *);
00134 void contextMenuEvent(QContextMenuEvent * ){emit showMenu();};
00135
00137 Graph *d_plot;
00138
00140 int d_frame;
00142 QPen d_frame_pen;
00144 QBrush d_brush;
00145
00147 int d_angle;
00148
00150 double d_x;
00152 double d_y;
00154 double d_x_right;
00156 double d_y_bottom;
00158 int d_shadow_width;
00159 };
00160
00161 #endif