DIALOG_PRINT_GENERIC: more easy to use user scale option. (not actual change for printing)
- fix an issue when trying to enter a scale < 1.0: such a scale starts by 0, that was rejected by the filter) - automatic clamp to user scale limits, to avoid many warnings to users. - if the user scale is out of bounds, warn the user before trying to print, not when opening the dialog.
This commit is contained in:
parent
a1f16f3681
commit
6577309de4
|
@ -30,7 +30,9 @@ static constexpr double MAX_SCALE = 100.0;
|
|||
DIALOG_PRINT_GENERIC::DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SETTINGS* aSettings )
|
||||
: DIALOG_PRINT_GENERIC_BASE( aParent ), m_config( nullptr ), m_settings( aSettings )
|
||||
{
|
||||
m_scaleValidator.SetRange( MIN_SCALE, MAX_SCALE );
|
||||
// Note: for the validator, min value is 0.0, to allow typing values like 0.5
|
||||
// that start by 0
|
||||
m_scaleValidator.SetRange( 0.0, MAX_SCALE );
|
||||
m_scaleCustomText->SetValidator( m_scaleValidator );
|
||||
|
||||
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
|
||||
|
@ -84,7 +86,7 @@ void DIALOG_PRINT_GENERIC::saveSettings()
|
|||
}
|
||||
|
||||
|
||||
double DIALOG_PRINT_GENERIC::getScaleValue() const
|
||||
double DIALOG_PRINT_GENERIC::getScaleValue()
|
||||
{
|
||||
if( m_scale1->GetValue() )
|
||||
return 1.0;
|
||||
|
@ -94,9 +96,30 @@ double DIALOG_PRINT_GENERIC::getScaleValue() const
|
|||
|
||||
if( m_scaleCustom->GetValue() )
|
||||
{
|
||||
double scale;
|
||||
double scale = 1.0;;
|
||||
|
||||
wxCHECK( m_scaleCustomText->GetValue().ToDouble( &scale ), 1.0 );
|
||||
if( !m_scaleCustomText->GetValue().ToDouble( &scale ) )
|
||||
{
|
||||
DisplayInfoMessage( nullptr, _( "Warning: Bad scale number" ) );
|
||||
scale = 1.0;
|
||||
}
|
||||
|
||||
if( scale > MAX_SCALE )
|
||||
{
|
||||
scale = MAX_SCALE;
|
||||
setScaleValue( scale );
|
||||
DisplayInfoMessage( nullptr,
|
||||
wxString::Format( _( "Warning: Scale option set to a very large value.\n"
|
||||
" Clamped to %f" ), scale ) );
|
||||
}
|
||||
else if( scale < MIN_SCALE )
|
||||
{
|
||||
scale = MIN_SCALE;
|
||||
setScaleValue( scale );
|
||||
DisplayInfoMessage( nullptr,
|
||||
wxString::Format( _( "Warning: Scale option set to a very small value.\n"
|
||||
" Clamped to %f" ), scale ) );
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
|
@ -118,14 +141,11 @@ void DIALOG_PRINT_GENERIC::setScaleValue( double aValue )
|
|||
}
|
||||
else
|
||||
{
|
||||
// Silently clamp the value (it comes from the config file).
|
||||
if( aValue > MAX_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( nullptr, _( "Warning: Scale option set to a very large value" ) );
|
||||
}
|
||||
aValue = MAX_SCALE;
|
||||
else if( aValue < MIN_SCALE )
|
||||
{
|
||||
DisplayInfoMessage( nullptr, _( "Warning: Scale option set to a very small value" ) );
|
||||
}
|
||||
aValue = MIN_SCALE;
|
||||
|
||||
m_scaleCustom->SetValue( true );
|
||||
m_scaleCustomText->SetValue( wxString::Format( wxT( "%f" ), aValue ) );
|
||||
|
|
|
@ -64,8 +64,9 @@ protected:
|
|||
|
||||
/**
|
||||
* Return scale value selected in the dialog.
|
||||
* if this value is outside limits, it will be clamped
|
||||
*/
|
||||
double getScaleValue() const;
|
||||
double getScaleValue();
|
||||
|
||||
/**
|
||||
* Select a corresponding scale radio button and update custom scale value if needed.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue