KiCad PCB EDA Suite
KIGFX::SCH_PAINTER Class Reference

Contains methods for drawing schematic-specific items. More...

#include <sch_painter.h>

Inheritance diagram for KIGFX::SCH_PAINTER:
KIGFX::PAINTER

Public Member Functions

 SCH_PAINTER (GAL *aGal)
 
virtual bool Draw (const VIEW_ITEM *, int) override
 Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item. More...
 
virtual SCH_RENDER_SETTINGSGetSettings () override
 Return a pointer to current settings that are going to be used when drawing items. More...
 
void SetSchematic (SCHEMATIC *aSchematic)
 
void SetGAL (GAL *aGal)
 Changes Graphics Abstraction Layer used for drawing items for a new one. More...
 

Protected Attributes

GALm_gal
 Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg. More...
 

Private Member Functions

void draw (const LIB_RECTANGLE *aRect, int aLayer)
 
void draw (LIB_PIN *aPin, int aLayer)
 
void draw (const LIB_CIRCLE *aCircle, int aLayer)
 
void draw (const LIB_SYMBOL *aSymbol, int, bool aDrawFields=true, int aUnit=0, int aConvert=0)
 
void draw (const LIB_ARC *aArc, int aLayer)
 
void draw (const LIB_POLYLINE *aLine, int aLayer)
 
void draw (const LIB_FIELD *aField, int aLayer)
 
void draw (const LIB_TEXT *aText, int aLayer)
 
void draw (const LIB_BEZIER *aCurve, int aLayer)
 
void draw (SCH_SYMBOL *aSymbol, int aLayer)
 
void draw (const SCH_JUNCTION *aJct, int aLayer)
 
void draw (const SCH_FIELD *aField, int aLayer)
 
void draw (const SCH_TEXT *aText, int aLayer)
 
void draw (SCH_HIERLABEL *aLabel, int aLayer)
 
void draw (SCH_GLOBALLABEL *aLabel, int aLayer)
 
void draw (const SCH_SHEET *aSheet, int aLayer)
 
void draw (const SCH_NO_CONNECT *aNC, int aLayer)
 
void draw (const SCH_MARKER *aMarker, int aLayer)
 
void draw (const SCH_BITMAP *aBitmap, int aLayer)
 
void draw (const SCH_LINE *aLine, int aLayer)
 
void draw (const SCH_BUS_ENTRY_BASE *aEntry, int aLayer)
 
void drawPinDanglingSymbol (const VECTOR2I &aPos, bool aDrawingShadows)
 
void drawDanglingSymbol (const wxPoint &aPos, int aWidth, bool aDrawingShadows)
 
int internalPinDecoSize (const LIB_PIN &aPin)
 
int externalPinDecoSize (const LIB_PIN &aPin)
 
bool isUnitAndConversionShown (const LIB_ITEM *aItem) const
 
float getShadowWidth () const
 
