KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_track_via_size.cpp
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2014 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Maciej Suminski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.or/licenses/>.
20 */
21
25
27#include <base_units.h>
28#include <confirm.h>
30#include <optional>
31#include <eda_draw_frame.h>
32#include <pcb_track.h>
33
35
36const int minSize = (int) ( 0.01 * pcbIUScale.IU_PER_MM );
37
51
52
54{
55 if( !wxDialog::TransferDataFromWindow() )
56 return false;
57
58 std::optional<int> viaDiameter = m_viaDiameter.GetIntValue();
59 std::optional<int> viaDrill = m_viaDrill.GetIntValue();
60
61 if( std::optional<PCB_VIA::VIA_PARAMETER_ERROR> error =
62 PCB_VIA::ValidateViaParameters( viaDiameter, viaDrill ) )
63 {
64 DisplayError( GetParent(), error->m_Message );
65
66 if( error->m_Field == PCB_VIA::VIA_PARAMETER_ERROR::FIELD::DRILL )
67 m_viaDrillText->SetFocus();
68 else if( error->m_Field == PCB_VIA::VIA_PARAMETER_ERROR::FIELD::DIAMETER )
69 m_viaDiameterText->SetFocus();
70
71 return false;
72 }
73
74 // Store dialog values to the router settings
75 m_settings.SetCustomTrackWidth( m_trackWidth.GetIntValue() );
76 m_settings.SetCustomViaSize( m_viaDiameter.GetIntValue() );
77 m_settings.SetCustomViaDrill( m_viaDrill.GetIntValue() );
78
79 return true;
80}
81
82
84{
85 if( !wxDialog::TransferDataToWindow() )
86 return false;
87
88 // Load router settings to dialog fields
89 m_trackWidth.SetValue( m_settings.GetCustomTrackWidth() );
90 m_viaDiameter.SetValue( m_settings.GetCustomViaSize() );
91 m_viaDrill.SetValue( m_settings.GetCustomViaDrill() );
92
93 return true;
94}
95
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
Container for design settings for a BOARD object.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
DIALOG_TRACK_VIA_SIZE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Track and Via Dimensions"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
DIALOG_TRACK_VIA_SIZE(EDA_DRAW_FRAME *aParent, BOARD_DESIGN_SETTINGS &aSettings)
Constructor.
BOARD_DESIGN_SETTINGS & m_settings
bool TransferDataFromWindow() override
The base class for create windows for drawing purpose.
static std::optional< VIA_PARAMETER_ERROR > ValidateViaParameters(std::optional< int > aDiameter, std::optional< int > aDrill, std::optional< PCB_LAYER_ID > aStartLayer=std::nullopt, std::optional< PCB_LAYER_ID > aEndLayer=std::nullopt)
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:169
This file is part of the common library.
const int minSize
Push and Shove router track width and via size dialog.