LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
symboleditorstate_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_SYMBOLEDITORSTATE_DRAWPOLYGONBASE_H
21 #define LIBREPCB_LIBRARY_EDITOR_SYMBOLEDITORSTATE_DRAWPOLYGONBASE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "symboleditorstate.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 SymbolEditorState_DrawPolygonBase
49  ******************************************************************************/
50 
58  Q_OBJECT
59 
60 public:
61  // Types
62  enum class Mode { LINE, RECT, POLYGON };
63 
64  // Constructors / Destructor
67  const SymbolEditorState_DrawPolygonBase& other) = delete;
68  SymbolEditorState_DrawPolygonBase(const Context& context, Mode mode) noexcept;
69  virtual ~SymbolEditorState_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 SymbolEditorState_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_SYMBOLEDITORSTATE_DRAWPOLYGONBASE_H
bool addNextSegment(const Point &pos) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:247
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition: symboleditorstate.h:52
void layerComboBoxValueChanged(const QString &layerName) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:290
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:49
std::shared_ptr< Polygon > mCurrentPolygon
Definition: symboleditorstate_drawpolygonbase.h:103
void grabAreaCheckBoxCheckedChanged(bool checked) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:329
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:165
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
UnsignedLength mLastLineWidth
Definition: symboleditorstate_drawpolygonbase.h:109
bool updateCurrentPosition(const Point &pos) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:270
Angle mLastAngle
Definition: symboleditorstate_drawpolygonbase.h:110
The CmdPolygonEdit class.
Definition: cmdpolygonedit.h:43
virtual ~SymbolEditorState_DrawPolygonBase() noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:64
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:81
bool entry() noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:74
SymbolEditorFsm::Context Context
Definition: symboleditorstate.h:56
GraphicsLayerName mLastLayerName
Definition: symboleditorstate_drawpolygonbase.h:108
Point mSegmentStartPos
Definition: symboleditorstate_drawpolygonbase.h:104
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:184
Mode mMode
Definition: symboleditorstate_drawpolygonbase.h:101
bool start(const Point &pos) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:202
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:153
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
bool processAbortCommand() noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:190
bool exit() noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:137
bool abort() noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:233
QScopedPointer< CmdPolygonEdit > mEditCmd
Definition: symboleditorstate_drawpolygonbase.h:102
Mode
Definition: symboleditorstate_drawpolygonbase.h:62
bool mLastGrabArea
Definition: symboleditorstate_drawpolygonbase.h:112
PolygonGraphicsItem * mCurrentGraphicsItem
Definition: symboleditorstate_drawpolygonbase.h:105
void fillCheckBoxCheckedChanged(bool checked) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:321
The Polygon class.
Definition: polygon.h:76
void angleSpinBoxValueChanged(double value) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:309
The SymbolEditorState_DrawPolygonBase class.
Definition: symboleditorstate_drawpolygonbase.h:57
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:662
void lineWidthSpinBoxValueChanged(double value) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:301
bool mLastFill
Definition: symboleditorstate_drawpolygonbase.h:111