KiCad PCB EDA Suite
Loading...
Searching...
No Matches
two_point_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_TWO_POINT_GEOMETRY_MANAGER_H
21#define PREVIEW_ITEMS_TWO_POINT_GEOMETRY_MANAGER_H
22
23#include <math/vector2d.h>
25
26namespace KIGFX
27{
28class GAL;
29
30namespace PREVIEW
31{
32
37{
38public:
40 void SetOrigin( const VECTOR2I& aOrigin )
41 {
42 m_origin = aOrigin;
43 m_originSet = true;
44 }
45
47 {
48 return m_origin;
49 }
50
54 void SetEnd( const VECTOR2I& aEnd )
55 {
56 switch( m_angleSnap )
57 {
60 default: m_end = aEnd; break;
61 }
62 }
63
65 {
66 return m_end;
67 }
68
69 void SetAngleSnap( LEADER_MODE aSnap ) { m_angleSnap = aSnap; }
70
72
76 bool IsReset() const
77 {
78 return !m_originSet;
79 }
80
84 void Reset()
85 {
86 m_originSet = false;
87 }
88
89 bool IsEmpty() const
90 {
91 return !m_originSet || m_origin == m_end;
92 }
93
94private:
98 bool m_originSet = false;
99};
100
101} // PREVIEW
102} // KIGFX
103
104#endif // PREVIEW_ITEMS_TWO_POINT_GEOMETRY_MANAGER_H
Abstract interface for drawing on a 2D-surface.
Represent a very simple geometry manager for items that have a start and end point.
void SetOrigin(const VECTOR2I &aOrigin)
< Set the origin of the ruler (the fixed end)
void Reset()
Reset the manager to the initial state.
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.
a few functions useful in geometry calculations.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
LEADER_MODE
The kind of the leader line.
@ DEG45
45 Degree only
@ DIRECT
Unconstrained point-to-point.
@ DEG90
90 Degree only
VECTOR2< T > GetVectorSnapped90(const VECTOR2< T > &aVec)
Snap a vector onto the nearest horizontal or vertical line.
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683