KiCad PCB EDA Suite
sch_symbol.cpp File Reference
#include <sch_edit_frame.h>
#include <widgets/msgpanel.h>
#include <bitmaps.h>
#include <core/mirror.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <lib_shape.h>
#include <sch_symbol.h>
#include <sch_sheet_path.h>
#include <schematic.h>
#include <trace_helpers.h>
#include <trigo.h>
#include <refdes_utils.h>
#include <wx/log.h>
#include <string_utils.h>
#include "plotters/plotter.h"

Go to the source code of this file.

Functions

std::string toUTFTildaText (const wxString &txt)
 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_SYMBOLdummy ()
 Used to draw a dummy shape when a LIB_SYMBOL is not found in library. More...
 

Function Documentation

◆ dummy()

static LIB_SYMBOL * dummy ( )
static

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

This symbol 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 74 of file sch_symbol.cpp.

75{
76 static LIB_SYMBOL* symbol;
77
78 if( !symbol )
79 {
80 symbol = new LIB_SYMBOL( wxEmptyString );
81
82 LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECT );
83
84 square->MoveTo( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
85 square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
86
87 LIB_TEXT* text = new LIB_TEXT( symbol );
88
89 text->SetTextSize( wxSize( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
90 text->SetText( wxString( wxT( "??" ) ) );
91
92 symbol->AddDrawItem( square );
93 symbol->AddDrawItem( text );
94 }
95
96 return symbol;
97}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
double square(double x)
Define a library symbol object.
Definition: lib_symbol.h:98
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:816
Define a symbol library graphical text item.
Definition: lib_text.h:40
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References LIB_SYMBOL::AddDrawItem(), EDA_IU_SCALE::MilsToIU(), RECT, schIUScale, square(), and text.

Referenced by SCH_EDITOR_CONTROL::Annotate(), APPEARANCE_CONTROLS::ApplyLayerPreset(), APPEARANCE_CONTROLS::ApplyViewport(), BOOST_FIXTURE_TEST_CASE(), DIALOG_TEMPLATE_SELECTOR::buildPageContent(), EXCELLON_WRITER::createDrillFile(), GERBER_WRITER::createDrillFile(), BOARD_ADAPTER::createPadWithMargin(), ROUTER_TOOL::CustomTrackWidthDialog(), DIALOG_IMPORT_GFX::DIALOG_IMPORT_GFX(), SCH_EDIT_FRAME::DisplayCurrentSheet(), PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), SCH_SYMBOL::doGetBoundingBox(), NETLIST_EXPORTER_SPICE::DoWriteNetlist(), COMMON_TOOLS::doZoomToPreset(), KIGFX::SCH_PAINTER::draw(), EDA_DRAW_FRAME::EDA_DRAW_FRAME(), PCB_EDIT_FRAME::Edit_Zone_Params(), EVT_MENU_RANGE(), GERBER_FILE_IMAGE::ExecuteRS274XCommand(), SCH_EDIT_FRAME::FocusOnItem(), JSON_SETTINGS::FormatAsString(), GENDRILL_WRITER_BASE::genDrillMapFile(), BOARD_EDITOR_CONTROL::GenerateFabFiles(), RENDER_3D_OPENGL::generateViasAndPads(), GERBVIEW_FRAME::GERBVIEW_FRAME(), DS_DRAW_ITEM_PAGE::GetBoundingBox(), EESCHEMA_HELPERS::GetDefaultProject(), GetDefaultProject(), FP_TREE_MODEL_ADAPTER::getFootprints(), FOOTPRINT::GetFpPadsLocalBbox(), SYMBOL_LIBRARY_FILTER::GetLibSource(), SCH_SYMBOL::GetMsgPanelInfo(), NETINFO_ITEM::GetPosition(), X2_ATTRIBUTE::GetPrm(), highlightNet(), SCH_NAVIGATE_TOOL::HypertextCommand(), DIALOG_EXPORT_SVG::initDialog(), DIALOG_GENDRILL::InitDisplayParams(), BOARD_INSPECTION_TOOL::InspectClearance(), SHAPE_LINE_CHAIN::Intersects(), isCoupledDiffPairFunc(), DRC_ENGINE::IsNetADiffPair(), PCB_EDIT_FRAME::KiwayMailIn(), LoadBoard(), EXCELLON_IMAGE::LoadFile(), PROJECT_TREE::LoadIcons(), EESCHEMA_HELPERS::LoadSchematic(), PANEL_TRACK_WIDTH::LoadSettings(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), NewBoard(), DIALOG_PCM::OnApplyChangesClicked(), PANEL_E_SERIE::OnCalculateESeries(), DIALOG_SCH_FIND::OnCancel(), SYMBOL_VIEWER_FRAME::OnCharHook(), FOOTPRINT_VIEWER_FRAME::OnCharHook(), GRID_TRICKS::onCharHook(), DIALOG_DRC::OnClose(), DIALOG_FOOTPRINT_CHECKER::OnClose(), DIALOG_PCM::OnCloseWindow(), PNS::SHOVE::onCollidingSolid(), DIALOG_EXPORT_STEP::onExportButton(), PCB_EDIT_FRAME::OnExportIDF3(), PCB_EDIT_FRAME::OnExportVRML(), DIALOG_LIB_SYMBOL_PROPERTIES::OnFilterDClick(), COMMON_TOOLS::OnGridChanged(), DIALOG_SIM_MODEL< T >::onLibraryPathTextKillFocus(), DIALOG_ERC::OnLinkClicked(), DIALOG_CHANGE_SYMBOLS::onOkButtonClicked(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked(), SIM_PLOT_FRAME::onPlotChanged(), SIM_PLOT_FRAME::onPlotClosed(), PANEL_SELECTION_FILTER::onPopupSelection(), APPEARANCE_CONTROLS::onReadOnlySwatch(), DIALOG_DRC::OnRunDRCClick(), PCB_EDIT_FRAME::OnRunTeardropTool(), EDA_DRAW_FRAME::OnSelectGrid(), PANEL_PACKAGES_VIEW::OnShowAllVersionsClicked(), COMMON_CONTROL::OpenPreferences(), BM2CMP_FRAME::OpenProjectFiles(), PANEL_SETUP_BUSES::PANEL_SETUP_BUSES(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), CLI::EXPORT_PCB_DXF_COMMAND::Perform(), CLI::EXPORT_PCB_GERBER_COMMAND::Perform(), CLI::EXPORT_PCB_PDF_COMMAND::Perform(), CLI::EXPORT_PCB_POS_COMMAND::Perform(), CLI::EXPORT_PCB_STEP_COMMAND::Perform(), LENGTH_TUNER_TOOL::performTuning(), DIALOG_PLOT::Plot(), PlotStandardLayer(), SCH_SYMBOL::Print(), SCH_PRINTOUT::PrintPage(), PANEL_SETUP_PINMAP::reBuildMatrixPanel(), GERBVIEW_FRAME::ReCreateAuxiliaryToolbar(), PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar(), DIALOG_INSPECTOR::ReCreateDesignList(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), PCB_EDIT_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), EDA_3D_VIEWER_FRAME::ReCreateMainToolbar(), PCB_EDIT_FRAME::ReCreateOptToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateVToolbar(), PCB_EDIT_FRAME::ReCreateVToolbar(), PCB_CONTROL::Redo(), SIM_PLOT_FRAME::removePlot(), PL_EDITOR_FRAME::ReturnCoordOriginCorner(), SaveBoard(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), CLIPBOARD_IO::SaveSelection(), JSON_SETTINGS::SaveToFile(), NESTED_SETTINGS::SaveToFile(), FOOTPRINT_VIEWER_FRAME::selectNext(), FOOTPRINT_VIEWER_FRAME::selectPrev(), DS_DATA_ITEM_TEXT::SetConstrainedTextSize(), DIALOG_EDIT_SYMBOLS_LIBID::setLibIdByBrowser(), PANEL_PACKAGES_VIEW::setPackageDetails(), PANEL_PACKAGES_VIEW::SetPackageState(), SCINTILLA_TRICKS::setupStyles(), SCH_EDITOR_CONTROL::ShowCvpcb(), SCH_EDITOR_CONTROL::ShowPcbNew(), SPICE_VALUE::SPICE_VALUE(), BM2CMP_FRAME::ToggleAspectRatioLock(), SYMBOL_EDITOR_CONTROL::ToggleSymbolTree(), EDA_DRAW_FRAME::ToggleUserUnits(), DIALOG_DIELECTRIC_MATERIAL::TransferDataFromWindow(), PANEL_SETUP_BOARD_STACKUP::TransferDataFromWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataFromWindow(), DIALOG_IMPORT_GFX::TransferDataFromWindow(), DIALOG_MIGRATE_SETTINGS::TransferDataToWindow(), DIALOG_PAGES_SETTINGS::TransferDataToWindow(), DIALOG_DIELECTRIC_MATERIAL::TransferDataToWindow(), DIALOG_PRINT_PCBNEW::TransferDataToWindow(), PANEL_SETUP_RULES::TransferDataToWindow(), FOOTPRINT::TransformPadsToPolySet(), SCH_EDITOR_CONTROL::Undo(), PCB_CONTROL::Undo(), FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), SCH_EDITOR_CONTROL::UpdatePCB(), EE_POINT_EDITOR::updatePoints(), LIB_ID_VALIDATOR::Validate(), and GERBER_JOBFILE_WRITER::WriteJSONJobFile().

◆ toUTFTildaText()

std::string toUTFTildaText ( const wxString &  txt)

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 47 of file sch_symbol.cpp.

48{
49 std::string ret = TO_UTF8( txt );
50
51 for( std::string::iterator it = ret.begin(); it!=ret.end(); ++it )
52 {
53 if( (unsigned char) *it <= ' ' )
54 *it = '~';
55 }
56
57 return ret;
58}
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96

References TO_UTF8.

Referenced by SCH_LEGACY_PLUGIN::saveSymbol(), and SCH_SEXPR_PLUGIN::saveSymbol().