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  ******************************************************************************/
26 #include "schematiceditorstate.h"
27 
31 
32 #include <QtCore>
33 #include <QtWidgets>
34 
35 #include <memory>
36 #include <optional.hpp>
37 
38 /*******************************************************************************
39  * Namespace / Forward Declarations
40  ******************************************************************************/
41 namespace librepcb {
42 
43 class Attribute;
44 class ComponentInstance;
45 class SI_Symbol;
46 
47 namespace editor {
48 
49 class AddComponentDialog;
50 class AttributeUnitComboBox;
51 class CmdSymbolInstanceEditAll;
52 
53 /*******************************************************************************
54  * Class SchematicEditorState_AddComponent
55  ******************************************************************************/
56 
61  Q_OBJECT
62 
63 public:
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;
83  virtual bool processGraphicsSceneMouseMoved(
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 
96 private: // 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 
112 private: // Data
115  QScopedPointer<AddComponentDialog> mAddComponentDialog;
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;
129  QPointer<AttributeUnitComboBox> mAttributeUnitComboBox;
130  QPointer<QAction> mAttributeUnitComboBoxAction;
131 };
132 
133 /*******************************************************************************
134  * End of File
135  ******************************************************************************/
136 
137 } // namespace editor
138 } // namespace librepcb
139 
140 #endif
The SchematicEditorState_AddComponent class.
Definition: schematiceditorstate_addcomponent.h:60
The schematic editor state base class.
Definition: schematiceditorstate.h:57
bool mLastMirrored
Definition: schematiceditorstate_addcomponent.h:117
virtual bool processAddComponent(const QString &searchTerm=QString()) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:147
void updateValueToolbar() noexcept
Definition: schematiceditorstate_addcomponent.cpp:531
SI_Symbol * mCurrentSymbolToPlace
Definition: schematiceditorstate_addcomponent.h:122
Definition: occmodel.cpp:77
int mCurrentSymbVarItemIndex
Definition: schematiceditorstate_addcomponent.h:121
void valueChanged(QString text) noexcept
Definition: schematiceditorstate_addcomponent.cpp:498
QPointer< AttributeUnitComboBox > mAttributeUnitComboBox
Definition: schematiceditorstate_addcomponent.h:129
static QString toSingleLine(const QString &text) noexcept
Definition: schematiceditorstate_addcomponent.cpp:570
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool mIsUndoCmdActive
Definition: schematiceditorstate_addcomponent.h:113
QPointer< QAction > mAttributeValueEditAction
Definition: schematiceditorstate_addcomponent.h:128
virtual bool processMirror(Qt::Orientation orientation) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:195
virtual bool entry() noexcept override
Definition: schematiceditorstate_addcomponent.cpp:89
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:309
void attributeChanged() noexcept
Definition: schematiceditorstate_addcomponent.cpp:505
SchematicEditorState_AddComponent & operator=(const SchematicEditorState_AddComponent &rhs)=delete
QPointer< QLineEdit > mAttributeValueEdit
Definition: schematiceditorstate_addcomponent.h:127
Angle mLastAngle
Definition: schematiceditorstate_addcomponent.h:116
QPointer< QAction > mAttributeUnitComboBoxAction
Definition: schematiceditorstate_addcomponent.h:130
bool mUseAddComponentDialog
Definition: schematiceditorstate_addcomponent.h:114
FSM Context.
Definition: schematiceditorfsm.h:81
virtual bool processRotate(const Angle &rotation) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:183
QScopedPointer< AddComponentDialog > mAddComponentDialog
Definition: schematiceditorstate_addcomponent.h:115
std::shared_ptr< const Attribute > getToolbarAttribute() const noexcept
Definition: schematiceditorstate_addcomponent.cpp:486
virtual bool processGraphicsSceneRightMouseButtonReleased(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:316
static QString toMultiLine(const QString &text) noexcept
Definition: schematiceditorstate_addcomponent.cpp:575
The CmdSymbolInstanceEditAll class.
Definition: cmdsymbolinstanceeditall.h:51
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
The ComponentInstance class.
Definition: componentinstance.h:54
The SI_Symbol class.
Definition: si_symbol.h:54
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:241
virtual ~SchematicEditorState_AddComponent() noexcept
Definition: schematiceditorstate_addcomponent.cpp:82
virtual bool processAbortCommand() noexcept override
Definition: schematiceditorstate_addcomponent.cpp:208
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
bool abortCommand(bool showErrMsgBox) noexcept
Definition: schematiceditorstate_addcomponent.cpp:460
void updateAttributeToolbar() noexcept
Definition: schematiceditorstate_addcomponent.cpp:543
QPointer< QComboBox > mValueComboBox
Definition: schematiceditorstate_addcomponent.h:126
ComponentInstance * mCurrentComponent
Definition: schematiceditorstate_addcomponent.h:120
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: schematiceditorstate_addcomponent.cpp:228
CmdSymbolInstanceEditAll * mCurrentSymbolEditCommand
Definition: schematiceditorstate_addcomponent.h:123
virtual bool exit() noexcept override
Definition: schematiceditorstate_addcomponent.cpp:131