KiCad PCB EDA Suite
pcb_origin_transforms.cpp
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-2021 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#include <wx/debug.h> // for wxASSERT
26#include <pcb_base_frame.h>
27#include <pcbnew_settings.h>
29
31
33 m_pcbBaseFrame( aPcbBaseFrame )
34{}
35
37{}
38
39long long int PCB_ORIGIN_TRANSFORMS::ToDisplay( long long int aValue,
40 COORD_TYPES_T aCoordType ) const
41{
42 long long int value = aValue;
43
44 switch( aCoordType )
45 {
46 case COORD_TYPE::ABS_X_COORD: value = ToDisplayAbsX( value ); break;
47 case COORD_TYPE::ABS_Y_COORD: value = ToDisplayAbsY( value ); break;
48 case COORD_TYPE::REL_X_COORD: value = ToDisplayRelX( value ); break;
49 case COORD_TYPE::REL_Y_COORD: value = ToDisplayRelY( value ); break;
50 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
51 default: wxASSERT( false ); break;
52 };
53
54 return value;
55}
56
57double PCB_ORIGIN_TRANSFORMS::ToDisplay( double aValue, COORD_TYPES_T aCoordType ) const
58{
59 double value = aValue;
60
61 switch( aCoordType )
62 {
63 case COORD_TYPE::ABS_X_COORD: value = ToDisplayAbsX( value ); break;
64 case COORD_TYPE::ABS_Y_COORD: value = ToDisplayAbsY( value ); break;
65 case COORD_TYPE::REL_X_COORD: value = ToDisplayRelX( value ); break;
66 case COORD_TYPE::REL_Y_COORD: value = ToDisplayRelY( value ); break;
67 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
68 default: wxASSERT( false ); break;
69 };
70
71 return value;
72}
73
74long long int PCB_ORIGIN_TRANSFORMS::FromDisplay( long long int aValue,
75 COORD_TYPES_T aCoordType ) const
76{
77 long long value = aValue;
78
79 switch( aCoordType )
80 {
81 case COORD_TYPE::ABS_X_COORD: value = FromDisplayAbsX( value ); break;
82 case COORD_TYPE::ABS_Y_COORD: value = FromDisplayAbsY( value ); break;
83 case COORD_TYPE::REL_X_COORD: value = FromDisplayRelX( value ); break;
84 case COORD_TYPE::REL_Y_COORD: value = FromDisplayRelY( value ); break;
85 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
86 default: wxASSERT( false ); break;
87 };
88
89 return value;
90}
91
92double PCB_ORIGIN_TRANSFORMS::FromDisplay( double aValue, COORD_TYPES_T aCoordType ) const
93{
94 double value = aValue;
95
96 switch( aCoordType )
97 {
98 case COORD_TYPE::ABS_X_COORD: value = FromDisplayAbsX( value ); break;
99 case COORD_TYPE::ABS_Y_COORD: value = FromDisplayAbsY( value ); break;
100 case COORD_TYPE::REL_X_COORD: value = FromDisplayRelX( value ); break;
101 case COORD_TYPE::REL_Y_COORD: value = FromDisplayRelY( value ); break;
102 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
103 default: wxASSERT( false ); break;
104 };
105
106 return value;
107}
108
109
111{
113}
114
116{
118}
119
121{
123}
124
126{
128}
COORD_TYPES_T
The supported Display Origin Transform types.
DISPLAY_OPTIONS m_Display
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
const VECTOR2I GetUserOrigin() const
T ToDisplayRelY(T aInternalValue) const
T ToDisplayAbsX(T aInternalValue) const
PCB_ORIGIN_TRANSFORMS(PCB_BASE_FRAME &aPcbBaseFrame)
virtual long long int FromDisplay(long long int aValue, COORD_TYPES_T aCoordType) const override
const PCB_BASE_FRAME & m_pcbBaseFrame
T FromDisplayRelY(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
Classes used in Pcbnew, CvPcb and GerbView.