KiCad PCB EDA Suite
project_rescue.cpp File Reference
#include <class_drawpanel.h>
#include <class_library.h>
#include <confirm.h>
#include <invoke_sch_dialog.h>
#include <kicad_device_context.h>
#include <kiway.h>
#include <project_rescue.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <schframe.h>
#include <symbol_lib_table.h>
#include <viewlib_frame.h>
#include <wildcards_and_files_ext.h>
#include <cctype>
#include <map>

Go to the source code of this file.

Typedefs

typedef std::pair< SCH_COMPONENT *, wxString > COMPONENT_NAME_PAIR
 

Functions

static bool sort_by_libid (const SCH_COMPONENT *ref, SCH_COMPONENT *cmp)
 
static void get_components (std::vector< SCH_COMPONENT * > &aComponents)
 Fill a vector with all of the project's symbols, to ease iterating over them. More...
 
static LIB_PARTfind_component (wxString aName, PART_LIBS *aLibs, bool aCached)
 Search the libraries for the first component with a given name. More...
 
static wxFileName GetRescueLibraryFileName ()
 

Typedef Documentation

typedef std::pair<SCH_COMPONENT*, wxString> COMPONENT_NAME_PAIR

Definition at line 43 of file project_rescue.cpp.

Function Documentation

static LIB_PART* find_component ( wxString  aName,
PART_LIBS aLibs,
bool  aCached 
)
static

Search the libraries for the first component with a given name.

Parameters
aName- name to search for
aLibs- the loaded PART_LIBS
aCached- whether we are looking for the cached part

Definition at line 94 of file project_rescue.cpp.

Referenced by RESCUE_CACHE_CANDIDATE::FindRescues(), and RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues().

95 {
96  LIB_PART *part = NULL;
97 
98  for( PART_LIB& each_lib : *aLibs )
99  {
100  if( aCached && !each_lib.IsCache() )
101  continue;
102 
103  if( !aCached && each_lib.IsCache() )
104  continue;
105 
106  part = each_lib.FindPart( aName );
107 
108  if( part )
109  break;
110  }
111 
112  return part;
113 }
Class LIB_PART defines a library part object.
Class PART_LIB is used to load, save, search, and otherwise manipulate part library files...
static void get_components ( std::vector< SCH_COMPONENT * > &  aComponents)
static

Fill a vector with all of the project's symbols, to ease iterating over them.

The list is sorted by LIB_ID, therefore components using the same library symbol are grouped, allowing later faster calculations (one library search by group of symbols)

Parameters
aComponents- a vector that will take the symbols

Definition at line 62 of file project_rescue.cpp.

References SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), SCH_ITEM::Next(), SCH_COMPONENT_T, and sort_by_libid().

Referenced by RESCUER::RESCUER().

63 {
64  SCH_SCREENS screens;
65 
66  // Get the full list
67  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
68  {
69  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
70  {
71  if( item->Type() != SCH_COMPONENT_T )
72  continue;
73 
74  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
75  aComponents.push_back( component );
76  }
77  }
78 
79  if( aComponents.empty() )
80  return;
81 
82  // sort aComponents by lib part. Components will be grouped by same lib part.
83  std::sort( aComponents.begin(), aComponents.end(), sort_by_libid );
84 }
SCH_SCREEN * GetNext()
static bool sort_by_libid(const SCH_COMPONENT *ref, SCH_COMPONENT *cmp)
SCH_ITEM * Next() const
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
SCH_SCREEN * GetFirst()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
static wxFileName GetRescueLibraryFileName ( )
static

Definition at line 116 of file project_rescue.cpp.

References g_RootSheet, SCH_SCREEN::GetFileName(), SCH_SHEET::GetScreen(), and SchematicLibraryFileExtension.

Referenced by SYMBOL_LIB_TABLE_RESCUER::AddPart(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(), LEGACY_RESCUER::OpenRescueLibrary(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

117 {
118  wxFileName fn( g_RootSheet->GetScreen()->GetFileName() );
119  fn.SetName( fn.GetName() + wxT( "-rescue" ) );
120  fn.SetExt( SchematicLibraryFileExtension );
121  return fn;
122 }
const wxString & GetFileName() const
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
const wxString SchematicLibraryFileExtension
static bool sort_by_libid ( const SCH_COMPONENT ref,
SCH_COMPONENT cmp 
)
static

Definition at line 47 of file project_rescue.cpp.

References SCH_COMPONENT::GetLibId().

Referenced by get_components().

48 {
49  return ref->GetLibId() < cmp->GetLibId();
50 }
const LIB_ID & GetLibId() const