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 <class_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 <class_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>

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 60 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 93 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 SCH_EDIT_FRAME::AskToSaveChanges(), TWO_COLUMN_TREE_LIST::AutosizeColumns(), DIALOG_EXCHANGE_MODULE::change_1_Module(), PCB_EDIT_FRAME::Clean_Pcb(), SHAPE::Collide(), PNS::ITEM::Collide(), GERBER_WRITER::createDrillFile(), EXCELLON_WRITER::createDrillFile(), GERBER_JOBFILE_WRITER::CreateJobFile(), 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(), 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(), 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(), 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(), 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(), DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser(), SPICE_VALUE::SPICE_VALUE(), TREEPROJECTFILES::TREEPROJECTFILES(), PL_EDITOR_FRAME::UpdateStatusBar(), UNIT_BINDER::Valid(), and DIALOG_NETLIST::verifyFootprints().

94 {
95  static LIB_PART* part;
96 
97  if( !part )
98  {
99  part = new LIB_PART( wxEmptyString );
100 
101  LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
102 
103  square->Move( wxPoint( -200, 200 ) );
104  square->SetEndPosition( wxPoint( 200, -200 ) );
105 
106  LIB_TEXT* text = new LIB_TEXT( part );
107 
108  text->SetTextSize( wxSize( 150, 150 ) );
109  text->SetText( wxString( wxT( "??" ) ) );
110 
111  part->AddDrawItem( square );
112  part->AddDrawItem( text );
113  }
114 
115  return part;
116 }
Define a symbol library graphical text item.
Definition: lib_text.h:44
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.
Define a library symbol object.
void SetEndPosition(const wxPoint &aPosition)
Definition: lib_rectangle.h:62
void Move(const wxPoint &aPosition) override
Move 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:345
static bool sort_by_libid ( const SCH_COMPONENT ref,
SCH_COMPONENT cmp 
)
static

Definition at line 345 of file sch_component.cpp.

References SCH_COMPONENT::GetLibId().

Referenced by SCH_COMPONENT::ResolveAll().

346 {
347  return ref->GetLibId() < cmp->GetLibId();
348 }
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 67 of file sch_component.cpp.

References TO_UTF8.

Referenced by SCH_LEGACY_PLUGIN::saveComponent().

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