LibrePCB Developers Documentation
Loading...
Searching...
No Matches
packageeditorstate_drawtextbase.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_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
21#define LIBREPCB_EDITOR_PACKAGEEDITORSTATE_DRAWTEXTBASE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "packageeditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38namespace editor {
39
40class CmdStrokeTextEdit;
41class LayerComboBox;
42class StrokeTextGraphicsItem;
43
44/*******************************************************************************
45 * Class PackageEditorState_DrawTextBase
46 ******************************************************************************/
47
52 Q_OBJECT
53
54public:
55 // Types
56 enum class Mode { NAME, VALUE, TEXT };
57
58 // Constructors / Destructor
61 const PackageEditorState_DrawTextBase& other) = delete;
63 Mode mode) noexcept;
64 virtual ~PackageEditorState_DrawTextBase() noexcept;
65
66 // General Methods
67 bool entry() noexcept override;
68 bool exit() noexcept override;
69
70 // Event Handlers
72 const GraphicsSceneMouseEvent& e) noexcept override;
74 const GraphicsSceneMouseEvent& e) noexcept override;
76 const GraphicsSceneMouseEvent& e) noexcept override;
77 bool processRotate(const Angle& rotation) noexcept override;
78 bool processMirror(Qt::Orientation orientation) noexcept override;
79 bool processFlip(Qt::Orientation orientation) noexcept override;
80
81 // Connection to UI
82 QSet<const Layer*> getAvailableLayers() const noexcept;
83 const Layer& getLayer() const noexcept {
85 }
86 void setLayer(const Layer& layer) noexcept;
87 const QString& getText() const noexcept {
89 }
90 void setText(const QString& text) noexcept;
91 QStringList getTextSuggestions() const noexcept;
92 const PositiveLength& getHeight() const noexcept {
94 }
95 void setHeight(const PositiveLength& height) noexcept;
96 const UnsignedLength& getStrokeWidth() const noexcept {
98 }
99 void setStrokeWidth(const UnsignedLength& width) noexcept;
100 const HAlign& getHAlign() const noexcept {
102 }
103 void setHAlign(const HAlign& align) noexcept;
104 const VAlign& getVAlign() const noexcept {
106 }
107 void setVAlign(const VAlign& align) noexcept;
108
109 // Operator Overloadings
111 const PackageEditorState_DrawTextBase& rhs) = delete;
112
113signals:
114 void layerChanged(const Layer& layer);
115 void textChanged(const QString& text);
116 void heightChanged(const PositiveLength& height);
118 void hAlignChanged(const HAlign& align);
119 void vAlignChanged(const VAlign& align);
120
121protected:
122 virtual void notifyToolEnter() noexcept = 0;
123
124private: // Methods
125 bool startAddText(const Point& pos) noexcept;
126 bool finishAddText(const Point& pos) noexcept;
127 bool abortAddText() noexcept;
128 void resetToDefaultParameters() noexcept;
129
130private:
133
138};
139
140/*******************************************************************************
141 * End of File
142 ******************************************************************************/
143
144} // namespace editor
145} // namespace librepcb
146
147#endif
const HAlign & getH() const noexcept
Definition alignment.h:124
const VAlign & getV() const noexcept
Definition alignment.h:125
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The HAlign class.
Definition alignment.h:43
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 StrokeText class.
Definition stroketext.h:51
const PositiveLength & getHeight() const noexcept
Definition stroketext.h:92
const Layer & getLayer() const noexcept
Definition stroketext.h:89
const Alignment & getAlign() const noexcept
Definition stroketext.h:100
const QString & getText() const noexcept
Definition stroketext.h:104
const UnsignedLength & getStrokeWidth() const noexcept
Definition stroketext.h:93
The VAlign class.
Definition alignment.h:79
The CmdStrokeTextEdit class.
Definition cmdstroketextedit.h:51
The PackageEditorState_DrawTextBase class.
Definition packageeditorstate_drawtextbase.h:51
const VAlign & getVAlign() const noexcept
Definition packageeditorstate_drawtextbase.h:104
const HAlign & getHAlign() const noexcept
Definition packageeditorstate_drawtextbase.h:100
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition packageeditorstate_drawtextbase.cpp:109
std::unique_ptr< CmdStrokeTextEdit > mCurrentEditCmd
Definition packageeditorstate_drawtextbase.h:135
bool abortAddText() noexcept
Definition packageeditorstate_drawtextbase.cpp:325
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition packageeditorstate_drawtextbase.cpp:131
void setLayer(const Layer &layer) noexcept
Definition packageeditorstate_drawtextbase.cpp:194
void setText(const QString &text) noexcept
Definition packageeditorstate_drawtextbase.cpp:204
Mode
Definition packageeditorstate_drawtextbase.h:56
Mode mMode
Definition packageeditorstate_drawtextbase.h:131
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition packageeditorstate_drawtextbase.cpp:121
QStringList getTextSuggestions() const noexcept
Definition packageeditorstate_drawtextbase.cpp:214
const PositiveLength & getHeight() const noexcept
Definition packageeditorstate_drawtextbase.h:92
bool finishAddText(const Point &pos) noexcept
Definition packageeditorstate_drawtextbase.cpp:306
const Layer & getLayer() const noexcept
Definition packageeditorstate_drawtextbase.h:83
virtual ~PackageEditorState_DrawTextBase() noexcept
Definition packageeditorstate_drawtextbase.cpp:68
PackageEditorState_DrawTextBase(const PackageEditorState_DrawTextBase &other)=delete
void heightChanged(const PositiveLength &height)
QSet< const Layer * > getAvailableLayers() const noexcept
Definition packageeditorstate_drawtextbase.cpp:189
bool processRotate(const Angle &rotation) noexcept override
Definition packageeditorstate_drawtextbase.cpp:137
void strokeWidthChanged(const UnsignedLength &width)
const QString & getText() const noexcept
Definition packageeditorstate_drawtextbase.h:87
std::shared_ptr< StrokeText > mCurrentText
Definition packageeditorstate_drawtextbase.h:136
void setVAlign(const VAlign &align) noexcept
Definition packageeditorstate_drawtextbase.cpp:265
PackageEditorState_DrawTextBase & operator=(const PackageEditorState_DrawTextBase &rhs)=delete
std::shared_ptr< StrokeTextGraphicsItem > mCurrentGraphicsItem
Definition packageeditorstate_drawtextbase.h:137
void resetToDefaultParameters() noexcept
Definition packageeditorstate_drawtextbase.cpp:339
void setStrokeWidth(const UnsignedLength &width) noexcept
Definition packageeditorstate_drawtextbase.cpp:243
bool exit() noexcept override
Definition packageeditorstate_drawtextbase.cpp:94
StrokeText mCurrentProperties
Definition packageeditorstate_drawtextbase.h:132
const UnsignedLength & getStrokeWidth() const noexcept
Definition packageeditorstate_drawtextbase.h:96
Point mStartPos
Definition packageeditorstate_drawtextbase.h:134
bool processFlip(Qt::Orientation orientation) noexcept override
Definition packageeditorstate_drawtextbase.cpp:164
bool processMirror(Qt::Orientation orientation) noexcept override
Definition packageeditorstate_drawtextbase.cpp:148
void setHeight(const PositiveLength &height) noexcept
Definition packageeditorstate_drawtextbase.cpp:232
void setHAlign(const HAlign &align) noexcept
Definition packageeditorstate_drawtextbase.cpp:254
bool startAddText(const Point &pos) noexcept
Definition packageeditorstate_drawtextbase.cpp:280
bool entry() noexcept override
Definition packageeditorstate_drawtextbase.cpp:76
The PackageEditorState class is the base class of all package editor FSM states.
Definition packageeditorstate.h:52
The StrokeTextGraphicsItem class is the graphical representation of a librepcb::StrokeText.
Definition stroketextgraphicsitem.h:49
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition uuid.h:186
Definition graphicsscene.h:45
Definition packageeditorfsm.h:89