Factor common parts of SCH_ & LIB_SYMBOL into SYMBOL.

This commit is contained in:
Jeff Young 2024-04-02 18:28:17 +01:00
parent bf2b3b0b0f
commit 92910d5d0f
95 changed files with 845 additions and 884 deletions

View File

@ -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 );
}

View File

@ -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

View File

@ -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 ) )
{

View File

@ -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 );

View File

@ -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 );

View File

@ -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() );

View File

@ -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;
}

View File

@ -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();

View File

@ -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() );

View File

@ -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 );

View File

@ -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 );
}

View File

@ -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.

View File

@ -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() );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 ) +

View File

@ -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 )

View File

@ -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.

View File

@ -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();
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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 )

View File

@ -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;
};

View File

@ -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;

View File

@ -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 change_log.txt for contributors.
* Copyright (C) 2004-2024 KiCad Developers, see change_log.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
@ -24,10 +24,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef CLASS_LIBENTRY_H
#define CLASS_LIBENTRY_H
#ifndef LIB_SYMBOL_H
#define LIB_SYMBOL_H
#include <general.h>
#include <symbol.h>
#include <lib_tree_item.h>
#include <lib_field.h>
#include <vector>
@ -59,28 +60,6 @@ enum LIBRENTRYOPTIONS
extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
struct LIB_SYMBOL_OPTIONS
{
TRANSFORM transform; // Coordinate adjustment settings
bool force_draw_pin_text; // Whether or not to force the drawing of pin names and numbers
bool draw_visible_fields; // Whether to draw "visible" fields
bool draw_hidden_fields; // Whether to draw "hidden" fields
bool show_elec_type; // Whether to show the pin electrical type
bool show_connect_point; // Whether to show the pin connect point marker (small circle)
// useful in dialog pin properties
LIB_SYMBOL_OPTIONS()
{
transform = DefaultTransform;
force_draw_pin_text = false;
draw_visible_fields = true;
draw_hidden_fields = true;
show_elec_type = false;
show_connect_point = false;
}
};
struct LIB_SYMBOL_UNIT
{
int m_unit; ///< The unit number.
@ -95,7 +74,7 @@ struct LIB_SYMBOL_UNIT
* A library symbol object is typically saved and loaded in a symbol library file (.lib).
* Library symbols are different from schematic symbols.
*/
class LIB_SYMBOL : public EDA_ITEM, public LIB_TREE_ITEM
class LIB_SYMBOL : public SYMBOL, public LIB_TREE_ITEM
{
public:
LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr,
@ -144,8 +123,6 @@ public:
*/
LIB_SYMBOL_SPTR GetRootSymbol() const;
void ClearCaches();
virtual wxString GetClass() const override
{
return wxT( "LIB_SYMBOL" );
@ -161,8 +138,9 @@ public:
LIB_ID GetLIB_ID() const override { return m_libId; }
wxString GetDesc() override { return GetDescription(); }
int GetSubUnitCount() const override { return GetUnitCount(); }
const LIB_ID& GetLibId() const { return m_libId; }
const LIB_ID& GetLibId() const override { return m_libId; }
void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; }
LIB_ID GetSourceLibId() const { return m_sourceLibId; }
@ -177,7 +155,7 @@ public:
}
///< Gets the Description field text value */
wxString GetDescription() const
wxString GetDescription() const override
{
if( GetDescriptionField().GetText().IsEmpty() && IsAlias() )
{
@ -190,7 +168,7 @@ public:
void SetKeyWords( const wxString& aKeyWords ) { m_keyWords = aKeyWords; }
wxString GetKeyWords() const
wxString GetKeyWords() const override
{
if( m_keyWords.IsEmpty() && IsAlias() )
{
@ -236,8 +214,6 @@ public:
return m_fpFilters;
}
void ViewGetLayers( int aLayers[], int& aCount ) const override;
/**
* Get the bounding box for the symbol.
*
@ -269,8 +245,8 @@ public:
return GetUnitBoundingBox( 0, 0 );
}
bool IsPower() const;
bool IsNormal() const;
bool IsPower() const override;
bool IsNormal() const override;
void SetPower();
void SetNormal();
@ -347,7 +323,8 @@ public:
wxString GetPrefix();
void RunOnChildren( const std::function<void( LIB_ITEM* )>& aFunction );
// JEY TODO: reconcile with RunOnChildren when LIB_ITEM collapses to SCH_ITEM
void RunOnLibChildren( const std::function<void( LIB_ITEM* )>& aFunction );
/**
* Order optional field indices.
@ -366,11 +343,10 @@ public:
* @param aOffset - Position of symbol.
* @param aMulti - unit if multiple units per symbol.
* @param aBodyStyle - Symbol alternate body style (DeMorgan) if available.
* @param aOpts - Drawing options
* @param aDimmed - Reduce brightness of symbol
*/
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, int aMulti,
int aBodyStyle, const LIB_SYMBOL_OPTIONS& aOpts, bool aDimmed );
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, int aMulti,
int aBodyStyle, bool aForceNoFill, bool aDimmed ) override;
/**
* Print just the background fills of a symbol
@ -378,11 +354,10 @@ public:
* @param aOffset - Position of symbol.
* @param aMulti - unit if multiple units per symbol.
* @param aBodyStyle - Symbol alternate body style (DeMorgan) if available.
* @param aOpts - Drawing options
* @param aDimmed - Reduce brightness of symbol
*/
void PrintBackground( const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, int aMulti,
int aBodyStyle, const LIB_SYMBOL_OPTIONS &aOpts, bool aDimmed );
void PrintBackground( const SCH_RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset,
int aMulti, int aBodyStyle, bool aForceNoFill, bool aDimmed ) override;
/**
* Plot lib symbol to plotter.
@ -398,7 +373,7 @@ public:
* @param aDimmed - Reduce brightness of symbol
*/
void Plot( PLOTTER* aPlotter, int aUnit, int aBodyStyle, bool aBackground,
const VECTOR2I& aOffset, const TRANSFORM& aTransform, bool aDimmed ) const;
const VECTOR2I& aOffset, const TRANSFORM& aTransform, bool aDimmed ) const override;
/**
* Plot Lib Fields only of the symbol to plotter.
@ -489,19 +464,14 @@ public:
*
* @param aOffset - Offset displacement.
*/
void SetOffset( const VECTOR2I& aOffset );
/**
* Remove duplicate draw items from list.
*/
void RemoveDuplicateDrawItems();
void Move( const VECTOR2I& aOffset ) override;
/**
* Test if symbol has more than one body conversion type (DeMorgan).
*
* @return True if symbol has more than one conversion.
*/
bool HasAlternateBodyStyle() const;
bool HasAlternateBodyStyle() const override;
/**
* @return the highest pin number of the symbol's pins.
@ -599,7 +569,7 @@ public:
* @return true if the symbol has multiple units per symbol.
* When true, the reference has a sub reference to identify symbol.
*/
bool IsMulti() const { return m_unitCount > 1; }
bool IsMulti() const override { return m_unitCount > 1; }
static wxString LetterSubReference( int aUnit, int aFirstId );
@ -616,56 +586,6 @@ public:
*/
void SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePins = true );
/**
* Set the offset in mils of the pin name text from the pin symbol.
*
* Set the offset to 0 to draw the pin name above the pin symbol.
*
* @param aOffset - The offset in mils.
*/
void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; }
int GetPinNameOffset() const { return m_pinNameOffset; }
/**
* Set or clear the pin name visibility flag.
*
* @param aShow - True to make the symbol pin names visible.
*/
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
bool ShowPinNames() const { return m_showPinNames; }
/**
* Set or clear the pin number visibility flag.
*
* @param aShow - True to make the symbol pin numbers visible.
*/
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
bool ShowPinNumbers() const { return m_showPinNumbers; }
/**
* Set or clear the exclude from simulation flag.
*
* @param aExcludeFromSim true to exclude symbol from simulation
*/
void SetExcludedFromSim( bool aExcludeFromSim ) { m_excludedFromSim = aExcludeFromSim; }
bool GetExcludedFromSim() const { return m_excludedFromSim; }
/**
* Set or clear the exclude from schematic bill of materials flag.
*
* @param aExcludeFromBOM true to exclude symbol from schematic bill of materials
*/
void SetExcludedFromBOM( bool aExcludeFromBOM ) { m_excludedFromBOM = aExcludeFromBOM; }
bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
/**
* Set or clear exclude from board netlist flag.
*
* @param aExcludeFromBoard true to exclude symbol from the board netlist
*/
void SetExcludedFromBoard( bool aExcludeFromBoard ) { m_excludedFromBoard = aExcludeFromBoard; }
bool GetExcludedFromBoard() const { return m_excludedFromBoard; }
/**
* Comparison test that can be used for operators.
*
@ -704,16 +624,6 @@ public:
*/
std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
/**
* Return a list of unit numbers that are unique to this symbol.
*
* If the symbol is inherited (alias), the unique units of the parent symbol are returned.
* When comparing pins, the pin number is ignored.
*
* @return a list of unique unit numbers and their associated draw items.
*/
std::vector<struct LIB_SYMBOL_UNIT> GetUniqueUnits();
/**
* Return a list of item pointers for \a aUnit and \a aBodyStyle for this symbol.
*
@ -732,7 +642,7 @@ public:
*
* @return a measure of similarity from 1.0 (identical) to 0.0 (no similarity).
*/
double Similarity( const LIB_SYMBOL& aSymbol ) const;
double Similarity( const SCH_ITEM& aSymbol ) const override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
@ -754,14 +664,6 @@ private:
bool m_unitsLocked; ///< True if symbol has multiple units and changing one
///< unit does not automatically change another unit.
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to
///< 0 to draw the pin name above the pin.
bool m_showPinNames;
bool m_showPinNumbers;
bool m_excludedFromSim;
bool m_excludedFromBOM;
bool m_excludedFromBoard;
LIBRENTRYOPTIONS m_options; ///< Special symbol features such as POWER or NORMAL.)
LIB_ITEMS_CONTAINER m_drawings;

