1 /****************************************************************************
2 ** $Id: rs_painter.h 1932 2004-11-30 02:11:33Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
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.
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.
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.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
36 #include <Q3PointArray>
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.
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???)
52 virtual ~RS_Painter() {}
54 void setDrawingMode(RS2::DrawingMode m);
55 RS2::DrawingMode getDrawingMode();
57 // virtual void moveTo(int x, int y) = 0;
58 // virtual void lineTo(int x, int y) = 0;
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;
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;
79 virtual void fillRect(int x1, int y1, int w, int h, const RS_Color & col) = 0;
81 virtual void fillTriangle(const Vector & p1, const Vector & p2, const Vector & p3) = 0;
83 virtual void drawHandle(const Vector & p, const RS_Color & c, int size=-1);
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;
97 virtual void setXORMode() = 0;
98 virtual void setNormalMode() = 0;
100 virtual void setPreviewMode();
101 virtual bool isPreviewMode();
103 virtual void setOffset(const Vector & o);
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);
112 * Current drawing mode.
114 RS2::DrawingMode drawingMode;
116 * A fixed offset added to all entities drawn (useful for previews).