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, 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#ifndef PREVIEW_ITEMS_TWO_POINT_GEOMETRY_MANAGER_H
25#define PREVIEW_ITEMS_TWO_POINT_GEOMETRY_MANAGER_H
26
27#include <math/vector2d.h>
29
30namespace KIGFX
31{
32class GAL;
33
34namespace PREVIEW
35{
36
41{
42public:
44 void SetOrigin( const VECTOR2I& aOrigin )
45 {
46 m_origin = aOrigin;
47 m_originSet = true;
48 }
49
51 {
52 return m_origin;
53 }
54
58 void SetEnd( const VECTOR2I& aEnd )
59 {
60 switch( m_angleSnap )
61 {
64 default: m_end = aEnd; break;
65 }
66 }
67
69 {
70 return m_end;
71 }
72
73 void SetAngleSnap( LEADER_MODE aSnap ) { m_angleSnap = aSnap; }
74
76
80 bool IsReset() const
81 {
82 return !m_originSet;
83 }
84
88 void Reset()
89 {
90 m_originSet = false;
91 }
92
93 bool IsEmpty() const
94 {
95 return !m_originSet || m_origin == m_end;
96 }
97
98private:
102 bool m_originSet = false;
103};
104
105} // PREVIEW
106} // KIGFX
107
108#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:33
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695