LibrePCB Developers Documentation
packageeditorstate_drawcircle.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_PACKAGEEDITORSTATE_DRAWCIRCLE_H
21 #define LIBREPCB_EDITOR_PACKAGEEDITORSTATE_DRAWCIRCLE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "packageeditorstate.h"
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 #include <memory>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class Circle;
39 class Layer;
40 
41 namespace editor {
42 
43 class CircleGraphicsItem;
44 class CmdCircleEdit;
45 
46 /*******************************************************************************
47  * Class PackageEditorState_DrawCircle
48  ******************************************************************************/
49 
54  Q_OBJECT
55 
56 public:
57  // Constructors / Destructor
60  delete;
61  explicit PackageEditorState_DrawCircle(Context& context) noexcept;
63 
64  // General Methods
65  bool entry() noexcept override;
66  bool exit() noexcept override;
67  QSet<EditorWidgetBase::Feature> getAvailableFeatures()
68  const noexcept override;
69 
70  // Event Handlers
72  QGraphicsSceneMouseEvent& e) noexcept override;
74  QGraphicsSceneMouseEvent& e) noexcept override;
75  bool processAbortCommand() noexcept override;
76 
77  // Operator Overloadings
79  const PackageEditorState_DrawCircle& rhs) = delete;
80 
81 signals:
82  void requestLineWidth(const UnsignedLength& value);
83 
84 private: // Methods
85  bool startAddCircle(const Point& pos) noexcept;
86  bool updateCircleDiameter(const Point& pos) noexcept;
87  bool finishAddCircle(const Point& pos) noexcept;
88  bool abortAddCircle() noexcept;
89 
90  void layerComboBoxValueChanged(const Layer& layer) noexcept;
91  void lineWidthEditValueChanged(const UnsignedLength& value) noexcept;
92  void fillCheckBoxCheckedChanged(bool checked) noexcept;
93  void grabAreaCheckBoxCheckedChanged(bool checked) noexcept;
94 
95 private: // Types / Data
96  QScopedPointer<CmdCircleEdit> mEditCmd;
97  std::shared_ptr<Circle> mCurrentCircle;
98  std::shared_ptr<CircleGraphicsItem> mCurrentGraphicsItem;
99 
100  // parameter memory
103  bool mLastFill;
105  QHash<const Layer*, UnsignedLength> mUsedLineWidths;
106 };
107 
108 /*******************************************************************************
109  * End of File
110  ******************************************************************************/
111 
112 } // namespace editor
113 } // namespace librepcb
114 
115 #endif
Definition: packageeditorfsm.h:89
bool exit() noexcept override
Definition: packageeditorstate_drawcircle.cpp:120
bool processGraphicsSceneLeftMouseButtonPressed(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawcircle.cpp:154
The PackageEditorState_DrawCircle class.
Definition: packageeditorstate_drawcircle.h:53
bool processAbortCommand() noexcept override
Definition: packageeditorstate_drawcircle.cpp:165
void requestLineWidth(const UnsignedLength &value)
bool startAddCircle(const Point &pos) noexcept
Definition: packageeditorstate_drawcircle.cpp:177
Definition: occmodel.cpp:77
bool mLastFill
Definition: packageeditorstate_drawcircle.h:103
The Layer class provides all supported geometry layers.
Definition: layer.h:40
std::shared_ptr< CircleGraphicsItem > mCurrentGraphicsItem
Definition: packageeditorstate_drawcircle.h:98
bool finishAddCircle(const Point &pos) noexcept
Definition: packageeditorstate_drawcircle.cpp:211
UnsignedLength mLastLineWidth
Definition: packageeditorstate_drawcircle.h:102
bool abortAddCircle() noexcept
Definition: packageeditorstate_drawcircle.cpp:230
bool processGraphicsSceneMouseMoved(QGraphicsSceneMouseEvent &e) noexcept override
Definition: packageeditorstate_drawcircle.cpp:143
bool updateCircleDiameter(const Point &pos) noexcept
Definition: packageeditorstate_drawcircle.cpp:200
QSet< EditorWidgetBase::Feature > getAvailableFeatures() const noexcept override
Definition: packageeditorstate_drawcircle.cpp:133
void grabAreaCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawcircle.cpp:278
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:79
void fillCheckBoxCheckedChanged(bool checked) noexcept
Definition: packageeditorstate_drawcircle.cpp:270
const Layer * mLastLayer
Definition: packageeditorstate_drawcircle.h:101
std::shared_ptr< Circle > mCurrentCircle
Definition: packageeditorstate_drawcircle.h:97
void layerComboBoxValueChanged(const Layer &layer) noexcept
Definition: packageeditorstate_drawcircle.cpp:244
PackageEditorState_DrawCircle & operator=(const PackageEditorState_DrawCircle &rhs)=delete
bool mLastGrabArea
Definition: packageeditorstate_drawcircle.h:104
bool entry() noexcept override
Definition: packageeditorstate_drawcircle.cpp:70
QScopedPointer< CmdCircleEdit > mEditCmd
Definition: packageeditorstate_drawcircle.h:96
The PackageEditorState class is the base class of all package editor FSM states.
Definition: packageeditorstate.h:52
QHash< const Layer *, UnsignedLength > mUsedLineWidths
Definition: packageeditorstate_drawcircle.h:105
~PackageEditorState_DrawCircle() noexcept
Definition: packageeditorstate_drawcircle.cpp:62
type_safe::constrained_type< Length, UnsignedLengthConstraint, UnsignedLengthVerifier > UnsignedLength
Definition: length.h:696
void lineWidthEditValueChanged(const UnsignedLength &value) noexcept
Definition: packageeditorstate_drawcircle.cpp:261