7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-07 21:55:32 +00:00

Readability improvements.

This commit is contained in:
Jeff Young 2022-09-19 10:25:20 +01:00
parent 8599323dce
commit 45d6b4a9fc
76 changed files with 692 additions and 844 deletions
3d-viewer/dialogs
common
eeschema
gerbview
include
pagelayout_editor
pcbnew

View File

@ -222,8 +222,7 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
*/
static double rotationFromString( const wxString& aValue )
{
double rotation =
EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::DEGREES, aValue );
double rotation = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES, aValue );
if( rotation > MAX_ROTATION )
{
@ -251,7 +250,7 @@ wxString PANEL_PREVIEW_3D_MODEL::formatRotationValue( double aValue )
{
return wxString::Format( wxT( "%.2f%s" ),
aValue,
EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
}
@ -265,7 +264,7 @@ wxString PANEL_PREVIEW_3D_MODEL::formatOffsetValue( double aValue )
return wxString::Format( wxT( "%.6f%s" ),
aValue,
EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( m_userUnits ) );
EDA_UNIT_UTILS::GetText( m_userUnits ) );
}
@ -393,7 +392,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aS
else if( spinCtrl == m_spinZrot )
textCtrl = zrot;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::DEGREES,
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
textCtrl->GetValue() );
curr_value += ( ROTATION_INCREMENT * aSign );
@ -468,7 +467,7 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event )
if( event.GetWheelRotation() >= 0 )
step = -step;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::DEGREES,
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
textCtrl->GetValue() );
curr_value += step;

View File

@ -118,10 +118,8 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow()
gridCfg.last_size_idx = m_currentGridCtrl->GetSelection();
m_parent->SetGridOrigin( wxPoint( m_gridOriginX.GetValue(), m_gridOriginY.GetValue() ) );
gridCfg.user_grid_x = EDA_UNIT_UTILS::UI::StringFromValue( m_parent->GetIuScale(), GetUserUnits(),
m_userGridX.GetValue(), true );
gridCfg.user_grid_y = EDA_UNIT_UTILS::UI::StringFromValue( m_parent->GetIuScale(), GetUserUnits(),
m_userGridY.GetValue(), true );
gridCfg.user_grid_x = m_parent->StringFromValue( m_userGridX.GetValue(), true );
gridCfg.user_grid_y = m_parent->StringFromValue( m_userGridY.GetValue(), true );
gridCfg.fast_grid_1 = m_grid1Ctrl->GetSelection();
gridCfg.fast_grid_2 = m_grid2Ctrl->GetSelection();
@ -150,10 +148,8 @@ bool DIALOG_GRID_SETTINGS::TransferDataToWindow()
m_currentGridCtrl->SetSelection( settings->m_Window.grid.last_size_idx );
m_userGridX.SetValue( EDA_UNIT_UTILS::UI::ValueFromString( m_parent->GetIuScale(),
GetUserUnits(), gridCfg.user_grid_x ) );
m_userGridY.SetValue( EDA_UNIT_UTILS::UI::ValueFromString( m_parent->GetIuScale(),
GetUserUnits(), gridCfg.user_grid_y ) );
m_userGridX.SetValue( m_parent->ValueFromString( gridCfg.user_grid_x ) );
m_userGridY.SetValue( m_parent->ValueFromString( gridCfg.user_grid_y ) );
m_gridOriginX.SetValue( m_parent->GetGridOrigin().x );
m_gridOriginY.SetValue( m_parent->GetGridOrigin().y );

View File

@ -26,19 +26,18 @@
#include <algorithm>
#include <pgm_base.h>
#include <base_units.h>
#include <eda_draw_frame.h>
#include <bitmaps.h>
#include <netclass.h>
#include <confirm.h>
#include <grid_tricks.h>
#include <dialogs/panel_setup_netclasses.h>
#include "widgets/wx_html_report_box.h"
#include <tool/tool_manager.h>
#include <widgets/wx_grid.h>
#include <string_utils.h>
#include <widgets/grid_color_swatch_helpers.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_html_report_box.h>
#include <widgets/wx_grid.h>
#include <wx/treebook.h>
#include <project/net_settings.h>
@ -231,14 +230,12 @@ void PANEL_SETUP_NETCLASSES::onUnitsChanged( wxCommandEvent& aEvent )
bool PANEL_SETUP_NETCLASSES::TransferDataToWindow()
{
EDA_UNITS units = m_frame->GetUserUnits();
int row = 0;
int row = 0;
auto setCell =
[&]( int aRow, int aCol, int aValue )
{
m_netclassGrid->SetCellValue( aRow, aCol,
EDA_UNIT_UTILS::UI::StringFromValue( m_frame->GetIuScale(), units, aValue, true ) );
m_netclassGrid->SetCellValue( aRow, aCol, m_frame->StringFromValue( aValue, true ) );
};
auto netclassToGridRow =
@ -336,13 +333,12 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow()
if( !Validate() )
return false;
EDA_UNITS units = m_frame->GetUserUnits();
int row = 0;
int row = 0;
auto getCell =
[this, units]( int aRow, int aCol ) -> long long int
[this]( int aRow, int aCol ) -> long long int
{
return EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(),units, m_netclassGrid->GetCellValue( aRow, aCol ) );
return m_frame->ValueFromString( m_netclassGrid->GetCellValue( aRow, aCol ) );
};
auto getCellStr =

