LibrePCB Developers Documentation
Loading...
Searching...
No Matches
measuretool.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_EDITOR_MEASURETOOL_H
21#define LIBREPCB_EDITOR_MEASURETOOL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
28
29#include <QtCore>
30#include <QtWidgets>
31
32#include <optional>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Board;
40class Footprint;
41class Path;
42class Schematic;
43class Symbol;
44class Transform;
45
46namespace editor {
47
48class GraphicsView;
49
50/*******************************************************************************
51 * Class MeasureTool
52 ******************************************************************************/
53
57class MeasureTool final : public QObject {
58 Q_OBJECT
59
60public:
61 // Constructors / Destructor
62 MeasureTool() = delete;
63 MeasureTool(const MeasureTool& other) = delete;
64 explicit MeasureTool(GraphicsView& view, const LengthUnit& unit,
65 QObject* parent = nullptr) noexcept;
66 ~MeasureTool() noexcept;
67
68 // General Methods
69 void setSymbol(const Symbol* symbol) noexcept;
70 void setFootprint(const Footprint* footprint) noexcept;
71 void setSchematic(const Schematic* schematic) noexcept;
72 void setBoard(const Board* board) noexcept;
73 void enter() noexcept;
74 void leave() noexcept;
75
76 // Event Handlers
77 bool processKeyPressed(const QKeyEvent& e) noexcept;
78 bool processKeyReleased(const QKeyEvent& e) noexcept;
79 bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent& e) noexcept;
81 QGraphicsSceneMouseEvent& e) noexcept;
82 bool processCopy() noexcept;
83 bool processRemove() noexcept;
84 bool processAbortCommand() noexcept;
85
86 // Operator Overloadings
87 MeasureTool& operator=(const MeasureTool& rhs) = delete;
88
89signals:
90 void statusBarMessageChanged(const QString& message, int timeoutMs = -1);
91
92private: // Methods
94 const Symbol& symbol, const Transform& transform) noexcept;
96 const Footprint& footprint, const Transform& transform) noexcept;
97 static QSet<Point> snapCandidatesFromPath(const Path& path) noexcept;
98 static QSet<Point> snapCandidatesFromCircle(const Point& center,
99 const Length& diameter) noexcept;
100 void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept;
101 void updateRulerPositions() noexcept;
102 void updateStatusBarMessage() noexcept;
103
104private: // Data
111 std::optional<Point> mStartPos;
112 std::optional<Point> mEndPos;
113};
114
115} // namespace editor
116} // namespace librepcb
117
118/*******************************************************************************
119 * End of File
120 ******************************************************************************/
121
122#endif
The Board class represents a PCB of a project and is always part of a circuit.
Definition board.h:73
The Footprint class represents one footprint variant of a package.
Definition footprint.h:55
The Length class is used to represent a length (for example 12.75 millimeters)
Definition length.h:82
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition lengthunit.h:60
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition path.h:57
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:74
The Symbol class represents the part of a component which is added to schematics.
Definition symbol.h:55
Helper class to perform coordinate transformation with various types.
Definition transform.h:59
The GraphicsView class.
Definition graphicsview.h:52
Measure tool providing the measure functionality for the editor states.
Definition measuretool.h:57
bool processKeyReleased(const QKeyEvent &e) noexcept
Definition measuretool.cpp:212
LengthUnit mUnit
Definition measuretool.h:106
bool processKeyPressed(const QKeyEvent &e) noexcept
Definition measuretool.cpp:203
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
std::optional< Point > mEndPos
Definition measuretool.h:112
void updateRulerPositions() noexcept
Definition measuretool.cpp:407
std::optional< Point > mStartPos
Definition measuretool.h:111
bool processRemove() noexcept
Definition measuretool.cpp:260
void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept
Definition measuretool.cpp:376
bool processCopy() noexcept
Definition measuretool.cpp:247
static QSet< Point > snapCandidatesFromCircle(const Point &center, const Length &diameter) noexcept
Definition measuretool.cpp:365
void setSchematic(const Schematic *schematic) noexcept
Definition measuretool.cpp:97
void leave() noexcept
Definition measuretool.cpp:182
void setFootprint(const Footprint *footprint) noexcept
Definition measuretool.cpp:90
MeasureTool(const MeasureTool &other)=delete
void setSymbol(const Symbol *symbol) noexcept
Definition measuretool.cpp:83
QPointer< GraphicsView > mView
Definition measuretool.h:105
static QSet< Point > snapCandidatesFromSymbol(const Symbol &symbol, const Transform &transform) noexcept
Definition measuretool.cpp:287
bool processAbortCommand() noexcept
Definition measuretool.cpp:272
QSet< Point > mSnapCandidates
Definition measuretool.h:107
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept
Definition measuretool.cpp:228
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept
Definition measuretool.cpp:221
static QSet< Point > snapCandidatesFromPath(const Path &path) noexcept
Definition measuretool.cpp:349
void updateStatusBarMessage() noexcept
Definition measuretool.cpp:464
bool mCursorSnapped
Definition measuretool.h:110
void setBoard(const Board *board) noexcept
Definition measuretool.cpp:123
static QSet< Point > snapCandidatesFromFootprint(const Footprint &footprint, const Transform &transform) noexcept
Definition measuretool.cpp:308
void enter() noexcept
Definition measuretool.cpp:169
Point mLastScenePos
Definition measuretool.h:108
Point mCursorPos
Definition measuretool.h:109
Definition occmodel.cpp:76
Definition uuid.h:186