Improve SNR.

(cherry picked from commit d23ee7db3d)
This commit is contained in:
Jeff Young 2024-02-26 22:17:15 +00:00
parent 35192f5bd4
commit 50c5b56781
1 changed files with 68 additions and 108 deletions

View File

@ -165,73 +165,64 @@ wxSize PROPERTIES_FRAME::GetMinSize() const
} }
double fromMM( double aMMValue )
{
return EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, EDA_UNITS::MILLIMETRES, aMMValue );
}
double toMM( double aIUValue )
{
return EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, EDA_UNITS::MILLIMETRES, aIUValue );
}
bool validateMM( UNIT_BINDER& aUnitBinder, double aMin, double aMax )
{
return aUnitBinder.Validate( aMin, aMax, EDA_UNITS::MILLIMETRES );
}
void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel() void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel()
{ {
static EDA_UNITS units = EDA_UNITS::MILLIMETRES; DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
// Set default parameters // Set default parameters
m_defaultLineWidth.SetDoubleValue( m_defaultLineWidth.SetDoubleValue( fromMM( model.m_DefaultLineWidth ) );
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultLineWidth ) );
m_defaultTextSizeX.SetDoubleValue( m_defaultTextSizeX.SetDoubleValue( fromMM( model.m_DefaultTextSize.x ) );
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultTextSize.x ) ); m_defaultTextSizeY.SetDoubleValue( fromMM( model.m_DefaultTextSize.y ) );
m_defaultTextSizeY.SetDoubleValue( m_defaultTextThickness.SetDoubleValue( fromMM( model.m_DefaultTextThickness ) );
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultTextSize.y ) );
m_defaultTextThickness.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit(
drawSheetIUScale,units, model.m_DefaultTextThickness ) );
m_textLeftMargin.SetDoubleValue( m_textLeftMargin.SetDoubleValue( fromMM( model.GetLeftMargin() ) );
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetLeftMargin() ) ); m_textRightMargin.SetDoubleValue( fromMM( model.GetRightMargin() ) );
m_textRightMargin.SetDoubleValue( m_textTopMargin.SetDoubleValue( fromMM( model.GetTopMargin() ) );
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetRightMargin() ) ); m_textBottomMargin.SetDoubleValue( fromMM( model.GetBottomMargin() ) );
m_textTopMargin.SetDoubleValue(
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetTopMargin() ) );
m_textBottomMargin.SetDoubleValue(
EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetBottomMargin() ) );
} }
bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral() bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral()
{ {
static EDA_UNITS units = EDA_UNITS::MILLIMETRES; DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
// Import default parameters from widgets // Import default parameters from widgets
bool is_valid = m_defaultLineWidth.Validate( 0.0, 10.0, EDA_UNITS::MILLIMETRES ); if( validateMM( m_defaultLineWidth, 0.0, 10.0 ) )
model.m_DefaultLineWidth = toMM( m_defaultLineWidth.GetIntValue() );
if( is_valid ) if( validateMM( m_defaultTextSizeX, DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE ) )
model.m_DefaultLineWidth = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, model.m_DefaultTextSize.x = toMM( m_defaultTextSizeX.GetIntValue() );
m_defaultLineWidth.GetValue() );
is_valid = m_defaultTextSizeX.Validate( DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE, if( validateMM( m_defaultTextSizeY, DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE ) )
EDA_UNITS::MILLIMETRES ); model.m_DefaultTextSize.y = toMM( m_defaultTextSizeY.GetIntValue() );
if( is_valid )
model.m_DefaultTextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
m_defaultTextSizeX.GetValue() );
is_valid = m_defaultTextSizeY.Validate( DLG_MIN_TEXTSIZE, DLG_MAX_TEXTSIZE, if( validateMM( m_defaultTextThickness, 0.0, 5.0 ) )
EDA_UNITS::MILLIMETRES ); model.m_DefaultTextThickness = toMM( m_defaultTextThickness.GetIntValue() );
if( is_valid )
model.m_DefaultTextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
m_defaultTextSizeY.GetValue() );
is_valid = m_defaultTextThickness.Validate( 0.0, 5.0, EDA_UNITS::MILLIMETRES );
if( is_valid )
model.m_DefaultTextThickness = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
m_defaultTextThickness.GetValue() );
// Get page margins values // Get page margins values
model.SetRightMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, model.SetRightMargin( toMM( m_textRightMargin.GetIntValue() ) );
m_textRightMargin.GetValue() ) ); model.SetBottomMargin( toMM( m_textBottomMargin.GetIntValue() ) );
model.SetBottomMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, model.SetLeftMargin( toMM( m_textLeftMargin.GetIntValue() ) );
m_textBottomMargin.GetValue() ) ); model.SetTopMargin( toMM( m_textTopMargin.GetIntValue() ) );
model.SetLeftMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
m_textLeftMargin.GetValue() ) );
model.SetTopMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
m_textTopMargin.GetValue() ) );
return true; return true;
} }
@ -245,8 +236,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
return; return;
} }
static EDA_UNITS units = EDA_UNITS::MILLIMETRES; wxString msg;
wxString msg;
// Set parameters common to all DS_DATA_ITEM types // Set parameters common to all DS_DATA_ITEM types
m_staticTextType->SetLabel( aItem->GetClassName() ); m_staticTextType->SetLabel( aItem->GetClassName() );
@ -261,10 +251,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
} }
// Position/ start point // Position/ start point
m_textPosX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, m_textPosX.SetDoubleValue( fromMM( aItem->m_Pos.m_Pos.x ) );
aItem->m_Pos.m_Pos.x ) ); m_textPosY.SetDoubleValue( fromMM( aItem->m_Pos.m_Pos.y ) );
m_textPosY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
aItem->m_Pos.m_Pos.y ) );
switch( aItem->m_Pos.m_Anchor ) switch( aItem->m_Pos.m_Anchor )
{ {
@ -275,10 +263,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
} }
// End point // End point
m_textEndX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, m_textEndX.SetDoubleValue( fromMM( aItem->m_End.m_Pos.x ) );
aItem->m_End.m_Pos.x ) ); m_textEndY.SetDoubleValue( fromMM( aItem->m_End.m_Pos.y ) );
m_textEndY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
aItem->m_End.m_Pos.y ) );
switch( aItem->m_End.m_Anchor ) switch( aItem->m_End.m_Anchor )
{ {
@ -288,8 +274,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
case LT_CORNER: m_comboBoxCornerEnd->SetSelection( 1 ); break; case LT_CORNER: m_comboBoxCornerEnd->SetSelection( 1 ); break;
} }
m_lineWidth.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, m_lineWidth.SetDoubleValue( fromMM( aItem->m_LineWidth ) );
aItem->m_LineWidth ) );
// Now, set prms more specific to DS_DATA_ITEM types // Now, set prms more specific to DS_DATA_ITEM types
// For a given type, disable widgets which are not relevant, // For a given type, disable widgets which are not relevant,
@ -312,10 +297,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
m_textCtrlRotation->SetValue( msg ); m_textCtrlRotation->SetValue( msg );
// Constraints: // Constraints:
m_constraintX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, m_constraintX.SetDoubleValue( fromMM( item->m_BoundingBoxSize.x ) );
item->m_BoundingBoxSize.x ) ); m_constraintY.SetDoubleValue( fromMM( item->m_BoundingBoxSize.y ) );
m_constraintY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
item->m_BoundingBoxSize.y ) );
// Font Options // Font Options
m_fontCtrl->SetFontSelection( item->m_Font ); m_fontCtrl->SetFontSelection( item->m_Font );
@ -346,10 +329,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
} }
// Text size // Text size
m_textSizeX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, m_textSizeX.SetDoubleValue( fromMM( item->m_TextSize.x ) );
item->m_TextSize.x ) ); m_textSizeY.SetDoubleValue( fromMM( item->m_TextSize.y ) );
m_textSizeY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
item->m_TextSize.y ) );
} }
if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON ) if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON )
@ -402,10 +383,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem )
msg.Printf( wxT( "%d" ), aItem->m_RepeatCount ); msg.Printf( wxT( "%d" ), aItem->m_RepeatCount );
m_textCtrlRepeatCount->SetValue( msg ); m_textCtrlRepeatCount->SetValue( msg );
m_textStepX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, m_textStepX.SetDoubleValue( fromMM( aItem->m_IncrementVector.x ) );
aItem->m_IncrementVector.x ) ); m_textStepY.SetDoubleValue( fromMM( aItem->m_IncrementVector.y ) );
m_textStepY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units,
aItem->m_IncrementVector.y ) );
// The number of widgets was modified, so recalculate sizers // The number of widgets was modified, so recalculate sizers
m_swItemProperties->Layout(); m_swItemProperties->Layout();
@ -497,8 +476,7 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
if( aItem == nullptr ) if( aItem == nullptr )
return false; return false;
const EDA_UNITS units = EDA_UNITS::MILLIMETRES; wxString msg;
wxString msg;
// Import common parameters: // Import common parameters:
aItem->m_Info = m_textCtrlComment->GetValue(); aItem->m_Info = m_textCtrlComment->GetValue();
@ -512,17 +490,12 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
} }
// Import thickness // Import thickness
bool is_valid = m_lineWidth.Validate( 0.0, 10.0, EDA_UNITS::MILLIMETRES ); if( validateMM( m_lineWidth, 0.0, 10.0 ) )
aItem->m_LineWidth = toMM( m_lineWidth.GetIntValue() );
if( is_valid )
aItem->m_LineWidth =
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_lineWidth.GetValue() );
// Import Start point // Import Start point
aItem->m_Pos.m_Pos.x = aItem->m_Pos.m_Pos.x = toMM( m_textPosX.GetIntValue() );
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textPosX.GetValue() ); aItem->m_Pos.m_Pos.y = toMM( m_textPosY.GetIntValue() );
aItem->m_Pos.m_Pos.y =
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textPosY.GetValue() );
switch( m_comboBoxCornerPos->GetSelection() ) switch( m_comboBoxCornerPos->GetSelection() )
{ {
@ -533,10 +506,8 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
} }
// Import End point // Import End point
aItem->m_End.m_Pos.x = aItem->m_End.m_Pos.x = toMM( m_textEndX.GetIntValue() );
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textEndX.GetValue() ); aItem->m_End.m_Pos.y = toMM( m_textEndY.GetIntValue() );
aItem->m_End.m_Pos.y =
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textEndY.GetValue() );
switch( m_comboBoxCornerEnd->GetSelection() ) switch( m_comboBoxCornerEnd->GetSelection() )
{ {
@ -562,10 +533,8 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
aItem->m_RepeatCount = itmp; aItem->m_RepeatCount = itmp;
aItem->m_IncrementVector.x = aItem->m_IncrementVector.x = toMM( m_textStepX.GetIntValue() );
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textStepX.GetValue() ); aItem->m_IncrementVector.y = toMM( m_textStepY.GetIntValue() );
aItem->m_IncrementVector.y =
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textStepY.GetValue() );
if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT ) if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT )
{ {
@ -603,22 +572,15 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
EDA_UNITS::UNSCALED, msg ); EDA_UNITS::UNSCALED, msg );
// Import text size // Import text size
is_valid = m_textSizeX.Validate( 0.0, DLG_MAX_TEXTSIZE, EDA_UNITS::MILLIMETRES ); if( validateMM( m_textSizeX, 0.0, DLG_MAX_TEXTSIZE ) )
item->m_TextSize.x = toMM( m_textSizeX.GetIntValue() );
if( is_valid ) if( validateMM( m_textSizeY, 0.0, DLG_MAX_TEXTSIZE ) )
item->m_TextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, item->m_TextSize.y = toMM( m_textSizeY.GetIntValue() );
m_textSizeX.GetValue() );
is_valid = m_textSizeY.Validate( 0.0, DLG_MAX_TEXTSIZE, EDA_UNITS::MILLIMETRES );
if( is_valid )
item->m_TextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units,
m_textSizeY.GetValue() );
// Import constraints: // Import constraints:
item->m_BoundingBoxSize.x = item->m_BoundingBoxSize.x = toMM( m_constraintX.GetIntValue() );
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_constraintX.GetValue() ); item->m_BoundingBoxSize.y = toMM( m_constraintY.GetIntValue() );
item->m_BoundingBoxSize.y =
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_constraintY.GetValue() );
} }
if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON ) if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON )
@ -626,9 +588,7 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem )
DS_DATA_ITEM_POLYGONS* item = static_cast<DS_DATA_ITEM_POLYGONS*>( aItem ); DS_DATA_ITEM_POLYGONS* item = static_cast<DS_DATA_ITEM_POLYGONS*>( aItem );
msg = m_textCtrlRotation->GetValue(); msg = m_textCtrlRotation->GetValue();
item->m_Orient = EDA_ANGLE( item->m_Orient = m_parent->AngleValueFromString( msg );
EDA_UNIT_UTILS::UI::DoubleValueFromString( drawSheetIUScale,EDA_UNITS::UNSCALED,
msg ), DEGREES_T );
} }
if( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP ) if( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP )