KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_origin_transforms.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) 2019-2020 Reece R. Pollack <[email protected]>
5 * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PCB_ORIGIN_TRANSFORM_H_
26#define PCB_ORIGIN_TRANSFORM_H_
27
28#include <origin_transforms.h>
29
30class PCB_BASE_FRAME;
31
33{
34public:
35 PCB_ORIGIN_TRANSFORMS( PCB_BASE_FRAME& aPcbBaseFrame );
36
37 virtual ~PCB_ORIGIN_TRANSFORMS() override;
38
40
41 virtual long long int ToDisplay( long long int aValue, COORD_TYPES_T aCoordType ) const override;
42
43 virtual double ToDisplay( double aValue, COORD_TYPES_T aCoordType ) const override;
44
45
47
48 virtual long long int FromDisplay( long long int aValue, COORD_TYPES_T aCoordType ) const override;
49
50 virtual double FromDisplay( double aValue, COORD_TYPES_T aCoordType ) const override;
51
52
92 // =============== Single-axis Relative Transforms ===============
93
94 template<typename T>
95 T ToDisplayRelX( T aInternalValue ) const
96 {
97 return ORIGIN_TRANSFORMS::ToDisplayRel( aInternalValue, invertXAxis() );
98 }
99
100 template<typename T>
101 T ToDisplayRelY( T aInternalValue ) const
102 {
103 return ORIGIN_TRANSFORMS::ToDisplayRel( aInternalValue, invertYAxis() );
104 }
105
106 template<typename T>
107 T FromDisplayRelX( T aDisplayValue ) const
108 {
109 return ORIGIN_TRANSFORMS::FromDisplayRel( aDisplayValue, invertXAxis() );
110 }
111
112 template<typename T>
113 T FromDisplayRelY( T aDisplayValue ) const
114 {
115 return ORIGIN_TRANSFORMS::FromDisplayRel( aDisplayValue, invertYAxis() );
116 }
117
118
119 // =============== Single-axis Absolute Transforms ===============
120
121 template<typename T>
122 T ToDisplayAbsX( T aInternalValue ) const
123 {
124 return ORIGIN_TRANSFORMS::ToDisplayAbs( aInternalValue, getUserXOrigin(), invertXAxis() );
125 }
126
127 template<typename T>
128 T ToDisplayAbsY( T aInternalValue ) const
129 {
130 return ORIGIN_TRANSFORMS::ToDisplayAbs( aInternalValue, getUserYOrigin(), invertYAxis() );
131 }
132
133 template<typename T>
134 T FromDisplayAbsX( T aDisplayValue ) const
135 {
137 }
138
139 template<typename T>
140 T FromDisplayAbsY( T aDisplayValue ) const
141 {
143 }
144
145
146 // =============== Two-axis Transforms ===============
147
148 template<typename T>
149 T ToDisplayAbs( T aInternalValue ) const
150 {
151 T displayValue;
152
153 displayValue.x = ToDisplayAbsX( aInternalValue.x );
154 displayValue.y = ToDisplayAbsY( aInternalValue.y );
155
156 return displayValue;
157 }
158
159 template<typename T>
160 T FromDisplayAbs( T aDisplayValue ) const
161 {
162 T internalValue;
163
164 internalValue.x = FromDisplayAbsX( aDisplayValue.x );
165 internalValue.y = FromDisplayAbsY( aDisplayValue.y );
166
167 return internalValue;
168 }
169
170 template<typename T>
171 T ToDisplayRel( T aInternalValue ) const
172 {
173 T displayValue;
174
175 displayValue.x = ToDisplayRelX( aInternalValue.x );
176 displayValue.y = ToDisplayRelY( aInternalValue.y );
177
178 return displayValue;
179 }
180
181 template<typename T>
182 T FromDisplayRel( T aDisplayValue ) const
183 {
184 T internalValue;
185
186 internalValue.x = FromDisplayRelX( aDisplayValue.x );
187 internalValue.y = FromDisplayRelY( aDisplayValue.y );
188
189 return internalValue;
190 }
191
192protected:
193 int getUserXOrigin() const;
194 int getUserYOrigin() const;
195
196 bool invertXAxis() const;
197 bool invertYAxis() const;
198
199protected:
201};
202
203#endif // PCB_ORIGIN_TRANSFORMS_H_
A class to perform either relative or absolute display origin transforms for a single axis of a point...
virtual int FromDisplay(int aValue, COORD_TYPES_T aCoordType) const
T FromDisplayRel(const T &aValue) const
T ToDisplayRel(const T &aValue) const
T ToDisplayAbs(const T &aValue) const
virtual int ToDisplay(int aValue, COORD_TYPES_T aCoordType) const
COORD_TYPES_T
The supported Display Origin Transform types.
T FromDisplayAbs(const T &aValue) const
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
T ToDisplayRelY(T aInternalValue) const
T ToDisplayAbsX(T aInternalValue) const
virtual long long int FromDisplay(long long int aValue, COORD_TYPES_T aCoordType) const override
T FromDisplayRel(T aDisplayValue) const
T ToDisplayAbs(T aInternalValue) const
const PCB_BASE_FRAME & m_pcbBaseFrame
T FromDisplayRelY(T aDisplayValue) const
T ToDisplayRel(T aInternalValue) const
T FromDisplayAbs(T aDisplayValue) const
virtual ~PCB_ORIGIN_TRANSFORMS() override
T FromDisplayAbsY(T aDisplayValue) const
T FromDisplayAbsX(T aDisplayValue) const
T ToDisplayRelX(T aInternalValue) const
Transform a 2-D coordinate point referenced to the internal origin to the equivalent point referenced...
T ToDisplayAbsY(T aInternalValue) const
virtual long long int ToDisplay(long long int aValue, COORD_TYPES_T aCoordType) const override
T FromDisplayRelX(T aDisplayValue) const