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
30
class
PCB_BASE_FRAME
;
31
32
class
PCB_ORIGIN_TRANSFORMS
:
public
ORIGIN_TRANSFORMS
33
{
34
public
:
35
PCB_ORIGIN_TRANSFORMS
(
PCB_BASE_FRAME
& aPcbBaseFrame );
36
37
virtual
~PCB_ORIGIN_TRANSFORMS
()
override
;
38
39
using
ORIGIN_TRANSFORMS::ToDisplay
;
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
46
using
ORIGIN_TRANSFORMS::FromDisplay
;
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
{
136
return
ORIGIN_TRANSFORMS::FromDisplayAbs
( aDisplayValue,
getUserXOrigin
(),
invertXAxis
() );
137
}
138
139
template
<
typename
T>
140
T
FromDisplayAbsY
( T aDisplayValue )
const
141
{
142
return
ORIGIN_TRANSFORMS::FromDisplayAbs
( aDisplayValue,
getUserYOrigin
(),
invertYAxis
() );
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
192
protected
:
193
int
getUserXOrigin
()
const
;
194
int
getUserYOrigin
()
const
;
195
196
bool
invertXAxis
()
const
;
197
bool
invertYAxis
()
const
;
198
199
protected
:
200
const
PCB_BASE_FRAME
&
m_pcbBaseFrame
;
201
};
202
203
#endif
// PCB_ORIGIN_TRANSFORMS_H_
ORIGIN_TRANSFORMS
A class to perform either relative or absolute display origin transforms for a single axis of a point...
Definition:
origin_transforms.h:40
ORIGIN_TRANSFORMS::FromDisplay
virtual int FromDisplay(int aValue, COORD_TYPES_T aCoordType) const
Definition:
origin_transforms.cpp:53
ORIGIN_TRANSFORMS::FromDisplayRel
T FromDisplayRel(const T &aValue) const
Definition:
origin_transforms.h:111
ORIGIN_TRANSFORMS::ToDisplayRel
T ToDisplayRel(const T &aValue) const
Definition:
origin_transforms.h:90
ORIGIN_TRANSFORMS::ToDisplayAbs
T ToDisplayAbs(const T &aValue) const
Definition:
origin_transforms.h:80
ORIGIN_TRANSFORMS::ToDisplay
virtual int ToDisplay(int aValue, COORD_TYPES_T aCoordType) const
Definition:
origin_transforms.cpp:35
ORIGIN_TRANSFORMS::COORD_TYPES_T
COORD_TYPES_T
The supported Display Origin Transform types.
Definition:
origin_transforms.h:48
ORIGIN_TRANSFORMS::FromDisplayAbs
T FromDisplayAbs(const T &aValue) const
Definition:
origin_transforms.h:101
PCB_BASE_FRAME
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Definition:
pcb_base_frame.h:87
PCB_ORIGIN_TRANSFORMS
Definition:
pcb_origin_transforms.h:33
PCB_ORIGIN_TRANSFORMS::ToDisplayRelY
T ToDisplayRelY(T aInternalValue) const
Definition:
pcb_origin_transforms.h:101
PCB_ORIGIN_TRANSFORMS::ToDisplayAbsX
T ToDisplayAbsX(T aInternalValue) const
Definition:
pcb_origin_transforms.h:122
PCB_ORIGIN_TRANSFORMS::invertYAxis
bool invertYAxis() const
Definition:
pcb_origin_transforms.cpp:129
PCB_ORIGIN_TRANSFORMS::FromDisplay
virtual long long int FromDisplay(long long int aValue, COORD_TYPES_T aCoordType) const override
Definition:
pcb_origin_transforms.cpp:75
PCB_ORIGIN_TRANSFORMS::FromDisplayRel
T FromDisplayRel(T aDisplayValue) const
Definition:
pcb_origin_transforms.h:182
PCB_ORIGIN_TRANSFORMS::invertXAxis
bool invertXAxis() const
Definition:
pcb_origin_transforms.cpp:121
PCB_ORIGIN_TRANSFORMS::ToDisplayAbs
T ToDisplayAbs(T aInternalValue) const
Definition:
pcb_origin_transforms.h:149
PCB_ORIGIN_TRANSFORMS::m_pcbBaseFrame
const PCB_BASE_FRAME & m_pcbBaseFrame
Definition:
pcb_origin_transforms.h:200
PCB_ORIGIN_TRANSFORMS::FromDisplayRelY
T FromDisplayRelY(T aDisplayValue) const
Definition:
pcb_origin_transforms.h:113
PCB_ORIGIN_TRANSFORMS::ToDisplayRel
T ToDisplayRel(T aInternalValue) const
Definition:
pcb_origin_transforms.h:171
PCB_ORIGIN_TRANSFORMS::FromDisplayAbs
T FromDisplayAbs(T aDisplayValue) const
Definition:
pcb_origin_transforms.h:160
PCB_ORIGIN_TRANSFORMS::~PCB_ORIGIN_TRANSFORMS
virtual ~PCB_ORIGIN_TRANSFORMS() override
Definition:
pcb_origin_transforms.cpp:37
PCB_ORIGIN_TRANSFORMS::FromDisplayAbsY
T FromDisplayAbsY(T aDisplayValue) const
Definition:
pcb_origin_transforms.h:140
PCB_ORIGIN_TRANSFORMS::FromDisplayAbsX
T FromDisplayAbsX(T aDisplayValue) const
Definition:
pcb_origin_transforms.h:134
PCB_ORIGIN_TRANSFORMS::getUserYOrigin
int getUserYOrigin() const
Definition:
pcb_origin_transforms.cpp:116
PCB_ORIGIN_TRANSFORMS::ToDisplayRelX
T ToDisplayRelX(T aInternalValue) const
Transform a 2-D coordinate point referenced to the internal origin to the equivalent point referenced...
Definition:
pcb_origin_transforms.h:95
PCB_ORIGIN_TRANSFORMS::ToDisplayAbsY
T ToDisplayAbsY(T aInternalValue) const
Definition:
pcb_origin_transforms.h:128
PCB_ORIGIN_TRANSFORMS::ToDisplay
virtual long long int ToDisplay(long long int aValue, COORD_TYPES_T aCoordType) const override
Definition:
pcb_origin_transforms.cpp:40
PCB_ORIGIN_TRANSFORMS::getUserXOrigin
int getUserXOrigin() const
Definition:
pcb_origin_transforms.cpp:111
PCB_ORIGIN_TRANSFORMS::FromDisplayRelX
T FromDisplayRelX(T aDisplayValue) const
Definition:
pcb_origin_transforms.h:107
origin_transforms.h
src
pcbnew
pcb_origin_transforms.h
Generated on Thu Dec 26 2024 00:05:14 for KiCad PCB EDA Suite by
1.9.6