KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_editor.cpp File Reference
#include <pgm_base.h>
#include <clipboard.h>
#include <confirm.h>
#include <kidialog.h>
#include <kiway.h>
#include <widgets/wx_infobar.h>
#include <tools/symbol_editor_drawing_tools.h>
#include <symbol_edit_frame.h>
#include <symbol_library.h>
#include <template_fieldnames.h>
#include <wildcards_and_files_ext.h>
#include <symbol_lib_table.h>
#include <lib_symbol_library_manager.h>
#include <symbol_tree_pane.h>
#include <project/project_file.h>
#include <widgets/lib_tree.h>
#include <sch_io/kicad_legacy/sch_io_kicad_legacy.h>
#include <sch_io/kicad_sexpr/sch_io_kicad_sexpr.h>
#include <dialogs/dialog_lib_new_symbol.h>
#include <eda_list_dialog.h>
#include <wx/clipbrd.h>
#include <wx/filedlg.h>
#include <wx/log.h>
#include <project_sch.h>
#include <string_utils.h>
#include "symbol_saveas_type.h"
#include <widgets/symbol_library_save_as_filedlg_hook.h>
#include <io/kicad/kicad_io_utils.h>

Go to the source code of this file.

Classes

class  SYMBOL_SAVE_AS_HANDLER
 This is a class that handles state involved in saving a symbol copy as a new symbol. More...
 
class  SAVE_SYMBOL_AS_DIALOG
 
struct  SAVE_SYMBOL_AS_DIALOG::PARAMS
 

Enumerations

enum  SAVE_AS_IDS { ID_MAKE_NEW_LIBRARY = wxID_HIGHEST + 1 , ID_OVERWRITE_CONFLICTS , ID_RENAME_CONFLICTS }
 

Functions

static std::vector< LIB_SYMBOL_SPTRGetParentChain (const LIB_SYMBOL &aSymbol, bool aIncludeLeaf=true)
 Get a list of all the symbols in the parental chain of a symbol, with the "leaf" symbol at the start and the "rootiest" symbol at the end.
 
static std::pair< bool, bool > CheckSavingIntoOwnInheritance (LIB_SYMBOL_LIBRARY_MANAGER &aLibMgr, LIB_SYMBOL &aSymbol, const wxString &aNewSymbolName, const wxString &aNewLibraryName)
 Check if a planned overwrite would put a symbol into it's own inheritance chain.
 
static std::vector< wxString > CheckForParentalChainConflicts (LIB_SYMBOL_LIBRARY_MANAGER &aLibMgr, LIB_SYMBOL &aSymbol, bool aFlattenSymbol, const wxString &newSymbolName, const wxString &newLibraryName)
 Get a list of all the symbols in the parental chain of a symbol that have conflicts when transposed to a different library.
 

Enumeration Type Documentation

◆ SAVE_AS_IDS

Enumerator
ID_MAKE_NEW_LIBRARY 
ID_OVERWRITE_CONFLICTS 
ID_RENAME_CONFLICTS 

Definition at line 753 of file symbol_editor.cpp.

Function Documentation

◆ CheckForParentalChainConflicts()

static std::vector< wxString > CheckForParentalChainConflicts ( LIB_SYMBOL_LIBRARY_MANAGER & aLibMgr,
LIB_SYMBOL & aSymbol,
bool aFlattenSymbol,
const wxString & newSymbolName,
const wxString & newLibraryName )
static

Get a list of all the symbols in the parental chain of a symbol that have conflicts when transposed to a different library.

This doesn't check for dangerous conflicts like saving into a symbol's own inheritance, this is just about which symbols will get overwritten if saved with these names.

Definition at line 567 of file symbol_editor.cpp.

References LIB_SYMBOL::GetLibId(), LIB_ID::GetLibNickname(), LIB_SYMBOL::GetName(), GetParentChain(), and SYMBOL_LIBRARY_MANAGER::SymbolNameInUse().

Referenced by SYMBOL_EDIT_FRAME::saveSymbolCopyAs().

◆ CheckSavingIntoOwnInheritance()

static std::pair< bool, bool > CheckSavingIntoOwnInheritance ( LIB_SYMBOL_LIBRARY_MANAGER & aLibMgr,
LIB_SYMBOL & aSymbol,
const wxString & aNewSymbolName,
const wxString & aNewLibraryName )
static

Check if a planned overwrite would put a symbol into it's own inheritance chain.

This causes infinite loops and other unpleasantness and makes not sense - inheritance must be acyclic.

Returns a pair of bools:

  • first: true if the symbol would be saved into it's own ancestry
  • second: true if the symbol would be saved into it's own descendents

Definition at line 506 of file symbol_editor.cpp.

References LIB_SYMBOL::GetLibId(), LIB_ID::GetLibNickname(), LIB_SYMBOL::GetName(), GetParentChain(), SYMBOL_LIBRARY_MANAGER::GetSymbol(), and SYMBOL_LIBRARY_MANAGER::SymbolNameInUse().

Referenced by SYMBOL_EDIT_FRAME::saveSymbolCopyAs().

◆ GetParentChain()

static std::vector< LIB_SYMBOL_SPTR > GetParentChain ( const LIB_SYMBOL & aSymbol,
bool aIncludeLeaf = true )
static

Get a list of all the symbols in the parental chain of a symbol, with the "leaf" symbol at the start and the "rootiest" symbol at the end.

If the symbol is not an alias, the list will contain only the symbol itself.

If aIncludeLeaf is false, the leaf symbol (the one that was actually named) is not included in the list, so the list may be empty if the symbol is not derived.

Definition at line 478 of file symbol_editor.cpp.

References chain, LIB_SYMBOL::GetParent(), LIB_SYMBOL::IsDerived(), and LIB_SYMBOL::SharedPtr().

Referenced by CheckForParentalChainConflicts(), CheckSavingIntoOwnInheritance(), SYMBOL_SAVE_AS_HANDLER::DoSave(), and SYMBOL_EDIT_FRAME::saveSymbolCopyAs().