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 <pgm_base.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 <settings/settings_manager.h>
#include <string_utils.h>
#include <utility>
#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 81 of file sch_symbol.cpp.

82{
83 static LIB_SYMBOL* symbol;
84
85 if( !symbol )
86 {
87 symbol = new LIB_SYMBOL( wxEmptyString );
88
89 LIB_SHAPE* square = new LIB_SHAPE( symbol, SHAPE_T::RECT );
90
91 square->MoveTo( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
92 square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
93
94 LIB_TEXT* text = new LIB_TEXT( symbol );
95
96 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
97 text->SetText( wxString( wxT( "??" ) ) );
98
99 symbol->AddDrawItem( square );
100 symbol->AddDrawItem( text );
101 }
102
103 return symbol;
104}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
double square(double x)
Define a library symbol object.
Definition: lib_symbol.h:99
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:820
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:590

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

Referenced by SCH_SYMBOL::doGetBoundingBox(), SCH_SYMBOL::GetMsgPanelInfo(), and SCH_SYMBOL::Print().

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

55{
56 std::string ret = TO_UTF8( txt );
57
58 for( std::string::iterator it = ret.begin(); it!=ret.end(); ++it )
59 {
60 if( (unsigned char) *it <= ' ' )
61 *it = '~';
62 }
63
64 return ret;
65}
#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().