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 The KiCad Developers, see AUTHORS.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 ),
39{
40 m_parentWindow->Bind( EDA_EVT_UNITS_CHANGED, &PANEL_SETUP_DIMENSIONS::onUnitsChanged, this );
41}
42
43
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
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
84 m_arrowLength.SetValue( aBrdSettings.m_DimensionArrowLength );
85
86 m_extensionOffset.SetValue( aBrdSettings.m_DimensionExtensionOffset );
87}
88
89
91{
92 int mode = m_dimensionUnits->GetSelection();
93 m_brdSettings->m_DimensionUnitsMode = static_cast<DIM_UNITS_MODE>( mode );
94 int format = m_dimensionUnitsFormat->GetSelection();
95 m_brdSettings->m_DimensionUnitsFormat = static_cast<DIM_UNITS_FORMAT>( format );
96 int precision = m_dimensionPrecision->GetSelection();
97 m_brdSettings->m_DimensionPrecision = static_cast<DIM_PRECISION>( precision );
98 m_brdSettings->m_DimensionSuppressZeroes = m_dimensionSuppressZeroes->GetValue();
99 int position = m_dimensionTextPositionMode->GetSelection();
100 m_brdSettings->m_DimensionTextPosition = static_cast<DIM_TEXT_POSITION>( position );
101 m_brdSettings->m_DimensionKeepTextAligned = m_dimensionTextKeepAligned->GetValue();
102 m_brdSettings->m_DimensionArrowLength = m_arrowLength.GetValue();
103 m_brdSettings->m_DimensionExtensionOffset = m_extensionOffset.GetValue();
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
PANEL_SETUP_DIMENSIONS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void onUnitsChanged(wxCommandEvent &aEvent)
BOARD_DESIGN_SETTINGS * m_brdSettings
void LoadFromSettings(const BOARD_DESIGN_SETTINGS &aBrdSettings)
PANEL_SETUP_DIMENSIONS(wxWindow *aParentWindow, UNITS_PROVIDER &aUnitsProvider, BOARD_DESIGN_SETTINGS &aBrdSettings)
DIM_TEXT_POSITION
Where to place the text on a dimension.
DIM_UNITS_FORMAT
How to display the units in a dimension's text.
DIM_UNITS_MODE
Used for storing the units selection in the file because EDA_UNITS alone doesn't cut it.
DIM_PRECISION