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 <schframe.h>
#include <plot_common.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 <class_netlist_object.h>
#include <lib_draw_item.h>
#include <dialogs/dialog_schematic_find.h>
#include <wx/tokenzr.h>
#include <iostream>

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 58 of file sch_component.cpp.

Referenced by SCH_COMPONENT::Load(), and SCH_COMPONENT::Save().

#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 91 of file sch_component.cpp.

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

Referenced by TWO_COLUMN_TREE_LIST::AutosizeColumns(), DIALOG_EXCHANGE_MODULE::change_1_Module(), PCB_EDIT_FRAME::Clean_Pcb(), SHAPE::Collide(), PNS::ITEM::Collide(), EXCELLON_WRITER::createDrillFile(), PNS_PCBNEW_RULE_RESOLVER::DpCoupledNet(), SCH_COMPONENT::Draw(), DrawGraphicText(), SCH_PRINTOUT::DrawPage(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), GERBER_FILE_IMAGE::Execute_G_Command(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), PCB_EDIT_FRAME::Fill_Zone(), EXCELLON_WRITER::GenDrillMapFile(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), PL_EDITOR_FRAME::GetAuxOrigin(), SCH_COMPONENT::GetBodyBoundingBox(), SCHLIB_FILTER::GetLibSource(), NETINFO_ITEM::GetPosition(), X2_ATTRIBUTE::GetPrm(), ZONE_CONTAINER::HitTestForCorner(), ZONE_CONTAINER::HitTestForEdge(), DIALOG_PAGES_SETTINGS::initDialog(), SHAPE_LINE_CHAIN::Intersects(), SCH_EDIT_FRAME::KiwayMailIn(), EXCELLON_IMAGE::LoadFile(), CVPCB_MAINFRAME::LoadFootprintFiles(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnCheckGithubList(), WIZARD_FPLIB_TABLE::OnCheckGithubList(), PNS::SHOVE::onCollidingSolid(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), PCB_EDIT_FRAME::OnExportIDF3(), PCB_EDIT_FRAME::OnExportSTEP(), 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(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), 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(), GERBVIEW_FRAME::RedrawActiveWindow(), KIGFX::VIEW_CONTROLS::Reset(), WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize(), SPICE_VALUE::SPICE_VALUE(), TREEPROJECTFILES::TREEPROJECTFILES(), PL_EDITOR_FRAME::UpdateStatusBar(), WX_UNIT_BINDER::Valid(), and DIALOG_NETLIST::verifyFootprints().

92 {
93  static LIB_PART* part;
94 
95  if( !part )
96  {
97  part = new LIB_PART( wxEmptyString );
98 
99  LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
100 
101  square->Move( wxPoint( -200, 200 ) );
102  square->SetEndPosition( wxPoint( 200, -200 ) );
103 
104  LIB_TEXT* text = new LIB_TEXT( part );
105 
106  text->SetTextSize( wxSize( 150, 150 ) );
107  text->SetText( wxString( wxT( "??" ) ) );
108 
109  part->AddDrawItem( square );
110  part->AddDrawItem( text );
111  }
112 
113  return part;
114 }
Class LIB_TEXT defines a component library graphical text item.
Definition: lib_text.h:45
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
Class LIB_PART defines a library part object.
void SetEndPosition(const wxPoint &aPosition)
Definition: lib_rectangle.h:62
void Move(const wxPoint &aPosition) override
Function Move moves a draw object to aPosition.
static double square(int x)
Definition: trigo.cpp:138
void SetText(const wxString &aText) override
Sets the text item string to aText.
Definition: lib_text.cpp:488
static bool sort_by_libid ( const SCH_COMPONENT ref,
SCH_COMPONENT cmp 
)
static

Definition at line 292 of file sch_component.cpp.

References SCH_COMPONENT::GetLibId().

Referenced by SCH_COMPONENT::ResolveAll().

293 {
294  return ref->GetLibId() < cmp->GetLibId();
295 }
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 65 of file sch_component.cpp.

References TO_UTF8.

Referenced by SCH_COMPONENT::Save(), and SCH_LEGACY_PLUGIN::saveComponent().

66 {
67  std::string ret = TO_UTF8( txt );
68 
69  for( std::string::iterator it = ret.begin(); it!=ret.end(); ++it )
70  {
71  if( (unsigned char) *it <= ' ' )
72  *it = '~';
73  }
74  return ret;
75 }
#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