LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
packageeditorstate_drawpolygonbase.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_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWPOLYGONBASE_H
21 #define LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWPOLYGONBASE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "packageeditorstate.h"
27 
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 #include <memory>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 
40 class Polygon;
41 class PolygonGraphicsItem;
42 class CmdPolygonEdit;
43 
44 namespace library {
45 namespace editor {
46 
47 /*******************************************************************************
48  * Class PackageEditorState_DrawPolygonBase
49  ******************************************************************************/
50 
55  Q_OBJECT
56 
57 public:
58  // Types
59  enum class Mode { LINE, RECT, POLYGON };
60 
61  // Constructors / Destructor
64  const PackageEditorState_DrawPolygonBase& other) = delete;
65  PackageEditorState_DrawPolygonBase(Context& context, Mode mode) noexcept;
66  virtual ~PackageEditorState_DrawPolygonBase() noexcept;
67 
68  // General Methods
69  bool entry() noexcept override;
70  bool exit() noexcept override;
71 
72  // Event Handlers
74  QGraphicsSceneMouseEvent& e) noexcept override;
76  QGraphicsSceneMouseEvent& e) noexcept override;
78  QGraphicsSceneMouseEvent& e) noexcept override;
79  bool processAbortCommand() noexcept override;
80 
81  // Operator Overloadings
83  const PackageEditorState_DrawPolygonBase& rhs) = delete;
84 
85 private: // Methods
86  bool start(const Point& pos) noexcept;
87  bool abort() noexcept;
88  bool addNextSegment(const Point& pos) noexcept;
89  bool updateCurrentPosition(const Point& pos) noexcept;
90 
91  void layerComboBoxValueChanged(const QString& layerName) noexcept;
92  void lineWidthSpinBoxValueChanged(double value) noexcept;
93  void angleSpinBoxValueChanged(double value) noexcept;
94  void fillCheckBoxCheckedChanged(bool checked) noexcept;
95  void grabAreaCheckBoxCheckedChanged(bool checked) noexcept;
96 
97 private: // Types / Data
99  QScopedPointer<CmdPolygonEdit> mEditCmd;
100  std::shared_ptr<Polygon> mCurrentPolygon;
103 
104  // parameter memory
108  bool mLastFill;
110 };
111 
112 /*******************************************************************************
113  * End of File
114  ******************************************************************************/
115 
116 } // namespace editor
117 } // namespace library
118 } // namespace librepcb
119 
120 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWPOLYGONBASE_H
bool mLastGrabArea
Definition: packageeditorstate_drawpolygonbase.h:109
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:46
void lineWidthSpinBoxValueChanged(double value) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:303
bool start(const Point &pos) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:204
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
bool abort() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:235
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:186
bool updateCurrentPosition(const Point &pos) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:272
The CmdPolygonEdit class.
Definition: cmdpolygonedit.h:43
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool processAbortCommand() noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:192
void layerComboBoxValueChanged(const QString &layerName) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:292
void angleSpinBoxValueChanged(double value) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:311
PolygonGraphicsItem * mCurrentGraphicsItem
Definition: packageeditorstate_drawpolygonbase.h:102
bool exit() noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:139
Mode
Definition: packageeditorstate_drawpolygonbase.h:59
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool addNextSegment(const Point &pos) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:249
std::shared_ptr< Polygon > mCurrentPolygon
Definition: packageeditorstate_drawpolygonbase.h:100
virtual ~PackageEditorState_DrawPolygonBase() noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:64
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:167
bool mLastFill
Definition: packageeditorstate_drawpolygonbase.h:108
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:49
Point mSegmentStartPos
Definition: packageeditorstate_drawpolygonbase.h:101
bool entry() noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:74
UnsignedLength mLastLineWidth
Definition: packageeditorstate_drawpolygonbase.h:106
GraphicsLayerName mLastLayerName
Definition: packageeditorstate_drawpolygonbase.h:105
Angle mLastAngle
Definition: packageeditorstate_drawpolygonbase.h:107
void grabAreaCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:331
QScopedPointer< CmdPolygonEdit > mEditCmd
Definition: packageeditorstate_drawpolygonbase.h:99
void fillCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:323
The Polygon class.
Definition: polygon.h:49
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:155
The PackageEditorState_DrawPolygonBase class.
Definition: packageeditorstate_drawpolygonbase.h:54
PackageEditorFsm::Context Context
Definition: packageeditorstate.h:53
Mode mMode
Definition: packageeditorstate_drawpolygonbase.h:98
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659