LibrePCB Developers Documentation
graphicspainter.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
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 3 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, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_GRAPHICSPAINTER_H
21#define LIBREPCB_CORE_GRAPHICSPAINTER_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../types/length.h"
27
28#include <QtCore>
29#include <QtGui>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36class Alignment;
37class Angle;
38class Path;
39class Point;
40
41/*******************************************************************************
42 * Class GraphicsPainter
43 ******************************************************************************/
44
48class GraphicsPainter final {
49public:
50 // Constructors / Destructor
51 GraphicsPainter() = delete;
52 explicit GraphicsPainter(QPainter& painter) noexcept;
53 GraphicsPainter(const GraphicsPainter& other) = delete;
54 ~GraphicsPainter() noexcept;
55
56 // Setters
57 void setMinLineWidth(const UnsignedLength& width) noexcept {
58 mMinLineWidth = width;
59 }
60
61 // General Methods
62 void drawLine(const Point& p1, const Point& p2, const Length& width,
63 const QColor& color) noexcept;
64 void drawPath(const QPainterPath& path, const Length& lineWidth,
65 const QColor& lineColor, const QColor& fillColor) noexcept;
66 void drawPolygon(const Path& path, const Length& lineWidth,
67 const QColor& lineColor, const QColor& fillColor) noexcept;
68 void drawCircle(const Point& center, const Length& diameter,
69 const Length& lineWidth, const QColor& lineColor,
70 const QColor& fillColor) noexcept;
71 void drawSlot(const Path& path, const PositiveLength& diameter,
72 const Length& lineWidth, const QColor& lineColor,
73 const QColor& fillColor) noexcept;
74 void drawText(const Point& position, const Angle& rotation,
75 const Length& height, const Alignment& alignment,
76 const QString& text, QFont font, const QColor& color,
77 bool autoRotate, bool mirrorInPlace, bool parseOverlines,
78 int fontPixelSize = 0) noexcept;
79 void drawSymbolPin(const Point& position, const Angle& rotation,
80 const Length& length, const QColor& lineColor,
81 const QColor& circleColor) noexcept;
82 void drawNetJunction(const Point& position, const QColor& color) noexcept;
83 void drawNetLabel(const Point& position, const Angle& rotation, bool mirror,
84 const QString& text, const QFont& font,
85 const QColor& color) noexcept;
86
87 // Operator Overloadings
88 GraphicsPainter& operator=(const GraphicsPainter& rhs) = delete;
89
90private: // Methods
91 qreal getPenWidthPx(const Length& width) const noexcept;
92
93private: // Data
94 QPainter& mPainter;
96};
97
98/*******************************************************************************
99 * End of File
100 ******************************************************************************/
101
102} // namespace librepcb
103
104#endif
The Alignment class.
Definition: alignment.h:115
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
Draw LibrePCB graphics elements on a QPainter.
Definition: graphicspainter.h:48
qreal getPenWidthPx(const Length &width) const noexcept
Definition: graphicspainter.cpp:253
void drawSlot(const Path &path, const PositiveLength &diameter, const Length &lineWidth, const QColor &lineColor, const QColor &fillColor) noexcept
Definition: graphicspainter.cpp:110
void setMinLineWidth(const UnsignedLength &width) noexcept
Definition: graphicspainter.h:57
void drawCircle(const Point &center, const Length &diameter, const Length &lineWidth, const QColor &lineColor, const QColor &fillColor) noexcept
Definition: graphicspainter.cpp:92
UnsignedLength mMinLineWidth
Definition: graphicspainter.h:95
GraphicsPainter(const GraphicsPainter &other)=delete
QPainter & mPainter
Definition: graphicspainter.h:94
void drawPath(const QPainterPath &path, const Length &lineWidth, const QColor &lineColor, const QColor &fillColor) noexcept
Definition: graphicspainter.cpp:69
~GraphicsPainter() noexcept
Definition: graphicspainter.cpp:49
void drawNetJunction(const Point &position, const QColor &color) noexcept
Definition: graphicspainter.cpp:200
void drawNetLabel(const Point &position, const Angle &rotation, bool mirror, const QString &text, const QFont &font, const QColor &color) noexcept
Definition: graphicspainter.cpp:212
void drawSymbolPin(const Point &position, const Angle &rotation, const Length &length, const QColor &lineColor, const QColor &circleColor) noexcept
Definition: graphicspainter.cpp:178
void drawLine(const Point &p1, const Point &p2, const Length &width, const QColor &color) noexcept
Definition: graphicspainter.cpp:56
void drawText(const Point &position, const Angle &rotation, const Length &height, const Alignment &alignment, const QString &text, QFont font, const QColor &color, bool autoRotate, bool mirrorInPlace, bool parseOverlines, int fontPixelSize=0) noexcept
Definition: graphicspainter.cpp:118
void drawPolygon(const Path &path, const Length &lineWidth, const QColor &lineColor, const QColor &fillColor) noexcept
Definition: graphicspainter.cpp:86
The Length class is used to represent a length (for example 12.75 millimeters)
Definition: length.h:83
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696