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 bool isOnTop(){return d_on_top;};
00124 void setOnTop(bool on = true);
00125
00126 void mousePressEvent(QMouseEvent *);
00127
00128 signals:
00129 void showDialog();
00130 void showMenu();
00131 void changedCoordinates(const QRectF&);
00132
00133 protected:
00135 double calculateXValue();
00137 double calculateYValue();
00139 double calculateRightValue();
00141 double calculateBottomValue();
00142
00143 virtual void drawFrame(QPainter *p, const QRect& rect);
00144 virtual void paintEvent(QPaintEvent *e);
00145 void contextMenuEvent(QContextMenuEvent * ){emit showMenu();};
00146
00148 Graph *d_plot;
00149
00151 int d_frame;
00153 QPen d_frame_pen;
00155 QBrush d_brush;
00156
00158 int d_angle;
00159
00161 double d_x;
00163 double d_y;
00165 double d_x_right;
00167 double d_y_bottom;
00169 int d_shadow_width;
00171 AttachPolicy d_attach_policy;
00172 bool d_on_top;
00173 };
00174
00175 #endif