KiCad PCB EDA Suite
sch_sexpr_plugin.cpp File Reference
#include <algorithm>
#include <wx/base64.h>
#include <wx/log.h>
#include <wx/mstream.h>
#include <advanced_config.h>
#include <trace_helpers.h>
#include <locale_io.h>
#include <sch_bitmap.h>
#include <sch_bus_entry.h>
#include <sch_symbol.h>
#include <sch_edit_frame.h>
#include <sch_junction.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_text.h>
#include <sch_sheet.h>
#include <sch_sheet_pin.h>
#include <schematic.h>
#include <sch_plugins/kicad/sch_sexpr_plugin.h>
#include <sch_screen.h>
#include <symbol_library.h>
#include <lib_shape.h>
#include <lib_field.h>
#include <lib_pin.h>
#include <lib_text.h>
#include <eeschema_id.h>
#include <sch_file_versions.h>
#include <schematic_lexer.h>
#include <sch_plugins/kicad/sch_sexpr_parser.h>
#include <symbol_lib_table.h>
#include <ee_selection.h>
#include <string_utils.h>
#include <wx_filename.h>
#include <progress_reporter.h>

Go to the source code of this file.

Classes

class  SCH_SEXPR_PLUGIN_CACHE
 A cache assistant for the symbol library portion of the SCH_PLUGIN API, and only for the SCH_SEXPR_PLUGIN, so therefore is private to this implementation file, i.e. More...
 

Macros

#define wxUSE_BASE64   1
 
#define SCH_PARSE_ERROR(text, reader, pos)
 
#define MIME_BASE64_LENGTH   76
 

Functions

static void formatFill (OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
 Fill token formatting helper. More...
 
static const char * getPinElectricalTypeToken (ELECTRICAL_PINTYPE aType)
 
static const char * getPinShapeToken (GRAPHIC_PINSHAPE aShape)
 
static float getPinAngle (int aOrientation)
 
static const char * getSheetPinShapeToken (PINSHEETLABEL_SHAPE aShape)
 
static double getSheetPinAngle (SHEET_SIDE aSide)
 
static wxString getLineStyleToken (PLOT_DASH_TYPE aStyle)
 
static const char * getTextTypeToken (KICAD_T aType)
 
static void formatStroke (OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
 Write stroke definition to aFormatter. More...
 
static void formatArc (OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aArc, int x1, int x2, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, KIID aUuid=niluuid)
 
static void formatCircle (OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aCircle, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, KIID aUuid=niluuid)
 
static void formatRect (OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aRect, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, KIID aUuid=niluuid)
 
static void formatBezier (OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aBezier, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, KIID aUuid=niluuid)
 
static void formatPoly (OUTPUTFORMATTER *aFormatter, int aNestLevel, EDA_SHAPE *aPolyLine, const STROKE_PARAMS &aStroke, FILL_T aFillMode, const COLOR4D &aFillColor, KIID aUuid=niluuid)
 

Variables

static const char * emptyString = ""
 

Macro Definition Documentation

◆ MIME_BASE64_LENGTH

#define MIME_BASE64_LENGTH   76

◆ SCH_PARSE_ERROR

#define SCH_PARSE_ERROR (   text,
  reader,
  pos 
)
Value:
THROW_PARSE_ERROR( text, reader.GetSource(), reader.Line(), \
reader.LineNumber(), pos - reader.Line() )
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Definition: ki_exception.h:164

Definition at line 66 of file sch_sexpr_plugin.cpp.

◆ wxUSE_BASE64

#define wxUSE_BASE64   1

Definition at line 27 of file sch_sexpr_plugin.cpp.

Function Documentation

◆ formatArc()

static void formatArc ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
EDA_SHAPE aArc,
int  x1,
int  x2,
const STROKE_PARAMS aStroke,
FILL_T  aFillMode,
const COLOR4D aFillColor,
KIID  aUuid = niluuid 
)
static

Definition at line 282 of file sch_sexpr_plugin.cpp.