View File

@ -338,8 +338,8 @@ KIFONT::FONT* LIB_TEXT::getDrawFont() const
}
void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
const TRANSFORM& aTransform, bool aDimmed )
void LIB_TEXT::print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
bool aForceNoFill, bool aDimmed )
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = GetTextColor();
@ -367,7 +367,7 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
// draw text in schematic)
EDA_ANGLE orient = GetTextAngle();
if( aTransform.y1 ) // Rotate symbol 90 degrees.
if( aSettings->m_Transform.y1 ) // Rotate symbol 90 degrees.
{
if( orient == ANGLE_HORIZONTAL )
orient = ANGLE_VERTICAL;
@ -397,7 +397,7 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
VECTOR2I txtpos = bBox.Centre();
// Calculate pos according to mirror/rotation.
txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
txtpos = aSettings->m_Transform.TransformCoordinate( txtpos ) + aOffset;
GRPrintText( DC, txtpos, color, GetShownText( true ), orient, GetTextSize(),
GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(),

View File

@ -130,8 +130,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;
};

View File

@ -39,9 +39,6 @@
#include <lib_textbox.h>
using KIGFX::SCH_RENDER_SETTINGS;
LIB_TEXTBOX::LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth, FILL_T aFillType,
const wxString& text ) :
LIB_SHAPE( aParent, SHAPE_T::RECTANGLE, aLineWidth, aFillType, LIB_TEXTBOX_T ),
@ -252,23 +249,22 @@ KIFONT::FONT* LIB_TEXTBOX::getDrawFont() const
}
void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
const TRANSFORM& aTransform, bool aDimmed )
void LIB_TEXTBOX::print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
bool aForceNoFill, bool aDimmed )
{
if( IsPrivate() )
return;
bool forceNoFill = static_cast<bool>( aData );
bool blackAndWhiteMode = GetGRForceBlackPenState();
int penWidth = GetEffectivePenWidth( aSettings );
COLOR4D color = GetStroke().GetColor();
LINE_STYLE lineStyle = GetStroke().GetLineStyle();
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;
if( !forceNoFill && GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode )
if( !aForceNoFill && GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode )
GRFilledRect( DC, pt1, pt2, penWidth, GetFillColor(), GetFillColor() );
if( penWidth > 0 )
@ -303,12 +299,12 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
for( SHAPE* shape : shapes )
{
STROKE_PARAMS::Stroke( shape, lineStyle, 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 )
@ -336,7 +332,7 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetMinPenWidth() );
if( aTransform.y1 )
if( aSettings->m_Transform.y1 )
{
text.SetTextAngle( text.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL
: ANGLE_HORIZONTAL );

View File

@ -116,8 +116,8 @@ protected:
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;
private:
int m_marginLeft;

View File

@ -210,7 +210,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
if( cfg->m_Printing.monochrome )
GRForceBlackPen( true );
KIGFX::SCH_RENDER_SETTINGS renderSettings( *m_parent->GetRenderSettings() );
SCH_RENDER_SETTINGS renderSettings( *m_parent->GetRenderSettings() );
renderSettings.SetPrintDC( dc );
if( cfg->m_Printing.use_theme && theme )
@ -276,7 +276,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
gal->SetWorldUnitLength( SCH_WORLD_UNIT );
// Init the SCH_RENDER_SETTINGS used by the painter used to print schematic
KIGFX::SCH_RENDER_SETTINGS* dstSettings = painter->GetSettings();
SCH_RENDER_SETTINGS* dstSettings = painter->GetSettings();
dstSettings->m_ShowPinsElectricalType = false;

View File

@ -326,12 +326,12 @@ SCH_DRAW_PANEL* SCH_BASE_FRAME::GetCanvas() const
}
KIGFX::SCH_RENDER_SETTINGS* SCH_BASE_FRAME::GetRenderSettings()
SCH_RENDER_SETTINGS* SCH_BASE_FRAME::GetRenderSettings()
{
if( GetCanvas() && GetCanvas()->GetView() )
{
if( KIGFX::PAINTER* painter = GetCanvas()->GetView()->GetPainter() )
return static_cast<KIGFX::SCH_RENDER_SETTINGS*>( painter->GetSettings() );
return static_cast<SCH_RENDER_SETTINGS*>( painter->GetSettings() );
}
return nullptr;

View File

@ -44,11 +44,7 @@
#include <template_fieldnames.h>
namespace KIGFX
{
class SCH_RENDER_SETTINGS;
}
class SCH_RENDER_SETTINGS;
class PAGE_INFO;
class TITLE_BLOCK;
class SYMBOL_VIEWER_FRAME;
@ -111,7 +107,7 @@ public:
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings();
SCH_RENDER_SETTINGS* GetRenderSettings();
COLOR4D GetDrawBgColor() const override;

View File

@ -134,7 +134,7 @@ const BOX2I SCH_BITMAP::GetBoundingBox() const
}
void SCH_BITMAP::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_BITMAP::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
VECTOR2I pos = m_pos + aOffset;

View File

@ -93,7 +93,7 @@ public:
void SwapData( SCH_ITEM* aItem ) override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;

View File

@ -265,7 +265,7 @@ void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemLis
}
void SCH_BUS_ENTRY_BASE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_BUS_ENTRY_BASE::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED ) ?
@ -496,15 +496,14 @@ void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter, bool aBackground,
if( aBackground )
return;
auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
SCH_RENDER_SETTINGS* cfg = static_cast<SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED )
? settings->GetLayerColor( m_layer )
: GetBusEntryColor();
COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED ) ? cfg->GetLayerColor( m_layer )
: GetBusEntryColor();
int penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth();
int penWidth = ( GetPenWidth() == 0 ) ? cfg->GetDefaultPenWidth() : GetPenWidth();
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
penWidth = std::max( penWidth, cfg->GetMinPenWidth() );
aPlotter->SetCurrentLineWidth( penWidth );
aPlotter->SetColor( color );

View File

@ -91,7 +91,7 @@ public:
void ViewGetLayers( int aLayers[], int& aCount ) const override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
const BOX2I GetBoundingBox() const override;

View File

@ -133,11 +133,11 @@ void SCH_COMMIT::pushLibEdit( const wxString& aMessage, int aCommitFlags )
{
view->Update( symbol );
symbol->RunOnChildren(
symbol->RunOnLibChildren(
[&]( LIB_ITEM* aChild )
{
view->Update( aChild );
});
} );
}
if( !( aCommitFlags & SKIP_UNDO ) )

View File

@ -1451,17 +1451,16 @@ void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
void SCH_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
{
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
COLOR4D bg = GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
const wxBrush& brush =
wxBrush( GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ).ToColour() );
aSettings->GetPrintDC()->SetBackground( brush );
aSettings->GetPrintDC()->Clear();
cfg->GetPrintDC()->SetBackground( wxBrush( bg.ToColour() ) );
cfg->GetPrintDC()->Clear();
aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
GetScreen()->Print( aSettings );
PrintDrawingSheet( aSettings, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS,
fileName );
cfg->GetPrintDC()->SetLogicalFunction( wxCOPY );
GetScreen()->Print( cfg );
PrintDrawingSheet( cfg, GetScreen(), Schematic().GetProperties(), schIUScale.IU_PER_MILS, fileName );
}

View File

@ -349,7 +349,7 @@ SCH_FIELD::GetRenderCache( const wxString& forResolvedText, const VECTOR2I& forP
}
void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_FIELD::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet();
wxDC* DC = aSettings->GetPrintDC();

View File

