LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematictab.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_SCHEMATICTAB_H
21#define LIBREPCB_EDITOR_SCHEMATICTAB_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../dialogs/graphicsexportdialog.h"
27#include "../../utils/dismissablemessagecontext.h"
28#include "../../utils/lengtheditcontext.h"
29#include "../../utils/searchcontext.h"
30#include "../../widgets/if_graphicsvieweventhandler.h"
33#include "windowtab.h"
34
35#include <QtCore>
36
37/*******************************************************************************
38 * Namespace / Forward Declarations
39 ******************************************************************************/
40namespace librepcb {
41
42class AttributeUnit;
43class ErcMsgBase;
44
45namespace editor {
46
47class GraphicsLayer;
48class GraphicsLayerList;
49class ProjectEditor;
50class SchematicEditor;
51class SchematicEditorFsm;
52class SlintGraphicsView;
53
54/*******************************************************************************
55 * Class SchematicTab
56 ******************************************************************************/
57
61class SchematicTab final : public WindowTab,
64 Q_OBJECT
65
66public:
67 // Signals
69
70 // Constructors / Destructor
71 SchematicTab() = delete;
72 SchematicTab(const SchematicTab& other) = delete;
73 explicit SchematicTab(GuiApplication& app, SchematicEditor& editor,
74 QObject* parent = nullptr) noexcept;
75 ~SchematicTab() noexcept;
76
77 // General Methods
78 int getProjectIndex() const noexcept;
79 int getProjectObjectIndex() const noexcept;
80 ui::TabData getUiData() const noexcept override;
81 void setUiData(const ui::TabData& data) noexcept override;
82 ui::SchematicTabData getDerivedUiData() const noexcept;
83 void setDerivedUiData(const ui::SchematicTabData& data) noexcept;
84 void highlightErcMessage(const std::shared_ptr<const ErcMsgBase>& msg,
85 bool zoomTo) noexcept;
86 void activate() noexcept override;
87 void deactivate() noexcept override;
88 void trigger(ui::TabAction a) noexcept override;
89 slint::Image renderScene(float width, float height,
90 int scene) noexcept override;
92 const QPointF& pos, slint::private_api::PointerEvent e) noexcept override;
94 const QPointF& pos,
95 slint::private_api::PointerScrollEvent e) noexcept override;
97 const slint::private_api::KeyEvent& e) noexcept override;
98
99 // IF_GraphicsViewEventHandler
101 const GraphicsSceneKeyEvent& e) noexcept override;
103 const GraphicsSceneKeyEvent& e) noexcept override;
105 const GraphicsSceneMouseEvent& e) noexcept override;
107 const GraphicsSceneMouseEvent& e) noexcept override;
109 const GraphicsSceneMouseEvent& e) noexcept override;
111 const GraphicsSceneMouseEvent& e) noexcept override;
113 const GraphicsSceneMouseEvent& e) noexcept override;
114
115 // SchematicEditorFsmAdapter
116 QWidget* fsmGetParentWidget() noexcept override;
117 SchematicGraphicsScene* fsmGetGraphicsScene() noexcept override;
118 bool fsmGetIgnoreLocks() const noexcept override;
119 void fsmSetViewCursor(
120 const std::optional<Qt::CursorShape>& shape) noexcept override;
121 void fsmSetViewGrayOut(bool grayOut) noexcept override;
122 void fsmSetViewInfoBoxText(const QString& text) noexcept override;
123 void fsmSetViewRuler(
124 const std::optional<std::pair<Point, Point>>& pos) noexcept override;
125 void fsmSetSceneCursor(const Point& pos, bool cross,
126 bool circle) noexcept override;
127 QPainterPath fsmCalcPosWithTolerance(
128 const Point& pos, qreal multiplier) const noexcept override;
129 Point fsmMapGlobalPosToScenePos(const QPoint& pos) const noexcept override;
130 void fsmZoomToSceneRect(const QRectF& r) noexcept override;
132 const QSet<const NetSignal*>& sigs) noexcept override;
133 void fsmAbortBlockingToolsInOtherEditors() noexcept override;
134 void fsmSetStatusBarMessage(const QString& message,
135 int timeoutMs = -1) noexcept override;
136 void fsmSetFeatures(Features features) noexcept override;
137 void fsmToolLeave() noexcept override;
138 void fsmToolEnter(SchematicEditorState_Select& state) noexcept override;
139 void fsmToolEnter(SchematicEditorState_DrawWire& state) noexcept override;
140 void fsmToolEnter(SchematicEditorState_DrawBus& state) noexcept override;
141 void fsmToolEnter(SchematicEditorState_AddLabel& state) noexcept override;
142 void fsmToolEnter(SchematicEditorState_AddComponent& state) noexcept override;
143 void fsmToolEnter(SchematicEditorState_DrawPolygon& state) noexcept override;
144 void fsmToolEnter(SchematicEditorState_AddText& state) noexcept override;
145 void fsmToolEnter(SchematicEditorState_AddImage& state) noexcept override;
146 void fsmToolEnter(SchematicEditorState_Measure& state) noexcept override;
147
148 // Operator Overloadings
149 SchematicTab& operator=(const SchematicTab& rhs) = delete;
150
151signals:
153 void layerRequested(const Layer& layer);
154 void filledRequested(bool filled);
155 void valueRequested(const QString& value);
156 void attributeValueRequested(const QString& value);
158
159private:
160 void updateMessages() noexcept;
161 void clearErcMarker() noexcept;
163 const QString& settingsKey) noexcept;
164 void goToSymbol(const QString& name, int index) noexcept;
165 void applyTheme() noexcept;
166 void requestRepaint() noexcept;
167
168private:
169 // References
177
178 // Message handles
181
182 // State
184 Theme::GridStyle mGridStyle;
188
189 // Current tool
191 ui::EditorTool mTool;
192 Qt::CursorShape mToolCursorShape;
195 QVector<const Layer*> mToolLayersQt;
196 std::shared_ptr<slint::VectorModel<slint::SharedString>> mToolLayers;
201 QString mToolValue;
202 std::shared_ptr<slint::VectorModel<slint::SharedString>>
204 std::optional<QString> mToolAttributeValue;
207 std::shared_ptr<slint::VectorModel<slint::SharedString>> mToolAttributeUnits;
209
210 // FSM
211 QVector<QMetaObject::Connection> mFsmStateConnections;
212 QScopedPointer<SchematicEditorFsm> mFsm;
213 std::unique_ptr<QGraphicsPathItem> mErcLocationGraphicsItem;
214
215 // Objects in active state
217};
218
219/*******************************************************************************
220 * End of File
221 ******************************************************************************/
222
223} // namespace editor
224} // namespace librepcb
225
226#endif
The AttributeUnit class.
Definition attributeunit.h:40
Base class for all ERC messages.
Definition electricalrulecheckmessages.h:62
The Image class.
Definition image.h:49
The Layer class provides all supported geometry layers.
Definition layer.h:42
The NetSignal class.
Definition netsignal.h:50
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Project class represents a whole (opened) project with all its content.
Definition project.h:71
The Schematic class represents one schematic page of a project and is always part of a circuit.
Definition schematic.h:81
The Signal class is used to emit signals on non-QObject derived classes.
Definition signalslot.h:65
Theme class as used by librepcb::WorkspaceSettingsItem_Themes.
Definition theme.h:44
A handle to a optionally dismissable message in the UI.
Definition dismissablemessagecontext.h:53
This class provides a Dialog (GUI) to choose DXF import settings.
Definition graphicsexportdialog.h:61
The GraphicsLayer class represents a graphical layer used in schematics and boards.
Definition graphicslayer.h:53
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The GuiApplication class.
Definition guiapplication.h:75
The IF_GraphicsViewEventHandler class.
Definition if_graphicsvieweventhandler.h:45
Backend configuration for the LengthEdit UI element.
Definition lengtheditcontext.h:49
The ProjectEditor class.
Definition projecteditor.h:64
Interface for the integration of the schematic editor FSM.
Definition schematiceditorfsmadapter.h:62
The schematic editor finite state machine (FSM)
Definition schematiceditorfsm.h:60
The SchematicEditor class.
Definition schematiceditor.h:50
The SchematicEditorState_AddComponent class.
Definition schematiceditorstate_addcomponent.h:58
The SchematicEditorState_AddImage class.
Definition schematiceditorstate_addimage.h:52
The SchematicEditorState_AddLabel class.
Definition schematiceditorstate_addlabel.h:52
The SchematicEditorState_AddText class.
Definition schematiceditorstate_addtext.h:56
The SchematicEditorState_DrawBus class.
Definition schematiceditorstate_drawbus.h:56
The SchematicEditorState_DrawPolygon class.
Definition schematiceditorstate_drawpolygon.h:56
The SchematicEditorState_DrawWire class.
Definition schematiceditorstate_drawwire.h:55
The "measure" state/tool of the schematic editor.
Definition schematiceditorstate_measure.h:45
The "select" state/tool of the schematic editor (default state)
Definition schematiceditorstate_select.h:63
The SchematicGraphicsScene class.
Definition schematicgraphicsscene.h:76
The SchematicTab class.
Definition schematictab.h:63
slint::Image renderScene(float width, float height, int scene) noexcept override
Definition schematictab.cpp:714
bool graphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematictab.cpp:752
bool mIgnorePlacementLocks
Definition schematictab.h:186
Features mToolFeatures
Definition schematictab.h:190
QPointF mSceneImagePos
Definition schematictab.h:185
std::unique_ptr< SlintGraphicsView > mView
Definition schematictab.h:176
void fsmSetSceneCursor(const Point &pos, bool cross, bool circle) noexcept override
Definition schematictab.cpp:830
std::shared_ptr< slint::VectorModel< slint::SharedString > > mToolAttributeUnits
Definition schematictab.h:207
void applyTheme() noexcept
Definition schematictab.cpp:1257
SchematicTab(const SchematicTab &other)=delete
Schematic & mSchematic
Definition schematictab.h:173
bool graphicsSceneRightMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematictab.cpp:773
DismissableMessageContext mMsgAddDrawingFrame
Definition schematictab.h:180
void layerRequested(const Layer &layer)
void highlightErcMessage(const std::shared_ptr< const ErcMsgBase > &msg, bool zoomTo) noexcept
Definition schematictab.cpp:405
QString mToolValue
Definition schematictab.h:201
int mFrameIndex
Definition schematictab.h:187
bool graphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematictab.cpp:768
std::unique_ptr< GraphicsLayerList > mLayers
Definition schematictab.h:174
QString mToolAttributeValuePlaceholder
Definition schematictab.h:205
Signal< SchematicTab > onDerivedUiDataChanged
Definition schematictab.h:68
bool graphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematictab.cpp:758
void fsmZoomToSceneRect(const QRectF &r) noexcept override
Definition schematictab.cpp:853
QWidget * fsmGetParentWidget() noexcept override
Definition schematictab.cpp:782
QList< const AttributeUnit * > mToolAttributeUnitsQt
Definition schematictab.h:206
bool fsmGetIgnoreLocks() const noexcept override
Definition schematictab.cpp:790
SchematicGraphicsScene * fsmGetGraphicsScene() noexcept override
Definition schematictab.cpp:786
Theme::GridStyle mGridStyle
Definition schematictab.h:184
void fsmToolEnter(SchematicEditorState_Select &state) noexcept override
Definition schematictab.cpp:887
std::shared_ptr< slint::VectorModel< slint::SharedString > > mToolValueSuggestions
Definition schematictab.h:203
std::shared_ptr< slint::VectorModel< slint::SharedString > > mToolLayers
Definition schematictab.h:196
LengthEditContext mToolSize
Definition schematictab.h:199
std::optional< QString > mToolAttributeValue
Definition schematictab.h:204
void fsmSetViewCursor(const std::optional< Qt::CursorShape > &shape) noexcept override
Definition schematictab.cpp:794
bool processSceneScrolled(const QPointF &pos, slint::private_api::PointerScrollEvent e) noexcept override
Definition schematictab.cpp:728
void fsmToolLeave() noexcept override
Definition schematictab.cpp:878
ProjectEditor & mProjectEditor
Definition schematictab.h:170
void fsmAbortBlockingToolsInOtherEditors() noexcept override
Definition schematictab.cpp:862
void valueRequested(const QString &value)
void requestRepaint() noexcept
Definition schematictab.cpp:1276
bool processScenePointerEvent(const QPointF &pos, slint::private_api::PointerEvent e) noexcept override
Definition schematictab.cpp:723
bool graphicsSceneKeyPressed(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematictab.cpp:742
SchematicEditorState_DrawWire::WireMode mToolWireMode
Definition schematictab.h:194
QPainterPath fsmCalcPosWithTolerance(const Point &pos, qreal multiplier) const noexcept override
Definition schematictab.cpp:837
void attributeUnitRequested(const AttributeUnit *unit)
std::shared_ptr< GraphicsLayer > mPinNumbersLayer
Definition schematictab.h:175
SearchContext mSearchContext
Definition schematictab.h:183
void setUiData(const ui::TabData &data) noexcept override
Definition schematictab.cpp:280
QVector< QMetaObject::Connection > mFsmStateConnections
Definition schematictab.h:211
bool processSceneKeyEvent(const slint::private_api::KeyEvent &e) noexcept override
Definition schematictab.cpp:733
ui::SchematicTabData getDerivedUiData() const noexcept
Definition schematictab.cpp:286
void fsmSetViewGrayOut(bool grayOut) noexcept override
Definition schematictab.cpp:804
void wireModeRequested(SchematicEditorState_DrawWire::WireMode mode)
void fsmSetViewRuler(const std::optional< std::pair< Point, Point > > &pos) noexcept override
Definition schematictab.cpp:823
const AttributeUnit * mToolAttributeUnit
Definition schematictab.h:208
SchematicEditor & mSchematicEditor
Definition schematictab.h:172
void fsmSetViewInfoBoxText(const QString &text) noexcept override
Definition schematictab.cpp:810
Project & mProject
Definition schematictab.h:171
void clearErcMarker() noexcept
Definition schematictab.cpp:1164
const Layer * mToolLayer
Definition schematictab.h:197
int getProjectObjectIndex() const noexcept
Definition schematictab.cpp:242
void goToSymbol(const QString &name, int index) noexcept
Definition schematictab.cpp:1218
Qt::CursorShape mToolCursorShape
Definition schematictab.h:192
void fsmSetStatusBarMessage(const QString &message, int timeoutMs=-1) noexcept override
Definition schematictab.cpp:866
Point fsmMapGlobalPosToScenePos(const QPoint &pos) const noexcept override
Definition schematictab.cpp:842
std::unique_ptr< SchematicGraphicsScene > mScene
Definition schematictab.h:216
QScopedPointer< SchematicEditorFsm > mFsm
Definition schematictab.h:212
void trigger(ui::TabAction a) noexcept override
Definition schematictab.cpp:460
void deactivate() noexcept override
Definition schematictab.cpp:453
void setDerivedUiData(const ui::SchematicTabData &data) noexcept
Definition schematictab.cpp:349
void attributeValueRequested(const QString &value)
std::unique_ptr< QGraphicsPathItem > mErcLocationGraphicsItem
Definition schematictab.h:213
void updateMessages() noexcept
Definition schematictab.cpp:1152
DismissableMessageContext mMsgInstallLibraries
Definition schematictab.h:179
void fsmSetHighlightedNetSignals(const QSet< const NetSignal * > &sigs) noexcept override
Definition schematictab.cpp:857
QString mToolOverlayText
Definition schematictab.h:193
ui::TabData getUiData() const noexcept override
Definition schematictab.cpp:246
bool graphicsSceneKeyReleased(const GraphicsSceneKeyEvent &e) noexcept override
Definition schematictab.cpp:747
void execGraphicsExportDialog(GraphicsExportDialog::Output output, const QString &settingsKey) noexcept
Definition schematictab.cpp:1171
bool mToolFilled
Definition schematictab.h:200
void filledRequested(bool filled)
ui::EditorTool mTool
Definition schematictab.h:191
void fsmSetFeatures(Features features) noexcept override
Definition schematictab.cpp:871
LengthEditContext mToolLineWidth
Definition schematictab.h:198
int getProjectIndex() const noexcept
Definition schematictab.cpp:238
bool graphicsSceneLeftMouseButtonReleased(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematictab.cpp:763
QVector< const Layer * > mToolLayersQt
Definition schematictab.h:195
void activate() noexcept override
Definition schematictab.cpp:435
The SearchContext class.
Definition searchcontext.h:43
The SlintGraphicsView class.
Definition slintgraphicsview.h:52
The WindowTab class.
Definition windowtab.h:52
Definition occmodel.cpp:77
Definition uuid.h:186
Definition graphicsscene.h:52
Definition graphicsscene.h:45