LibrePCB Developers Documentation
packageeditorwidget.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_PACKAGEEDITORWIDGET_H
21#define LIBREPCB_EDITOR_PACKAGEEDITORWIDGET_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../widgets/if_graphicsvieweventhandler.h"
27#include "../cat/categorylisteditorwidget.h"
28#include "../editorwidgetbase.h"
29
33
34#include <QtCore>
35#include <QtWidgets>
36
37#include <memory>
38
39/*******************************************************************************
40 * Namespace / Forward Declarations
41 ******************************************************************************/
42namespace librepcb {
43
44class Package;
45class PackageModel;
46
47namespace editor {
48
49class GraphicsScene;
50class OpenGlSceneBuilder;
51class OpenGlView;
52class PackageEditorFsm;
53
54namespace Ui {
55class PackageEditorWidget;
56}
57
58/*******************************************************************************
59 * Class PackageEditorWidget
60 ******************************************************************************/
61
67 Q_OBJECT
68
69public:
70 // Constructors / Destructor
73 PackageEditorWidget(const Context& context, const FilePath& fp,
74 QWidget* parent = nullptr);
75 ~PackageEditorWidget() noexcept;
76
77 // Getters
78 QSet<Feature> getAvailableFeatures() const noexcept override;
79
80 // Setters
81 void connectEditor(UndoStackActionGroup& undoStackActionGroup,
82 ExclusiveActionGroup& toolsActionGroup,
83 QToolBar& commandToolBar,
84 StatusBar& statusBar) noexcept override;
85 void disconnectEditor() noexcept override;
86
87 // Operator Overloadings
88 PackageEditorWidget& operator=(const PackageEditorWidget& rhs) = delete;
89
90public slots:
91 bool save() noexcept override;
92 bool selectAll() noexcept override;
93 bool cut() noexcept override;
94 bool copy() noexcept override;
95 bool paste() noexcept override;
96 bool move(Qt::ArrowType direction) noexcept override;
97 bool rotate(const librepcb::Angle& rotation) noexcept override;
98 bool mirror(Qt::Orientation orientation) noexcept override;
99 bool flip(Qt::Orientation orientation) noexcept override;
100 bool snapToGrid() noexcept override;
101 bool remove() noexcept override;
102 bool editProperties() noexcept override;
103 bool zoomIn() noexcept override;
104 bool zoomOut() noexcept override;
105 bool zoomAll() noexcept override;
106 bool toggle3D() noexcept override;
107 bool abortCommand() noexcept override;
108 bool processGenerateOutline() noexcept override;
109 bool processGenerateCourtyard() noexcept override;
110 bool importDxf() noexcept override;
111 bool editGridProperties() noexcept override;
112 bool increaseGridInterval() noexcept override;
113 bool decreaseGridInterval() noexcept override;
114
115private: // Methods
116 void updateMetadata() noexcept;
117 QString commitMetadata() noexcept;
119 bool graphicsViewEventHandler(QEvent* event) noexcept override;
120 bool toolChangeRequested(Tool newTool,
121 const QVariant& mode) noexcept override;
122 void currentFootprintChanged(int index) noexcept;
123 void currentModelChanged(int index) noexcept;
124 void scheduleOpenGlSceneUpdate() noexcept;
125 void updateOpenGlScene() noexcept;
126 void memorizePackageInterface() noexcept;
127 bool isInterfaceBroken() const noexcept override;
128 bool runChecks(RuleCheckMessageList& msgs) const override;
129 template <typename MessageType>
130 void fixMsg(const MessageType& msg);
131 template <typename MessageType>
132 void fixPadFunction(const MessageType& msg);
133 template <typename MessageType>
134 bool fixMsgHelper(std::shared_ptr<const RuleCheckMessage> msg, bool applyFix);
135 bool processRuleCheckMessage(std::shared_ptr<const RuleCheckMessage> msg,
136 bool applyFix) override;
137 void ruleCheckApproveRequested(std::shared_ptr<const RuleCheckMessage> msg,
138 bool approve) noexcept override;
140 const QString& settingsKey) noexcept override;
141 void setGridProperties(const PositiveLength& interval, const LengthUnit& unit,
142 Theme::GridStyle style) noexcept;
143 void toggle3DMode(bool enable) noexcept;
144 bool is3DModeEnabled() const noexcept;
145
146private: // Data
147 QScopedPointer<Ui::PackageEditorWidget> mUi;
148 QScopedPointer<OpenGlView> mOpenGlView;
154 std::unique_ptr<Package> mPackage;
155 std::shared_ptr<Footprint> mCurrentFootprint;
156 std::shared_ptr<PackageModel> mCurrentModel;
157
158 // broken interface detection
161
163 QScopedPointer<PackageEditorFsm> mFsm;
164};
165
166/*******************************************************************************
167 * End of File
168 ******************************************************************************/
169
170} // namespace editor
171} // namespace librepcb
172
173#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:55
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition: lengthunit.h:60
The Package class represents a package of a component (including footprint and 3D model)
Definition: package.h:59
Represents a 3D model of a librepcb::Package.
Definition: packagemodel.h:43
The RuleCheckMessage class.
Definition: rulecheckmessage.h:45
Theme class as used by librepcb::WorkspaceSettingsItem_Themes.
Definition: theme.h:44
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The CategoryListEditorWidget class.
Definition: categorylisteditorwidget.h:54
The EditorWidgetBase class.
Definition: editorwidgetbase.h:62
Tool
Definition: editorwidgetbase.h:76
Feature
Definition: editorwidgetbase.h:95
The ExclusiveActionGroup class groups multiple QAction's together.
Definition: exclusiveactiongroup.h:54
This class provides a Dialog (GUI) to choose DXF import settings.
Definition: graphicsexportdialog.h:61
The GraphicsScene class.
Definition: graphicsscene.h:45
The IF_GraphicsViewEventHandler class.
Definition: if_graphicsvieweventhandler.h:41
Asynchronously generates a 3D board scene for OpenGL rendering.
Definition: openglscenebuilder.h:49
OpenGL 3D viewer widget.
Definition: openglview.h:52
The PackageEditorFsm class is the finit state machine (FSM) of the package editor.
Definition: packageeditorfsm.h:60
The PackageEditorWidget class.
Definition: packageeditorwidget.h:66
void memorizePackageInterface() noexcept
Definition: packageeditorwidget.cpp:700
bool graphicsViewEventHandler(QEvent *event) noexcept override
Definition: packageeditorwidget.cpp:515
bool processGenerateCourtyard() noexcept override
Definition: packageeditorwidget.cpp:429
bool copy() noexcept override
Definition: packageeditorwidget.cpp:353
bool mirror(Qt::Orientation orientation) noexcept override
Definition: packageeditorwidget.cpp:369
bool save() noexcept override
Definition: packageeditorwidget.cpp:321
bool execGraphicsExportDialog(GraphicsExportDialog::Output output, const QString &settingsKey) noexcept override
Definition: packageeditorwidget.cpp:1017
bool toggle3D() noexcept override
Definition: packageeditorwidget.cpp:416
void setGridProperties(const PositiveLength &interval, const LengthUnit &unit, Theme::GridStyle style) noexcept
Definition: packageeditorwidget.cpp:1058
void updateMetadata() noexcept
Definition: packageeditorwidget.cpp:466
bool processGenerateOutline() noexcept override
Definition: packageeditorwidget.cpp:425
bool increaseGridInterval() noexcept override
Definition: packageeditorwidget.cpp:446
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: packageeditorwidget.h:150
bool flip(Qt::Orientation orientation) noexcept override
Definition: packageeditorwidget.cpp:373
bool abortCommand() noexcept override
Definition: packageeditorwidget.cpp:421
bool editGridProperties() noexcept override
Definition: packageeditorwidget.cpp:437
LengthUnit mLengthUnit
Definition: packageeditorwidget.h:153
QScopedPointer< OpenGlSceneBuilder > mOpenGlSceneBuilder
Definition: packageeditorwidget.h:151
void currentFootprintChanged(int index) noexcept
Definition: packageeditorwidget.cpp:612
void ruleCheckApproveRequested(std::shared_ptr< const RuleCheckMessage > msg, bool approve) noexcept override
Definition: packageeditorwidget.cpp:1011
PackageEditorWidget(const PackageEditorWidget &other)=delete
QScopedPointer< PackageEditorFsm > mFsm
Editor state machine.
Definition: packageeditorwidget.h:163
std::shared_ptr< PackageModel > mCurrentModel
Definition: packageeditorwidget.h:156
bool snapToGrid() noexcept override
Definition: packageeditorwidget.cpp:377
bool is3DModeEnabled() const noexcept
Definition: packageeditorwidget.cpp:1100
void updateOpenGlScene() noexcept
Definition: packageeditorwidget.cpp:628
QScopedPointer< CategoryListEditorWidget > mCategoriesEditorWidget
Definition: packageeditorwidget.h:149
bool paste() noexcept override
Definition: packageeditorwidget.cpp:357
void connectEditor(UndoStackActionGroup &undoStackActionGroup, ExclusiveActionGroup &toolsActionGroup, QToolBar &commandToolBar, StatusBar &statusBar) noexcept override
Definition: packageeditorwidget.cpp:274
bool cut() noexcept override
Definition: packageeditorwidget.cpp:349
bool importDxf() noexcept override
Definition: packageeditorwidget.cpp:433
FootprintList mOriginalFootprints
Definition: packageeditorwidget.h:160
void scheduleOpenGlSceneUpdate() noexcept
Definition: packageeditorwidget.cpp:624
bool decreaseGridInterval() noexcept override
Definition: packageeditorwidget.cpp:453
bool rotate(const librepcb::Angle &rotation) noexcept override
Definition: packageeditorwidget.cpp:365
bool selectAll() noexcept override
Definition: packageeditorwidget.cpp:345
bool zoomAll() noexcept override
Definition: packageeditorwidget.cpp:407
QSet< Uuid > mOriginalPadUuids
Definition: packageeditorwidget.h:159
~PackageEditorWidget() noexcept
Definition: packageeditorwidget.cpp:237
bool move(Qt::ArrowType direction) noexcept override
Definition: packageeditorwidget.cpp:361
void fixMsg(const MessageType &msg)
bool editProperties() noexcept override
Definition: packageeditorwidget.cpp:385
bool mOpenGlSceneBuildScheduled
Definition: packageeditorwidget.h:152
QString commitMetadata() noexcept
Definition: packageeditorwidget.cpp:481
void toggle3DMode(bool enable) noexcept
Definition: packageeditorwidget.cpp:1072
bool fixMsgHelper(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix)
Definition: packageeditorwidget.cpp:972
std::unique_ptr< Package > mPackage
Definition: packageeditorwidget.h:154
bool toolChangeRequested(Tool newTool, const QVariant &mode) noexcept override
Definition: packageeditorwidget.cpp:571
QScopedPointer< Ui::PackageEditorWidget > mUi
Definition: packageeditorwidget.h:147
void disconnectEditor() noexcept override
Definition: packageeditorwidget.cpp:306
bool isInterfaceBroken() const noexcept override
Definition: packageeditorwidget.cpp:705
QSet< Feature > getAvailableFeatures() const noexcept override
Definition: packageeditorwidget.cpp:257
bool zoomIn() noexcept override
Definition: packageeditorwidget.cpp:389
bool zoomOut() noexcept override
Definition: packageeditorwidget.cpp:398
std::shared_ptr< Footprint > mCurrentFootprint
Definition: packageeditorwidget.h:155
bool runChecks(RuleCheckMessageList &msgs) const override
Definition: packageeditorwidget.cpp:717
void currentModelChanged(int index) noexcept
Definition: packageeditorwidget.cpp:619
void fixPadFunction(const MessageType &msg)
Definition: packageeditorwidget.cpp:922
bool remove() noexcept override
Definition: packageeditorwidget.cpp:381
bool processRuleCheckMessage(std::shared_ptr< const RuleCheckMessage > msg, bool applyFix) override
Definition: packageeditorwidget.cpp:983
QScopedPointer< OpenGlView > mOpenGlView
Definition: packageeditorwidget.h:148
The StatusBar class extends QStatusBar for some commonly used fields.
Definition: statusbar.h:45
The UndoStackActionGroup class groups an undo-QAction and redo-QAction together and optionally connec...
Definition: undostackactiongroup.h:45
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
QVector< std::shared_ptr< const RuleCheckMessage > > RuleCheckMessageList
Definition: rulecheckmessage.h:104
Definition: editorwidgetbase.h:68