View File

@ -139,19 +139,17 @@ void DS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
aList.emplace_back( _( "First Page Option" ), msg );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), EDA_UNITS::UNSCALED,
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED,
dataItem->m_RepeatCount );
aList.emplace_back( _( "Repeat Count" ), msg );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), EDA_UNITS::UNSCALED,
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED,
dataItem->m_IncrementLabel );
aList.emplace_back( _( "Repeat Label Increment" ), msg );
msg.Printf( wxT( "(%s, %s)" ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), aFrame->GetUserUnits(),
dataItem->m_IncrementVector.x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), aFrame->GetUserUnits(),
dataItem->m_IncrementVector.y ) );
aFrame->MessageTextFromValue( dataItem->m_IncrementVector.x ),
aFrame->MessageTextFromValue( dataItem->m_IncrementVector.y ) );
aList.emplace_back( _( "Repeat Position Increment" ), msg );

View File

@ -576,14 +576,11 @@ void EDA_DRAW_FRAME::DisplayConstraintsMsg( const wxString& msg )
void EDA_DRAW_FRAME::DisplayGridMsg()
{
wxString line;
wxString msg;
line.Printf( "grid %s", EDA_UNIT_UTILS::UI::MessageTextFromValue(
GetIuScale(), GetUserUnits(),
GetCanvas()->GetGAL()->GetGridSize().x,
false ) );
msg.Printf( "grid %s", MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x, false ) );
SetStatusText( line, 4 );
SetStatusText( msg, 4 );
}

View File

@ -563,7 +563,6 @@ void EDA_SHAPE::SetArcAngleAndEnd( const EDA_ANGLE& aAngle, bool aCheckNegativeA
void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
EDA_UNITS units = aFrame->GetUserUnits();
ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();
wxString msg;
@ -573,9 +572,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
{
case SHAPE_T::CIRCLE:
aList.emplace_back( shape, _( "Circle" ) );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units, GetRadius() );
aList.emplace_back( _( "Radius" ), msg );
aList.emplace_back( _( "Radius" ), aFrame->MessageTextFromValue( GetRadius() ) );
break;
case SHAPE_T::ARC:
@ -584,15 +581,12 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( GetArcAngle() );
aList.emplace_back( _( "Angle" ), msg );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units, GetRadius() );
aList.emplace_back( _( "Radius" ), msg );
aList.emplace_back( _( "Radius" ), aFrame->MessageTextFromValue( GetRadius() ) );
break;
case SHAPE_T::BEZIER:
aList.emplace_back( shape, _( "Curve" ) );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units, GetLength() );
aList.emplace_back( _( "Length" ), msg );
aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( GetLength() ) );
break;
case SHAPE_T::POLY:
@ -608,22 +602,19 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
else
aList.emplace_back( shape, _( "Rectangle" ) );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units,
std::abs( GetEnd().x - GetStart().x ) );
aList.emplace_back( _( "Width" ), msg );
aList.emplace_back( _( "Width" ),
aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units,
std::abs( GetEnd().y - GetStart().y ) );
aList.emplace_back( _( "Height" ), msg );
aList.emplace_back( _( "Height" ),
aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) );
break;
case SHAPE_T::SEGMENT:
{
aList.emplace_back( shape, _( "Segment" ) );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units,
GetLineLength( GetStart(), GetEnd() ) );
aList.emplace_back( _( "Length" ), msg );
aList.emplace_back( _( "Length" ),
aFrame->MessageTextFromValue( GetLineLength( GetStart(), GetEnd() ) ));
// angle counter-clockwise from 3'o-clock
EDA_ANGLE angle( atan2( (double)( GetStart().y - GetEnd().y ),
@ -637,7 +628,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
break;
}
m_stroke.GetMsgPanelInfo( aFrame->GetIuScale(), units, aList );
m_stroke.GetMsgPanelInfo( aFrame->GetIuScale(), aFrame->GetUserUnits(), aList );
}

View File

