mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 13:41:43 +00:00
Factor common parts of SCH_ & LIB_SYMBOL into SYMBOL.
This commit is contained in:
parent
bf2b3b0b0f
commit
92910d5d0f
common
eeschema
CMakeLists.txtconnection_graph.cpp
dialogs
dialog_field_properties.cppdialog_lib_shape_properties.cppdialog_lib_symbol_properties.cppdialog_lib_text_properties.cppdialog_lib_textbox_properties.cppdialog_pin_properties.cppdialog_plot_schematic.cppdialog_sim_model.cppdialog_symbol_properties.cpppanel_eeschema_color_settings.cpp
eeschema_jobs_handler.cppeeschema_jobs_handler.herc.cpplib_field.cpplib_field.hlib_item.cpplib_item.hlib_pin.cpplib_pin.hlib_shape.cpplib_shape.hlib_symbol.cpplib_symbol.hlib_text.cpplib_text.hlib_textbox.cpplib_textbox.hprinting
sch_base_frame.cppsch_base_frame.hsch_bitmap.cppsch_bitmap.hsch_bus_entry.cppsch_bus_entry.hsch_commit.cppsch_edit_frame.cppsch_field.cppsch_field.hsch_io
sch_item.cppsch_item.hsch_junction.cppsch_junction.hsch_label.cppsch_label.hsch_line.cppsch_line.hsch_marker.cppsch_marker.hsch_no_connect.cppsch_no_connect.hsch_painter.cppsch_painter.hsch_pin.cppsch_pin.hsch_preview_panel.cppsch_preview_panel.hsch_render_settings.cppsch_render_settings.hsch_screen.cppsch_screen.hsch_shape.cppsch_shape.hsch_sheet.cppsch_sheet.hsch_sheet_path.cppsch_sheet_pin.cppsch_sheet_pin.hsch_symbol.cppsch_symbol.hsch_table.cppsch_table.hsch_tablecell.cppsch_tablecell.hsch_text.cppsch_text.hsch_textbox.cppsch_textbox.hsheet.cppsymbol.cppsymbol.hsymbol_editor
symbol_viewer_frame.cpptools
symbol_editor_control.cppsymbol_editor_drawing_tools.cppsymbol_editor_edit_tool.cppsymbol_editor_pin_tool.cpp
widgets
include
@ -203,9 +203,9 @@ LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM( LIB_TREE_NODE* aParent, LIB_TREE_ITEM* a
|
||||
|
||||
m_IsRoot = aItem->IsRoot();
|
||||
|
||||
if( aItem->GetUnitCount() > 1 )
|
||||
if( aItem->GetSubUnitCount() > 1 )
|
||||
{
|
||||
for( int u = 1; u <= aItem->GetUnitCount(); ++u )
|
||||
for( int u = 1; u <= aItem->GetSubUnitCount(); ++u )
|
||||
AddUnit( aItem, u );
|
||||
}
|
||||
}
|
||||
@ -234,7 +234,7 @@ void LIB_TREE_NODE_ITEM::Update( LIB_TREE_ITEM* aItem )
|
||||
m_IsRoot = aItem->IsRoot();
|
||||
m_Children.clear();
|
||||
|
||||
for( int u = 1; u <= aItem->GetUnitCount(); ++u )
|
||||
for( int u = 1; u <= aItem->GetSubUnitCount(); ++u )
|
||||
AddUnit( aItem, u );
|
||||
}
|
||||
|
||||
|
@ -394,6 +394,7 @@ set( EESCHEMA_SRCS
|
||||
sch_plotter.cpp
|
||||
sch_preview_panel.cpp
|
||||
sch_reference_list.cpp
|
||||
sch_render_settings.cpp
|
||||
sch_screen.cpp
|
||||
sch_shape.cpp
|
||||
sch_sheet.cpp
|
||||
@ -410,6 +411,7 @@ set( EESCHEMA_SRCS
|
||||
schematic_settings.cpp
|
||||
schematic_undo_redo.cpp
|
||||
sheet.cpp
|
||||
symbol.cpp
|
||||
symbol_async_loader.cpp
|
||||
symbol_checker.cpp
|
||||
symbol_chooser_frame.cpp
|
||||
|
@ -107,8 +107,8 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCheckMultipleDrivers )
|
||||
SCH_PIN* pa = static_cast<SCH_PIN*>( a );
|
||||
SCH_PIN* pb = static_cast<SCH_PIN*>( b );
|
||||
|
||||
bool aPower = pa->GetLibPin()->GetParent()->IsPower();
|
||||
bool bPower = pb->GetLibPin()->GetParent()->IsPower();
|
||||
bool aPower = pa->GetLibPin()->GetParentSymbol()->IsPower();
|
||||
bool bPower = pb->GetLibPin()->GetParentSymbol()->IsPower();
|
||||
|
||||
if( aPower && !bPower )
|
||||
return true;
|
||||
@ -643,7 +643,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
|
||||
if( symbol->GetUnit() != new_unit )
|
||||
symbolsChanged.push_back( { symbol, symbol->GetUnit() } );
|
||||
|
||||
symbol->UpdateUnit( new_unit );
|
||||
symbol->SetUnit( new_unit );
|
||||
}
|
||||
}
|
||||
|
||||
@ -656,7 +656,7 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
|
||||
|
||||
// Restore the m_unit member variables where we had to change them
|
||||
for( const auto& [ symbol, originalUnit ] : symbolsChanged )
|
||||
symbol->UpdateUnit( originalUnit );
|
||||
symbol->SetUnit( originalUnit );
|
||||
}
|
||||
|
||||
// Restore the danlging states of items in the current SCH_SCREEN to match the current
|
||||
@ -1444,7 +1444,7 @@ void CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs()
|
||||
SCH_SHEET_PATH sheet = it.first;
|
||||
SCH_PIN* pin = it.second;
|
||||
|
||||
if( !pin->ConnectedItems( sheet ).empty() && !pin->GetLibPin()->GetParent()->IsPower() )
|
||||
if( !pin->ConnectedItems( sheet ).empty() && !pin->GetLibPin()->GetParentSymbol()->IsPower() )
|
||||
{
|
||||
// ERC will warn about this: user has wired up an invisible pin
|
||||
continue;
|
||||
@ -1459,7 +1459,7 @@ void CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs()
|
||||
// Proper modern power symbols get their net name from the value field
|
||||
// in the symbol, but we support legacy non-power symbols with global
|
||||
// power connections based on invisible, power-in, pin's names.
|
||||
if( pin->GetLibPin()->GetParent()->IsPower() )
|
||||
if( pin->GetLibPin()->GetParentSymbol()->IsPower() )
|
||||
connection->SetName( pin->GetParentSymbol()->GetValueFieldText( true, &sheet, false ) );
|
||||
else
|
||||
connection->SetName( pin->GetShownName() );
|
||||
@ -3465,7 +3465,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
|
||||
// net items by name, because usually failing to connect them graphically is a mistake
|
||||
if( pin && !has_other_connections
|
||||
&& !pin->IsGlobalPower()
|
||||
&& !pin->GetLibPin()->GetParent()->IsPower() )
|
||||
&& !pin->GetLibPin()->GetParentSymbol()->IsPower() )
|
||||
{
|
||||
wxString name = pin->Connection( &sheet )->Name();
|
||||
wxString local_name = pin->Connection( &sheet )->Name( true );
|
||||
@ -3504,7 +3504,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph
|
||||
// We only apply this test to power symbols, because other symbols have
|
||||
// pins that are meant to be dangling, but the power symbols have pins
|
||||
// that are *not* meant to be dangling.
|
||||
if( testPin->GetLibPin()->GetParent()->IsPower()
|
||||
if( testPin->GetLibPin()->GetParentSymbol()->IsPower()
|
||||
&& testPin->ConnectedItems( sheet ).empty()
|
||||
&& settings.IsTestEnabled( ERCE_PIN_NOT_CONNECTED ) )
|
||||
{
|
||||
|
@ -432,6 +432,8 @@ DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
||||
|
||||
if( m_fieldId == FOOTPRINT_FIELD )
|
||||
{
|
||||
const LIB_SYMBOL* parentSymbol = dynamic_cast<const LIB_SYMBOL*>( aField->GetParentSymbol() );
|
||||
|
||||
/*
|
||||
* Symbol netlist format:
|
||||
* pinNumber pinName <tab> pinNumber pinName...
|
||||
@ -441,7 +443,7 @@ DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
||||
|
||||
std::vector<LIB_PIN*> pinList;
|
||||
|
||||
aField->GetParent()->GetPins( pinList, 0, 1 ); // All units, but a single convert
|
||||
parentSymbol->GetPins( pinList, 0, 1 ); // All units, but a single convert
|
||||
|
||||
wxArrayString pins;
|
||||
|
||||
@ -453,7 +455,7 @@ DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
|
||||
|
||||
netlist << wxS( "\r" );
|
||||
|
||||
wxArrayString fpFilters = aField->GetParent()->GetFPFilters();
|
||||
wxArrayString fpFilters = parentSymbol->GetFPFilters();
|
||||
|
||||
if( !fpFilters.IsEmpty() )
|
||||
netlist << EscapeString( wxJoin( fpFilters, ' ' ), CTX_LINE );
|
||||
|
@ -97,7 +97,7 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow()
|
||||
if( !wxDialog::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
LIB_SYMBOL* symbol = m_shape->GetParent();
|
||||
const SYMBOL* symbol = m_shape->GetParentSymbol();
|
||||
|
||||
m_checkBorder->SetValue( m_shape->GetWidth() >= 0 );
|
||||
|
||||
|
@ -190,8 +190,8 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
m_excludeFromBomCheckBox->SetValue( m_libEntry->GetExcludedFromBOM() );
|
||||
m_excludeFromBoardCheckBox->SetValue( m_libEntry->GetExcludedFromBoard() );
|
||||
|
||||
m_ShowPinNumButt->SetValue( m_libEntry->ShowPinNumbers() );
|
||||
m_ShowPinNameButt->SetValue( m_libEntry->ShowPinNames() );
|
||||
m_ShowPinNumButt->SetValue( m_libEntry->GetShowPinNumbers() );
|
||||
m_ShowPinNameButt->SetValue( m_libEntry->GetShowPinNames() );
|
||||
m_PinsNameInsideButt->SetValue( m_libEntry->GetPinNameOffset() != 0 );
|
||||
m_pinNameOffset.ChangeValue( m_libEntry->GetPinNameOffset() );
|
||||
|
||||
|
@ -125,11 +125,9 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
wxCHECK( m_commonToAllUnits, false );
|
||||
|
||||
LIB_SYMBOL* symbol = nullptr;
|
||||
|
||||
if( m_graphicText )
|
||||
{
|
||||
symbol = m_graphicText->GetParent();
|
||||
const SYMBOL* symbol = m_graphicText->GetParentSymbol();
|
||||
|
||||
wxCHECK( symbol, false );
|
||||
|
||||
@ -144,8 +142,8 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
|
||||
m_bold->Check( m_graphicText->IsBold() );
|
||||
|
||||
m_privateCheckbox->SetValue( m_graphicText->IsPrivate() );
|
||||
m_commonToAllUnits->SetValue( symbol && symbol->GetUnitCount() > 1
|
||||
&& m_graphicText->GetUnit() == 0 );
|
||||
m_commonToAllUnits->SetValue( symbol->GetUnitCount() > 1 && m_graphicText->GetUnit() == 0 );
|
||||
m_commonToAllUnits->Enable( symbol->GetUnitCount() > 1 );
|
||||
m_commonToAllBodyStyles->SetValue( m_graphicText->GetBodyStyle() == 0 );
|
||||
|
||||
if( m_graphicText->GetTextAngle().IsHorizontal() )
|
||||
@ -173,13 +171,14 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
SYMBOL_EDITOR_SETTINGS* cfg = m_parent->GetSettings();
|
||||
auto* tools = m_parent->GetToolManager()->GetTool<SYMBOL_EDITOR_DRAWING_TOOLS>();
|
||||
symbol = m_parent->GetCurSymbol();
|
||||
SYMBOL* symbol = m_parent->GetCurSymbol();
|
||||
|
||||
wxCHECK( cfg && symbol && tools, false );
|
||||
|
||||
m_textSize.SetValue( schIUScale.MilsToIU( cfg->m_Defaults.text_size ) );
|
||||
|
||||
m_commonToAllUnits->SetValue( symbol->GetUnitCount() > 1 && !tools->GetDrawSpecificUnit() );
|
||||
m_commonToAllUnits->Enable( symbol->GetUnitCount() > 1 );
|
||||
m_commonToAllBodyStyles->SetValue( !tools->GetDrawSpecificBodyStyle() );
|
||||
|
||||
if( tools->GetLastTextAngle().IsHorizontal() )
|
||||
@ -188,8 +187,6 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow()
|
||||
m_vertical->Check();
|
||||
}
|
||||
|
||||
m_commonToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow()
|
||||
if( !wxDialog::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
LIB_SYMBOL* symbol = m_currentText->GetParent();
|
||||
const SYMBOL* symbol = m_currentText->GetParentSymbol();
|
||||
|
||||
m_textCtrl->SetValue( m_currentText->GetText() );
|
||||
m_textCtrl->EmptyUndoBuffer();
|
||||
|
@ -137,7 +137,7 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN
|
||||
m_initialized( false )
|
||||
{
|
||||
// Creates a dummy pin to show on a panel, inside this dialog:
|
||||
m_dummyParent = new LIB_SYMBOL( *m_pin->GetParent() );
|
||||
m_dummyParent = new LIB_SYMBOL( *dynamic_cast<LIB_SYMBOL*>( m_pin->GetParentSymbol() ) );
|
||||
m_dummyPin = new LIB_PIN( *m_pin );
|
||||
m_dummyPin->SetParent( m_dummyParent );
|
||||
m_dummyParent->SetShowPinNames( true );
|
||||
@ -197,7 +197,7 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN
|
||||
OnAddAlternate( aEvent );
|
||||
} ) );
|
||||
|
||||
if( aPin->GetParent()->HasAlternateBodyStyle() )
|
||||
if( aPin->GetParentSymbol()->HasAlternateBodyStyle() )
|
||||
{
|
||||
m_alternatesTurndown->Collapse();
|
||||
m_alternatesTurndown->Disable();
|
||||
@ -266,8 +266,8 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow()
|
||||
m_textPinNumber->SetValue( m_pin->GetNumber() );
|
||||
m_numberSize.SetValue( m_pin->GetNumberTextSize() );
|
||||
m_pinLength.SetValue( m_pin->GetLength() );
|
||||
m_checkApplyToAllParts->Enable( m_pin->GetParent()->IsMulti() );
|
||||
m_checkApplyToAllParts->SetValue( m_pin->GetParent()->IsMulti() && m_pin->GetUnit() == 0 );
|
||||
m_checkApplyToAllParts->Enable( m_pin->GetParentSymbol()->IsMulti() );
|
||||
m_checkApplyToAllParts->SetValue( m_pin->GetParentSymbol()->IsMulti() && m_pin->GetUnit() == 0 );
|
||||
m_checkApplyToAllBodyStyles->SetValue( m_pin->GetBodyStyle() == 0 );
|
||||
m_checkShow->SetValue( m_pin->IsVisible() );
|
||||
|
||||
@ -301,7 +301,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow()
|
||||
commonUnitsToolTip = _( "If checked, this pin will exist in all units." );
|
||||
}
|
||||
|
||||
if( !m_pin->GetParent()->IsMulti() )
|
||||
if( !m_pin->GetParentSymbol()->IsMulti() )
|
||||
commonUnitsToolTip = _( "This symbol only has one unit. This control has no effect." );
|
||||
|
||||
m_checkApplyToAllParts->SetToolTip( commonUnitsToolTip );
|
||||
@ -335,7 +335,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
|
||||
if( !DIALOG_SHIM::TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
VECTOR2I newPos( m_posX.GetValue(), -m_posY.GetValue() );
|
||||
VECTOR2I newPos( m_posX.GetIntValue(), -m_posY.GetIntValue() );
|
||||
|
||||
const int standard_grid = 50;
|
||||
|
||||
@ -353,11 +353,11 @@ bool DIALOG_PIN_PROPERTIES::TransferDataFromWindow()
|
||||
|
||||
m_pin->SetName( m_textPinName->GetValue() );
|
||||
m_pin->SetNumber( m_textPinNumber->GetValue() );
|
||||
m_pin->SetNameTextSize( m_nameSize.GetValue() );
|
||||
m_pin->SetNumberTextSize( m_numberSize.GetValue() );
|
||||
m_pin->SetNameTextSize( m_nameSize.GetIntValue() );
|
||||
m_pin->SetNumberTextSize( m_numberSize.GetIntValue() );
|
||||
m_pin->SetOrientation( PinOrientationCode( m_choiceOrientation->GetSelection() ) );
|
||||
m_pin->SetPosition( newPos );
|
||||
m_pin->ChangeLength( m_pinLength.GetValue() );
|
||||
m_pin->ChangeLength( m_pinLength.GetIntValue() );
|
||||
m_pin->SetType( m_choiceElectricalType->GetPinTypeSelection() );
|
||||
m_pin->SetShape( m_choiceStyle->GetPinShapeSelection() );
|
||||
m_pin->SetBodyStyle( m_checkApplyToAllBodyStyles->GetValue() ? 0 : m_frame->GetBodyStyle() );
|
||||
@ -399,15 +399,15 @@ void DIALOG_PIN_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
|
||||
dc.SetUserScale( scale, scale );
|
||||
GRResetPenAndBrush( &dc );
|
||||
|
||||
LIB_SYMBOL_OPTIONS opts;
|
||||
opts.force_draw_pin_text = true;
|
||||
opts.draw_hidden_fields = true;
|
||||
opts.show_connect_point = true;
|
||||
SCH_RENDER_SETTINGS renderSettings( *symbolEditor->GetRenderSettings() );
|
||||
renderSettings.m_ShowPinNumbers = true;
|
||||
renderSettings.m_ShowPinNames = true;
|
||||
renderSettings.m_ShowHiddenLibFields = true;
|
||||
renderSettings.m_ShowConnectionPoints = true;
|
||||
renderSettings.m_Transform = DefaultTransform;
|
||||
renderSettings.SetPrintDC( &dc );
|
||||
|
||||
RENDER_SETTINGS* renderSettings = symbolEditor->GetRenderSettings();
|
||||
renderSettings->SetPrintDC( &dc );
|
||||
|
||||
m_dummyPin->Print( renderSettings, -bBox.Centre(), (void*) &opts, DefaultTransform, false );
|
||||
m_dummyPin->Print( &renderSettings, -bBox.Centre(), false, false );
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
@ -420,10 +420,10 @@ void DIALOG_PIN_PROPERTIES::OnPropertiesChange( wxCommandEvent& event )
|
||||
|
||||
m_dummyPin->SetName( m_textPinName->GetValue() );
|
||||
m_dummyPin->SetNumber( m_textPinNumber->GetValue() );
|
||||
m_dummyPin->SetNameTextSize( m_nameSize.GetValue() );
|
||||
m_dummyPin->SetNumberTextSize( m_numberSize.GetValue() );
|
||||
m_dummyPin->SetNameTextSize( m_nameSize.GetIntValue() );
|
||||
m_dummyPin->SetNumberTextSize( m_numberSize.GetIntValue() );
|
||||
m_dummyPin->SetOrientation( PinOrientationCode( m_choiceOrientation->GetSelection() ) );
|
||||
m_dummyPin->SetLength( m_pinLength.GetValue() );
|
||||
m_dummyPin->SetLength( m_pinLength.GetIntValue() );
|
||||
m_dummyPin->SetType( m_choiceElectricalType->GetPinTypeSelection() );
|
||||
m_dummyPin->SetShape( m_choiceStyle->GetPinShapeSelection() );
|
||||
m_dummyPin->SetVisible( m_checkShow->GetValue() );
|
||||
|
@ -370,7 +370,7 @@ void DIALOG_PLOT_SCHEMATIC::plotSchematic( bool aPlotAll )
|
||||
{
|
||||
wxBusyCursor dummy;
|
||||
|
||||
KIGFX::SCH_RENDER_SETTINGS renderSettings( *m_parent->GetRenderSettings() );
|
||||
SCH_RENDER_SETTINGS renderSettings( *m_parent->GetRenderSettings() );
|
||||
|
||||
getPlotOptions( &renderSettings );
|
||||
|
||||
|
@ -85,7 +85,7 @@ DIALOG_SIM_MODEL<T_symbol, T_field>::DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BA
|
||||
for( LIB_PIN* pin : aSymbol.GetAllLibPins() )
|
||||
{
|
||||
// De Morgan conversions are equivalences, not additional items to simulate
|
||||
if( !pin->GetParent()->HasAlternateBodyStyle() || pin->GetBodyStyle() < 2 )
|
||||
if( !pin->GetParentSymbol()->HasAlternateBodyStyle() || pin->GetBodyStyle() < 2 )
|
||||
m_sortedPartPins.push_back( pin );
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
{
|
||||
// Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies)
|
||||
// from the current sheet path, because it can be modified by previous calculations
|
||||
m_symbol->UpdateUnit( m_symbol->GetUnitSelection( &GetParent()->GetCurrentSheet() ) );
|
||||
m_symbol->SetUnit( m_symbol->GetUnitSelection( &GetParent()->GetCurrentSheet() ) );
|
||||
|
||||
for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
|
||||
{
|
||||
@ -537,8 +537,8 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
|
||||
|
||||
if( m_part )
|
||||
{
|
||||
m_ShowPinNumButt->SetValue( m_part->ShowPinNumbers() );
|
||||
m_ShowPinNameButt->SetValue( m_part->ShowPinNames() );
|
||||
m_ShowPinNumButt->SetValue( m_part->GetShowPinNumbers() );
|
||||
m_ShowPinNameButt->SetValue( m_part->GetShowPinNames() );
|
||||
}
|
||||
|
||||
// Set the symbol's library name.
|
||||
|
@ -218,7 +218,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createSwatches()
|
||||
m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
|
||||
m_preview->GetGAL()->SetAxesEnabled( false );
|
||||
|
||||
KIGFX::SCH_RENDER_SETTINGS* settings = m_preview->GetRenderSettings();
|
||||
SCH_RENDER_SETTINGS* settings = m_preview->GetRenderSettings();
|
||||
settings->m_IsSymbolEditor = true;
|
||||
|
||||
m_colorsMainSizer->Add( m_preview, 1, wxTOP | wxEXPAND, 1 );
|
||||
@ -490,7 +490,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::updatePreview()
|
||||
return;
|
||||
|
||||
KIGFX::VIEW* view = m_preview->GetView();
|
||||
auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
||||
auto settings = static_cast<SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
||||
settings->LoadColors( m_currentSettings );
|
||||
|
||||
m_preview->GetGAL()->SetClearColor( settings->GetBackgroundColor() );
|
||||
|
@ -88,7 +88,7 @@ EESCHEMA_JOBS_HANDLER::EESCHEMA_JOBS_HANDLER( KIWAY* aKiway ) :
|
||||
}
|
||||
|
||||
|
||||
void EESCHEMA_JOBS_HANDLER::InitRenderSettings( KIGFX::SCH_RENDER_SETTINGS* aRenderSettings,
|
||||
void EESCHEMA_JOBS_HANDLER::InitRenderSettings( SCH_RENDER_SETTINGS* aRenderSettings,
|
||||
const wxString& aTheme, SCHEMATIC* aSch,
|
||||
const wxString& aDrawingSheetOverride )
|
||||
{
|
||||
@ -149,8 +149,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportPlot( JOB* aJob )
|
||||
|
||||
sch->Prj().ApplyTextVars( aJob->GetVarOverrides() );
|
||||
|
||||
std::unique_ptr<KIGFX::SCH_RENDER_SETTINGS> renderSettings =
|
||||
std::make_unique<KIGFX::SCH_RENDER_SETTINGS>();
|
||||
std::unique_ptr<SCH_RENDER_SETTINGS> renderSettings = std::make_unique<SCH_RENDER_SETTINGS>();
|
||||
InitRenderSettings( renderSettings.get(), aPlotJob->m_theme, sch, aPlotJob->m_drawingSheet );
|
||||
|
||||
std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
|
||||
@ -661,9 +660,9 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob )
|
||||
}
|
||||
|
||||
|
||||
int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
|
||||
KIGFX::SCH_RENDER_SETTINGS* aRenderSettings,
|
||||
LIB_SYMBOL* symbol )
|
||||
int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
|
||||
SCH_RENDER_SETTINGS* aRenderSettings,
|
||||
LIB_SYMBOL* symbol )
|
||||
{
|
||||
wxASSERT( symbol != nullptr );
|
||||
|
||||
@ -844,7 +843,7 @@ int EESCHEMA_JOBS_HANDLER::JobSymExportSvg( JOB* aJob )
|
||||
wxFileName::Mkdir( svgJob->m_outputDirectory );
|
||||
}
|
||||
|
||||
KIGFX::SCH_RENDER_SETTINGS renderSettings;
|
||||
SCH_RENDER_SETTINGS renderSettings;
|
||||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings( svgJob->m_colorTheme );
|
||||
renderSettings.LoadColors( cs );
|
||||
renderSettings.SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS );
|
||||
|
@ -24,11 +24,7 @@
|
||||
#include <jobs/job_dispatcher.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class SCH_RENDER_SETTINGS;
|
||||
};
|
||||
|
||||
class KIWAY;
|
||||
class SCHEMATIC;
|
||||
class JOB_SYM_EXPORT_SVG;
|
||||
@ -61,13 +57,13 @@ public:
|
||||
* left blank for default.
|
||||
* @param aSch The schematic to further copy settings from to be put into aRenderSettings.
|
||||
*/
|
||||
void InitRenderSettings( KIGFX::SCH_RENDER_SETTINGS* aRenderSettings, const wxString& aTheme,
|
||||
void InitRenderSettings( SCH_RENDER_SETTINGS* aRenderSettings, const wxString& aTheme,
|
||||
SCHEMATIC* aSch,
|
||||
const wxString& aDrawingSheetOverride = wxEmptyString );
|
||||
|
||||
private:
|
||||
|
||||
int doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, KIGFX::SCH_RENDER_SETTINGS* aRenderSettings,
|
||||
int doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, SCH_RENDER_SETTINGS* aRenderSettings,
|
||||
LIB_SYMBOL* symbol );
|
||||
|
||||
DS_PROXY_VIEW_ITEM* getDrawingSheetProxyView( SCHEMATIC* aSch );
|
||||
|
@ -835,7 +835,7 @@ int ERC_TESTER::TestMultUnitPinConflicts()
|
||||
SCH_PIN* pin = static_cast<SCH_PIN*>( item );
|
||||
const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
|
||||
|
||||
if( !pin->GetLibPin()->GetParent()->IsMulti() )
|
||||
if( !pin->GetLibPin()->GetParentSymbol()->IsMulti() )
|
||||
continue;
|
||||
|
||||
wxString name = pin->GetParentSymbol()->GetRef( &sheet ) +
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2022 CERN
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2024 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
|
||||
@ -127,16 +127,15 @@ KIFONT::FONT* LIB_FIELD::getDrawFont() const
|
||||
}
|
||||
|
||||
|
||||
void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed )
|
||||
void LIB_FIELD::print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
bool aForceNoFill, bool aDimmed )
|
||||
{
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
COLOR4D color = aSettings->GetLayerColor( IsVisible() ? GetDefaultLayer() : LAYER_HIDDEN );
|
||||
COLOR4D bg = aSettings->GetBackgroundColor();
|
||||
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
||||
int penWidth = GetEffectivePenWidth( aSettings );
|
||||
VECTOR2I text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
|
||||
wxString text = aData ? *static_cast<wxString*>( aData ) : GetText();
|
||||
VECTOR2I text_pos = aSettings->m_Transform.TransformCoordinate( GetTextPos() ) + aOffset;
|
||||
|
||||
if( blackAndWhiteMode || bg == COLOR4D::UNSPECIFIED )
|
||||
bg = COLOR4D::WHITE;
|
||||
@ -155,7 +154,7 @@ void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||
if( !font )
|
||||
font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
|
||||
|
||||
GRPrintText( DC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(),
|
||||
GRPrintText( DC, text_pos, color, GetText(), GetTextAngle(), GetTextSize(), GetHorizJustify(),
|
||||
GetVertJustify(), penWidth, IsItalic(), IsBold(), font, GetFontMetrics() );
|
||||
}
|
||||
|
||||
@ -411,9 +410,7 @@ wxString LIB_FIELD::GetFullText( int unit ) const
|
||||
wxString text = GetText();
|
||||
text << wxT( "?" );
|
||||
|
||||
wxCHECK( GetParent(), text );
|
||||
|
||||
if( GetParent()->IsMulti() )
|
||||
if( GetParentSymbol() && GetParentSymbol()->IsMulti() )
|
||||
text << LIB_SYMBOL::LetterSubReference( unit, 'A' );
|
||||
|
||||
return text;
|
||||
@ -600,10 +597,10 @@ bool LIB_FIELD::operator==( const LIB_ITEM& aItem ) const
|
||||
if( m_name != field.m_name )
|
||||
return false;
|
||||
|
||||
if( !m_parent || !aItem.GetParent() )
|
||||
if( !m_parent || !aItem.GetParentSymbol() )
|
||||
return false;
|
||||
|
||||
if( m_parent->m_Uuid != aItem.GetParent()->m_Uuid )
|
||||
if( m_parent->m_Uuid != aItem.GetParentSymbol()->m_Uuid )
|
||||
return false;
|
||||
|
||||
if( m_id < MANDATORY_FIELDS )
|
||||
@ -626,7 +623,10 @@ double LIB_FIELD::Similarity( const LIB_ITEM& aItem ) const
|
||||
if( m_id != field.m_id && m_id < MANDATORY_FIELDS )
|
||||
return 0.0;
|
||||
|
||||
if( m_parent->m_Uuid != aItem.GetParent()->m_Uuid )
|
||||
if( !m_parent || !aItem.GetParentSymbol() )
|
||||
return false;
|
||||
|
||||
if( m_parent->m_Uuid != aItem.GetParentSymbol()->m_Uuid )
|
||||
return 0.0;
|
||||
|
||||
if( m_id < MANDATORY_FIELDS )
|
||||
|
@ -224,8 +224,8 @@ private:
|
||||
* If \a aData not NULL, \a aData must point a wxString which is used instead of
|
||||
* the m_Text
|
||||
*/
|
||||
void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed ) override;
|
||||
void print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, bool aForceNoFill,
|
||||
bool aDimmed ) override;
|
||||
|
||||
/**
|
||||
* Calculate the new circle at \a aPosition when editing.
|
||||
|
@ -72,7 +72,7 @@ void LIB_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
|
||||
|
||||
aList.emplace_back( _( "Type" ), GetTypeName() );
|
||||
|
||||
if( LIB_SYMBOL* parent = GetParent() )
|
||||
if( const SYMBOL* parent = GetParentSymbol() )
|
||||
{
|
||||
if( parent->GetUnitCount() )
|
||||
aList.emplace_back( _( "Unit" ), GetUnitDescription( m_unit ) );
|
||||
@ -169,10 +169,10 @@ const KIFONT::METRICS& LIB_ITEM::GetFontMetrics() const
|
||||
}
|
||||
|
||||
|
||||
void LIB_ITEM::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed )
|
||||
void LIB_ITEM::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
bool aForceNoFill, bool aDimmed )
|
||||
{
|
||||
print( aSettings, aOffset, aData, aTransform, aDimmed );
|
||||
print( aSettings, aOffset, aForceNoFill, aDimmed );
|
||||
}
|
||||
|
||||
|
||||
@ -200,7 +200,7 @@ static struct LIB_ITEM_DESC
|
||||
{
|
||||
if( LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( aItem ) )
|
||||
{
|
||||
if( LIB_SYMBOL* symbol = libItem->GetParent() )
|
||||
if( const SYMBOL* symbol = libItem->GetParentSymbol() )
|
||||
return symbol->IsMulti();
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ static struct LIB_ITEM_DESC
|
||||
{
|
||||
if( LIB_ITEM* libItem = dynamic_cast<LIB_ITEM*>( aItem ) )
|
||||
{
|
||||
if( LIB_SYMBOL* symbol = libItem->GetParent() )
|
||||
if( const SYMBOL* symbol = libItem->GetParentSymbol() )
|
||||
return symbol->HasAlternateBodyStyle();
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <eda_item.h>
|
||||
#include <eda_shape.h>
|
||||
#include <symbol.h>
|
||||
#include <transform.h>
|
||||
#include <render_settings.h>
|
||||
|
||||
@ -175,17 +176,11 @@ public:
|
||||
/**
|
||||
* Draw an item
|
||||
*
|
||||
* @param aDC Device Context (can be null)
|
||||
* @param aOffset Offset to draw
|
||||
* @param aData Value or pointer used to pass others parameters, depending on body items.
|
||||
* Used for some items to force to force no fill mode ( has meaning only for
|
||||
* items what can be filled ). used in printing or moving objects mode or to
|
||||
* pass reference to the lib symbol for pins.
|
||||
* @param aTransform Transform Matrix (rotation, mirror ..)
|
||||
* @param aDimmed Dim the color on the printout
|
||||
*/
|
||||
virtual void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed );
|
||||
virtual void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
bool aForceNoFill, bool aDimmed );
|
||||
|
||||
virtual int GetPenWidth() const = 0;
|
||||
|
||||
@ -206,9 +201,16 @@ public:
|
||||
return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
|
||||
}
|
||||
|
||||
LIB_SYMBOL* GetParent() const // Replace EDA_ITEM::GetParent() with a more useful return-type
|
||||
const SYMBOL* GetParentSymbol() const
|
||||
{
|
||||
return (LIB_SYMBOL*) m_parent;
|
||||
wxCHECK( m_parent->Type() == LIB_SYMBOL_T, nullptr );
|
||||
return static_cast<const SYMBOL*>( m_parent );
|
||||
}
|
||||
|
||||
SYMBOL* GetParentSymbol()
|
||||
{
|
||||
wxCHECK( m_parent->Type() == LIB_SYMBOL_T, nullptr );
|
||||
return static_cast<SYMBOL*>( m_parent );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -381,15 +383,11 @@ protected:
|
||||
virtual int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const;
|
||||
|
||||
/**
|
||||
* Print the item to \a aDC.
|
||||
*
|
||||
* @param aOffset A reference to a wxPoint object containing the offset where to draw
|
||||
* from the object's current position.
|
||||
* @param aData A pointer to any object specific data required to perform the draw.
|
||||
* @param aTransform A reference to a #TRANSFORM object containing drawing transform.
|
||||
*/
|
||||
virtual void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed ) = 0;
|
||||
virtual void print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
bool aForceNoFill, bool aDimmed ) = 0;
|
||||
|
||||
private:
|
||||
friend class LIB_SYMBOL;
|
||||
|
@ -72,7 +72,7 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( ELECTRICAL_PINTYPE aType
|
||||
|
||||
static int internalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
|
||||
{
|
||||
const KIGFX::SCH_RENDER_SETTINGS* settings = static_cast<const KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
|
||||
const SCH_RENDER_SETTINGS* settings = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
|
||||
|
||||
if( settings && settings->m_PinSymbolSize )
|
||||
return settings->m_PinSymbolSize;
|
||||
@ -85,7 +85,7 @@ static int internalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN
|
||||
// marker
|
||||
static int externalPinDecoSize( const RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
|
||||
{
|
||||
const KIGFX::SCH_RENDER_SETTINGS* settings = static_cast<const KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
|
||||
const SCH_RENDER_SETTINGS* settings = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
|
||||
|
||||
if( settings && settings->m_PinSymbolSize )
|
||||
return settings->m_PinSymbolSize;
|
||||
@ -195,37 +195,32 @@ VECTOR2I LIB_PIN::GetPinRoot() const
|
||||
}
|
||||
|
||||
|
||||
void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed )
|
||||
void LIB_PIN::print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
bool aForceNoFill, bool aDimmed )
|
||||
{
|
||||
LIB_SYMBOL_OPTIONS* opts = (LIB_SYMBOL_OPTIONS*) aData;
|
||||
bool drawHiddenFields = opts ? opts->draw_hidden_fields : false;
|
||||
bool showPinType = opts ? opts->show_elec_type : false;
|
||||
bool show_connect_point = opts ? opts->show_connect_point : false;
|
||||
LIB_SYMBOL* part = dynamic_cast<LIB_SYMBOL*>( GetParentSymbol() );
|
||||
|
||||
LIB_SYMBOL* part = GetParent();
|
||||
|
||||
wxCHECK( part && opts, /* void */ );
|
||||
wxCHECK( part && aSettings, /* void */ );
|
||||
|
||||
/* Calculate pin orient taking in account the symbol orientation. */
|
||||
PIN_ORIENTATION orient = PinDrawOrient( aTransform );
|
||||
PIN_ORIENTATION orient = PinDrawOrient( aSettings->m_Transform );
|
||||
|
||||
/* Calculate the pin position */
|
||||
VECTOR2I pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
|
||||
VECTOR2I pos1 = aSettings->m_Transform.TransformCoordinate( m_position ) + aOffset;
|
||||
|
||||
if( IsVisible() || drawHiddenFields )
|
||||
if( IsVisible() || aSettings->m_ShowHiddenLibFields )
|
||||
{
|
||||
printPinSymbol( aSettings, pos1, orient, aDimmed );
|
||||
|
||||
printPinTexts( aSettings, pos1, orient, part->GetPinNameOffset(),
|
||||
opts->force_draw_pin_text || part->ShowPinNumbers(),
|
||||
opts->force_draw_pin_text || part->ShowPinNames(),
|
||||
aSettings->m_ShowPinNumbers || part->GetShowPinNumbers(),
|
||||
aSettings->m_ShowPinNames || part->GetShowPinNames(),
|
||||
aDimmed );
|
||||
|
||||
if( showPinType )
|
||||
if( aSettings->m_ShowPinElectricalTypes )
|
||||
printPinElectricalTypeName( aSettings, pos1, orient, aDimmed );
|
||||
|
||||
if( show_connect_point
|
||||
if( aSettings->m_ShowConnectionPoints
|
||||
&& m_type != ELECTRICAL_PINTYPE::PT_NC
|
||||
&& m_type != ELECTRICAL_PINTYPE::PT_NIC )
|
||||
{
|
||||
@ -1174,13 +1169,14 @@ void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset
|
||||
if( !IsVisible() || aBackground )
|
||||
return;
|
||||
|
||||
const SYMBOL* part = GetParentSymbol();
|
||||
|
||||
PIN_ORIENTATION orient = PinDrawOrient( aTransform );
|
||||
VECTOR2I pos = aTransform.TransformCoordinate( m_position ) + aOffset;
|
||||
|
||||
PlotSymbol( aPlotter, pos, orient, aDimmed );
|
||||
PlotPinTexts( aPlotter, pos, orient, GetParent()->GetPinNameOffset(),
|
||||
GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(),
|
||||
aDimmed );
|
||||
PlotPinTexts( aPlotter, pos, orient, part->GetPinNameOffset(), part->GetShowPinNumbers(),
|
||||
part->GetShowPinNames(), aDimmed );
|
||||
}
|
||||
|
||||
|
||||
@ -1279,14 +1275,14 @@ const BOX2I LIB_PIN::GetBoundingBox( bool aIncludeInvisiblePins, bool aIncludeNa
|
||||
includeType = false;
|
||||
}
|
||||
|
||||
if( GetParent() )
|
||||
if( const SYMBOL* parentSymbol = GetParentSymbol() )
|
||||
{
|
||||
if( GetParent()->ShowPinNames() )
|
||||
pinNameOffset = GetParent()->GetPinNameOffset();
|
||||
if( parentSymbol->GetShowPinNames() )
|
||||
pinNameOffset = parentSymbol->GetPinNameOffset();
|
||||
else
|
||||
includeName = false;
|
||||
|
||||
if( !GetParent()->ShowPinNumbers() )
|
||||
if( !parentSymbol->GetShowPinNumbers() )
|
||||
includeNumber = false;
|
||||
}
|
||||
|
||||
|
@ -147,12 +147,9 @@ public:
|
||||
* Print a pin, with or without the pin texts
|
||||
*
|
||||
* @param aOffset Offset to draw
|
||||
* @param aData = used here as a boolean indicating whether or not to draw the pin
|
||||
* electrical types
|
||||
* @param aTransform Transform Matrix (rotation, mirror ..)
|
||||
*/
|
||||
void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed ) override;
|
||||
void print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, bool aForceNoFill,
|
||||
bool aDimmed ) override;
|
||||
|
||||
/**
|
||||
* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
|
||||
@ -207,7 +204,7 @@ public:
|
||||
bool IsGlobalPower() const
|
||||
{
|
||||
return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN
|
||||
&& ( !IsVisible() || (LIB_SYMBOL*) GetParent()->IsPower() );
|
||||
&& ( !IsVisible() || GetParentSymbol()->IsPower() );
|
||||
}
|
||||
|
||||
int GetPenWidth() const override;
|
||||
|
@ -259,21 +259,20 @@ int LIB_SHAPE::GetPenWidth() const
|
||||
}
|
||||
|
||||
|
||||
void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed )
|
||||
void LIB_SHAPE::print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
bool aForceNoFill, bool aDimmed )
|
||||
{
|
||||
if( IsPrivate() )
|
||||
return;
|
||||
|
||||
bool forceNoFill = static_cast<bool>( aData );
|
||||
int penWidth = GetEffectivePenWidth( aSettings );
|
||||
|
||||
if( forceNoFill && IsFilled() && penWidth == 0 )
|
||||
if( aForceNoFill && IsFilled() && penWidth == 0 )
|
||||
return;
|
||||
|
||||
wxDC* DC = aSettings->GetPrintDC();
|
||||
VECTOR2I pt1 = aTransform.TransformCoordinate( m_start ) + aOffset;
|
||||
VECTOR2I pt2 = aTransform.TransformCoordinate( m_end ) + aOffset;
|
||||
VECTOR2I pt1 = aSettings->m_Transform.TransformCoordinate( m_start ) + aOffset;
|
||||
VECTOR2I pt2 = aSettings->m_Transform.TransformCoordinate( m_end ) + aOffset;
|
||||
VECTOR2I c;
|
||||
COLOR4D color = GetStroke().GetColor();
|
||||
|
||||
@ -302,7 +301,7 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||
buffer = new VECTOR2I[ptCount];
|
||||
|
||||
for( unsigned ii = 0; ii < ptCount; ++ii )
|
||||
buffer[ii] = aTransform.TransformCoordinate( poly.CPoint( ii ) ) + aOffset;
|
||||
buffer[ii] = aSettings->m_Transform.TransformCoordinate( poly.CPoint( ii ) ) + aOffset;
|
||||
}
|
||||
else if( GetShape() == SHAPE_T::BEZIER )
|
||||
{
|
||||
@ -310,11 +309,11 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||
buffer = new VECTOR2I[ptCount];
|
||||
|
||||
for( size_t ii = 0; ii < ptCount; ++ii )
|
||||
buffer[ii] = aTransform.TransformCoordinate( m_bezierPoints[ii] ) + aOffset;
|
||||
buffer[ii] = aSettings->m_Transform.TransformCoordinate( m_bezierPoints[ii] ) + aOffset;
|
||||
}
|
||||
else if( GetShape() == SHAPE_T::ARC )
|
||||
{
|
||||
c = aTransform.TransformCoordinate( getCenter() ) + aOffset;
|
||||
c = aSettings->m_Transform.TransformCoordinate( getCenter() ) + aOffset;
|
||||
|
||||
EDA_ANGLE t1, t2;
|
||||
|
||||
@ -322,7 +321,7 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||
|
||||
// N.B. The order of evaluation is critical here as MapAngles will modify t1, t2
|
||||
// and the Normalize routine depends on these modifications for the correct output
|
||||
bool transformed = aTransform.MapAngles( &t1, &t2 );
|
||||
bool transformed = aSettings->m_Transform.MapAngles( &t1, &t2 );
|
||||
EDA_ANGLE arc_angle = ( t1 - t2 ).Normalize180();
|
||||
bool transformed2 = ( arc_angle > ANGLE_0 ) && ( arc_angle < ANGLE_180 );
|
||||
|
||||
@ -332,7 +331,7 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||
|
||||
COLOR4D fillColor = COLOR4D::UNSPECIFIED;
|
||||
|
||||
if( !forceNoFill )
|
||||
if( !aForceNoFill )
|
||||
{
|
||||
if( GetFillMode() == FILL_T::FILLED_SHAPE )
|
||||
fillColor = color;
|
||||
@ -418,12 +417,12 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
|
||||
for( SHAPE* shape : shapes )
|
||||
{
|
||||
STROKE_PARAMS::Stroke( shape, GetEffectiveLineStyle(), penWidth, aSettings,
|
||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||
{
|
||||
VECTOR2I pts = aTransform.TransformCoordinate( a ) + aOffset;
|
||||
VECTOR2I pte = aTransform.TransformCoordinate( b ) + aOffset;
|
||||
GRLine( DC, pts.x, pts.y, pte.x, pte.y, penWidth, color );
|
||||
} );
|
||||
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
||||
{
|
||||
VECTOR2I pts = aSettings->m_Transform.TransformCoordinate( a ) + aOffset;
|
||||
VECTOR2I pte = aSettings->m_Transform.TransformCoordinate( b ) + aOffset;
|
||||
GRLine( DC, pts.x, pts.y, pte.x, pte.y, penWidth, color );
|
||||
} );
|
||||
}
|
||||
|
||||
for( SHAPE* shape : shapes )
|
||||
|
@ -135,8 +135,8 @@ private:
|
||||
*/
|
||||
int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
||||
|
||||
void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
|
||||
const TRANSFORM& aTransform, bool aDimmed ) override;
|
||||
void print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, bool aForceNoFill,
|
||||
bool aDimmed ) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2022 CERN
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2024 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
|
||||
@ -96,19 +96,14 @@ struct null_deleter
|
||||
|
||||
|
||||
LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB* aLibrary ) :
|
||||
EDA_ITEM( LIB_SYMBOL_T ),
|
||||
m_me( this, null_deleter() ),
|
||||
m_excludedFromSim( false ),
|
||||
m_excludedFromBOM( false ),
|
||||
m_excludedFromBoard( false )
|
||||
SYMBOL( LIB_SYMBOL_T ),
|
||||
m_me( this, null_deleter() )
|
||||
{
|
||||
m_lastModDate = 0;
|
||||
m_unitCount = 1;
|
||||
m_pinNameOffset = schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET );
|
||||
m_options = ENTRY_NORMAL;
|
||||
m_unitsLocked = false;
|
||||
m_showPinNumbers = true;
|
||||
m_showPinNames = true;
|
||||
|
||||
// Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
|
||||
// when the field editors are invoked.
|
||||
@ -126,7 +121,7 @@ LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB*
|
||||
|
||||
|
||||
LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) :
|
||||
EDA_ITEM( aSymbol ),
|
||||
SYMBOL( aSymbol ),
|
||||
m_me( this, null_deleter() )
|
||||
{
|
||||
LIB_ITEM* newItem;
|
||||
@ -136,12 +131,6 @@ LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) :
|
||||
m_fpFilters = wxArrayString( aSymbol.m_fpFilters );
|
||||
m_unitCount = aSymbol.m_unitCount;
|
||||
m_unitsLocked = aSymbol.m_unitsLocked;
|
||||
m_pinNameOffset = aSymbol.m_pinNameOffset;
|
||||
m_showPinNumbers = aSymbol.m_showPinNumbers;
|
||||
m_excludedFromSim = aSymbol.m_excludedFromSim;
|
||||
m_excludedFromBOM = aSymbol.m_excludedFromBOM;
|
||||
m_excludedFromBoard = aSymbol.m_excludedFromBoard;
|
||||
m_showPinNames = aSymbol.m_showPinNames;
|
||||
m_lastModDate = aSymbol.m_lastModDate;
|
||||
m_options = aSymbol.m_options;
|
||||
m_libId = aSymbol.m_libId;
|
||||
@ -511,13 +500,9 @@ int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aR
|
||||
|
||||
// Compare unit display names
|
||||
if( m_unitDisplayNames < aRhs.m_unitDisplayNames )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if( m_unitDisplayNames > aRhs.m_unitDisplayNames )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return retv;
|
||||
@ -551,22 +536,16 @@ bool LIB_SYMBOL::HasUnitDisplayName( int aUnit )
|
||||
wxString LIB_SYMBOL::GetUnitDisplayName( int aUnit )
|
||||
{
|
||||
if( HasUnitDisplayName( aUnit ) )
|
||||
{
|
||||
return m_unitDisplayNames[aUnit];
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxString::Format( _( "Unit %s" ), GetUnitReference( aUnit ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::CopyUnitDisplayNames( std::map<int, wxString>& aTarget ) const
|
||||
{
|
||||
for( const auto& it : m_unitDisplayNames )
|
||||
{
|
||||
aTarget[it.first] = it.second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -575,13 +554,9 @@ void LIB_SYMBOL::SetUnitDisplayName( int aUnit, const wxString& aName )
|
||||
if( aUnit <= GetUnitCount() )
|
||||
{
|
||||
if( aName.Length() > 0 )
|
||||
{
|
||||
m_unitDisplayNames[aUnit] = aName;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_unitDisplayNames.erase( aUnit );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -679,19 +654,6 @@ std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::ClearCaches()
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( &item ) )
|
||||
{
|
||||
eda_text->ClearBoundingBoxCache();
|
||||
eda_text->ClearRenderCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const wxString LIB_SYMBOL::GetLibraryName() const
|
||||
{
|
||||
if( m_library )
|
||||
@ -776,9 +738,8 @@ wxString LIB_SYMBOL::LetterSubReference( int aUnit, int aFirstId )
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
int aUnit, int aBodyStyle, const LIB_SYMBOL_OPTIONS& aOpts,
|
||||
bool aDimmed )
|
||||
void LIB_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
int aUnit, int aBodyStyle, bool aForceNoFill, bool aDimmed )
|
||||
{
|
||||
/* draw background for filled items using background option
|
||||
* Solid lines will be drawn after the background
|
||||
@ -804,17 +765,16 @@ void LIB_SYMBOL::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR
|
||||
continue;
|
||||
|
||||
if( shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
|
||||
shape.Print( aSettings, aOffset, (void*) false, aOpts.transform, aDimmed );
|
||||
shape.Print( aSettings, aOffset, false, aDimmed );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, int aUnit,
|
||||
int aBodyStyle, const LIB_SYMBOL_OPTIONS& aOpts, bool aDimmed )
|
||||
void LIB_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
|
||||
int aUnit, int aBodyStyle, bool aForceNoFill, bool aDimmed )
|
||||
{
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
// Do not print private items
|
||||
@ -832,31 +792,33 @@ void LIB_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse
|
||||
{
|
||||
LIB_FIELD& field = static_cast<LIB_FIELD&>( item );
|
||||
|
||||
if( field.IsVisible() && !aOpts.draw_visible_fields )
|
||||
if( field.IsVisible() && !aSettings->m_ShowVisibleLibFields )
|
||||
continue;
|
||||
|
||||
if( !field.IsVisible() && !aOpts.draw_hidden_fields )
|
||||
if( !field.IsVisible() && !aSettings->m_ShowHiddenLibFields )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( item.Type() == LIB_PIN_T )
|
||||
{
|
||||
item.Print( aSettings, aOffset, (void*) &aOpts, aOpts.transform, aDimmed );
|
||||
item.Print( aSettings, aOffset, aForceNoFill, aDimmed );
|
||||
}
|
||||
else if( item.Type() == LIB_FIELD_T )
|
||||
{
|
||||
item.Print( aSettings, aOffset, nullptr, aOpts.transform, aDimmed );
|
||||
item.Print( aSettings, aOffset, aForceNoFill, aDimmed );
|
||||
}
|
||||
else if( item.Type() == LIB_SHAPE_T )
|
||||
{
|
||||
LIB_SHAPE& shape = static_cast<LIB_SHAPE&>( item );
|
||||
bool forceNoFill = shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR;
|
||||
|
||||
shape.Print( aSettings, aOffset, (void*) forceNoFill, aOpts.transform, aDimmed );
|
||||
if( shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
|
||||
aForceNoFill = true;
|
||||
|
||||
shape.Print( aSettings, aOffset, aForceNoFill, aDimmed );
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Print( aSettings, aOffset, (void*) false, aOpts.transform, aDimmed );
|
||||
item.Print( aSettings, aOffset, aForceNoFill, aDimmed );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1193,20 +1155,6 @@ const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aBodyStyle,
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
{
|
||||
aCount = 0;
|
||||
aLayers[ aCount++ ] = LAYER_DEVICE;
|
||||
aLayers[ aCount++ ] = LAYER_DEVICE_BACKGROUND;
|
||||
aLayers[ aCount++ ] = LAYER_REFERENCEPART;
|
||||
aLayers[ aCount++ ] = LAYER_VALUEPART;
|
||||
aLayers[ aCount++ ] = LAYER_FIELDS;
|
||||
aLayers[ aCount++ ] = LAYER_PRIVATE_NOTES;
|
||||
aLayers[ aCount++ ] = LAYER_NOTES_BACKGROUND;
|
||||
aLayers[ aCount++ ] = LAYER_SELECTION_SHADOWS;
|
||||
}
|
||||
|
||||
|
||||
const BOX2I LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
|
||||
bool aIncludePrivateItems ) const
|
||||
{
|
||||
@ -1436,7 +1384,7 @@ wxString LIB_SYMBOL::GetPrefix()
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::RunOnChildren( const std::function<void( LIB_ITEM* )>& aFunction )
|
||||
void LIB_SYMBOL::RunOnLibChildren( const std::function<void( LIB_ITEM* )>& aFunction )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
aFunction( &item );
|
||||
@ -1482,19 +1430,13 @@ int LIB_SYMBOL::GetNextAvailableFieldId() const
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::SetOffset( const VECTOR2I& aOffset )
|
||||
void LIB_SYMBOL::Move( const VECTOR2I& aOffset )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
item.Offset( aOffset );
|
||||
}
|
||||
|
||||
|
||||
void LIB_SYMBOL::RemoveDuplicateDrawItems()
|
||||
{
|
||||
m_drawings.unique();
|
||||
}
|
||||
|
||||
|
||||
bool LIB_SYMBOL::HasAlternateBodyStyle() const
|
||||
{
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
@ -1771,110 +1713,6 @@ std::vector<struct LIB_SYMBOL_UNIT> LIB_SYMBOL::GetUnitDrawItems()
|
||||
}
|
||||
|
||||
|
||||
std::vector<struct LIB_SYMBOL_UNIT> LIB_SYMBOL::GetUniqueUnits()
|
||||
{
|
||||
int unitNum;
|
||||
size_t i;
|
||||
struct LIB_SYMBOL_UNIT unit;
|
||||
std::vector<LIB_ITEM*> compareDrawItems;
|
||||
std::vector<LIB_ITEM*> currentDrawItems;
|
||||
std::vector<struct LIB_SYMBOL_UNIT> uniqueUnits;
|
||||
|
||||
// The first unit is guaranteed to be unique so always include it.
|
||||
unit.m_unit = 1;
|
||||
unit.m_bodyStyle = 1;
|
||||
unit.m_items = GetUnitDrawItems( 1, 1 );
|
||||
|
||||
// There are no unique units if there are no draw items other than fields.
|
||||
if( unit.m_items.size() == 0 )
|
||||
return uniqueUnits;
|
||||
|
||||
uniqueUnits.emplace_back( unit );
|
||||
|
||||
if( ( GetUnitCount() == 1 || UnitsLocked() ) && !HasAlternateBodyStyle() )
|
||||
return uniqueUnits;
|
||||
|
||||
currentDrawItems = unit.m_items;
|
||||
|
||||
for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
|
||||
{
|
||||
compareDrawItems = GetUnitDrawItems( unitNum, 1 );
|
||||
|
||||
wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
|
||||
"Multiple unit symbol defined with empty units." );
|
||||
|
||||
if( currentDrawItems.size() != compareDrawItems.size() )
|
||||
{
|
||||
unit.m_unit = unitNum;
|
||||
unit.m_bodyStyle = 1;
|
||||
unit.m_items = compareDrawItems;
|
||||
uniqueUnits.emplace_back( unit );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < currentDrawItems.size(); i++ )
|
||||
{
|
||||
if( currentDrawItems[i]->compare( *compareDrawItems[i],
|
||||
LIB_ITEM::COMPARE_FLAGS::UNIT ) != 0 )
|
||||
{
|
||||
unit.m_unit = unitNum;
|
||||
unit.m_bodyStyle = 1;
|
||||
unit.m_items = compareDrawItems;
|
||||
uniqueUnits.emplace_back( unit );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( HasAlternateBodyStyle() )
|
||||
{
|
||||
currentDrawItems = GetUnitDrawItems( 1, 2 );
|
||||
|
||||
if( ( GetUnitCount() == 1 || UnitsLocked() ) )
|
||||
{
|
||||
unit.m_unit = 1;
|
||||
unit.m_bodyStyle = 2;
|
||||
unit.m_items = currentDrawItems;
|
||||
uniqueUnits.emplace_back( unit );
|
||||
|
||||
return uniqueUnits;
|
||||
}
|
||||
|
||||
for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
|
||||
{
|
||||
compareDrawItems = GetUnitDrawItems( unitNum, 2 );
|
||||
|
||||
wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
|
||||
"Multiple unit symbol defined with empty units." );
|
||||
|
||||
if( currentDrawItems.size() != compareDrawItems.size() )
|
||||
{
|
||||
unit.m_unit = unitNum;
|
||||
unit.m_bodyStyle = 2;
|
||||
unit.m_items = compareDrawItems;
|
||||
uniqueUnits.emplace_back( unit );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < currentDrawItems.size(); i++ )
|
||||
{
|
||||
if( currentDrawItems[i]->compare( *compareDrawItems[i],
|
||||
LIB_ITEM::COMPARE_FLAGS::UNIT ) != 0 )
|
||||
{
|
||||
unit.m_unit = unitNum;
|
||||
unit.m_bodyStyle = 2;
|
||||
unit.m_items = compareDrawItems;
|
||||
uniqueUnits.emplace_back( unit );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return uniqueUnits;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_SYMBOL::operator==( const LIB_SYMBOL& aOther ) const
|
||||
{
|
||||
if( m_libId != aOther.m_libId )
|
||||
@ -1936,10 +1774,13 @@ bool LIB_SYMBOL::operator==( const LIB_SYMBOL& aOther ) const
|
||||
}
|
||||
|
||||
|
||||
double LIB_SYMBOL::Similarity( const LIB_SYMBOL& aOther ) const
|
||||
double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const
|
||||
{
|
||||
double similarity = 0.0;
|
||||
int totalItems = 0;
|
||||
wxCHECK( aOther.Type() == LIB_SYMBOL_T, 0.0 );
|
||||
|
||||
const LIB_SYMBOL& other = static_cast<const LIB_SYMBOL&>( aOther );
|
||||
double similarity = 0.0;
|
||||
int totalItems = 0;
|
||||
|
||||
if( m_Uuid == aOther.m_Uuid )
|
||||
return 1.0;
|
||||
@ -1949,7 +1790,7 @@ double LIB_SYMBOL::Similarity( const LIB_SYMBOL& aOther ) const
|
||||
totalItems += 1;
|
||||
double max_similarity = 0.0;
|
||||
|
||||
for( const LIB_ITEM& otherItem : aOther.m_drawings )
|
||||
for( const LIB_ITEM& otherItem : other.m_drawings )
|
||||
{
|
||||
double temp_similarity = item.Similarity( otherItem );
|
||||
max_similarity = std::max( max_similarity, temp_similarity );
|
||||
@ -1966,7 +1807,7 @@ double LIB_SYMBOL::Similarity( const LIB_SYMBOL& aOther ) const
|
||||
totalItems += 1;
|
||||
double max_similarity = 0.0;
|
||||
|
||||
for( const LIB_PIN* otherPin : aOther.GetAllLibPins() )
|
||||
for( const LIB_PIN* otherPin : other.GetAllLibPins() )
|
||||
{
|
||||
double temp_similarity = pin->Similarity( *otherPin );
|
||||
max_similarity = std::max( max_similarity, temp_similarity );
|
||||
@ -1983,28 +1824,28 @@ double LIB_SYMBOL::Similarity( const LIB_SYMBOL& aOther ) const
|
||||
else
|
||||
similarity /= totalItems;
|
||||
|
||||
if( m_excludedFromBoard != aOther.m_excludedFromBoard )
|
||||
if( m_excludedFromBoard != other.m_excludedFromBoard )
|
||||
similarity *= 0.9;
|
||||
|
||||
if( m_excludedFromBOM != aOther.m_excludedFromBOM )
|
||||
if( m_excludedFromBOM != other.m_excludedFromBOM )
|
||||
similarity *= 0.9;
|
||||
|
||||
if( m_excludedFromSim != aOther.m_excludedFromSim )
|
||||
if( m_excludedFromSim != other.m_excludedFromSim )
|
||||
similarity *= 0.9;
|
||||
|
||||
if( m_flags != aOther.m_flags )
|
||||
if( m_flags != other.m_flags )
|
||||
similarity *= 0.9;
|
||||
|
||||
if( m_unitCount != aOther.m_unitCount )
|
||||
if( m_unitCount != other.m_unitCount )
|
||||
similarity *= 0.5;
|
||||
|
||||
if( m_pinNameOffset != aOther.m_pinNameOffset )
|
||||
if( m_pinNameOffset != other.m_pinNameOffset )
|
||||
similarity *= 0.9;
|
||||
|
||||
if( m_showPinNames != aOther.m_showPinNames )
|
||||
if( m_showPinNames != other.m_showPinNames )
|
||||
similarity *= 0.9;
|
||||
|
||||
if( m_showPinNumbers != aOther.m_showPinNumbers )
|
||||
if( m_showPinNumbers != other.m_showPinNumbers )
|
||||
similarity *= 0.9;
|
||||
|
||||
return similarity;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user