KiCad PCB EDA Suite
Loading...
Searching...
No Matches
graphic_edit.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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 GRAPHIC_EDIT_H
21#define GRAPHIC_EDIT_H
22
23#include <eda_shape.h>
24#include <geometry/shape_arc.h>
25#include <math/vector2d.h>
26
27#include <limits>
28#include <vector>
29
30class BOARD_ITEM;
31class EDA_ITEM;
32class PCB_SHAPE;
33
35constexpr int MAX_GRAPHIC_EDIT_ARC_RADIUS = std::numeric_limits<int>::max() / 2;
36
38constexpr double GRAPHIC_EDIT_ANGLE_EPSILON = 1e-6;
39
50
63
65{
66 explicit operator bool() const { return m_Refusal == GRAPHIC_EDIT_REFUSAL::NONE; }
67
69
71 std::vector<GRAPHIC_EDIT_GEOMETRY> m_Geometry;
72
75 std::vector<GRAPHIC_EDIT_GEOMETRY> m_Preview;
76
77 std::vector<const BOARD_ITEM*> m_Boundaries;
78};
79
81const PCB_SHAPE* GraphicEditShape( const EDA_ITEM* aItem );
82
84bool IsGraphicExtendSource( const PCB_SHAPE& aShape );
85
87bool IsGraphicTrimSource( const PCB_SHAPE& aShape );
88
90const PCB_SHAPE* GraphicEditSource( const BOARD_ITEM& aSource, bool ( *aAccepts )( const PCB_SHAPE& ),
91 GRAPHIC_EDIT_RESULT& aResult );
92
94const PCB_SHAPE* GraphicEditBoundary( const BOARD_ITEM* aBoundary, const PCB_SHAPE& aSource );
95
96SHAPE_ARC GraphicEditArc( const PCB_SHAPE& aShape );
97
99bool IsGraphicEditArcUsable( const SHAPE_ARC& aArc );
100
102bool GraphicEditCoincident( const VECTOR2I& aA, const VECTOR2I& aB );
103
104#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
@ NONE
Definition eda_fill.h:42
SHAPE_T
Definition eda_shape.h:54
@ SEGMENT
Definition eda_shape.h:56
GRAPHIC_EDIT_REFUSAL
Why a planner refused. Each one gets its own message.
SHAPE_ARC GraphicEditArc(const PCB_SHAPE &aShape)
bool IsGraphicEditArcUsable(const SHAPE_ARC &aArc)
False for radii and sweeps the planners refuse. Check before planning an arc.
bool IsGraphicTrimSource(const PCB_SHAPE &aShape)
Trim also takes the closed shapes, which it opens up.
constexpr int MAX_GRAPHIC_EDIT_ARC_RADIUS
Larger arcs overflow the boundary search box.
const PCB_SHAPE * GraphicEditBoundary(const BOARD_ITEM *aBoundary, const PCB_SHAPE &aSource)
A boundary usable against aSource. Null if it is the source, off-layer or unusable.
const PCB_SHAPE * GraphicEditSource(const BOARD_ITEM &aSource, bool(*aAccepts)(const PCB_SHAPE &), GRAPHIC_EDIT_RESULT &aResult)
The shape to edit, or null with the reason in aResult. aAccepts decides the kinds.
bool GraphicEditCoincident(const VECTOR2I &aA, const VECTOR2I &aB)
Points built by different routes land a rounding step apart.
bool IsGraphicExtendSource(const PCB_SHAPE &aShape)
Extend needs two ends to work with.
const PCB_SHAPE * GraphicEditShape(const EDA_ITEM *aItem)
Any graphical shape a planner or a boundary search might use. Anything else gives null.
constexpr double GRAPHIC_EDIT_ANGLE_EPSILON
Sweeps this near zero or a full turn are ambiguous.
SHAPE_T m_Shape
A result need not be the same kind as the source.
VECTOR2I m_Mid
Arcs only. Everything else leaves it default.
std::vector< GRAPHIC_EDIT_GEOMETRY > m_Geometry
What the source becomes. Empty means the whole source goes.
std::vector< const BOARD_ITEM * > m_Boundaries
GRAPHIC_EDIT_REFUSAL m_Refusal
std::vector< GRAPHIC_EDIT_GEOMETRY > m_Preview
What the preview draws.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683