KiCad PCB EDA Suite
sch_component.cpp File Reference
#include <fctsys.h>
#include <pgm_base.h>
#include <sch_draw_panel.h>
#include <gr_basic.h>
#include <kicad_string.h>
#include <richio.h>
#include <sch_edit_frame.h>
#include <plotter.h>
#include <msgpanel.h>
#include <bitmaps.h>
#include <general.h>
#include <class_library.h>
#include <lib_rectangle.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <netlist_object.h>
#include <lib_item.h>
#include <symbol_lib_table.h>
#include <dialogs/dialog_schematic_find.h>
#include <wx/tokenzr.h>
#include <iostream>
#include <cctype>
#include <eeschema_id.h>
#include <trace_helpers.h>

Go to the source code of this file.

Functions

std::string toUTFTildaText (const wxString &txt)
 Function toUTFTildaText convert a wxString to UTF8 and replace any control characters with a ~, where a control character is one of the first ASCII values up to ' ' 32d. More...
 
static LIB_PARTdummy ()
 Used to draw a dummy shape when a LIB_PART is not found in library. More...
 
static bool sort_by_libid (const SCH_COMPONENT *ref, SCH_COMPONENT *cmp)
 

Function Documentation

◆ dummy()

static LIB_PART* dummy ( )
static

Used to draw a dummy shape when a LIB_PART is not found in library.

This component is a 400 mils square with the text ?? DEF DUMMY U 0 40 Y Y 1 0 N F0 "U" 0 -350 60 H V F1 "DUMMY" 0 350 60 H V DRAW T 0 0 0 150 0 0 0 ?? S -200 200 200 -200 0 1 0 ENDDRAW ENDDEF

Definition at line 90 of file sch_component.cpp.

91 {
92  static LIB_PART* part;
93 
94  if( !part )
95  {
96  part = new LIB_PART( wxEmptyString );
97 
98  LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
99 
100  square->MoveTo( wxPoint( -200, 200 ));
101  square->SetEndPosition( wxPoint( 200, -200 ) );
102 
103  LIB_TEXT* text = new LIB_TEXT( part );
104 
105  text->SetTextSize( wxSize( 150, 150 ) );
106  text->SetText( wxString( wxT( "??" ) ) );
107 
108  part->AddDrawItem( square );
109  part->AddDrawItem( text );
110  }
111 
112  return part;
113 }
Define a symbol library graphical text item.
Definition: lib_text.h:40
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:220
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:112
Define a library symbol object.
void SetEndPosition(const wxPoint &aPosition)
Definition: lib_rectangle.h:57

References LIB_PART::AddDrawItem(), LIB_RECTANGLE::MoveTo(), LIB_RECTANGLE::SetEndPosition(), EDA_TEXT::SetText(), and EDA_TEXT::SetTextSize().

