7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 18:23:45 +00:00

Rename SCH_COMPONENT to SCH_SYMBOL.

This commit is contained in:
Wayne Stambaugh 2021-06-10 10:10:55 -04:00
parent 1c3df973d6
commit fbc135e69f
118 changed files with 1380 additions and 1348 deletions
common
eeschema
annotate.cppautoplace_fields.cppcomponent_references_lister.cppconnection_graph.cppconnection_graph.hcross-probing.cpp
dialogs
ee_collectors.cppee_collectors.heeschema_id.herc.cppfields_grid_table.cppgetpart.cppinvoke_sch_dialog.hlib_pin.hlibarch.cpp
netlist_exporters
project_rescue.cppproject_rescue.hsch_base_frame.cppsch_edit_frame.cppsch_edit_frame.hsch_field.cppsch_field.hsch_junction.hsch_line.cppsch_no_connect.hsch_painter.cppsch_painter.hsch_pin.cppsch_pin.h
sch_plugins
sch_reference_list.hsch_rtree.hsch_screen.cppsch_screen.hsch_sheet.cppsch_sheet.hsch_sheet_path.cppsch_sheet_path.hsch_symbol.cppsch_symbol.hschematic.cppschematic_undo_redo.cpp
sim
symbol_editor
symbol_tree_model_adapter.cppsymbol_tree_model_adapter.hsymbol_viewer_frame.cpp
tools
widgets
include
pcbnew
qa/eeschema

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -280,7 +280,7 @@ static struct EDA_ITEM_DESC
.Map( SCH_GLOBAL_LABEL_T, _HKI( "Global Label" ) )
.Map( SCH_HIER_LABEL_T, _HKI( "Hierarchical Label" ) )
.Map( SCH_FIELD_T, _HKI( "Schematic Field" ) )
.Map( SCH_COMPONENT_T, _HKI( "Component" ) )
.Map( SCH_SYMBOL_T, _HKI( "Schematic Symbol" ) )
.Map( SCH_SHEET_PIN_T, _HKI( "Sheet Pin" ) )
.Map( SCH_SHEET_T, _HKI( "Sheet" ) )

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2014-2021 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
@ -36,27 +36,18 @@
static const int kDataViewIndent = 20;
/**
* Convert CMP_TREE_NODE -> wxDataViewItem
*/
wxDataViewItem LIB_TREE_MODEL_ADAPTER::ToItem( LIB_TREE_NODE const* aNode )
{
return wxDataViewItem( const_cast<void*>( static_cast<void const*>( aNode ) ) );
}
/**
* Convert wxDataViewItem -> CMP_TREE_NODE
*/
LIB_TREE_NODE* LIB_TREE_MODEL_ADAPTER::ToNode( wxDataViewItem aItem )
{
return static_cast<LIB_TREE_NODE*>( aItem.GetID() );
}
/**
* Convert CMP_TREE_NODE's children to wxDataViewItemArray
*/
unsigned int LIB_TREE_MODEL_ADAPTER::IntoArray( LIB_TREE_NODE const& aNode,
wxDataViewItemArray& aChildren )
{
@ -77,7 +68,7 @@ unsigned int LIB_TREE_MODEL_ADAPTER::IntoArray( LIB_TREE_NODE const& aNode,
LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, wxString aPinnedKey ) :
m_parent( aParent ),
m_filter( CMP_FILTER_NONE ),
m_filter( SYM_FILTER_NONE ),
m_show_units( true ),
m_preselect_unit( 0 ),
m_freeze( 0 ),
@ -144,7 +135,7 @@ void LIB_TREE_MODEL_ADAPTER::SavePinnedItems()
}
void LIB_TREE_MODEL_ADAPTER::SetFilter( CMP_FILTER_TYPE aFilter )
void LIB_TREE_MODEL_ADAPTER::SetFilter( SYM_FILTER_TYPE aFilter )
{
m_filter = aFilter;
}
@ -548,10 +539,12 @@ LIB_TREE_NODE* LIB_TREE_MODEL_ADAPTER::ShowPreselect()
FindAndExpand( m_tree,
[&]( LIB_TREE_NODE const* n )
{
if( n->m_Type == LIB_TREE_NODE::LIBID && ( n->m_Children.empty() || !m_preselect_unit ) )
if( n->m_Type == LIB_TREE_NODE::LIBID && ( n->m_Children.empty() ||
!m_preselect_unit ) )
return m_preselect_lib_id == n->m_LibId;
else if( n->m_Type == LIB_TREE_NODE::UNIT && m_preselect_unit )
return m_preselect_lib_id == n->m_Parent->m_LibId && m_preselect_unit == n->m_Unit;
return m_preselect_lib_id == n->m_Parent->m_LibId &&
m_preselect_unit == n->m_Unit;
else
return false;
},

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 CERN
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jon Evans <jon@craftyjon.com>
*
* This program is free software: you can redistribute it and/or modify it
@ -36,12 +37,12 @@ const int projectFileSchemaVersion = 1;
PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
JSON_SETTINGS( aFullPath, SETTINGS_LOC::PROJECT, projectFileSchemaVersion ),
m_sheets(),
m_boards(),
m_project( nullptr ),
m_ErcSettings( nullptr ),
m_SchematicSettings( nullptr ),
m_BoardSettings()
m_BoardSettings(),
m_sheets(),
m_boards(),
m_project( nullptr )
{
// Keep old files around
m_deleteLegacyAfterMigration = false;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2014-2021 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
@ -106,7 +106,7 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
m_tree_ctrl->Bind( wxEVT_DATAVIEW_SELECTION_CHANGED, &LIB_TREE::onTreeSelect, this );
m_tree_ctrl->Bind( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &LIB_TREE::onContextMenu, this );
Bind( COMPONENT_PRESELECTED, &LIB_TREE::onPreselect, this );
Bind( SYMBOL_PRESELECTED, &LIB_TREE::onPreselect, this );
// If wxTextCtrl::SetHint() is called before binding wxEVT_TEXT, the event
// handler will intermittently fire.
@ -271,14 +271,14 @@ void LIB_TREE::expandIfValid( const wxDataViewItem& aTreeId )
void LIB_TREE::postPreselectEvent()
{
wxCommandEvent event( COMPONENT_PRESELECTED );
wxCommandEvent event( SYMBOL_PRESELECTED );
wxPostEvent( this, event );
}
void LIB_TREE::postSelectEvent()
{
wxCommandEvent event( COMPONENT_SELECTED );
wxCommandEvent event( SYMBOL_SELECTED );
wxPostEvent( this, event );
}
@ -367,7 +367,7 @@ void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke )
toggleExpand( sel );
break;
}
// Intentionally fall through, so the selected component will be treated as the selected one
// Intentionally fall through, so the selected symbol will be treated as the selected one
KI_FALLTHROUGH;
default:
@ -448,5 +448,5 @@ void LIB_TREE::onContextMenu( wxDataViewEvent& aEvent )
}
wxDEFINE_EVENT( COMPONENT_PRESELECTED, wxCommandEvent );
wxDEFINE_EVENT( COMPONENT_SELECTED, wxCommandEvent );
wxDEFINE_EVENT( SYMBOL_PRESELECTED, wxCommandEvent );
wxDEFINE_EVENT( SYMBOL_SELECTED, wxCommandEvent );

View File