@ -219,7 +219,7 @@ public:
GetRenderCache( const wxString& forResolvedText, const VECTOR2I& forPosition,
TEXT_ATTRIBUTES& aAttrs ) const;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Move( const VECTOR2I& aMoveVector ) override
{

View File

@ -1496,8 +1496,8 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA
aFormatter.Print( 0, " %d %d %c %c %d %c %c\n",
0, schIUScale.IUToMils( aSymbol->GetPinNameOffset() ),
aSymbol->ShowPinNumbers() ? 'Y' : 'N',
aSymbol->ShowPinNames() ? 'Y' : 'N',
aSymbol->GetShowPinNumbers() ? 'Y' : 'N',
aSymbol->GetShowPinNames() ? 'Y' : 'N',
aSymbol->GetUnitCount(), aSymbol->UnitsLocked() ? 'L' : 'F',
aSymbol->IsPower() ? 'P' : 'N' );

View File

@ -166,11 +166,11 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
// TODO: add anchor position token here.
if( !aSymbol->ShowPinNumbers() )
if( !aSymbol->GetShowPinNumbers() )
aFormatter.Print( 0, " (pin_numbers hide)" );
if( aSymbol->GetPinNameOffset() != schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET )
|| !aSymbol->ShowPinNames() )
|| !aSymbol->GetShowPinNames() )
{
aFormatter.Print( 0, " (pin_names" );
@ -179,7 +179,7 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale,
aSymbol->GetPinNameOffset() ).c_str() );
if( !aSymbol->ShowPinNames() )
if( !aSymbol->GetShowPinNames() )
aFormatter.Print( 0, " hide" );
aFormatter.Print( 0, ")" );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-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
@ -349,13 +349,6 @@ bool SCH_ITEM::RenderAsBitmap( double aWorldScale ) const
}
void SCH_ITEM::Plot( PLOTTER* aPlotter, bool aBackground,
const SCH_PLOT_SETTINGS& aPlotSettings ) const
{
wxFAIL_MSG( wxT( "Plot() method not implemented for class " ) + GetClass() );
}
static struct SCH_ITEM_DESC
{
SCH_ITEM_DESC()

View File

@ -30,11 +30,11 @@
#include <set>
#include <eda_item.h>
#include <default_values.h>
#include <sch_sheet_path.h>
#include <netclass.h>
#include <stroke_params.h>
#include <layer_ids.h>
#include <sch_render_settings.h>
class CONNECTION_GRAPH;
class SCH_CONNECTION;
@ -44,16 +44,12 @@ class LINE_READER;
class SCH_EDIT_FRAME;
class PLOTTER;
struct SCH_PLOT_SETTINGS;
class NETLIST_OBJECT_LIST;
class PLOTTER;
namespace KIFONT
{
class METRICS;
}
using KIGFX::RENDER_SETTINGS;
enum FIELDS_AUTOPLACED
{
@ -249,14 +245,7 @@ public:
*/
SCHEMATIC* Schematic() const;
/**
* @return true if the object is locked, else false.
*/
virtual bool IsLocked() const { return false; }
/**
* Set the 'lock' status to \a aLocked for of this item.
*/
virtual void SetLocked( bool aLocked ) {}
/**
@ -270,12 +259,6 @@ public:
* Return the layer this item is on.
*/
SCH_LAYER_ID GetLayer() const { return m_layer; }
/**
* Set the layer this item is on.
*
* @param aLayer The layer number.
*/
void SetLayer( SCH_LAYER_ID aLayer ) { m_layer = aLayer; }
/**
@ -297,11 +280,16 @@ public:
/**
* Return a measure of how likely the other object is to represent the same
* object. The scale runs from 0.0 (definitely different objects) to 1.0 (same)
*
* This is a pure virtual function. Derived classes must implement this.
*/
virtual double Similarity( const SCH_ITEM& aItem ) const = 0;
virtual bool operator==( const SCH_ITEM& aOtherItem ) const = 0;
*/
virtual double Similarity( const SCH_ITEM& aItem ) const
{
wxCHECK_MSG( false, 0.0, wxT( "Similarity not implemented in " ) + GetClass() );
}
virtual bool operator==( const SCH_ITEM& aOtherItem ) const
{
wxCHECK_MSG( false, false, wxT( "operator== not implemented in " ) + GetClass() );
}
/**
* Print a schematic item.
@ -311,36 +299,73 @@ public:
* @param aOffset is the drawing offset (usually {0,0} but can be different when moving an
* object).
*/
virtual void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) = 0;
virtual void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxCHECK_MSG( false, /*void*/, wxT( "Print not implemented in " ) + GetClass() );
}
/**
* Print the (optional) backaground elements if they exist
* @param aSettings Print settings
* @param aOffset is the drawing offset (usually {0,0} but can be different when moving an
* object).
* Print just the background fills.
*/
virtual void PrintBackground( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxCHECK_MSG( false, /*void*/, wxT( "PrintBackground not implemented in " ) + GetClass() );
}
virtual void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) {};
/**
* Print item.
*
* @param aOffset - Position of the item.
* @param aMulti - unit if multiple units per symbol.
* @param aBodyStyle - Symbol alternate body style (DeMorgan) if available.
* @param aDimmed - Reduce brightness
*/
virtual void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
int aMulti, int aBodyStyle, bool aForceNoFill, bool aDimmed )
{
wxCHECK_MSG( false, /*void*/, wxT( "Print not implemented in " ) + GetClass() );
}
/**
* Print just the background fills.
*/
virtual void PrintBackground( const SCH_RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset,
int aMulti, int aBodyStyle, bool aForceNoFill, bool aDimmed )
{
wxCHECK_MSG( false, /*void*/, wxT( "PrintBackground not implemented in " ) + GetClass() );
}
/**
* Move the item by \a aMoveVector to a new position.
*/
virtual void Move( const VECTOR2I& aMoveVector ) = 0;
virtual void Move( const VECTOR2I& aMoveVector )
{
wxCHECK_MSG( false, /*void*/, wxT( "Move not implemented in " ) + GetClass() );
}
/**
* Mirror item horizontally about \a aCenter.
*/
virtual void MirrorHorizontally( int aCenter ) = 0;
virtual void MirrorHorizontally( int aCenter )
{
wxCHECK_MSG( false, /*void*/, wxT( "MirrorHorizontally not implemented in " ) + GetClass() );
}
/**
* Mirror item vertically about \a aCenter.
*/
virtual void MirrorVertically( int aCenter ) = 0;
virtual void MirrorVertically( int aCenter )
{
wxCHECK_MSG( false, /*void*/, wxT( "MirrorVertically not implemented in " ) + GetClass() );
}
/**
* Rotate the item around \a aCenter 90 degrees in the clockwise direction.
*/
virtual void Rotate( const VECTOR2I& aCenter ) = 0;
virtual void Rotate( const VECTOR2I& aCenter )
{
wxCHECK_MSG( false, /*void*/, wxT( "Rotate not implemented in " ) + GetClass() );
}
/**
* Add the schematic item end points to \a aItemList if the item has end points.
@ -533,7 +558,16 @@ public:
* aBackground true and then with aBackground false.
*/
virtual void Plot( PLOTTER* aPlotter, bool aBackground,
const SCH_PLOT_SETTINGS& aPlotSettings ) const;
const SCH_PLOT_SETTINGS& aPlotSettings ) const
{
wxCHECK_MSG( false, /*void*/, wxT( "Plot not implemented in " ) + GetClass() );
}
virtual void Plot( PLOTTER* aPlotter, int aUnit, int aBodyStyle, bool aBackground,
const VECTOR2I& aOffset, const TRANSFORM& aTransform, bool aDimmed ) const
{
wxCHECK_MSG( false, /*void*/, wxT( "Plot not implemented in " ) + GetClass() );
}
virtual bool operator <( const SCH_ITEM& aItem ) const;

View File

@ -113,7 +113,7 @@ const BOX2I SCH_JUNCTION::GetBoundingBox() const
}
void SCH_JUNCTION::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_JUNCTION::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = GetJunctionColor();

View File

@ -69,7 +69,7 @@ public:
const BOX2I GetBoundingBox() const override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Move( const VECTOR2I& aMoveVector ) override
{

View File

@ -47,8 +47,6 @@
#include <api/api_utils.h>
#include <api/schematic/schematic_types.pb.h>
using KIGFX::SCH_RENDER_SETTINGS;
bool IncrementLabelMember( wxString& name, int aIncrement )
{
@ -1408,7 +1406,7 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground,
}
void SCH_LABEL_BASE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_LABEL_BASE::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
static std::vector<VECTOR2I> s_poly;

View File

@ -324,7 +324,7 @@ public:
void Plot( PLOTTER* aPlotter, bool aBackground,
const SCH_PLOT_SETTINGS& aPlotSettings ) const override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
/**
* @brief autoRotateOnPlacement

View File

@ -359,7 +359,7 @@ int SCH_LINE::GetPenWidth() const
}
void SCH_LINE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset )
void SCH_LINE::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& offset )
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = GetLineColor();
@ -903,7 +903,7 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground,
if( aBackground )
return;
auto* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
auto* settings = static_cast<SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
int penWidth = std::max( GetPenWidth(), settings->GetMinPenWidth() );
COLOR4D color = GetLineColor();

View File

@ -202,7 +202,7 @@ public:
*/
double GetLength() const;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
int GetPenWidth() const override;

View File

@ -253,7 +253,7 @@ SEVERITY SCH_MARKER::GetSeverity() const
}
void SCH_MARKER::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_MARKER::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
PrintMarker( aSettings, aOffset );
}

View File

@ -62,7 +62,7 @@ public:
SEVERITY GetSeverity() const override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Plot( PLOTTER* /* aPlotter */, bool /* aBackground */,
const SCH_PLOT_SETTINGS& /* aPlotSettings */ ) const override

View File

@ -102,7 +102,7 @@ int SCH_NO_CONNECT::GetPenWidth() const
}
void SCH_NO_CONNECT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_NO_CONNECT::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
int half = GetSize() / 2;

View File

@ -65,7 +65,7 @@ public:
void ViewGetLayers( int aLayers[], int& aCount ) const override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) override;

View File

@ -100,57 +100,6 @@ std::vector<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
};
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_IsSymbolEditor( false ),
m_ShowUnit( 0 ),
m_ShowBodyStyle( 0 ),
m_ShowPinsElectricalType( true ),
m_ShowHiddenLibPins( true ), // Force showing of hidden pin ( symbol editor specific)
m_ShowHiddenLibFields( true ), // Force showing of hidden fields ( symbol editor specific)
m_ShowPinNumbers( false ),
m_ShowDisabled( false ),
m_ShowGraphicsDisabled( false ),
m_OverrideItemColors( false ),
m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ),
m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ),
m_PinSymbolSize( DEFAULT_TEXT_SIZE * schIUScale.IU_PER_MILS / 2 )
{
SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS );
SetDashLengthRatio( 12 ); // From ISO 128-2
SetGapLengthRatio( 3 ); // From ISO 128-2
m_minPenWidth = ADVANCED_CFG::GetCfg().m_MinPlotPenWidth * schIUScale.IU_PER_MM;
}
void SCH_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
{
for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
m_layerColors[ layer ] = aSettings->GetColor( layer );
for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
m_layerColors[ layer ] = aSettings->GetColor( layer );
m_backgroundColor = aSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
m_layerColors[LAYER_AUX_ITEMS] = m_layerColors[LAYER_SCHEMATIC_AUX_ITEMS];
m_OverrideItemColors = aSettings->GetOverrideSchItemColors();
}
COLOR4D SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
{
return m_layerColors[ aLayer ];
}
bool SCH_RENDER_SETTINGS::GetShowPageLimits() const
{
return eeconfig() && eeconfig()->m_Appearance.show_page_limits && !IsPrinting();
}
/**
* Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
* This symbol is a 400 mils square with the text "??"
@ -1123,7 +1072,7 @@ void SCH_PAINTER::draw( const LIB_FIELD* aField, int aLayer, bool aDimmed )
// Draw the umbilical line when in the schematic editor
if( aField->IsMoving() && m_schematic )
{
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
m_gal->SetLineWidth( m_schSettings.GetOutlineWidth() );
m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
m_gal->DrawLine( bbox.Centre(), VECTOR2I( 0, 0 ) );
}
@ -1630,7 +1579,7 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
}
}
LIB_SYMBOL* libEntry = aPin->GetParent();
const SYMBOL* libEntry = aPin->GetParentSymbol();
// Draw the labels
@ -1644,8 +1593,8 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
int textOffset = libEntry->GetPinNameOffset();
float nameStrokeWidth = getLineWidth( aPin, false );
float numStrokeWidth = getLineWidth( aPin, false );
bool showPinNames = libEntry->ShowPinNames();
bool showPinNumbers = m_schSettings.m_ShowPinNumbers || libEntry->ShowPinNumbers();
bool showPinNames = libEntry->GetShowPinNames();
bool showPinNumbers = m_schSettings.m_ShowPinNumbers || libEntry->GetShowPinNumbers();
nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), true );
numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), true );
@ -2485,7 +2434,7 @@ void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer )
lineStyle = stroke.GetLineStyle();
if( lineWidth == 0 )
lineWidth = m_schSettings.m_defaultPenWidth;
lineWidth = m_schSettings.GetDefaultPenWidth();
if( color == COLOR4D::UNSPECIFIED )
color = m_schSettings.GetLayerColor( LAYER_NOTES );
@ -2910,7 +2859,7 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed )
{
VECTOR2I parentPos = aField->GetParentPosition();
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
m_gal->SetLineWidth( m_schSettings.GetOutlineWidth() );
m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
m_gal->DrawLine( bbox.Centre(), parentPos );
}

View File

@ -27,6 +27,7 @@
#ifndef __SCH_PAINTER_H
#define __SCH_PAINTER_H
#include <sch_render_settings.h>
#include <sch_symbol.h>
#include <gal/painter.h>
@ -65,71 +66,6 @@ class GAL;
class SCH_PAINTER;
/**
* Store schematic specific render settings.
*/
class SCH_RENDER_SETTINGS : public RENDER_SETTINGS
{
public:
friend class SCH_PAINTER;
SCH_RENDER_SETTINGS();
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
/// @copydoc RENDER_SETTINGS::GetColor()
virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
bool IsBackgroundDark() const override
{
auto luma = m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ].GetBrightness();
return luma < 0.5;
}
const COLOR4D& GetBackgroundColor() const override
{
return m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ];
}
void SetBackgroundColor( const COLOR4D& aColor ) override
{
m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ] = aColor;
}
float GetDanglingIndicatorThickness() const
{
return (float) m_defaultPenWidth / 3.0F;
}
const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_SCHEMATIC_GRID ]; }
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; }
bool GetShowPageLimits() const override;
public:
bool m_IsSymbolEditor;
int m_ShowUnit; // Show all units if 0
int m_ShowBodyStyle; // Show all body styles if 0
bool m_ShowPinsElectricalType;
bool m_ShowHiddenLibPins; // Force showing of hidden pin ( symbol editor specific)
bool m_ShowHiddenLibFields; // Force showing of hidden fields ( symbol editor specific)
bool m_ShowPinNumbers; // Force showing of pin numbers (normally symbol-specific)
bool m_ShowDisabled;
bool m_ShowGraphicsDisabled;
bool m_OverrideItemColors;
double m_LabelSizeRatio; // Proportion of font size to label box
double m_TextOffsetRatio; // Proportion of font size to offset text above/below
// wires, buses, etc.
int m_PinSymbolSize;
};
/**
* Contains methods for drawing schematic-specific items.
*/

View File

@ -318,7 +318,7 @@ wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoC
// with legacy global power pins on non-power symbols
if( IsGlobalPower() )
{
if( GetLibPin()->GetParent()->IsPower() )
if( GetLibPin()->GetParentSymbol()->IsPower() )
{
return EscapeString( GetParentSymbol()->GetValueFieldText( true, &aPath, false ),
CTX_NETNAME );

View File

@ -71,7 +71,7 @@ public:
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {}
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {}
void Move( const VECTOR2I& aMoveVector ) override {}

View File

@ -54,7 +54,7 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo
m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) );
KIGFX::SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings();
SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings();
renderSettings->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
renderSettings->m_ShowPinsElectricalType = false;
renderSettings->m_ShowPinNumbers = false;
@ -90,9 +90,9 @@ SCH_PREVIEW_PANEL::~SCH_PREVIEW_PANEL()
}
KIGFX::SCH_RENDER_SETTINGS* SCH_PREVIEW_PANEL::GetRenderSettings() const
SCH_RENDER_SETTINGS* SCH_PREVIEW_PANEL::GetRenderSettings() const
{
return static_cast<KIGFX::SCH_RENDER_SETTINGS*>( m_painter->GetSettings() );
return static_cast<SCH_RENDER_SETTINGS*>( m_painter->GetSettings() );
}

View File

@ -28,8 +28,9 @@
#include <class_draw_panel_gal.h>
class SCH_RENDER_SETTINGS;
namespace KIGFX {
class SCH_RENDER_SETTINGS;
class SCH_VIEW;
namespace PREVIEW {
class SELECTION_AREA;
@ -52,7 +53,7 @@ public:
/// @copydoc wxWindow::Refresh()
void Refresh( bool aEraseBackground, const wxRect* aRect ) override;
KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings() const;
SCH_RENDER_SETTINGS* GetRenderSettings() const;
protected:

View File

@ -0,0 +1,82 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <pgm_base.h>
#include <kiface_base.h>
#include <advanced_config.h>
#include <settings/settings_manager.h>
#include <eeschema_settings.h>
#include <default_values.h>
#include <sch_render_settings.h>
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_IsSymbolEditor( false ),
m_ShowUnit( 0 ),
m_ShowBodyStyle( 0 ),
m_ShowPinsElectricalType( true ),
m_ShowHiddenLibPins( true ), // Force showing of hidden pin ( symbol editor specific)
m_ShowHiddenLibFields( true ), // Force showing of hidden fields ( symbol editor specific)
m_ShowVisibleLibFields( true ),
m_ShowPinNumbers( false ),
m_ShowPinNames( false ),
m_ShowPinElectricalTypes( false ),
m_ShowDisabled( false ),
m_ShowGraphicsDisabled( false ),
m_ShowConnectionPoints( false ),
m_OverrideItemColors( false ),
m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ),
m_TextOffsetRatio( DEFAULT_TEXT_OFFSET_RATIO ),
m_PinSymbolSize( DEFAULT_TEXT_SIZE * schIUScale.IU_PER_MILS / 2 ),
m_Transform()
{
SetDefaultPenWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS );
SetDashLengthRatio( 12 ); // From ISO 128-2
SetGapLengthRatio( 3 ); // From ISO 128-2
m_minPenWidth = KiROUND( ADVANCED_CFG::GetCfg().m_MinPlotPenWidth * schIUScale.IU_PER_MM );
}
void SCH_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
{
for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
m_layerColors[ layer ] = aSettings->GetColor( layer );
for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
m_layerColors[ layer ] = aSettings->GetColor( layer );
m_backgroundColor = aSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
m_layerColors[LAYER_AUX_ITEMS] = m_layerColors[LAYER_SCHEMATIC_AUX_ITEMS];
m_OverrideItemColors = aSettings->GetOverrideSchItemColors();
}
bool SCH_RENDER_SETTINGS::GetShowPageLimits() const
{
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
return cfg && cfg->m_Appearance.show_page_limits && !IsPrinting();
}

View File

@ -0,0 +1,100 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef SCH_RENDER_SETTINGS_H
#define SCH_RENDER_SETTINGS_H
#include <gal/color4d.h>
#include <render_settings.h>
#include <transform.h>
using KIGFX::COLOR4D;
class SCH_RENDER_SETTINGS : public KIGFX::RENDER_SETTINGS
{
public:
SCH_RENDER_SETTINGS();
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
virtual COLOR4D GetColor( const KIGFX::VIEW_ITEM* aItem, int aLayer ) const override
{
return m_layerColors[ aLayer ];
}
bool IsBackgroundDark() const override
{
return m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ].GetBrightness() < 0.5;
}
const KIGFX::COLOR4D& GetBackgroundColor() const override
{
return m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ];
}
void SetBackgroundColor( const COLOR4D& aColor ) override
{
m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ] = aColor;
}
float GetDanglingIndicatorThickness() const
{
return (float) m_defaultPenWidth / 3.0F;
}
const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_SCHEMATIC_GRID ]; }
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; }
bool GetShowPageLimits() const override;
public:
bool m_IsSymbolEditor;
int m_ShowUnit; // Show all units if 0
int m_ShowBodyStyle; // Show all body styles if 0
bool m_ShowPinsElectricalType;
bool m_ShowHiddenLibPins; // Force showing of hidden pin ( symbol editor specific)
bool m_ShowHiddenLibFields; // Force showing of hidden fields ( symbol editor specific)
bool m_ShowVisibleLibFields;
bool m_ShowPinNumbers; // Force showing of pin numbers (normally symbol-specific)
bool m_ShowPinNames; // Force showing of pin names (normally symbol-specific)
bool m_ShowPinElectricalTypes;
bool m_ShowDisabled;
bool m_ShowGraphicsDisabled;
bool m_ShowConnectionPoints;
bool m_OverrideItemColors;
double m_LabelSizeRatio; // Proportion of font size to label box
double m_TextOffsetRatio; // Proportion of font size to offset text above/below
// wires, buses, etc.
int m_PinSymbolSize;
TRANSFORM m_Transform;
};
#endif /* SCH_RENDER_SETTINGS_H */

View File

@ -1065,7 +1065,7 @@ void SCH_SCREEN::SetConnectivityDirty()
}
void SCH_SCREEN::Print( const RENDER_SETTINGS* aSettings )
void SCH_SCREEN::Print( const SCH_RENDER_SETTINGS* aSettings )
{
// Ensure links are up to date, even if a library was reloaded for some reason:
std::vector<SCH_ITEM*> junctions;

View File

@ -246,7 +246,7 @@ public:
* @note This function is useful only for schematic. The library editor and library viewer
* do not use a draw list and therefore draws nothing.
*/
void Print( const RENDER_SETTINGS* aSettings );
void Print( const SCH_RENDER_SETTINGS* aSettings );
/**
* Plot all the schematic objects to \a aPlotter.

View File

@ -227,7 +227,7 @@ int SCH_SHAPE::GetPenWidth() const
}
void SCH_SHAPE::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_SHAPE::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color;
@ -293,7 +293,7 @@ void SCH_SHAPE::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2
}
void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_SHAPE::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
int penWidth = GetPenWidth();
wxDC* DC = aSettings->GetPrintDC();

View File

@ -125,8 +125,8 @@ protected:
private:
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void PrintBackground( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
};

View File

@ -1147,15 +1147,14 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground,
if( aBackground && !aPlotter->GetColorMode() )
return;
auto* settings = dynamic_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
bool override = settings ? settings->m_OverrideItemColors : false;
COLOR4D borderColor = GetBorderColor();
COLOR4D backgroundColor = GetBackgroundColor();
SCH_RENDER_SETTINGS* cfg = static_cast<SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
COLOR4D borderColor = GetBorderColor();
COLOR4D backgroundColor = GetBackgroundColor();
if( override || borderColor == COLOR4D::UNSPECIFIED )
if( cfg->m_OverrideItemColors || borderColor == COLOR4D::UNSPECIFIED )
borderColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET );
if( override || backgroundColor == COLOR4D::UNSPECIFIED )
if( cfg->m_OverrideItemColors || backgroundColor == COLOR4D::UNSPECIFIED )
backgroundColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET_BACKGROUND );
if( aBackground && backgroundColor.a > 0.0 )
@ -1195,20 +1194,18 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground,
}
void SCH_SHEET::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_SHEET::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
VECTOR2I pos = m_pos + aOffset;
int lineWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
const auto* settings = dynamic_cast<const KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
bool override = settings && settings->m_OverrideItemColors;
COLOR4D border = GetBorderColor();
COLOR4D background = GetBackgroundColor();
wxDC* DC = aSettings->GetPrintDC();
VECTOR2I pos = m_pos + aOffset;
int lineWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
COLOR4D border = GetBorderColor();
COLOR4D background = GetBackgroundColor();
if( override || border == COLOR4D::UNSPECIFIED )
if( aSettings->m_OverrideItemColors || border == COLOR4D::UNSPECIFIED )
border = aSettings->GetLayerColor( LAYER_SHEET );
if( override || background == COLOR4D::UNSPECIFIED )
if( aSettings->m_OverrideItemColors || background == COLOR4D::UNSPECIFIED )
background = aSettings->GetLayerColor( LAYER_SHEET_BACKGROUND );
if( GetGRForceBlackPenState() ) // printing in black & white

View File

@ -249,7 +249,7 @@ public:
int GetPenWidth() const override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
/**
* Return a bounding box for the sheet body but not the fields.

View File

@ -74,7 +74,7 @@ public:
// pure virtuals:
void SetPosition( const VECTOR2I& ) override {}
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {}
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {}
void Move( const VECTOR2I& aMoveVector ) override {}
void MirrorHorizontally( int aCenter ) override {}
void MirrorVertically( int aCenter ) override {}
@ -348,7 +348,7 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences() const
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
symbol->GetField( REFERENCE_FIELD )->SetText( symbol->GetRef( this ) );
symbol->UpdateUnit( symbol->GetUnitSelection( this ) );
symbol->SetUnit( symbol->GetUnitSelection( this ) );
LastScreen()->Update( item, false );
}
else if( item->Type() == SCH_GLOBAL_LABEL_T )

View File

@ -65,7 +65,7 @@ EDA_ITEM* SCH_SHEET_PIN::Clone() const
}
void SCH_SHEET_PIN::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_SHEET_PIN::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
// The icon selection is handle by the virtual method CreateGraphicShape called by ::Print
SCH_HIERLABEL::Print( aSettings, aOffset );

View File

@ -105,7 +105,7 @@ public:
*/
bool IsMovableFromAnchorPoint() const override { return true; }
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
/**
* Calculate the graphic shape (a polygon) associated to the text.

View File

@ -100,7 +100,7 @@ static LIB_SYMBOL* dummy()
SCH_SYMBOL::SCH_SYMBOL() :
SCH_ITEM( nullptr, SCH_SYMBOL_T )
SYMBOL( nullptr, SCH_SYMBOL_T )
{
m_DNP = false;
Init( VECTOR2I( 0, 0 ) );
@ -110,7 +110,7 @@ SCH_SYMBOL::SCH_SYMBOL() :
SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId,
const SCH_SHEET_PATH* aSheet, int aUnit, int aBodyStyle,
const VECTOR2I& aPosition, EDA_ITEM* aParent ) :
SCH_ITEM( aParent, SCH_SYMBOL_T )
SYMBOL( aParent, SCH_SYMBOL_T )
{
Init( aPosition );
@ -164,7 +164,7 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet,
SCH_SYMBOL::SCH_SYMBOL( const SCH_SYMBOL& aSymbol ) :
SCH_ITEM( aSymbol )
SYMBOL( aSymbol )
{
m_parent = aSymbol.m_parent;
m_pos = aSymbol.m_pos;
@ -172,9 +172,6 @@ SCH_SYMBOL::SCH_SYMBOL( const SCH_SYMBOL& aSymbol ) :
m_bodyStyle = aSymbol.m_bodyStyle;
m_lib_id = aSymbol.m_lib_id;
m_isInNetlist = aSymbol.m_isInNetlist;
m_excludedFromSim = aSymbol.m_excludedFromSim;
m_excludedFromBOM = aSymbol.m_excludedFromBOM;
m_excludedFromBoard = aSymbol.m_excludedFromBoard;
m_DNP = aSymbol.m_DNP;
const_cast<KIID&>( m_Uuid ) = aSymbol.m_Uuid;
@ -251,21 +248,6 @@ bool SCH_SYMBOL::IsMissingLibSymbol() const
}
void SCH_SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 8;
aLayers[0] = LAYER_DANGLING; // Pins are drawn by their parent symbol, so the parent
// symbol needs to draw to LAYER_DANGLING
aLayers[1] = LAYER_OP_CURRENTS; // Same for pin operating points
aLayers[2] = LAYER_DEVICE;
aLayers[3] = LAYER_REFERENCEPART;
aLayers[4] = LAYER_VALUEPART;
aLayers[5] = LAYER_FIELDS;
aLayers[6] = LAYER_DEVICE_BACKGROUND;
aLayers[7] = LAYER_SELECTION_SHADOWS;
}
bool SCH_SYMBOL::IsMovableFromAnchorPoint() const
{
// If a symbol's anchor is not grid-aligned to its pins then moving from the anchor is
@ -452,18 +434,6 @@ void SCH_SYMBOL::UpdatePins()
}
void SCH_SYMBOL::SetUnit( int aUnit )
{
UpdateUnit( aUnit );
}
void SCH_SYMBOL::UpdateUnit( int aUnit )
{
m_unit = aUnit;
}
void SCH_SYMBOL::SetBodyStyle( int aBodyStyle )
{
if( m_bodyStyle != aBodyStyle )
@ -476,6 +446,15 @@ void SCH_SYMBOL::SetBodyStyle( int aBodyStyle )
}
bool SCH_SYMBOL::HasAlternateBodyStyle() const
{
if( m_part )
return m_part->HasAlternateBodyStyle();
return false;
}
void SCH_SYMBOL::SetTransform( const TRANSFORM& aTransform )
{
if( m_transform != aTransform )
@ -508,24 +487,24 @@ bool SCH_SYMBOL::HasUnitDisplayName( int aUnit )
}
void SCH_SYMBOL::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
LIB_SYMBOL_OPTIONS opts;
opts.transform = m_transform;
opts.draw_visible_fields = false;
opts.draw_hidden_fields = false;
SCH_RENDER_SETTINGS cfg( *aSettings );
cfg.m_Transform = m_transform;
cfg.m_ShowVisibleLibFields = false;
cfg.m_ShowHiddenLibFields = false;
if( m_part )
m_part->PrintBackground( aSettings, m_pos + aOffset, m_unit, m_bodyStyle, opts, GetDNP() );
m_part->PrintBackground( &cfg, m_pos + aOffset, m_unit, m_bodyStyle, false, GetDNP() );
}
void SCH_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
LIB_SYMBOL_OPTIONS opts;
opts.transform = m_transform;
opts.draw_visible_fields = false;
opts.draw_hidden_fields = false;
SCH_RENDER_SETTINGS cfg( *aSettings );
cfg.m_Transform = m_transform;
cfg.m_ShowVisibleLibFields = false;
cfg.m_ShowHiddenLibFields = false;
if( m_part )
{
@ -558,21 +537,21 @@ void SCH_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse
}
}
tempSymbol.Print( aSettings, m_pos + aOffset, m_unit, m_bodyStyle, opts, GetDNP() );
tempSymbol.Print( &cfg, m_pos + aOffset, m_unit, m_bodyStyle, false, GetDNP() );
}
else // Use dummy() part if the actual cannot be found.
{
dummy()->Print( aSettings, m_pos + aOffset, 0, 0, opts, GetDNP() );
dummy()->Print( &cfg, m_pos + aOffset, 0, 0, false, GetDNP() );
}
for( SCH_FIELD& field : m_fields )
field.Print( aSettings, aOffset );
field.Print( &cfg, aOffset );
if( m_DNP )
{
BOX2I bbox = GetBodyAndPinsBoundingBox();
wxDC* DC = aSettings->GetPrintDC();
COLOR4D dnp_color = aSettings->GetLayerColor( LAYER_DNP_MARKER );
wxDC* DC = cfg.GetPrintDC();
COLOR4D dnp_color = cfg.GetLayerColor( LAYER_DNP_MARKER );
GRFilledSegment( DC, bbox.GetOrigin(), bbox.GetEnd(),
3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ),
@ -2613,7 +2592,7 @@ void SCH_SYMBOL::PlotPins( PLOTTER* aPlotter ) const
bool SCH_SYMBOL::HasBrightenedPins()
{
for( const auto& pin : m_pins )
for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
{
if( pin->IsBrightened() )
return true;
@ -2625,7 +2604,7 @@ bool SCH_SYMBOL::HasBrightenedPins()
void SCH_SYMBOL::ClearBrightenedPins()
{
for( auto& pin : m_pins )
for( std::unique_ptr<SCH_PIN>& pin : m_pins )
pin->ClearBrightened();
}
@ -2679,6 +2658,14 @@ bool SCH_SYMBOL::IsPower() const
}
bool SCH_SYMBOL::IsNormal() const
{
wxCHECK( m_part, false );
return m_part->IsNormal();
}
bool SCH_SYMBOL::operator==( const SCH_ITEM& aOther ) const
{
if( Type() != aOther.Type() )
@ -2746,7 +2733,7 @@ static struct SCH_SYMBOL_DESC
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
REGISTER_TYPE( SCH_SYMBOL );
propMgr.InheritsAfter( TYPE_HASH( SCH_SYMBOL ), TYPE_HASH( SCH_ITEM ) );
propMgr.InheritsAfter( TYPE_HASH( SCH_SYMBOL ), TYPE_HASH( SYMBOL ) );
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, int>( _HKI( "Position X" ),
&SCH_SYMBOL::SetX, &SCH_SYMBOL::GetX, PROPERTY_DISPLAY::PT_COORD,
@ -2766,7 +2753,7 @@ static struct SCH_SYMBOL_DESC
auto hasLibPart = []( INSPECTABLE* aItem ) -> bool
{
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( aItem ) )
return symbol->GetLibSymbolRef().get() != nullptr;
return symbol->GetLibSymbolRef() != nullptr;
return false;
};

View File

@ -25,8 +25,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __SYMBOL_H__
#define __SYMBOL_H__
#ifndef SCH_SYMBOL_H
#define SCH_SYMBOL_H
#include <eda_item.h>
#include <core/typeinfo.h>
@ -45,8 +45,8 @@
#include <wx/string.h>
#include <schematic.h>
#include <symbol.h>
#include <sch_field.h>
#include <sch_item.h>
#include <sch_pin.h>
#include <sch_sheet_path.h> // SCH_SYMBOL_INSTANCE
#include <symbol_lib_table.h>
@ -105,7 +105,7 @@ enum SYMBOL_ORIENTATION_PROP
/**
* Schematic symbol object.
*/
class SCH_SYMBOL : public SCH_ITEM
class SCH_SYMBOL : public SYMBOL
{
public:
SCH_SYMBOL();
@ -180,8 +180,6 @@ public:
void SortInstances( bool ( *aSortFunction )( const SCH_SYMBOL_INSTANCE& aLhs,
const SCH_SYMBOL_INSTANCE& aRhs ) );
void ViewGetLayers( int aLayers[], int& aCount ) const override;
/**
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor.
@ -200,7 +198,7 @@ public:
void SetLibId( const LIB_ID& aName );
const LIB_ID& GetLibId() const { return m_lib_id; }
const LIB_ID& GetLibId() const override { return m_lib_id; }
wxString GetSymbolIDAsString() const { return m_lib_id.Format(); }
@ -243,12 +241,12 @@ public:
/**
* @return the associated LIB_SYMBOL's description field (or wxEmptyString).
*/
wxString GetDescription() const;
wxString GetDescription() const override;
/**
* @return the associated LIB_SYMBOL's keywords field (or wxEmptyString).
*/
wxString GetKeyWords() const;
wxString GetKeyWords() const override;
/**
* Return the documentation text for the given part alias
@ -256,23 +254,13 @@ public:
wxString GetDatasheet() const;
int GetUnit() const { return m_unit; }
void SetUnit( int aUnit ) { m_unit = aUnit; }
/**
* Updates the cache of SCH_PIN objects for each pin
*/
void UpdatePins();
/**
* Change the unit number to \a aUnit
*
* This has meaning only for symbols made up of multiple units per package.
*
* @note This also set the modified flag bit
*
* @param aUnit is the new unit to select.
*/
void SetUnit( int aUnit );
/**
* Return true if the given unit \a aUnit has a display name set.
*
@ -287,21 +275,12 @@ public:
*/
wxString GetUnitDisplayName( int aUnit );
/**
* Change the unit number to \a aUnit without setting any internal flags.
* This has meaning only for symbols made up of multiple units per package.
*
* @note This also set the modified flag bit
*
* @param aUnit is the new unit to select.
*/
void UpdateUnit( int aUnit );
int GetBodyStyle() const { return m_bodyStyle; }
void SetBodyStyle( int aBodyStyle );
wxString GetPrefix() const { return m_prefix; }
bool HasAlternateBodyStyle() const override;
wxString GetPrefix() const { return m_prefix; }
void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
/**
@ -321,7 +300,9 @@ public:
*
* @return the number of units per package or zero if the library entry cannot be found.
*/
int GetUnitCount() const;
int GetUnitCount() const override;
bool IsMulti() const override { return GetUnitCount() > 1; }
/**
* Compute the new transform matrix based on \a aOrientation for the symbol which is
@ -556,7 +537,7 @@ public:
{
return GetRef( &Schematic()->CurrentSheet() );
}
void SetRefProp( const wxString aRef )
void SetRefProp( const wxString& aRef )
{
SetRef( &Schematic()->CurrentSheet(), aRef );
}
@ -564,7 +545,7 @@ public:
{
return GetValueFieldText( false, &Schematic()->CurrentSheet(), false );
}
void SetValueProp( const wxString aRef )
void SetValueProp( const wxString& aRef )
{
SetValueFieldText( aRef );
}
@ -655,7 +636,7 @@ public:
* @param aOffset is the drawing offset (usually VECTOR2I(0,0), but can be different when
* moving an object)
*/
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
/**
* Print only the background parts of a symbol (if any)
@ -664,7 +645,7 @@ public:
* @param aOffset is the drawing offset (usually VECTOR2I(0,0), but can be different when
* moving an object)
*/
void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void PrintBackground( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
void SwapData( SCH_ITEM* aItem ) override;
@ -727,8 +708,6 @@ public:
/// Set the selected unit of this symbol for all sheets.
void SetUnitSelection( int aUnitSelection );
// Geometric transforms (used in block operations):
void Move( const VECTOR2I& aMoveVector ) override
{
if( aMoveVector == VECTOR2I( 0, 0 ) )
@ -869,7 +848,7 @@ public:
bool GetShowPinNumbers() const
{
return m_part && m_part->ShowPinNumbers();
return m_part && m_part->GetShowPinNumbers();
}
void SetShowPinNumbers( bool aShow )
@ -878,7 +857,7 @@ public:
m_part->SetShowPinNumbers( aShow );
}
bool GetShowPinNames() const { return m_part && m_part->ShowPinNames(); }
bool GetShowPinNames() const { return m_part && m_part->GetShowPinNames(); }
void SetShowPinNames( bool aShow )
{
@ -895,7 +874,8 @@ public:
*/
bool IsSymbolLikePowerGlobalLabel() const;
bool IsPower() const;
bool IsPower() const override;
bool IsNormal() const override;
double Similarity( const SCH_ITEM& aOther ) const override;
@ -950,4 +930,4 @@ private:
static std::unordered_map<TRANSFORM, int> s_transformToOrientationCache;
};
#endif /* __SYMBOL_H__ */
#endif /* SCH_SYMBOL_H */

View File

@ -34,8 +34,6 @@
#include <wx/log.h>
#include <sch_table.h>
using KIGFX::SCH_RENDER_SETTINGS;
SCH_TABLE::SCH_TABLE( int aLineWidth ) :
SCH_ITEM( nullptr, SCH_TABLE_T ),
@ -238,7 +236,7 @@ void SCH_TABLE::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction
}
void SCH_TABLE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_TABLE::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
for( SCH_TABLECELL* cell : m_cells )
cell->Print( aSettings, aOffset );

View File

@ -88,7 +88,7 @@ public:
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
bool operator<( const SCH_ITEM& aItem ) const override;

View File

@ -28,8 +28,6 @@
#include <sch_table.h>
#include <sch_tablecell.h>
using KIGFX::SCH_RENDER_SETTINGS;
SCH_TABLECELL::SCH_TABLECELL( int aLineWidth, FILL_T aFillType ) :
SCH_TEXTBOX( aLineWidth, aFillType, wxEmptyString, SCH_TABLECELL_T ),
@ -98,7 +96,7 @@ wxString SCH_TABLECELL::GetAddr() const
}
void SCH_TABLECELL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_TABLECELL::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
if( m_colSpan >= 1 && m_rowSpan >= 1 )
SCH_TEXTBOX::Print( aSettings, aOffset );

View File

@ -64,7 +64,7 @@ public:
int GetRowSpan() const { return m_rowSpan; }
void SetRowSpan( int aSpan ) { m_rowSpan = aSpan; }
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void Plot( PLOTTER* aPlotter, bool aBackground,
const SCH_PLOT_SETTINGS& aPlotSettings ) const override;

View File

@ -45,8 +45,6 @@
#include <tools/sch_navigate_tool.h>
#include <trigo.h>
using KIGFX::SCH_RENDER_SETTINGS;
SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) :
SCH_ITEM( nullptr, aType ),
@ -196,7 +194,7 @@ KIFONT::FONT* SCH_TEXT::getDrawFont() const
}
void SCH_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_TEXT::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
COLOR4D color = GetTextColor();
bool blackAndWhiteMode = GetGRForceBlackPenState();

