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 (C) 2017-2021 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:
43
45 void SetOrigin( const VECTOR2I& aOrigin )
46 {
47 m_origin = aOrigin;
48 m_originSet = true;
50 }
51
53 {
54 return m_origin;
55 }
56
60 void SetEnd( const VECTOR2I& aEnd )
61 {
62 if( m_angleSnap )
63 {
65 }
66 else
67 {
68 m_end = aEnd;
69 }
71 }
72
74 {
75 return m_end;
76 }
77
78 void SetAngleSnap( bool aSnap )
79 {
80 m_angleSnap = aSnap;
81 }
82
83 bool GetAngleSnap() const
84 {
85 return m_angleSnap;
86 }
87
91 bool IsReset() const
92 {
93 return !m_originSet;
94 }
95
99 void Reset()
100 {
101 m_originSet = false;
103 }
104
109 {
110 return m_changed;
111 }
112
118 {
119 m_changed = false;
120 }
121
122protected:
125 {
126 m_changed = true;
127 }
128
129private:
130
132 bool m_angleSnap = false;
133
135 bool m_changed = false;
136 bool m_originSet = false;
137};
138
139} // PREVIEW
140} // KIGFX
141
142#endif // PREVIEW_ITEMS_TWO_POINT_GEOMETRY_MANAGER_H
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)
bool m_angleSnap
Has the geometry changed such that a client should redraw?
void ClearGeometryChanged()
Clear the geometry changed flag, call after the client code has updated everything as needed.
void setGeometryChanged()
< Mark the geometry as changed for clients to notice
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.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:246