COLOR4D getRenderColor (const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
 
float getLineWidth (const LIB_ITEM *aItem, bool aDrawingShadows) const
 
float getLineWidth (const SCH_ITEM *aItem, bool aDrawingShadows) const
 
float getTextThickness (const SCH_TEXT *aItem, bool aDrawingShadows) const
 
float getTextThickness (const SCH_FIELD *aItem, bool aDrawingShadows) const
 
float getTextThickness (const LIB_FIELD *aItem, bool aDrawingShadows) const
 
float getTextThickness (const LIB_TEXT *aItem, bool aDrawingShadows) const
 
bool setDeviceColors (const LIB_ITEM *aItem, int aLayer)
 
void fillIfSelection (int aLayer)
 
void triLine (const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
 
void strokeText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 
void boxText (const wxString &aText, const VECTOR2D &aPosition, double aAngle)
 

Private Attributes

SCH_RENDER_SETTINGS m_schSettings
 
SCHEMATICm_schematic
 

Detailed Description

Contains methods for drawing schematic-specific items.

Definition at line 134 of file sch_painter.h.

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 162 of file sch_painter.cpp.

162  :
163  KIGFX::PAINTER( aGal ),
164  m_schematic( nullptr )
165 { }
SCHEMATIC * m_schematic
Definition: sch_painter.h:204
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:57

Member Function Documentation

◆ boxText()

void KIGFX::SCH_PAINTER::boxText ( const wxString &  aText,
const VECTOR2D aPosition,
double  aAngle 
)
private

Definition at line 424 of file sch_painter.cpp.

425 {
426  const STROKE_FONT& font = m_gal->GetStrokeFont();
427  VECTOR2D extents = font.ComputeStringBoundaryLimits( aText, m_gal->GetGlyphSize(),
428  m_gal->GetLineWidth() );
429  EDA_RECT box( (wxPoint) aPosition, wxSize( extents.x, extents.y ) );
430 
432  box.SetX( box.GetX() - ( box.GetWidth() / 2) );
434  box.SetX( box.GetX() - box.GetWidth() );
435 
437  box.SetY( box.GetY() - ( box.GetHeight() / 2) );
439  box.SetY( box.GetY() - box.GetHeight() );
440 
441  box.Normalize(); // Make h and v sizes always >= 0
442  box = box.GetBoundingBoxRotated((wxPoint) aPosition, RAD2DECIDEG( aAngle ) );
443  box.RevertYAxis();
444  m_gal->DrawRectangle( mapCoords( box.GetOrigin() ), mapCoords( box.GetEnd() ) );
445 }
const STROKE_FONT & GetStrokeFont() const
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
double RAD2DECIDEG(double rad)
Definition: trigo.h:234
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const
Return current text horizontal justification setting.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
const VECTOR2D & GetGlyphSize() const
static VECTOR2D mapCoords(const wxPoint &aCoord)
EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const
Returns current text vertical justification setting.
Handle the component boundary box.
Definition: eda_rect.h:42

References KIGFX::STROKE_FONT::ComputeStringBoundaryLimits(), KIGFX::GAL::DrawRectangle(), EDA_RECT::GetBoundingBoxRotated(), EDA_RECT::GetEnd(), KIGFX::GAL::GetGlyphSize(), EDA_RECT::GetHeight(), KIGFX::GAL::GetHorizontalJustify(), KIGFX::GAL::GetLineWidth(), EDA_RECT::GetOrigin(), KIGFX::GAL::GetStrokeFont(), KIGFX::GAL::GetVerticalJustify(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), EDA_RECT::Normalize(), RAD2DECIDEG(), EDA_RECT::RevertYAxis(), EDA_RECT::SetX(), EDA_RECT::SetY(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by draw().

◆ Draw()

bool KIGFX::SCH_PAINTER::Draw ( const VIEW_ITEM aItem,
int  aLayer 
)
overridevirtual

Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.

Parameters
aItemis an item to be drawn.
aLayertells which layer is currently rendered so that draw functions may know what to draw (eg. for pads there are separate layers for holes, because they have other dimensions then the pad itself.

Implements KIGFX::PAINTER.

Definition at line 172 of file sch_painter.cpp.

173 {
174  const auto item = dynamic_cast<const EDA_ITEM*>( aItem );
175 
176  if( !item )
177  return false;
178 
179 #ifdef CONNECTIVITY_DEBUG
180 
181  auto sch_item = dynamic_cast<const SCH_ITEM*>( item );
182  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
183 
184  if( conn )
185  {
186  auto pos = item->GetBoundingBox().Centre();
187  auto label = conn->Name( true );
188 
192  m_gal->SetLineWidth( Mils2ui( 2 ) );
193  m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
194  m_gal->StrokeText( conn->Name( true ), pos, 0.0, 0 );
195  }
196 
197 #endif
198 
200  {
201  BOX2I box = item->GetBoundingBox();
202 
203  if( item->Type() == SCH_SYMBOL_T )
204  box = static_cast<const SCH_SYMBOL*>( item )->GetBodyBoundingBox();
205 
206  m_gal->SetIsFill( false );
207  m_gal->SetIsStroke( true );
208  m_gal->SetStrokeColor( item->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
209  : COLOR4D( 0.2, 0.2, 0.2, 1 ) );
210  m_gal->SetLineWidth( Mils2iu( 3 ) );
211  m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
212  }
213 
214  switch( item->Type() )
215  {
240 
241  default: return false;
242  }
243 
244  return false;
245 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
const Vec GetEnd() const
Definition: box2.h:178
Define a symbol library graphical text item.
Definition: lib_text.h:39
Field object used in symbol libraries.
Definition: lib_field.h:59
Define a library symbol object.
Definition: lib_symbol.h:96
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:42
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a vector type text using preloaded Newstroke font.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:40
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool m_DrawBoundingBoxes
Draw GAL bounding boxes in painters.
Schematic symbol object.
Definition: sch_symbol.h:78
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
#define HANDLE_ITEM(type_id, type_name)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
const Vec & GetOrigin() const
Definition: box2.h:176
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Define a bezier curve graphic body item.
Definition: lib_bezier.h:34
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References KIGFX::GAL::DrawRectangle(), ADVANCED_CFG::GetCfg(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, HANDLE_ITEM, LIB_ARC_T, LIB_BEZIER_T, LIB_CIRCLE_T, LIB_FIELD_T, LIB_PIN_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, LIB_SYMBOL_T, LIB_TEXT_T, LIGHTRED, ADVANCED_CFG::m_DrawBoundingBoxes, KIGFX::PAINTER::m_gal, SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), and KIGFX::GAL::StrokeText().

Referenced by draw().

◆ draw() [1/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_RECTANGLE aRect,
int  aLayer 
)
private

Definition at line 548 of file sch_painter.cpp.

549 {
550  if( !isUnitAndConversionShown( aRect ) )
551  return;
552 
553  if( setDeviceColors( aRect, aLayer ) )
554  {
555  fillIfSelection( aLayer );
556  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
557  }
558 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
wxPoint GetEnd() const
Definition: lib_rectangle.h:82
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
void fillIfSelection(int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Definition: lib_rectangle.h:69

References KIGFX::GAL::DrawRectangle(), fillIfSelection(), LIB_RECTANGLE::GetEnd(), LIB_RECTANGLE::GetPosition(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), and setDeviceColors().

Referenced by draw().

◆ draw() [2/21]

void KIGFX::SCH_PAINTER::draw ( LIB_PIN aPin,
int  aLayer 
)
private

Definition at line 780 of file sch_painter.cpp.

781 {
782  if( !isUnitAndConversionShown( aPin ) )
783  return;
784 
785  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
786 #if 1
787  bool dangling = !m_schematic || aPin->HasFlag(IS_DANGLING );
788 #else
789  bool dangling = aPin->HasFlag( IS_DANGLING );
790 #endif
791 
792  if( drawingShadows && !aPin->IsSelected() )
793  return;
794 
795  VECTOR2I pos = mapCoords( aPin->GetPosition() );
796  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
797 
798  if( !aPin->IsVisible() )
799  {
801  {
802  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
803  }
804  else
805  {
806  if( dangling && aPin->IsPowerConnection() )
807  drawPinDanglingSymbol( pos, drawingShadows );
808 
809  return;
810  }
811  }
812 
813  VECTOR2I p0;
814  VECTOR2I dir;
815  int len = aPin->GetLength();
816  int orient = aPin->GetOrientation();
817 
818  switch( orient )
819  {
820  case PIN_UP:
821  p0 = VECTOR2I( pos.x, pos.y - len );
822  dir = VECTOR2I( 0, 1 );
823  break;
824 
825  case PIN_DOWN:
826  p0 = VECTOR2I( pos.x, pos.y + len );
827  dir = VECTOR2I( 0, -1 );
828  break;
829 
830  case PIN_LEFT:
831  p0 = VECTOR2I( pos.x - len, pos.y );
832  dir = VECTOR2I( 1, 0 );
833  break;
834 
835  default:
836  case PIN_RIGHT:
837  p0 = VECTOR2I( pos.x + len, pos.y );
838  dir = VECTOR2I( -1, 0 );
839  break;
840  }
841 
842  VECTOR2D pc;
843 
844  m_gal->SetIsStroke( true );
845  m_gal->SetIsFill( false );
846  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
848  m_gal->SetFontBold( false );
849  m_gal->SetFontUnderlined( false );
850  m_gal->SetFontItalic( false );
851 
852  const int radius = externalPinDecoSize( *aPin );
853  const int diam = radius*2;
854  const int clock_size = internalPinDecoSize( *aPin );
855 
856  if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
857  {
858  m_gal->DrawLine( p0, pos );
859 
860  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
861  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
862  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
863  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
864 
865  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
866  }
867  else
868  {
869  switch( aPin->GetShape() )
870  {
872  m_gal->DrawLine( p0, pos );
873  break;
874 
876  m_gal->DrawCircle( p0 + dir * radius, radius );
877  m_gal->DrawLine( p0 + dir * ( diam ), pos );
878  break;
879 
881  pc = p0 - dir * clock_size ;
882 
883  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
884  pc,
885  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
886 
887  m_gal->DrawCircle( p0 + dir * radius, radius );
888  m_gal->DrawLine( p0 + dir * ( diam ), pos );
889  break;
890 
893  pc = p0 - dir * clock_size ;
894 
895  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
896  pc,
897  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
898 
899  if( !dir.y )
900  {
901  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
902  p0 + VECTOR2D(dir.x, -1) * diam,
903  p0 );
904  }
905  else /* MapX1 = 0 */
906  {
907  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
908  p0 + VECTOR2D(-1, dir.y) * diam,
909  p0 );
910  }
911 
912  m_gal->DrawLine( p0, pos );
913  break;
914 
916  m_gal->DrawLine( p0, pos );
917 
918  if( !dir.y )
919  {
920  triLine( p0 + VECTOR2D( 0, clock_size ),
921  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
922  p0 + VECTOR2D( 0, -clock_size ) );
923  }
924  else
925  {
926  triLine( p0 + VECTOR2D( clock_size, 0 ),
927  p0 + VECTOR2D( 0, -dir.y * clock_size ),
928  p0 + VECTOR2D( -clock_size, 0 ) );
929  }
930  break;
931 
933  m_gal->DrawLine( p0, pos );
934 
935  if( !dir.y )
936  {
937  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
938  p0 + VECTOR2D(dir.x, -1) * diam,
939  p0 );
940  }
941  else /* MapX1 = 0 */
942  {
943  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
944  p0 + VECTOR2D(-1, dir.y) * diam,
945  p0 );
946  }
947  break;
948 
949  case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
950  m_gal->DrawLine( p0, pos );
951 
952  if( !dir.y ) // Horizontal pin
953  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
954  else // Vertical pin
955  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
956  break;
957 
958  case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
959  m_gal->DrawLine( p0, pos );
960 
961  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
962  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
963  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
964  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
965  break;
966  }
967  }
968 
969 
970  if( dangling )
971  drawPinDanglingSymbol( pos, drawingShadows );
972 
973  LIB_SYMBOL* libEntry = aPin->GetParent();
974 
975  // Draw the labels
976  if( drawingShadows
977  && ( libEntry->Type() == LIB_SYMBOL_T || libEntry->IsSelected() )
979  {
980  return;
981  }
982 
983  float penWidth = (float) m_schSettings.GetDefaultPenWidth();
984  int textOffset = libEntry->GetPinNameOffset();
985  float nameStrokeWidth = getLineWidth( aPin, drawingShadows );
986  float numStrokeWidth = getLineWidth( aPin, drawingShadows );
987 
988  nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), false );
989  numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), false );
990 
991  #define PIN_TEXT_MARGIN 4.0
992 
993  // Four locations around a pin where text can be drawn
994  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
995  int size[4] = { 0, 0, 0, 0 };
996  float thickness[4] = { numStrokeWidth, numStrokeWidth, numStrokeWidth, numStrokeWidth };
997  COLOR4D colour[4];
998  wxString text[4];
999 
1000  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
1001  if( textOffset )
1002  {
1003  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
1004  thickness[INSIDE] = nameStrokeWidth;
1005  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
1006  text [INSIDE] = aPin->GetShownName();
1007 
1008  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
1009  thickness[ABOVE] = numStrokeWidth;
1010  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
1011  text [ABOVE] = aPin->GetShownNumber();
1012  }
1013  // Otherwise pin NAMES go above and pin NUMBERS go below
1014  else
1015  {
1016  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
1017  thickness[ABOVE] = nameStrokeWidth;
1018  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
1019  text [ABOVE] = aPin->GetShownName();
1020 
1021  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
1022  thickness[BELOW] = numStrokeWidth;
1023  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
1024  text [BELOW] = aPin->GetShownNumber();
1025  }
1026 
1028  {
1029  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
1030  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
1031  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
1032  text [OUTSIDE] = aPin->GetElectricalTypeName();
1033  }
1034 
1035  if( !aPin->IsVisible() )
1036  {
1037  for( COLOR4D& c : colour )
1038  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
1039  }
1040 
1041  float insideOffset = textOffset - thickness[INSIDE] / 2.0;
1042  float outsideOffset = 2 * Mils2iu( PIN_TEXT_MARGIN ) - thickness[OUTSIDE] / 2.0;
1043  float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + penWidth ) / 2.0;
1044  float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[BELOW] + penWidth ) / 2.0;
1045 
1046  if( dangling )
1047  outsideOffset += TARGET_PIN_RADIUS / 2.0;
1048 
1049  if( drawingShadows )
1050  {
1051  float shadowWidth = getShadowWidth();
1052 
1053  if( eeconfig()->m_Selection.text_as_box )
1054  {
1055  insideOffset -= thickness[INSIDE] / 2.0;
1056  outsideOffset -= thickness[OUTSIDE] / 2.0;
1057  aboveOffset -= thickness[ABOVE] + penWidth;
1058  belowOffset -= thickness[BELOW] + penWidth;
1059  }
1060 
1061  for( float& t : thickness )
1062  t += shadowWidth;
1063 
1064  insideOffset -= shadowWidth / 2.0;
1065  outsideOffset -= shadowWidth / 2.0;
1066  }
1067 
1068  auto setupDC =
1069  [&]( int i )
1070  {
1071  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) );
1072  m_gal->SetIsStroke( !( drawingShadows && eeconfig()->m_Selection.text_as_box ) );
1073  m_gal->SetLineWidth( thickness[i] );
1074  m_gal->SetStrokeColor( colour[i] );
1075  m_gal->SetIsFill( drawingShadows && eeconfig()->m_Selection.text_as_box );
1076  m_gal->SetFillColor( colour[i] );
1077  };
1078 
1079  auto drawText =
1080  [&]( const wxString& aText, const VECTOR2D& aPos, double aAngle )
1081  {
1082  if( aText.IsEmpty() )
1083  return;
1084 
1085  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
1086  boxText( aText, aPos, aAngle );
1087  else
1088  strokeText( aText, aPos, aAngle );
1089  };
1090 
1091  switch( orient )
1092  {
1093  case PIN_LEFT:
1094  if( size[INSIDE] )
1095  {
1096  setupDC( INSIDE );
1099  drawText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
1100  }
1101  if( size[OUTSIDE] )
1102  {
1103  setupDC( OUTSIDE );
1106  drawText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
1107  }
1108  if( size[ABOVE] )
1109  {
1110  setupDC( ABOVE );
1113  drawText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
1114  }
1115  if( size[BELOW] )
1116  {
1117  setupDC( BELOW );
1120  drawText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
1121  }
1122  break;
1123 
1124  case PIN_RIGHT:
1125  if( size[INSIDE] )
1126  {
1127  setupDC( INSIDE );
1131  drawText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
1132  }
1133  if( size[OUTSIDE] )
1134  {
1135  setupDC( OUTSIDE );
1138  drawText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
1139  }
1140  if( size[ABOVE] )
1141  {
1142  setupDC( ABOVE );
1145  drawText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
1146  }
1147  if( size[BELOW] )
1148  {
1149  setupDC( BELOW );
1152  drawText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
1153  }
1154  break;
1155 
1156  case PIN_DOWN:
1157  if( size[INSIDE] )
1158  {
1159  setupDC( INSIDE );
1162  drawText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
1163  }
1164  if( size[OUTSIDE] )
1165  {
1166  setupDC( OUTSIDE );
1169  drawText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
1170  }
1171  if( size[ABOVE] )
1172  {
1173  setupDC( ABOVE );
1176  drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
1177  }
1178  if( size[BELOW] )
1179  {
1180  setupDC( BELOW );
1183  drawText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
1184  }
1185  break;
1186 
1187  case PIN_UP:
1188  if( size[INSIDE] )
1189  {
1190  setupDC( INSIDE );
1193  drawText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
1194  }
1195  if( size[OUTSIDE] )
1196  {
1197  setupDC( OUTSIDE );
1200  drawText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
1201  }
1202  if( size[ABOVE] )
1203  {
1204  setupDC( ABOVE );
1207  drawText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
1208  }
1209  if( size[BELOW] )
1210  {
1211  setupDC( BELOW );
1214  drawText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
1215  }
1216  break;
1217 
1218  default:
1219  wxFAIL_MSG( "Unknown pin orientation" );
1220  }
1221 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
SCHEMATIC * m_schematic
Definition: sch_painter.h:204
int GetPinNameOffset() const
Definition: lib_symbol.h:561
wxString GetShownNumber() const
Definition: lib_pin.h:117
bool IsSelected() const
Definition: eda_item.h:123
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
int GetOrientation() const
Definition: lib_pin.h:75
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:78
int color
Definition: DXF_plotter.cpp:57
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:156
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
void SetFontBold(bool aBold)
Set bold property of current font.
bool ShowPinNumbers() const
Definition: lib_symbol.h:577
Text appears outside the dimension line (default)
Definition: lib_pin.h:48
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
Define a library symbol object.
Definition: lib_symbol.h:96
float getShadowWidth() const
EESCHEMA_SETTINGS * eeconfig()
void boxText(const wxString &aText, const VECTOR2D &aPosition, double aAngle)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN.
Definition: lib_pin.h:186
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:67
#define IS_DANGLING
indicates a pin is dangling
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxString const GetElectricalTypeName() const
Definition: lib_pin.h:92
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
bool ShowPinNames() const
Definition: lib_symbol.h:569
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
bool IsVisible() const
Definition: lib_pin.h:97
int GetNameTextSize() const
Definition: lib_pin.h:126
wxString GetShownName() const
Definition: lib_pin.cpp:172
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
void SetFontItalic(bool aItalic)
Set italic property of current font.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
wxPoint GetPosition() const override
Definition: lib_pin.h:210
int externalPinDecoSize(const LIB_PIN &aPin)
ELECTRICAL_PINTYPE GetType() const
Definition: lib_pin.h:84
LIB_SYMBOL * GetParent() const
Definition: lib_item.h:159
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:129
void SetFontUnderlined(bool aUnderlined)
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int GetLength() const
Definition: lib_pin.h:81
int internalPinDecoSize(const LIB_PIN &aPin)
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:36
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
int GetDefaultPenWidth() const
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
not connected (must be left open)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define PIN_TEXT_MARGIN
static constexpr int Millimeter2iu(double mm)
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References boxText(), Clamp_Text_PenSize(), EDA_ITEM::ClearFlags(), CLOCK, CLOCK_LOW, color, EESCHEMA_SETTINGS::SELECTION::draw_selected_children, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), drawPinDanglingSymbol(), KIGFX::eeconfig(), externalPinDecoSize(), FALLING_EDGE_CLOCK, KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), LIB_PIN::GetElectricalTypeName(), LIB_PIN::GetLength(), getLineWidth(), LIB_PIN::GetNameTextSize(), LIB_PIN::GetNumberTextSize(), LIB_PIN::GetOrientation(), LIB_ITEM::GetParent(), LIB_SYMBOL::GetPinNameOffset(), LIB_PIN::GetPosition(), getRenderColor(), getShadowWidth(), LIB_PIN::GetShape(), LIB_PIN::GetShownName(), LIB_PIN::GetShownNumber(), LIB_PIN::GetType(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, EDA_ITEM::HasFlag(), INPUT_LOW, internalPinDecoSize(), INVERTED, INVERTED_CLOCK, IS_DANGLING, LIB_PIN::IsPowerConnection(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), LIB_PIN::IsVisible(), LAYER_HIDDEN, LAYER_NOTES, LAYER_PIN, LAYER_PINNAM, LAYER_PINNUM, LAYER_SELECTION_SHADOWS, LIB_SYMBOL_T, LINE, KIGFX::PAINTER::m_gal, m_schematic, m_schSettings, EESCHEMA_SETTINGS::m_Selection, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenPins, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, KIGFX::mapCoords(), Millimeter2iu(), NONLOGIC, OUTPUT_LOW, OUTSIDE, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_TEXT_MARGIN, PIN_UP, PT_NC, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), LIB_SYMBOL::ShowPinNames(), LIB_SYMBOL::ShowPinNumbers(), strokeText(), TARGET_PIN_RADIUS, text, EESCHEMA_SETTINGS::SELECTION::text_as_box, triLine(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [3/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_CIRCLE aCircle,
int  aLayer 
)
private

Definition at line 561 of file sch_painter.cpp.

562 {
563  if( !isUnitAndConversionShown( aCircle ) )
564  return;
565 
566  if( setDeviceColors( aCircle, aLayer ) )
567  {
568  fillIfSelection( aLayer );
569  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
570  }
571 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
wxPoint GetPosition() const override
Definition: lib_circle.h:66
void fillIfSelection(int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
int GetRadius() const
Definition: lib_circle.cpp:261
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.

References KIGFX::GAL::DrawCircle(), fillIfSelection(), LIB_CIRCLE::GetPosition(), LIB_CIRCLE::GetRadius(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), and setDeviceColors().

◆ draw() [4/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_SYMBOL aSymbol,
int  aLayer,
bool  aDrawFields = true,
int  aUnit = 0,
int  aConvert = 0 
)
private

Definition at line 455 of file sch_painter.cpp.

456 {
457  if( !aUnit )
458  aUnit = m_schSettings.m_ShowUnit;
459 
460  if( !aConvert )
461  aConvert = m_schSettings.m_ShowConvert;
462 
463  std::unique_ptr< LIB_SYMBOL > tmpSymbol;
464  const LIB_SYMBOL* drawnSymbol = aSymbol;
465 
466  if( aSymbol->IsAlias() )
467  {
468  tmpSymbol = aSymbol->Flatten();
469  drawnSymbol = tmpSymbol.get();
470  }
471 
472  for( const LIB_ITEM& item : drawnSymbol->GetDrawItems() )
473  {
474  if( !aDrawFields && item.Type() == LIB_FIELD_T )
475  continue;
476 
477  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
478  continue;
479 
480  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
481  continue;
482 
483  Draw( &item, aLayer );
484  }
485 }
virtual bool Draw(const VIEW_ITEM *, int) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
bool IsAlias() const
Definition: lib_symbol.h:172
Define a library symbol object.
Definition: lib_symbol.h:96
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:332
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:473
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References Draw(), LIB_SYMBOL::Flatten(), LIB_SYMBOL::GetDrawItems(), LIB_SYMBOL::IsAlias(), LIB_FIELD_T, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowConvert, and KIGFX::SCH_RENDER_SETTINGS::m_ShowUnit.

◆ draw() [5/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_ARC aArc,
int  aLayer 
)
private

This accounts for an oddity in the old library format, where the symbol is overdefined. The previous draw (based on wxwidgets) used start point and end point and always drew counter-clockwise. The new GAL draw takes center, radius and start/end angles. All of these points were stored in the file, so we need to mimic the swapping of start/end points rather than using the stored angles in order to properly map edge cases.

todo(v6): Remove this hack when we update the file format and do translation on loading.

Definition at line 574 of file sch_painter.cpp.

575 {
576  if( !isUnitAndConversionShown( aArc ) )
577  return;
578 
579  if( setDeviceColors( aArc, aLayer ) )
580  {
581  int sai = aArc->GetFirstRadiusAngle();
582  int eai = aArc->GetSecondRadiusAngle();
583 
594  if( !TRANSFORM().MapAngles( &sai, &eai ) )
595  {
596  LIB_ARC new_arc( *aArc );
597 
598  new_arc.SetStart( aArc->GetEnd() );
599  new_arc.SetEnd( aArc->GetStart() );
600  new_arc.CalcRadiusAngles();
601  sai = new_arc.GetFirstRadiusAngle();
602  eai = new_arc.GetSecondRadiusAngle();
603  TRANSFORM().MapAngles( &sai, &eai );
604  }
605 
606  double sa = (double) sai * M_PI / 1800.0;
607  double ea = (double) eai * M_PI / 1800.0 ;
608 
609  VECTOR2D pos = mapCoords( aArc->GetPosition() );
610 
611  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
612  }
613 }
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
int GetSecondRadiusAngle() const
Definition: lib_arc.h:90
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
wxPoint GetStart() const
Definition: lib_arc.h:92
static VECTOR2D mapCoords(const wxPoint &aCoord)
int GetRadius() const
Definition: lib_arc.h:84
wxPoint GetEnd() const
Definition: lib_arc.h:95
int GetFirstRadiusAngle() const
Definition: lib_arc.h:87
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:79
wxPoint GetPosition() const override
Definition: lib_arc.h:71

References LIB_ARC::CalcRadiusAngles(), KIGFX::GAL::DrawArc(), LIB_ARC::GetEnd(), LIB_ARC::GetFirstRadiusAngle(), LIB_ARC::GetPosition(), LIB_ARC::GetRadius(), LIB_ARC::GetSecondRadiusAngle(), LIB_ARC::GetStart(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, TRANSFORM::MapAngles(), KIGFX::mapCoords(), setDeviceColors(), LIB_ARC::SetEnd(), and LIB_ARC::SetStart().

◆ draw() [6/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_POLYLINE aLine,
int  aLayer 
)
private

Definition at line 616 of file sch_painter.cpp.

617 {
618  if( !isUnitAndConversionShown( aLine ) )
619  return;
620 
621  if( setDeviceColors( aLine, aLayer ) )
622  {
623  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
624  std::deque<VECTOR2D> vtx;
625 
626  for( auto p : pts )
627  vtx.push_back( mapCoords( p ) );
628 
629  fillIfSelection( aLayer );
630  m_gal->DrawPolygon( vtx );
631  }
632 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
void fillIfSelection(int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:54
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.

References KIGFX::GAL::DrawPolygon(), fillIfSelection(), LIB_POLYLINE::GetPolyPoints(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), and setDeviceColors().

◆ draw() [7/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_FIELD aField,
int  aLayer 
)
private

Definition at line 635 of file sch_painter.cpp.

636 {
637  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
638 
639  if( drawingShadows && !aField->IsSelected() )
640  return;
641 
642  if( !isUnitAndConversionShown( aField ) )
643  return;
644 
645  // Must check layer as fields are sometimes drawn by their parent rather than
646  // directly from the view.
647  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
648  int layers_count;
649  bool foundLayer = false;
650 
651  aField->ViewGetLayers( layers, layers_count );
652 
653  for( int i = 0; i < layers_count; ++i )
654  {
655  if( layers[i] == aLayer )
656  foundLayer = true;
657  }
658 
659  if( !foundLayer )
660  return;
661 
662  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
663 
664  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
665  {
667  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
668  else
669  return;
670  }
671 
672  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
673  m_gal->SetIsFill( false );
674  m_gal->SetIsStroke( true );
676 
677  EDA_RECT bbox = aField->GetBoundingBox();
678  wxPoint textpos = bbox.Centre();
679 
680  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
681  {
682  m_gal->SetIsFill( true );
684  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
685  bbox.RevertYAxis();
686 
687  m_gal->DrawRectangle( mapCoords( bbox.GetPosition() ), mapCoords( bbox.GetEnd() ) );
688  }
689  else
690  {
693  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
694  m_gal->SetFontItalic( aField->IsItalic() );
695 
696  strokeText( UnescapeString( aField->GetText() ), textpos, aField->GetTextAngleRadians() );
697  }
698 
699  // Draw the umbilical line
700  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
701  {
703  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
704  m_gal->DrawLine( textpos, wxPoint( 0, 0 ) );
705  }
706 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: eda_item.h:123
bool IsMoving() const
Definition: eda_item.h:120
int color
Definition: DXF_plotter.cpp:57
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows) const
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_field.cpp:311
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: eda_rect.h:198
EESCHEMA_SETTINGS * eeconfig()
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:726
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:180
const wxPoint GetEnd() const
Definition: eda_rect.h:103
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: lib_field.cpp:336
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual bool IsVisible() const
Definition: eda_text.h:186
const wxSize & GetTextSize() const
Definition: eda_text.h:238
const wxPoint GetPosition() const
Definition: eda_rect.h:102
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
void SetFontItalic(bool aItalic)
Set italic property of current font.
wxString UnescapeString(const wxString &aSource)
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
double GetTextAngleRadians() const
Definition: eda_text.h:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsForceVisible() const
Definition: eda_item.h:206
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint Centre() const
Definition: eda_rect.h:55
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References EDA_RECT::Centre(), color, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), KIGFX::eeconfig(), LIB_FIELD::GetBoundingBox(), EDA_RECT::GetEnd(), KIGFX::GAL::GetLineWidth(), EDA_RECT::GetPosition(), getRenderColor(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), getTextThickness(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_ITEM::IsForceVisible(), EDA_TEXT::IsItalic(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), EDA_TEXT::IsVisible(), LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::SCH_RENDER_SETTINGS::m_ShowUmbilicals, KIGFX::mapCoords(), EDA_RECT::RevertYAxis(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), strokeText(), UnescapeString(), KIGFX::VIEW::VIEW_MAX_LAYERS, and LIB_FIELD::ViewGetLayers().

◆ draw() [8/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_TEXT aText,
int  aLayer 
)
private

Definition at line 709 of file sch_painter.cpp.

710 {
711  if( !isUnitAndConversionShown( aText ) )
712  return;
713 
714  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
715 
716  if( drawingShadows && !aText->IsSelected() )
717  return;
718 
719  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
720 
721  if( !aText->IsVisible() )
722  {
724  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
725  else
726  return;
727  }
728 
729  EDA_RECT bBox = aText->GetBoundingBox();
730  bBox.RevertYAxis();
731  VECTOR2D pos = mapCoords( bBox.Centre() );
732  double orient = aText->GetTextAngleRadians();
733 
736  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
737  m_gal->SetIsFill( false );
738  m_gal->SetIsStroke( true );
740  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
741  m_gal->SetFontBold( aText->IsBold() );
742  m_gal->SetFontItalic( aText->IsItalic() );
743  m_gal->SetFontUnderlined( false );
744  strokeText( aText->GetText(), pos, orient );
745 }
bool IsBold() const
Definition: eda_text.h:183
bool IsSelected() const
Definition: eda_item.h:123
int color
Definition: DXF_plotter.cpp:57
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows) const
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
void SetFontBold(bool aBold)
Set bold property of current font.
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: eda_rect.h:198
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:180
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual bool IsVisible() const
Definition: eda_text.h:186
const wxSize & GetTextSize() const
Definition: eda_text.h:238
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
void SetFontItalic(bool aItalic)
Set italic property of current font.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
double GetTextAngleRadians() const
Definition: eda_text.h:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void SetFontUnderlined(bool aUnderlined)
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:355
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint Centre() const
Definition: eda_rect.h:55
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References EDA_RECT::Centre(), color, LIB_TEXT::GetBoundingBox(), getRenderColor(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), getTextThickness(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), EDA_TEXT::IsVisible(), LAYER_DEVICE, LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::mapCoords(), EDA_RECT::RevertYAxis(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), and strokeText().

◆ draw() [9/21]

void KIGFX::SCH_PAINTER::draw ( const LIB_BEZIER aCurve,
int  aLayer 
)
private

Definition at line 1224 of file sch_painter.cpp.

1225 {
1226  if( !isUnitAndConversionShown( aCurve ) )
1227  return;
1228 
1229  if( setDeviceColors( aCurve, aLayer ) )
1230  {
1231  BEZIER_POLY poly ( aCurve->GetPoints() );
1232  std::vector<wxPoint> pts;
1233  std::deque<VECTOR2D> pts_xformed;
1234  poly.GetPoly( pts );
1235 
1236  for( const wxPoint &p : pts )
1237  pts_xformed.push_back( mapCoords( p ) );
1238 
1239  m_gal->DrawPolygon( pts_xformed );
1240  }
1241 }
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Convert a Bezier curve to a polygon.
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:64
static VECTOR2D mapCoords(const wxPoint &aCoord)
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.

References KIGFX::GAL::DrawPolygon(), LIB_BEZIER::GetPoints(), BEZIER_POLY::GetPoly(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), and setDeviceColors().

◆ draw() [10/21]

void KIGFX::SCH_PAINTER::draw ( SCH_SYMBOL aSymbol,
int  aLayer 
)
private

Definition at line 1494 of file sch_painter.cpp.

1495 {
1496  int unit = aSymbol->GetUnitSelection( &m_schematic->CurrentSheet() );
1497  int convert = aSymbol->GetConvert();
1498 
1499  // Use dummy symbol if the actual couldn't be found (or couldn't be locked).
1500  LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ?
1501  aSymbol->GetLibSymbolRef().get() : dummy();
1502  LIB_PINS originalPins;
1503  originalSymbol->GetPins( originalPins, unit, convert );
1504 
1505  // Copy the source so we can re-orient and translate it.
1506  LIB_SYMBOL tempSymbol( *originalSymbol );
1507  LIB_PINS tempPins;
1508  tempSymbol.GetPins( tempPins, unit, convert );
1509 
1510  tempSymbol.SetFlags( aSymbol->GetFlags() );
1511 
1512  orientSymbol( &tempSymbol, aSymbol->GetOrientation() );
1513 
1514  for( auto& tempItem : tempSymbol.GetDrawItems() )
1515  {
1516  tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1517  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aSymbol->GetPosition() ) );
1518  }
1519 
1520  // Copy the pin info from the symbol to the temp pins
1521  for( unsigned i = 0; i < tempPins.size(); ++ i )
1522  {
1523  SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
1524  LIB_PIN* tempPin = tempPins[ i ];
1525 
1526  tempPin->ClearFlags();
1527  tempPin->SetFlags( symbolPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1528 
1529  tempPin->SetName( symbolPin->GetShownName() );
1530  tempPin->SetType( symbolPin->GetType() );
1531  tempPin->SetShape( symbolPin->GetShape() );
1532 
1533  if( symbolPin->IsDangling() )
1534  tempPin->SetFlags( IS_DANGLING );
1535  }
1536 
1537  draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() );
1538 
1539  // The fields are SCH_SYMBOL-specific so don't need to be copied/oriented/translated
1540  for( const SCH_FIELD& field : aSymbol->GetFields() )
1541  draw( &field, aLayer );
1542 }
void draw(const LIB_RECTANGLE *aRect, int aLayer)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
SCHEMATIC * m_schematic
Definition: sch_painter.h:204
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:693
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition: lib_pin.h:79
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:711
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
Define a library symbol object.
Definition: lib_symbol.h:96
bool IsDangling() const override
Definition: sch_pin.h:84
wxString GetShownName() const
Definition: sch_pin.cpp:90
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:164
void SetType(ELECTRICAL_PINTYPE aType)
Definition: lib_pin.h:85
#define IS_DANGLING
indicates a pin is dangling
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:531
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:122
static VECTOR2D mapCoords(const wxPoint &aCoord)
static LIB_SYMBOL * dummy()
Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:155
static void orientSymbol(LIB_SYMBOL *symbol, int orientation)
void SetName(const wxString &aName)
Definition: lib_pin.h:108
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
Definition: sch_symbol.cpp:840
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:113
wxPoint GetPosition() const override
Definition: sch_symbol.h:641
int GetOrientation()
Get the display symbol orientation.
int GetUnit() const
Definition: sch_symbol.h:195
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121
int GetConvert() const
Definition: sch_symbol.h:223

References EDA_ITEM::ClearFlags(), convert, SCHEMATIC::CurrentSheet(), draw(), KIGFX::dummy(), SCH_SYMBOL::GetConvert(), LIB_SYMBOL::GetDrawItems(), SCH_SYMBOL::GetFields(), EDA_ITEM::GetFlags(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SYMBOL::GetOrientation(), SCH_SYMBOL::GetPin(), LIB_SYMBOL::GetPins(), SCH_SYMBOL::GetPosition(), SCH_PIN::GetShape(), SCH_PIN::GetShownName(), SCH_PIN::GetType(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitSelection(), IS_DANGLING, SCH_PIN::IsDangling(), m_schematic, KIGFX::mapCoords(), KIGFX::orientSymbol(), EDA_ITEM::SetFlags(), LIB_PIN::SetName(), LIB_PIN::SetShape(), and LIB_PIN::SetType().

◆ draw() [11/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_JUNCTION aJct,
int  aLayer 
)
private

Definition at line 1260 of file sch_painter.cpp.

1261 {
1262  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1263 
1264  if( drawingShadows && !aJct->IsSelected() )
1265  return;
1266 
1267  COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows );
1268 
1269  int junctionSize = aJct->GetEffectiveDiameter() / 2;
1270 
1271  if( junctionSize > 1 )
1272  {
1273  m_gal->SetIsStroke( drawingShadows );
1274  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1276  m_gal->SetIsFill( !drawingShadows );
1277  m_gal->SetFillColor( color );
1278  m_gal->DrawCircle( aJct->GetPosition(), junctionSize );
1279  }
1280 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: eda_item.h:123
int color
Definition: DXF_plotter.cpp:57
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint GetPosition() const override
Definition: sch_junction.h:92
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:268
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
int GetEffectiveDiameter() const
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, KIGFX::GAL::DrawCircle(), SCH_JUNCTION::GetEffectiveDiameter(), SCH_ITEM::GetLayer(), getLineWidth(), SCH_JUNCTION::GetPosition(), getRenderColor(), EDA_ITEM::IsSelected(), LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [12/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_FIELD aField,
int  aLayer 
)
private

Definition at line 1545 of file sch_painter.cpp.

1546 {
1547  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1548 
1549  if( drawingShadows && !aField->IsSelected() )
1550  return;
1551 
1552  aLayer = aField->GetLayer();
1553 
1554  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1555 
1556  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
1557  {
1559  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1560  else
1561  return;
1562  }
1563 
1564  if( aField->IsVoid() )
1565  return;
1566 
1567  if( drawingShadows && aField->GetParent()->IsSelected()
1569  {
1570  return;
1571  }
1572 
1573  bool underline = false;
1574 
1575  if( aField->IsHypertext() && ( aField->GetFlags() & IS_ROLLOVER ) > 0
1576  && !drawingShadows && !aField->IsMoving() )
1577  {
1578  color = PUREBLUE;
1579  underline = true;
1580  }
1581 
1582  // Calculate the text orientation according to the parent orientation.
1583  int orient = (int) aField->GetTextAngle();
1584 
1585  if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
1586  {
1587  if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 )
1588  {
1589  // Rotate symbol 90 degrees.
1590  if( orient == TEXT_ANGLE_HORIZ )
1591  orient = TEXT_ANGLE_VERT;
1592  else
1593  orient = TEXT_ANGLE_HORIZ;
1594  }
1595  }
1596 
1597  /*
1598  * Calculate the text justification, according to the symbol orientation/mirror.
1599  * This is a bit complicated due to cumulative calculations:
1600  * - numerous cases (mirrored or not, rotation)
1601  * - the DrawGraphicText function recalculate also H and H justifications according to the
1602  * text orientation.
1603  * - when symbol is mirrored, the text is not mirrored and justifications are complicated
1604  * to calculate so the easier way is to use no justifications (centered text) and use
1605  * GetBoundingBox to know the text coordinate considered as centered
1606  */
1607  EDA_RECT bbox = aField->GetBoundingBox();
1608  wxPoint textpos = bbox.Centre();
1609 
1611  m_gal->SetIsStroke( true );
1612 
1613  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
1614  {
1615  m_gal->SetIsFill( true );
1616  m_gal->SetFillColor( color );
1617  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1618  bbox.RevertYAxis();
1619 
1620  m_gal->DrawRectangle( mapCoords( bbox.GetPosition() ), mapCoords( bbox.GetEnd() ) );
1621  }
1622  else
1623  {
1626  m_gal->SetIsFill( false );
1627  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1628  m_gal->SetFontBold( aField->IsBold() );
1629  m_gal->SetFontItalic( aField->IsItalic() );
1630  m_gal->SetFontUnderlined( underline );
1631  m_gal->SetTextMirrored( aField->IsMirrored() );
1632  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
1633 
1634  strokeText( aField->GetShownText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
1635  }
1636 
1637  // Draw the umbilical line
1638  if( aField->IsMoving() )
1639  {
1640  wxPoint parentPos = aField->GetParentPosition();
1641 
1643  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1644  m_gal->DrawLine( textpos, parentPos );
1645  }
1646 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:50
bool IsBold() const
Definition: eda_text.h:183
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsMirrored() const
Definition: eda_text.h:189
bool IsSelected() const
Definition: eda_item.h:123
bool IsMoving() const
Definition: eda_item.h:120
int color
Definition: DXF_plotter.cpp:57
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows) const
void SetFontBold(bool aBold)
Set bold property of current font.
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.h:89
double GetTextAngle() const
Definition: eda_text.h:174
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: eda_rect.h:198
EESCHEMA_SETTINGS * eeconfig()
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:105
bool IsVoid() const
Definition: sch_field.cpp:325
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:180
const wxPoint GetEnd() const
Definition: eda_rect.h:103
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual bool IsVisible() const
Definition: eda_text.h:186
const wxSize & GetTextSize() const
Definition: eda_text.h:238
const wxPoint GetPosition() const
Definition: eda_rect.h:102
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
void SetFontItalic(bool aItalic)
Set italic property of current font.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:155
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:268
void SetTextMirrored(bool aMirrored)
Set a mirrored property of text.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsForceVisible() const
Definition: eda_item.h:206
void SetFontUnderlined(bool aUnderlined)
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:266
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint Centre() const
Definition: eda_rect.h:55
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
#define TEXT_ANGLE_VERT
Definition: eda_text.h:51
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
wxPoint GetParentPosition() const
Definition: sch_field.cpp:725
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References EDA_RECT::Centre(), color, EESCHEMA_SETTINGS::SELECTION::draw_selected_children, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), KIGFX::eeconfig(), SCH_FIELD::GetBoundingBox(), EDA_RECT::GetEnd(), EDA_ITEM::GetFlags(), SCH_ITEM::GetLayer(), KIGFX::GAL::GetLineWidth(), EDA_ITEM::GetParent(), SCH_FIELD::GetParentPosition(), EDA_RECT::GetPosition(), getRenderColor(), SCH_FIELD::GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), getTextThickness(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, IS_ROLLOVER, EDA_TEXT::IsBold(), EDA_ITEM::IsForceVisible(), SCH_FIELD::IsHypertext(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), SCH_FIELD::IsVoid(), LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, EESCHEMA_SETTINGS::m_Selection, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::mapCoords(), PUREBLUE, EDA_RECT::RevertYAxis(), SCH_SYMBOL_T, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), strokeText(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, and EDA_ITEM::Type().

◆ draw() [13/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_TEXT aText,
int  aLayer 
)
private

Definition at line 1362 of file sch_painter.cpp.

1363 {
1364  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1365 
1366  if( drawingShadows && !aText->IsSelected() )
1367  return;
1368 
1369  switch( aText->Type() )
1370  {
1371  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1372  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1373  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1374  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1375  default: aLayer = LAYER_NOTES; break;
1376  }
1377 
1378  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1379 
1380  if( m_schematic )
1381  {
1382  SCH_CONNECTION* conn = aText->Connection();
1383 
1384  if( conn && conn->IsBus() )
1385  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1386  }
1387 
1388  if( !( aText->IsVisible() || aText->IsForceVisible() ) )
1389  {
1391  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1392  else
1393  return;
1394  }
1395 
1396  m_gal->SetIsFill( false );
1397  m_gal->SetIsStroke( true );
1398  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
1400  m_gal->SetTextAttributes( aText );
1401  m_gal->SetFontUnderlined( false );
1402 
1403  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset( &m_schSettings );
1404  wxString shownText( aText->GetShownText() );
1405 
1406  if( drawingShadows )
1407  {
1409  {
1410  EDA_RECT bBox = aText->GetBoundingBox();
1411 
1412  m_gal->SetIsFill( true );
1413  m_gal->SetFillColor( color );
1414  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1415  bBox.RevertYAxis();
1416 
1417  m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1418  return;
1419  }
1420 
1421  switch( aText->GetLabelSpinStyle() )
1422  {
1423  case LABEL_SPIN_STYLE::LEFT: text_offset.x += getShadowWidth() / 2; break;
1424  case LABEL_SPIN_STYLE::UP: text_offset.y += getShadowWidth() / 2; break;
1425  case LABEL_SPIN_STYLE::RIGHT: text_offset.x -= getShadowWidth() / 2; break;
1426  case LABEL_SPIN_STYLE::BOTTOM: text_offset.y -= getShadowWidth() / 2; break;
1427  }
1428  }
1429 
1430  if( !shownText.IsEmpty() )
1431  {
1432  strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1433  }
1434 
1435  if( aText->IsDangling() )
1436  {
1437  drawDanglingSymbol( aText->GetTextPos(), Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1438  drawingShadows );
1439  }
1440 
1441 }
bool IsDangling() const override
Definition: sch_text.h:230
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
SCHEMATIC * m_schematic
Definition: sch_painter.h:204
float GetLineWidth() const
Get the line width.
void drawDanglingSymbol(const wxPoint &aPos, int aWidth, bool aDrawingShadows)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: eda_item.h:123
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
int color
Definition: DXF_plotter.cpp:57
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows) const
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: eda_rect.h:198
float getShadowWidth() const
virtual wxPoint GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Definition: sch_text.cpp:247
EESCHEMA_SETTINGS * eeconfig()
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
const wxPoint GetEnd() const
Definition: eda_rect.h:103
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define DANGLING_SYMBOL_SIZE
< The size of the rectangle indicating an unconnected wire or label
virtual bool IsVisible() const
Definition: eda_text.h:186
const wxPoint GetPosition() const
Definition: eda_rect.h:102
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:159
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:550
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:595
double GetTextAngleRadians() const
Definition: eda_text.h:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsForceVisible() const
Definition: eda_item.h:206
void SetFontUnderlined(bool aUnderlined)
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Handle the component boundary box.
Definition: eda_rect.h:42
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References LABEL_SPIN_STYLE::BOTTOM, color, SCH_ITEM::Connection(), DANGLING_SYMBOL_SIZE, drawDanglingSymbol(), KIGFX::GAL::DrawRectangle(), KIGFX::eeconfig(), SCH_TEXT::GetBoundingBox(), EDA_RECT::GetEnd(), SCH_TEXT::GetLabelSpinStyle(), KIGFX::GAL::GetLineWidth(), EDA_RECT::GetPosition(), getRenderColor(), SCH_TEXT::GetSchematicTextOffset(), getShadowWidth(), SCH_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), getTextThickness(), SCH_CONNECTION::IsBus(), SCH_TEXT::IsDangling(), EDA_ITEM::IsForceVisible(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), LAYER_BUS, LAYER_GLOBLABEL, LAYER_HIDDEN, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, LAYER_SELECTION_SHADOWS, LAYER_SHEETLABEL, LABEL_SPIN_STYLE::LEFT, KIGFX::PAINTER::m_gal, m_schematic, m_schSettings, EESCHEMA_SETTINGS::m_Selection, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::mapCoords(), EDA_RECT::RevertYAxis(), LABEL_SPIN_STYLE::RIGHT, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), strokeText(), EESCHEMA_SETTINGS::SELECTION::text_as_box, EDA_ITEM::Type(), LABEL_SPIN_STYLE::UP, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [14/21]

void KIGFX::SCH_PAINTER::draw ( SCH_HIERLABEL aLabel,
int  aLayer 
)
private

Definition at line 1687 of file sch_painter.cpp.

1688 {
1689  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1690 
1691  if( drawingShadows && !aLabel->IsSelected() )
1692  return;
1693 
1694  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1695 
1696  if( m_schematic )
1697  {
1698  SCH_CONNECTION* conn = aLabel->Connection();
1699 
1700  if( conn && conn->IsBus() )
1701  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1702  }
1703 
1704  std::vector<wxPoint> pts;
1705  std::deque<VECTOR2D> pts2;
1706 
1707  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1708 
1709  for( const wxPoint& p : pts )
1710  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1711 
1712  m_gal->SetIsFill( true );
1714  m_gal->SetIsStroke( true );
1715  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1717  m_gal->DrawPolyline( pts2 );
1718 
1719  draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
1720 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void draw(const LIB_RECTANGLE *aRect, int aLayer)
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
SCHEMATIC * m_schematic
Definition: sch_painter.h:204
bool IsSelected() const
Definition: eda_item.h:123
int color
Definition: DXF_plotter.cpp:57
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows) const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1609
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, SCH_ITEM::Connection(), SCH_HIERLABEL::CreateGraphicShape(), draw(), KIGFX::GAL::DrawPolyline(), KIGFX::RENDER_SETTINGS::GetLayerColor(), getRenderColor(), EDA_TEXT::GetTextPos(), getTextThickness(), SCH_CONNECTION::IsBus(), EDA_ITEM::IsSelected(), LAYER_BUS, LAYER_SCHEMATIC_BACKGROUND, LAYER_SELECTION_SHADOWS, LAYER_SHEETLABEL, KIGFX::PAINTER::m_gal, m_schematic, m_schSettings, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [15/21]

void KIGFX::SCH_PAINTER::draw ( SCH_GLOBALLABEL aLabel,
int  aLayer 
)
private

Definition at line 1649 of file sch_painter.cpp.

1650 {
1651  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1652 
1653  if( !drawingShadows || aLabel->IsSelected() )
1654  {
1655  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1656 
1657  std::vector<wxPoint> pts;
1658  std::deque<VECTOR2D> pts2;
1659 
1660  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1661 
1662  for( const wxPoint& p : pts )
1663  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1664 
1665  // The text is drawn inside the graphic shape.
1666  // On Cairo the graphic shape is filled by the background before drawing the text.
1667  // However if the text is selected, it is draw twice: first on LAYER_SELECTION_SHADOWS
1668  // and second on the text layer. The second must not erase the first drawing.
1669  bool fillBg = ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected();
1670  m_gal->SetIsFill( fillBg );
1672  m_gal->SetIsStroke( true );
1673  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1675  m_gal->DrawPolyline( pts2 );
1676 
1677  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1678  }
1679 
1680  if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children || !aLabel->IsSelected() )
1681  {
1682  draw( aLabel->GetIntersheetRefs(), aLayer );
1683  }
1684 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void draw(const LIB_RECTANGLE *aRect, int aLayer)
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
bool IsSelected() const
Definition: eda_item.h:123
int color
Definition: DXF_plotter.cpp:57
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows) const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
EESCHEMA_SETTINGS * eeconfig()
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:413
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void CreateGraphicShape(const RENDER_SETTINGS *aRenderSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1328
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, SCH_GLOBALLABEL::CreateGraphicShape(), draw(), KIGFX::GAL::DrawPolyline(), KIGFX::eeconfig(), SCH_GLOBALLABEL::GetIntersheetRefs(), KIGFX::RENDER_SETTINGS::GetLayerColor(), getRenderColor(), EDA_TEXT::GetTextPos(), getTextThickness(), EDA_ITEM::IsSelected(), LAYER_GLOBLABEL, LAYER_SCHEMATIC_BACKGROUND, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [16/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_SHEET aSheet,
int  aLayer 
)
private

Definition at line 1723 of file sch_painter.cpp.

1724 {
1725  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1726 
1727  if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS )
1728  {
1729  for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
1730  {
1731  if( drawingShadows && !aSheet->IsSelected() && !sheetPin->IsSelected() )
1732  continue;
1733 
1734  if( drawingShadows && aSheet->IsSelected()
1736  {
1737  break;
1738  }
1739 
1740  int width = std::max( aSheet->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
1741  wxPoint initial_pos = sheetPin->GetTextPos();
1742  wxPoint offset_pos = initial_pos;
1743 
1744  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1745  switch( sheetPin->GetEdge() )
1746  {
1747  case SHEET_SIDE::TOP: offset_pos.y += KiROUND( width / 2.0 ); break;
1748  case SHEET_SIDE::BOTTOM: offset_pos.y -= KiROUND( width / 2.0 ); break;
1749  case SHEET_SIDE::RIGHT: offset_pos.x -= KiROUND( width / 2.0 ); break;
1750  case SHEET_SIDE::LEFT: offset_pos.x += KiROUND( width / 2.0 ); break;
1751  default: break;
1752  }
1753 
1754  sheetPin->SetTextPos( offset_pos );
1755  draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
1756  m_gal->DrawLine( offset_pos, initial_pos );
1757  sheetPin->SetTextPos( initial_pos );
1758  }
1759  }
1760 
1761  VECTOR2D pos = aSheet->GetPosition();
1762  VECTOR2D size = aSheet->GetSize();
1763 
1764  if( aLayer == LAYER_SHEET_BACKGROUND )
1765  {
1767  m_gal->SetIsFill( true );
1768  m_gal->SetIsStroke( false );
1769 
1770  m_gal->DrawRectangle( pos, pos + size );
1771  }
1772 
1773  if( aLayer == LAYER_SHEET || aLayer == LAYER_SELECTION_SHADOWS )
1774  {
1775  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1776  m_gal->SetIsStroke( true );
1777  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1778  m_gal->SetIsFill( false );
1779 
1780  m_gal->DrawRectangle( pos, pos + size );
1781 
1782  if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children && aSheet->IsSelected() )
1783  return;
1784 
1785  for( const SCH_FIELD& field : aSheet->GetFields() )
1786  draw( &field, aLayer );
1787  }
1788 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void draw(const LIB_RECTANGLE *aRect, int aLayer)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: eda_item.h:123
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
EESCHEMA_SETTINGS * eeconfig()
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:88
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetPenWidth() const override
Definition: sch_sheet.cpp:509
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
wxPoint GetPosition() const override
Definition: sch_sheet.h:380
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
wxSize GetSize() const
Definition: sch_sheet.h:105
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
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
int GetDefaultPenWidth() const
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References BOTTOM, draw(), EESCHEMA_SETTINGS::SELECTION::draw_selected_children, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), KIGFX::eeconfig(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), SCH_SHEET::GetFields(), getLineWidth(), SCH_SHEET::GetPenWidth(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), getRenderColor(), SCH_SHEET::GetSize(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_HIERLABEL, LAYER_SELECTION_SHADOWS, LAYER_SHEET, LAYER_SHEET_BACKGROUND, LEFT, KIGFX::PAINTER::m_gal, m_schSettings, EESCHEMA_SETTINGS::m_Selection, RIGHT, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and TOP.

◆ draw() [17/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_NO_CONNECT aNC,
int  aLayer 
)
private

Definition at line 1791 of file sch_painter.cpp.

1792 {
1793  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1794 
1795  if( drawingShadows && !aNC->IsSelected() )
1796  return;
1797 
1798  m_gal->SetIsStroke( true );
1799  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1800  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1801  m_gal->SetIsFill( false );
1802 
1803  VECTOR2D p = aNC->GetPosition();
1804  int delta = std::max( aNC->GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
1805 
1806  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1807  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1808 }
bool IsSelected() const
Definition: eda_item.h:123
wxPoint GetPosition() const override
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetSize() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
int GetDefaultPenWidth() const
constexpr int delta
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References delta, KIGFX::GAL::DrawLine(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), getLineWidth(), SCH_NO_CONNECT::GetPosition(), getRenderColor(), SCH_NO_CONNECT::GetSize(), EDA_ITEM::IsSelected(), LAYER_NOCONNECT, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [18/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_MARKER aMarker,
int  aLayer 
)
private

Definition at line 1904 of file sch_painter.cpp.

1905 {
1906  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1907 
1908  if( drawingShadows && !aMarker->IsSelected() )
1909  return;
1910 
1911  COLOR4D color = getRenderColor( aMarker, aMarker->GetColorLayer(), drawingShadows );
1912 
1913  m_gal->Save();
1914  m_gal->Translate( aMarker->GetPosition() );
1915  m_gal->SetIsFill( !drawingShadows );
1916  m_gal->SetFillColor( color );
1917  m_gal->SetIsStroke( drawingShadows );
1918  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1920 
1921  SHAPE_LINE_CHAIN polygon;
1922  aMarker->ShapeToPolygon( polygon );
1923 
1924  m_gal->DrawPolygon( polygon );
1925  m_gal->Restore();
1926 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
SCH_LAYER_ID GetColorLayer() const
Definition: sch_marker.cpp:122
bool IsSelected() const
Definition: eda_item.h:123
wxPoint GetPosition() const override
Definition: sch_marker.h:101
int color
Definition: DXF_plotter.cpp:57
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Represent a polyline (an zero-thickness chain of connected line segments).
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
virtual void Save()
Save the context.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, KIGFX::GAL::DrawPolygon(), SCH_MARKER::GetColorLayer(), getLineWidth(), SCH_MARKER::GetPosition(), getRenderColor(), EDA_ITEM::IsSelected(), LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), MARKER_BASE::ShapeToPolygon(), and KIGFX::GAL::Translate().

◆ draw() [19/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_BITMAP aBitmap,
int  aLayer 
)
private

Definition at line 1859 of file sch_painter.cpp.

1860 {
1861  m_gal->Save();
1862  m_gal->Translate( aBitmap->GetPosition() );
1863 
1864  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1865  // factor is similar to a local zoom
1866  double img_scale = aBitmap->GetImageScale();
1867 
1868  if( img_scale != 1.0 )
1869  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1870 
1871  if( aLayer == LAYER_DRAW_BITMAPS )
1872  {
1873  m_gal->DrawBitmap( *aBitmap->GetImage() );
1874  }
1875 
1876  if( aLayer == LAYER_SELECTION_SHADOWS )
1877  {
1878  if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
1879  {
1880  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1881  m_gal->SetIsStroke( true );
1884  m_gal->SetIsFill( false );
1885 
1886  // Draws a bounding box.
1887  VECTOR2D bm_size( aBitmap->GetSize() );
1888  // bm_size is the actual image size in UI.
1889  // but m_gal scale was previously set to img_scale
1890  // so recalculate size relative to this image size.
1891  bm_size.x /= img_scale;
1892  bm_size.y /= img_scale;
1893  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1894  VECTOR2D end = origin + bm_size;
1895 
1896  m_gal->DrawRectangle( origin, end );
1897  }
1898  }
1899 
1900  m_gal->Restore();
1901 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: eda_item.h:123
int color
Definition: DXF_plotter.cpp:57
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
bool IsBrightened() const
Definition: eda_item.h:126
wxPoint GetPosition() const override
Definition: sch_bitmap.h:136
float getShadowWidth() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxSize GetSize() const
Definition: sch_bitmap.cpp:125
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
to handle and draw images bitmaps
Definition: layer_ids.h:218
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
double GetImageScale() const
Definition: sch_bitmap.h:66
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, KIGFX::GAL::DrawBitmap(), KIGFX::GAL::DrawRectangle(), SCH_BITMAP::GetImage(), SCH_BITMAP::GetImageScale(), SCH_BITMAP::GetPosition(), getRenderColor(), getShadowWidth(), SCH_BITMAP::GetSize(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsSelected(), LAYER_DRAW_BITMAPS, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::Scale(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::Translate(), and VECTOR2< T >::x.

◆ draw() [20/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_LINE aLine,
int  aLayer 
)
private

Definition at line 1283 of file sch_painter.cpp.

1284 {
1285  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1286 
1287  if( drawingShadows && !aLine->IsSelected() )
1288  return;
1289 
1290  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1291  float width = getLineWidth( aLine, drawingShadows );
1292  PLOT_DASH_TYPE lineStyle = aLine->GetEffectiveLineStyle();
1293 
1294  m_gal->SetIsStroke( true );
1296  m_gal->SetLineWidth( width );
1297 
1298  if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1299  {
1300  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1301  }
1302  else
1303  {
1304  VECTOR2D start = aLine->GetStartPoint();
1305  VECTOR2D end = aLine->GetEndPoint();
1306 
1307  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1308  clip.Normalize();
1309 
1310  double theta = atan2( end.y - start.y, end.x - start.x );
1311  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1312 
1313  switch( lineStyle )
1314  {
1315  default:
1316  case PLOT_DASH_TYPE::DASH:
1317  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1318  break;
1319  case PLOT_DASH_TYPE::DOT:
1320  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1321  break;
1323  strokes[0] = DASH_MARK_LEN( width );
1324  strokes[2] = DOT_MARK_LEN( width );
1325  break;
1326  }
1327 
1328  for( size_t i = 0; i < 10000; ++i )
1329  {
1330  // Calculations MUST be done in doubles to keep from accumulating rounding
1331  // errors as we go.
1332  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1333  start.y + strokes[ i % 4 ] * sin( theta ) );
1334 
1335  // Drawing each segment can be done rounded to ints.
1336  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1337  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1338 
1339  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1340  break;
1341  else if( i % 2 == 0 )
1342  m_gal->DrawLine( segStart, segEnd );
1343 
1344  start = next;
1345  }
1346  }
1347 
1348  if( aLine->IsStartDangling() && aLine->IsWire() )
1349  {
1350  drawDanglingSymbol( aLine->GetStartPoint(), getLineWidth( aLine, drawingShadows ),
1351  drawingShadows );
1352  }
1353 
1354  if( aLine->IsEndDangling() && aLine->IsWire() )
1355  {
1356  drawDanglingSymbol( aLine->GetEndPoint(), getLineWidth( aLine, drawingShadows ),
1357  drawingShadows );
1358  }
1359 }
CITER next(CITER it)
Definition: ptree.cpp:126
void drawDanglingSymbol(const wxPoint &aPos, int aWidth, bool aDrawingShadows)
wxPoint GetStartPoint() const
Definition: sch_line.h:90
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:928
bool IsSelected() const
Definition: eda_item.h:123
int color
Definition: DXF_plotter.cpp:57
#define DASH_MARK_LEN(aLineWidth)
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsEndDangling() const
Definition: sch_line.h:200
#define DOT_MARK_LEN(aLineWidth)
PLOT_DASH_TYPE
Dashed line types.
Definition: plotter.h:104
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:268
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Definition: sch_line.cpp:257
bool IsStartDangling() const
Definition: sch_line.h:199
Handle the component boundary box.
Definition: eda_rect.h:42
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
#define DASH_GAP_LEN(aLineWidth)
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References ClipLine(), color, DASH, DASH_GAP_LEN, DASH_MARK_LEN, DASHDOT, DOT, DOT_MARK_LEN, drawDanglingSymbol(), KIGFX::GAL::DrawLine(), FIRST_TYPE, SCH_LINE::GetEffectiveLineStyle(), SCH_LINE::GetEndPoint(), SCH_ITEM::GetLayer(), getLineWidth(), getRenderColor(), SCH_LINE::GetStartPoint(), SCH_LINE::IsEndDangling(), EDA_ITEM::IsSelected(), SCH_LINE::IsStartDangling(), SCH_LINE::IsWire(), KiROUND(), LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, next(), EDA_RECT::Normalize(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [21/21]

void KIGFX::SCH_PAINTER::draw ( const SCH_BUS_ENTRY_BASE aEntry,
int  aLayer 
)
private

Definition at line 1811 of file sch_painter.cpp.

1812 {
1813  SCH_LINE line;
1814  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1815 
1816  if( drawingShadows && !aEntry->IsSelected() )
1817  return;
1818 
1819  line.SetLayer( aEntry->Type() == SCH_BUS_WIRE_ENTRY_T ? LAYER_WIRE : LAYER_BUS );
1820 
1821  if( aEntry->IsSelected() )
1822  line.SetSelected();
1823  else if( aEntry->IsBrightened() )
1824  line.SetBrightened();
1825 
1826  line.SetStartPoint( aEntry->GetPosition() );
1827  line.SetEndPoint( aEntry->GetEnd() );
1828  line.SetStroke( aEntry->GetStroke() );
1829  line.SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
1830 
1831  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1832 
1833  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1834  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1835 
1836  line.SetLineColor( color );
1837  line.SetLineStyle( aEntry->GetStrokeStyle() );
1838 
1839  draw( &line, aLayer );
1840 
1841  m_gal->SetIsFill( false );
1842  m_gal->SetIsStroke( true );
1843  m_gal->SetLineWidth( drawingShadows ? getShadowWidth() : 1.0F );
1844 
1845  if( aEntry->IsDanglingStart() )
1846  {
1847  m_gal->DrawCircle( aEntry->GetPosition(),
1848  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1849  }
1850 
1851  if( aEntry->IsDanglingEnd() )
1852  {
1853  m_gal->DrawCircle( aEntry->GetEnd(),
1854  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1855  }
1856 }
void draw(const LIB_RECTANGLE *aRect, int aLayer)
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:36
bool IsSelected() const
Definition: eda_item.h:123
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:69
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
int color
Definition: DXF_plotter.cpp:57
void SetBrightened()
Definition: eda_item.h:130
bool IsBrightened() const
Definition: eda_item.h:126
float getShadowWidth() const
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:48
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
PLOT_DASH_TYPE GetStrokeStyle() const
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:239
bool IsDanglingStart() const
Definition: sch_bus_entry.h:47
void SetSelected()
Definition: eda_item.h:129
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:91
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:275
#define F(x, y, z)
Definition: md5_hash.cpp:15
void SetLineColor(const COLOR4D &aColor)
Definition: sch_line.cpp:189
virtual int GetPenWidth() const
Definition: sch_item.h:285
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_line.h:125
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
wxPoint GetEnd() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
wxPoint GetPosition() const override

References color, draw(), KIGFX::GAL::DrawCircle(), F, SCH_BUS_ENTRY_BASE::GetEnd(), getLineWidth(), SCH_ITEM::GetPenWidth(), SCH_BUS_ENTRY_BASE::GetPosition(), getRenderColor(), getShadowWidth(), SCH_BUS_ENTRY_BASE::GetStroke(), SCH_BUS_ENTRY_BASE::GetStrokeStyle(), EDA_ITEM::IsBrightened(), SCH_BUS_ENTRY_BASE::IsDanglingEnd(), SCH_BUS_ENTRY_BASE::IsDanglingStart(), EDA_ITEM::IsSelected(), LAYER_BUS, LAYER_SELECTION_SHADOWS, LAYER_WIRE, KIGFX::PAINTER::m_gal, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, EDA_ITEM::SetBrightened(), SCH_LINE::SetEndPoint(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), SCH_ITEM::SetLayer(), SCH_LINE::SetLineColor(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), KIGFX::GAL::SetLineWidth(), EDA_ITEM::SetSelected(), SCH_LINE::SetStartPoint(), SCH_LINE::SetStroke(), TARGET_BUSENTRY_RADIUS, and EDA_ITEM::Type().

◆ drawDanglingSymbol()

void KIGFX::SCH_PAINTER::drawDanglingSymbol ( const wxPoint &  aPos,
int  aWidth,
bool  aDrawingShadows 
)
private

Definition at line 1246 of file sch_painter.cpp.

1247 {
1248  wxPoint radius( aWidth + Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1249  aWidth + Mils2iu( DANGLING_SYMBOL_SIZE / 2 ) );
1250 
1251  m_gal->SetIsStroke( true );
1252  m_gal->SetIsFill( false );
1253  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth()
1255 
1256  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1257 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
float getShadowWidth() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define DANGLING_SYMBOL_SIZE
< The size of the rectangle indicating an unconnected wire or label
float GetDanglineSymbolThickness() const
Definition: sch_painter.h:99
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References DANGLING_SYMBOL_SIZE, KIGFX::GAL::DrawRectangle(), KIGFX::SCH_RENDER_SETTINGS::GetDanglineSymbolThickness(), getShadowWidth(), KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), and KIGFX::GAL::SetLineWidth().

Referenced by draw().

◆ drawPinDanglingSymbol()

void KIGFX::SCH_PAINTER::drawPinDanglingSymbol ( const VECTOR2I aPos,
bool  aDrawingShadows 
)
private

Definition at line 769 of file sch_painter.cpp.

770 {
771  m_gal->SetIsFill( false );
772  m_gal->SetIsStroke( true );
773  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth()
775 
777 }
float getShadowWidth() const
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
float GetDanglineSymbolThickness() const
Definition: sch_painter.h:99
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:36
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References KIGFX::GAL::DrawCircle(), KIGFX::SCH_RENDER_SETTINGS::GetDanglineSymbolThickness(), getShadowWidth(), KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and TARGET_PIN_RADIUS.

Referenced by draw().

◆ externalPinDecoSize()

int KIGFX::SCH_PAINTER::externalPinDecoSize ( const LIB_PIN aPin)
private

Definition at line 759 of file sch_painter.cpp.

760 {
763 
764  return aPin.GetNumberTextSize() / 2;
765 }
int GetNumberTextSize() const
Definition: lib_pin.h:129
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References LIB_PIN::GetNumberTextSize(), KIGFX::SCH_RENDER_SETTINGS::m_PinSymbolSize, and m_schSettings.

Referenced by draw().

◆ fillIfSelection()

void KIGFX::SCH_PAINTER::fillIfSelection ( int  aLayer)
private

Definition at line 541 of file sch_painter.cpp.

542 {
543  if( aLayer == LAYER_SELECTION_SHADOWS && eeconfig()->m_Selection.fill_shapes )
544  m_gal->SetIsFill( true );
545 }
EESCHEMA_SETTINGS * eeconfig()
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.

References KIGFX::eeconfig(), LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, and KIGFX::GAL::SetIsFill().

Referenced by draw().

◆ getLineWidth() [1/2]

float KIGFX::SCH_PAINTER::getLineWidth ( const LIB_ITEM aItem,
bool  aDrawingShadows 
) const
private

Definition at line 342 of file sch_painter.cpp.

343 {
344  float width = (float) aItem->GetEffectivePenWidth( &m_schSettings );
345 
346  if( aItem->IsSelected() && aDrawingShadows )
347  width += getShadowWidth();
348 
349  return width;
350 }
bool IsSelected() const
Definition: eda_item.h:123
virtual int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const
Definition: lib_item.h:146
float getShadowWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References LIB_ITEM::GetEffectivePenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), and m_schSettings.

Referenced by draw(), and setDeviceColors().

◆ getLineWidth() [2/2]

float KIGFX::SCH_PAINTER::getLineWidth ( const SCH_ITEM aItem,
bool  aDrawingShadows 
) const
private

Definition at line 353 of file sch_painter.cpp.

354 {
355  wxCHECK( aItem, static_cast<float>( m_schSettings.m_DefaultWireThickness ) );
356 
357  float width = (float) aItem->GetPenWidth();
358 
359  if( aItem->IsSelected() && aDrawingShadows )
360  width += getShadowWidth();
361 
362  return std::max( width, 1.0f );
363 }
bool IsSelected() const
Definition: eda_item.h:123
float getShadowWidth() const
virtual int GetPenWidth() const
Definition: sch_item.h:285
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References SCH_ITEM::GetPenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), KIGFX::SCH_RENDER_SETTINGS::m_DefaultWireThickness, and m_schSettings.

◆ getRenderColor()

COLOR4D KIGFX::SCH_PAINTER::getRenderColor ( const EDA_ITEM aItem,
int  aLayer,
bool  aDrawingShadows 
) const
private

Definition at line 279 of file sch_painter.cpp.

280 {
282 
283  if( aItem->Type() == SCH_LINE_T )
284  {
285  COLOR4D lineColor = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
286 
287  if( lineColor != COLOR4D::UNSPECIFIED )
288  color = lineColor;
289  }
290  else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
291  {
292  COLOR4D busEntryColor = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetStrokeColor();
293 
294  if( busEntryColor != COLOR4D::UNSPECIFIED )
295  color = busEntryColor;
296  }
297  else if( aItem->Type() == SCH_JUNCTION_T )
298  {
299  COLOR4D junctionColor = static_cast<const SCH_JUNCTION*>( aItem )->GetJunctionColor();
300 
301  if( junctionColor != COLOR4D::UNSPECIFIED )
302  color = junctionColor;
303  }
304  else if( aItem->Type() == SCH_SHEET_T )
305  {
306  SCH_SHEET* sheet = (SCH_SHEET*) aItem;
307 
309  color = m_schSettings.GetLayerColor( aLayer );
310  else if( aLayer == LAYER_SHEET )
311  color = sheet->GetBorderColor();
312  else if( aLayer == LAYER_SHEET_BACKGROUND )
313  color = sheet->GetBackgroundColor();
314 
315  if( color == COLOR4D::UNSPECIFIED )
316  color = m_schSettings.GetLayerColor( aLayer );
317  }
318 
319  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
320  {
322 
323  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
324  color = color.WithAlpha( 0.2 );
325  }
326  else if( aItem->IsSelected() )
327  {
328  if( aDrawingShadows )
330  }
331 
333  || ( m_schSettings.m_ShowGraphicsDisabled && aItem->Type() != LIB_FIELD_T ) )
334  {
335  color = color.Darken( 0.5f );
336  }
337 
338  return color;
339 }
bool IsSelected() const
Definition: eda_item.h:123
int color
Definition: DXF_plotter.cpp:57
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:111
bool IsBrightened() const
Definition: eda_item.h:126
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:114
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:377
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, SCH_SHEET::GetBackgroundColor(), SCH_SHEET::GetBorderColor(), KIGFX::RENDER_SETTINGS::GetLayerColor(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsSelected(), LAYER_BRIGHTENED, LAYER_DEVICE_BACKGROUND, LAYER_SELECTION_SHADOWS, LAYER_SHEET, LAYER_SHEET_BACKGROUND, LIB_FIELD_T, KIGFX::SCH_RENDER_SETTINGS::m_OverrideItemColors, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowDisabled, KIGFX::SCH_RENDER_SETTINGS::m_ShowGraphicsDisabled, SCH_BUS_WIRE_ENTRY_T, SCH_JUNCTION_T, SCH_LINE_T, SCH_SHEET_T, EDA_ITEM::Type(), and KIGFX::COLOR4D::UNSPECIFIED.

Referenced by draw(), and setDeviceColors().

◆ GetSettings()

virtual SCH_RENDER_SETTINGS* KIGFX::SCH_PAINTER::GetSettings ( )
inlineoverridevirtual

Return a pointer to current settings that are going to be used when drawing items.

Returns
Current rendering settings.

Implements KIGFX::PAINTER.

Definition at line 143 of file sch_painter.h.

144  {
145  return &m_schSettings;
146  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References m_schSettings.

Referenced by SCH_EDITOR_CONTROL::ToggleHiddenFields(), and SCH_EDITOR_CONTROL::ToggleHiddenPins().

◆ getShadowWidth()

float KIGFX::SCH_PAINTER::getShadowWidth ( ) const
private

Definition at line 268 of file sch_painter.cpp.

269 {
270  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
271 
272  // For best visuals the selection width must be a cross between the zoom level and the
273  // default line width.
274  return (float) std::fabs( matrix.GetScale().x * 2.75 ) +
275  Mils2iu( eeconfig()->m_Selection.thickness );
276 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
EESCHEMA_SETTINGS * eeconfig()
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101

References KIGFX::eeconfig(), MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), KIGFX::PAINTER::m_gal, EESCHEMA_SETTINGS::m_Selection, EESCHEMA_SETTINGS::SELECTION::thickness, and VECTOR2< T >::x.

Referenced by draw(), drawDanglingSymbol(), drawPinDanglingSymbol(), getLineWidth(), and getTextThickness().

◆ getTextThickness() [1/4]

float KIGFX::SCH_PAINTER::getTextThickness ( const SCH_TEXT aItem,
bool  aDrawingShadows 
) const
private

Definition at line 366 of file sch_painter.cpp.

367 {
368  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
369 
370  if( aItem->IsSelected() && aDrawingShadows )
371  width += getShadowWidth();
372 
373  return width;
374 }
bool IsSelected() const
Definition: eda_item.h:123
float getShadowWidth() const
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:149
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), and m_schSettings.

Referenced by draw().

◆ getTextThickness() [2/4]

float KIGFX::SCH_PAINTER::getTextThickness ( const SCH_FIELD aItem,
bool  aDrawingShadows 
) const
private

Definition at line 377 of file sch_painter.cpp.

378 {
379  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
380 
381  if( aItem->IsSelected() && aDrawingShadows )
382  width += getShadowWidth();
383 
384  return width;
385 }
bool IsSelected() const
Definition: eda_item.h:123
float getShadowWidth() const
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:149
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), and m_schSettings.

◆ getTextThickness() [3/4]

float KIGFX::SCH_PAINTER::getTextThickness ( const LIB_FIELD aItem,
bool  aDrawingShadows 
) const
private

Definition at line 388 of file sch_painter.cpp.

389 {
390  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
392 
393  if( aItem->IsSelected() && aDrawingShadows )
394  width += getShadowWidth();
395 
396  return width;
397 }
bool IsSelected() const
Definition: eda_item.h:123
float getShadowWidth() const
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:149
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), and m_schSettings.

◆ getTextThickness() [4/4]

float KIGFX::SCH_PAINTER::getTextThickness ( const LIB_TEXT aItem,
bool  aDrawingShadows 
) const
private

Definition at line 400 of file sch_painter.cpp.

401 {
402  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
404 
405  if( aItem->IsSelected() && aDrawingShadows )
406  width += getShadowWidth();
407 
408  return width;
409 }
bool IsSelected() const
Definition: eda_item.h:123
float getShadowWidth() const
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:149
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), and m_schSettings.

◆ internalPinDecoSize()

int KIGFX::SCH_PAINTER::internalPinDecoSize ( const LIB_PIN aPin)
private

Definition at line 748 of file sch_painter.cpp.

749 {
752 
753  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
754 }
int GetNameTextSize() const
Definition: lib_pin.h:126
int GetNumberTextSize() const
Definition: lib_pin.h:129
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References LIB_PIN::GetNameTextSize(), LIB_PIN::GetNumberTextSize(), KIGFX::SCH_RENDER_SETTINGS::m_PinSymbolSize, and m_schSettings.

Referenced by draw().

◆ isUnitAndConversionShown()

bool KIGFX::SCH_PAINTER::isUnitAndConversionShown ( const LIB_ITEM aItem) const
private

Definition at line 248 of file sch_painter.cpp.

249 {
250  if( m_schSettings.m_ShowUnit // showing a specific unit
251  && aItem->GetUnit() // item is unit-specific
252  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
253  {
254  return false;
255  }
256 
257  if( m_schSettings.m_ShowConvert // showing a specific conversion
258  && aItem->GetConvert() // item is conversion-specific
259  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
260  {
261  return false;
262  }
263 
264  return true;
265 }
int GetUnit() const
Definition: lib_item.h:272
int GetConvert() const
Definition: lib_item.h:275
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:202

References LIB_ITEM::GetConvert(), LIB_ITEM::GetUnit(), m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowConvert, and KIGFX::SCH_RENDER_SETTINGS::m_ShowUnit.

Referenced by draw().

◆ setDeviceColors()

bool KIGFX::SCH_PAINTER::setDeviceColors ( const LIB_ITEM aItem,
int  aLayer 
)
private

Definition at line 488 of file sch_painter.cpp.

489 {
490  switch( aLayer )
491  {
493  if( aItem->IsSelected() )
494  {
495  m_gal->SetIsFill( false );
496  m_gal->SetIsStroke( true );
497  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
498  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
499  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
500  return true;
501  }
502 
503  return false;
504 
507  {
508  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
509 
511  m_gal->SetFillColor( fillColor );
512  m_gal->SetIsStroke( false );
513  return true;
514  }
515 
516  return false;
517 
518  case LAYER_DEVICE:
520  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
521 
522  if( aItem->GetPenWidth() >= 0 || aItem->GetFillMode() == FILL_TYPE::NO_FILL )
523  {
524  m_gal->SetIsStroke( true );
525  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
526  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
527  }
528  else
529  {
530  m_gal->SetIsStroke( false );
531  }
532 
533  return true;
534 
535  default:
536  return false;
537  }
538 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual int GetPenWidth() const =0
bool IsSelected() const
Definition: eda_item.h:123
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
virtual void SetLineWidth(float aLineWidth)
Set the line width.
FILL_TYPE GetFillMode() const
Definition: lib_item.h:278
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows) const
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows) const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, LIB_ITEM::GetFillMode(), getLineWidth(), LIB_ITEM::GetPenWidth(), getRenderColor(), EDA_ITEM::IsSelected(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, NO_FILL, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

Referenced by draw().

◆ SetGAL()

void KIGFX::PAINTER::SetGAL ( GAL aGal)
inlineinherited

Changes Graphics Abstraction Layer used for drawing items for a new one.

Parameters
aGalis the new GAL instance.

Definition at line 75 of file painter.h.

76  {
77  m_gal = aGal;
78  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101

References KIGFX::PAINTER::m_gal.

◆ SetSchematic()

void KIGFX::SCH_PAINTER::SetSchematic ( SCHEMATIC aSchematic)
inline

Definition at line 148 of file sch_painter.h.

149  {
150  m_schematic = aSchematic;
151  }
SCHEMATIC * m_schematic
Definition: sch_painter.h:204

References m_schematic.

◆ strokeText()

void KIGFX::SCH_PAINTER::strokeText ( const wxString &  aText,
const VECTOR2D aPosition,
double  aRotationAngle 
)
private

Definition at line 418 of file sch_painter.cpp.

419 {
420  m_gal->StrokeText( aText, VECTOR2D( aPosition.x, aPosition.y ), aAngle );
421 }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a vector type text using preloaded Newstroke font.

References KIGFX::PAINTER::m_gal, KIGFX::GAL::StrokeText(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by draw().

◆ triLine()

void KIGFX::SCH_PAINTER::triLine ( const VECTOR2D a,
const VECTOR2D b,
const VECTOR2D c 
)
private

Definition at line 448 of file sch_painter.cpp.

449 {
450  m_gal->DrawLine( a, b );
451  m_gal->DrawLine( b, c );
452 }
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101

References KIGFX::GAL::DrawLine(), and KIGFX::PAINTER::m_gal.

Referenced by draw().

Member Data Documentation

◆ m_gal

◆ m_schematic

SCHEMATIC* KIGFX::SCH_PAINTER::m_schematic
private

Definition at line 204 of file sch_painter.h.

Referenced by draw(), and SetSchematic().

◆ m_schSettings


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