@ -99,26 +99,26 @@ void EDA_UNIT_UTILS::FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS
}
wxString EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( EDA_UNITS aUnits, EDA_DATA_TYPE aType )
wxString EDA_UNIT_UTILS::GetText( EDA_UNITS aUnits, EDA_DATA_TYPE aType )
{
wxString label;
switch( aUnits )
{
case EDA_UNITS::MILLIMETRES: label = wxT( " mm" ); break;
case EDA_UNITS::DEGREES: label = wxT( "°" ); break;
case EDA_UNITS::MILS: label = wxT( " mils" ); break;
case EDA_UNITS::INCHES: label = wxT( " in" ); break;
case EDA_UNITS::PERCENT: label = wxT( "%" ); break;
case EDA_UNITS::UNSCALED: break;
default: UNIMPLEMENTED_FOR( "Unknown units" ); break;
case EDA_UNITS::MILLIMETRES: label = wxT( " mm" ); break;
case EDA_UNITS::DEGREES: label = wxT( "°" ); break;
case EDA_UNITS::MILS: label = wxT( " mils" ); break;
case EDA_UNITS::INCHES: label = wxT( " in" ); break;
case EDA_UNITS::PERCENT: label = wxT( "%" ); break;
case EDA_UNITS::UNSCALED: break;
default: UNIMPLEMENTED_FOR( "Unknown units" ); break;
}
switch( aType )
{
case EDA_DATA_TYPE::VOLUME: label += wxT( "³" ); break;
case EDA_DATA_TYPE::AREA: label += wxT( "²" ); break;
case EDA_DATA_TYPE::DISTANCE: break;
case EDA_DATA_TYPE::VOLUME: label += wxT( "³" ); break;
case EDA_DATA_TYPE::AREA: label += wxT( "²" ); break;
case EDA_DATA_TYPE::DISTANCE: break;
default: UNIMPLEMENTED_FOR( "Unknown measurement" ); break;
}
@ -126,6 +126,12 @@ wxString EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( EDA_UNITS aUnits, EDA_DATA_TY
}
wxString EDA_UNIT_UTILS::GetLabel( EDA_UNITS aUnits, EDA_DATA_TYPE aType )
{
return GetText( aUnits, aType ).Trim( false );
}
std::string EDA_UNIT_UTILS::FormatAngle( const EDA_ANGLE& aAngle )
{
std::string temp = fmt::format( "{:.10g}", aAngle.AsDegrees() );
@ -225,7 +231,7 @@ double EDA_UNIT_UTILS::UI::ToUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS a
* in internal units, and therefore modified.
*/
wxString EDA_UNIT_UTILS::UI::StringFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
double aValue, bool aAddUnitSymbol,
double aValue, bool aAddUnitsText,
EDA_DATA_TYPE aType )
{
double value_to_print = aValue;
@ -263,8 +269,8 @@ wxString EDA_UNIT_UTILS::UI::StringFromValue( const EDA_IU_SCALE& aIuScale, EDA_
wxString stringValue( buf, wxConvUTF8 );
if( aAddUnitSymbol )
stringValue += EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits, aType );
if( aAddUnitsText )
stringValue += EDA_UNIT_UTILS::GetText( aUnits, aType );
return stringValue;
}
@ -315,7 +321,7 @@ wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( EDA_ANGLE aValue, bool aAddUn
// A lower-precision (for readability) version of StringFromValue()
wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits,
double aValue, bool aAddUnitLabel,
double aValue, bool aAddUnitsText,
EDA_DATA_TYPE aType )
{
wxString text;
@ -377,8 +383,8 @@ wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale,
text.Printf( format, value );
if( aAddUnitLabel )
text += EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits, aType );
if( aAddUnitsText )
text += EDA_UNIT_UTILS::GetText( aUnits, aType );
return text;
}

View File

@ -56,7 +56,7 @@ wxString KIGFX::PREVIEW::DimensionLabel( const wxString& prefix, double aVal,
str << wxString::Format( fmtStr, EDA_UNIT_UTILS::UI::ToUserUnit( aIuScale, aUnits, aVal ) );
if( aIncludeUnits )
str << EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits );
str << EDA_UNIT_UTILS::GetText( aUnits );
return str;
}

View File

@ -54,20 +54,21 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason )
m_frame = getEditFrame<EDA_DRAW_FRAME>();
GRID_SETTINGS& settings = m_toolMgr->GetSettings()->m_Window.grid;
EDA_IU_SCALE scale = m_frame->GetIuScale();
m_grids.clear();
for( const wxString& gridDef : settings.sizes )
{
int gridSize = (int) EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(), EDA_UNITS::MILLIMETRES, gridDef );
int gridSize = (int) EDA_UNIT_UTILS::UI::ValueFromString( scale, EDA_UNITS::MILLIMETRES,
gridDef );
m_grids.emplace_back( gridSize, gridSize );
}
m_grids.emplace_back(
EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(), EDA_UNITS::MILLIMETRES,
settings.user_grid_x ),
EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(), EDA_UNITS::MILLIMETRES,
settings.user_grid_y ) );
m_grids.emplace_back( EDA_UNIT_UTILS::UI::ValueFromString( scale, EDA_UNITS::MILLIMETRES,
settings.user_grid_x ),
EDA_UNIT_UTILS::UI::ValueFromString( scale, EDA_UNITS::MILLIMETRES,
settings.user_grid_y ) );
OnGridChanged();
}

View File

