00001 #ifndef GURULER_H
00002 #define GURULER_H
00003
00004 #include <string>
00005
00006
00007
00008 #include <QWidget>
00009 #include <QPoint>
00010 #include <QPainterPath>
00011 #include <QGraphicsView>
00012
00013
00014
00015
00016
00017 namespace PSQt {
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class GURuler : public QWidget
00042 {
00043 Q_OBJECT
00044
00045 public:
00046
00047 enum ORIENT {HD=0, HU, VL, VR};
00048
00049 GURuler( QGraphicsView& view
00050 , const ORIENT& orient = HD
00051 , const float& vmin = 0
00052 , const float& vmax = 100
00053 , const float& vort = 0
00054 , const unsigned& ndiv1= 5
00055 , const unsigned& ndiv2= 2
00056 , const unsigned& opt = 1
00057 , const int& txt_off_h = 0
00058 , const int& txt_off_v = 0
00059 , const int& size_tick1= 8
00060 , const int& size_tick2= 4
00061 , const QColor& color = QColor(Qt::black)
00062 , const QPen& pen = QPen(Qt::black, 2, Qt::SolidLine)
00063 , const QFont& font = QFont()
00064 );
00065
00066 virtual ~GURuler();
00067
00068 void setPars();
00069 void setPathForRuler();
00070
00071
00072 const QPainterPath& pathForRuler(){ return m_path; }
00073 void printTransform();
00074 int precision();
00075
00076 private:
00077
00078 QGraphicsView& m_view;
00079 ORIENT m_orient;
00080 float m_vmin;
00081 float m_vmax;
00082 float m_vort;
00083 unsigned m_ndiv1;
00084 unsigned m_ndiv2;
00085 unsigned m_opt;
00086 int m_txt_off_h;
00087 int m_txt_off_v;
00088 int m_size_tick1;
00089 int m_size_tick2;
00090 QColor m_color;
00091 QPen m_pen;
00092 QFont m_font;
00093
00094
00095 std::vector<QGraphicsItem*> v_textitems;
00096
00097 float m_scx;
00098 float m_scy;
00099 float m_hoff;
00100
00101 QPainterPath m_path;
00102 QGraphicsPathItem* m_path_item;
00103
00104 QPointF m_p1;
00105 QPointF m_p2;
00106 QPointF m_dt1;
00107 QPointF m_dt2;
00108 QPointF m_dtxt;
00109 };
00110
00111
00112 }
00113
00114 #endif // GURULER_H