LibrePCB Developers Documentation
Loading...
Searching...
No Matches
schematiceditorstate_drawpolygon.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_DRAWPOLYGON_H
21#define LIBREPCB_EDITOR_SCHEMATICEDITORSTATE_DRAWPOLYGON_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
29
30#include <QtCore>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Layer;
40class SI_Polygon;
41class Schematic;
42
43namespace editor {
44
45class CmdPolygonEdit;
46class LayerComboBox;
47class UnsignedLengthEdit;
48
49/*******************************************************************************
50 * Class SchematicEditorState_DrawPolygon
51 ******************************************************************************/
52
57 Q_OBJECT
58
59public:
60 // Constructors / Destructor
63 const SchematicEditorState_DrawPolygon& other) = delete;
64 explicit SchematicEditorState_DrawPolygon(const Context& context) noexcept;
65 virtual ~SchematicEditorState_DrawPolygon() noexcept;
66
67 // General Methods
68 virtual bool entry() noexcept override;
69 virtual bool exit() noexcept override;
70
71 // Event Handlers
72 virtual bool processAbortCommand() noexcept override;
74 const GraphicsSceneMouseEvent& e) noexcept override;
76 const GraphicsSceneMouseEvent& e) noexcept override;
78 const GraphicsSceneMouseEvent& e) noexcept override;
79
80 // Connection to UI
81 QSet<const Layer*> getAvailableLayers() const noexcept;
82 const Layer& getLayer() const noexcept {
84 }
85 void setLayer(const Layer& layer) noexcept;
86 const UnsignedLength& getLineWidth() const noexcept {
88 }
89 void setLineWidth(const UnsignedLength& width) noexcept;
90 bool getFilled() const noexcept { return mCurrentProperties.isFilled(); }
91 void setFilled(bool filled) noexcept;
92
93 // Operator Overloadings
95 const SchematicEditorState_DrawPolygon& rhs) = delete;
96
97signals:
98 void layerChanged(const Layer& layer);
99 void lineWidthChanged(const UnsignedLength& width);
100 void filledChanged(bool filled);
101
102private: // Methods
103 bool startAddPolygon(const Point& pos) noexcept;
104 bool addSegment(const Point& pos) noexcept;
105 bool updateLastVertexPosition(const Point& pos) noexcept;
106 bool abortCommand(bool showErrMsgBox) noexcept;
107
108private: // Data
109 // State
112
113 // Current tool settings
115
116 // Information about the current polygon to place. Only valid if
117 // mIsUndoCmdActive == true.
119 std::unique_ptr<CmdPolygonEdit> mCurrentPolygonEditCmd;
120};
121
122/*******************************************************************************
123 * End of File
124 ******************************************************************************/
125
126} // namespace editor
127} // namespace librepcb
128
129#endif
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Polygon class.
Definition polygon.h:45
bool isFilled() const noexcept
Definition polygon.h:74
const Layer & getLayer() const noexcept
Definition polygon.h:72
const UnsignedLength & getLineWidth() const noexcept
Definition polygon.h:73
The SI_Polygon class represents a polygon in a schematic.
Definition si_polygon.h:47
The SchematicEditorState_DrawPolygon class.
Definition schematiceditorstate_drawpolygon.h:56
virtual bool processGraphicsSceneMouseMoved(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawpolygon.cpp:101
std::unique_ptr< CmdPolygonEdit > mCurrentPolygonEditCmd
Definition schematiceditorstate_drawpolygon.h:119
virtual ~SchematicEditorState_DrawPolygon() noexcept
Definition schematiceditorstate_drawpolygon.cpp:63
bool startAddPolygon(const Point &pos) noexcept
Definition schematiceditorstate_drawpolygon.cpp:171
SchematicEditorState_DrawPolygon(const SchematicEditorState_DrawPolygon &other)=delete
void setLayer(const Layer &layer) noexcept
Definition schematiceditorstate_drawpolygon.cpp:134
virtual bool processGraphicsSceneLeftMouseButtonPressed(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawpolygon.cpp:108
virtual bool processAbortCommand() noexcept override
Definition schematiceditorstate_drawpolygon.cpp:91
const Layer & getLayer() const noexcept
Definition schematiceditorstate_drawpolygon.h:82
QSet< const Layer * > getAvailableLayers() const noexcept
Definition schematiceditorstate_drawpolygon.cpp:129
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(const GraphicsSceneMouseEvent &e) noexcept override
Definition schematiceditorstate_drawpolygon.cpp:120
bool abortCommand(bool showErrMsgBox) noexcept
Definition schematiceditorstate_drawpolygon.cpp:256
const UnsignedLength & getLineWidth() const noexcept
Definition schematiceditorstate_drawpolygon.h:86
bool mIsUndoCmdActive
Definition schematiceditorstate_drawpolygon.h:110
Polygon mCurrentProperties
Definition schematiceditorstate_drawpolygon.h:114
void setFilled(bool filled) noexcept
Definition schematiceditorstate_drawpolygon.cpp:156
virtual bool exit() noexcept override
Definition schematiceditorstate_drawpolygon.cpp:78
bool addSegment(const Point &pos) noexcept
Definition schematiceditorstate_drawpolygon.cpp:202
SchematicEditorState_DrawPolygon & operator=(const SchematicEditorState_DrawPolygon &rhs)=delete
void setLineWidth(const UnsignedLength &width) noexcept
Definition schematiceditorstate_drawpolygon.cpp:144
bool getFilled() const noexcept
Definition schematiceditorstate_drawpolygon.h:90
SI_Polygon * mCurrentPolygon
Definition schematiceditorstate_drawpolygon.h:118
bool updateLastVertexPosition(const Point &pos) noexcept
Definition schematiceditorstate_drawpolygon.cpp:244
void lineWidthChanged(const UnsignedLength &width)
Point mLastSegmentPos
Definition schematiceditorstate_drawpolygon.h:111
virtual bool entry() noexcept override
Definition schematiceditorstate_drawpolygon.cpp:70
The schematic editor state base class.
Definition schematiceditorstate.h:58
Definition occmodel.cpp:77
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition length.h:694
Definition graphicsscene.h:45
FSM Context.
Definition schematiceditorfsm.h:62