285 {
286  if( x1 > 1800 )
287  x1 -= 3600;
288 
289  if( x2 > 1800 )
290  x2 -= 3600;
291 
292  aFormatter->Print( aNestLevel, "(arc (start %s) (mid %s) (end %s)\n",
293  FormatInternalUnits( aArc->GetStart() ).c_str(),
294  FormatInternalUnits( aArc->GetArcMid() ).c_str(),
295  FormatInternalUnits( aArc->GetEnd() ).c_str() );
296 
297  formatStroke( aFormatter, aNestLevel + 1, aStroke );
298  aFormatter->Print( 0, "\n" );
299  formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor );
300  aFormatter->Print( 0, "\n" );
301 
302  if( aUuid != niluuid )
303  aFormatter->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aUuid.AsString() ) );
304 
305  aFormatter->Print( aNestLevel, ")\n" );
306 }
KIID niluuid(0)
static void formatFill(OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
wxString AsString() const
Definition: kiid.cpp:218
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
wxPoint GetArcMid() const
Definition: eda_shape.cpp:436
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References formatFill(), FormatInternalUnits(), formatStroke(), EDA_SHAPE::GetArcMid(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), niluuid, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem().

◆ formatBezier()

static void formatBezier ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
EDA_SHAPE aBezier,
const STROKE_PARAMS aStroke,
FILL_T  aFillMode,
const COLOR4D aFillColor,
KIID  aUuid = niluuid 
)
static

Definition at line 352 of file sch_sexpr_plugin.cpp.

355 {
356  aFormatter->Print( aNestLevel, "(bezier (pts " );
357 
358  for( const wxPoint& pt : { aBezier->GetStart(), aBezier->GetBezierC1(),
359  aBezier->GetBezierC2(), aBezier->GetEnd() } )
360  {
361  aFormatter->Print( 0, " (xy %s %s)",
362  FormatInternalUnits( pt.x ).c_str(),
363  FormatInternalUnits( pt.y ).c_str() );
364  }
365 
366  aFormatter->Print( 0, ")\n" ); // Closes pts token on same line.
367 
368  formatStroke( aFormatter, aNestLevel + 1, aStroke );
369  aFormatter->Print( 0, "\n" );
370  formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor );
371  aFormatter->Print( 0, "\n" );
372 
373  if( aUuid != niluuid )
374  aFormatter->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aUuid.AsString() ) );
375 
376  aFormatter->Print( aNestLevel, ")\n" );
377 }
KIID niluuid(0)
static void formatFill(OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
wxString AsString() const
Definition: kiid.cpp:218
const wxPoint & GetBezierC1() const
Definition: eda_shape.h:145
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
const wxPoint & GetBezierC2() const
Definition: eda_shape.h:148
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References formatFill(), FormatInternalUnits(), formatStroke(), EDA_SHAPE::GetBezierC1(), EDA_SHAPE::GetBezierC2(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), niluuid, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem().

◆ formatCircle()

static void formatCircle ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
EDA_SHAPE aCircle,
const STROKE_PARAMS aStroke,
FILL_T  aFillMode,
const COLOR4D aFillColor,
KIID  aUuid = niluuid 
)
static

Definition at line 309 of file sch_sexpr_plugin.cpp.

