LibrePCB Developers Documentation
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#include <optional/tl/optional.hpp>
29
30#include <QtCore>
31#include <QtWidgets>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37
38class Board;
39class Footprint;
40class Path;
41class Schematic;
42class Symbol;
43class Transform;
44
45namespace editor {
46
47class GraphicsView;
48
49/*******************************************************************************
50 * Class MeasureTool
51 ******************************************************************************/
52
56class MeasureTool final : public QObject {
57 Q_OBJECT
58
59public:
60 // Constructors / Destructor
61 MeasureTool() = delete;
62 MeasureTool(const MeasureTool& other) = delete;
63 explicit MeasureTool(GraphicsView& view, const LengthUnit& unit,
64 QObject* parent = nullptr) noexcept;
65 ~MeasureTool() noexcept;
66
67 // General Methods
68 void setSymbol(const Symbol* symbol) noexcept;
69 void setFootprint(const Footprint* footprint) noexcept;
70 void setSchematic(const Schematic* schematic) noexcept;
71 void setBoard(const Board* board) noexcept;
72 void enter() noexcept;
73 void leave() noexcept;
74
75 // Event Handlers
76 bool processKeyPressed(const QKeyEvent& e) noexcept;
77 bool processKeyReleased(const QKeyEvent& e) noexcept;
78 bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent& e) noexcept;
80 QGraphicsSceneMouseEvent& e) noexcept;
81 bool processCopy() noexcept;
82 bool processRemove() noexcept;
83 bool processAbortCommand() noexcept;
84
85 // Operator Overloadings
86 MeasureTool& operator=(const MeasureTool& rhs) = delete;
87
88signals:
89 void statusBarMessageChanged(const QString& message, int timeoutMs = -1);
90
91private: // Methods
93 const Symbol& symbol, const Transform& transform) noexcept;
95 const Footprint& footprint, const Transform& transform) noexcept;
96 static QSet<Point> snapCandidatesFromPath(const Path& path) noexcept;
97 static QSet<Point> snapCandidatesFromCircle(const Point& center,
98 const Length& diameter) noexcept;
99 void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept;
100 void updateRulerPositions() noexcept;
101 void updateStatusBarMessage() noexcept;
102
103private: // Data
110 tl::optional<Point> mStartPos;
111 tl::optional<Point> mEndPos;
112};
113
114} // namespace editor
115} // namespace librepcb
116
117/*******************************************************************************
118 * End of File
119 ******************************************************************************/
120
121#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:83
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:58
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition: point.h:79
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:51
Measure tool providing the measure functionality for the editor states.
Definition: measuretool.h:56
tl::optional< Point > mStartPos
Definition: measuretool.h:110
bool processKeyReleased(const QKeyEvent &e) noexcept
Definition: measuretool.cpp:212
LengthUnit mUnit
Definition: measuretool.h:105
bool processKeyPressed(const QKeyEvent &e) noexcept
Definition: measuretool.cpp:203
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
void updateRulerPositions() noexcept
Definition: measuretool.cpp:407
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:104
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:106
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
tl::optional< Point > mEndPos
Definition: measuretool.h:111
void updateStatusBarMessage() noexcept
Definition: measuretool.cpp:464
bool mCursorSnapped
Definition: measuretool.h:109
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:107
Point mCursorPos
Definition: measuretool.h:108
Definition: occmodel.cpp:77
Definition: uuid.h:183