@ -43,7 +43,7 @@ void SCH_EDIT_FRAME::mapExistingAnnotation( std::map<wxString, wxString>& aMap )
for( size_t i = 0; i < references.GetCount(); i++ )
{
SCH_COMPONENT* symbol = references[ i ].GetSymbol();
SCH_SYMBOL* symbol = references[ i ].GetSymbol();
SCH_SHEET_PATH* curr_sheetpath = &references[ i ].GetSheetPath();
KIID_PATH curr_full_uuid = curr_sheetpath->Path();
@ -65,7 +65,7 @@ void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool* aA
auto clearSymbolAnnotation =
[&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet )
{
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( aItem );
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
SaveCopyInUndoList( aScreen, symbol, UNDO_REDO::CHANGED, *aAppendUndo );
*aAppendUndo = true;
@ -75,7 +75,7 @@ void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool* aA
auto clearSheetAnnotation =
[&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet )
{
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_COMPONENT_T ) )
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
clearSymbolAnnotation( item, aScreen, aSheet );
};
@ -104,7 +104,7 @@ void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool* aA
for( EDA_ITEM* item : selection.Items() )
{
if( item->Type() == SCH_COMPONENT_T )
if( item->Type() == SCH_SYMBOL_T )
clearSymbolAnnotation( item, screen, &currentSheet );
}
break;
@ -256,7 +256,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope,
for( size_t i = 0; i < references.GetCount(); i++ )
{
SCH_REFERENCE& ref = references[i];
SCH_COMPONENT* symbol = ref.GetSymbol();
SCH_SYMBOL* symbol = ref.GetSymbol();
SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
SaveCopyInUndoList( sheet->LastScreen(), symbol, UNDO_REDO::CHANGED, appendUndo );

View File

@ -111,7 +111,7 @@ public:
COLLISION collision;
};
AUTOPLACER( SCH_COMPONENT* aSymbol, SCH_SCREEN* aScreen ) :
AUTOPLACER( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScreen ) :
m_screen( aScreen ),
m_symbol( aSymbol )
{
@ -265,7 +265,7 @@ protected:
for( SCH_ITEM* item : m_screen->Items().Overlapping( m_symbol->GetBoundingBox() ) )
{
if( SCH_COMPONENT* candidate = dynamic_cast<SCH_COMPONENT*>( item ) )
if( SCH_SYMBOL* candidate = dynamic_cast<SCH_SYMBOL*>( item ) )
{
if( candidate == m_symbol )
continue;
@ -293,7 +293,7 @@ protected:
{
EDA_RECT item_box;
if( SCH_COMPONENT* item_comp = dynamic_cast<SCH_COMPONENT*>( item ) )
if( SCH_SYMBOL* item_comp = dynamic_cast<SCH_SYMBOL*>( item ) )
item_box = item_comp->GetBodyBoundingBox();
else
item_box = item->GetBoundingBox();
@ -320,8 +320,8 @@ protected:
int orient = m_symbol->GetOrientation();
int orient_angle = orient & 0xff; // enum is a bitmask
bool h_mirrored = ( ( orient & CMP_MIRROR_X )
&& ( orient_angle == CMP_ORIENT_0 || orient_angle == CMP_ORIENT_180 ) );
bool h_mirrored = ( ( orient & SYM_MIRROR_X )
&& ( orient_angle == SYM_ORIENT_0 || orient_angle == SYM_ORIENT_180 ) );
double w = double( m_symbol_bbox.GetWidth() );
double h = double( m_symbol_bbox.GetHeight() );
@ -333,21 +333,21 @@ protected:
// For power symbols, we generally want the label at the top first.
switch( orient_angle )
{
case CMP_ORIENT_0:
case SYM_ORIENT_0:
std::swap( sides[0], sides[1] );
std::swap( sides[1], sides[3] );
// TOP, BOTTOM, RIGHT, LEFT
break;
case CMP_ORIENT_90:
case SYM_ORIENT_90:
std::swap( sides[0], sides[2] );
std::swap( sides[1], sides[2] );
// LEFT, RIGHT, TOP, BOTTOM
break;
case CMP_ORIENT_180:
case SYM_ORIENT_180:
std::swap( sides[0], sides[3] );
// BOTTOM, TOP, LEFT, RIGHT
break;
case CMP_ORIENT_270:
case SYM_ORIENT_270:
std::swap( sides[1], sides[2] );
// RIGHT, LEFT, TOP, BOTTOM
break;
@ -657,7 +657,7 @@ protected:
private:
SCH_SCREEN* m_screen;
SCH_COMPONENT* m_symbol;
SCH_SYMBOL* m_symbol;
std::vector<SCH_FIELD*> m_fields;
std::vector<SCH_ITEM*> m_colliders;
EDA_RECT m_symbol_bbox;
@ -674,7 +674,7 @@ const AUTOPLACER::SIDE AUTOPLACER::SIDE_LEFT( -1, 0 );
const AUTOPLACER::SIDE AUTOPLACER::SIDE_RIGHT( 1, 0 );
void SCH_COMPONENT::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
void SCH_SYMBOL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
{
if( aManual )
wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );

View File

@ -25,7 +25,7 @@
/**
* @file component_references_lister.cpp
* @brief functions to create a component flat list and to annotate schematic.
* @brief functions to create a symbol flat list and to annotate schematic.
*/
#include <sch_reference_list.h>
@ -211,7 +211,7 @@ void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList,
sort( aIdList.begin(), aIdList.end() );
// Ensure each reference number appears only once. If there are components with
// Ensure each reference number appears only once. If there are symbols with
// multiple parts per package the same number will be stored for each part.
std::vector< int >::iterator it = unique( aIdList.begin(), aIdList.end() );
@ -342,8 +342,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
size_t originalSize = GetCount();
// For multi units components, store the list of already used full references.
// The algorithm tries to allocate the new reference to components having the same
// For multi units symbols, store the list of already used full references.
// The algorithm tries to allocate the new reference to symbols having the same
// old reference.
// This algo works fine as long as the previous annotation has no duplicates.
// But when a hierarchy is reannotated with this option, the previous anotation can
@ -371,8 +371,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
int LastReferenceNumber = 0;
int NumberOfUnits, Unit;
/* calculate index of the first component with the same reference prefix
* than the current component. All components having the same reference
/* calculate index of the first symbol with the same reference prefix
* than the current symbol. All symbols having the same reference
* prefix will receive a reference number with consecutive values:
* IC .. will be set to IC4, IC4, IC5 ...
*/
@ -399,7 +399,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
if( ref_unit.m_flag )
continue;
// Check whether this component is in aLockedUnitMap.
// Check whether this symbol is in aLockedUnitMap.
SCH_REFERENCE_LIST* lockedList = NULL;
for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : aLockedUnitMap )
{
@ -440,7 +440,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
GetRefsInUse( first, idList, minRefId );
}
// Annotation of one part per package components (trivial case).
// Annotation of one part per package symbols (trivial case).
if( ref_unit.GetLibPart()->GetUnitCount() <= 1 )
{
if( ref_unit.m_isNew )
@ -465,8 +465,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
ref_unit.m_flag = 1;
}
// If this component is in aLockedUnitMap, copy the annotation to all
// components that are not it
// If this symbol is in aLockedUnitMap, copy the annotation to all
// symbols that are not it
if( lockedList != NULL )
{
unsigned n_refs = lockedList->GetCount();
@ -477,7 +477,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
if( thisRef.IsSameInstance( ref_unit ) )
{
// This is the component we're currently annotating. Hold the unit!
// This is the symbol we're currently annotating. Hold the unit!
ref_unit.m_unit = thisRef.m_unit;
// lock this new full reference
inUseRefs.insert( buildFullReference( ref_unit ) );
@ -489,7 +489,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
if( thisRef.CompareLibName( ref_unit ) != 0 )
continue;
// Find the matching component
// Find the matching symbol
for( unsigned jj = ii + 1; jj < flatList.size(); jj++ )
{
if( ! thisRef.IsSameInstance( flatList[jj] ) )
@ -497,9 +497,9 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
wxString ref_candidate = buildFullReference( ref_unit, thisRef.m_unit );
// propagate the new reference and unit selection to the "old" component,
// propagate the new reference and unit selection to the "old" symbol,
// if this new full reference is not already used (can happens when initial
// multiunits components have duplicate references)
// multiunits symbols have duplicate references)
if( inUseRefs.find( ref_candidate ) == inUseRefs.end() )
{
flatList[jj].m_numRef = ref_unit.m_numRef;
@ -514,7 +514,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
}
else
{
/* search for others units of this component.
/* search for others units of this symbol.
* we search for others parts that have the same value and the same
* reference prefix (ref without ref number)
*/
@ -528,7 +528,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
if( found >= 0 )
continue; // this unit exists for this reference (unit already annotated)
// Search a component to annotate ( same prefix, same value, not annotated)
// Search a symbol to annotate ( same prefix, same value, not annotated)
for( unsigned jj = ii + 1; jj < flatList.size(); jj++ )
{
auto& cmp_unit = flatList[jj];
@ -552,7 +552,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int
if( !cmp_unit.m_isNew )
continue;
// Component without reference number found, annotate it if possible
// Symbol without reference number found, annotate it if possible.
if( cmp_unit.m_unit == Unit )
{
cmp_unit.m_numRef = ref_unit.m_numRef;
@ -617,7 +617,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler )
}
// Error if unit number selected does not exist (greater than the number of units in
// the component). This can happen if a component has changed in a library after a
// the symbol). This can happen if a symbol has changed in a library after a
// previous annotation.
if( std::max( flatList[ii].GetLibPart()->GetUnitCount(), 1 ) < flatList[ii].m_unit )
{
@ -733,13 +733,13 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler )
}
SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aSymbol, LIB_PART* aLibPart,
SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_PART* aLibPart,
const SCH_SHEET_PATH& aSheetPath )
{
wxASSERT( aSymbol != NULL );
m_rootSymbol = aSymbol;
m_libPart = aLibPart; // Warning: can be nullptr for orphan components
m_libPart = aLibPart; // Warning: can be nullptr for orphan symbols
// (i.e. with a symbol library not found)
m_unit = aSymbol->GetUnitSelection( &aSheetPath );
m_footprint = aSymbol->GetFootprint( &aSheetPath, true );

View File

@ -517,9 +517,9 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
m_items.emplace_back( pin );
}
}
else if( item->Type() == SCH_COMPONENT_T )
else if( item->Type() == SCH_SYMBOL_T )
{
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
for( SCH_PIN* pin : symbol->GetPins( &aSheet ) )
{

View File

@ -337,7 +337,7 @@ private:
*
* Any item that is stored in the list of items that have a connection point
* at a given (x, y) location will eventually be electrically connected.
* This means that we can't store SCH_COMPONENTs in this map -- we must store
* This means that we can't store SCH_SYMBOLs in this map -- we must store
* a structure that links a specific pin on a symbol back to that symbol: a
* SCH_PIN_CONNECTION. This wrapper class is a convenience for linking a pin
* and symbol to a specific (x, y) point.

View File

@ -46,7 +46,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
const wxString& aSearchText )
{
SCH_SHEET_PATH* sheetWithComponentFound = nullptr;
SCH_COMPONENT* component = nullptr;
SCH_SYMBOL* symbol = nullptr;
wxPoint pos;
SCH_PIN* pin = nullptr;
SCH_SHEET_LIST sheetList;
@ -61,27 +61,27 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
{
SCH_SCREEN* screen = sheet.LastScreen();
for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
{
SCH_COMPONENT* candidate = static_cast<SCH_COMPONENT*>( item );
SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
if( aReference.CmpNoCase( candidate->GetRef( &sheet ) ) == 0 )
{
component = candidate;
symbol = candidate;
sheetWithComponentFound = &sheet;
if( aSearchType == HIGHLIGHT_PIN )
{
// temporary: will be changed if the pin is found.
pos = component->GetPosition();
pin = component->GetPin( aSearchText );
pos = symbol->GetPosition();
pin = symbol->GetPin( aSearchText );
// Ensure we have found the right unit in case of multi-units symbol
if( pin )
{
int unit = pin->GetLibPin()->GetUnit();
if( unit != 0 && unit != component->GetUnit() )
if( unit != 0 && unit != symbol->GetUnit() )
{
pin = nullptr;
continue;
@ -95,8 +95,8 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
}
else
{
pos = component->GetPosition();
foundItem = component;
pos = symbol->GetPosition();
foundItem = symbol;
break;
}
}
@ -109,7 +109,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
if( component )
if( symbol )
{
if( *sheetWithComponentFound != m_frame->GetCurrentSheet() )
{
@ -127,7 +127,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
//#define COMP_1_TO_1_RATIO // Un-comment for normal KiCad full screen zoom cross-probe
#ifdef COMP_1_TO_1_RATIO
// Pass "false" to only include visible fields of component in bbox calculations
EDA_RECT bbox = component->GetBoundingBox( false );
EDA_RECT bbox = symbol->GetBoundingBox( false );
wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
VECTOR2D screenSize = getView()->GetViewport().GetSize();
@ -145,7 +145,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
#ifndef COMP_1_TO_1_RATIO // Do the scaled zoom
// Pass "false" to only include visible fields of component in bbox calculations
EDA_RECT bbox = component->GetBoundingBox( false );
EDA_RECT bbox = symbol->GetBoundingBox( false );
wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
VECTOR2D screenSize = getView()->GetViewport().GetSize();
@ -257,7 +257,7 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
/* Print diag */
wxString msg;
if( component )
if( symbol )
{
if( aSearchType == HIGHLIGHT_PIN )
{
@ -350,7 +350,7 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( idcmd == nullptr ) // Highlight component only (from CvPcb or Pcbnew)
{
// Highlight component part_ref, or clear Highlight, if part_ref is not existing
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
return;
}
@ -365,13 +365,13 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
{
// Highlighting the reference itself isn't actually that useful, and it's harder to
// see. Highlight the parent and display the message.
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, msg );
}
else if( strcmp( idcmd, "$VAL:" ) == 0 )
{
// Highlighting the value itself isn't actually that useful, and it's harder to see.
// Highlight the parent and display the message.
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, msg );
}
else if( strcmp( idcmd, "$PAD:" ) == 0 )
{
@ -379,12 +379,12 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
}
else
{
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
}
}
std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aSymbol )
std::string FormatProbeItem( EDA_ITEM* aItem, SCH_SYMBOL* aSymbol )
{
// This is a keyword followed by a quoted string.
@ -399,8 +399,8 @@ std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aSymbol )
}
break;
case SCH_COMPONENT_T:
aSymbol = (SCH_COMPONENT*) aItem;
case SCH_SYMBOL_T:
aSymbol = (SCH_SYMBOL*) aItem;
return StrPrintf( "$PART: \"%s\"",
TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
@ -452,7 +452,7 @@ std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aSymbol )
}
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aLibItem )
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_SYMBOL* aLibItem )
{
wxASSERT( aObjectToSync ); // fix the caller

View File

@ -49,7 +49,7 @@ bool g_resetFieldPositions[2] = { true, false };
bool g_resetAttributes[2] = { true, false };
DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aSymbol,
DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_SYMBOL* aSymbol,
MODE aMode ) :
DIALOG_CHANGE_SYMBOLS_BASE( aParent ),
m_symbol( aSymbol),
@ -272,9 +272,9 @@ void DIALOG_CHANGE_SYMBOLS::updateFieldsList()
wxCHECK2( screen, continue );
for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) )
for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
{
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
wxCHECK2( symbol, continue );
@ -379,7 +379,7 @@ void DIALOG_CHANGE_SYMBOLS::onOkButtonClicked( wxCommandEvent& aEvent )
}
bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aInstance )
bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInstance )
{
LIB_ID id;
@ -442,12 +442,12 @@ bool DIALOG_CHANGE_SYMBOLS::processMatchingSymbols()
wxCHECK2( screen, continue );
std::vector<SCH_COMPONENT*> symbols;
std::vector<SCH_SYMBOL*> symbols;
for( SCH_ITEM* item : screen->Items().OfType( SCH_COMPONENT_T ) )
symbols.push_back( static_cast<SCH_COMPONENT*>( item ) );
for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
symbols.push_back( static_cast<SCH_SYMBOL*>( item ) );
for( SCH_COMPONENT* symbol : symbols )
for( SCH_SYMBOL* symbol : symbols )
{
if( !isMatch( symbol, &instance ) )
continue;
@ -474,7 +474,7 @@ bool DIALOG_CHANGE_SYMBOLS::processMatchingSymbols()
}
bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_COMPONENT* aSymbol, const SCH_SHEET_PATH* aInstance,
bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH* aInstance,
const LIB_ID& aNewId, bool aAppendToUndo )
{
wxCHECK( aSymbol, false );

View File

@ -26,7 +26,7 @@
#include <dialog_change_symbols_base.h>
class LIB_ID;
class SCH_COMPONENT;
class SCH_SYMBOL;
class SCH_EDIT_FRAME;
class SCH_SCREEN;
class SCH_SHEET_PATH;
@ -39,7 +39,7 @@ class DIALOG_CHANGE_SYMBOLS : public DIALOG_CHANGE_SYMBOLS_BASE
public:
enum class MODE { CHANGE = 0, UPDATE };
DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aSymbol,
DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_SYMBOL* aSymbol,
MODE aMode = MODE::UPDATE );
~DIALOG_CHANGE_SYMBOLS() override;
@ -70,13 +70,13 @@ protected:
private:
void updateFieldsList();
bool isMatch( SCH_COMPONENT* aSymbol, SCH_SHEET_PATH* aInstance );
bool isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInstance );
bool processMatchingSymbols();
bool processSymbol( SCH_COMPONENT* aSymbol, const SCH_SHEET_PATH* aInstance,
bool processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH* aInstance,
const LIB_ID& aNewId, bool aAppendToUndo );
SCH_COMPONENT* m_symbol;
MODE m_mode;
SCH_SYMBOL* m_symbol;
MODE m_mode;
///< Set of field names that should have values updated
std::set<wxString> m_updateFields;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2021 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
@ -71,7 +71,7 @@ DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL( SCH_BASE_FRAME* aParent, const wxStr
m_external_browser_requested( false )
{
// Never show footprints in power symbol mode
if( aAdapter->GetFilter() == SYMBOL_TREE_MODEL_ADAPTER::CMP_FILTER_POWER )
if( aAdapter->GetFilter() == SYMBOL_TREE_MODEL_ADAPTER::SYM_FILTER_POWER )
m_show_footprints = false;
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
@ -201,8 +201,8 @@ DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL( SCH_BASE_FRAME* aParent, const wxStr
Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_SYMBOL::OnInitDialog, this );
Bind( wxEVT_TIMER, &DIALOG_CHOOSE_SYMBOL::OnCloseTimer, this, m_dbl_click_timer->GetId() );
Bind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentPreselected, this );
Bind( COMPONENT_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentSelected, this );
Bind( SYMBOL_PRESELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentPreselected, this );
Bind( SYMBOL_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentSelected, this );
if( m_browser_button )
{
@ -228,8 +228,8 @@ DIALOG_CHOOSE_SYMBOL::~DIALOG_CHOOSE_SYMBOL()
{
Unbind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_SYMBOL::OnInitDialog, this );
Unbind( wxEVT_TIMER, &DIALOG_CHOOSE_SYMBOL::OnCloseTimer, this );
Unbind( COMPONENT_PRESELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentPreselected, this );
Unbind( COMPONENT_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentSelected, this );
Unbind( SYMBOL_PRESELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentPreselected, this );
Unbind( SYMBOL_SELECTED, &DIALOG_CHOOSE_SYMBOL::OnComponentSelected, this );
if( m_browser_button )
{
@ -368,7 +368,7 @@ void DIALOG_CHOOSE_SYMBOL::OnUseBrowser( wxCommandEvent& aEvent )
void DIALOG_CHOOSE_SYMBOL::OnCloseTimer( wxTimerEvent& aEvent )
{
// Hack handler because of eaten MouseUp event. See
// DIALOG_CHOOSE_COMPONENT::OnComponentSelected for the beginning
// DIALOG_CHOOSE_SYMBOL::OnComponentSelected for the beginning
// of this spaghetti noodle.
auto state = wxGetMouseState();
@ -549,7 +549,7 @@ void DIALOG_CHOOSE_SYMBOL::OnComponentSelected( wxCommandEvent& aEvent )
// possible (docs are vague). To get around this, we use a one-shot
// timer to schedule the dialog close.
//
// See DIALOG_CHOOSE_COMPONENT::OnCloseTimer for the other end of this
// See DIALOG_CHOOSE_SYMBOL::OnCloseTimer for the other end of this
// spaghetti noodle.
m_dbl_click_timer->StartOnce( DIALOG_CHOOSE_SYMBOL::DblClickDelay );
}
@ -565,4 +565,4 @@ bool DIALOG_CHOOSE_SYMBOL::GetUseAllUnits() const
bool DIALOG_CHOOSE_SYMBOL::GetKeepSymbol() const
{
return m_keepSymbol->GetValue();
}
}

View File

@ -21,8 +21,8 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DIALOG_CHOOSE_COMPONENT_H
#define DIALOG_CHOOSE_COMPONENT_H
#ifndef DIALOG_CHOOSE_SYMBOL_H
#define DIALOG_CHOOSE_SYMBOL_H
#include "dialog_shim.h"
#include <symbol_tree_model_adapter.h>
@ -55,8 +55,8 @@ class SCH_DRAW_PANEL;
* Dialog class to select a symbol from the libraries. This is the master View class in a
* Model-View-Adapter (mediated MVC) architecture. The other pieces are in:
*
* - Adapter: CMP_TREE_MODEL_ADAPTER in common/cmp_tree_model_adapter.h
* - Model: CMP_TREE_NODE and descendants in common/cmp_tree_model.h
* - Adapter: SYM_TREE_MODEL_ADAPTER in common/cmp_tree_model_adapter.h
* - Model: SYM_TREE_NODE and descendants in common/cmp_tree_model.h
*
* Because everything is tied together in the adapter class, see that file
* for thorough documentation. A simple example usage follows:
@ -94,7 +94,7 @@ public:
*
* @param aParent a SCH_BASE_FRAME parent window.
* @param aTitle Dialog title.
* @param aAdapter SYMBOL_TREE_MODEL_ADAPTER::PTR. See CMP_TREE_MODEL_ADAPTER
* @param aAdapter SYMBOL_TREE_MODEL_ADAPTER::PTR. See SYM_TREE_MODEL_ADAPTER
* for documentation.
* @param aDeMorganConvert preferred deMorgan conversion.
* (TODO: should happen in dialog)
@ -227,4 +227,4 @@ protected:
std::vector<std::pair<int, wxString>> m_field_edits;
};
#endif /* DIALOG_CHOOSE_COMPONENT_H */
#endif /* DIALOG_CHOOSE_SYMBOL_H */

View File

@ -242,33 +242,33 @@ int GRIDCELL_AUTOWRAP_STRINGRENDERER::GetHeight( wxDC& aDC, wxGrid* aGrid, int a
/**
* A helper to handle symbols to edit.
*/
class CMP_CANDIDATE
class SYM_CANDIDATE
{
public:
CMP_CANDIDATE( SCH_COMPONENT* aComponent )
SYM_CANDIDATE( SCH_SYMBOL* aSymbol )
{
m_Component = aComponent;
m_InitialLibId = m_Component->GetLibId().Format();
m_Symbol = aSymbol;
m_InitialLibId = m_Symbol->GetLibId().Format();
m_Row = -1;
m_IsOrphan = false;
m_Screen = nullptr;
}
// Return a string like mylib:symbol_name from the #LIB_ID of the component.
// Return a string like mylib:symbol_name from the #LIB_ID of the symbol.
wxString GetStringLibId()
{
return m_Component->GetLibId().GetUniStringLibId();
return m_Symbol->GetLibId().GetUniStringLibId();
}
// Return a string containing the reference of the component.
// Return a string containing the reference of the symbol.
wxString GetSchematicReference()
{
return m_Reference;
}
SCH_COMPONENT* m_Component; // the schematic component
SCH_SYMBOL* m_Symbol; // the schematic symbol
int m_Row; // the row index in m_grid
SCH_SCREEN* m_Screen; // the screen where m_Component lives
SCH_SCREEN* m_Screen; // the screen where m_Symbol lives
wxString m_Reference; // the schematic reference, only to display it in list
wxString m_InitialLibId; // the Lib Id of the component before any change
bool m_IsOrphan; // true if a component has no corresponding symbol found in libs
@ -344,7 +344,7 @@ private:
bool m_isModified; // set to true if the schematic is modified
std::vector<int> m_OrphansRowIndexes; // list of rows containing orphan lib_id
std::vector<CMP_CANDIDATE> m_components;
std::vector<SYM_CANDIDATE> m_symbols;
GRIDCELL_AUTOWRAP_STRINGRENDERER* m_autoWrapRenderer;
};
@ -373,12 +373,12 @@ DIALOG_EDIT_COMPONENTS_LIBID::~DIALOG_EDIT_COMPONENTS_LIBID()
// A sort compare function to sort components list by LIB_ID and then reference
static bool sort_by_libid( const CMP_CANDIDATE& cmp1, const CMP_CANDIDATE& cmp2 )
static bool sort_by_libid( const SYM_CANDIDATE& cmp1, const SYM_CANDIDATE& cmp2 )
{
if( cmp1.m_Component->GetLibId() == cmp2.m_Component->GetLibId() )
if( cmp1.m_Symbol->GetLibId() == cmp2.m_Symbol->GetLibId() )
return cmp1.m_Reference.Cmp( cmp2.m_Reference ) < 0;
return cmp1.m_Component->GetLibId() < cmp2.m_Component->GetLibId();
return cmp1.m_Symbol->GetLibId() < cmp2.m_Symbol->GetLibId();
}
@ -404,29 +404,29 @@ void DIALOG_EDIT_COMPONENTS_LIBID::initDlg()
for( unsigned ii = 0; ii < references.GetCount(); ii++ )
{
SCH_REFERENCE& item = references[ii];
CMP_CANDIDATE candidate( item.GetSymbol() );
SYM_CANDIDATE candidate( item.GetSymbol() );
candidate.m_Screen = item.GetSheetPath().LastScreen();
SCH_SHEET_PATH sheetpath = item.GetSheetPath();
candidate.m_Reference = candidate.m_Component->GetRef( &sheetpath );
int unitcount = candidate.m_Component->GetUnitCount();
candidate.m_Reference = candidate.m_Symbol->GetRef( &sheetpath );
int unitcount = candidate.m_Symbol->GetUnitCount();
candidate.m_IsOrphan = ( unitcount == 0 );
m_components.push_back( candidate );
m_symbols.push_back( candidate );
}
if( m_components.size() == 0 )
if( m_symbols.size() == 0 )
return;
// now sort by lib id to create groups of items having the same lib id
std::sort( m_components.begin(), m_components.end(), sort_by_libid );
std::sort( m_symbols.begin(), m_symbols.end(), sort_by_libid );
// Now, fill m_grid
wxString last_str_libid = m_components.front().GetStringLibId();
wxString last_str_libid = m_symbols.front().GetStringLibId();
int row = 0;
wxString refs;
wxString last_ref;
bool mark_cell = m_components.front().m_IsOrphan;
bool mark_cell = m_symbols.front().m_IsOrphan;
for( auto& cmp : m_components )
for( auto& cmp : m_symbols )
{
wxString str_libid = cmp.GetStringLibId();
@ -709,7 +709,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow()
LIB_ID id;
id.Parse( new_libid, true );
for( CMP_CANDIDATE& cmp : m_components )
for( SYM_CANDIDATE& cmp : m_symbols )
{
if( cmp.m_Row != row )
continue;
@ -735,30 +735,30 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow()
if( symbol == nullptr )
continue;
GetParent()->SaveCopyInUndoList( cmp.m_Screen, cmp.m_Component, UNDO_REDO::CHANGED,
GetParent()->SaveCopyInUndoList( cmp.m_Screen, cmp.m_Symbol, UNDO_REDO::CHANGED,
m_isModified );
m_isModified = true;
cmp.m_Screen->Remove( cmp.m_Component );
SCH_FIELD* value = cmp.m_Component->GetField( VALUE_FIELD );
cmp.m_Screen->Remove( cmp.m_Symbol );
SCH_FIELD* value = cmp.m_Symbol->GetField( VALUE_FIELD );
// If value is a proxy for the itemName then make sure it gets updated
if( cmp.m_Component->GetLibId().GetLibItemName().wx_str() == value->GetText() )
cmp.m_Component->SetValue( id.GetLibItemName().wx_str() );
if( cmp.m_Symbol->GetLibId().GetLibItemName().wx_str() == value->GetText() )
cmp.m_Symbol->SetValue( id.GetLibItemName().wx_str() );
cmp.m_Component->SetLibId( id );
cmp.m_Component->SetLibSymbol( symbol->Flatten().release() );
cmp.m_Screen->Append( cmp.m_Component );
cmp.m_Symbol->SetLibId( id );
cmp.m_Symbol->SetLibSymbol( symbol->Flatten().release() );
cmp.m_Screen->Append( cmp.m_Symbol );
cmp.m_Screen->SetContentModified();
if ( m_checkBoxUpdateFields->IsChecked() )
{
cmp.m_Component->UpdateFields( nullptr,
false, /* update style */
false, /* update ref */
false, /* update other fields */
false, /* reset ref */
true /* reset other fields */ );
cmp.m_Symbol->UpdateFields( nullptr,
false, /* update style */
false, /* update ref */
false, /* update other fields */
false, /* reset ref */
true /* reset other fields */ );
}
}
}

View File

@ -275,7 +275,7 @@ void DIALOG_LABEL_EDITOR::onScintillaCharAdded( wxStyledTextEvent &aEvent )
wxString ref = te->GetRange( refStart, start-1 );
SCH_SHEET_LIST sheets = m_Parent->Schematic().GetSheets();
SCH_REFERENCE_LIST refs;
SCH_COMPONENT* refSymbol = nullptr;
SCH_SYMBOL* refSymbol = nullptr;
sheets.GetSymbols( refs );

View File

@ -230,7 +230,7 @@ bool DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow()
if( m_fieldId == REFERENCE_FIELD )
{
// Test if the reference string is valid:
if( !SCH_COMPONENT::IsReferenceStringValid( m_text ) )
if( !SCH_SYMBOL::IsReferenceStringValid( m_text ) )
{
DisplayError( this, _( "Illegal reference designator value!" ) );
return false;
@ -290,7 +290,7 @@ DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent,
DIALOG_EDIT_ONE_FIELD( aParent, aTitle, aField ),
m_field( aField )
{
if( aField->GetParent() && aField->GetParent()->Type() == SCH_COMPONENT_T )
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
{
m_fieldId = aField->GetId();
}
@ -311,14 +311,14 @@ DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent,
m_textLabel->SetLabel( m_field->GetName() + ":" );
// The library symbol may have been removed so using SCH_COMPONENT::GetPartRef() here
// The library symbol may have been removed so using SCH_SYMBOL::GetPartRef() here
// could result in a segfault. If the library symbol is no longer available, the
// schematic fields can still edit so set the power symbol flag to false. This may not
// be entirely accurate if the power library is missing but it's better then a segfault.
if( aField->GetParent() && aField->GetParent()->Type() == SCH_COMPONENT_T )
if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
{
const SCH_COMPONENT* component = (SCH_COMPONENT*) aField->GetParent();
const LIB_PART* part = GetParent()->GetLibPart( component->GetLibId(), true );
const SCH_SYMBOL* symbol = (SCH_SYMBOL*) aField->GetParent();
const LIB_PART* part = GetParent()->GetLibPart( symbol->GetLibId(), true );
if( part && part->IsPower() )
m_isPower = true;
@ -375,7 +375,7 @@ void DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded( wxStyledTextEvent &aEvent
wxString ref = m_StyledTextCtrl->GetRange( refStart, start - 1 );
SCH_SHEET_LIST sheets = editFrame->Schematic().GetSheets();
SCH_REFERENCE_LIST refs;
SCH_COMPONENT* refSymbol = nullptr;
SCH_SYMBOL* refSymbol = nullptr;
sheets.GetSymbols( refs );
@ -396,8 +396,8 @@ void DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded( wxStyledTextEvent &aEvent
{
partial = m_StyledTextCtrl->GetTextRange( start, pos );
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( m_field->GetParent() );
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_field->GetParent() );
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
if( symbol )
{
@ -427,9 +427,9 @@ void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH*
SCH_ITEM* parent = dynamic_cast<SCH_ITEM*>( aField->GetParent() );
int fieldType = aField->GetId();
if( parent && parent->Type() == SCH_COMPONENT_T )
if( parent && parent->Type() == SCH_SYMBOL_T )
{
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( parent );
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
if( fieldType == REFERENCE_FIELD )
symbol->SetRef( aSheetPath, m_text );
@ -461,9 +461,9 @@ void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH*
// The value, footprint and datasheet fields should be kept in sync in multi-unit parts.
// Of course the component must be annotated to collect other units.
if( editFrame && parent && parent->Type() == SCH_COMPONENT_T )
if( editFrame && parent && parent->Type() == SCH_SYMBOL_T )
{
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( parent );
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( parent );
if( symbol->IsAnnotated( aSheetPath ) && ( fieldType == VALUE_FIELD
|| fieldType == FOOTPRINT_FIELD
@ -475,13 +475,13 @@ void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH*
for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
{
SCH_SCREEN* screen = sheet.LastScreen();
std::vector<SCH_COMPONENT*> otherUnits;
constexpr bool appendUndo = true;
SCH_SCREEN* screen = sheet.LastScreen();
std::vector<SCH_SYMBOL*> otherUnits;
constexpr bool appendUndo = true;
CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
for( SCH_COMPONENT* otherUnit : otherUnits )
for( SCH_SYMBOL* otherUnit : otherUnits )
{
editFrame->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
appendUndo );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Oliver Walters
* Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-2021 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
@ -205,8 +205,9 @@ public:
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
{
SCH_COMPONENT* symbol = m_symbolsList[ i ].GetSymbol();
m_dataStore[ symbol->m_Uuid ][ aFieldName ] = symbol->GetFieldText( aFieldName, m_frame );
SCH_SYMBOL* symbol = m_symbolsList[ i ].GetSymbol();
m_dataStore[ symbol->m_Uuid ][ aFieldName ] = symbol->GetFieldText( aFieldName,
m_frame );
}
}
@ -589,8 +590,8 @@ public:
{
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
{
SCH_COMPONENT& symbol = *m_symbolsList[ i ].GetSymbol();
SCH_SCREEN* screen = m_symbolsList[i].GetSheetPath().LastScreen();
SCH_SYMBOL& symbol = *m_symbolsList[ i ].GetSymbol();
SCH_SCREEN* screen = m_symbolsList[i].GetSheetPath().LastScreen();
m_frame->SaveCopyInUndoList( screen, &symbol, UNDO_REDO::CHANGED, true );
@ -840,16 +841,16 @@ bool DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow()
TOOL_MANAGER* toolMgr = m_parent->GetToolManager();
EE_SELECTION_TOOL* selectionTool = toolMgr->GetTool<EE_SELECTION_TOOL>();
EE_SELECTION& selection = selectionTool->GetSelection();
SCH_COMPONENT* symbol = nullptr;
SCH_SYMBOL* symbol = nullptr;
if( selection.GetSize() == 1 )
{
EDA_ITEM* item = selection.Front();
if( item->Type() == SCH_COMPONENT_T )
symbol = (SCH_COMPONENT*) item;
else if( item->GetParent() && item->GetParent()->Type() == SCH_COMPONENT_T )
symbol = (SCH_COMPONENT*) item->GetParent();
if( item->Type() == SCH_SYMBOL_T )
symbol = (SCH_SYMBOL*) item;
else if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T )
symbol = (SCH_SYMBOL*) item->GetParent();
}
if( symbol )
@ -943,7 +944,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::LoadFieldNames()
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
{
SCH_COMPONENT* symbol = m_symbolsList[ i ].GetSymbol();
SCH_SYMBOL* symbol = m_symbolsList[ i ].GetSymbol();
for( int j = MANDATORY_FIELDS; j < symbol->GetFieldCount(); ++j )
userFieldNames.insert( symbol->GetFields()[j].GetName() );
@ -1148,7 +1149,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableCellClick( wxGridEvent& event )
SCH_EDITOR_CONTROL* editor = m_parent->GetToolManager()->GetTool<SCH_EDITOR_CONTROL>();
editor->FindSymbolAndItem( refs[ 0 ].GetRef() + refs[ 0 ].GetRefNumber(), true,
HIGHLIGHT_COMPONENT, wxEmptyString );
HIGHLIGHT_SYMBOL, wxEmptyString );
}
}
else

View File

@ -302,9 +302,9 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
if( m_referenceFilterOpt->GetValue() && !m_referenceFilter->GetValue().IsEmpty() )
{
if( aItem->Type() == SCH_COMPONENT_T )
if( aItem->Type() == SCH_SYMBOL_T )
{
wxString ref = static_cast<SCH_COMPONENT*>( aItem )->GetRef( &aSheetPath );
wxString ref = static_cast<SCH_SYMBOL*>( aItem )->GetRef( &aSheetPath );
if( !WildCompareString( m_referenceFilter->GetValue(), ref, false ) )
return;
@ -313,9 +313,9 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
if( m_symbolFilterOpt->GetValue() && !m_symbolFilter->GetValue().IsEmpty() )
{
if( aItem->Type() == SCH_COMPONENT_T )
if( aItem->Type() == SCH_SYMBOL_T )
{
wxString id = static_cast<SCH_COMPONENT*>( aItem )->GetLibId().Format();
wxString id = static_cast<SCH_SYMBOL*>( aItem )->GetLibId().Format();
if( !WildCompareString( m_symbolFilter->GetValue(), id, false ) )
return;
@ -324,9 +324,9 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
if( m_typeFilterOpt->GetValue() )
{
if( aItem->Type() == SCH_COMPONENT_T )
if( aItem->Type() == SCH_SYMBOL_T )
{
bool isPower = static_cast<SCH_COMPONENT*>( aItem )->GetPartRef()->IsPower();
bool isPower = static_cast<SCH_SYMBOL*>( aItem )->GetPartRef()->IsPower();
if( isPower != ( m_typeFilter->GetSelection() == 1 ) )
return;
@ -337,9 +337,9 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( const SCH_SHEET_PATH& aShe
static KICAD_T busTypes[] = { SCH_LINE_LOCATE_BUS_T, SCH_LABEL_LOCATE_BUS_T, EOT };
static KICAD_T schTextAndGraphics[] = { SCH_TEXT_T, SCH_LINE_LOCATE_GRAPHIC_LINE_T, EOT };
if( aItem->Type() == SCH_COMPONENT_T )
if( aItem->Type() == SCH_SYMBOL_T )
{
SCH_COMPONENT* symbol = (SCH_COMPONENT*) aItem;
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
if( m_references->GetValue() )
processItem( aSheetPath, symbol->GetField( REFERENCE_FIELD ), aItem );

View File

@ -222,7 +222,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::Validate()
// Alias symbol reference can be empty because it inherits from the parent symbol.
if( m_libEntry->IsRoot() &&
!SCH_COMPONENT::IsReferenceStringValid( m_fields->at( REFERENCE_FIELD ).GetText() ) )
!SCH_SYMBOL::IsReferenceStringValid( m_fields->at( REFERENCE_FIELD ).GetText() ) )
{
if( m_NoteBook->GetSelection() != 0 )
m_NoteBook->SetSelection( 0 );
@ -564,9 +564,9 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event )
{
#ifdef KICAD_SPICE
int diff = m_fields->size();
auto cmp = SCH_COMPONENT( *m_libEntry, m_libEntry->GetLibId(), nullptr );
auto symbol = SCH_SYMBOL( *m_libEntry, m_libEntry->GetLibId(), nullptr );
DIALOG_SPICE_MODEL dialog( this, cmp, m_fields );
DIALOG_SPICE_MODEL dialog( this, symbol, m_fields );
if( dialog.ShowModal() != wxID_OK )
return;

View File

@ -214,15 +214,15 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
wxVector<wxVariant> data;
int count = 0;
for( SCH_COMPONENT* each_component : *m_Rescuer->GetComponents() )
for( SCH_SYMBOL* eachSymbol : *m_Rescuer->GetSymbols() )
{
if( each_component->GetLibId().Format() != UTF8( selected_part.GetRequestedName() ) )
if( eachSymbol->GetLibId().Format() != UTF8( selected_part.GetRequestedName() ) )
continue;
SCH_FIELD* valueField = each_component->GetField( VALUE_FIELD );
SCH_FIELD* valueField = eachSymbol->GetField( VALUE_FIELD );
data.clear();
data.push_back( each_component->GetRef( m_currentSheet ) );
data.push_back( eachSymbol->GetRef( m_currentSheet ) );
data.push_back( valueField ? valueField->GetText() : wxT( "" ) );
m_ListOfInstances->AppendItem( data );
count++;

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2017 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -47,7 +47,8 @@ static bool empty( const wxTextCtrl* aCtrl )
// Function to sort PWL values list
static int wxCALLBACK comparePwlValues( wxIntPtr aItem1, wxIntPtr aItem2, wxIntPtr WXUNUSED( aSortData ) )
static int wxCALLBACK comparePwlValues( wxIntPtr aItem1, wxIntPtr aItem2,
wxIntPtr WXUNUSED( aSortData ) )
{
float* t1 = reinterpret_cast<float*>( &aItem1 );
float* t2 = reinterpret_cast<float*>( &aItem2 );
@ -106,8 +107,9 @@ static int getModelTypeIdx( char aPrimitive )
}
DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, SCH_FIELDS* aFields )
: DIALOG_SPICE_MODEL_BASE( aParent ), m_component( aComponent ), m_schfields( aFields ),
DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol,
SCH_FIELDS* aFields )
: DIALOG_SPICE_MODEL_BASE( aParent ), m_symbol( aSymbol ), m_schfields( aFields ),
m_libfields( nullptr ), m_useSchFields( true ),
m_spiceEmptyValidator( true ), m_notEmptyValidator( wxFILTER_EMPTY )
{
@ -115,10 +117,10 @@ DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aCompo
}
DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent,
DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol,
std::vector<LIB_FIELD>* aFields ) :
DIALOG_SPICE_MODEL_BASE( aParent ),
m_component( aComponent ),
m_symbol( aSymbol ),
m_schfields( nullptr ),
m_libfields( aFields ),
m_useSchFields( false ),
@ -257,7 +259,6 @@ bool DIALOG_SPICE_MODEL::TransferDataFromWindow()
m_fieldsTmp[SF_MODEL] = m_pasValue->GetValue();
}
// Model
else if( page == m_model )
{
@ -274,9 +275,7 @@ bool DIALOG_SPICE_MODEL::TransferDataFromWindow()
if( !empty( m_modelLibrary ) )
m_fieldsTmp[SF_LIB_FILE] = m_modelLibrary->GetValue();
}
// Power source
else if( page == m_power )
else if( page == m_power ) // Power source
{
wxString model;
@ -286,8 +285,6 @@ bool DIALOG_SPICE_MODEL::TransferDataFromWindow()
m_fieldsTmp[SF_PRIMITIVE] = (char)( m_pwrType->GetSelection() ? SP_ISOURCE : SP_VSOURCE );
m_fieldsTmp[SF_MODEL] = model;
}
else
{
wxASSERT_MSG( false, "Unhandled model type" );
@ -310,7 +307,8 @@ bool DIALOG_SPICE_MODEL::TransferDataFromWindow()
else
{
// Erase empty fields (having empty fields causes a warning in the properties dialog)
const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) i );
const wxString& spiceField =
NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD ) i );
if( m_useSchFields )
{
@ -346,8 +344,9 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
{
const wxString& spiceField = spiceFields[idx];
m_fieldsTmp[idx] = NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( (SPICE_FIELD) idx, &m_component,
NET_ADJUST_INCLUDE_PATHS | NET_ADJUST_PASSIVE_VALS );
m_fieldsTmp[idx] = NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(
(SPICE_FIELD ) idx, &m_symbol,
NET_ADJUST_INCLUDE_PATHS | NET_ADJUST_PASSIVE_VALS );
// Do not modify the existing value, just add missing fields with default values
if( m_useSchFields && m_schfields )
@ -361,7 +360,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
}
}
}
else if( m_libfields)
else if( m_libfields )
{
// TODO: There must be a good way to template out these repetitive calls
for( const LIB_FIELD& field : *m_libfields )
@ -427,7 +426,7 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
// Check if node sequence is different than the default one
if( m_fieldsTmp[SF_NODE_SEQUENCE]
!= NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SF_NODE_SEQUENCE, &m_component, 0 ) )
!= NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal( SF_NODE_SEQUENCE, &m_symbol, 0 ) )
{
m_nodeSeqCheck->SetValue( true );
m_nodeSeqVal->SetValue( m_fieldsTmp[SF_NODE_SEQUENCE] );
@ -540,15 +539,14 @@ bool DIALOG_SPICE_MODEL::parsePowerSource( const wxString& aModel )
genericControls = { m_pulseInit, m_pulseNominal, m_pulseDelay,
m_pulseRise, m_pulseFall, m_pulseWidth, m_pulsePeriod };
}
else if( tkn == "sin" )
{
m_powerNotebook->SetSelection( m_powerNotebook->FindPage( m_pwrSin ) );
genericProcessing = true;
genericReqParamsCount = 2;
genericControls = { m_sinOffset, m_sinAmplitude, m_sinFreq, m_sinDelay, m_sinDampFactor };
genericControls = { m_sinOffset, m_sinAmplitude, m_sinFreq, m_sinDelay,
m_sinDampFactor };
}
else if( tkn == "exp" )
{
@ -673,7 +671,8 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
try
{
if( !empty( m_genDc ) )
acdc += wxString::Format( "dc %s ", SPICE_VALUE( m_genDc->GetValue() ).ToSpiceString() );
acdc += wxString::Format( "dc %s ",
SPICE_VALUE( m_genDc->GetValue() ).ToSpiceString() );
}
catch( ... )
{
@ -685,10 +684,12 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
{
if( !empty( m_genAcMag ) )
{
acdc += wxString::Format( "ac %s ", SPICE_VALUE( m_genAcMag->GetValue() ).ToSpiceString() );
acdc += wxString::Format( "ac %s ",
SPICE_VALUE( m_genAcMag->GetValue() ).ToSpiceString() );
if( !empty( m_genAcPhase ) )
acdc += wxString::Format( "%s ", SPICE_VALUE( m_genAcPhase->GetValue() ).ToSpiceString() );
acdc += wxString::Format( "%s ",
SPICE_VALUE( m_genAcPhase->GetValue() ).ToSpiceString() );
}
}
catch( ... )
@ -792,26 +793,26 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
// all empty
useTrans = false;
}
else if( std::distance( genericControls.begin(), first_empty ) < (int)genericReqParamsCount )
else if( std::distance( genericControls.begin(),
first_empty ) < (int)genericReqParamsCount )
{
DisplayError( nullptr,
wxString::Format( wxT( "You need to specify at least the "
"first %d parameters for the transient source" ),
genericReqParamsCount ) );
wxString::Format( _( "You need to specify at least the "
"first %d parameters for the transient source" ),
genericReqParamsCount ) );
return false;
}
else if( std::find_if_not( first_empty, genericControls.end(),
empty ) != genericControls.end() )
empty ) != genericControls.end() )
{
DisplayError( nullptr, wxT( "You cannot leave interleaved empty fields "
"when defining a transient source" ) );
DisplayError( nullptr, _( "You cannot leave interleaved empty fields "
"when defining a transient source" ) );
return false;
}
else
{
std::for_each( genericControls.begin(), first_empty,
[&trans] ( wxTextCtrl* ctrl ) {
std::for_each( genericControls.begin(), first_empty, [&trans] ( wxTextCtrl* ctrl ) {
trans += wxString::Format( "%s ", ctrl->GetValue() );
} );
}
@ -939,9 +940,11 @@ void DIALOG_SPICE_MODEL::loadLibrary( const wxString& aFilePath )
SCH_FIELD& DIALOG_SPICE_MODEL::getSchField( int aFieldType )
{
const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) aFieldType );
const wxString& spiceField =
NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) aFieldType );
auto fieldIt = std::find_if( m_schfields->begin(), m_schfields->end(), [&]( const SCH_FIELD& f ) {
auto fieldIt = std::find_if( m_schfields->begin(), m_schfields->end(),
[&]( const SCH_FIELD& f ) {
return f.GetName() == spiceField;
} );
@ -950,14 +953,15 @@ SCH_FIELD& DIALOG_SPICE_MODEL::getSchField( int aFieldType )
return *fieldIt;
// Create a new field with requested name
m_schfields->emplace_back( wxPoint(), m_schfields->size(), &m_component, spiceField );
m_schfields->emplace_back( wxPoint(), m_schfields->size(), &m_symbol, spiceField );
return m_schfields->back();
}
LIB_FIELD& DIALOG_SPICE_MODEL::getLibField( int aFieldType )
{
const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) aFieldType );
const wxString& spiceField =
NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( ( SPICE_FIELD ) aFieldType );
auto fieldIt = std::find_if( m_libfields->begin(), m_libfields->end(),
[&]( const LIB_FIELD& f )
@ -1023,7 +1027,8 @@ void DIALOG_SPICE_MODEL::onSelectLibrary( wxCommandEvent& event )
wxFileName libPath( openDlg.GetPath() );
// Try to convert the path to relative to project
if( libPath.MakeRelativeTo( Prj().GetProjectPath() ) && !libPath.GetFullPath().StartsWith( ".." ) )
if( libPath.MakeRelativeTo( Prj().GetProjectPath() )
&& !libPath.GetFullPath().StartsWith( ".." ) )
m_modelLibrary->SetValue( libPath.GetFullPath() );
else
m_modelLibrary->SetValue( openDlg.GetPath() );

View File

@ -40,9 +40,9 @@
class DIALOG_SPICE_MODEL : public DIALOG_SPICE_MODEL_BASE
{
public:
DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent,
DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol,
std::vector<SCH_FIELD>* aSchFields );
DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent,
DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol,
std::vector<LIB_FIELD>* aLibFields );
private:
@ -131,7 +131,7 @@ private:
void onTypeSelected( wxCommandEvent& event ) override;
///< Edited component
SCH_COMPONENT& m_component;
SCH_SYMBOL& m_symbol;
///< Fields from the component properties dialog
std::vector<SCH_FIELD>* m_schfields;

View File

@ -274,15 +274,15 @@ public:
DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
SCH_COMPONENT* aComponent ) :
SCH_SYMBOL* aSymbol ) :
DIALOG_SYMBOL_PROPERTIES_BASE( aParent ),
m_comp( nullptr ),
m_symbol( nullptr ),
m_part( nullptr ),
m_fields( nullptr ),
m_dataModel( nullptr )
{
m_comp = aComponent;
m_part = m_comp->GetPartRef().get();
m_symbol = aSymbol;
m_part = m_symbol->GetPartRef().get();
// GetPartRef() now points to the cached part in the schematic, which should always be
// there for usual cases, but can be null when opening old schematics not storing the part
@ -301,7 +301,7 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
#endif /* not KICAD_SPICE */
// disable some options inside the edit dialog which can cause problems while dragging
if( m_comp->IsDragging() )
if( m_symbol->IsDragging() )
{
m_orientationLabel->Disable();
m_orientationCtrl->Disable();
@ -332,14 +332,14 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
// back and forth when the conversion is changed.)
m_pinTablePage->Disable();
m_pinTablePage->SetToolTip(
_( "Alternate pin assignments are not available for DeMorgan components." ) );
_( "Alternate pin assignments are not available for DeMorgan symbols." ) );
}
else
{
m_dataModel = new SCH_PIN_TABLE_DATA_MODEL();
// Make a copy of the pins for editing
for( const std::unique_ptr<SCH_PIN>& pin : m_comp->GetRawPins() )
for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
m_dataModel->push_back( *pin );
m_dataModel->SortRows( COL_NUMBER, true );
@ -413,12 +413,12 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
std::set<wxString> defined;
// Push a copy of each field into m_updateFields
for( int i = 0; i < m_comp->GetFieldCount(); ++i )
for( int i = 0; i < m_symbol->GetFieldCount(); ++i )
{
SCH_FIELD field( m_comp->GetFields()[i] );
SCH_FIELD field( m_symbol->GetFields()[i] );
// change offset to be symbol-relative
field.Offset( -m_comp->GetPosition() );
field.Offset( -m_symbol->GetPosition() );
defined.insert( field.GetName() );
m_fields->push_back( field );
@ -430,7 +430,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
{
if( defined.count( templateFieldname.m_Name ) <= 0 )
{
SCH_FIELD field( wxPoint( 0, 0 ), -1, m_comp, templateFieldname.m_Name );
SCH_FIELD field( wxPoint( 0, 0 ), -1, m_symbol, templateFieldname.m_Name );
field.SetVisible( templateFieldname.m_Visible );
m_fields->push_back( field );
}
@ -441,14 +441,14 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
m_fieldsGrid->ProcessTableMessage( msg );
AdjustGridColumns( m_fieldsGrid->GetRect().GetWidth() );
// If a multi-unit component, set up the unit selector and interchangeable checkbox.
if( m_comp->GetUnitCount() > 1 )
// If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
if( m_symbol->GetUnitCount() > 1 )
{
for( int ii = 1; ii <= m_comp->GetUnitCount(); ii++ )
for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
m_unitChoice->Append( LIB_PART::SubReference( ii, false ) );
if( m_comp->GetUnit() <= ( int )m_unitChoice->GetCount() )
m_unitChoice->SetSelection( m_comp->GetUnit() - 1 );
if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
}
else
{
@ -458,7 +458,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
if( m_part && m_part->HasConversion() )
{
if( m_comp->GetConvert() > LIB_ITEM::LIB_CONVERT::BASE )
if( m_symbol->GetConvert() > LIB_ITEM::LIB_CONVERT::BASE )
m_cbAlternateSymbol->SetValue( true );
}
else
@ -467,28 +467,28 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
}
// Set the symbol orientation and mirroring.
int orientation = m_comp->GetOrientation() & ~( CMP_MIRROR_X | CMP_MIRROR_Y );
int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
switch( orientation )
{
default:
case CMP_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
case CMP_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
case CMP_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
case CMP_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
}
int mirror = m_comp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
switch( mirror )
{
default: m_mirrorCtrl->SetSelection( 0 ) ; break;
case CMP_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
case CMP_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
}
m_cbExcludeFromBom->SetValue( !m_comp->GetIncludeInBom() );
m_cbExcludeFromBoard->SetValue( !m_comp->GetIncludeOnBoard() );
m_cbExcludeFromBom->SetValue( !m_symbol->GetIncludeInBom() );
m_cbExcludeFromBoard->SetValue( !m_symbol->GetIncludeOnBoard() );
if( m_part )
{
@ -496,8 +496,8 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow()
m_ShowPinNameButt->SetValue( m_part->ShowPinNames() );
}
// Set the component's library name.
m_tcLibraryID->SetLabelText( m_comp->GetLibId().Format() );
// Set the symbol's library name.
m_tcLibraryID->SetLabelText( m_symbol->GetLibId().Format() );
Layout();
@ -518,7 +518,7 @@ void DIALOG_SYMBOL_PROPERTIES::OnEditSpiceModel( wxCommandEvent& event )
#ifdef KICAD_SPICE
int diff = m_fields->size();
DIALOG_SPICE_MODEL dialog( this, *m_comp, m_fields );
DIALOG_SPICE_MODEL dialog( this, *m_symbol, m_fields );
if( dialog.ShowModal() != wxID_OK )
return;
@ -557,7 +557,7 @@ bool DIALOG_SYMBOL_PROPERTIES::Validate()
if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
return false;
if( !SCH_COMPONENT::IsReferenceStringValid( m_fields->at( REFERENCE_FIELD ).GetText() ) )
if( !SCH_SYMBOL::IsReferenceStringValid( m_fields->at( REFERENCE_FIELD ).GetText() ) )
{
DisplayErrorMessage( this, _( "References must start with a letter." ) );
@ -608,41 +608,41 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
// This needs to be done before the LIB_ID is changed to prevent stale library symbols in
// the schematic file.
currentScreen->Remove( m_comp );
currentScreen->Remove( m_symbol );
wxString msg;
// save old cmp in undo list if not already in edit, or moving ...
if( m_comp->GetEditFlags() == 0 )
GetParent()->SaveCopyInUndoList( currentScreen, m_comp, UNDO_REDO::CHANGED, false );
if( m_symbol->GetEditFlags() == 0 )
GetParent()->SaveCopyInUndoList( currentScreen, m_symbol, UNDO_REDO::CHANGED, false );
// Save current flags which could be modified by next change settings
EDA_ITEM_FLAGS flags = m_comp->GetFlags();
EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
// For symbols with multiple shapes (De Morgan representation) Set the selected shape:
if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
m_comp->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN );
m_symbol->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN );
else
m_comp->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
m_symbol->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
//Set the part selection in multiple part per package
int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
m_comp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
m_comp->SetUnit( unit_selection );
m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
m_symbol->SetUnit( unit_selection );
switch( m_orientationCtrl->GetSelection() )
{
case 0: m_comp->SetOrientation( CMP_ORIENT_0 ); break;
case 1: m_comp->SetOrientation( CMP_ORIENT_90 ); break;
case 2: m_comp->SetOrientation( CMP_ORIENT_270 ); break;
case 3: m_comp->SetOrientation( CMP_ORIENT_180 ); break;
case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
}
switch( m_mirrorCtrl->GetSelection() )
{
case 0: break;
case 1: m_comp->SetOrientation( CMP_MIRROR_X ); break;
case 2: m_comp->SetOrientation( CMP_MIRROR_Y ); break;
case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
}
if( m_part )
@ -652,21 +652,21 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
}
// Restore m_Flag modified by SetUnit() and other change settings
m_comp->ClearFlags();
m_comp->SetFlags( flags );
m_symbol->ClearFlags();
m_symbol->SetFlags( flags );
// change all field positions from relative to absolute
for( unsigned i = 0; i < m_fields->size(); ++i )
m_fields->at( i ).Offset( m_comp->GetPosition() );
m_fields->at( i ).Offset( m_symbol->GetPosition() );
LIB_PART* entry = GetParent()->GetLibPart( m_comp->GetLibId() );
LIB_PART* entry = GetParent()->GetLibPart( m_symbol->GetLibId() );
if( entry && entry->IsPower() )
m_fields->at( VALUE_FIELD ).SetText( m_comp->GetLibId().GetLibItemName() );
m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() );
// Push all fields to the component -except- for those which are TEMPLATE_FIELDNAMES
// Push all fields to the symbol -except- for those which are TEMPLATE_FIELDNAMES
// with empty values.
SCH_FIELDS& fields = m_comp->GetFields();
SCH_FIELDS& fields = m_symbol->GetFields();
fields.clear();
@ -693,35 +693,35 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
}
// Reference has a specific initialization, depending on the current active sheet
// because for a given component, in a complex hierarchy, there are more than one
// because for a given symbol, in a complex hierarchy, there are more than one
// reference.
m_comp->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() );
m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() );
// Similar for Value and Footprint, except that the GUI behaviour is that they are kept
// in sync between multiple instances.
m_comp->SetValue( m_fields->at( VALUE_FIELD ).GetText() );
m_comp->SetFootprint( m_fields->at( FOOTPRINT_FIELD ).GetText() );
m_symbol->SetValue( m_fields->at( VALUE_FIELD ).GetText() );
m_symbol->SetFootprint( m_fields->at( FOOTPRINT_FIELD ).GetText() );
m_comp->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() );
m_comp->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() );
m_symbol->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() );
m_symbol->SetIncludeOnBoard( !m_cbExcludeFromBoard->IsChecked() );
// The value, footprint and datasheet fields and exclude from bill of materials setting
// should be kept in sync in multi-unit parts.
if( m_comp->GetUnitCount() > 1 && m_comp->IsAnnotated( &GetParent()->GetCurrentSheet() ) )
if( m_symbol->GetUnitCount() > 1 && m_symbol->IsAnnotated( &GetParent()->GetCurrentSheet() ) )
{
wxString ref = m_comp->GetRef( &GetParent()->GetCurrentSheet() );
int unit = m_comp->GetUnit();
LIB_ID libId = m_comp->GetLibId();
wxString ref = m_symbol->GetRef( &GetParent()->GetCurrentSheet() );
int unit = m_symbol->GetUnit();
LIB_ID libId = m_symbol->GetLibId();
for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() )
{
SCH_SCREEN* screen = sheet.LastScreen();
std::vector<SCH_COMPONENT*> otherUnits;
constexpr bool appendUndo = true;
SCH_SCREEN* screen = sheet.LastScreen();
std::vector<SCH_SYMBOL*> otherUnits;
constexpr bool appendUndo = true;
CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
for( SCH_COMPONENT* otherUnit : otherUnits )
for( SCH_SYMBOL* otherUnit : otherUnits )
{
GetParent()->SaveCopyInUndoList( screen, otherUnit, UNDO_REDO::CHANGED,
appendUndo );
@ -740,15 +740,15 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
{
for( const SCH_PIN& model_pin : *m_dataModel )
{
// map from the edited copy back to the "real" pin in the component
SCH_PIN* src_pin = m_comp->GetPin( model_pin.GetLibPin() );
// map from the edited copy back to the "real" pin in the symbol.
SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetLibPin() );
src_pin->SetAlt( model_pin.GetAlt() );
}
}
currentScreen->Append( m_comp );
currentScreen->Append( m_symbol );
GetParent()->TestDanglingEnds();
GetParent()->UpdateItem( m_comp );
GetParent()->UpdateItem( m_symbol );
GetParent()->OnModify();
// This must go after OnModify() so that the connectivity graph will have been updated.
@ -807,9 +807,9 @@ void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
if( !m_fieldsGrid->CommitPendingChanges() )
return;
SCHEMATIC_SETTINGS& settings = m_comp->Schematic()->Settings();
SCHEMATIC_SETTINGS& settings = m_symbol->Schematic()->Settings();
int fieldID = m_fields->size();
SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_comp,
SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_symbol,
TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID ) );
newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 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
@ -47,7 +47,7 @@ enum SYMBOL_PROPS_RETVALUE
/**
* Dialog used to edit #SCH_COMPONENT objects in a schematic.
* Dialog used to edit #SCH_SYMBOL objects in a schematic.
*
* This is derived from DIALOG_SYMBOL_PROPERTIES_BASE which is maintained by
* wxFormBuilder.
@ -55,7 +55,7 @@ enum SYMBOL_PROPS_RETVALUE
class DIALOG_SYMBOL_PROPERTIES : public DIALOG_SYMBOL_PROPERTIES_BASE
{
public:
DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_COMPONENT* aComponent );
DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_SYMBOL* aSymbol );
~DIALOG_SYMBOL_PROPERTIES() override;
SCH_EDIT_FRAME* GetParent();
@ -89,7 +89,7 @@ private:
void AdjustGridColumns( int aWidth );
private:
SCH_COMPONENT* m_comp;
SCH_SYMBOL* m_symbol;
LIB_PART* m_part;
int m_width;

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