312 {
313  aFormatter->Print( aNestLevel, "(circle (center %s %s) (radius %s) (stroke (width %s)) ",
314  FormatInternalUnits( aCircle->GetStart().x ).c_str(),
315  FormatInternalUnits( aCircle->GetStart().y ).c_str(),
316  FormatInternalUnits( aCircle->GetRadius() ).c_str(),
317  FormatInternalUnits( aCircle->GetWidth() ).c_str() );
318 
319  formatStroke( aFormatter, aNestLevel + 1, aStroke );
320  aFormatter->Print( 0, "\n" );
321  formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor );
322  aFormatter->Print( 0, "\n" );
323 
324  if( aUuid != niluuid )
325  aFormatter->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aUuid.AsString() ) );
326 
327  aFormatter->Print( aNestLevel, ")\n" );
328 }
int GetWidth() const
Definition: eda_shape.h:89
KIID niluuid(0)
static void formatFill(OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
wxString AsString() const
Definition: kiid.cpp:218
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
int GetRadius() const
Definition: eda_shape.cpp:465
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References formatFill(), FormatInternalUnits(), formatStroke(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetStart(), EDA_SHAPE::GetWidth(), niluuid, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem().

◆ formatFill()

static void formatFill ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
FILL_T  aFillMode,
const COLOR4D aFillColor 
)
static

Fill token formatting helper.

Definition at line 76 of file sch_sexpr_plugin.cpp.

78 {
79  const char* fillType;
80 
81  switch( aFillMode )
82  {
83  default:
84  case FILL_T::NO_FILL: fillType = "none"; break;
85  case FILL_T::FILLED_SHAPE: fillType = "outline"; break;
86  case FILL_T::FILLED_WITH_BG_BODYCOLOR: fillType = "background"; break;
87  }
88 
89  aFormatter->Print( aNestLevel, "(fill (type %s))", fillType );
90 }
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426

References FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, NO_FILL, and OUTPUTFORMATTER::Print().

Referenced by formatArc(), formatBezier(), formatCircle(), formatPoly(), and formatRect().

◆ formatPoly()

static void formatPoly ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
EDA_SHAPE aPolyLine,
const STROKE_PARAMS aStroke,
FILL_T  aFillMode,
const COLOR4D aFillColor,
KIID  aUuid = niluuid 
)
static

Definition at line 380 of file sch_sexpr_plugin.cpp.

383 {
384  int newLine = 0;
385  int lineCount = 1;
386  aFormatter->Print( aNestLevel, "(polyline\n" );
387  aFormatter->Print( aNestLevel + 1, "(pts" );
388 
389  for( const VECTOR2I& pt : aPolyLine->GetPolyShape().Outline( 0 ).CPoints() )
390  {
391  if( newLine == 4 || !ADVANCED_CFG::GetCfg().m_CompactSave )
392  {
393  aFormatter->Print( 0, "\n" );
394  aFormatter->Print( aNestLevel + 2, "(xy %s %s)",
395  FormatInternalUnits( pt.x ).c_str(),
396  FormatInternalUnits( pt.y ).c_str() );
397  newLine = 0;
398  lineCount += 1;
399  }
400  else
401  {
402  aFormatter->Print( 0, " (xy %s %s)",
403  FormatInternalUnits( pt.x ).c_str(),
404  FormatInternalUnits( pt.y ).c_str() );
405  }
406 
407  newLine += 1;
408  }
409 
410  if( lineCount == 1 )
411  {
412  aFormatter->Print( 0, ")\n" ); // Closes pts token on same line.
413  }
414  else
415  {
416  aFormatter->Print( 0, "\n" );
417  aFormatter->Print( aNestLevel + 1, ")\n" ); // Closes pts token with multiple lines.
418  }
419 
420  formatStroke( aFormatter, aNestLevel + 1, aStroke );
421  aFormatter->Print( 0, "\n" );
422  formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor );
423  aFormatter->Print( 0, "\n" );
424 
425  if( aUuid != niluuid )
426  aFormatter->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aUuid.AsString() ) );
427 
428  aFormatter->Print( aNestLevel, ")\n" );
429 }
bool m_CompactSave
Save files in compact display mode When is is not specified, points are written one per line.
KIID niluuid(0)
static void formatFill(OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
wxString AsString() const
Definition: kiid.cpp:218
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:207
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References SHAPE_LINE_CHAIN::CPoints(), formatFill(), FormatInternalUnits(), formatStroke(), ADVANCED_CFG::GetCfg(), EDA_SHAPE::GetPolyShape(), ADVANCED_CFG::m_CompactSave, niluuid, SHAPE_POLY_SET::Outline(), OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem().

◆ formatRect()

static void formatRect ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
EDA_SHAPE aRect,
const STROKE_PARAMS aStroke,
FILL_T  aFillMode,
const COLOR4D aFillColor,
KIID  aUuid = niluuid 
)
static

