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 GraphicsScene;
49
50/*******************************************************************************
51 * Class MeasureTool
52 ******************************************************************************/
53
57class MeasureTool final : public QObject {
58 Q_OBJECT
59
60public:
61 // Constructors / Destructor
62 MeasureTool(const MeasureTool& other) = delete;
63 explicit MeasureTool(QObject* parent = nullptr) noexcept;
64 ~MeasureTool() noexcept;
65
66 // General Methods
67 void setSymbol(const Symbol* symbol) noexcept;
68 void setFootprint(const Footprint* footprint) noexcept;
69 void setSchematic(const Schematic* schematic) noexcept;
70 void setBoard(const Board* board) noexcept;
71 void enter(GraphicsScene& scene, const LengthUnit& unit,
72 const Point& pos) noexcept;
73 void leave() noexcept;
74
75 // Event Handlers
76 bool processKeyPressed(int key, Qt::KeyboardModifiers modifiers) noexcept;
77 bool processKeyReleased(int key, Qt::KeyboardModifiers modifiers) noexcept;
79 Qt::KeyboardModifiers modifiers) 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 infoBoxTextChanged(const QString& text);
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:62
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 GraphicsScene class.
Definition graphicsscene.h:64
Measure tool providing the measure functionality for the editor states.
Definition measuretool.h:57
void enter(GraphicsScene &scene, const LengthUnit &unit, const Point &pos) noexcept
Definition measuretool.cpp:168
LengthUnit mUnit
Definition measuretool.h:106
void statusBarMessageChanged(const QString &message, int timeoutMs=-1)
std::optional< Point > mEndPos
Definition measuretool.h:112
void updateRulerPositions() noexcept
Definition measuretool.cpp:405
std::optional< Point > mStartPos
Definition measuretool.h:111
bool processRemove() noexcept
Definition measuretool.cpp:258
void updateCursorPosition(Qt::KeyboardModifiers modifiers) noexcept
Definition measuretool.cpp:374
bool processCopy() noexcept
Definition measuretool.cpp:245
static QSet< Point > snapCandidatesFromCircle(const Point &center, const Length &diameter) noexcept
Definition measuretool.cpp:363
void setSchematic(const Schematic *schematic) noexcept
Definition measuretool.cpp:96
void leave() noexcept
Definition measuretool.cpp:182
void setFootprint(const Footprint *footprint) noexcept
Definition measuretool.cpp:89
MeasureTool(const MeasureTool &other)=delete
void setSymbol(const Symbol *symbol) noexcept
Definition measuretool.cpp:82
bool processKeyPressed(int key, Qt::KeyboardModifiers modifiers) noexcept
Definition measuretool.cpp:202
static QSet< Point > snapCandidatesFromSymbol(const Symbol &symbol, const Transform &transform) noexcept
Definition measuretool.cpp:285
bool processAbortCommand() noexcept
Definition measuretool.cpp:270
QSet< Point > mSnapCandidates
Definition measuretool.h:107
bool processGraphicsSceneLeftMouseButtonPressed() noexcept
Definition measuretool.cpp:229
QPointer< GraphicsScene > mScene
Definition measuretool.h:105
void infoBoxTextChanged(const QString &text)
static QSet< Point > snapCandidatesFromPath(const Path &path) noexcept
Definition measuretool.cpp:347
void updateStatusBarMessage() noexcept
Definition measuretool.cpp:455
bool mCursorSnapped
Definition measuretool.h:110
bool processGraphicsSceneMouseMoved(const Point &pos, Qt::KeyboardModifiers modifiers) noexcept
Definition measuretool.cpp:222
void setBoard(const Board *board) noexcept
Definition measuretool.cpp:122
static QSet< Point > snapCandidatesFromFootprint(const Footprint &footprint, const Transform &transform) noexcept
Definition measuretool.cpp:306
bool processKeyReleased(int key, Qt::KeyboardModifiers modifiers) noexcept
Definition measuretool.cpp:212
Point mLastScenePos
Definition measuretool.h:108
Point mCursorPos
Definition measuretool.h:109
Definition occmodel.cpp:77
Definition uuid.h:186