]> Shamusworld >> Repos - architektonas/blob - src/base/rs_painter.h.old
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / base / rs_painter.h.old
1 /****************************************************************************
2 ** $Id: rs_painter.h 1932 2004-11-30 02:11:33Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the qcadlib Library project.
7 **
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
12 **
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #ifndef RS_PAINTER_H
28 #define RS_PAINTER_H
29
30 #include <QtCore>
31 #include "rs_color.h"
32 #include "rs_math.h"
33 #include "rs_pen.h"
34 #include "vector.h"
35 //Added by qt3to4:
36 #include <Q3PointArray>
37
38 /**
39  * This class is a common interface for a painter class. Such
40  * a class will in it's implementation be responsible to paint
41  * lines, arcs, ... in widgets. All angles in rad.
42  *
43  * Note that this is just an interface used as a slot to
44  * communicate with the qcadlib from a GUI level. This
45  * does not contain any Qt or platform specific code.
46  * (Oh yeah? Then WTF is that Q3PointArray doing in here???)
47  */
48 class RS_Painter
49 {
50         public:
51                 RS_Painter();
52                 virtual ~RS_Painter() {}
53
54                 void setDrawingMode(RS2::DrawingMode m);
55                 RS2::DrawingMode getDrawingMode();
56
57 //              virtual void moveTo(int x, int y) = 0;
58 //              virtual void lineTo(int x, int y) = 0;
59
60                 virtual void drawGridPoint(const Vector & p) = 0;
61                 virtual void drawPoint(const Vector & p) = 0;
62                 virtual void drawLine(const Vector & p1, const Vector & p2) = 0;
63                 virtual void drawRect(const Vector & p1, const Vector & p2);
64                 virtual void drawArc(const Vector & cp, double radius, double a1, double a2,
65                         const Vector & p1, const Vector & p2, bool reversed) = 0;
66                 virtual void drawArc(const Vector & cp, double radius,
67                         double a1, double a2, bool reversed) = 0;
68                 void createArc(Q3PointArray & pa, const Vector & cp, double radius,
69                         double a1, double a2, bool reversed);
70                 virtual void drawCircle(const Vector & cp, double radius) = 0;
71                 virtual void drawEllipse(const Vector & cp, double radius1, double radius2,
72                         double angle, double angle1, double angle2, bool reversed) = 0;
73                 virtual void drawImg(QImage & img, const Vector & pos,
74                         double angle, const Vector & factor, int sx, int sy, int sw, int sh) = 0;
75
76 //              virtual void drawTextH(int x1, int y1, int x2, int y2, const QString & text) = 0;
77 //              virtual void drawTextV(int x1, int y1, int x2, int y2, const QString & text) = 0;
78
79                 virtual void fillRect(int x1, int y1, int w, int h, const RS_Color & col) = 0;
80
81                 virtual void fillTriangle(const Vector & p1, const Vector & p2, const Vector & p3) = 0;
82
83                 virtual void drawHandle(const Vector & p, const RS_Color & c, int size=-1);
84
85                 virtual void setPreviewPen() = 0;
86                 virtual RS_Pen getPen() = 0;
87                 virtual void setPen(const RS_Pen & pen) = 0;
88                 virtual void setPen(const RS_Color & color) = 0;
89                 virtual void setPen(int r, int g, int b) = 0;
90                 virtual void disablePen() = 0;
91                 virtual void setBrush(const RS_Color & color) = 0;
92                 virtual void drawPolygon(const Q3PointArray & a) = 0;
93                 virtual void erase() = 0;
94                 virtual int getWidth() = 0;
95                 virtual int getHeight() = 0;
96
97                 virtual void setXORMode() = 0;
98                 virtual void setNormalMode() = 0;
99
100                 virtual void setPreviewMode();
101                 virtual bool isPreviewMode();
102
103                 virtual void setOffset(const Vector & o);
104
105                 virtual void setClipRect(int x, int y, int w, int h) = 0;
106                 virtual void resetClipping() = 0;
107                 int toScreenX(double x);
108                 int toScreenY(double y);
109
110         protected:
111                 /**
112                 * Current drawing mode.
113                 */
114                 RS2::DrawingMode drawingMode;
115                 /**
116                 * A fixed offset added to all entities drawn (useful for previews).
117                 */
118                 Vector offset;
119 };
120
121 #endif