KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bezier_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 (C) 2024 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
27#include <geometry/eda_angle.h>
28#include <geometry/seg.h>
29
30namespace KIGFX
31{
32namespace PREVIEW
33{
34
35
45 {
46 public:
48
50 {
56 };
57
58 int getMaxStep() const override { return COMPLETE; }
59
64 BEZIER_STEPS GetStep() const { return static_cast<BEZIER_STEPS>( getStep() ); }
65
66 bool acceptPoint( const VECTOR2I& aPt ) override;
67
68 /*
69 * Geometry query interface - used by clients of the manager
70 */
71
73 VECTOR2I GetStart() const;
74
76 VECTOR2I GetControlC1() const;
77 VECTOR2I GetControlC2() const;
78
80 VECTOR2I GetEnd() const;
81
82 private:
83 /*
84 * Point acceptor functions
85 */
86
88 bool setStart( const VECTOR2I& aOrigin );
89 bool setControlC1( const VECTOR2I& aControl );
90 bool setEnd( const VECTOR2I& aCursor );
91 bool setControlC2( const VECTOR2I& aControl );
92
93 /*
94 * Bezier geometry
95 */
100 };
101} // namespace PREVIEW
102} // namespace KIGFX
Manage the construction of a bezier through a series of steps.
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
int getMaxStep() const override
The highest step this manager has - used to recognize completion and to clamp the step as it advances...
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)
BEZIER_STEPS GetStep() const
Get the current step the manager is on (useful when drawing something depends on the current state)
bool setStart(const VECTOR2I &aOrigin)
< Set the center point of the arc
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: color4d.cpp:247