KiCad PCB EDA Suite
sch_text.cpp File Reference

Code for handling schematic texts (texts, labels, hlabels and global labels). More...

#include <sch_symbol.h>
#include <sch_edit_frame.h>
#include <plotters/plotter.h>
#include <widgets/msgpanel.h>
#include <gal/stroke_font.h>
#include <bitmaps.h>
#include <string_utils.h>
#include <sch_text.h>
#include <schematic.h>
#include <settings/color_settings.h>
#include <sch_painter.h>
#include <default_values.h>
#include <wx/debug.h>
#include <wx/log.h>
#include <dialogs/html_message_box.h>
#include <project/project_file.h>
#include <project/net_settings.h>
#include <core/mirror.h>
#include <core/kicad_algo.h>
#include <trigo.h>
#include "sch_text_help_md.h"

Go to the source code of this file.

Functions

bool IncrementLabelMember (wxString &name, int aIncrement)
 
wxString getElectricalTypeLabel (PINSHEETLABEL_SHAPE aType)
 

Variables

static int TemplateIN_HN [] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 }
 
static int TemplateIN_HI [] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 }
 
static int TemplateIN_UP [] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 }
 
static int TemplateIN_BOTTOM [] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 }
 
static int TemplateOUT_HN [] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 }
 
static int TemplateOUT_HI [] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 }
 
static int TemplateOUT_UP [] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 }
 
static int TemplateOUT_BOTTOM [] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 }
 
static int TemplateUNSPC_HN [] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 }
 
static int TemplateUNSPC_HI [] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 }
 
static int TemplateUNSPC_UP [] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 }
 
static int TemplateUNSPC_BOTTOM [] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 }
 
static int TemplateBIDI_HN [] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }
 
static int TemplateBIDI_HI [] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }
 
static int TemplateBIDI_UP [] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }
 
static int TemplateBIDI_BOTTOM [] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }
 
static int Template3STATE_HN [] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }
 
static int Template3STATE_HI [] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }
 
static int Template3STATE_UP [] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }
 
static int Template3STATE_BOTTOM [] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }
 
static int * TemplateShape [5][4]
 

Detailed Description

Code for handling schematic texts (texts, labels, hlabels and global labels).

Definition in file sch_text.cpp.

Function Documentation

◆ getElectricalTypeLabel()

wxString getElectricalTypeLabel ( PINSHEETLABEL_SHAPE  aType)

Definition at line 576 of file sch_text.cpp.

577 {
578  switch( aType )
579  {
580  case PINSHEETLABEL_SHAPE::PS_INPUT: return _( "Input" );
581  case PINSHEETLABEL_SHAPE::PS_OUTPUT: return _( "Output" );
582  case PINSHEETLABEL_SHAPE::PS_BIDI: return _( "Bidirectional" );
583  case PINSHEETLABEL_SHAPE::PS_TRISTATE: return _( "Tri-State" );
584  case PINSHEETLABEL_SHAPE::PS_UNSPECIFIED: return _( "Passive" );
585  default: return wxT( "???" );
586  }
587 }
#define _(s)

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

Referenced by SCH_TEXT::GetMsgPanelInfo(), and SCH_TEXT::GetShownText().

◆ IncrementLabelMember()

bool IncrementLabelMember ( wxString &  name,
int  aIncrement 
)

Definition at line 55 of file sch_text.cpp.

56 {
57  if( name.IsEmpty() )
58  return true;
59 
60  wxString suffix;
61  wxString digits;
62  wxString outputFormat;
63  wxString outputNumber;
64  int ii = name.Len() - 1;
65  int dCount = 0;
66 
67  while( ii >= 0 && !wxIsdigit( name.GetChar( ii ) ) )
68  {
69  suffix = name.GetChar( ii ) + suffix;
70  ii--;
71  }
72 
73  while( ii >= 0 && wxIsdigit( name.GetChar( ii ) ) )
74  {
75  digits = name.GetChar( ii ) + digits;
76  ii--;
77  dCount++;
78  }
79 
80  if( digits.IsEmpty() )
81  return true;
82 
83  long number = 0;
84 
85  if( digits.ToLong( &number ) )
86  {
87  number += aIncrement;
88 
89  // Don't let result go below zero
90 
91  if( number > -1 )
92  {
93  name.Remove( ii + 1 );
94  //write out a format string with correct number of leading zeroes
95  outputFormat.Printf( wxT( "%%0%dd" ), dCount );
96  //write out the number using the format string
97  outputNumber.Printf( outputFormat, number );
98  name << outputNumber << suffix;
99  return true;
100  }
101  }
102 
103  return false;
104 }
const char * name
Definition: DXF_plotter.cpp:56

References name.

Referenced by SCH_TEXT::IncrementLabel(), and SYMBOL_EDITOR_PIN_TOOL::RepeatPin().

Variable Documentation

◆ Template3STATE_BOTTOM

int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }
static

Definition at line 135 of file sch_text.cpp.

◆ Template3STATE_HI

int Template3STATE_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }
static

Definition at line 133 of file sch_text.cpp.

◆ Template3STATE_HN

int Template3STATE_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }
static

Definition at line 132 of file sch_text.cpp.

◆ Template3STATE_UP

int Template3STATE_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }
static

Definition at line 134 of file sch_text.cpp.

◆ TemplateBIDI_BOTTOM