@ -85,35 +85,33 @@ void GRID_MENU::update()
void GRID_MENU::BuildChoiceList( wxArrayString* aGridsList, APP_SETTINGS_BASE* aCfg,
EDA_DRAW_FRAME* aParent )
{
wxString msg;
EDA_UNITS primaryUnit;
EDA_UNITS secondaryUnit;
wxString msg;
EDA_IU_SCALE scale = aParent->GetIuScale();
EDA_UNITS primaryUnit;
EDA_UNITS secondaryUnit;
aParent->GetUnitPair( primaryUnit, secondaryUnit );
for( const wxString& gridSize : aCfg->m_Window.grid.sizes )
{
int val = (int) EDA_UNIT_UTILS::UI::ValueFromString( aParent->GetIuScale(), EDA_UNITS::MILLIMETRES, gridSize );
int val = (int) EDA_UNIT_UTILS::UI::ValueFromString( scale, EDA_UNITS::MILLIMETRES,
gridSize );
msg.Printf(
_( "Grid: %s (%s)" ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), primaryUnit, val ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), secondaryUnit,
val ) );
msg.Printf( _( "Grid: %s (%s)" ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, primaryUnit, val ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, secondaryUnit, val ) );
aGridsList->Add( msg );
}
if( !aCfg->m_Window.grid.user_grid_x.empty() )
{
int val = (int) EDA_UNIT_UTILS::UI::ValueFromString( aParent->GetIuScale(),EDA_UNITS::INCHES,
int val = (int) EDA_UNIT_UTILS::UI::ValueFromString( scale, EDA_UNITS::INCHES,
aCfg->m_Window.grid.user_grid_x );
msg.Printf( _( "User grid: %s (%s)" ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), primaryUnit, val ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), secondaryUnit,
val ) );
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, primaryUnit, val ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( scale, secondaryUnit, val ) );
aGridsList->Add( msg );
}

View File

@ -76,8 +76,7 @@ UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, const EDA_IU_SCALE& aIUScale,
}
if( m_unitLabel )
m_unitLabel->SetLabel(
EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
m_unitLabel->SetLabel( EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ) );
m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
nullptr, this );
@ -105,8 +104,7 @@ void UNIT_BINDER::SetUnits( EDA_UNITS aUnits )
m_units = aUnits;
if( m_unitLabel )
m_unitLabel->SetLabel(
EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
m_unitLabel->SetLabel( EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ) );
}
@ -121,8 +119,7 @@ void UNIT_BINDER::SetDataType( EDA_DATA_TYPE aDataType )
m_dataType = aDataType;
if( m_unitLabel )
m_unitLabel->SetLabel(
EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
m_unitLabel->SetLabel( EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ) );
}
@ -259,7 +256,8 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
double val_min_iu = EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMin );
m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
valueDescriptionFromLabel( m_label ),
EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, val_min_iu, true ) );
EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
val_min_iu, true ) );
textEntry->SelectAll();
@ -274,7 +272,8 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
double val_max_iu = EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMax );
m_errorMessage = wxString::Format( _( "%s must be less than %s." ),
valueDescriptionFromLabel( m_label ),
EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, val_max_iu, true ) );
EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
val_max_iu, true ) );
textEntry->SelectAll();
@ -290,29 +289,28 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits )
void UNIT_BINDER::SetValue( long long int aValue )
{
double value = aValue;
double displayValue = m_originTransforms.ToDisplay( value, m_coordType );
double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue,
false, m_dataType );
if( displayValue == 0 && m_negativeZero )
SetValue( wxT( "-" ) + EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue, false, m_dataType ) );
SetValue( wxT( "-" ) + textValue );
else
SetValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue,
false, m_dataType ) );
SetValue( textValue );
}
void UNIT_BINDER::SetDoubleValue( double aValue )
{
double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
displayValue = setPrecision( displayValue, false );
double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
setPrecision( displayValue, false ),
false, m_dataType );
if( displayValue == 0 && m_negativeZero )
SetValue( wxT( "-" )
+ EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
displayValue, false, m_dataType ) );
SetValue( wxT( "-" ) + textValue );
else
SetValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue,
false, m_dataType ) );
SetValue( textValue );
}
@ -336,38 +334,35 @@ void UNIT_BINDER::SetValue( const wxString& aValue )
m_eval.Clear();
if( m_unitLabel )
m_unitLabel->SetLabel(
EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
m_unitLabel->SetLabel( EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ) );
}
void UNIT_BINDER::ChangeValue( int aValue )
{
double value = aValue;
double displayValue = m_originTransforms.ToDisplay( value, m_coordType );
double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
setPrecision( displayValue, false ),
false, m_dataType );
if( displayValue == 0 && m_negativeZero )
ChangeValue( wxT( "-" )
+ EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
displayValue, false ) );
ChangeValue( wxT( "-" ) + textValue );
else
ChangeValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
displayValue, false ) );
ChangeValue( textValue );
}
void UNIT_BINDER::ChangeDoubleValue( double aValue )
{
double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
displayValue = setPrecision( displayValue, false );
double displayValue = m_originTransforms.ToDisplay( aValue, m_coordType );
wxString textValue = EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
setPrecision( displayValue, false ),
false, m_dataType );
if( displayValue == 0 && m_negativeZero )
ChangeValue( wxT( "-" )
+ EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
displayValue, false, m_dataType ) );
ChangeValue( wxT( "-" ) + textValue );
else
ChangeValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units,
displayValue, false, m_dataType ) );
ChangeValue( textValue );
}
@ -391,8 +386,7 @@ void UNIT_BINDER::ChangeValue( const wxString& aValue )
m_eval.Clear();
if( m_unitLabel )
m_unitLabel->SetLabel(
EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
m_unitLabel->SetLabel( EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ) );
}
@ -418,7 +412,8 @@ long long int UNIT_BINDER::GetValue()
return 0;
}
long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( m_iuScale, m_units, value, m_dataType );
long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( m_iuScale, m_units, value,
m_dataType );
return m_originTransforms.FromDisplay( displayValue, m_coordType );
}

View File

@ -136,10 +136,10 @@ public:
wxString GetValue( int aRow, int aCol ) override
{
return GetValue( m_rows[ aRow ], aCol, m_frame->GetUserUnits() );
return GetValue( m_rows[ aRow ], aCol, m_frame );
}
static wxString GetValue( const LIB_PINS& pins, int aCol, EDA_UNITS aUserUnits )
static wxString GetValue( const LIB_PINS& pins, int aCol, EDA_DRAW_FRAME* aParentFrame )
{
wxString fieldValue;
@ -179,28 +179,23 @@ public:
break;
case COL_NUMBER_SIZE:
val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits,
pin->GetNumberTextSize(), true );
val = aParentFrame->StringFromValue( pin->GetNumberTextSize(), true );
break;
case COL_NAME_SIZE:
val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits,
pin->GetNameTextSize(), true );
val = aParentFrame->StringFromValue( pin->GetNameTextSize(), true );
break;
case COL_LENGTH:
val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits,
pin->GetLength(), true );
val = aParentFrame->StringFromValue( pin->GetLength(), true );
break;
case COL_POSX:
val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits,
pin->GetPosition().x, true );
val = aParentFrame->StringFromValue( pin->GetPosition().x, true );
break;
case COL_POSY:
val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits,
-pin->GetPosition().y, true );
val = aParentFrame->StringFromValue( -pin->GetPosition().y, true );
break;
case COL_VISIBLE:
@ -259,11 +254,13 @@ public:
LIB_PINS pins = m_rows[ aRow ];
// If the NUMBER column is edited and the pins are grouped, renumber, and add or remove pins based on the comma separated list of pins.
// If the NUMBER column is edited and the pins are grouped, renumber, and add or
// remove pins based on the comma separated list of pins.
if( aCol == COL_NUMBER && m_pinTable->IsDisplayGrouped() )
{
wxStringTokenizer tokenizer( aValue, "," );
size_t i = 0;
while( tokenizer.HasMoreTokens() )
{
wxString pinName = tokenizer.GetNextToken();
@ -308,10 +305,9 @@ public:
i++;
}
while( i < pins.size() )
while( pins.size() > i )
{
LIB_PIN* pin = pins.back();
m_pinTable->RemovePin( pin );
m_pinTable->RemovePin( pins.back() );
pins.pop_back();
}
@ -430,17 +426,17 @@ public:
}
static bool compare( const LIB_PINS& lhs, const LIB_PINS& rhs, int sortCol, bool ascending,
EDA_UNITS units )
EDA_DRAW_FRAME* parentFrame )
{
wxString lhStr = GetValue( lhs, sortCol, units );
wxString rhStr = GetValue( rhs, sortCol, units );
wxString lhStr = GetValue( lhs, sortCol, parentFrame );
wxString rhStr = GetValue( rhs, sortCol, parentFrame );
if( lhStr == rhStr )
{
// Secondary sort key is always COL_NUMBER
sortCol = COL_NUMBER;
lhStr = GetValue( lhs, sortCol, units );
rhStr = GetValue( rhs, sortCol, units );
lhStr = GetValue( lhs, sortCol, parentFrame );
rhStr = GetValue( rhs, sortCol, parentFrame );
}
bool res;
@ -463,14 +459,14 @@ public:
break;
case COL_NUMBER_SIZE:
case COL_NAME_SIZE:
res = cmp( EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, lhStr ),
EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, rhStr ) );
res = cmp( parentFrame->ValueFromString( lhStr ),
parentFrame->ValueFromString( rhStr ) );
break;
case COL_LENGTH:
case COL_POSX:
case COL_POSY:
res = cmp( EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, lhStr ),
EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, rhStr ) );
res = cmp( parentFrame->ValueFromString( lhStr ),
parentFrame->ValueFromString( rhStr ) );
break;
case COL_VISIBLE:
case COL_DEMORGAN:
@ -578,7 +574,7 @@ public:
std::sort( m_rows.begin(), m_rows.end(),
[ aSortCol, ascending, this ]( const LIB_PINS& lhs, const LIB_PINS& rhs ) -> bool
{
return compare( lhs, rhs, aSortCol, ascending, m_frame->GetUserUnits() );
return compare( lhs, rhs, aSortCol, ascending, m_frame );
} );
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2022 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
@ -100,20 +100,15 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow()
m_suffixCtrl->ChangeValue( settings.m_IntersheetRefsSuffix );
m_listOwnPage->SetValue( settings.m_IntersheetRefsListOwnPage );
m_textOffsetRatioCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, EDA_UNITS::PERCENT,
settings.m_TextOffsetRatio * 100.0 ) );
#define SET_VALUE( ctrl, units, value ) \
ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
schIUScale, EDA_UNITS::UNSCALED,
settings.m_DashedLineDashRatio ) );
SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, settings.m_TextOffsetRatio * 100.0 );
SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineDashRatio );
SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineGapRatio );
SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, settings.m_LabelSizeRatio * 100.0 );
m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
schIUScale, EDA_UNITS::UNSCALED,
settings.m_DashedLineGapRatio ) );
m_labelSizeRatioCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
schIUScale, EDA_UNITS::PERCENT,
settings.m_LabelSizeRatio * 100.0 ) );
#undef SET_VALUE
return true;
}
@ -157,21 +152,14 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow()
settings.m_IntersheetRefsSuffix = m_suffixCtrl->GetValue();
settings.m_IntersheetRefsListOwnPage = m_listOwnPage->GetValue();
settings.m_TextOffsetRatio =
EDA_UNIT_UTILS::UI::DoubleValueFromString( schIUScale, EDA_UNITS::PERCENT,
m_textOffsetRatioCtrl->GetValue() )
/ 100.0;
#define GET_VALUE( units, str ) EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, units, str )
settings.m_DashedLineDashRatio = EDA_UNIT_UTILS::UI::DoubleValueFromString(
schIUScale, EDA_UNITS::UNSCALED, m_dashLengthCtrl->GetValue() );
settings.m_TextOffsetRatio = GET_VALUE( EDA_UNITS::PERCENT, m_textOffsetRatioCtrl->GetValue() ) / 100.0;
settings.m_DashedLineDashRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_dashLengthCtrl->GetValue() );
settings.m_DashedLineGapRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_gapLengthCtrl->GetValue() );
settings.m_LabelSizeRatio = GET_VALUE( EDA_UNITS::PERCENT, m_labelSizeRatioCtrl->GetValue() ) / 100.0;
settings.m_DashedLineGapRatio = EDA_UNIT_UTILS::UI::DoubleValueFromString(
schIUScale, EDA_UNITS::UNSCALED, m_gapLengthCtrl->GetValue() );
settings.m_LabelSizeRatio =
EDA_UNIT_UTILS::UI::DoubleValueFromString( schIUScale, EDA_UNITS::PERCENT,
m_labelSizeRatioCtrl->GetValue() )
/ 100.0;
#undef GET_VALUE
return true;
}
@ -190,17 +178,13 @@ void PANEL_SETUP_FORMATTING::ImportSettingsFrom( SCHEMATIC_SETTINGS& aSettings )
m_suffixCtrl->ChangeValue( aSettings.m_IntersheetRefsSuffix );
m_listOwnPage->SetValue( aSettings.m_IntersheetRefsListOwnPage );
wxString offsetRatio = wxString::Format( "%f", aSettings.m_TextOffsetRatio * 100.0 );
m_textOffsetRatioCtrl->SetValue( offsetRatio );
#define SET_VALUE( ctrl, units, value ) \
ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
wxString labelSizeRatio = wxString::Format( "%f", aSettings.m_LabelSizeRatio * 100.0 );
m_labelSizeRatioCtrl->SetValue( labelSizeRatio );
SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_TextOffsetRatio * 100.0 );
SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineDashRatio );
SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, aSettings.m_DashedLineGapRatio );
SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, aSettings.m_LabelSizeRatio * 100.0 );
m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
schIUScale, EDA_UNITS::UNSCALED,
aSettings.m_DashedLineDashRatio ) );
m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue(
schIUScale, EDA_UNITS::UNSCALED,
aSettings.m_DashedLineGapRatio ) );
#undef SET_VALUE
}

View File

@ -583,7 +583,7 @@ wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
return StringFromBool( field.IsBold() );
case FDC_TEXT_SIZE:
return EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, m_frame->GetUserUnits(), field.GetTextHeight(), true );
return m_frame->StringFromValue( field.GetTextHeight(), true );
case FDC_ORIENTATION:
if( field.GetTextAngle().IsHorizontal() )
@ -592,12 +592,10 @@ wxString FIELDS_GRID_TABLE<T>::GetValue( int aRow, int aCol )
return _( "Vertical" );
case FDC_POSX:
return EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, m_frame->GetUserUnits(),
field.GetTextPos().x, true );
return m_frame->StringFromValue( field.GetTextPos().x, true );
case FDC_POSY:
return EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, m_frame->GetUserUnits(),
field.GetTextPos().y, true );
return m_frame->StringFromValue( field.GetTextPos().y, true );
case FDC_FONT:
if( field.GetFont() )

View File

@ -532,8 +532,7 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
aList.emplace_back( _( "Style" ), GetTextStyleName() );
aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(),
GetTextWidth() ) );
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
switch ( GetHorizJustify() )
{

View File

@ -1141,8 +1141,6 @@ void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset
void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
EDA_UNITS units = aFrame->GetUserUnits();
LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) );
@ -1153,7 +1151,7 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
aList.emplace_back( _( "Style" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
// Display pin length
aList.emplace_back( _( "Length" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, m_length, true ) );
aList.emplace_back( _( "Length" ), aFrame->MessageTextFromValue( m_length, true ) );
int i = PinOrientationIndex( m_orientation );
aList.emplace_back( _( "Orientation" ), PinOrientationName( (unsigned) i ) );
@ -1161,8 +1159,8 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
VECTOR2I pinpos = GetPosition();
pinpos.y = -pinpos.y; // Display coords are top to bottom; lib item coords are bottom to top
aList.emplace_back( _( "Pos X" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, pinpos.x, true ) );
aList.emplace_back( _( "Pos Y" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, pinpos.y, true ) );
aList.emplace_back( _( "Pos X" ), aFrame->MessageTextFromValue( pinpos.x, true ) );
aList.emplace_back( _( "Pos Y" ), aFrame->MessageTextFromValue( pinpos.y, true ) );
}

View File

@ -391,8 +391,7 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
aList.emplace_back( _( "Style" ), GetTextStyleName() );
aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(),
GetTextWidth() ) );
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
switch ( GetHorizJustify() )
{

View File

@ -447,8 +447,6 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOf
void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
EDA_UNITS units = aFrame->GetUserUnits();
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
@ -458,15 +456,15 @@ void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
aList.emplace_back( _( "Style" ), textStyle[style] );
aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, GetTextWidth() ) );
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
wxString msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, std::abs( GetEnd().x - GetStart().x ) );
wxString msg = aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) );
aList.emplace_back( _( "Box Width" ), msg );
msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, std::abs( GetEnd().y - GetStart().y ) );
msg = aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) );
aList.emplace_back( _( "Box Height" ), msg );
m_stroke.GetMsgPanelInfo( schIUScale, units, aList );
m_stroke.GetMsgPanelInfo( schIUScale, aFrame->GetUserUnits(), aList );
}