Referenced by SCH_EDITOR_CONTROL::Annotate(), TWO_COLUMN_TREE_LIST::AutosizeColumns(), CINFO3D_VISU::buildPadShapePolygon(), D_PAD::BuildPadShapePolygon(), SHAPE::Collide(), GERBER_WRITER::createDrillFile(), EXCELLON_WRITER::createDrillFile(), PL_DRAW_PANEL_GAL::DisplayWorksheet(), COMMON_TOOLS::doZoomToPreset(), PNS_PCBNEW_RULE_RESOLVER::DpCoupledNet(), PCB_EDIT_FRAME::Edit_Zone_Params(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), GENDRILL_WRITER_BASE::genDrillMapFile(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), PCB_EDITOR_CONTROL::GenerateFabFiles(), GERBVIEW_FRAME::GERBVIEW_FRAME(), PL_EDITOR_FRAME::GetAuxOrigin(), SCH_COMPONENT::GetBodyBoundingBox(), LIB_ALIAS::GetBoundingBox(), WS_DRAW_ITEM_PAGE::GetBoundingBox(), FP_TREE_MODEL_ADAPTER::getFootprints(), SCHLIB_FILTER::GetLibSource(), SCH_COMPONENT::GetMsgPanelInfo(), LIB_PART::GetName(), NETINFO_ITEM::GetPosition(), X2_ATTRIBUTE::GetPrm(), COMMON_TOOLS::GridPreset(), GRText(), highlightNet(), ZONE_CONTAINER::HitTestForCorner(), ZONE_CONTAINER::HitTestForEdge(), DIALOG_PAGES_SETTINGS::initDialog(), DIALOG_GENDRILL::InitDisplayParams(), SHAPE_LINE_CHAIN::Intersects(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EXCELLON_IMAGE::LoadFile(), CVPCB_CONTROL::Main(), PCBNEW_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_POINTS_FACTORY::Make(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnAddAlias(), DIALOG_EXCHANGE_FOOTPRINTS::OnApplyClicked(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnBrowseLibrary(), DIALOG_SCH_FIND::OnCancel(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnCheckGithubList(), PNS::SHOVE::onCollidingSolid(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnDeleteAlias(), DIALOG_EXPORT_STEP::onExportButton(), PCB_EDIT_FRAME::OnExportIDF3(), PCB_EDIT_FRAME::OnExportVRML(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnFilterDClick(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnSelectAll3Dlibs(), EDA_DRAW_FRAME::OnSelectGrid(), DIALOG_DRC_CONTROL::OnStartdrcClick(), DIALOG_NETLIST::OnTestFootprintsClick(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI(), LENGTH_TUNER_TOOL::performTuning(), DIALOG_PLOT::Plot(), PlotStandardLayer(), SCH_COMPONENT::Print(), SCH_PRINTOUT::PrintPage(), DIALOG_ERC::ReBuildMatrixPanel(), GERBVIEW_FRAME::ReCreateAuxiliaryToolbar(), PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar(), DIALOG_INSPECTOR::ReCreateDesignList(), PCB_EDIT_FRAME::ReCreateHToolbar(), EDA_3D_VIEWER::ReCreateMainToolbar(), PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar(), PCB_EDIT_FRAME::ReCreateOptToolbar(), PCB_EDIT_FRAME::ReCreateVToolbar(), PCBNEW_CONTROL::Redo(), PL_EDITOR_FRAME::ReturnCoordOriginCorner(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), WS_DATA_ITEM_TEXT::SetConstrainedTextSize(), DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser(), LIB_CONTROL::ShowComponentTree(), SCH_EDITOR_CONTROL::ShowCvpcb(), SCH_EDITOR_CONTROL::ShowPcbNew(), SPICE_VALUE::SPICE_VALUE(), DIALOG_IMPORT_GFX::TransferDataFromWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataToWindow(), TREEPROJECTFILES::TREEPROJECTFILES(), PCBNEW_CONTROL::Undo(), FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), SCH_EDITOR_CONTROL::UpdatePCB(), EE_POINT_EDITOR::updatePoints(), LIB_ID_VALIDATOR::Validate(), and GERBER_JOBFILE_WRITER::WriteJSONJobFile().

◆ sort_by_libid()

static bool sort_by_libid ( const SCH_COMPONENT ref,
SCH_COMPONENT cmp 
)
static

Definition at line 377 of file sch_component.cpp.

378 {
379  if( ref->GetLibId() == cmp->GetLibId() )
380  {
381  if( ref->GetUnit() == cmp->GetUnit() )
382  return ref->GetConvert() < cmp->GetConvert();
383 
384  return ref->GetUnit() < cmp->GetUnit();
385  }
386 
387  return ref->GetLibId() < cmp->GetLibId();
388 }
int GetUnit() const
int GetConvert() const
const LIB_ID & GetLibId() const

References SCH_COMPONENT::GetConvert(), SCH_COMPONENT::GetLibId(), and SCH_COMPONENT::GetUnit().

Referenced by SCH_COMPONENT::ResolveAll().

◆ toUTFTildaText()

std::string toUTFTildaText ( const wxString &  txt)

Function toUTFTildaText convert a wxString to UTF8 and replace any control characters with a ~, where a control character is one of the first ASCII values up to ' ' 32d.

Definition at line 64 of file sch_component.cpp.

65 {
66  std::string ret = TO_UTF8( txt );
67 
68  for( std::string::iterator it = ret.begin(); it!=ret.end(); ++it )
69  {
70  if( (unsigned char) *it <= ' ' )
71  *it = '~';
72  }
73  return ret;
74 }
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48

References TO_UTF8.

Referenced by SCH_LEGACY_PLUGIN::saveComponent().