2014-05-14 13:53:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
|
|
|
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.or/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Push and Shove router track width and via size dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dialog_track_via_size.h"
|
|
|
|
#include <base_units.h>
|
|
|
|
#include <confirm.h>
|
2017-11-23 13:05:26 +00:00
|
|
|
#include <widgets/text_ctrl_eval.h>
|
2017-11-01 11:14:16 +00:00
|
|
|
#include <core/optional.h>
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2014-11-14 18:15:58 +00:00
|
|
|
#include "class_board_design_settings.h"
|
|
|
|
|
|
|
|
DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings ) :
|
2014-05-14 13:53:54 +00:00
|
|
|
DIALOG_TRACK_VIA_SIZE_BASE( aParent ),
|
2015-02-18 00:29:54 +00:00
|
|
|
m_trackWidth( aParent, m_trackWidthText, m_trackWidthLabel ),
|
|
|
|
m_viaDiameter( aParent, m_viaDiameterText, m_viaDiameterLabel ),
|
|
|
|
m_viaDrill( aParent, m_viaDrillText, m_viaDrillLabel ),
|
2014-05-14 13:53:54 +00:00
|
|
|
m_settings( aSettings )
|
|
|
|
{
|
|
|
|
// Load router settings to dialog fields
|
2015-02-18 00:29:54 +00:00
|
|
|
m_trackWidth.SetValue( m_settings.GetCustomTrackWidth() );
|
|
|
|
m_viaDiameter.SetValue( m_settings.GetCustomViaSize() );
|
|
|
|
m_viaDrill.SetValue( m_settings.GetCustomViaDrill() );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
m_trackWidthText->SetFocus();
|
2015-02-18 16:53:46 +00:00
|
|
|
m_trackWidthText->SetSelection( -1, -1 );
|
2015-02-18 00:29:54 +00:00
|
|
|
m_stdButtonsOK->SetDefault();
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-07-14 14:25:35 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
2015-03-13 16:48:42 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
// Pressing ENTER when any of the text input fields is active applies changes
|
2015-10-14 07:20:28 +00:00
|
|
|
Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE::onOkClick ), NULL, this );
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_TRACK_VIA_SIZE::check()
|
|
|
|
{
|
2015-07-09 11:35:50 +00:00
|
|
|
if( m_trackWidth.GetValue() <= 0 )
|
2015-06-15 15:54:58 +00:00
|
|
|
{
|
|
|
|
DisplayError( GetParent(), _( "Invalid track width" ) );
|
|
|
|
m_trackWidthText->SetFocus();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-09 11:35:50 +00:00
|
|
|
if( m_viaDiameter.GetValue() <= 0 )
|
2015-06-15 15:54:58 +00:00
|
|
|
{
|
|
|
|
DisplayError( GetParent(), _( "Invalid via diameter" ) );
|
|
|
|
m_viaDiameterText->SetFocus();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-09 11:35:50 +00:00
|
|
|
if( m_viaDrill.GetValue() <= 0 )
|
2015-06-15 15:54:58 +00:00
|
|
|
{
|
|
|
|
DisplayError( GetParent(), _( "Invalid via drill size" ) );
|
|
|
|
m_viaDrillText->SetFocus();
|
2014-05-14 13:53:54 +00:00
|
|
|
return false;
|
2015-06-15 15:54:58 +00:00
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
if( m_viaDrill.GetValue() >= m_viaDiameter.GetValue() )
|
2015-06-15 15:54:58 +00:00
|
|
|
{
|
|
|
|
DisplayError( GetParent(), _( "Via drill size has to be smaller than via diameter" ) );
|
|
|
|
m_viaDrillText->SetFocus();
|
2014-05-14 13:53:54 +00:00
|
|
|
return false;
|
2015-06-15 15:54:58 +00:00
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_SIZE::onClose( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
EndModal( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_SIZE::onOkClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( check() )
|
|
|
|
{
|
|
|
|
// Store dialog values to the router settings
|
2015-02-18 00:29:54 +00:00
|
|
|
m_settings.SetCustomTrackWidth( m_trackWidth.GetValue() );
|
|
|
|
m_settings.SetCustomViaSize( m_viaDiameter.GetValue() );
|
|
|
|
m_settings.SetCustomViaDrill( m_viaDrill.GetValue() );
|
2014-05-14 13:53:54 +00:00
|
|
|
EndModal( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_TRACK_VIA_SIZE::onCancelClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
EndModal( 0 );
|
|
|
|
}
|