~librecad-dev/librecad/librecad

« back to all changes in this revision

Viewing changes to librecad/src/lib/gui/rs_painterqt.h

  • Committer: Scott Howard
  • Date: 2014-02-21 19:07:55 UTC
  • Revision ID: showard@debian.org-20140221190755-csjax9wb146hgdq4
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** This file is part of the LibreCAD project, a 2D CAD program
 
4
**
 
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
 
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
 
7
**
 
8
**
 
9
** This file may be distributed and/or modified under the terms of the
 
10
** GNU General Public License version 2 as published by the Free Software
 
11
** Foundation and appearing in the file gpl-2.0.txt included in the
 
12
** packaging of this file.
 
13
**
 
14
** This program is distributed in the hope that it will be useful,
 
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
** GNU General Public License for more details.
 
18
**
 
19
** You should have received a copy of the GNU General Public License
 
20
** along with this program; if not, write to the Free Software
 
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
22
**
 
23
** This copyright notice MUST APPEAR in all copies of the script!
 
24
**
 
25
**********************************************************************/
 
26
 
 
27
 
 
28
#ifndef RS_PAINTERQT_H
 
29
#define RS_PAINTERQT_H
 
30
 
 
31
#include <QPainter>
 
32
 
 
33
#include "rs_painter.h"
 
34
 
 
35
/**
 
36
 * The Qt implementation of a painter. It can draw objects such as
 
37
 * lines or arcs in a widget. All coordinates are screen coordinates
 
38
 * and have nothing to do with the graphic view.
 
39
 */
 
40
class RS_PainterQt: public QPainter, public RS_Painter {
 
41
 
 
42
public:
 
43
    RS_PainterQt( QPaintDevice* pd);
 
44
    virtual ~RS_PainterQt();
 
45
 
 
46
    virtual void moveTo(int x, int y);
 
47
    virtual void lineTo(int x, int y);
 
48
    virtual void drawGridPoint(const RS_Vector& p);
 
49
    virtual void drawPoint(const RS_Vector& p);
 
50
    virtual void drawLine(const RS_Vector& p1, const RS_Vector& p2);
 
51
    //virtual void drawRect(const RS_Vector& p1, const RS_Vector& p2);
 
52
    virtual void fillRect ( const QRectF & rectangle, const RS_Color & color );
 
53
    virtual void fillRect ( const QRectF & rectangle, const QBrush & brush );
 
54
    virtual void drawArc(const RS_Vector& cp, double radius,
 
55
                         double a1, double a2,
 
56
                         const RS_Vector& p1, const RS_Vector& p2,
 
57
                         bool reversed);
 
58
 
 
59
    virtual void drawArc(const RS_Vector& cp, double radius,
 
60
                         double a1, double a2,
 
61
                         bool reversed);
 
62
    virtual void drawArcMac(const RS_Vector& cp, double radius,
 
63
                         double a1, double a2,
 
64
                         bool reversed);
 
65
    virtual void drawCircle(const RS_Vector&, double radius);
 
66
    virtual void drawEllipse(const RS_Vector& cp,
 
67
                             double radius1, double radius2,
 
68
                             double angle,
 
69
                             double a1, double a2,
 
70
                             bool reversed);
 
71
        virtual void drawImg(QImage& img, const RS_Vector& pos,
 
72
            double angle, const RS_Vector& factor,
 
73
            int sx, int sy, int sw, int sh);
 
74
    virtual void drawTextH(int x1, int y1, int x2, int y2,
 
75
                           const QString& text);
 
76
    virtual void drawTextV(int x1, int y1, int x2, int y2,
 
77
                           const QString& text);
 
78
 
 
79
    virtual void fillRect(int x1, int y1, int w, int h,
 
80
                          const RS_Color& col);
 
81
 
 
82
    virtual void fillTriangle(const RS_Vector& p1,
 
83
                              const RS_Vector& p2,
 
84
                              const RS_Vector& p3);
 
85
 
 
86
    virtual void drawPolygon(const QPolygon& a,Qt::FillRule rule=Qt::WindingFill);
 
87
    virtual void drawPath ( const QPainterPath & path );
 
88
    virtual void erase();
 
89
    virtual int getWidth();
 
90
    /** get Density per millimeter on screen/print device
 
91
      *@return density per millimeter in pixel/mm
 
92
      */
 
93
    virtual double getDpmm();
 
94
    virtual int getHeight();
 
95
 
 
96
    virtual RS_Pen getPen();
 
97
    virtual void setPen(const RS_Pen& pen);
 
98
    virtual void setPen(const RS_Color& color);
 
99
    virtual void setPen(int r, int g, int b);
 
100
    virtual void disablePen();
 
101
    //virtual void setColor(const QColor& color);
 
102
    virtual void setBrush(const RS_Color& color);
 
103
 
 
104
    virtual void setClipRect(int x, int y, int w, int h);
 
105
    virtual void resetClipping();
 
106
 
 
107
protected:
 
108
    RS_Pen lpen;
 
109
    long rememberX; // Used for the moment because QPainter doesn't support moveTo anymore, thus we need to remember ourselve the moveTo positions
 
110
    long rememberY;
 
111
};
 
112
 
 
113
#endif
 
114