LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditorstate_addcomponent.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_ADDCOMPONENT_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITORSTATE_ADDCOMPONENT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
31
32#include <QtCore>
33
34#include <memory>
35#include <optional>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42class Attribute;
43class ComponentInstance;
44class SI_Symbol;
45
46namespace editor {
47
48class AddComponentDialog;
49class CmdSymbolInstanceEditAll;
50
51/*******************************************************************************
52 * Class SchematicEditorState_AddComponent
53 ******************************************************************************/
54
59 Q_OBJECT
60
61public:
62 // Constructors / Destructor
65 const SchematicEditorState_AddComponent& other) = delete;
66 explicit SchematicEditorState_AddComponent(const Context& context) noexcept;
67 virtual ~SchematicEditorState_AddComponent() noexcept;
68
69 // General Methods
70 virtual bool entry() noexcept override;
71 virtual bool exit() noexcept override;
72
73 // Event Handlers
74 virtual bool processAddComponent(
75 const QString& searchTerm = QString()) noexcept override;
76 virtual bool processAddComponent(const Uuid& cmp,
77 const Uuid& symbVar) noexcept override;
78 virtual bool processRotate(const Angle& rotation) noexcept override;
79 virtual bool processMirror(Qt::Orientation orientation) noexcept override;
80 virtual bool processAbortCommand() noexcept override;
82 const GraphicsSceneMouseEvent& e) noexcept override;
84 const GraphicsSceneMouseEvent& e) noexcept override;
86 const GraphicsSceneMouseEvent& e) noexcept override;
88 const GraphicsSceneMouseEvent& e) noexcept override;
89
90 // Connection to UI
91 const QString& getValue() const noexcept { return mCurrentValue; }
92 void setValue(const QString& value) noexcept;
93 const QStringList& getValueSuggestions() const noexcept {
95 }
96 std::optional<AttributeKey> getValueAttributeKey() const noexcept {
98 ? std::make_optional(mCurrentValueAttribute->getKey())
99 : std::nullopt;
100 }
101 const AttributeType* getValueAttributeType() const noexcept {
103 : nullptr;
104 }
105 std::optional<QString> getValueAttributeValue() const noexcept {
107 ? std::make_optional(mCurrentValueAttribute->getValue())
108 : std::nullopt;
109 }
110 void setValueAttributeValue(const QString& value) noexcept;
111 const AttributeUnit* getValueAttributeUnit() const noexcept {
112 return mCurrentValueAttribute ? mCurrentValueAttribute->getUnit() : nullptr;
113 }
114 void setValueAttributeUnit(const AttributeUnit* unit) noexcept;
115
116 // Operator Overloadings
118 const SchematicEditorState_AddComponent& rhs) = delete;
119
120signals:
121 void valueChanged(const QString& value);
122 void valueSuggestionsChanged(const QStringList& suggestions);
123 void valueAttributeKeyChanged(const std::optional<AttributeKey>& key);
125 void valueAttributeValueChanged(const std::optional<QString>& value);
127
128private: // Methods
130 const std::optional<Uuid>& cmp = std::nullopt,
131 const std::optional<Uuid>& symbVar = std::nullopt,
132 const std::optional<librepcb::ComponentAssemblyOptionList>& options =
133 std::nullopt,
134 const QString& searchTerm = QString(), bool keepValue = false);
135 bool abortCommand(bool showErrMsgBox) noexcept;
136 void applyValueAndAttributeToComponent() noexcept;
137
138private: // Data
142
143 // Current tool settings
149
150 // Information about the current component/symbol to place
155};
156
157/*******************************************************************************
158 * End of File
159 ******************************************************************************/
160
161} // namespace editor
162} // namespace librepcb
163
164#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Attribute class.
Definition attribute.h:46
The AttributeType class.
Definition attributetype.h:42
Type_t getType() const noexcept
Definition attributetype.h:67
The AttributeUnit class.
Definition attributeunit.h:40
The ComponentInstance class.
Definition componentinstance.h:54
The SI_Symbol class.
Definition si_symbol.h:54
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The AddComponentDialog class.
Definition addcomponentdialog.h:73
The CmdSymbolInstanceEditAll class.
Definition cmdsymbolinstanceeditall.h:51
The SchematicEditorState_AddComponent class.
Definition schematiceditorstate_addcomponent.h:58
virtual ~SchematicEditorState_AddComponent() noexcept
Definition schematiceditorstate_addcomponent.cpp:77
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addcomponent.cpp:198
void startAddingComponent(const std::optional< Uuid > &cmp=std::nullopt, const std::optional< Uuid > &symbVar=std::nullopt, const std::optional< librepcb::ComponentAssemblyOptionList > &options=std::nullopt, const QString &searchTerm=QString(), bool keepValue=false)
Definition schematiceditorstate_addcomponent.cpp:384
void setValue(const QString &value) noexcept
Definition schematiceditorstate_addcomponent.cpp:305
virtual bool processGraphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addcomponent.cpp:284
void valueAttributeValueChanged(const std::optional< QString > &value)
void setValueAttributeValue(const QString &value) noexcept
Definition schematiceditorstate_addcomponent.cpp:354
SchematicEditorState_AddComponent(const SchematicEditorState_AddComponent &other)=delete
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addcomponent.cpp:211
void setValueAttributeUnit(const AttributeUnit *unit) noexcept
Definition schematiceditorstate_addcomponent.cpp:367
const AttributeType * getValueAttributeType() const noexcept
Definition schematiceditorstate_addcomponent.h:101
std::optional< QString > getValueAttributeValue() const noexcept
Definition schematiceditorstate_addcomponent.h:105
void valueSuggestionsChanged(const QStringList &suggestions)
QString mCurrentValue
Definition schematiceditorstate_addcomponent.h:146
virtual bool processAbortCommand() noexcept override
Definition schematiceditorstate_addcomponent.cpp:177
ComponentInstance * mCurrentComponent
Definition schematiceditorstate_addcomponent.h:151
bool mUseAddComponentDialog
Definition schematiceditorstate_addcomponent.h:140
void applyValueAndAttributeToComponent() noexcept
Definition schematiceditorstate_addcomponent.cpp:549
virtual bool processRotate(const Angle &rotation) noexcept override
Definition schematiceditorstate_addcomponent.cpp:152
SchematicEditorState_AddComponent & operator=(const SchematicEditorState_AddComponent &rhs)=delete
const QStringList & getValueSuggestions() const noexcept
Definition schematiceditorstate_addcomponent.h:93
std::optional< AttributeKey > getValueAttributeKey() const noexcept
Definition schematiceditorstate_addcomponent.h:96
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_addcomponent.cpp:277
bool abortCommand(bool showErrMsgBox) noexcept
Definition schematiceditorstate_addcomponent.cpp:523
Angle mCurrentAngle
Definition schematiceditorstate_addcomponent.h:144
const QString & getValue() const noexcept
Definition schematiceditorstate_addcomponent.h:91
const AttributeUnit * getValueAttributeUnit() const noexcept
Definition schematiceditorstate_addcomponent.h:111
bool mIsUndoCmdActive
Definition schematiceditorstate_addcomponent.h:139
void valueAttributeUnitChanged(const AttributeUnit *unit)
virtual bool processAddComponent(const QString &searchTerm=QString()) noexcept override
Definition schematiceditorstate_addcomponent.cpp:114
bool mCurrentMirrored
Definition schematiceditorstate_addcomponent.h:145
QStringList mCurrentValueSuggestions
Definition schematiceditorstate_addcomponent.h:147
virtual bool exit() noexcept override
Definition schematiceditorstate_addcomponent.cpp:99
void valueAttributeKeyChanged(const std::optional< AttributeKey > &key)
int mCurrentSymbVarItemIndex
Definition schematiceditorstate_addcomponent.h:152
CmdSymbolInstanceEditAll * mCurrentSymbolEditCommand
Definition schematiceditorstate_addcomponent.h:154
virtual bool processMirror(Qt::Orientation orientation) noexcept override
Definition schematiceditorstate_addcomponent.cpp:164
void valueAttributeTypeChanged(const AttributeType *type)
QScopedPointer< AddComponentDialog > mAddComponentDialog
Definition schematiceditorstate_addcomponent.h:141
SI_Symbol * mCurrentSymbolToPlace
Definition schematiceditorstate_addcomponent.h:153
std::optional< Attribute > mCurrentValueAttribute
Definition schematiceditorstate_addcomponent.h:148
virtual bool entry() noexcept override
Definition schematiceditorstate_addcomponent.cpp:84
The schematic editor state base class.
Definition schematiceditorstate.h:58
Definition occmodel.cpp:77
Definition uuid.h:186
Definition graphicsscene.h:45
FSM Context.
Definition schematiceditorfsm.h:62