KiCad PCB EDA Suite
ETEXT Struct Reference

Eagle text element. More...

#include <eagle_parser.h>

Public Types

enum  {
  CENTER, CENTER_LEFT, TOP_CENTER, TOP_LEFT,
  TOP_RIGHT, CENTER_RIGHT = -CENTER_LEFT, BOTTOM_CENTER = -TOP_CENTER, BOTTOM_LEFT = -TOP_RIGHT,
  BOTTOM_RIGHT = -TOP_LEFT
}
 

Public Member Functions

 ETEXT (wxXmlNode *aText)
 
wxSize ConvertSize () const
 Calculate text size based on font type and size. More...
 

Public Attributes

wxString text
 
ECOORD x
 
ECOORD y
 
ECOORD size
 
int layer
 
opt_wxString font
 
opt_double ratio
 
opt_erot rot
 
opt_int align
 

Detailed Description

Eagle text element.

Definition at line 645 of file eagle_parser.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
CENTER 
CENTER_LEFT 
TOP_CENTER 
TOP_LEFT 
TOP_RIGHT 
CENTER_RIGHT 
BOTTOM_CENTER 
BOTTOM_LEFT 
BOTTOM_RIGHT 

Definition at line 656 of file eagle_parser.h.

656  { // for align
657  CENTER,
658  CENTER_LEFT,
659  TOP_CENTER,
660  TOP_LEFT,
661  TOP_RIGHT,
662 
663  // opposites are -1 x above, used by code tricks in here
668  };

Constructor & Destructor Documentation

◆ ETEXT()

ETEXT::ETEXT ( wxXmlNode *  aText)

Definition at line 551 of file eagle_parser.cpp.

552 {
553  /*
554  <!ELEMENT text (#PCDATA)>
555  <!ATTLIST text
556  x %Coord; #REQUIRED
557  y %Coord; #REQUIRED
558  size %Dimension; #REQUIRED
559  layer %Layer; #REQUIRED
560  font %TextFont; "proportional"
561  ratio %Int; "8"
562  rot %Rotation; "R0"
563  align %Align; "bottom-left"
564  >
565  */
566 
567  text = aText->GetNodeContent();
568  x = parseRequiredAttribute<ECOORD>( aText, "x" );
569  y = parseRequiredAttribute<ECOORD>( aText, "y" );
570  size = parseRequiredAttribute<ECOORD>( aText, "size" );
571  layer = parseRequiredAttribute<int>( aText, "layer" );
572 
573  font = parseOptionalAttribute<wxString>( aText, "font" );
574  ratio = parseOptionalAttribute<double>( aText, "ratio" );
575  rot = parseOptionalAttribute<EROT>( aText, "rot" );
576 
577  opt_wxString stemp = parseOptionalAttribute<wxString>( aText, "align" );
578 
579  align = stemp ? parseAlignment( *stemp ) : DEFAULT_ALIGNMENT;
580 }
opt_double ratio
Definition: eagle_parser.h:653
ECOORD x
Definition: eagle_parser.h:648
ECOORD size
Definition: eagle_parser.h:650
wxString text
Definition: eagle_parser.h:647
opt_int align
Definition: eagle_parser.h:670
static int parseAlignment(const wxString &aAlignment)
opt_erot rot
Definition: eagle_parser.h:654
opt_wxString font
Definition: eagle_parser.h:652
constexpr auto DEFAULT_ALIGNMENT
ECOORD y
Definition: eagle_parser.h:649
int layer
Definition: eagle_parser.h:651

References align, DEFAULT_ALIGNMENT, font, layer, parseAlignment(), ratio, rot, size, text, x, and y.

Member Function Documentation

◆ ConvertSize()

wxSize ETEXT::ConvertSize ( ) const

Calculate text size based on font type and size.

Definition at line 583 of file eagle_parser.cpp.

584 {
585  wxSize textsize;
586 
587  if( font )
588  {
589  const wxString& fontName = font.CGet();
590 
591  if( fontName == "vector" )
592  {
593  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
594  }
595  else if( fontName == "fixed" )
596  {
597  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() * 0.80 );
598  }
599  else
600  {
601  wxLogDebug( "Invalid font name \"%s\"", fontName );
602  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
603  }
604  }
605  else
606  {
607  textsize = wxSize( size.ToSchUnits() * 0.85, size.ToSchUnits() );
608  }
609 
610  return textsize;
611 }
int ToSchUnits() const
Definition: eagle_parser.h:437
const T & CGet() const
Function CGet returns a constant reference to the value of the attribute assuming it is available.
Definition: eagle_parser.h:311
ECOORD size
Definition: eagle_parser.h:650
opt_wxString font
Definition: eagle_parser.h:652

References OPTIONAL_XML_ATTRIBUTE< T >::CGet(), font, size, and ECOORD::ToSchUnits().

Referenced by SCH_EAGLE_PLUGIN::loadTextAttributes().

Member Data Documentation

◆ align

◆ font

opt_wxString ETEXT::font

Definition at line 652 of file eagle_parser.h.

Referenced by ConvertSize(), and ETEXT().

◆ layer

int ETEXT::layer

Definition at line 651 of file eagle_parser.h.

Referenced by ETEXT(), EAGLE_PLUGIN::loadPlain(), and EAGLE_PLUGIN::packageText().

◆ ratio

◆ rot

◆ size

ECOORD ETEXT::size

◆ text

wxString ETEXT::text

Definition at line 647 of file eagle_parser.h.

Referenced by ETEXT(), EAGLE_PLUGIN::loadPlain(), and EAGLE_PLUGIN::packageText().

◆ x

◆ y


The documentation for this struct was generated from the following files: