KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bezier_geom_manager.cpp
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
21
22using namespace KIGFX::PREVIEW;
23
24
26{
27 switch( getStep() )
28 {
29 case SET_START: return setStart( aPt );
30 case SET_CONTROL1: return setControlC1( aPt );
31 case SET_END: return setEnd( aPt );
32 case SET_CONTROL2: return setControlC2( aPt );
33 case COMPLETE: return false;
34 }
35
36 return false;
37}
38
39
44
45
50
51
53{
54 return m_end;
55}
56
57
59{
60 // The actual bezier C2 point is the reflection over the end point
61 // so that the cursor will be on the C1 point of the next bezier.
62 return m_end - ( m_controlC2 - m_end );
63}
64
65
67{
68 m_start = aStart;
69
70 // Prevents weird-looking loops if the control points aren't initialized
71 m_end = aStart;
72 m_controlC1 = aStart;
73 m_controlC2 = aStart;
74 return true;
75}
76
77
79{
80 m_controlC1 = aControlC1;
83 // It's possible to set the control 1 point to the same as the start point
84 return true;
85}
86
87
89{
90 m_end = aEnd;
92 return m_end != m_start;
93}
94
95
97{
98 m_controlC2 = aControlC2;
99
100 // It's possible to set the control 2 point to the same as the end point
101 return true;
102}
VECTOR2I GetControlC2() const
Get the coordinates of the arc end point.
VECTOR2I GetStart() const
< Get the center point of the arc (valid when state > SET_ORIGIN)
bool acceptPoint(const VECTOR2I &aPt) override
< Function that accepts a point for a stage, or rejects it to return to the previous stage
bool setEnd(const VECTOR2I &aCursor)
@ SET_CONTROL2
Waiting to lock in the second control point.
@ SET_END
Waiting to lock in the end point.
@ SET_CONTROL1
Waiting to lock in the first control point.
@ SET_START
Waiting to lock in the start point.
bool setControlC1(const VECTOR2I &aControl)
bool setControlC2(const VECTOR2I &aControl)
bool setStart(const VECTOR2I &aOrigin)
< Set the center point of the arc
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683