KiCad PCB EDA Suite
Loading...
Searching...
No Matches
edit_relations.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 3
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 EDIT_RELATIONS_H_
21#define EDIT_RELATIONS_H_
22
23#include <math/vector2d.h>
24
25#include <memory>
26
27class EDIT_LINE;
28class EDIT_POINT;
29class EDIT_POINTS;
30class GRID_HELPER;
31
32
43
44
50
51
58
59
66
67
69{
70public:
71 static std::unique_ptr<EDIT_RELATION> SameX( const EDIT_POINT& aReference );
72 static std::unique_ptr<EDIT_RELATION> SameY( const EDIT_POINT& aReference );
73 static std::unique_ptr<EDIT_RELATION> Angle45( const EDIT_POINT& aReference );
74 static std::unique_ptr<EDIT_RELATION> Angle90( const EDIT_POINT& aReference );
75 static std::unique_ptr<EDIT_RELATION> PointOnLine( const EDIT_POINT& aConstrained, const EDIT_POINT& aReference );
76 static std::unique_ptr<EDIT_RELATION> PointOnCircle( const EDIT_POINT& aCenter, const EDIT_POINT& aEnd );
77 static std::unique_ptr<EDIT_RELATION> PerpendicularTranslation( const EDIT_LINE& aLine );
78
79 EDIT_RELATION_KIND Kind() const { return m_kind; }
80 const EDIT_POINT* Reference() const { return m_reference; }
82 const VECTOR2I& Origin() const { return m_origin; }
83 const VECTOR2I& Direction() const { return m_direction; }
84
85 void Apply( EDIT_POINT& aHandle, const GRID_HELPER& aGrid ) const;
86 void Apply( EDIT_LINE& aHandle, const GRID_HELPER& aGrid ) const;
87
88private:
90 m_kind( aKind )
91 {
92 }
93
94 static std::unique_ptr<EDIT_RELATION> make( EDIT_RELATION_KIND aKind, const EDIT_POINT& aReference );
95
97 const EDIT_POINT* m_reference = nullptr;
101};
102
103
136
137#endif
Represent a line connecting two EDIT_POINTs.
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
Represent a single point that can be used for modifying items.
Definition edit_points.h:44
VECTOR2I m_origin
static std::unique_ptr< EDIT_RELATION > Angle90(const EDIT_POINT &aReference)
const VECTOR2I & Origin() const
static std::unique_ptr< EDIT_RELATION > Angle45(const EDIT_POINT &aReference)
EDIT_RELATION(EDIT_RELATION_KIND aKind)
const EDIT_POINT * m_secondaryReference
static std::unique_ptr< EDIT_RELATION > SameY(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > PerpendicularTranslation(const EDIT_LINE &aLine)
const EDIT_POINT * m_reference
VECTOR2I m_direction
const EDIT_POINT * Reference() const
EDIT_RELATION_KIND m_kind
void Apply(EDIT_POINT &aHandle, const GRID_HELPER &aGrid) const
const VECTOR2I & Direction() const
static std::unique_ptr< EDIT_RELATION > PointOnCircle(const EDIT_POINT &aCenter, const EDIT_POINT &aEnd)
static std::unique_ptr< EDIT_RELATION > SameX(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > make(EDIT_RELATION_KIND aKind, const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > PointOnLine(const EDIT_POINT &aConstrained, const EDIT_POINT &aReference)
const EDIT_POINT * SecondaryReference() const
EDIT_RELATION_KIND Kind() const
void SetMode(POLYGON_LINE_MODE aMode)
void Apply(EDIT_LINE &aHandle, const GRID_HELPER &aGrid)
void applyFixedLength(EDIT_LINE &aHandle)
POLYGON_EDGE_DRAG_POLICY(EDIT_LINE &aLine, EDIT_POINTS &aPoints, POLYGON_LINE_MODE aMode=POLYGON_LINE_MODE::CONVERGING)
POLYGON_LINE_MODE GetMode() const
const VECTOR2I & GetOriginalCenter() const
void applyConverging(EDIT_LINE &aHandle)
POLYGON_LINE_MODE m_mode
const VECTOR2I & GetPerpVector() const
SNAP_CONSTRAINT_TYPE
@ ALL_LAYERS
@ OBJECT_LAYERS
@ IGNORE_SNAPS
POLYGON_LINE_MODE
GRID_CONSTRAINT_TYPE
@ IGNORE_GRID
@ SNAP_BY_GRID
@ SNAP_TO_GRID
EDIT_RELATION_KIND
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683