KiCad PCB EDA Suite
sch_component.cpp File Reference

Implementation of the class SCH_COMPONENT. More...

#include <fctsys.h>
#include <pgm_base.h>
#include <class_drawpanel.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_draw_item.h>
#include <symbol_lib_table.h>
#include <dialogs/dialog_schematic_find.h>
#include <wx/tokenzr.h>
#include <iostream>
#include <eeschema_id.h>
#include <trace_helpers.h>

Go to the source code of this file.

Macros

#define NULL_STRING   "_NONAME_"
 
#define ROTATE_VALUES_COUNT   12
 

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 when a LIB_PART is not found in library to draw a dummy shape 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. More...
 
static bool sort_by_libid (const SCH_COMPONENT *ref, SCH_COMPONENT *cmp)
 

Detailed Description

Implementation of the class SCH_COMPONENT.

Definition in file sch_component.cpp.

Macro Definition Documentation

#define NULL_STRING   "_NONAME_"

Definition at line 62 of file sch_component.cpp.

#define ROTATE_VALUES_COUNT   12

Function Documentation

static LIB_PART* dummy ( )
static

Used when a LIB_PART is not found in library to draw a dummy shape 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 95 of file sch_component.cpp.

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

Referenced by SCH_EDIT_FRAME::AskToSaveChanges(), TWO_COLUMN_TREE_LIST::AutosizeColumns(), DIALOG_EXCHANGE_FOOTPRINTS::change_1_Module(), PCB_EDIT_FRAME::Clean_Pcb(), SHAPE::Collide(), PNS::ITEM::Collide(), GERBER_WRITER::createDrillFile(), EXCELLON_WRITER::createDrillFile(), PNS_PCBNEW_RULE_RESOLVER::DpCoupledNet(), SCH_COMPONENT::Draw(), DrawGraphicText(), SCH_PRINTOUT::DrawPage(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), PCB_EDIT_FRAME::Edit_Zone_Params(), GERBER_FILE_IMAGE::Execute_G_Command(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), GENDRILL_WRITER_BASE::genDrillMapFile(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), PL_EDITOR_FRAME::GetAuxOrigin(), SCH_COMPONENT::GetBodyBoundingBox(), SCHLIB_FILTER::GetLibSource(), SCH_COMPONENT::GetMsgPanelInfo(), LIB_PART::GetName(), NETINFO_ITEM::GetPosition(), X2_ATTRIBUTE::GetPrm(), DRAWSEGMENT::HitTest(), 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(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnCheckGithubList(), WIZARD_FPLIB_TABLE::OnCheckGithubList(), PNS::SHOVE::onCollidingSolid(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_EXPORT_STEP::onExportButton(), PCB_EDIT_FRAME::OnExportIDF3(), PCB_EDIT_FRAME::OnExportVRML(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnOkClick(), FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnSelectAll3Dlibs(), WIZARD_FPLIB_TABLE::OnSelectAllGH(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnSelectChipName(), DIALOG_DRC_CONTROL::OnStartdrcClick(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), DIALOG_PLOT::Plot(), HK_PROMPT_DIALOG::PromptForKey(), DIALOG_ERC::ReBuildMatrixPanel(), GERBVIEW_FRAME::ReCreateAuxiliaryToolbar(), PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar(), DESIGN_TREE_FRAME::ReCreateDesignTree(), PCB_EDIT_FRAME::ReCreateHToolbar(), PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar(), PCB_EDIT_FRAME::ReCreateOptToolbar(), PCB_EDIT_FRAME::ReCreateVToolbar(), C3D_RENDER_OGL_LEGACY::Redraw(), C3D_RENDER_RAYTRACING::Redraw(), GERBVIEW_FRAME::RedrawActiveWindow(), KIGFX::VIEW_CONTROLS::Reset(), WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize(), DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser(), SPICE_VALUE::SPICE_VALUE(), TREEPROJECTFILES::TREEPROJECTFILES(), PL_EDITOR_FRAME::UpdateStatusBar(), UNIT_BINDER::Valid(), DIALOG_NETLIST::verifyFootprints(), and GERBER_JOBFILE_WRITER::WriteJSONJobFile().

96 {
97  static LIB_PART* part;
98 
99  if( !part )
100  {
101  part = new LIB_PART( wxEmptyString );
102 
103  LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
104 
105  square->Move( wxPoint( -200, 200 ) );
106  square->SetEndPosition( wxPoint( 200, -200 ) );
107 
108  LIB_TEXT* text = new LIB_TEXT( part );
109 
110  text->SetTextSize( wxSize( 150, 150 ) );
111  text->SetText( wxString( wxT( "??" ) ) );
112 
113  part->AddDrawItem( square );
114  part->AddDrawItem( text );
115  }
116 
117  return part;
118 }
Define a symbol library graphical text item.
Definition: lib_text.h:44
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:212
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
Define a library symbol object.
void SetEndPosition(const wxPoint &aPosition)
Definition: lib_rectangle.h:67
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
void SetText(const wxString &aText) override
Sets the text item string to aText.
Definition: lib_text.cpp:343
static bool sort_by_libid ( const SCH_COMPONENT ref,
SCH_COMPONENT cmp 
)
static

Definition at line 354 of file sch_component.cpp.

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

Referenced by SCH_COMPONENT::ResolveAll(), and SCH_COMPONENT::UpdateAllPinCaches().

355 {
356  if( ref->GetLibId() == cmp->GetLibId() )
357  {
358  if( ref->GetUnit() == cmp->GetUnit() )
359  return ref->GetConvert() < cmp->GetConvert();
360 
361  return ref->GetUnit() < cmp->GetUnit();
362  }
363 
364  return ref->GetLibId() < cmp->GetLibId();
365 }
int GetConvert() const
int GetUnit() const
const LIB_ID & GetLibId() const
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 69 of file sch_component.cpp.

References TO_UTF8.

Referenced by SCH_LEGACY_PLUGIN::saveComponent().

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