KiCad PCB EDA Suite
Loading...
Searching...
No Matches
arc_geom_manager.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (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 <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PREVIEW_ITEMS_ARC_GEOMETRY_MANAGER_H
21#define PREVIEW_ITEMS_ARC_GEOMETRY_MANAGER_H
22
24#include <geometry/eda_angle.h>
25
26namespace KIGFX {
27namespace PREVIEW {
28
38{
39public:
42
50
51 int getMaxStep() const override
52 {
53 return COMPLETE;
54 }
55
61 {
62 return static_cast<ARC_STEPS>( getStep() );
63 }
64
65 void Reset() override;
66
68 void SetClockwise( bool aCw );
69
71 void ToggleClockwise();
72
74 void SetAngleSnap( bool aSnap )
75 {
76 m_angleSnap = aSnap;
77 }
78
79 /*
80 * Geometry query interface - used by clients of the manager
81 */
82
84 VECTOR2I GetOrigin() const;
85
88
91
93 double GetRadius() const;
94
97
99 EDA_ANGLE GetSubtended() const;
100
101protected:
102 bool acceptPoint( const VECTOR2I& aPt ) override;
103
104private:
105 /*
106 * Point acceptor functions
107 */
108
110 bool setOrigin( const VECTOR2I& aOrigin );
111
113 bool setStart( const VECTOR2I& aEnd );
114
116 bool setEnd( const VECTOR2I& aCursor );
117
118 /*
119 * Arc geometry
120 */
121 bool m_clockwise = true;
123 double m_radius = 0.0;
126
127 /*
128 * construction parameters
129 */
130 bool m_angleSnap = false;
131 bool m_directionLocked = false;
132};
133
134} // PREVIEW
135} // KIGFX
136
137#endif // PREVIEW_ITEMS_ARC_GEOMETRY_MANAGER_H
VECTOR2I GetOrigin() const
< Get the center point of the arc (valid when state > SET_ORIGIN)
void Reset() override
The arc to be clockwise from start.
ARC_STEPS GetStep() const
Get the current step the manager is on (useful when drawing something depends on the current state)
void SetClockwise(bool aCw)
Reverse the current are direction.
int getMaxStep() const override
The highest step this manager has - used to recognize completion and to clamp the step as it advances...
void ToggleClockwise()
Set angle snapping (for the next point)
EDA_ANGLE GetStartAngle() const
Get the angle of the vector leading to the end point (valid if step >= SET_ANGLE)
bool setStart(const VECTOR2I &aEnd)
Set a point of the second radius line (collinear with arc end)
VECTOR2I GetStartRadiusEnd() const
Get the coordinates of the arc end point.
bool acceptPoint(const VECTOR2I &aPt) override
< Function that accepts a point for a stage, or rejects it to return to the previous stage
VECTOR2I GetEndRadiusEnd() const
Get the radius of the arc (valid if step >= SET_START)
bool setEnd(const VECTOR2I &aCursor)
double GetRadius() const
Get the angle of the vector leading to the start point (valid if step >= SET_START)
bool setOrigin(const VECTOR2I &aOrigin)
< Set the center point of the arc
@ SET_ORIGIN
Waiting to lock in origin point.
@ SET_ANGLE
Waiting to lock in the arc end point.
@ SET_START
Waiting to lock in the arc start point.
A geometry manager that works by accepting a sequence of points and advancing though stages of geomet...
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683