KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_dimensions.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) 2018-2023 KiCad Developers, see change_log.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <pcb_edit_frame.h>
28
29
30PANEL_SETUP_DIMENSIONS::PANEL_SETUP_DIMENSIONS( wxWindow* aParentWindow, UNITS_PROVIDER& aUnitsProvider,
31 BOARD_DESIGN_SETTINGS& aBrdSettings ) :
32 PANEL_SETUP_DIMENSIONS_BASE( aParentWindow ),
33 m_parentWindow( aParentWindow ),
34 m_unitsProvider( aUnitsProvider ),
35 m_brdSettings( &aBrdSettings ),
36 m_arrowLength( &m_unitsProvider, aParentWindow, m_lblArrowLength, m_dimensionArrowLength, m_arrowLengthUnits ),
37 m_extensionOffset( &m_unitsProvider, aParentWindow, m_lblExtensionOffset, m_dimensionExtensionOffset,
38 m_dimensionExtensionOffsetUnits )
39{
40 m_parentWindow->Bind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_DIMENSIONS::onUnitsChanged, this );
41}
42
43
45{
46 m_parentWindow->Unbind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_DIMENSIONS::onUnitsChanged, this );
47}
48
49
50void PANEL_SETUP_DIMENSIONS::onUnitsChanged( wxCommandEvent& aEvent )
51{
52 BOARD_DESIGN_SETTINGS tempBDS( nullptr, "dummy" );
54
55 m_brdSettings = &tempBDS; // No, address of stack var does not escape function
56
59
60 m_brdSettings = saveBDS;
61
62 aEvent.Skip();
63}
64
65
67{
69 return true;
70}
71
72
74{
75 m_dimensionUnits->SetSelection( static_cast<int>( aBrdSettings.m_DimensionUnitsMode ) );
76 m_dimensionUnitsFormat->SetSelection( static_cast<int>( aBrdSettings.m_DimensionUnitsFormat ) );
77 m_dimensionPrecision->SetSelection( static_cast<int>( aBrdSettings.m_DimensionPrecision ) );
79
80 int position = static_cast<int>( aBrdSettings.m_DimensionTextPosition );
81 m_dimensionTextPositionMode->SetSelection( position );
82
85
87}
88
89
91{
92 int mode = m_dimensionUnits->GetSelection();
94 int format = m_dimensionUnitsFormat->GetSelection();
96 int precision = m_dimensionPrecision->GetSelection();
97 m_brdSettings->m_DimensionPrecision = static_cast<DIM_PRECISION>( precision );
99 int position = m_dimensionTextPositionMode->GetSelection();
100 m_brdSettings->m_DimensionTextPosition = static_cast<DIM_TEXT_POSITION>( position );
104
105 return true;
106}
Container for design settings for a BOARD object.
DIM_PRECISION m_DimensionPrecision
Number of digits after the decimal.
DIM_UNITS_FORMAT m_DimensionUnitsFormat
DIM_TEXT_POSITION m_DimensionTextPosition
DIM_UNITS_MODE m_DimensionUnitsMode
Class PANEL_SETUP_DIMENSIONS_BASE.
void onUnitsChanged(wxCommandEvent &aEvent)
bool TransferDataFromWindow() override
BOARD_DESIGN_SETTINGS * m_brdSettings
void LoadFromSettings(const BOARD_DESIGN_SETTINGS &aBrdSettings)
PANEL_SETUP_DIMENSIONS(wxWindow *aParentWindow, UNITS_PROVIDER &aUnitsProvider, BOARD_DESIGN_SETTINGS &aBrdSettings)
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
DIM_TEXT_POSITION
Where to place the text on a dimension.
Definition: pcb_dimension.h:62
DIM_UNITS_FORMAT
How to display the units in a dimension's text.
Definition: pcb_dimension.h:40
DIM_UNITS_MODE
Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it.
Definition: pcb_dimension.h:72
DIM_PRECISION
Definition: pcb_dimension.h:47