Definition at line 331 of file sch_sexpr_plugin.cpp.

334 {
335  aFormatter->Print( aNestLevel, "(rectangle (start %s %s) (end %s %s)\n",
336  FormatInternalUnits( aRect->GetStart().x ).c_str(),
337  FormatInternalUnits( aRect->GetStart().y ).c_str(),
338  FormatInternalUnits( aRect->GetEnd().x ).c_str(),
339  FormatInternalUnits( aRect->GetEnd().y ).c_str() );
340  formatStroke( aFormatter, aNestLevel + 1, aStroke );
341  aFormatter->Print( 0, "\n" );
342  formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor );
343  aFormatter->Print( 0, "\n" );
344 
345  if( aUuid != niluuid )
346  aFormatter->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aUuid.AsString() ) );
347 
348  aFormatter->Print( aNestLevel, ")\n" );
349 }
KIID niluuid(0)
static void formatFill(OUTPUTFORMATTER *aFormatter, int aNestLevel, FILL_T aFillMode, const COLOR4D &aFillColor)
Fill token formatting helper.
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
wxString AsString() const
Definition: kiid.cpp:218
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
static void formatStroke(OUTPUTFORMATTER *aFormatter, int aNestLevel, const STROKE_PARAMS &aStroke)
Write stroke definition to aFormatter.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References formatFill(), FormatInternalUnits(), formatStroke(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), niluuid, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem().

◆ formatStroke()

static void formatStroke ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
const STROKE_PARAMS aStroke 
)
static

Write stroke definition to aFormatter.

This only writes the stroke definition if aWidth, aStyle and aColor are not the default setting or are not defined.

Parameters
aFormatterA pointer to the OUTPUTFORMATTER object to write to.
aNestLevelThe nest level to indent the stroke definition.
aWidthThe stroke line width in internal units.
aStyleThe stroke line style.
aColorThe stroke line color.

Definition at line 267 of file sch_sexpr_plugin.cpp.

269 {
270  wxASSERT( aFormatter != nullptr );
271 
272  aFormatter->Print( aNestLevel, "(stroke (width %s) (type %s) (color %d %d %d %s))",
273  FormatInternalUnits( aStroke.GetWidth() ).c_str(),
274  TO_UTF8( getLineStyleToken( aStroke.GetPlotStyle() ) ),
275  KiROUND( aStroke.GetColor().r * 255.0 ),
276  KiROUND( aStroke.GetColor().g * 255.0 ),
277  KiROUND( aStroke.GetColor().b * 255.0 ),
278  Double2Str( aStroke.GetColor().a ).c_str() );
279 }
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
double a
Alpha component.
Definition: color4d.h:380
static wxString getLineStyleToken(PLOT_DASH_TYPE aStyle)
PLOT_DASH_TYPE GetPlotStyle() const
Definition: sch_item.h:155
int GetWidth() const
Definition: sch_item.h:152
COLOR4D GetColor() const
Definition: sch_item.h:158
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
std::string Double2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
double r
Red component.
Definition: color4d.h:377
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:485

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, Double2Str(), FormatInternalUnits(), KIGFX::COLOR4D::g, STROKE_PARAMS::GetColor(), getLineStyleToken(), STROKE_PARAMS::GetPlotStyle(), STROKE_PARAMS::GetWidth(), KiROUND(), OUTPUTFORMATTER::Print(), KIGFX::COLOR4D::r, and TO_UTF8.

Referenced by formatArc(), formatBezier(), formatCircle(), formatPoly(), formatRect(), SCH_SEXPR_PLUGIN::saveBusEntry(), SCH_SEXPR_PLUGIN::saveLine(), and SCH_SEXPR_PLUGIN::saveSheet().

◆ getLineStyleToken()

static wxString getLineStyleToken ( PLOT_DASH_TYPE  aStyle)
static

Definition at line 225 of file sch_sexpr_plugin.cpp.

226 {
227  wxString token;
228 
229  switch( aStyle )
230  {
231  case PLOT_DASH_TYPE::DASH: token = "dash"; break;
232  case PLOT_DASH_TYPE::DOT: token = "dot"; break;
233  case PLOT_DASH_TYPE::DASHDOT: token = "dash_dot"; break;
234  case PLOT_DASH_TYPE::SOLID: token = "solid"; break;
235  case PLOT_DASH_TYPE::DEFAULT: token = "default"; break;
236  }
237 
238  return token;
239 }

References DASH, DASHDOT, DEFAULT, DOT, and SOLID.

Referenced by formatStroke().

◆ getPinAngle()

static float getPinAngle ( int  aOrientation)
static

Definition at line 180 of file sch_sexpr_plugin.cpp.

181 {
182  switch( aOrientation )
183  {
184  case PIN_RIGHT: return 0.0;
185  case PIN_LEFT: return 180.0;
186  case PIN_UP: return 90.0;
187  case PIN_DOWN: return 270.0;
188  default: wxFAIL_MSG( "Missing symbol library pin orientation type" ); return 0.0;
189  }
190 }
Definition: lib_pin.h:48

References PIN_DOWN, PIN_LEFT, PIN_RIGHT, and PIN_UP.

Referenced by SCH_SEXPR_PLUGIN_CACHE::savePin().

◆ getPinElectricalTypeToken()

static const char* getPinElectricalTypeToken ( ELECTRICAL_PINTYPE  aType)
static

Definition at line 93 of file sch_sexpr_plugin.cpp.

94 {
95  switch( aType )
96  {
98  return SCHEMATIC_LEXER::TokenName( T_input );
99 
101  return SCHEMATIC_LEXER::TokenName( T_output );
102 
104  return SCHEMATIC_LEXER::TokenName( T_bidirectional );
105 
107  return SCHEMATIC_LEXER::TokenName( T_tri_state );
108 
110  return SCHEMATIC_LEXER::TokenName( T_passive );
111 
113  return SCHEMATIC_LEXER::TokenName( T_free );
114 
116  return SCHEMATIC_LEXER::TokenName( T_unspecified );
117 
119  return SCHEMATIC_LEXER::TokenName( T_power_in );
120 
122  return SCHEMATIC_LEXER::TokenName( T_power_out );
123 
125  return SCHEMATIC_LEXER::TokenName( T_open_collector );
126 
128  return SCHEMATIC_LEXER::TokenName( T_open_emitter );
129 
131  return SCHEMATIC_LEXER::TokenName( T_no_connect );
132 
133  default:
134  wxFAIL_MSG( "Missing symbol library pin connection type" );
135  }
136 
137  return emptyString;
138 }
power input (GND, VCC for ICs). Must be connected to a power output.
pin for passive symbols: must be connected, and can be connected to any pin
unknown electrical properties: creates always a warning when connected
static const char * emptyString
not internally connected (may be connected to anything)
usual pin input: must be connected
input or output (like port for a microprocessor)
not connected (must be left open)
output of a regulator: intended to be connected to power input pins

References emptyString, PT_BIDI, PT_INPUT, PT_NC, PT_NIC, PT_OPENCOLLECTOR, PT_OPENEMITTER, PT_OUTPUT, PT_PASSIVE, PT_POWER_IN, PT_POWER_OUT, PT_TRISTATE, and PT_UNSPECIFIED.

Referenced by SCH_SEXPR_PLUGIN_CACHE::savePin().

◆ getPinShapeToken()

static const char* getPinShapeToken ( GRAPHIC_PINSHAPE  aShape)
static

Definition at line 141 of file sch_sexpr_plugin.cpp.