int TemplateBIDI_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }
static

Definition at line 130 of file sch_text.cpp.

◆ TemplateBIDI_HI

int TemplateBIDI_HI[] = { 5, 0, 0, 1, -1, 2, 0, 1, 1, 0, 0 }
static

Definition at line 128 of file sch_text.cpp.

◆ TemplateBIDI_HN

int TemplateBIDI_HN[] = { 5, 0, 0, -1, -1, -2, 0, -1, 1, 0, 0 }
static

Definition at line 127 of file sch_text.cpp.

◆ TemplateBIDI_UP

int TemplateBIDI_UP[] = { 5, 0, 0, -1, -1, 0, -2, 1, -1, 0, 0 }
static

Definition at line 129 of file sch_text.cpp.

◆ TemplateIN_BOTTOM

int TemplateIN_BOTTOM[] = { 6, 0, 0, 1, 1, 1, 2, -1, 2, -1, 1, 0, 0 }
static

Definition at line 115 of file sch_text.cpp.

◆ TemplateIN_HI

int TemplateIN_HI[] = { 6, 0, 0, 1, 1, 2, 1, 2, -1, 1, -1, 0, 0 }
static

Definition at line 113 of file sch_text.cpp.

◆ TemplateIN_HN

int TemplateIN_HN[] = { 6, 0, 0, -1, -1, -2, -1, -2, 1, -1, 1, 0, 0 }
static

Definition at line 112 of file sch_text.cpp.

◆ TemplateIN_UP

int TemplateIN_UP[] = { 6, 0, 0, 1, -1, 1, -2, -1, -2, -1, -1, 0, 0 }
static

Definition at line 114 of file sch_text.cpp.

◆ TemplateOUT_BOTTOM

int TemplateOUT_BOTTOM[] = { 6, 0, 2, 1, 1, 1, 0, -1, 0, -1, 1, 0, 2 }
static

Definition at line 120 of file sch_text.cpp.

◆ TemplateOUT_HI

int TemplateOUT_HI[] = { 6, 2, 0, 1, -1, 0, -1, 0, 1, 1, 1, 2, 0 }
static

Definition at line 118 of file sch_text.cpp.

◆ TemplateOUT_HN

int TemplateOUT_HN[] = { 6, -2, 0, -1, 1, 0, 1, 0, -1, -1, -1, -2, 0 }
static

Definition at line 117 of file sch_text.cpp.

◆ TemplateOUT_UP

int TemplateOUT_UP[] = { 6, 0, -2, 1, -1, 1, 0, -1, 0, -1, -1, 0, -2 }
static

Definition at line 119 of file sch_text.cpp.

◆ TemplateShape

int* TemplateShape[5][4]
static
Initial value:
=
{
}
static int Template3STATE_HN[]
Definition: sch_text.cpp:132
static int TemplateUNSPC_HN[]
Definition: sch_text.cpp:122
static int Template3STATE_HI[]
Definition: sch_text.cpp:133
static int TemplateUNSPC_HI[]
Definition: sch_text.cpp:123
static int TemplateOUT_UP[]
Definition: sch_text.cpp:119
static int TemplateOUT_HN[]
Definition: sch_text.cpp:117
static int TemplateUNSPC_UP[]
Definition: sch_text.cpp:124
static int TemplateIN_UP[]
Definition: sch_text.cpp:114
static int TemplateOUT_HI[]
Definition: sch_text.cpp:118
static int TemplateBIDI_HI[]
Definition: sch_text.cpp:128
static int Template3STATE_BOTTOM[]
Definition: sch_text.cpp:135
static int TemplateIN_BOTTOM[]
Definition: sch_text.cpp:115
static int TemplateOUT_BOTTOM[]
Definition: sch_text.cpp:120
static int TemplateIN_HI[]
Definition: sch_text.cpp:113
static int Template3STATE_UP[]
Definition: sch_text.cpp:134
static int TemplateBIDI_HN[]
Definition: sch_text.cpp:127
static int TemplateBIDI_BOTTOM[]
Definition: sch_text.cpp:130
static int TemplateBIDI_UP[]
Definition: sch_text.cpp:129
static int TemplateUNSPC_BOTTOM[]
Definition: sch_text.cpp:125
static int TemplateIN_HN[]
Definition: sch_text.cpp:112

Definition at line 137 of file sch_text.cpp.

Referenced by SCH_HIERLABEL::CreateGraphicShape().

◆ TemplateUNSPC_BOTTOM

int TemplateUNSPC_BOTTOM[] = { 5, 1, 0, 1, 2, -1, 2, -1, 0, 1, 0 }
static

Definition at line 125 of file sch_text.cpp.

◆ TemplateUNSPC_HI

int TemplateUNSPC_HI[] = { 5, 0, -1, 2, -1, 2, 1, 0, 1, 0, -1 }
static

Definition at line 123 of file sch_text.cpp.

◆ TemplateUNSPC_HN

int TemplateUNSPC_HN[] = { 5, 0, -1, -2, -1, -2, 1, 0, 1, 0, -1 }
static

Definition at line 122 of file sch_text.cpp.

◆ TemplateUNSPC_UP

int TemplateUNSPC_UP[] = { 5, 1, 0, 1, -2, -1, -2, -1, 0, 1, 0 }
static

Definition at line 124 of file sch_text.cpp.