View File

@ -184,16 +184,14 @@ void SCH_BASE_FRAME::UpdateStatusBar()
VECTOR2D d = cursorPos - screen->m_LocalOrigin;
line.Printf( "X %s Y %s",
EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(),
cursorPos.x, false ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), cursorPos.y, false ) );
MessageTextFromValue( cursorPos.x, false ),
MessageTextFromValue( cursorPos.y, false ) );
SetStatusText( line, 2 );
line.Printf( "dx %s dy %s dist %s",
EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), d.x, false ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), d.y, false ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(),
hypot( d.x, d.y ), false ) );
MessageTextFromValue( d.x, false ),
MessageTextFromValue( d.y, false ),
MessageTextFromValue( hypot( d.x, d.y ), false ) );
SetStatusText( line, 3 );
DisplayGridMsg();

View File

@ -204,8 +204,8 @@ void SCH_BITMAP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
{
aList.emplace_back( _( "Bitmap" ), wxEmptyString );
aList.emplace_back( _( "Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetSize().x ) );
aList.emplace_back( _( "Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetSize().y ) );
aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( GetSize().x ) );
aList.emplace_back( _( "Height" ), aFrame->MessageTextFromValue( GetSize().y ) );
}

View File

@ -725,8 +725,7 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
aList.emplace_back( _( "Style" ), GetTextStyleName() );
aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(),
GetTextWidth() ) );
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
switch ( GetHorizJustify() )
{

View File

@ -853,8 +853,7 @@ void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
aList.emplace_back( _( "Style" ), textStyle[style] );
aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(),
GetTextWidth() ) );
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
switch( GetTextSpinStyle() )
{

View File

@ -1429,29 +1429,30 @@ void SCH_ALTIUM_PLUGIN::ParseEllipse( const std::map<wxString, wxString>& aPrope
// To do: Import true ellipses when KiCad supports them
if( elem.Radius != elem.SecondaryRadius )
{
m_reporter->Report(
wxString::Format( _( "Unsupported ellipse was not imported at (X = %d; Y = %d)." ),
( elem.Center + m_sheetOffset ).x, ( elem.Center + m_sheetOffset ).y ),
RPT_SEVERITY_ERROR );
m_reporter->Report( wxString::Format( _( "Unsupported ellipse was not imported at "
"(X = %d; Y = %d)." ),
( elem.Center + m_sheetOffset ).x,
( elem.Center + m_sheetOffset ).y ),
RPT_SEVERITY_ERROR );
return;
}
if( elem.OwnerPartID == ALTIUM_COMPONENT_NONE )
{
SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE );
SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE );
circle->SetPosition( elem.Center + m_sheetOffset );
circle->SetEnd( circle->GetPosition() + VECTOR2I( elem.Radius, 0 ) );
circle->SetStroke( STROKE_PARAMS( 0.1, PLOT_DASH_TYPE::SOLID ) );
circle->SetPosition( elem.Center + m_sheetOffset );
circle->SetEnd( circle->GetPosition() + VECTOR2I( elem.Radius, 0 ) );
circle->SetStroke( STROKE_PARAMS( 1, PLOT_DASH_TYPE::SOLID ) );
circle->SetFillColor( GetColorFromInt( elem.AreaColor ) );
circle->SetFillColor( GetColorFromInt( elem.AreaColor ) );
if( elem.IsSolid )
circle->SetFillMode( FILL_T::FILLED_WITH_COLOR );
else
circle->SetFilled( false );
if( elem.IsSolid )
circle->SetFillMode( FILL_T::FILLED_WITH_COLOR );
else
circle->SetFilled( false );
m_currentSheet->GetScreen()->Append( circle );
m_currentSheet->GetScreen()->Append( circle );
}
else
{
@ -1460,9 +1461,9 @@ void SCH_ALTIUM_PLUGIN::ParseEllipse( const std::map<wxString, wxString>& aPrope
if( libSymbolIt == m_libSymbols.end() )
{
// TODO: e.g. can depend on Template (RECORD=39
m_reporter->Report(
wxString::Format( wxT( "Ellipse's owner (%d) not found." ), elem.OwnerIndex ),
RPT_SEVERITY_DEBUG );
m_reporter->Report( wxString::Format( wxT( "Ellipse's owner (%d) not found." ),
elem.OwnerIndex ),
RPT_SEVERITY_DEBUG );
return;
}
@ -1475,7 +1476,7 @@ void SCH_ALTIUM_PLUGIN::ParseEllipse( const std::map<wxString, wxString>& aPrope
circle->SetPosition( GetRelativePosition( elem.Center + m_sheetOffset, symbol ) );
circle->SetEnd( circle->GetPosition() + VECTOR2I( elem.Radius, 0 ) );
circle->SetStroke( STROKE_PARAMS( 0.1, PLOT_DASH_TYPE::SOLID ) );
circle->SetStroke( STROKE_PARAMS( 1, PLOT_DASH_TYPE::SOLID ) );
circle->SetFillColor( GetColorFromInt( elem.AreaColor ) );

View File

@ -498,8 +498,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
aList.emplace_back( _( "Style" ), textStyle[style] );
aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(),
GetTextWidth() ) );
aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
switch( GetTextSpinStyle() )
{

View File

@ -23,8 +23,7 @@
#include <vector>
#include <sch_symbol.h>
#include <base_units.h>
#include <math/util.h> // for KiROUND
#include <eda_draw_frame.h>
// helper function to sort pins by pin num
static bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst );
@ -40,10 +39,10 @@ static bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst );
* @param aMessages is a room to store error messages
* @param aGridForPins (in IU) is the grid to test pin positions ( >= 25 mils )
* should be 25, 50 or 100 mils (convered to IUs)
* @param aDisplayUnits is the unit to display coordinates in messages
* @param aUnitsProvider a frame to format coordinates in messages
*/
void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
int aGridForPins, EDA_UNITS aDisplayUnits )
int aGridForPins, EDA_DRAW_FRAME* aUnitsProvider )
{
if( !aSymbol )
return;
@ -116,12 +115,12 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" of converted." ),
next->GetNumber(),
nextName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
pin->GetNumber(),
pin->GetName(),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) );
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
}
else
{
@ -130,12 +129,12 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" in units %s and %s of converted." ),
next->GetNumber(),
nextName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
aSymbol->GetUnitReference( next->GetUnit() ),
aSymbol->GetUnitReference( pin->GetUnit() ) );
}
@ -148,12 +147,12 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" conflicts with pin %s%s at location <b>(%s, %s)</b>." ),
next->GetNumber(),
nextName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) );
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
}
else
{
@ -162,12 +161,12 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" in units %s and %s." ),
next->GetNumber(),
nextName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( next->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -next->GetPosition().y ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
aSymbol->GetUnitReference( next->GetUnit() ),
aSymbol->GetUnitReference( pin->GetUnit() ) );
}
@ -242,8 +241,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" of converted." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) );
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
}
else
{
@ -251,8 +250,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" in unit %c of converted." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1 );
}
}
@ -263,8 +262,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
msg.Printf( _( "Info: <b>Hidden power pin %s</b> %s at location <b>(%s, %s)</b>." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) );
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
}
else
{
@ -272,8 +271,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" in unit %c." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1 );
}
}
@ -296,8 +295,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" of converted." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) );
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
}
else
{
@ -305,8 +304,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" in unit %c of converted." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1 );
}
}
@ -317,8 +316,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
msg.Printf( _( "<b>Off grid pin %s</b> %s at location <b>(%s, %s)</b>." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) );
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ) );
}
else
{
@ -326,8 +325,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
" in unit %c." ),
pin->GetNumber(),
pinName,
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ),
EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ),
aUnitsProvider->MessageTextFromValue( pin->GetPosition().x ),
aUnitsProvider->MessageTextFromValue( -pin->GetPosition().y ),
'A' + pin->GetUnit() - 1 );
}
}

Some files were not shown because too many files have changed in this diff Show More