2023-10-06 18:40:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2023-10-15 16:02:15 +00:00
|
|
|
#include "dialog_tuning_pattern_properties.h"
|
2023-10-06 18:40:49 +00:00
|
|
|
#include <bitmaps.h>
|
2023-10-11 10:48:43 +00:00
|
|
|
#include <pcb_base_edit_frame.h>
|
|
|
|
#include <board_design_settings.h>
|
|
|
|
#include <drc/drc_engine.h>
|
2023-10-06 18:40:49 +00:00
|
|
|
|
2023-10-11 10:48:43 +00:00
|
|
|
|
2023-10-15 16:02:15 +00:00
|
|
|
DIALOG_TUNING_PATTERN_PROPERTIES::DIALOG_TUNING_PATTERN_PROPERTIES( PCB_BASE_EDIT_FRAME* aFrame,
|
|
|
|
PNS::MEANDER_SETTINGS& aSettings,
|
|
|
|
PNS::ROUTER_MODE aMeanderType,
|
|
|
|
const DRC_CONSTRAINT& aConstraint ) :
|
|
|
|
DIALOG_TUNING_PATTERN_PROPERTIES_BASE( aFrame ),
|
2023-10-11 10:48:43 +00:00
|
|
|
m_constraint( aConstraint ),
|
|
|
|
m_targetLength( aFrame, m_targetLengthLabel, m_targetLengthCtrl, m_targetLengthUnits ),
|
2023-10-06 18:40:49 +00:00
|
|
|
m_minA( aFrame, m_track_minALabel, m_minACtrl, m_minAUnits ),
|
|
|
|
m_maxA( aFrame, m_maxALabel, m_maxACtrl, m_maxAUnits ),
|
|
|
|
m_spacing( aFrame, m_spacingLabel, m_spacingCtrl, m_spacingUnits ),
|
|
|
|
m_r( aFrame, m_rLabel, m_rCtrl, m_rUnits ),
|
2023-10-15 13:13:32 +00:00
|
|
|
m_settings( aSettings ),
|
|
|
|
m_mode( aMeanderType )
|
2023-10-06 18:40:49 +00:00
|
|
|
{
|
|
|
|
m_r.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
|
2023-10-15 13:13:32 +00:00
|
|
|
switch( m_mode )
|
2023-10-06 18:40:49 +00:00
|
|
|
{
|
|
|
|
case PNS::PNS_MODE_TUNE_SINGLE:
|
2023-10-21 18:56:19 +00:00
|
|
|
m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_single_track_length_legend ) );
|
2023-10-06 18:40:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PNS::PNS_MODE_TUNE_DIFF_PAIR:
|
2023-10-21 18:56:19 +00:00
|
|
|
m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_length_legend ) );
|
2023-10-06 18:40:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW:
|
2023-10-21 18:56:19 +00:00
|
|
|
m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_skew_legend ) );
|
2023-10-15 13:13:32 +00:00
|
|
|
m_targetLengthLabel->SetLabel( _( "Target skew: ") );
|
2023-10-06 18:40:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bitmap has a new size, so recalculate sizes
|
2023-10-11 10:48:43 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2023-10-06 18:40:49 +00:00
|
|
|
SetupStandardButtons();
|
|
|
|
|
2023-10-11 10:48:43 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2023-10-06 18:40:49 +00:00
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-15 16:02:15 +00:00
|
|
|
bool DIALOG_TUNING_PATTERN_PROPERTIES::TransferDataToWindow()
|
2023-10-06 18:40:49 +00:00
|
|
|
{
|
2023-10-15 13:13:32 +00:00
|
|
|
if( m_mode == PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW )
|
2023-10-16 23:27:08 +00:00
|
|
|
m_targetLength.SetValue( m_settings.m_targetSkew.Opt() );
|
2023-10-15 13:13:32 +00:00
|
|
|
else
|
2023-10-16 23:27:08 +00:00
|
|
|
m_targetLength.SetValue( m_settings.m_targetLength.Opt() );
|
2023-10-15 13:13:32 +00:00
|
|
|
|
2023-12-30 20:27:03 +00:00
|
|
|
if( m_targetLength.GetValue() == std::numeric_limits<int>::max() )
|
|
|
|
m_targetLengthCtrl->SetValue( wxEmptyString );
|
|
|
|
|
2023-10-11 10:48:43 +00:00
|
|
|
m_overrideCustomRules->SetValue( m_settings.m_overrideCustomRules );
|
|
|
|
|
|
|
|
m_targetLength.Enable( m_constraint.IsNull() || m_settings.m_overrideCustomRules );
|
|
|
|
|
|
|
|
if( !m_constraint.IsNull() )
|
|
|
|
m_sourceInfo->SetLabel( wxString::Format( _( "(from %s)" ), m_constraint.GetName() ) );
|
|
|
|
|
|
|
|
m_sourceInfo->Show( !m_constraint.IsNull() && !m_settings.m_overrideCustomRules );
|
|
|
|
|
2023-10-06 18:40:49 +00:00
|
|
|
m_minA.SetValue( m_settings.m_minAmplitude );
|
|
|
|
m_maxA.SetValue( m_settings.m_maxAmplitude );
|
|
|
|
m_spacing.SetValue( m_settings.m_spacing );
|
|
|
|
m_cornerCtrl->SetSelection( m_settings.m_cornerStyle == PNS::MEANDER_STYLE_ROUND ? 1 : 0 );
|
|
|
|
m_r.SetValue( m_settings.m_cornerRadiusPercentage );
|
|
|
|
m_singleSided->SetValue( m_settings.m_singleSided );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-15 16:02:15 +00:00
|
|
|
bool DIALOG_TUNING_PATTERN_PROPERTIES::TransferDataFromWindow()
|
2023-10-06 18:40:49 +00:00
|
|
|
{
|
2023-12-30 20:27:03 +00:00
|
|
|
if(! m_targetLengthCtrl->GetValue().IsEmpty() )
|
2023-10-16 23:27:08 +00:00
|
|
|
{
|
2023-12-30 20:27:03 +00:00
|
|
|
if( m_mode == PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW )
|
|
|
|
{
|
|
|
|
if( m_targetLength.GetValue() != m_constraint.GetValue().Opt() )
|
|
|
|
m_settings.SetTargetSkew( m_targetLength.GetValue() );
|
|
|
|
else
|
|
|
|
m_settings.m_targetSkew = m_constraint.GetValue();
|
|
|
|
}
|
2023-10-16 23:27:08 +00:00
|
|
|
else
|
2023-12-30 20:27:03 +00:00
|
|
|
{
|
|
|
|
if( m_targetLength.GetValue() != m_constraint.GetValue().Opt() )
|
|
|
|
m_settings.SetTargetLength( m_targetLength.GetValue() );
|
|
|
|
else
|
|
|
|
m_settings.SetTargetLength( m_constraint.GetValue() );
|
|
|
|
}
|
2023-10-16 23:27:08 +00:00
|
|
|
}
|
2023-10-15 13:13:32 +00:00
|
|
|
|
2023-10-11 10:48:43 +00:00
|
|
|
m_settings.m_overrideCustomRules = m_overrideCustomRules->GetValue();
|
|
|
|
|
2023-10-06 18:40:49 +00:00
|
|
|
m_settings.m_minAmplitude = m_minA.GetIntValue();
|
|
|
|
m_settings.m_maxAmplitude = m_maxA.GetIntValue();
|
|
|
|
m_settings.m_spacing = m_spacing.GetIntValue();
|
|
|
|
m_settings.m_cornerStyle = m_cornerCtrl->GetSelection() ? PNS::MEANDER_STYLE_ROUND
|
|
|
|
: PNS::MEANDER_STYLE_CHAMFER;
|
2023-10-11 10:48:43 +00:00
|
|
|
m_settings.m_cornerRadiusPercentage = m_r.GetIntValue();
|
2023-10-06 18:40:49 +00:00
|
|
|
m_settings.m_singleSided = m_singleSided->GetValue();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2023-10-11 10:48:43 +00:00
|
|
|
|
|
|
|
|
2023-10-15 16:02:15 +00:00
|
|
|
void DIALOG_TUNING_PATTERN_PROPERTIES::onOverrideCustomRules( wxCommandEvent& event )
|
2023-10-11 10:48:43 +00:00
|
|
|
{
|
|
|
|
m_targetLength.Enable( event.IsChecked() || m_constraint.IsNull() );
|
|
|
|
|
|
|
|
if( !event.IsChecked() && !m_constraint.IsNull() )
|
|
|
|
{
|
|
|
|
m_targetLength.SetValue( m_constraint.GetValue().Opt() );
|
|
|
|
m_sourceInfo->Show( true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_sourceInfo->Show( false );
|
|
|
|
}
|
2023-10-21 18:56:19 +00:00
|
|
|
}
|