Make sure users don't run into min text size.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17543
This commit is contained in:
Jeff Young 2024-03-23 13:15:31 +00:00
parent 1c7e3871b5
commit fc572bfbc6
12 changed files with 32 additions and 30 deletions

View File

@ -380,8 +380,8 @@ void EDA_TEXT::SetTextSize( VECTOR2I aNewSize, bool aEnforceMinTextSize )
if( aEnforceMinTextSize )
{
int min = m_IuScale.get().MilsToIU( TEXT_MIN_SIZE_MILS );
int max = m_IuScale.get().MilsToIU( TEXT_MAX_SIZE_MILS );
int min = m_IuScale.get().mmToIU( TEXT_MIN_SIZE_MM );
int max = m_IuScale.get().mmToIU( TEXT_MAX_SIZE_MM );
aNewSize = VECTOR2I( alg::clamp( min, aNewSize.x, max ),
alg::clamp( min, aNewSize.y, max ) );
@ -396,8 +396,8 @@ void EDA_TEXT::SetTextSize( VECTOR2I aNewSize, bool aEnforceMinTextSize )
void EDA_TEXT::SetTextWidth( int aWidth )
{
int min = m_IuScale.get().MilsToIU( TEXT_MIN_SIZE_MILS );
int max = m_IuScale.get().MilsToIU( TEXT_MAX_SIZE_MILS );
int min = m_IuScale.get().mmToIU( TEXT_MIN_SIZE_MM );
int max = m_IuScale.get().mmToIU( TEXT_MAX_SIZE_MM );
m_attributes.m_Size.x = alg::clamp( min, aWidth, max );
ClearRenderCache();
@ -407,8 +407,8 @@ void EDA_TEXT::SetTextWidth( int aWidth )
void EDA_TEXT::SetTextHeight( int aHeight )
{
int min = m_IuScale.get().MilsToIU( TEXT_MIN_SIZE_MILS );
int max = m_IuScale.get().MilsToIU( TEXT_MAX_SIZE_MILS );
int min = m_IuScale.get().mmToIU( TEXT_MIN_SIZE_MM );
int max = m_IuScale.get().mmToIU( TEXT_MAX_SIZE_MM );
m_attributes.m_Size.y = alg::clamp( min, aHeight, max );
ClearRenderCache();

View File

@ -62,9 +62,8 @@
*/
/**
* @brief some define and functions to convert a value in mils, decimils or mm
* to the internal unit used in pcbnew, cvpcb or gerbview (nanometer or deci-mil)
* depending on compile time option
* @brief some macros and functions to convert a value in mils, decimils or mm to the internal
* unit used in pcbnew, cvpcb or gerbview (nanometer or deci-mil) depending on compile time option
*/
constexpr double GERB_IU_PER_MM = 1e5; // Gerbview IU is 10 nanometers.

View File

@ -38,9 +38,12 @@ class SHAPE_COMPOUND;
class SHAPE_POLY_SET;
// These are only here for algorithmic safety, not to tell the user what to do
#define TEXT_MIN_SIZE_MILS 1 ///< Minimum text size in mils
#define TEXT_MAX_SIZE_MILS 10000 ///< Maximum text size in mils (10 inches)
// These are only here for algorithmic safety, not to tell the user what to do.
// PL_EDITOR has the least resolution (its internal units are microns), so the min size is chosen
// to yield 1 in PL_EDITOR.
// The max size chosen is somewhat arbitrary, but no one has complained yet.
#define TEXT_MIN_SIZE_MM 0.001 ///< Minimum text size (1 micron).
#define TEXT_MAX_SIZE_MM 250.0 ///< Maximum text size in mm (~10 inches)
namespace KIGFX

View File

@ -677,8 +677,8 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS( JSON_SETTINGS* aParent, const std:
},
{} ) );
int minTextSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
int maxTextSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
int minTextSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
int maxTextSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
int minStroke = 1;
int maxStroke = pcbIUScale.mmToIU( 100 );

View File

@ -393,8 +393,8 @@ bool DIALOG_FOOTPRINT_PROPERTIES::Validate()
return false;
}
int minSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
int maxSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
int width = m_frame->ValueFromString( m_itemsGrid->GetCellValue( i, FPT_WIDTH ) );
int height = m_frame->ValueFromString( m_itemsGrid->GetCellValue( i, FPT_HEIGHT ) );

View File

@ -441,8 +441,8 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate()
return false;
}
int minSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
int maxSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
if( field.GetTextWidth() < minSize || field.GetTextWidth() > maxSize )
{

View File

@ -514,8 +514,8 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( BOARD_COMMIT& aCommit, BOA
bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
{
int minTextSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
int maxTextSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
int minTextSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
int maxTextSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
if( !m_textWidth.Validate( minTextSize, maxTextSize )
|| !m_textHeight.Validate( minTextSize, maxTextSize ) )

View File

@ -433,8 +433,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
if( !DIALOG_TEXT_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
int minSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
int maxSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
if( !m_textWidth.Validate( minSize, maxSize ) || !m_textHeight.Validate( minSize, maxSize ) )
return false;

View File

@ -292,8 +292,8 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
if( !DIALOG_TEXTBOX_PROPERTIES_BASE::TransferDataFromWindow() )
return false;
int minSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
int maxSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
if( !m_textWidth.Validate( minSize, maxSize ) || !m_textHeight.Validate( minSize, maxSize ) )
return false;

View File

@ -361,8 +361,8 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow()
// A minimal value for sizes and thickness:
const int minWidth = pcbIUScale.mmToIU( MINIMUM_LINE_WIDTH_MM );
const int maxWidth = pcbIUScale.mmToIU( MAXIMUM_LINE_WIDTH_MM );
const int minSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
const int maxSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
const int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
const int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
wxString errorsMsg;
for( int i = 0; i < ROW_COUNT; ++i )

View File

@ -205,8 +205,8 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow()
// A minimal value for sizes and thickness
const int minWidth = pcbIUScale.mmToIU( MINIMUM_LINE_WIDTH_MM );
const int maxWidth = pcbIUScale.mmToIU( MAXIMUM_LINE_WIDTH_MM );
const int minSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
const int maxSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
const int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
const int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
wxString errorsMsg;
UNITS_PROVIDER* unitProvider = m_Frame;

View File

@ -184,8 +184,8 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
{ "${REFERENCE}", true, F_Fab }
} ) ) );
int minTextSize = pcbIUScale.MilsToIU( TEXT_MIN_SIZE_MILS );
int maxTextSize = pcbIUScale.MilsToIU( TEXT_MAX_SIZE_MILS );
int minTextSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
int maxTextSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
int minStroke = 1;
int maxStroke = pcbIUScale.mmToIU( 100 );