KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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>
30
32
34 m_pcbBaseFrame( aPcbBaseFrame )
35{}
36
38{}
39
40long long int PCB_ORIGIN_TRANSFORMS::ToDisplay( long long int aValue,
41 COORD_TYPES_T aCoordType ) const
42{
43 long long int value = aValue;
44
45 switch( aCoordType )
46 {
47 case COORD_TYPE::ABS_X_COORD: value = ToDisplayAbsX( value ); break;
48 case COORD_TYPE::ABS_Y_COORD: value = ToDisplayAbsY( value ); break;
49 case COORD_TYPE::REL_X_COORD: value = ToDisplayRelX( value ); break;
50 case COORD_TYPE::REL_Y_COORD: value = ToDisplayRelY( value ); break;
51 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
52 default: wxASSERT( false ); break;
53 };
54
55 return value;
56}
57
58double PCB_ORIGIN_TRANSFORMS::ToDisplay( double aValue, COORD_TYPES_T aCoordType ) const
59{
60 double value = aValue;
61
62 switch( aCoordType )
63 {
64 case COORD_TYPE::ABS_X_COORD: value = ToDisplayAbsX( value ); break;
65 case COORD_TYPE::ABS_Y_COORD: value = ToDisplayAbsY( value ); break;
66 case COORD_TYPE::REL_X_COORD: value = ToDisplayRelX( value ); break;
67 case COORD_TYPE::REL_Y_COORD: value = ToDisplayRelY( value ); break;
68 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
69 default: wxASSERT( false ); break;
70 };
71
72 return value;
73}
74
75long long int PCB_ORIGIN_TRANSFORMS::FromDisplay( long long int aValue,
76 COORD_TYPES_T aCoordType ) const
77{
78 long long value = aValue;
79
80 switch( aCoordType )
81 {
82 case COORD_TYPE::ABS_X_COORD: value = FromDisplayAbsX( value ); break;
83 case COORD_TYPE::ABS_Y_COORD: value = FromDisplayAbsY( value ); break;
84 case COORD_TYPE::REL_X_COORD: value = FromDisplayRelX( value ); break;
85 case COORD_TYPE::REL_Y_COORD: value = FromDisplayRelY( value ); break;
86 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
87 default: wxASSERT( false ); break;
88 };
89
90 return value;
91}
92
93double PCB_ORIGIN_TRANSFORMS::FromDisplay( double aValue, COORD_TYPES_T aCoordType ) const
94{
95 double value = aValue;
96
97 switch( aCoordType )
98 {
99 case COORD_TYPE::ABS_X_COORD: value = FromDisplayAbsX( value ); break;
100 case COORD_TYPE::ABS_Y_COORD: value = FromDisplayAbsY( value ); break;
101 case COORD_TYPE::REL_X_COORD: value = FromDisplayRelX( value ); break;
102 case COORD_TYPE::REL_Y_COORD: value = FromDisplayRelY( value ); break;
103 case COORD_TYPE::NOT_A_COORD: /* do nothing */ ; break;
104 default: wxASSERT( false ); break;
105 };
106
107 return value;
108}
109
110
112{
114}
115
117{
119}
120
122{
125 else
127}
128
130{
133 else
135}
FRAME_T GetFrameType() const
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
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() 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
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42