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 
58  Q_OBJECT
59 
60 public:
61  // Types
62  enum class Mode { LINE, RECT, POLYGON };
63 
64  // Constructors / Destructor
67  const PackageEditorState_DrawPolygonBase& other) = delete;
68  PackageEditorState_DrawPolygonBase(Context& context, Mode mode) noexcept;
69  virtual ~PackageEditorState_DrawPolygonBase() noexcept;
70 
71  // General Methods
72  bool entry() noexcept override;
73  bool exit() noexcept override;
74 
75  // Event Handlers
77  QGraphicsSceneMouseEvent& e) noexcept override;
79  QGraphicsSceneMouseEvent& e) noexcept override;
81  QGraphicsSceneMouseEvent& e) noexcept override;
82  bool processAbortCommand() noexcept override;
83 
84  // Operator Overloadings
86  const PackageEditorState_DrawPolygonBase& rhs) = delete;
87 
88 private: // Methods
89  bool start(const Point& pos) noexcept;
90  bool abort() noexcept;
91  bool addNextSegment(const Point& pos) noexcept;
92  bool updateCurrentPosition(const Point& pos) noexcept;
93 
94  void layerComboBoxValueChanged(const QString& layerName) noexcept;
95  void lineWidthSpinBoxValueChanged(double value) noexcept;
96  void angleSpinBoxValueChanged(double value) noexcept;
97  void fillCheckBoxCheckedChanged(bool checked) noexcept;
98  void grabAreaCheckBoxCheckedChanged(bool checked) noexcept;
99 
100 private: // Types / Data
102  QScopedPointer<CmdPolygonEdit> mEditCmd;
103  std::shared_ptr<Polygon> mCurrentPolygon;
106 
107  // parameter memory
111  bool mLastFill;
113 };
114 
115 /*******************************************************************************
116  * End of File
117  ******************************************************************************/
118 
119 } // namespace editor
120 } // namespace library
121 } // namespace librepcb
122 
123 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGEEDITORSTATE_DRAWPOLYGONBASE_H
bool mLastGrabArea
Definition: packageeditorstate_drawpolygonbase.h:112
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:49
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:81
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:105
bool exit() noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:139
Mode
Definition: packageeditorstate_drawpolygonbase.h:62
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
bool addNextSegment(const Point &pos) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:249
std::shared_ptr< Polygon > mCurrentPolygon
Definition: packageeditorstate_drawpolygonbase.h:103
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:111
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:52
Point mSegmentStartPos
Definition: packageeditorstate_drawpolygonbase.h:104
bool entry() noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:74
UnsignedLength mLastLineWidth
Definition: packageeditorstate_drawpolygonbase.h:109
GraphicsLayerName mLastLayerName
Definition: packageeditorstate_drawpolygonbase.h:108
Angle mLastAngle
Definition: packageeditorstate_drawpolygonbase.h:110
void grabAreaCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:331
QScopedPointer< CmdPolygonEdit > mEditCmd
Definition: packageeditorstate_drawpolygonbase.h:102
void fillCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawpolygonbase.cpp:323
The Polygon class.
Definition: polygon.h:76
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: packageeditorstate_drawpolygonbase.cpp:155
The PackageEditorState_DrawPolygonBase class.
Definition: packageeditorstate_drawpolygonbase.h:57
PackageEditorFsm::Context Context
Definition: packageeditorstate.h:56
Mode mMode
Definition: packageeditorstate_drawpolygonbase.h:101
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662