]> Shamusworld >> Repos - architektonas/blob - src/base/paintintf.h
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / base / paintintf.h
1 // paintintf.h: Qt Painter interface
2 //
3 // by James L. Hammons
4 // (C) 2010 Underground Software
5
6 #ifndef __PAINTINTF_H__
7 #define __PAINTINTF_H__
8
9 #include <QtGui>
10 #include "rs.h"
11 #include "vector.h"
12 #include "rs_color.h"
13 #include "rs_pen.h"
14
15 // This is an interface class to the rest of the RS_* functions that are supposed
16 // to be toolkit independent, but, because the author of QCad had no idea how to
17 // do that cleanly, we have the present clusterfuck of disaster and failure that
18 // is RS_Painter & friends. This class proposes to fix that.
19 //
20 // The QPainter passed in is only used, never created. Once this class finishes,
21 // it does *nothing* to the QPainter passed in. But this class *MUST^ pass a valid
22 // one in, or else nothing happens.
23 class PaintInterface
24 {
25         public:
26                 PaintInterface(QPainter * p);
27
28                 void setDrawingMode(RS2::DrawingMode m);
29                 RS2::DrawingMode getDrawingMode();
30                 void drawGridPoint(const Vector & p);
31                 void drawPoint(const Vector & p);
32                 void drawLine(const Vector & p1, const Vector & p2);
33                 void drawRect(const Vector & p1, const Vector & p2);
34                 void drawArc(const Vector & cp, double radius, double a1, double a2,
35                         const Vector & p1, const Vector & p2, bool reversed);
36                 void drawArc(const Vector & cp, double radius,
37                         double a1, double a2, bool reversed);
38                 void drawArcMac(const Vector & cp, double radius, double a1, double a2, bool reversed);
39                 void createArc(QPolygon & pa, const Vector & cp, double radius,
40                         double a1, double a2, bool reversed);
41                 void drawCircle(const Vector & cp, double radius);
42                 void drawEllipse(const Vector & cp, double radius1, double radius2,
43                         double angle, double angle1, double angle2, bool reversed);
44                 void drawImg(QImage & img, const Vector & pos,
45                         double angle, const Vector & factor, int sx, int sy, int sw, int sh);
46                 void fillRect(int x1, int y1, int w, int h, const RS_Color & col);
47                 void fillTriangle(const Vector & p1, const Vector & p2, const Vector & p3);
48                 void drawHandle(const Vector & p, const RS_Color & c, int size = -1);
49                 void setPreviewPen();
50                 RS_Pen getPen();
51                 void setPen(const RS_Pen & pen);
52                 void setPen(const RS_Color & color);
53                 void setPen(int r, int g, int b);
54                 void disablePen();
55                 void setBrush(const RS_Color & color);
56                 void drawPolygon(const QPolygon & p);
57                 void erase();
58                 int getWidth();
59                 int getHeight();
60                 void setXORMode();
61                 void setNormalMode();
62                 void setPreviewMode();
63                 bool isPreviewMode();
64                 void setOffset(const Vector & o);
65                 void setClipRect(int x, int y, int w, int h);
66                 void resetClipping();
67                 int toScreenX(double x);
68                 int toScreenY(double y);
69
70         private:
71                 QPainter * painter;
72                 /**
73                  * Current drawing mode.
74                  */
75                 RS2::DrawingMode drawingMode;
76                 /**
77                  * A fixed offset added to all entities drawn (useful for previews).
78                  */
79                 Vector offset;
80                 RS_Pen lpen;
81 };
82
83 #endif  // __PAINTINTF_H__