LibrePCB Developers Documentation
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#include <QtWidgets>
34
35#include <memory>
36#include <optional.hpp>
37
38/*******************************************************************************
39 * Namespace / Forward Declarations
40 ******************************************************************************/
41namespace librepcb {
42
43class Attribute;
44class ComponentInstance;
45class SI_Symbol;
46
47namespace editor {
48
49class AddComponentDialog;
50class AttributeUnitComboBox;
51class CmdSymbolInstanceEditAll;
52
53/*******************************************************************************
54 * Class SchematicEditorState_AddComponent
55 ******************************************************************************/
56
61 Q_OBJECT
62
63public:
64 // Constructors / Destructor
67 const SchematicEditorState_AddComponent& other) = delete;
68 explicit SchematicEditorState_AddComponent(const Context& context) noexcept;
69 virtual ~SchematicEditorState_AddComponent() noexcept;
70
71 // General Methods
72 virtual bool entry() noexcept override;
73 virtual bool exit() noexcept override;
74
75 // Event Handlers
76 virtual bool processAddComponent(
77 const QString& searchTerm = QString()) noexcept override;
78 virtual bool processAddComponent(const Uuid& cmp,
79 const Uuid& symbVar) noexcept override;
80 virtual bool processRotate(const Angle& rotation) noexcept override;
81 virtual bool processMirror(Qt::Orientation orientation) noexcept override;
82 virtual bool processAbortCommand() noexcept override;
84 QGraphicsSceneMouseEvent& e) noexcept override;
86 QGraphicsSceneMouseEvent& e) noexcept override;
88 QGraphicsSceneMouseEvent& e) noexcept override;
90 QGraphicsSceneMouseEvent& e) noexcept override;
91
92 // Operator Overloadings
94 const SchematicEditorState_AddComponent& rhs) = delete;
95
96private: // Methods
98 const tl::optional<Uuid>& cmp = tl::nullopt,
99 const tl::optional<Uuid>& symbVar = tl::nullopt,
100 const tl::optional<librepcb::ComponentAssemblyOptionList>& options =
101 tl::nullopt,
102 const QString& searchTerm = QString(), bool keepValue = false);
103 bool abortCommand(bool showErrMsgBox) noexcept;
104 std::shared_ptr<const Attribute> getToolbarAttribute() const noexcept;
105 void valueChanged(QString text) noexcept;
106 void attributeChanged() noexcept;
107 void updateValueToolbar() noexcept;
108 void updateAttributeToolbar() noexcept;
109 static QString toSingleLine(const QString& text) noexcept;
110 static QString toMultiLine(const QString& text) noexcept;
111
112private: // Data
118
119 // information about the current component/symbol to place
124
125 // Widgets for the command toolbar
126 QPointer<QComboBox> mValueComboBox;
127 QPointer<QLineEdit> mAttributeValueEdit;
128 QPointer<QAction> mAttributeValueEditAction;
131};
132
133/*******************************************************************************
134 * End of File
135 ******************************************************************************/
136
137} // namespace editor
138} // namespace librepcb
139
140#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
The Attribute class.
Definition: attribute.h:46
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:58
The AddComponentDialog class.
Definition: addcomponentdialog.h:73
The AttributeUnitComboBox class.
Definition: attributeunitcombobox.h:46
The CmdSymbolInstanceEditAll class.
Definition: cmdsymbolinstanceeditall.h:51
The SchematicEditorState_AddComponent class.
Definition: schematiceditorstate_addcomponent.h:60
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:228
QPointer< QComboBox > mValueComboBox
Definition: schematiceditorstate_addcomponent.h:126
virtual ~SchematicEditorState_AddComponent() noexcept
Definition: schematiceditorstate_addcomponent.cpp:82
static QString toSingleLine(const QString &text) noexcept
Definition: schematiceditorstate_addcomponent.cpp:570
QPointer< QAction > mAttributeValueEditAction
Definition: schematiceditorstate_addcomponent.h:128
SchematicEditorState_AddComponent(const SchematicEditorState_AddComponent &other)=delete
void updateAttributeToolbar() noexcept
Definition: schematiceditorstate_addcomponent.cpp:543
Angle mLastAngle
Definition: schematiceditorstate_addcomponent.h:116
virtual bool processAbortCommand() noexcept override
Definition: schematiceditorstate_addcomponent.cpp:208
void valueChanged(QString text) noexcept
Definition: schematiceditorstate_addcomponent.cpp:498
ComponentInstance * mCurrentComponent
Definition: schematiceditorstate_addcomponent.h:120
std::shared_ptr< const Attribute > getToolbarAttribute() const noexcept
Definition: schematiceditorstate_addcomponent.cpp:486
QPointer< AttributeUnitComboBox > mAttributeUnitComboBox
Definition: schematiceditorstate_addcomponent.h:129
bool mUseAddComponentDialog
Definition: schematiceditorstate_addcomponent.h:114
bool mLastMirrored
Definition: schematiceditorstate_addcomponent.h:117
virtual bool processRotate(const Angle &rotation) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:183
QPointer< QAction > mAttributeUnitComboBoxAction
Definition: schematiceditorstate_addcomponent.h:130
void attributeChanged() noexcept
Definition: schematiceditorstate_addcomponent.cpp:505
void updateValueToolbar() noexcept
Definition: schematiceditorstate_addcomponent.cpp:531
bool abortCommand(bool showErrMsgBox) noexcept
Definition: schematiceditorstate_addcomponent.cpp:460
bool mIsUndoCmdActive
Definition: schematiceditorstate_addcomponent.h:113
virtual bool processAddComponent(const QString &searchTerm=QString()) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:147
virtual bool exit() noexcept override
Definition: schematiceditorstate_addcomponent.cpp:131
void startAddingComponent(const tl::optional< Uuid > &cmp=tl::nullopt, const tl::optional< Uuid > &symbVar=tl::nullopt, const tl::optional< librepcb::ComponentAssemblyOptionList > &options=tl::nullopt, const QString &searchTerm=QString(), bool keepValue=false)
Definition: schematiceditorstate_addcomponent.cpp:338
int mCurrentSymbVarItemIndex
Definition: schematiceditorstate_addcomponent.h:121
CmdSymbolInstanceEditAll * mCurrentSymbolEditCommand
Definition: schematiceditorstate_addcomponent.h:123
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:316
virtual bool processMirror(Qt::Orientation orientation) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:195
QScopedPointer< AddComponentDialog > mAddComponentDialog
Definition: schematiceditorstate_addcomponent.h:115
SI_Symbol * mCurrentSymbolToPlace
Definition: schematiceditorstate_addcomponent.h:122
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:241
virtual bool entry() noexcept override
Definition: schematiceditorstate_addcomponent.cpp:89
QPointer< QLineEdit > mAttributeValueEdit
Definition: schematiceditorstate_addcomponent.h:127
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:309
static QString toMultiLine(const QString &text) noexcept
Definition: schematiceditorstate_addcomponent.cpp:575
The schematic editor state base class.
Definition: schematiceditorstate.h:57
Definition: occmodel.cpp:77
Definition: uuid.h:183
FSM Context.
Definition: schematiceditorfsm.h:81