KiCad PCB EDA Suite
Loading...
Searching...
No Matches
transform.h
Go to the documentation of this file.
1
5/*
6 * This program source code file is part of KiCad, a free EDA CAD application.
7 *
8 * Copyright (C) 2007-2010 Wayne Stambaugh <[email protected]>
9 * Copyright (C) 2007-2021 KiCad Developers, see AUTHORS.txt for contributors.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, you may find one here:
23 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24 * or you may search the http://www.gnu.org website for the version 2 license,
25 * or you may write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27 */
28
29
30#ifndef _TRANSFORM_H_
31#define _TRANSFORM_H_
32
33#include <geometry/eda_angle.h>
34#include <math/box2.h>
35
36
46{
47public:
48 int x1;
49 int y1;
50 int x2;
51 int y2;
52
57 x1( 1 ),
58 y1( 0 ),
59 x2( 0 ),
60 y2( 1 )
61 {}
62
63 TRANSFORM( int ax1, int ay1, int ax2, int ay2 ) :
64 x1( ax1 ),
65 y1( ay1 ),
66 x2( ax2 ),
67 y2( ay2 )
68 {}
69
70 bool operator==( const TRANSFORM& aTransform ) const;
71
72 bool operator!=( const TRANSFORM& aTransform ) const { return !( *this == aTransform ); }
73
81 VECTOR2I TransformCoordinate( const VECTOR2I& aPoint ) const;
82
90 BOX2I TransformCoordinate( const BOX2I& aRect ) const;
91
99
107 bool MapAngles( EDA_ANGLE* aAngle1, EDA_ANGLE* aAngle2 ) const;
108};
109
110namespace std
111{
112 template <> struct hash<TRANSFORM>
113 {
114 size_t operator() ( const TRANSFORM& k ) const;
115 };
116}
117
118#endif // _TRANSFORM_H_
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
TRANSFORM(int ax1, int ay1, int ax2, int ay2)
Definition: transform.h:63
int x2
Definition: transform.h:50
int y1
Definition: transform.h:49
bool MapAngles(EDA_ANGLE *aAngle1, EDA_ANGLE *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:81
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:59
bool operator==(const TRANSFORM &aTransform) const
Definition: transform.cpp:35
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:44
TRANSFORM()
The default construct creates a transform that draws object is the normal orientation.
Definition: transform.h:56
bool operator!=(const TRANSFORM &aTransform) const
Definition: transform.h:72
int y2
Definition: transform.h:51
int x1
Definition: transform.h:48
STL namespace.