chalk

kis_grid_drawer.h
1/*
2 * This file is part of Chalk
3 *
4 * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef KIS_GRID_DRAWER_H
22#define KIS_GRID_DRAWER_H
23
24#include <math.h>
25
26#include <tqobject.h>
27#include <tqpainter.h>
28
29#include "kis_types.h"
30#include "kis_point.h"
31
32class KisSubPerspectiveGrid;
33
34class GridDrawer {
35 public:
36 GridDrawer() {}
37 virtual ~GridDrawer() {}
38
39 public:
40 void drawGrid(KisImageSP image, const TQRect& wr);
41 void drawPerspectiveGrid(KisImageSP image, const TQRect& wr, const KisSubPerspectiveGrid* grid);
42
43 virtual void setPen(const TQPen& pen) = 0;
44 virtual void drawLine(TQ_INT32 x1, TQ_INT32 y1, TQ_INT32 x2, TQ_INT32 y2) = 0;
45 inline void drawLine(const TQPoint& p1, const TQPoint& p2) { drawLine(p1.x(), p1.y(), p2.x(), p2.y() ); }
46 inline void drawLine(const KisPoint* p1, const KisPoint* p2) { drawLine( p1->roundTQPoint(), p2->roundTQPoint()); }
47 private:
48 TQt::PenStyle gs2style(TQ_UINT32 s);
49};
50
51class TQPainterGridDrawer : public GridDrawer {
52public:
53 TQPainterGridDrawer(TQPainter *p) { m_painter = p; }
54
55 virtual void setPen(const TQPen& pen) { m_painter->setPen(pen); }
56 virtual void drawLine(TQ_INT32 x1, TQ_INT32 y1, TQ_INT32 x2, TQ_INT32 y2) { m_painter->drawLine(x1, y1, x2, y2); }
57
58private:
59 TQPainter *m_painter;
60};
61
62class OpenGLGridDrawer : public GridDrawer {
63public:
64 OpenGLGridDrawer();
65 virtual ~OpenGLGridDrawer();
66
67 virtual void setPen(const TQPen& pen);
68 virtual void drawLine(TQ_INT32 x1, TQ_INT32 y1, TQ_INT32 x2, TQ_INT32 y2);
69};
70
71#endif
A double-based point class that can return it's coordinates approximated to integers.
Definition kis_point.h:28