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 646 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 657 of file eagle_parser.h.

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

Constructor & Destructor Documentation

◆ ETEXT()

ETEXT::ETEXT ( wxXmlNode *  aText)

Definition at line 568 of file eagle_parser.cpp.

569 {
570  /*
571  <!ELEMENT text (#PCDATA)>
572  <!ATTLIST text
573  x %Coord; #REQUIRED
574  y %Coord; #REQUIRED
575  size %Dimension; #REQUIRED
576  layer %Layer; #REQUIRED
577  font %TextFont; "proportional"
578  ratio %Int; "8"
579  rot %Rotation; "R0"
580  align %Align; "bottom-left"
581  >
582  */
583 
584  text = aText->GetNodeContent();
585  x = parseRequiredAttribute<ECOORD>( aText, "x" );
586  y = parseRequiredAttribute<ECOORD>( aText, "y" );
587  size = parseRequiredAttribute<ECOORD>( aText, "size" );
588  layer = parseRequiredAttribute<int>( aText, "layer" );
589 
590  font = parseOptionalAttribute<wxString>( aText, "font" );
591  ratio = parseOptionalAttribute<double>( aText, "ratio" );
592  rot = parseOptionalAttribute<EROT>( aText, "rot" );
593 
594  opt_wxString stemp = parseOptionalAttribute<wxString>( aText, "align" );
595 
596  align = stemp ? parseAlignment( *stemp ) : DEFAULT_ALIGNMENT;
597 }
opt_double ratio
Definition: eagle_parser.h:654
ECOORD x
Definition: eagle_parser.h:649
ECOORD size
Definition: eagle_parser.h:651
wxString text
Definition: eagle_parser.h:648
opt_int align
Definition: eagle_parser.h:671
static int parseAlignment(const wxString &aAlignment)
opt_erot rot
Definition: eagle_parser.h:655
opt_wxString font
Definition: eagle_parser.h:653
constexpr auto DEFAULT_ALIGNMENT
ECOORD y
Definition: eagle_parser.h:650
int layer
Definition: eagle_parser.h:652

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 600 of file eagle_parser.cpp.

601 {
602  wxSize textsize;
603 
604  if( font )
605  {
606  const wxString& fontName = font.CGet();
607 
608  if( fontName == "vector" )
609  {
610  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
611  }
612  else if( fontName == "fixed" )
613  {
614  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() * 0.80 );
615  }
616  else
617  {
618  wxLogDebug( "Invalid font name \"%s\"", fontName );
619  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
620  }
621  }
622  else
623  {
624  textsize = wxSize( size.ToSchUnits() * 0.85, size.ToSchUnits() );
625  }
626 
627  return textsize;
628 }
int ToSchUnits() const
Definition: eagle_parser.h:438
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:651
opt_wxString font
Definition: eagle_parser.h:653

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 653 of file eagle_parser.h.

Referenced by ConvertSize(), and ETEXT().

◆ layer

int ETEXT::layer

Definition at line 652 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 648 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: