LibrePCB Developers Documentation
Loading...
Searching...
No Matches
boardeditorstate_addstroketext.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_BOARDEDITORSTATE_ADDSTROKETEXT_H
21#define LIBREPCB_EDITOR_BOARDEDITORSTATE_ADDSTROKETEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "boardeditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Board;
40
41namespace editor {
42
43class CmdBoardStrokeTextEdit;
44
45/*******************************************************************************
46 * Class BoardEditorState_AddStrokeText
47 ******************************************************************************/
48
53 Q_OBJECT
54
55public:
56 // Constructors / Destructor
59 delete;
60 explicit BoardEditorState_AddStrokeText(const Context& context) noexcept;
61 virtual ~BoardEditorState_AddStrokeText() noexcept;
62
63 // General Methods
64 virtual bool entry() noexcept override;
65 virtual bool exit() noexcept override;
66
67 // Event Handlers
68 virtual bool processRotate(const Angle& rotation) noexcept override;
69 virtual bool processFlip(Qt::Orientation orientation) noexcept override;
71 const GraphicsSceneMouseEvent& e) noexcept override;
73 const GraphicsSceneMouseEvent& e) noexcept override;
75 const GraphicsSceneMouseEvent& e) noexcept override;
77 const GraphicsSceneMouseEvent& e) noexcept override;
78
79 // Connection to UI
80 QSet<const Layer*> getAvailableLayers() noexcept;
81 const Layer& getLayer() const noexcept {
83 }
84 void setLayer(const Layer& layer) noexcept;
85 const PositiveLength& getHeight() const noexcept {
87 }
88 void setHeight(const PositiveLength& height) noexcept;
89 const QString& getText() const noexcept {
91 }
92 QStringList getTextSuggestions() const noexcept;
93 void setText(const QString& text) noexcept;
94 bool getMirrored() const noexcept { return mCurrentProperties.getMirrored(); }
95 void setMirrored(bool mirrored) noexcept;
96
97 // Operator Overloadings
99 const BoardEditorState_AddStrokeText& rhs) = delete;
100
101signals:
102 void layerChanged(const Layer& layer);
103 void heightChanged(const PositiveLength& height);
104 void textChanged(const QString& text);
105 void mirroredChanged(bool mirrored);
106
107private: // Methods
108 bool addText(const Point& pos) noexcept;
109 bool rotateText(const Angle& angle) noexcept;
110 bool flipText(Qt::Orientation orientation) noexcept;
111 bool updatePosition(const Point& pos) noexcept;
112 bool fixPosition(const Point& pos) noexcept;
113 bool abortCommand(bool showErrMsgBox) noexcept;
114
115private: // Data
116 // State
118
119 // Current tool settings
121
122 // Information about the current text to place. Only valid if
123 // mIsUndoCmdActive == true.
125 std::unique_ptr<CmdBoardStrokeTextEdit> mCurrentTextEditCmd;
126};
127
128/*******************************************************************************
129 * End of File
130 ******************************************************************************/
131
132} // namespace editor
133} // namespace librepcb
134
135#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The BI_StrokeText class.
Definition bi_stroketext.h:49
The BoardStrokeTextData class.
Definition boardstroketextdata.h:49
bool getMirrored() const noexcept
Definition boardstroketextdata.h:81
const PositiveLength & getHeight() const noexcept
Definition boardstroketextdata.h:72
const Layer & getLayer() const noexcept
Definition boardstroketextdata.h:69
const QString & getText() const noexcept
Definition boardstroketextdata.h:84
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The "add stroke text" state/tool of the board editor.
Definition boardeditorstate_addstroketext.h:52
bool getMirrored() const noexcept
Definition boardeditorstate_addstroketext.h:94
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addstroketext.cpp:117
virtual ~BoardEditorState_AddStrokeText() noexcept
Definition boardeditorstate_addstroketext.cpp:68
virtual bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addstroketext.cpp:138
void setLayer(const Layer &layer) noexcept
Definition boardeditorstate_addstroketext.cpp:158
void setText(const QString &text) noexcept
Definition boardeditorstate_addstroketext.cpp:190
QSet< const Layer * > getAvailableLayers() noexcept
Definition boardeditorstate_addstroketext.cpp:154
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addstroketext.cpp:123
std::unique_ptr< CmdBoardStrokeTextEdit > mCurrentTextEditCmd
Definition boardeditorstate_addstroketext.h:125
bool updatePosition(const Point &pos) noexcept
Definition boardeditorstate_addstroketext.cpp:265
QStringList getTextSuggestions() const noexcept
Definition boardeditorstate_addstroketext.cpp:180
const PositiveLength & getHeight() const noexcept
Definition boardeditorstate_addstroketext.h:85
const Layer & getLayer() const noexcept
Definition boardeditorstate_addstroketext.h:81
BoardEditorState_AddStrokeText & operator=(const BoardEditorState_AddStrokeText &rhs)=delete
void heightChanged(const PositiveLength &height)
virtual bool processRotate(const Angle &rotation) noexcept override
Definition boardeditorstate_addstroketext.cpp:107
const QString & getText() const noexcept
Definition boardeditorstate_addstroketext.h:89
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition boardeditorstate_addstroketext.cpp:132
void setMirrored(bool mirrored) noexcept
Definition boardeditorstate_addstroketext.cpp:200
BoardStrokeTextData mCurrentProperties
Definition boardeditorstate_addstroketext.h:120
bool abortCommand(bool showErrMsgBox) noexcept
Definition boardeditorstate_addstroketext.cpp:293
bool mIsUndoCmdActive
Definition boardeditorstate_addstroketext.h:117
virtual bool exit() noexcept override
Definition boardeditorstate_addstroketext.cpp:93
bool fixPosition(const Point &pos) noexcept
Definition boardeditorstate_addstroketext.cpp:274
virtual bool processFlip(Qt::Orientation orientation) noexcept override
Definition boardeditorstate_addstroketext.cpp:112
void setHeight(const PositiveLength &height) noexcept
Definition boardeditorstate_addstroketext.cpp:169
bool flipText(Qt::Orientation orientation) noexcept
Definition boardeditorstate_addstroketext.cpp:249
bool addText(const Point &pos) noexcept
Definition boardeditorstate_addstroketext.cpp:214
BoardEditorState_AddStrokeText(const BoardEditorState_AddStrokeText &other)=delete
bool rotateText(const Angle &angle) noexcept
Definition boardeditorstate_addstroketext.cpp:239
virtual bool entry() noexcept override
Definition boardeditorstate_addstroketext.cpp:75
BI_StrokeText * mCurrentTextToPlace
Definition boardeditorstate_addstroketext.h:124
The board editor state base class.
Definition boardeditorstate.h:60
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
FSM Context.
Definition boardeditorfsm.h:88
Definition graphicsscene.h:45