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 
55  Q_OBJECT
56 
57 public:
58  // Types
59  enum class Mode { LINE, RECT, POLYGON };
60 
61  // Constructors / Destructor
64  const SymbolEditorState_DrawPolygonBase& other) = delete;
65  SymbolEditorState_DrawPolygonBase(const Context& context, Mode mode) noexcept;
66  virtual ~SymbolEditorState_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 SymbolEditorState_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 GraphicsLayerName& layerName) noexcept;
92  void lineWidthEditValueChanged(const UnsignedLength& value) noexcept;
93  void angleEditValueChanged(const Angle& 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_SYMBOLEDITORSTATE_DRAWPOLYGONBASE_H
bool addNextSegment(const Point &pos) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:239
The SymbolEditorState class is the base class of all symbol editor FSM states.
Definition: symboleditorstate.h:49
The PolygonGraphicsItem class.
Definition: polygongraphicsitem.h:46
std::shared_ptr< Polygon > mCurrentPolygon
Definition: symboleditorstate_drawpolygonbase.h:100
void angleEditValueChanged(const Angle &value) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:298
void grabAreaCheckBoxCheckedChanged(bool checked) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:318
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:157
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
UnsignedLength mLastLineWidth
Definition: symboleditorstate_drawpolygonbase.h:106
bool updateCurrentPosition(const Point &pos) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:262
Angle mLastAngle
Definition: symboleditorstate_drawpolygonbase.h:107
The CmdPolygonEdit class.
Definition: cmdpolygonedit.h:43
virtual ~SymbolEditorState_DrawPolygonBase() noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:67
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
bool entry() noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:77
SymbolEditorFsm::Context Context
Definition: symboleditorstate.h:53
GraphicsLayerName mLastLayerName
Definition: symboleditorstate_drawpolygonbase.h:105
Point mSegmentStartPos
Definition: symboleditorstate_drawpolygonbase.h:101
bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:176
Mode mMode
Definition: symboleditorstate_drawpolygonbase.h:98
bool start(const Point &pos) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:194
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:145
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
bool processAbortCommand() noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:182
bool exit() noexceptoverride
Definition: symboleditorstate_drawpolygonbase.cpp:129
void layerComboBoxValueChanged(const GraphicsLayerName &layerName) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:282
bool abort() noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:225
QScopedPointer< CmdPolygonEdit > mEditCmd
Definition: symboleditorstate_drawpolygonbase.h:99
void lineWidthEditValueChanged(const UnsignedLength &value) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:290
Mode
Definition: symboleditorstate_drawpolygonbase.h:59
bool mLastGrabArea
Definition: symboleditorstate_drawpolygonbase.h:109
PolygonGraphicsItem * mCurrentGraphicsItem
Definition: symboleditorstate_drawpolygonbase.h:102
void fillCheckBoxCheckedChanged(bool checked) noexcept
Definition: symboleditorstate_drawpolygonbase.cpp:310
The Polygon class.
Definition: polygon.h:49
The SymbolEditorState_DrawPolygonBase class.
Definition: symboleditorstate_drawpolygonbase.h:54
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:659
bool mLastFill
Definition: symboleditorstate_drawpolygonbase.h:108