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/ee_actions.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_filedlg_save_as.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_AS_DIALOG
 

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)
 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, 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 799 of file symbol_editor.cpp.

Function Documentation

◆ CheckForParentalChainConflicts()

static std::vector< wxString > CheckForParentalChainConflicts ( LIB_SYMBOL_LIBRARY_MANAGER aLibMgr,
LIB_SYMBOL aSymbol,
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 629 of file symbol_editor.cpp.

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

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 568 of file symbol_editor.cpp.

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

Referenced by SYMBOL_EDIT_FRAME::saveSymbolCopyAs().

◆ GetParentChain()

static std::vector< LIB_SYMBOL_SPTR > GetParentChain ( const LIB_SYMBOL aSymbol)
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.

Definition at line 545 of file symbol_editor.cpp.

References LIB_SYMBOL::SharedPtr().

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