View File

@ -89,7 +89,7 @@ public:
*/
virtual VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const;
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void SwapData( SCH_ITEM* aItem ) override;

View File

@ -40,8 +40,6 @@
#include <sch_textbox.h>
#include <tools/sch_navigate_tool.h>
using KIGFX::SCH_RENDER_SETTINGS;
SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text, KICAD_T aType ) :
SCH_SHAPE( SHAPE_T::RECTANGLE, aLineWidth, aFillType, aType ),
@ -264,7 +262,7 @@ KIFONT::FONT* SCH_TEXTBOX::getDrawFont() const
}
void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
void SCH_TEXTBOX::Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
wxDC* DC = aSettings->GetPrintDC();
int penWidth = GetPenWidth();

View File

@ -92,7 +92,7 @@ public:
void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
bool GetExcludedFromSim() const override { return m_excludedFromSim; }
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void Print( const SCH_RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
void SwapData( SCH_ITEM* aItem ) override;

View File

@ -654,7 +654,7 @@ void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard()
GRForceBlackPen( false );
dc.SetUserScale( scale, scale );
KIGFX::SCH_RENDER_SETTINGS* cfg = GetRenderSettings();
SCH_RENDER_SETTINGS* cfg = GetRenderSettings();
cfg->SetPrintDC( &dc );

52
eeschema/symbol.cpp Normal file
View File

@ -0,0 +1,52 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <symbol.h>
void SYMBOL::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 0;
// Pins are drawn by their parent symbol, so the parent must draw to LAYER_DANGLING
if( Type() == SCH_SYMBOL_T )
aLayers[aCount++] = LAYER_DANGLING;
// Same for operating point currents
if( Type() == SCH_SYMBOL_T )
aLayers[aCount++] = LAYER_OP_CURRENTS;
aLayers[aCount++] = LAYER_DEVICE;
aLayers[aCount++] = LAYER_REFERENCEPART;
aLayers[aCount++] = LAYER_VALUEPART;
aLayers[aCount++] = LAYER_FIELDS;
if( Type() == LIB_SYMBOL_T )
aLayers[aCount++] = LAYER_PRIVATE_NOTES;
aLayers[aCount++] = LAYER_DEVICE_BACKGROUND;
aLayers[aCount++] = LAYER_NOTES_BACKGROUND;
aLayers[aCount++] = LAYER_SELECTION_SHADOWS;
}

147
eeschema/symbol.h Normal file
View File

@ -0,0 +1,147 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2024 KiCad Developers, see change_log.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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef SYMBOL_H
#define SYMBOL_H
#include <lib_id.h>
#include <sch_item.h>
/**
* A base class for LIB_SYMBOL and SCH_SYMBOL.
*/
class SYMBOL : public SCH_ITEM
{
public:
void init()
{
m_pinNameOffset = 0;
m_showPinNames = true;
m_showPinNumbers = true;
m_excludedFromSim = false;
m_excludedFromBOM = false;
m_excludedFromBoard = false;
};
SYMBOL( KICAD_T idType ) :
SCH_ITEM( nullptr, idType )
{
init();
};
SYMBOL( EDA_ITEM* aParent, KICAD_T idType ) :
SCH_ITEM( aParent, idType )
{
init();
};
SYMBOL( const SYMBOL& base ) :
SCH_ITEM( base ),
m_pinNameOffset( base.m_pinNameOffset ),
m_showPinNames( base.m_showPinNames ),
m_showPinNumbers( base.m_showPinNumbers ),
m_excludedFromSim( base.m_excludedFromSim ),
m_excludedFromBOM( base.m_excludedFromBOM ),
m_excludedFromBoard( base.m_excludedFromBoard )
{ };
virtual ~SYMBOL() { };
virtual const LIB_ID& GetLibId() const = 0;
virtual wxString GetDescription() const = 0;
virtual wxString GetKeyWords() const = 0;
virtual bool IsPower() const = 0;
virtual bool IsNormal() const = 0;
/**
* Test if symbol has more than one body conversion type (DeMorgan).
*
* @return True if symbol has more than one conversion.
*/
virtual bool HasAlternateBodyStyle() const = 0;
/**
* @return true if the symbol has multiple units per symbol.
*/
virtual bool IsMulti() const = 0;
/**
* @return the number of units defined for the symbol.
*/
virtual int GetUnitCount() const = 0;
/**
* Set the offset in mils of the pin name text from the pin symbol.
*
* Set the offset to 0 to draw the pin name above the pin symbol.
*
* @param aOffset - The offset in mils.
*/
void SetPinNameOffset( int aOffset ) { m_pinNameOffset = aOffset; }
int GetPinNameOffset() const { return m_pinNameOffset; }
/**
* Set or clear the pin name visibility flag.
*/
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
bool GetShowPinNames() const { return m_showPinNames; }
/**
* Set or clear the pin number visibility flag.
*/
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
bool GetShowPinNumbers() const { return m_showPinNumbers; }
/**
* Set or clear the exclude from simulation flag.
*/
void SetExcludedFromSim( bool aExcludeFromSim ) override { m_excludedFromSim = aExcludeFromSim; }
bool GetExcludedFromSim() const override { return m_excludedFromSim; }
/**
* Set or clear the exclude from schematic bill of materials flag.
*/
void SetExcludedFromBOM( bool aExcludeFromBOM ) { m_excludedFromBOM = aExcludeFromBOM; }
bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
/**
* Set or clear exclude from board netlist flag.
*/
void SetExcludedFromBoard( bool aExcludeFromBoard ) { m_excludedFromBoard = aExcludeFromBoard; }
bool GetExcludedFromBoard() const { return m_excludedFromBoard; }
void ViewGetLayers( int aLayers[], int& aCount ) const override;
protected:
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to
///< 0 to draw the pin name above the pin.
bool m_showPinNames;
bool m_showPinNumbers;
bool m_excludedFromSim;
bool m_excludedFromBOM;
bool m_excludedFromBoard;
};
#endif // SYMBOL_H

