KiCad PCB EDA Suite
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 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 
30 namespace KIGFX
31 {
32 class GAL;
33 
34 namespace PREVIEW
35 {
36 
44 {
45 public:
46 
48  void SetOrigin( const VECTOR2I& aOrigin )
49  {
50  m_origin = aOrigin;
51  }
52 
54  {
55  return m_origin;
56  }
57 
62  void SetEnd( const VECTOR2I& aEnd )
63  {
64  if( m_angleSnap )
65  {
67  }
68  else
69  {
70  m_end = aEnd;
71  }
72  }
73 
74  VECTOR2I GetEnd() const
75  {
76  return m_end;
77  }
78 
79  void SetAngleSnap( bool aSnap )
80  {
81  m_angleSnap = aSnap;
82  }
83 
84 private:
85 
87  bool m_angleSnap = false;
88 };
89 
90 } // PREVIEW
91 } // KIGFX
92 
93 #endif // PREVIEW_ITEMS_TWO_POINT_GEOMETRY_MANAGER_H
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
Class TWO_POINT_GEOMETRY_MANAGER.
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
a few functions useful in geometry calculations.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec)
Snap a vector onto the nearest 0, 45 or 90 degree line.
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.