LibrePCB Developers Documentation
Loading...
Searching...
No Matches
symboleditorstate_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_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
21#define LIBREPCB_EDITOR_SYMBOLEDITORSTATE_DRAWTEXTBASE_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "symboleditorstate.h"
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38namespace editor {
39
40class CmdTextEdit;
41class TextGraphicsItem;
42
43/*******************************************************************************
44 * Class SymbolEditorState_DrawTextBase
45 ******************************************************************************/
46
51 Q_OBJECT
52
53public:
54 // Types
55 enum class Mode { NAME, VALUE, TEXT };
56
57 // Constructors / Destructor
60 delete;
61 explicit SymbolEditorState_DrawTextBase(const Context& context,
62 Mode mode) noexcept;
63 virtual ~SymbolEditorState_DrawTextBase() noexcept;
64
65 // General Methods
66 bool entry() noexcept override;
67 bool exit() noexcept override;
68
69 // Event Handlers
71 const GraphicsSceneMouseEvent& e) noexcept override;
73 const GraphicsSceneMouseEvent& e) noexcept override;
75 const GraphicsSceneMouseEvent& e) noexcept override;
76 bool processRotate(const Angle& rotation) noexcept override;
77 bool processMirror(Qt::Orientation orientation) noexcept override;
78
79 // Connection to UI
80 QSet<const Layer*> getAvailableLayers() const noexcept;
81 const Layer& getLayer() const noexcept {
83 }
84 void setLayer(const Layer& layer) noexcept;
85 const QString& getText() const noexcept {
87 }
88 void setText(const QString& text) noexcept;
89 QStringList getTextSuggestions() const noexcept;
90 const PositiveLength& getHeight() const noexcept {
92 }
93 void setHeight(const PositiveLength& height) noexcept;
94 const HAlign& getHAlign() const noexcept {
96 }
97 void setHAlign(const HAlign& align) noexcept;
98 const VAlign& getVAlign() const noexcept {
100 }
101 void setVAlign(const VAlign& align) noexcept;
102
103 // Operator Overloadings
105 const SymbolEditorState_DrawTextBase& rhs) = delete;
106
107signals:
108 void layerChanged(const Layer& layer);
109 void textChanged(const QString& text);
110 void heightChanged(const PositiveLength& height);
111 void hAlignChanged(const HAlign& align);
112 void vAlignChanged(const VAlign& align);
113
114protected:
115 virtual void notifyToolEnter() noexcept = 0;
116
117private: // Methods
118 bool startAddText(const Point& pos) noexcept;
119 bool finishAddText(const Point& pos) noexcept;
120 bool abortAddText() noexcept;
121 void resetToDefaultParameters() noexcept;
122
123private:
126
129 std::shared_ptr<Text> mCurrentText;
131};
132
133/*******************************************************************************
134 * End of File
135 ******************************************************************************/
136
137} // namespace editor
138} // namespace librepcb
139
140#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 Text class.
Definition text.h:48
const PositiveLength & getHeight() const noexcept
Definition text.h:80
const Layer & getLayer() const noexcept
Definition text.h:77
const Alignment & getAlign() const noexcept
Definition text.h:81
const QString & getText() const noexcept
Definition text.h:82
The VAlign class.
Definition alignment.h:79
The CmdTextEdit class.
Definition cmdtextedit.h:51
The SymbolEditorState_DrawTextBase class.
Definition symboleditorstate_drawtextbase.h:50
const VAlign & getVAlign() const noexcept
Definition symboleditorstate_drawtextbase.h:98
const HAlign & getHAlign() const noexcept
Definition symboleditorstate_drawtextbase.h:94
bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawtextbase.cpp:102
SymbolEditorState_DrawTextBase(const SymbolEditorState_DrawTextBase &other)=delete
bool abortAddText() noexcept
Definition symboleditorstate_drawtextbase.cpp:285
bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawtextbase.cpp:123
void setLayer(const Layer &layer) noexcept
Definition symboleditorstate_drawtextbase.cpp:164
void setText(const QString &text) noexcept
Definition symboleditorstate_drawtextbase.cpp:174
Mode
Definition symboleditorstate_drawtextbase.h:55
SymbolEditorState_DrawTextBase & operator=(const SymbolEditorState_DrawTextBase &rhs)=delete
Mode mMode
Definition symboleditorstate_drawtextbase.h:124
bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition symboleditorstate_drawtextbase.cpp:113
QStringList getTextSuggestions() const noexcept
Definition symboleditorstate_drawtextbase.cpp:184
const PositiveLength & getHeight() const noexcept
Definition symboleditorstate_drawtextbase.h:90
std::shared_ptr< Text > mCurrentText
Definition symboleditorstate_drawtextbase.h:129
bool finishAddText(const Point &pos) noexcept
Definition symboleditorstate_drawtextbase.cpp:266
const Layer & getLayer() const noexcept
Definition symboleditorstate_drawtextbase.h:81
std::shared_ptr< TextGraphicsItem > mCurrentGraphicsItem
Definition symboleditorstate_drawtextbase.h:130
std::unique_ptr< CmdTextEdit > mCurrentEditCmd
Definition symboleditorstate_drawtextbase.h:128
void heightChanged(const PositiveLength &height)
QSet< const Layer * > getAvailableLayers() const noexcept
Definition symboleditorstate_drawtextbase.cpp:159
bool processRotate(const Angle &rotation) noexcept override
Definition symboleditorstate_drawtextbase.cpp:129
const QString & getText() const noexcept
Definition symboleditorstate_drawtextbase.h:85
void setVAlign(const VAlign &align) noexcept
Definition symboleditorstate_drawtextbase.cpp:225
void resetToDefaultParameters() noexcept
Definition symboleditorstate_drawtextbase.cpp:299
bool exit() noexcept override
Definition symboleditorstate_drawtextbase.cpp:87
virtual ~SymbolEditorState_DrawTextBase() noexcept
Definition symboleditorstate_drawtextbase.cpp:62
Point mStartPos
Definition symboleditorstate_drawtextbase.h:127
bool processMirror(Qt::Orientation orientation) noexcept override
Definition symboleditorstate_drawtextbase.cpp:140
void setHeight(const PositiveLength &height) noexcept
Definition symboleditorstate_drawtextbase.cpp:203
void setHAlign(const HAlign &align) noexcept
Definition symboleditorstate_drawtextbase.cpp:214
bool startAddText(const Point &pos) noexcept
Definition symboleditorstate_drawtextbase.cpp:240
bool entry() noexcept override
Definition symboleditorstate_drawtextbase.cpp:70
Text mCurrentProperties
Definition symboleditorstate_drawtextbase.h:125
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition symboleditorstate.h:56
The TextGraphicsItem class is the graphical representation of a librepcb::Text.
Definition textgraphicsitem.h:49
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
Definition graphicsscene.h:45
Definition symboleditorfsm.h:75