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

string text
 
ECOORD x
 
ECOORD y
 
ECOORD size
 
int layer
 
opt_string font
 
opt_double ratio
 
opt_erot rot
 
opt_int align
 

Detailed Description

Eagle text element.

Definition at line 636 of file eagle_parser.h.

Member Enumeration Documentation

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

Definition at line 647 of file eagle_parser.h.

647  { // for align
648  CENTER,
649  CENTER_LEFT,
650  TOP_CENTER,
651  TOP_LEFT,
652  TOP_RIGHT,
653 
654  // opposites are -1 x above, used by code tricks in here
659  };

Constructor & Destructor Documentation

ETEXT::ETEXT ( wxXmlNode *  aText)

Definition at line 532 of file eagle_parser.cpp.

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

533 {
534  /*
535  <!ELEMENT text (#PCDATA)>
536  <!ATTLIST text
537  x %Coord; #REQUIRED
538  y %Coord; #REQUIRED
539  size %Dimension; #REQUIRED
540  layer %Layer; #REQUIRED
541  font %TextFont; "proportional"
542  ratio %Int; "8"
543  rot %Rotation; "R0"
544  align %Align; "bottom-left"
545  >
546  */
547 
548  text = aText->GetNodeContent();
549  x = parseRequiredAttribute<ECOORD>( aText, "x" );
550  y = parseRequiredAttribute<ECOORD>( aText, "y" );
551  size = parseRequiredAttribute<ECOORD>( aText, "size" );
552  layer = parseRequiredAttribute<int>( aText, "layer" );
553 
554  font = parseOptionalAttribute<string>( aText, "font" );
555  ratio = parseOptionalAttribute<double>( aText, "ratio" );
556  rot = parseOptionalAttribute<EROT>( aText, "rot" );
557 
558  opt_string stemp = parseOptionalAttribute<string>( aText, "align" );
559 
560  align = stemp ? parseAlignment( *stemp ) : DEFAULT_ALIGNMENT;
561 }
opt_double ratio
Definition: eagle_parser.h:644
string text
Definition: eagle_parser.h:638
ECOORD x
Definition: eagle_parser.h:639
ECOORD size
Definition: eagle_parser.h:641
opt_int align
Definition: eagle_parser.h:661
static int parseAlignment(const wxString &aAlignment)
opt_erot rot
Definition: eagle_parser.h:645
constexpr auto DEFAULT_ALIGNMENT
ECOORD y
Definition: eagle_parser.h:640
opt_string font
Definition: eagle_parser.h:643
int layer
Definition: eagle_parser.h:642

Member Function Documentation

wxSize ETEXT::ConvertSize ( ) const

Calculate text size based on font type and size.

Definition at line 564 of file eagle_parser.cpp.

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

Referenced by SCH_EAGLE_PLUGIN::loadTextAttributes().

565 {
566  wxSize textsize;
567 
568  if( font )
569  {
570  const wxString& fontName = font.CGet();
571 
572  if( fontName == "vector" )
573  {
574  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
575  }
576  else if( fontName == "fixed" )
577  {
578  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() * 0.80 );
579  }
580  else
581  {
582  wxASSERT( false );
583  textsize = wxSize( size.ToSchUnits(), size.ToSchUnits() );
584  }
585  }
586  else
587  {
588  textsize = wxSize( size.ToSchUnits() * 0.85, size.ToSchUnits() );
589  }
590 
591  return textsize;
592 }
ECOORD size
Definition: eagle_parser.h:641
const T & CGet() const
Function CGet returns a constant reference to the value of the attribute assuming it is available...
Definition: eagle_parser.h:303
opt_string font
Definition: eagle_parser.h:643
int ToSchUnits() const
Definition: eagle_parser.h:415

Member Data Documentation

opt_string ETEXT::font

Definition at line 643 of file eagle_parser.h.

Referenced by ConvertSize(), and ETEXT().

int ETEXT::layer

Definition at line 642 of file eagle_parser.h.

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

ECOORD ETEXT::size
string ETEXT::text

Definition at line 638 of file eagle_parser.h.

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


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