Centralize min/opt/max printing.
This commit is contained in:
parent
55caa9c1e8
commit
2c02c26af4
|
@ -26,6 +26,7 @@
|
||||||
#include <math/util.h> // for KiROUND
|
#include <math/util.h> // for KiROUND
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
|
#include <wx/translation.h>
|
||||||
|
|
||||||
bool EDA_UNIT_UTILS::IsImperialUnit( EDA_UNITS aUnit )
|
bool EDA_UNIT_UTILS::IsImperialUnit( EDA_UNITS aUnit )
|
||||||
{
|
{
|
||||||
|
@ -425,6 +426,37 @@ wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString EDA_UNIT_UTILS::UI::MessageTextFromMinOptMax( const EDA_IU_SCALE& aIuScale,
|
||||||
|
EDA_UNITS aUnits,
|
||||||
|
const MINOPTMAX<int>& aValue )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
if( aValue.HasMin() && aValue.Min() > 0 )
|
||||||
|
{
|
||||||
|
msg += _( "min" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Min() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aValue.HasOpt() )
|
||||||
|
{
|
||||||
|
if( !msg.IsEmpty() )
|
||||||
|
msg += wxS( "; " );
|
||||||
|
|
||||||
|
msg += _( "opt" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Opt() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aValue.HasMax() )
|
||||||
|
{
|
||||||
|
if( !msg.IsEmpty() )
|
||||||
|
msg += wxS( "; " );
|
||||||
|
|
||||||
|
msg += _( "max" ) + wxS( " " ) + MessageTextFromValue( aIuScale, aUnits, aValue.Max() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
double EDA_UNIT_UTILS::UI::FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
|
double EDA_UNIT_UTILS::UI::FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
|
||||||
double aValue )
|
double aValue )
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <geometry/eda_angle.h>
|
#include <geometry/eda_angle.h>
|
||||||
#include <base_units.h>
|
#include <base_units.h>
|
||||||
|
#include <core/minoptmax.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of unit.
|
* The type of unit.
|
||||||
|
@ -216,10 +217,15 @@ namespace EDA_UNIT_UTILS
|
||||||
KICOMMON_API wxString MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel = true );
|
KICOMMON_API wxString MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel = true );
|
||||||
|
|
||||||
|
|
||||||
|
KICOMMON_API wxString MessageTextFromMinOptMax( const EDA_IU_SCALE& aIuScale,
|
||||||
|
EDA_UNITS aUnits,
|
||||||
|
const MINOPTMAX<int>& aValue );
|
||||||
/**
|
/**
|
||||||
* Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg"
|
* Return in internal units the value \a aValue given in a real unit such as "in", "mm",
|
||||||
|
* or "deg"
|
||||||
*/
|
*/
|
||||||
KICOMMON_API double FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnit, double aValue );
|
KICOMMON_API double FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnit,
|
||||||
|
double aValue );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <eda_units.h>
|
#include <eda_units.h>
|
||||||
#include <origin_transforms.h>
|
#include <origin_transforms.h>
|
||||||
|
#include <core/minoptmax.h>
|
||||||
|
|
||||||
|
|
||||||
class UNITS_PROVIDER
|
class UNITS_PROVIDER
|
||||||
|
@ -111,6 +112,11 @@ public:
|
||||||
EDA_DATA_TYPE::DISTANCE );
|
EDA_DATA_TYPE::DISTANCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString MessageTextFromMinOptMax( const MINOPTMAX<int>& aValue ) const
|
||||||
|
{
|
||||||
|
return EDA_UNIT_UTILS::UI::MessageTextFromMinOptMax( GetIuScale(), GetUserUnits(), aValue );
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts \a aTextValue in \a aUnits to internal units used by the frame.
|
* Converts \a aTextValue in \a aUnits to internal units used by the frame.
|
||||||
* @warning This utilizes the current locale and will break if decimal formats differ
|
* @warning This utilizes the current locale and will break if decimal formats differ
|
||||||
|
|
|
@ -1572,35 +1572,6 @@ void PCB_GENERATOR_MEANDERS::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto getMinOptMax =
|
|
||||||
[&]( const MINOPTMAX<int>& v )
|
|
||||||
{
|
|
||||||
wxString msg;
|
|
||||||
|
|
||||||
if( v.HasMin() )
|
|
||||||
{
|
|
||||||
msg += wxString::Format( _( "min %s" ), aFrame->MessageTextFromValue( v.Min() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( v.HasOpt() )
|
|
||||||
{
|
|
||||||
if( !msg.IsEmpty() )
|
|
||||||
msg += wxS( "; " );
|
|
||||||
|
|
||||||
msg += wxString::Format( _( "opt %s" ), aFrame->MessageTextFromValue( v.Opt() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( v.HasMax() )
|
|
||||||
{
|
|
||||||
if( !msg.IsEmpty() )
|
|
||||||
msg += wxS( "; " );
|
|
||||||
|
|
||||||
msg += wxString::Format( _( "max %s" ), aFrame->MessageTextFromValue( v.Max() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
};
|
|
||||||
|
|
||||||
if( m_tuningMode == DIFF_PAIR_SKEW )
|
if( m_tuningMode == DIFF_PAIR_SKEW )
|
||||||
{
|
{
|
||||||
constraint = drcEngine->EvalRules( SKEW_CONSTRAINT, primaryItem, coupledItem, m_layer );
|
constraint = drcEngine->EvalRules( SKEW_CONSTRAINT, primaryItem, coupledItem, m_layer );
|
||||||
|
@ -1614,11 +1585,11 @@ void PCB_GENERATOR_MEANDERS::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg = getMinOptMax( constraint.GetValue() );
|
msg = aFrame->MessageTextFromMinOptMax( constraint.GetValue() );
|
||||||
|
|
||||||
if( !msg.IsEmpty() )
|
if( !msg.IsEmpty() )
|
||||||
{
|
{
|
||||||
aList.emplace_back( wxString::Format( _( "Skew Constraints: %s." ), msg ),
|
aList.emplace_back( wxString::Format( _( "Skew Constraints: %s" ), msg ),
|
||||||
wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
|
wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1636,11 +1607,11 @@ void PCB_GENERATOR_MEANDERS::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg = getMinOptMax( constraint.GetValue() );
|
msg = aFrame->MessageTextFromMinOptMax( constraint.GetValue() );
|
||||||
|
|
||||||
if( !msg.IsEmpty() )
|
if( !msg.IsEmpty() )
|
||||||
{
|
{
|
||||||
aList.emplace_back( wxString::Format( _( "Length Constraints: %s." ), msg ),
|
aList.emplace_back( wxString::Format( _( "Length Constraints: %s" ), msg ),
|
||||||
wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
|
wxString::Format( _( "(from %s)" ), constraint.GetName() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1877,8 +1848,8 @@ static struct PCB_GENERATOR_MEANDERS_DESC
|
||||||
{
|
{
|
||||||
ENUM_MAP<LENGTH_TUNING_MODE>::Instance()
|
ENUM_MAP<LENGTH_TUNING_MODE>::Instance()
|
||||||
.Map( LENGTH_TUNING_MODE::SINGLE, _HKI( "Single track" ) )
|
.Map( LENGTH_TUNING_MODE::SINGLE, _HKI( "Single track" ) )
|
||||||
.Map( LENGTH_TUNING_MODE::DIFF_PAIR, _HKI( "Diff. pair" ) )
|
.Map( LENGTH_TUNING_MODE::DIFF_PAIR, _HKI( "Differential pair" ) )
|
||||||
.Map( LENGTH_TUNING_MODE::DIFF_PAIR_SKEW, _HKI( "Diff. pair Skew" ) );
|
.Map( LENGTH_TUNING_MODE::DIFF_PAIR_SKEW, _HKI( "Diff pair skew" ) );
|
||||||
|
|
||||||
ENUM_MAP<PNS::MEANDER_SIDE>::Instance()
|
ENUM_MAP<PNS::MEANDER_SIDE>::Instance()
|
||||||
.Map( PNS::MEANDER_SIDE_LEFT, _HKI( "Left" ) )
|
.Map( PNS::MEANDER_SIDE_LEFT, _HKI( "Left" ) )
|
||||||
|
|
|
@ -904,19 +904,12 @@ void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
|
||||||
aFrame->MessageTextFromValue( clearance ) ),
|
aFrame->MessageTextFromValue( clearance ) ),
|
||||||
wxString::Format( _( "(from %s)" ), source ) );
|
wxString::Format( _( "(from %s)" ), source ) );
|
||||||
|
|
||||||
MINOPTMAX<int> c = GetWidthConstraint( &source );
|
MINOPTMAX<int> constraintValue = GetWidthConstraint( &source );
|
||||||
|
msg = aFrame->MessageTextFromMinOptMax( constraintValue );
|
||||||
|
|
||||||
if( c.HasMax() )
|
if( !msg.IsEmpty() )
|
||||||
{
|
{
|
||||||
aList.emplace_back( wxString::Format( _( "Width Constraints: min %s, max %s" ),
|
aList.emplace_back( wxString::Format( _( "Width Constraints: %s" ), msg ),
|
||||||
aFrame->MessageTextFromValue( c.Min() ),
|
|
||||||
aFrame->MessageTextFromValue( c.Max() ) ),
|
|
||||||
wxString::Format( _( "(from %s)" ), source ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aList.emplace_back( wxString::Format( _( "Width Constraints: min %s" ),
|
|
||||||
aFrame->MessageTextFromValue( c.Min() ) ),
|
|
||||||
wxString::Format( _( "(from %s)" ), source ) );
|
wxString::Format( _( "(from %s)" ), source ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue