LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditorstate_addtext.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_SCHEMATICEDITORSTATE_ADDTEXT_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITORSTATE_ADDTEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Layer;
40class SI_Text;
41class Schematic;
42
43namespace editor {
44
45class CmdTextEdit;
46class LayerComboBox;
47class PositiveLengthEdit;
48
49/*******************************************************************************
50 * Class SchematicEditorState_AddText
51 ******************************************************************************/
52
57 Q_OBJECT
58
59public:
60 // Constructors / Destructor
63 delete;
64 explicit SchematicEditorState_AddText(const Context& context) noexcept;
65 virtual ~SchematicEditorState_AddText() noexcept;
66
67 // General Methods
68 virtual bool entry() noexcept override;
69 virtual bool exit() noexcept override;
70
71 // Event Handlers
72 virtual bool processRotate(const Angle& rotation) noexcept override;
73 virtual bool processMirror(Qt::Orientation orientation) noexcept override;
75 const GraphicsSceneMouseEvent& e) noexcept override;
77 const GraphicsSceneMouseEvent& e) noexcept override;
79 const GraphicsSceneMouseEvent& e) noexcept override;
81 const GraphicsSceneMouseEvent& e) noexcept override;
82
83 // Connection to UI
84 QSet<const Layer*> getAvailableLayers() const noexcept;
85 const Layer& getLayer() const noexcept {
87 }
88 void setLayer(const Layer& layer) noexcept;
89 const PositiveLength& getHeight() const noexcept {
91 }
92 void setHeight(const PositiveLength& height) noexcept;
93 const QString& getText() const noexcept {
95 }
96 QStringList getTextSuggestions() const noexcept;
97 void setText(const QString& text) noexcept;
98
99 // Operator Overloadings
101 const SchematicEditorState_AddText& rhs) = delete;
102
103signals:
104 void layerChanged(const Layer& layer);
105 void heightChanged(const PositiveLength& height);
106 void textChanged(const QString& text);
107
108private: // Methods
109 bool addText(const Point& pos) noexcept;
110 bool rotateText(const Angle& angle) noexcept;
111 bool updatePosition(const Point& pos) noexcept;
112 bool fixPosition(const Point& pos) noexcept;
113 bool abortCommand(bool showErrMsgBox) noexcept;
114 void layerComboBoxLayerChanged(const Layer& layer) noexcept;
115 void textComboBoxValueChanged(const QString& value) noexcept;
116 void heightEditValueChanged(const PositiveLength& value) noexcept;
117
118private: // Data
119 // State
121
122 // Current tool settings
124
125 // Information about the current text to place. Only valid if
126 // mIsUndoCmdActive == true.
129};
130
131/*******************************************************************************
132 * End of File
133 ******************************************************************************/
134
135} // namespace editor
136} // namespace librepcb
137
138#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
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 SI_Text class represents a text label in a schematic.
Definition si_text.h:48
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 QString & getText() const noexcept
Definition text.h:82
The CmdTextEdit class.
Definition cmdtextedit.h:51
The SchematicEditorState_AddText class.
Definition schematiceditorstate_addtext.h:56
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addtext.cpp:114
void layerComboBoxLayerChanged(const Layer &layer) noexcept
virtual bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addtext.cpp:134
void setLayer(const Layer &layer) noexcept
Definition schematiceditorstate_addtext.cpp:154
void setText(const QString &text) noexcept
Definition schematiceditorstate_addtext.cpp:187
void heightEditValueChanged(const PositiveLength &value) noexcept
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addtext.cpp:120
bool updatePosition(const Point &pos) noexcept
Definition schematiceditorstate_addtext.cpp:235
QStringList getTextSuggestions() const noexcept
Definition schematiceditorstate_addtext.cpp:175
const PositiveLength & getHeight() const noexcept
Definition schematiceditorstate_addtext.h:89
const Layer & getLayer() const noexcept
Definition schematiceditorstate_addtext.h:85
void heightChanged(const PositiveLength &height)
SchematicEditorState_AddText(const SchematicEditorState_AddText &other)=delete
QSet< const Layer * > getAvailableLayers() const noexcept
Definition schematiceditorstate_addtext.cpp:149
virtual bool processRotate(const Angle &rotation) noexcept override
Definition schematiceditorstate_addtext.cpp:99
std::unique_ptr< CmdTextEdit > mCurrentTextEditCmd
Definition schematiceditorstate_addtext.h:128
SI_Text * mCurrentTextToPlace
Definition schematiceditorstate_addtext.h:127
void textComboBoxValueChanged(const QString &value) noexcept
const QString & getText() const noexcept
Definition schematiceditorstate_addtext.h:93
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addtext.cpp:129
bool abortCommand(bool showErrMsgBox) noexcept
Definition schematiceditorstate_addtext.cpp:263
bool mIsUndoCmdActive
Definition schematiceditorstate_addtext.h:120
virtual bool exit() noexcept override
Definition schematiceditorstate_addtext.cpp:85
bool fixPosition(const Point &pos) noexcept
Definition schematiceditorstate_addtext.cpp:244
virtual bool processMirror(Qt::Orientation orientation) noexcept override
Definition schematiceditorstate_addtext.cpp:104
void setHeight(const PositiveLength &height) noexcept
Definition schematiceditorstate_addtext.cpp:164
bool addText(const Point &pos) noexcept
Definition schematiceditorstate_addtext.cpp:201
bool rotateText(const Angle &angle) noexcept
Definition schematiceditorstate_addtext.cpp:226
virtual ~SchematicEditorState_AddText() noexcept
Definition schematiceditorstate_addtext.cpp:62
virtual bool entry() noexcept override
Definition schematiceditorstate_addtext.cpp:69
Text mCurrentProperties
Definition schematiceditorstate_addtext.h:123
The schematic editor state base class.
Definition schematiceditorstate.h:58
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition uuid.h:186
Definition graphicsscene.h:45
FSM Context.
Definition schematiceditorfsm.h:62