LibrePCB Developers Documentation
boardeditorstate_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_BOARDEDITORSTATE_DRAWPOLYGON_H
21 #define LIBREPCB_EDITOR_BOARDEDITORSTATE_DRAWPOLYGON_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "boardeditorstate.h"
27 
30 
31 #include <QtCore>
32 #include <QtWidgets>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class BI_Polygon;
40 class Layer;
41 
42 namespace editor {
43 
44 class CmdBoardPolygonEdit;
45 class LayerComboBox;
46 class UnsignedLengthEdit;
47 
48 /*******************************************************************************
49  * Class BoardEditorState_DrawPolygon
50  ******************************************************************************/
51 
56  Q_OBJECT
57 
58 public:
59  // Constructors / Destructor
62  delete;
63  explicit BoardEditorState_DrawPolygon(const Context& context) noexcept;
64  virtual ~BoardEditorState_DrawPolygon() noexcept;
65 
66  // General Methods
67  virtual bool entry() noexcept override;
68  virtual bool exit() noexcept override;
69 
70  // Event Handlers
71  virtual bool processAbortCommand() noexcept override;
72  virtual bool processGraphicsSceneMouseMoved(
73  QGraphicsSceneMouseEvent& e) noexcept override;
75  QGraphicsSceneMouseEvent& e) noexcept override;
77  QGraphicsSceneMouseEvent& e) noexcept override;
78  virtual bool processSwitchToBoard(int index) noexcept override;
79 
80  // Operator Overloadings
82  const BoardEditorState_DrawPolygon& rhs) = delete;
83 
84 private: // Methods
85  bool startAddPolygon(const Point& pos) noexcept;
86  bool addSegment(const Point& pos) noexcept;
87  bool updateLastVertexPosition(const Point& pos) noexcept;
88  bool abortCommand(bool showErrMsgBox) noexcept;
89  void layerComboBoxLayerChanged(const Layer& layer) noexcept;
90  void widthEditValueChanged(const UnsignedLength& value) noexcept;
91  void filledCheckBoxCheckedChanged(bool checked) noexcept;
92 
93 private:
94  // State
97 
98  // parameter memory
99  const Layer* mLastLayer;
104 
105  // Information about the current polygon to place. Only valid if
106  // mIsUndoCmdActive == true.
108  QScopedPointer<CmdBoardPolygonEdit> mCurrentPolygonEditCmd;
109 };
110 
111 /*******************************************************************************
112  * End of File
113  ******************************************************************************/
114 
115 } // namespace editor
116 } // namespace librepcb
117 
118 #endif
virtual ~BoardEditorState_DrawPolygon() noexcept
Definition: boardeditorstate_drawpolygon.cpp:66
FSM Context.
Definition: boardeditorfsm.h:88
virtual bool processSwitchToBoard(int index) noexcept override
Definition: boardeditorstate_drawpolygon.cpp:165
bool updateLastVertexPosition(const Point &pos) noexcept
Definition: boardeditorstate_drawpolygon.cpp:249
void filledCheckBoxCheckedChanged(bool checked) noexcept
Definition: boardeditorstate_drawpolygon.cpp:300
BI_Polygon * mCurrentPolygon
Definition: boardeditorstate_drawpolygon.h:107
Definition: occmodel.cpp:77
bool abortCommand(bool showErrMsgBox) noexcept
Definition: boardeditorstate_drawpolygon.cpp:261
The Layer class provides all supported geometry layers.
Definition: layer.h:40
virtual bool exit() noexcept override
Definition: boardeditorstate_drawpolygon.cpp:117
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_drawpolygon.cpp:160
virtual bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_drawpolygon.cpp:142
bool mIsUndoCmdActive
Definition: boardeditorstate_drawpolygon.h:95
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
Point mLastSegmentPos
Definition: boardeditorstate_drawpolygon.h:96
QScopedPointer< CmdBoardPolygonEdit > mCurrentPolygonEditCmd
Definition: boardeditorstate_drawpolygon.h:108
bool addSegment(const Point &pos) noexcept
Definition: boardeditorstate_drawpolygon.cpp:208
virtual bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: boardeditorstate_drawpolygon.cpp:148
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
The "draw polygon" state/tool of the board editor.
Definition: boardeditorstate_drawpolygon.h:55
void widthEditValueChanged(const UnsignedLength &value) noexcept
Definition: boardeditorstate_drawpolygon.cpp:292
bool mLastIsGrabArea
Definition: boardeditorstate_drawpolygon.h:103
Angle mLastRotation
Definition: boardeditorstate_drawpolygon.h:101
bool startAddPolygon(const Point &pos) noexcept
Definition: boardeditorstate_drawpolygon.cpp:174
bool mLastIsFilled
Definition: boardeditorstate_drawpolygon.h:102
void layerComboBoxLayerChanged(const Layer &layer) noexcept
Definition: boardeditorstate_drawpolygon.cpp:283
virtual bool entry() noexcept override
Definition: boardeditorstate_drawpolygon.cpp:73
UnsignedLength mLastLineWidth
Definition: boardeditorstate_drawpolygon.h:100
The BI_Polygon class.
Definition: bi_polygon.h:46
virtual bool processAbortCommand() noexcept override
Definition: boardeditorstate_drawpolygon.cpp:132
const Layer * mLastLayer
Definition: boardeditorstate_drawpolygon.h:99
The board editor state base class.
Definition: boardeditorstate.h:59
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
BoardEditorState_DrawPolygon & operator=(const BoardEditorState_DrawPolygon &rhs)=delete