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 <boost/optional.hpp>
29 
31 
33  DIALOG_TRACK_VIA_SIZE_BASE( aParent ),
34  m_trackWidth( aParent, m_trackWidthText, m_trackWidthLabel ),
35  m_viaDiameter( aParent, m_viaDiameterText, m_viaDiameterLabel ),
36  m_viaDrill( aParent, m_viaDrillText, m_viaDrillLabel ),
37  m_settings( aSettings )
38 {
39  // Load router settings to dialog fields
43 
44  m_trackWidthText->SetFocus();
45  m_trackWidthText->SetSelection( -1, -1 );
46  m_stdButtonsOK->SetDefault();
47 
48  // Now all widgets have the size fixed, call FinishDialogSettings
50 
51  // Pressing ENTER when any of the text input fields is active applies changes
52  Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE::onOkClick ), NULL, this );
53 }
54 
55 
57 {
58  if( m_trackWidth.GetValue() <= 0 )
59  {
60  DisplayError( GetParent(), _( "Invalid track width" ) );
61  m_trackWidthText->SetFocus();
62  return false;
63  }
64 
65  if( m_viaDiameter.GetValue() <= 0 )
66  {
67  DisplayError( GetParent(), _( "Invalid via diameter" ) );
68  m_viaDiameterText->SetFocus();
69  return false;
70  }
71 
72  if( m_viaDrill.GetValue() <= 0 )
73  {
74  DisplayError( GetParent(), _( "Invalid via drill size" ) );
75  m_viaDrillText->SetFocus();
76  return false;
77  }
78 
80  {
81  DisplayError( GetParent(), _( "Via drill size has to be smaller than via diameter" ) );
82  m_viaDrillText->SetFocus();
83  return false;
84  }
85 
86  return true;
87 }
88 
89 
90 void DIALOG_TRACK_VIA_SIZE::onClose( wxCloseEvent& aEvent )
91 {
92  EndModal( 0 );
93 }
94 
95 
96 void DIALOG_TRACK_VIA_SIZE::onOkClick( wxCommandEvent& aEvent )
97 {
98  if( check() )
99  {
100  // Store dialog values to the router settings
104  EndModal( 1 );
105  }
106 }
107 
108 
109 void DIALOG_TRACK_VIA_SIZE::onCancelClick( wxCommandEvent& aEvent )
110 {
111  EndModal( 0 );
112 }
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...
void onOkClick(wxCommandEvent &aEvent) override
void SetCustomViaSize(int aSize)
Function SetCustomViaSize Sets custom size for via diameter (i.e.
void onCancelClick(wxCommandEvent &aEvent) override
bool check()
Checks if values given in the dialog are sensible.
int GetCustomViaSize() const
Function GetCustomViaSize.
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
int GetCustomViaDrill() const
Function GetCustomViaDrill.
int GetCustomTrackWidth() const
Function GetCustomTrackWidth.
void SetCustomTrackWidth(int aWidth)
Function SetCustomTrackWidth Sets custom width for track (i.e.
virtual int GetValue() const
Function GetValue Returns the current value in Internal Units.
BOARD_DESIGN_SETTINGS & m_settings
void onClose(wxCloseEvent &aEvent) override
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:69
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.