View File

@ -29,7 +29,7 @@
void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName, VECTOR2I aOffset )
{
KIGFX::SCH_RENDER_SETTINGS renderSettings;
SCH_RENDER_SETTINGS renderSettings;
renderSettings.LoadColors( GetColorSettings() );
renderSettings.SetDefaultPenWidth( GetRenderSettings()->GetDefaultPenWidth() );
@ -63,7 +63,7 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName, VECTOR2I a
{
constexpr bool background = true;
TRANSFORM temp; // Uses default transform
VECTOR2I plotPos;
VECTOR2I plotPos;
plotPos.x = aOffset.x;
plotPos.y = aOffset.y;
@ -91,6 +91,7 @@ void SYMBOL_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
if( !m_symbol )
return;
const SCH_RENDER_SETTINGS* cfg = static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
VECTOR2I pagesize = GetScreen()->GetPageSettings().GetSizeIU( schIUScale.IU_PER_MILS );
/* Plot item centered to the page
@ -101,8 +102,6 @@ void SYMBOL_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
plot_offset.x = pagesize.x / 2;
plot_offset.y = pagesize.y / 2;
m_symbol->PrintBackground( aSettings, plot_offset, m_unit, m_bodyStyle, LIB_SYMBOL_OPTIONS(),
false );
m_symbol->Print( aSettings, plot_offset, m_unit, m_bodyStyle, LIB_SYMBOL_OPTIONS(), false );
m_symbol->PrintBackground( cfg, plot_offset, m_unit, m_bodyStyle, false, false );
m_symbol->Print( cfg, plot_offset, m_unit, m_bodyStyle, false, false );
}

View File

@ -882,7 +882,7 @@ void SYMBOL_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg)
cfg->m_LibViewPanel.lib_list_width = m_libListWidth;
cfg->m_LibViewPanel.cmp_list_width = m_symbolListWidth;
if( KIGFX::SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings() )
if( SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings() )
{
cfg->m_LibViewPanel.show_pin_electrical_type = renderSettings->m_ShowPinsElectricalType;
cfg->m_LibViewPanel.show_pin_numbers = renderSettings->m_ShowPinNumbers;

View File

@ -570,7 +570,7 @@ int SYMBOL_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent )
{
KIGFX::SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings();
SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings();
renderSettings->m_ShowPinsElectricalType = !renderSettings->m_ShowPinsElectricalType;
// Update canvas
@ -583,7 +583,7 @@ int SYMBOL_EDITOR_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent )
int SYMBOL_EDITOR_CONTROL::ShowPinNumbers( const TOOL_EVENT& aEvent )
{
KIGFX::SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings();
SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings();
renderSettings->m_ShowPinNumbers = !renderSettings->m_ShowPinNumbers;
// Update canvas

View File

@ -633,7 +633,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
VECTOR2I offset( -cursorPos.x, cursorPos.y );
symbol->SetOffset( offset );
symbol->Move( offset );
// Refresh the view without changing the viewport
auto center = m_view->GetCenter();

View File

@ -550,9 +550,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField )
if( aField == nullptr )
return;
wxString caption;
LIB_SYMBOL* parent = aField->GetParent();
wxCHECK( parent, /* void */ );
wxString caption;
if( aField->GetId() >= 0 && aField->GetId() < MANDATORY_FIELDS )
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );

View File

@ -121,22 +121,23 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
LIB_PIN original_pin( *aPin );
DIALOG_PIN_PROPERTIES dlg( m_frame, aPin );
SCH_COMMIT commit( m_frame );
LIB_SYMBOL* parentSymbol = dynamic_cast<LIB_SYMBOL*>( aPin->GetParentSymbol() );
if( aPin->GetEditFlags() == 0 )
commit.Modify( aPin->GetParent() );
commit.Modify( parentSymbol );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
if( !aPin->IsNew() && m_frame->SynchronizePins() && aPin->GetParent() )
if( !aPin->IsNew() && m_frame->SynchronizePins() && parentSymbol )
{
LIB_PINS pinList;
aPin->GetParent()->GetPins( pinList );
parentSymbol->GetPins( pinList );
// a pin can have a unit id = 0 (common to all units) to unit count
// So we need a buffer size = GetUnitCount()+1 to store a value in a vector
// when using the unit id of a pin as index
std::vector<bool> got_unit( aPin->GetParent()->GetUnitCount() + 1 );
std::vector<bool> got_unit( parentSymbol->GetUnitCount() + 1 );
got_unit[static_cast<size_t>(aPin->GetUnit())] = true;
@ -160,7 +161,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
if( aPin->GetBodyStyle() == 0 )
{
if( !aPin->GetUnit() || other->GetUnit() == aPin->GetUnit() )
aPin->GetParent()->RemoveDrawItem( other );
parentSymbol->RemoveDrawItem( other );
}
else if( other->GetBodyStyle() == aPin->GetBodyStyle() )
{
@ -172,7 +173,7 @@ bool SYMBOL_EDITOR_PIN_TOOL::EditPinProperties( LIB_PIN* aPin )
if( aPin->GetUnit() == 0 )
{
if( !aPin->GetBodyStyle() || other->GetBodyStyle() == aPin->GetBodyStyle() )
aPin->GetParent()->RemoveDrawItem( other );
parentSymbol->RemoveDrawItem( other );
}
other->SetOrientation( aPin->GetOrientation() );
@ -334,7 +335,7 @@ void SYMBOL_EDITOR_PIN_TOOL::CreateImagePins( LIB_PIN* aPin )
// to facilitate pin editing, create pins for all other units for the current body style
// at the same position as aPin
for( ii = 1; ii <= aPin->GetParent()->GetUnitCount(); ii++ )
for( ii = 1; ii <= aPin->GetParentSymbol()->GetUnitCount(); ii++ )
{
if( ii == aPin->GetUnit() )
continue;
@ -352,7 +353,7 @@ void SYMBOL_EDITOR_PIN_TOOL::CreateImagePins( LIB_PIN* aPin )
try
{
aPin->GetParent()->AddDrawItem( newPin );
dynamic_cast<LIB_SYMBOL*>( aPin->GetParentSymbol() )->AddDrawItem( newPin );
}
catch( const boost::bad_pointer& e )
{

View File

@ -88,8 +88,7 @@ void SYMBOL_DIFF_WIDGET::DisplayDiff( LIB_SYMBOL* aSchSymbol, LIB_SYMBOL* aLibSy
m_previewItem = aSchSymbol;
// For symbols having a De Morgan body style, use the first style
auto settings =
static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
auto settings = static_cast<SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
settings->m_ShowUnit = ( m_previewItem->IsMulti() && !aUnit ) ? 1 : aUnit;
settings->m_ShowBodyStyle = ( m_previewItem->HasAlternateBodyStyle() && !aConvert ) ? 1 : aConvert;

View File

@ -74,7 +74,7 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY* aKiway,
// Early initialization of the canvas background color,
// before any OnPaint event is fired for the canvas using a wrong bg color
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() );
if( auto* theme = Pgm().GetSettingsManager().GetColorSettings( app_settings->m_ColorTheme ) )
settings->LoadColors( theme );
@ -187,7 +187,7 @@ void SYMBOL_PREVIEW_WIDGET::fitOnDrawArea()
void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit, int aBodyStyle )
{
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() );
std::unique_ptr< LIB_SYMBOL > symbol;
try
@ -277,8 +277,7 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_SYMBOL* aSymbol, int aUnit, int aBo
m_previewItem = new LIB_SYMBOL( *aSymbol );
// For symbols having a De Morgan body style, use the first style
auto settings =
static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
auto settings = static_cast<SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
// If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll
// draw all of them.)

View File

@ -76,7 +76,7 @@ public:
/**
* For items with units, return the number of units.
*/
virtual int GetUnitCount() const { return 0; }
virtual int GetSubUnitCount() const { return 0; }
/**
* For items with units, return an identifier for unit x.

View File

@ -294,10 +294,8 @@ public:
*
* @param aWidth is the new width.
*/
void SetOutlineWidth( float aWidth )
{
m_outlineWidth = aWidth;
}
void SetOutlineWidth( float aWidth ) { m_outlineWidth = aWidth; }
float GetOutlineWidth() const { return m_outlineWidth; }
void SetHighlightFactor( float aFactor ) { m_highlightFactor = aFactor; }
void SetSelectFactor( float aFactor ) { m_selectFactor = aFactor; }