KiCad PCB EDA Suite
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  * Author: Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.or/licenses/>.
19  */
20 
25 #include "dialog_track_via_size.h"
26 #include <base_units.h>
27 #include <confirm.h>
28 #include <widgets/text_ctrl_eval.h>
29 #include <core/optional.h>
30 
31 #include "board_design_settings.h"
32 
34  DIALOG_TRACK_VIA_SIZE_BASE( aParent ),
35  m_trackWidth( aParent, m_trackWidthText, m_trackWidthLabel ),
36  m_viaDiameter( aParent, m_viaDiameterText, m_viaDiameterLabel ),
37  m_viaDrill( aParent, m_viaDrillText, m_viaDrillLabel ),
38  m_settings( aSettings )
39 {
40  m_stdButtonsOK->SetDefault();
41 
42  // Now all widgets have the size fixed, call FinishDialogSettings
44 }
45 
46 
48 {
49  if( !wxDialog::TransferDataFromWindow() )
50  return false;
51 
52  if( !check() )
53  return false;
54 
55  // Store dialog values to the router settings
59 
60  return true;
61 }
62 
63 
65 {
66  if( !wxDialog::TransferDataToWindow() )
67  return false;
68 
69  // Load router settings to dialog fields
73 
74  return true;
75 }
76 
77 
79 {
80  if( m_trackWidth.GetValue() <= 0 )
81  {
82  DisplayError( GetParent(), _( "Invalid track width" ) );
83  m_trackWidthText->SetFocus();
84  return false;
85  }
86 
87  if( m_viaDiameter.GetValue() <= 0 )
88  {
89  DisplayError( GetParent(), _( "Invalid via diameter" ) );
90  m_viaDiameterText->SetFocus();
91  return false;
92  }
93 
94  if( m_viaDrill.GetValue() <= 0 )
95  {
96  DisplayError( GetParent(), _( "Invalid via drill size" ) );
97  m_viaDrillText->SetFocus();
98  return false;
99  }
100 
102  {
103  DisplayError( GetParent(), _( "Via drill size has to be smaller than via diameter" ) );
104  m_viaDrillText->SetFocus();
105  return false;
106  }
107 
108  return true;
109 }
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
void SetCustomViaDrill(int aDrill)
Function SetCustomViaDrill Sets custom size for via drill (i.e.
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool TransferDataFromWindow() override
virtual int GetValue() const
Function GetValue Returns the current value in Internal Units.
Definition: unit_binder.cpp:64
void SetCustomViaSize(int aSize)
Function SetCustomViaSize Sets custom size for via diameter (i.e.
bool check()
Checks if values given in the dialog are sensible.
int GetCustomViaSize() const
Function GetCustomViaSize.
int GetCustomViaDrill() const
Function GetCustomViaDrill.
int GetCustomTrackWidth() const
Function GetCustomTrackWidth.
void SetCustomTrackWidth(int aWidth)
Function SetCustomTrackWidth Sets custom width for track (i.e.
bool TransferDataToWindow() override
BOARD_DESIGN_SETTINGS & m_settings
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
Definition: unit_binder.cpp:54
DIALOG_TRACK_VIA_SIZE(wxWindow *aParent, BOARD_DESIGN_SETTINGS &aSettings)
Constructor.
Class DIALOG_TRACK_VIA_SIZE_BASE.
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.