krita
kis_grid_manager.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KIS_GRID_MANAGER_H
00022 #define KIS_GRID_MANAGER_H
00023
00024 #include <qobject.h>
00025 #include <qpainter.h>
00026
00027 #include "kis_types.h"
00028
00029 class KisView;
00030 class KActionCollection;
00031 class KToggleAction;
00032 class KAction;
00033
00034 class KisGridManager : public QObject
00035 {
00036 Q_OBJECT
00037 public:
00038 KisGridManager(KisView * parent);
00039 ~KisGridManager();
00040 public:
00041 void setup(KActionCollection * collection);
00042 void drawGrid(QRect wr, QPainter *p, bool openGL = false);
00043 public slots:
00044 void updateGUI();
00045 private slots:
00046 void toggleGrid();
00047 void fastConfig1x1();
00048 void fastConfig2x2();
00049 void fastConfig5x5();
00050 void fastConfig10x10();
00051 void fastConfig20x20();
00052 void fastConfig40x40();
00053 private:
00054
00055 class GridDrawer {
00056 public:
00057 GridDrawer() {}
00058 virtual ~GridDrawer() {}
00059
00060 public:
00061 void drawGrid(KisImageSP image, const QRect& wr);
00062
00063 virtual void setPen(const QPen& pen) = 0;
00064 virtual void drawLine(Q_INT32 x1, Q_INT32 y1, Q_INT32 x2, Q_INT32 y2) = 0;
00065 private:
00066 Qt::PenStyle gs2style(Q_UINT32 s);
00067 };
00068
00069 class QPainterGridDrawer : public GridDrawer {
00070 public:
00071 QPainterGridDrawer(QPainter *p) { m_painter = p; }
00072
00073 virtual void setPen(const QPen& pen) { m_painter->setPen(pen); }
00074 virtual void drawLine(Q_INT32 x1, Q_INT32 y1, Q_INT32 x2, Q_INT32 y2) { m_painter->drawLine(x1, y1, x2, y2); }
00075
00076 private:
00077 QPainter *m_painter;
00078 };
00079
00080 class OpenGLGridDrawer : public GridDrawer {
00081 public:
00082 OpenGLGridDrawer();
00083 virtual ~OpenGLGridDrawer();
00084
00085 virtual void setPen(const QPen& pen);
00086 virtual void drawLine(Q_INT32 x1, Q_INT32 y1, Q_INT32 x2, Q_INT32 y2);
00087 };
00088
00089 private:
00090 KisView* m_view;
00091 KToggleAction* m_toggleGrid;
00092 KAction* m_gridConfig;
00093 KAction* m_gridFastConfig1x1;
00094 KAction* m_gridFastConfig2x2;
00095 KAction* m_gridFastConfig5x5;
00096 KAction* m_gridFastConfig10x10;
00097 KAction* m_gridFastConfig20x20;
00098 KAction* m_gridFastConfig40x40;
00099 };
00100
00101 #endif
|