142 {
143  switch( aShape )
144  {
146  return SCHEMATIC_LEXER::TokenName( T_line );
147 
149  return SCHEMATIC_LEXER::TokenName( T_inverted );
150 
152  return SCHEMATIC_LEXER::TokenName( T_clock );
153 
155  return SCHEMATIC_LEXER::TokenName( T_inverted_clock );
156 
158  return SCHEMATIC_LEXER::TokenName( T_input_low );
159 
161  return SCHEMATIC_LEXER::TokenName( T_clock_low );
162 
164  return SCHEMATIC_LEXER::TokenName( T_output_low );
165 
167  return SCHEMATIC_LEXER::TokenName( T_edge_clock_high );
168 
170  return SCHEMATIC_LEXER::TokenName( T_non_logic );
171 
172  default:
173  wxFAIL_MSG( "Missing symbol library pin shape type" );
174  }
175 
176  return emptyString;
177 }
static const char * emptyString

References CLOCK, CLOCK_LOW, emptyString, FALLING_EDGE_CLOCK, INPUT_LOW, INVERTED, INVERTED_CLOCK, LINE, NONLOGIC, and OUTPUT_LOW.

Referenced by SCH_SEXPR_PLUGIN_CACHE::savePin().

◆ getSheetPinAngle()

static double getSheetPinAngle ( SHEET_SIDE  aSide)
static

Definition at line 207 of file sch_sexpr_plugin.cpp.

208 {
209  double retv;
210 
211  switch( aSide )
212  {
214  case SHEET_SIDE::LEFT: retv = 180.0; break;
215  case SHEET_SIDE::RIGHT: retv = 0.0; break;
216  case SHEET_SIDE::TOP: retv = 90.0; break;
217  case SHEET_SIDE::BOTTOM: retv = 270.0; break;
218  default: wxFAIL; retv = 0.0; break;
219  }
220 
221  return retv;
222 }

References BOTTOM, LEFT, RIGHT, TOP, and UNDEFINED.

Referenced by SCH_SEXPR_PLUGIN::saveSheet().

◆ getSheetPinShapeToken()

static const char* getSheetPinShapeToken ( PINSHEETLABEL_SHAPE  aShape)
static

Definition at line 193 of file sch_sexpr_plugin.cpp.

194 {
195  switch( aShape )
196  {
197  case PINSHEETLABEL_SHAPE::PS_INPUT: return SCHEMATIC_LEXER::TokenName( T_input );
198  case PINSHEETLABEL_SHAPE::PS_OUTPUT: return SCHEMATIC_LEXER::TokenName( T_output );
199  case PINSHEETLABEL_SHAPE::PS_BIDI: return SCHEMATIC_LEXER::TokenName( T_bidirectional );
200  case PINSHEETLABEL_SHAPE::PS_TRISTATE: return SCHEMATIC_LEXER::TokenName( T_tri_state );
201  case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: return SCHEMATIC_LEXER::TokenName( T_passive );
202  default: wxFAIL; return SCHEMATIC_LEXER::TokenName( T_passive );
203  }
204 }

References PS_BIDI, PS_INPUT, PS_OUTPUT, PS_TRISTATE, and PS_UNSPECIFIED.

Referenced by SCH_SEXPR_PLUGIN::saveSheet(), and SCH_SEXPR_PLUGIN::saveText().

◆ getTextTypeToken()

static const char* getTextTypeToken ( KICAD_T  aType)
static

Definition at line 242 of file sch_sexpr_plugin.cpp.

243 {
244  switch( aType )
245  {
246  case SCH_TEXT_T: return SCHEMATIC_LEXER::TokenName( T_text );
247  case SCH_LABEL_T: return SCHEMATIC_LEXER::TokenName( T_label );
248  case SCH_GLOBAL_LABEL_T: return SCHEMATIC_LEXER::TokenName( T_global_label );
249  case SCH_HIER_LABEL_T: return SCHEMATIC_LEXER::TokenName( T_hierarchical_label );
250  default: wxFAIL; return SCHEMATIC_LEXER::TokenName( T_text );
251  }
252 }

References SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, and SCH_TEXT_T.

Referenced by SCH_SEXPR_PLUGIN::saveText().

Variable Documentation

◆ emptyString

const char* emptyString = ""
static