KiCad PCB EDA Suite
KIGFX::SCH_PAINTER Class Reference

Class SCH_PAINTER 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
 Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the item. More...
 
virtual void ApplySettings (const RENDER_SETTINGS *aSettings) override
 Function ApplySettings Loads colors and display modes settings that are going to be used when drawing items. More...
 
virtual SCH_RENDER_SETTINGSGetSettings () override
 Function GetSettings Returns pointer to current settings that are going to be used when drawing items. More...
 
void SetGAL (GAL *aGal)
 Function SetGAL 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...
 
COLOR4D m_brightenedColor
 Color of brightened item frame. More...
 

Private Member Functions

void draw (LIB_RECTANGLE *aRect, int aLayer)
 
void draw (LIB_PIN *aPin, int aLayer)
 
void draw (LIB_CIRCLE *aCircle, int aLayer)
 
void draw (LIB_ITEM *, int aLayer)
 
void draw (LIB_PART *aPart, int, bool aDrawFields=true, int aUnit=0, int aConvert=0)
 
void draw (LIB_ALIAS *aAlias, int aLayer)
 
void draw (LIB_ARC *aArc, int aLayer)
 
void draw (LIB_POLYLINE *aLine, int aLayer)
 
void draw (LIB_FIELD *aField, int aLayer)
 
void draw (LIB_TEXT *aText, int aLayer)
 
void draw (LIB_BEZIER *aCurve, int aLayer)
 
void draw (SCH_COMPONENT *aComp, int aLayer)
 
void draw (SCH_JUNCTION *aJct, int aLayer)
 
void draw (SCH_FIELD *aField, int aLayer)
 
void draw (SCH_TEXT *aText, int aLayer)
 
void draw (SCH_HIERLABEL *aLabel, int aLayer)
 
void draw (SCH_GLOBALLABEL *aLabel, int aLayer)
 
void draw (SCH_SHEET *aSheet, int aLayer)
 
void draw (SCH_NO_CONNECT *aNC, int aLayer)
 
void draw (SCH_MARKER *aMarker, int aLayer)
 
void draw (SCH_BITMAP *aBitmap, int aLayer)
 
void draw (SCH_LINE *aLine, int aLayer)
 
void draw (SCH_BUS_ENTRY_BASE *aEntry, int aLayer)
 
bool isUnitAndConversionShown (const LIB_ITEM *aItem)
 
COLOR4D getRenderColor (const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
 
bool setColors (const LIB_ITEM *aItem, int aLayer)
 
void triLine (const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
 

Private Attributes

SCH_RENDER_SETTINGS m_schSettings
 

Detailed Description

Class SCH_PAINTER Contains methods for drawing schematic-specific items.

Definition at line 116 of file sch_painter.h.

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 135 of file sch_painter.cpp.

135  :
136  KIGFX::PAINTER (aGal)
137 { }
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:308

Member Function Documentation

◆ ApplySettings()

virtual void KIGFX::SCH_PAINTER::ApplySettings ( const RENDER_SETTINGS aSettings)
inlineoverridevirtual

Function ApplySettings Loads colors and display modes settings that are going to be used when drawing items.

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 125 of file sch_painter.h.

126  {
127  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
128  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169

References m_schSettings.

◆ Draw()

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

Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know 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 144 of file sch_painter.cpp.

145 {
146  auto item2 = static_cast<const EDA_ITEM*>( aItem );
147  auto item = const_cast<EDA_ITEM*>( item2 );
148 
150 
151 #ifdef CONNECTIVITY_DEBUG
152 
153  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
154  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
155 
156  if( conn )
157  {
158  auto pos = item->GetBoundingBox().Centre();
159  auto label = conn->Name( true );
160 
164  m_gal->SetLineWidth( 2 );
165  m_gal->SetGlyphSize( VECTOR2D( 20, 20 ) );
166  m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
167  }
168 
169 #endif
170 
171  switch( item->Type() )
172  {
198 
199  default: return false;
200  }
201 
202  return false;
203 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
Part library alias object definition.
Define a symbol library graphical text item.
Definition: lib_text.h:44
Field object used in symbol libraries.
Definition: lib_field.h:59
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
Define a library symbol object.
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:42
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
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)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: sch_painter.cpp:79
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:39
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References g_CurrentSheet, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, HANDLE_ITEM, KIGFX::SCH_RENDER_SETTINGS::ImportLegacyColors(), LIB_ALIAS_T, LIB_ARC_T, LIB_BEZIER_T, LIB_CIRCLE_T, LIB_FIELD_T, LIB_PART_T, LIB_PIN_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, LIB_TEXT_T, LIGHTRED, KIGFX::PAINTER::m_gal, m_schSettings, SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_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_TEXT_T, KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), and KIGFX::GAL::StrokeText().

Referenced by draw().

◆ draw() [1/23]

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

Definition at line 346 of file sch_painter.cpp.

347 {
348  if( !isUnitAndConversionShown( aRect ) )
349  return;
350 
351  if( setColors( aRect, aLayer ) )
352  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
353 
354 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool setColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetEnd() const
Definition: lib_rectangle.h:97
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
static VECTOR2D mapCoords(const wxPoint &aCoord)
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_rectangle.h:84

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

Referenced by draw().

◆ draw() [2/23]

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

Definition at line 515 of file sch_painter.cpp.

516 {
517  if( aLayer != LAYER_DEVICE )
518  return;
519 
520  if( !isUnitAndConversionShown( aPin ) )
521  return;
522 
523  VECTOR2I pos = mapCoords( aPin->GetPosition() );
524  COLOR4D color = getRenderColor( aPin, LAYER_PIN, false );
525 
526  if( !aPin->IsVisible() )
527  {
529  {
531  }
532  else
533  {
534  if( ( aPin->GetFlags() & IS_DANGLING ) && aPin->IsPowerConnection() )
536 
537  return;
538  }
539  }
540 
541  VECTOR2I p0, dir;
542  int len = aPin->GetLength();
543  int width = aPin->GetPenSize();
544  int shape = aPin->GetShape();
545  int orient = aPin->GetOrientation();
546 
547  switch( orient )
548  {
549  case PIN_UP:
550  p0 = VECTOR2I( pos.x, pos.y - len );
551  dir = VECTOR2I(0, 1);
552  break;
553  case PIN_DOWN:
554  p0 = VECTOR2I( pos.x, pos.y + len );
555  dir = VECTOR2I(0, -1);
556  break;
557  case PIN_LEFT:
558  p0 = VECTOR2I( pos.x - len, pos.y );
559  dir = VECTOR2I(1, 0);
560  break;
561  case PIN_RIGHT:
562  p0 = VECTOR2I( pos.x + len, pos.y );
563  dir = VECTOR2I(-1, 0);
564  break;
565  }
566 
567  VECTOR2D pc;
568 
569  m_gal->SetIsStroke( true );
570  m_gal->SetIsFill( false );
571  m_gal->SetLineWidth( width );
573  m_gal->SetFontBold( false );
574  m_gal->SetFontItalic( false );
575 
576  const int radius = ExternalPinDecoSize( *aPin );
577  const int diam = radius*2;
578  const int clock_size = InternalPinDecoSize( *aPin );
579 
580  if( shape == PINSHAPE_INVERTED )
581  {
582  m_gal->DrawCircle( p0 + dir * radius, radius );
583  m_gal->DrawLine( p0 + dir * ( diam ), pos );
584  }
585  else if( shape == PINSHAPE_FALLING_EDGE_CLOCK )
586  {
587  pc = p0 + dir * clock_size ;
588 
589  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
590  pc,
591  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
592 
593  m_gal->DrawLine( pos, pc );
594  }
595  else
596  {
597  m_gal->DrawLine( p0, pos );
598  }
599 
600  if( shape == PINSHAPE_CLOCK )
601  {
602  if (!dir.y)
603  {
604  triLine( p0 + VECTOR2D( 0, clock_size ),
605  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
606  p0 + VECTOR2D( 0, -clock_size ) );
607  }
608  else
609  {
610  triLine( p0 + VECTOR2D( clock_size, 0 ),
611  p0 + VECTOR2D( 0, -dir.y * clock_size ),
612  p0 + VECTOR2D( -clock_size, 0 ) );
613  }
614  }
615 
616  if( shape == PINSHAPE_INPUT_LOW )
617  {
618  if(!dir.y)
619  {
620  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
621  p0 + VECTOR2D(dir.x, -1) * diam,
622  p0 );
623  }
624  else /* MapX1 = 0 */
625  {
626  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
627  p0 + VECTOR2D(-1, dir.y) * diam,
628  p0 );
629  }
630  }
631 
632  if( shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
633  {
634  if( !dir.y ) // Horizontal pin
635  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
636  else // Vertical pin
637  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
638  }
639 
640  if( shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
641  {
642  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
643  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
644  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
645  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
646  }
647 
648  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
649  {
650  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
651  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
652  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
653  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
654 
655  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
656  }
657 
658  if( ( aPin->GetFlags() & IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
660 
661  // Draw the labels
662 
663  LIB_PART* libEntry = aPin->GetParent();
664  int textOffset = libEntry->GetPinNameOffset();
665 
666  int nameLineWidth = aPin->GetPenSize();
667  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
668  int numLineWidth = aPin->GetPenSize();
669  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
670 
671  #define PIN_TEXT_MARGIN 4
672 
673  // Four locations around a pin where text can be drawn
674  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
675  int size[4] = { 0, 0, 0, 0 };
676  int thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
677  COLOR4D colour[4];
678  wxString text[4];
679 
680  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
681  if( textOffset )
682  {
683  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
684  thickness[INSIDE] = nameLineWidth;
685  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, false );
686  text [INSIDE] = aPin->GetName();
687 
688  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
689  thickness[ABOVE] = numLineWidth;
690  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, false );
691  text [ABOVE] = aPin->GetNumber();
692  }
693  // Otherwise pin NAMES go above and pin NUMBERS go below
694  else
695  {
696  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
697  thickness[ABOVE] = nameLineWidth;
698  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, false );
699  text [ABOVE] = aPin->GetName();
700 
701  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
702  thickness[BELOW] = numLineWidth;
703  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, false );
704  text [BELOW] = aPin->GetNumber();
705  }
706 
708  {
709  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
710  thickness[OUTSIDE] = size[OUTSIDE] / 6;
711  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, false );
712  text [OUTSIDE] = aPin->GetElectricalTypeName();
713  }
714 
715  if( !aPin->IsVisible() )
716  {
717  for( COLOR4D& c : colour )
719  }
720 
721  int insideOffset = textOffset;
722  int outsideOffset = 10;
723  int aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + GetDefaultLineThickness() ) / 2;
724  int belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + GetDefaultLineThickness() ) / 2;
725 
726  #define SET_DC( i ) \
727  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
728  m_gal->SetLineWidth( thickness[i] ); \
729  m_gal->SetStrokeColor( colour[i] );
730 
731  switch( orient )
732  {
733  case PIN_LEFT:
734  if( size[INSIDE] )
735  {
736  SET_DC( INSIDE );
739  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
740  }
741  if( size[OUTSIDE] )
742  {
743  SET_DC( OUTSIDE );
746  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
747  }
748  if( size[ABOVE] )
749  {
750  SET_DC( ABOVE );
753  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
754  }
755  if( size[BELOW] )
756  {
757  SET_DC( BELOW );
760  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
761  }
762  break;
763 
764  case PIN_RIGHT:
765  if( size[INSIDE] )
766  {
767  SET_DC( INSIDE );
771  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
772  }
773  if( size[OUTSIDE] )
774  {
775  SET_DC( OUTSIDE );
778  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
779  }
780  if( size[ABOVE] )
781  {
782  SET_DC( ABOVE );
785  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
786  }
787  if( size[BELOW] )
788  {
789  SET_DC( BELOW );
792  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
793  }
794  break;
795 
796  case PIN_DOWN:
797  if( size[INSIDE] )
798  {
799  SET_DC( INSIDE );
802  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2);
803  }
804  if( size[OUTSIDE] )
805  {
806  SET_DC( OUTSIDE );
809  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2);
810  }
811  if( size[ABOVE] )
812  {
813  SET_DC( ABOVE );
816  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
817  }
818  if( size[BELOW] )
819  {
820  SET_DC( BELOW );
823  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
824  }
825  break;
826 
827  case PIN_UP:
828  if( size[INSIDE] )
829  {
830  SET_DC( INSIDE );
833  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2);
834  }
835  if( size[OUTSIDE] )
836  {
837  SET_DC( OUTSIDE );
840  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2);
841  }
842  if( size[ABOVE] )
843  {
844  SET_DC( ABOVE );
847  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
848  }
849  if( size[BELOW] )
850  {
851  SET_DC( BELOW );
854  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
855  }
856  break;
857 
858  default:
859  wxFAIL_MSG( "Unknown pin orientation" );
860  }
861 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
int GetPinNameOffset()
int GetOrientation() const
Definition: lib_pin.h:205
LIB_PART * GetParent() const
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:219
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
static int InternalPinDecoSize(const LIB_PIN &aPin)
Definition: lib_pin.h:55
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
#define SET_DC(i)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
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:352
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static int ExternalPinDecoSize(const LIB_PIN &aPin)
bool ShowPinNames()
int GetPenSize() const override
Definition: lib_pin.cpp:549
void SetFontBold(const bool aBold)
Set bold property of current font.
bool ShowPinNumbers()
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxString const GetElectricalTypeName() const
return a translated string for messages giving the electrical type of the pin.
Definition: lib_pin.h:259
const wxString & GetName() const
Definition: lib_pin.h:150
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
Define a library symbol object.
static void drawPinDanglingSymbol(GAL *aGal, const VECTOR2I &aPos, const COLOR4D &aColor)
#define OUTSIDE
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:346
int GetNameTextSize() const
Definition: lib_pin.h:176
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_pin.h:432
const wxString & GetNumber() const
Definition: lib_pin.h:178
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:235
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:203
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:143
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
#define max(a, b)
Definition: auxiliary.h:86
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
#define INSIDE
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:261
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define PIN_TEXT_MARGIN
int GetLength()
Definition: lib_pin.h:285
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References Clamp_Text_PenSize(), EDA_ITEM::ClearFlags(), color, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::drawPinDanglingSymbol(), KIGFX::ExternalPinDecoSize(), GetDefaultLineThickness(), LIB_PIN::GetElectricalTypeName(), EDA_ITEM::GetFlags(), KIGFX::RENDER_SETTINGS::GetLayerColor(), LIB_PIN::GetLength(), LIB_PIN::GetName(), LIB_PIN::GetNameTextSize(), LIB_PIN::GetNumber(), LIB_PIN::GetNumberTextSize(), LIB_PIN::GetOrientation(), LIB_ITEM::GetParent(), LIB_PIN::GetPenSize(), LIB_PART::GetPinNameOffset(), LIB_PIN::GetPosition(), getRenderColor(), LIB_PIN::GetShape(), 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, INSIDE, KIGFX::InternalPinDecoSize(), IS_DANGLING, LIB_PIN::IsPowerConnection(), isUnitAndConversionShown(), LIB_PIN::IsVisible(), LAYER_DEVICE, LAYER_HIDDEN, LAYER_NOTES, LAYER_PIN, LAYER_PINNAM, LAYER_PINNUM, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenPins, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, KIGFX::mapCoords(), max, OUTSIDE, PIN_DOWN, PIN_LEFT, PIN_NC, PIN_RIGHT, PIN_TEXT_MARGIN, PIN_UP, PINSHAPE_CLOCK, PINSHAPE_FALLING_EDGE_CLOCK, PINSHAPE_INPUT_LOW, PINSHAPE_INVERTED, PINSHAPE_NONLOGIC, PINSHAPE_OUTPUT_LOW, SET_DC, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), LIB_PART::ShowPinNames(), LIB_PART::ShowPinNumbers(), KIGFX::GAL::StrokeText(), TARGET_PIN_RADIUS, triLine(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [3/23]

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

Definition at line 357 of file sch_painter.cpp.

358 {
359  if( !isUnitAndConversionShown( aCircle ) )
360  return;
361 
362  if( setColors( aCircle, aLayer ) )
363  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
364 }
bool setColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_circle.h:79
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
int GetRadius() const
Definition: lib_circle.h:96
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

◆ draw() [4/23]

void KIGFX::SCH_PAINTER::draw ( LIB_ITEM ,
int  aLayer 
)
private

◆ draw() [5/23]

void KIGFX::SCH_PAINTER::draw ( LIB_PART aPart,
int  aLayer,
bool  aDrawFields = true,
int  aUnit = 0,
int  aConvert = 0 
)
private

Definition at line 250 of file sch_painter.cpp.

251 {
252  if( !aUnit )
253  aUnit = m_schSettings.m_ShowUnit;
254 
255  if( !aConvert )
256  aConvert = m_schSettings.m_ShowConvert;
257 
258  for( auto& item : aPart->GetDrawItems() )
259  {
260  if( !aDrawFields && item.Type() == LIB_FIELD_T )
261  continue;
262 
263  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
264  continue;
265 
266  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
267  continue;
268 
269  Draw( &item, aLayer );
270  }
271 }
virtual bool Draw(const VIEW_ITEM *, int) override
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169

References Draw(), LIB_PART::GetDrawItems(), LIB_FIELD_T, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowConvert, and KIGFX::SCH_RENDER_SETTINGS::m_ShowUnit.

◆ draw() [6/23]

void KIGFX::SCH_PAINTER::draw ( LIB_ALIAS aAlias,
int  aLayer 
)
private

Definition at line 274 of file sch_painter.cpp.

275 {
276  LIB_PART* comp = aAlias->GetPart();
277 
278  draw( comp, aLayer, false );
279 
280  LIB_FIELDS fields;
281  comp->GetFields( fields );
282 
283  if( !aAlias->IsRoot() )
284  {
285  fields[ VALUE ].SetText( aAlias->GetName() );
286  fields[ DATASHEET ].SetText( aAlias->GetDocFileName() );
287  }
288 
289  for( LIB_FIELD& field : fields )
290  draw( &field, aLayer );
291 }
name of datasheet
Field object used in symbol libraries.
Definition: lib_field.h:59
const wxString & GetDocFileName() const
bool IsRoot() const override
For symbols having aliases, IsRoot() indicates the principal item.
#define VALUE
Define a library symbol object.
LIB_PART * GetPart() const
Get the shared LIB_PART.
const wxString & GetName() const override
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:250
void draw(LIB_RECTANGLE *aRect, int aLayer)
void GetFields(LIB_FIELDS &aList)
Return a list of fields within this part.

References DATASHEET, draw(), LIB_ALIAS::GetDocFileName(), LIB_PART::GetFields(), LIB_ALIAS::GetName(), LIB_ALIAS::GetPart(), LIB_ALIAS::IsRoot(), and VALUE.

◆ draw() [7/23]

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

Definition at line 367 of file sch_painter.cpp.

368 {
369  if( !isUnitAndConversionShown( aArc ) )
370  return;
371 
372  int sai = aArc->GetFirstRadiusAngle();
373  int eai = aArc->GetSecondRadiusAngle();
374 
375  if( TRANSFORM().MapAngles( &sai, &eai ) )
376  std::swap( sai, eai );
377 
378  double sa = (double) sai * M_PI / 1800.0;
379  double ea = (double) eai * M_PI / 1800.0 ;
380 
381  VECTOR2D pos = mapCoords( aArc->GetPosition() );
382 
383  if( setColors( aArc, aLayer ) )
384  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
385 }
bool setColors(const LIB_ITEM *aItem, int aLayer)
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
int GetSecondRadiusAngle() const
Definition: lib_arc.h:123
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
static VECTOR2D mapCoords(const wxPoint &aCoord)
int GetRadius() const
Definition: lib_arc.h:117
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
int GetFirstRadiusAngle() const
Definition: lib_arc.h:120
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_arc.h:103

References KIGFX::GAL::DrawArc(), LIB_ARC::GetFirstRadiusAngle(), LIB_ARC::GetPosition(), LIB_ARC::GetRadius(), LIB_ARC::GetSecondRadiusAngle(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), and setColors().

◆ draw() [8/23]

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

Definition at line 388 of file sch_painter.cpp.

389 {
390  if( !isUnitAndConversionShown( aLine ) )
391  return;
392 
393  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
394  std::deque<VECTOR2D> vtx;
395 
396  for( auto p : pts )
397  vtx.push_back( mapCoords( p ) );
398 
399  if( setColors( aLine, aLayer ) )
400  m_gal->DrawPolygon( vtx );
401 }
bool setColors(const LIB_ITEM *aItem, int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:66
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

◆ draw() [9/23]

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

Definition at line 404 of file sch_painter.cpp.

405 {
406  // Must check layer as fields are sometimes drawn by their parent rather than
407  // directly from the view.
408  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS], layers_count;
409  aField->ViewGetLayers( layers, layers_count );
410 
411  if( aLayer != layers[0] )
412  return;
413 
414  if( !isUnitAndConversionShown( aField ) )
415  return;
416 
417  auto color = getRenderColor( aField, aLayer, false );
418 
419  if( !aField->IsVisible() )
420  {
423  else
424  return;
425  }
426 
427  int linewidth = aField->GetPenSize();
428 
429  m_gal->SetLineWidth( linewidth );
430  m_gal->SetIsFill( false );
431  m_gal->SetIsStroke( true );
433  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
434  m_gal->SetFontItalic( aField->IsItalic() );
435 
437  m_gal->SetVerticalJustify( aField->GetVertJustify( ) );
438 
439  auto pos = mapCoords( aField->GetPosition() );
440  double orient = aField->GetTextAngleRadians();
441 
442  m_gal->StrokeText( aField->GetText(), pos, orient );
443 
444  // Draw the umbilical line
445  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
446  {
448  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
449  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
450  }
451 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_field.h:215
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
bool IsMoving() const
Definition: base_struct.h:224
int color
Definition: DXF_plotter.cpp:62
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
virtual const wxString GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:147
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:712
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsVisible() const
Definition: lib_field.h:165
bool IsItalic() const
Definition: eda_text.h:187
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: lib_field.cpp:371
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:232
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
double GetTextAngleRadians() const
Definition: eda_text.h:184
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
int GetPenSize() const override
Definition: lib_field.cpp:118
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, KIGFX::GAL::DrawLine(), EDA_TEXT::GetHorizJustify(), KIGFX::RENDER_SETTINGS::GetLayerColor(), LIB_FIELD::GetPenSize(), LIB_FIELD::GetPosition(), getRenderColor(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsItalic(), EDA_ITEM::IsMoving(), isUnitAndConversionShown(), LIB_FIELD::IsVisible(), LAYER_HIDDEN, 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(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), KIGFX::GAL::StrokeText(), KIGFX::VIEW::VIEW_MAX_LAYERS, and LIB_FIELD::ViewGetLayers().

◆ draw() [10/23]

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

Definition at line 454 of file sch_painter.cpp.

455 {
456  if( !isUnitAndConversionShown( aText ) )
457  return;
458 
459  auto color = getRenderColor( aText, LAYER_DEVICE, false );
460 
461  if( !aText->IsVisible() )
462  {
465  else
466  return;
467  }
468 
469  int linewidth = aText->GetPenSize();
470  EDA_RECT bBox = aText->GetBoundingBox();
471  bBox.RevertYAxis();
472  VECTOR2D pos = mapCoords( bBox.Centre() );
473  double orient = aText->GetTextAngleRadians();
474 
477  m_gal->SetLineWidth( linewidth );
478  m_gal->SetIsFill( false );
479  m_gal->SetIsStroke( true );
481  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
482  m_gal->SetFontBold( aText->IsBold() );
483  m_gal->SetFontItalic( aText->IsItalic() );
484  m_gal->StrokeText( aText->GetText(), pos, orient );
485 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:190
bool IsVisible() const
Definition: eda_text.h:193
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
virtual const wxString GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:147
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:144
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:187
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:232
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
int GetPenSize() const override
Definition: lib_text.cpp:204
double GetTextAngleRadians() const
Definition: eda_text.h:184
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:279
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint Centre() const
Definition: eda_rect.h:60
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169

References EDA_RECT::Centre(), color, LIB_TEXT::GetBoundingBox(), KIGFX::RENDER_SETTINGS::GetLayerColor(), LIB_TEXT::GetPenSize(), getRenderColor(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), isUnitAndConversionShown(), EDA_TEXT::IsVisible(), LAYER_DEVICE, LAYER_HIDDEN, 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::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), and KIGFX::GAL::StrokeText().

◆ draw() [11/23]

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

Definition at line 864 of file sch_painter.cpp.

865 {
866  if( !isUnitAndConversionShown( aCurve ) )
867  return;
868 
869  if( setColors( aCurve, aLayer ) )
870  {
871  BEZIER_POLY poly ( aCurve->GetPoints() );
872  std::vector<wxPoint> pts;
873  std::deque<VECTOR2D> pts_xformed;
874  poly.GetPoly( pts );
875 
876  for( const auto &p : pts )
877  {
878  pts_xformed.push_back( mapCoords( p ) );
879  }
880 
881  m_gal->DrawPolygon( pts_xformed );
882  }
883 }
bool setColors(const LIB_ITEM *aItem, int aLayer)
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:76
static VECTOR2D mapCoords(const wxPoint &aCoord)
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

◆ draw() [12/23]

void KIGFX::SCH_PAINTER::draw ( SCH_COMPONENT aComp,
int  aLayer 
)
private

Definition at line 1081 of file sch_painter.cpp.

1082 {
1083  PART_SPTR originalPartSptr = aComp->GetPartRef().lock();
1084 
1085  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1086  LIB_PART* originalPart = originalPartSptr ? originalPartSptr.get() : dummy();
1087 
1088  // Copy the source so we can re-orient and translate it.
1089  LIB_PART tempPart( *originalPart );
1090 
1091  tempPart.SetFlags( aComp->GetFlags() );
1092 
1093  orientPart( &tempPart, aComp->GetOrientation());
1094 
1095  for( auto& tempItem : tempPart.GetDrawItems() )
1096  {
1097  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1098  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition()));
1099  }
1100 
1101  // Copy the pin info from the component to the temp pins
1102  LIB_PINS tempPins;
1103  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1104  const SCH_PINS& compPins = aComp->GetPins();
1105 
1106  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1107  {
1108  LIB_PIN* tempPin = tempPins[ i ];
1109  const SCH_PIN& compPin = compPins[ i ];
1110 
1111  tempPin->ClearFlags();
1112  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1113 
1114  if( compPin.IsDangling() )
1115  tempPin->SetFlags( IS_DANGLING );
1116  }
1117 
1118  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1119 
1120  // The fields are SCH_COMPONENT-specific and so don't need to be copied/
1121  // oriented/translated.
1122  std::vector<SCH_FIELD*> fields;
1123  aComp->GetFields( fields, false );
1124 
1125  for( SCH_FIELD* field : fields )
1126  draw( field, aLayer );
1127 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
PART_REF & GetPartRef()
int GetOrientation()
Get the display symbol orientation.
std::vector< SCH_PIN > SCH_PINS
A container for several SCH_PIN items.
Definition: sch_component.h:51
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
bool IsDangling() const override
Definition: sch_pin.h:81
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int GetUnit() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
Define a library symbol object.
static VECTOR2D mapCoords(const wxPoint &aCoord)
static void orientPart(LIB_PART *part, int orientation)
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:61
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:143
size_t i
Definition: json11.cpp:597
wxPoint GetPosition() const override
Function GetPosition.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:261

References EDA_ITEM::ClearFlags(), draw(), KIGFX::dummy(), SCH_COMPONENT::GetConvert(), LIB_PART::GetDrawItems(), SCH_COMPONENT::GetFields(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetOrientation(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetPins(), LIB_PART::GetPins(), SCH_COMPONENT::GetPosition(), SCH_COMPONENT::GetUnit(), i, IS_DANGLING, SCH_PIN::IsDangling(), KIGFX::mapCoords(), KIGFX::orientPart(), and EDA_ITEM::SetFlags().

◆ draw() [13/23]

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

Definition at line 900 of file sch_painter.cpp.

901 {
902  COLOR4D color;
903  auto conn = aJct->Connection( *g_CurrentSheet );
904 
905  if( conn && conn->IsBus() )
906  color = getRenderColor( aJct, LAYER_BUS, false );
907  else
908  color = getRenderColor( aJct, LAYER_JUNCTION, false );
909 
910  m_gal->SetIsStroke(true);
911  m_gal->SetIsFill(true);
915 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:95
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:127
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
static int GetEffectiveSymbolSize()
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, SCH_ITEM::Connection(), KIGFX::GAL::DrawCircle(), g_CurrentSheet, SCH_JUNCTION::GetEffectiveSymbolSize(), SCH_JUNCTION::GetPosition(), getRenderColor(), LAYER_BUS, LAYER_JUNCTION, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [14/23]

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

Definition at line 1130 of file sch_painter.cpp.

1131 {
1132  COLOR4D color;
1133  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1134 
1135  switch( aField->GetId() )
1136  {
1137  case REFERENCE: color = getRenderColor( aField, LAYER_REFERENCEPART, false ); break;
1138  case VALUE: color = getRenderColor( aField, LAYER_VALUEPART, false ); break;
1139  default: color = getRenderColor( aField, LAYER_FIELDS, false ); break;
1140  }
1141 
1142  if( !aField->IsVisible() )
1143  {
1146  else
1147  return;
1148  }
1149 
1150  if( aField->IsVoid() )
1151  return;
1152 
1153  // Calculate the text orientation according to the component orientation.
1154  int orient = (int) aField->GetTextAngle();
1155 
1156  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1157  {
1158  if( orient == TEXT_ANGLE_HORIZ )
1159  orient = TEXT_ANGLE_VERT;
1160  else
1161  orient = TEXT_ANGLE_HORIZ;
1162  }
1163 
1164  /* Calculate the text justification, according to the component
1165  * orientation/mirror this is a bit complicated due to cumulative
1166  * calculations:
1167  * - numerous cases (mirrored or not, rotation)
1168  * - the DrawGraphicText function recalculate also H and H justifications
1169  * according to the text orientation.
1170  * - When a component is mirrored, the text is not mirrored and
1171  * justifications are complicated to calculate
1172  * so the more easily way is to use no justifications ( Centered text )
1173  * and use GetBoundaryBox to know the text coordinate considered as centered
1174  */
1175  EDA_RECT boundaryBox = aField->GetBoundingBox();
1176  wxPoint textpos = boundaryBox.Centre();
1177  int lineWidth = aField->GetPenSize();
1178 
1182  m_gal->SetIsFill( false );
1183  m_gal->SetIsStroke( true );
1184  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1185  m_gal->SetFontBold( aField->IsBold() );
1186  m_gal->SetFontItalic( aField->IsItalic() );
1187  m_gal->SetTextMirrored( aField->IsMirrored() );
1188  m_gal->SetLineWidth( lineWidth );
1189  m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI/2 : 0 );
1190 
1191  // Draw the umbilical line
1192  if( aField->IsMoving() )
1193  {
1195  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1196  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1197  }
1198 }
#define TEXT_ANGLE_HORIZ
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:190
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_field.cpp:135
bool IsMirrored() const
Definition: eda_text.h:196
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
#define TEXT_ANGLE_VERT
bool IsVisible() const
Definition: eda_text.h:193
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
bool IsMoving() const
Definition: base_struct.h:224
int color
Definition: DXF_plotter.cpp:62
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
double GetTextAngle() const
Definition: eda_text.h:181
int GetId() const
Definition: sch_field.h:105
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
Field Reference of part, i.e. "IC21".
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:299
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:187
int y1
Definition: transform.h:49
void SetFontBold(const bool aBold)
Set bold property of current font.
#define VALUE
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
TRANSFORM & GetTransform() const
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:232
EDA_ITEM * GetParent() const
Definition: base_struct.h:214
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:236
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:80
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
wxPoint GetPosition() const override
Function GetPosition.
wxPoint Centre() const
Definition: eda_rect.h:60
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References EDA_RECT::Centre(), color, KIGFX::GAL::DrawLine(), SCH_FIELD::GetBoundingBox(), SCH_FIELD::GetFullyQualifiedText(), SCH_FIELD::GetId(), KIGFX::RENDER_SETTINGS::GetLayerColor(), EDA_ITEM::GetParent(), SCH_FIELD::GetPenSize(), SCH_COMPONENT::GetPosition(), getRenderColor(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), SCH_COMPONENT::GetTransform(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_ITEM::IsMoving(), EDA_TEXT::IsVisible(), SCH_FIELD::IsVoid(), LAYER_FIELDS, LAYER_HIDDEN, LAYER_REFERENCEPART, LAYER_VALUEPART, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, REFERENCE, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), KIGFX::GAL::StrokeText(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, VALUE, and TRANSFORM::y1.

◆ draw() [15/23]

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

Definition at line 986 of file sch_painter.cpp.

987 {
988  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
989  COLOR4D color;
990 
991  switch( aText->Type() )
992  {
993  case SCH_SHEET_PIN_T: color = getRenderColor( aText, LAYER_SHEETLABEL, false ); break;
994  case SCH_HIER_LABEL_T: color = getRenderColor( aText, LAYER_HIERLABEL, false ); break;
995  case SCH_GLOBAL_LABEL_T: color = getRenderColor( aText, LAYER_GLOBLABEL, false ); break;
996  case SCH_LABEL_T: color = getRenderColor( aText, LAYER_LOCLABEL, false ); break;
997  default: color = getRenderColor( aText, LAYER_NOTES, false ); break;
998  }
999 
1000  if( conn && conn->IsBus() )
1001  color = getRenderColor( aText, LAYER_BUS, false );
1002 
1003  if( !aText->IsVisible() )
1004  {
1007  else
1008  return;
1009  }
1010 
1012 
1013  if( aText->IsDangling() )
1014  drawDanglingSymbol( m_gal, aText->GetTextPos() );
1015 
1016  wxPoint text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1017  int linewidth = aText->GetPenSize();
1018  wxString shownText( aText->GetShownText() );
1019 
1020  if( !shownText.IsEmpty() )
1021  {
1022  m_gal->SetIsFill( false );
1023  m_gal->SetIsStroke( true );
1024  m_gal->SetTextAttributes( aText );
1025  m_gal->SetLineWidth( linewidth );
1026  m_gal->StrokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1027  }
1028 }
bool IsDangling() const override
Definition: sch_text.h:177
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_text.cpp:297
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
bool IsVisible() const
Definition: eda_text.h:193
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:145
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:127
double GetTextAngleRadians() const
Definition: eda_text.h:184
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).
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:152
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
static void drawDanglingSymbol(GAL *aGal, const wxPoint &aPos)
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, SCH_ITEM::Connection(), KIGFX::drawDanglingSymbol(), g_CurrentSheet, KIGFX::RENDER_SETTINGS::GetLayerColor(), SCH_TEXT::GetPenSize(), getRenderColor(), SCH_TEXT::GetSchematicTextOffset(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), SCH_CONNECTION::IsBus(), SCH_TEXT::IsDangling(), EDA_TEXT::IsVisible(), LAYER_BUS, LAYER_GLOBLABEL, LAYER_HIDDEN, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, LAYER_SHEETLABEL, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), KIGFX::GAL::StrokeText(), and EDA_ITEM::Type().

◆ draw() [16/23]

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

Definition at line 1226 of file sch_painter.cpp.

1227 {
1228  auto color = getRenderColor( aLabel, LAYER_SHEETLABEL, false );
1230  int width = aLabel->GetThickness() ? aLabel->GetThickness() : GetDefaultLineThickness();
1231 
1232  auto conn = aLabel->Connection( *g_CurrentSheet );
1233 
1234  if( conn && conn->IsBus() )
1235  color = getRenderColor( aLabel, LAYER_BUS, false );
1236 
1237  std::vector<wxPoint> pts;
1238  std::deque<VECTOR2D> pts2;
1239 
1240  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1241 
1242  for( auto p : pts )
1243  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1244 
1245  m_gal->SetIsFill( true );
1246  m_gal->SetFillColor( back_color );
1247  m_gal->SetIsStroke( true );
1248  m_gal->SetLineWidth( width );
1250  m_gal->DrawPolyline( pts2 );
1251 
1252  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1253 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:127
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1072
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169

References color, SCH_ITEM::Connection(), SCH_HIERLABEL::CreateGraphicShape(), draw(), KIGFX::GAL::DrawPolyline(), g_CurrentSheet, GetDefaultLineThickness(), KIGFX::RENDER_SETTINGS::GetLayerColor(), getRenderColor(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetThickness(), LAYER_BUS, LAYER_SCHEMATIC_BACKGROUND, LAYER_SHEETLABEL, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [17/23]

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

Definition at line 1201 of file sch_painter.cpp.

1202 {
1203  auto color = getRenderColor( aLabel, LAYER_GLOBLABEL, false );
1205  int width = aLabel->GetThickness() ? aLabel->GetThickness() : GetDefaultLineThickness();
1206 
1207  std::vector<wxPoint> pts;
1208  std::deque<VECTOR2D> pts2;
1209 
1210  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1211 
1212  for( auto p : pts )
1213  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1214 
1215  m_gal->SetIsFill( true );
1216  m_gal->SetFillColor( back_color );
1217  m_gal->SetIsStroke( true );
1218  m_gal->SetLineWidth( width );
1220  m_gal->DrawPolyline( pts2 );
1221 
1222  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1223 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:832
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169

References color, SCH_GLOBALLABEL::CreateGraphicShape(), draw(), KIGFX::GAL::DrawPolyline(), GetDefaultLineThickness(), KIGFX::RENDER_SETTINGS::GetLayerColor(), getRenderColor(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetThickness(), LAYER_GLOBLABEL, LAYER_SCHEMATIC_BACKGROUND, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [18/23]

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

Definition at line 1255 of file sch_painter.cpp.

1256 {
1257  VECTOR2D pos = aSheet->GetPosition();
1258  VECTOR2D size = aSheet->GetSize();
1259 
1260  if( aLayer == LAYER_SHEET_BACKGROUND )
1261  {
1262  m_gal->SetIsStroke( false );
1263 
1264  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1265  {
1266  // Select a fill color working well with black and white background color,
1267  // both in Opengl and Cairo
1268  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1269  m_gal->SetIsFill( true );
1270  }
1271  else
1272  {
1273  // Could be modified later, when sheets can have their own fill color
1274  return;
1275  }
1276 
1277  m_gal->DrawRectangle( pos, pos + size );
1278  }
1279  else if( aLayer == LAYER_SHEET )
1280  {
1281  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, false ) );
1282  m_gal->SetIsStroke( true );
1283 
1284  m_gal->SetIsFill( false );
1285  m_gal->SetLineWidth( aSheet->GetPenSize() );
1286 
1287  m_gal->DrawRectangle( pos, pos + size );
1288 
1289  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1290  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1291  double nameAngle = 0.0;
1292 
1293  if( aSheet->IsVerticalOrientation() )
1294  nameAngle = -M_PI/2;
1295 
1296  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, false ) );
1297 
1298  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1299 
1302 
1303  auto txtSize = aSheet->GetSheetNameSize();
1304 
1305  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1306  m_gal->SetFontBold( false );
1307  m_gal->SetFontItalic( false );
1308 
1309  m_gal->StrokeText( text, pos_sheetname, nameAngle );
1310 
1311  txtSize = aSheet->GetFileNameSize();
1312  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1315 
1316  text = wxT( "File: " ) + aSheet->GetFileName();
1317  m_gal->StrokeText( text, pos_filename, nameAngle );
1318  }
1319  else if( aLayer == LAYER_HIERLABEL )
1320  {
1321  for( auto& sheetPin : aSheet->GetPins() )
1322  {
1323  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset
1324  // of width / 2
1325  int width = aSheet->GetPenSize();
1326  wxPoint initial_pos = sheetPin.GetTextPos();
1327  wxPoint offset_pos = initial_pos;
1328 
1329  switch( sheetPin.GetEdge() )
1330  {
1331  case SCH_SHEET_PIN::SHEET_TOP_SIDE: offset_pos.y -= width / 2; break;
1332  case SCH_SHEET_PIN::SHEET_BOTTOM_SIDE: offset_pos.y += width / 2; break;
1333  case SCH_SHEET_PIN::SHEET_RIGHT_SIDE: offset_pos.x -= width / 2; break;
1334  case SCH_SHEET_PIN::SHEET_LEFT_SIDE: offset_pos.x += width / 2; break;
1335  default: break;
1336  }
1337 
1338  sheetPin.SetTextPos( offset_pos );
1339  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1340  m_gal->DrawLine( offset_pos, initial_pos );
1341  sheetPin.SetTextPos( initial_pos );
1342  }
1343  }
1344 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
SCH_SHEET_PINS & GetPins()
Definition: sch_sheet.h:322
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
bool IsMoving() const
Definition: base_struct.h:224
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_sheet.cpp:383
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetFileNameSize() const
Definition: sch_sheet.h:265
void SetFontBold(const bool aBold)
Set bold property of current font.
int GetSheetNameSize() const
Definition: sch_sheet.h:262
wxString GetName() const
Definition: sch_sheet.h:259
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:530
wxPoint GetFileNamePosition()
Definition: sch_sheet.cpp:408
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:627
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:221
wxPoint GetSheetNamePosition()
Definition: sch_sheet.cpp:389
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void draw(LIB_RECTANGLE *aRect, int aLayer)
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxSize GetSize()
Definition: sch_sheet.h:270
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References draw(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), SCH_SHEET::GetFileName(), SCH_SHEET::GetFileNamePosition(), SCH_SHEET::GetFileNameSize(), SCH_SHEET::GetName(), SCH_SHEET::GetPenSize(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), getRenderColor(), SCH_SHEET::GetSheetNamePosition(), SCH_SHEET::GetSheetNameSize(), SCH_SHEET::GetSize(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_ITEM::IsMoving(), SCH_SHEET::IsVerticalOrientation(), LAYER_HIERLABEL, LAYER_SHEET, LAYER_SHEET_BACKGROUND, LAYER_SHEETFILENAME, LAYER_SHEETNAME, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), SCH_SHEET_PIN::SHEET_BOTTOM_SIDE, SCH_SHEET_PIN::SHEET_LEFT_SIDE, SCH_SHEET_PIN::SHEET_RIGHT_SIDE, SCH_SHEET_PIN::SHEET_TOP_SIDE, and KIGFX::GAL::StrokeText().

◆ draw() [19/23]

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

Definition at line 1347 of file sch_painter.cpp.

1348 {
1349  int delta = aNC->GetSize() / 2;
1350  int width = GetDefaultLineThickness();
1351 
1352  COLOR4D color = getRenderColor( aNC, LAYER_NOCONNECT, false );
1353 
1355  m_gal->SetIsStroke( true );
1356  m_gal->SetIsFill( false );
1357  m_gal->SetLineWidth( width );
1358 
1359  VECTOR2D p = aNC->GetPosition();
1360 
1361  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1362  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1363 }
wxPoint GetPosition() const override
Function GetPosition.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
static const int delta[8][2]
Definition: solve.cpp:112
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetSize() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, delta, KIGFX::GAL::DrawLine(), GetDefaultLineThickness(), SCH_NO_CONNECT::GetPosition(), getRenderColor(), SCH_NO_CONNECT::GetSize(), LAYER_NOCONNECT, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [20/23]

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

Definition at line 1411 of file sch_painter.cpp.

1412 {
1413  SHAPE_LINE_CHAIN polygon;
1414  aMarker->ShapeToPolygon( polygon );
1415 
1417  : LAYER_ERC_WARN;
1418  COLOR4D color = getRenderColor( aMarker, layer, false );
1419 
1420  m_gal->Save();
1421  m_gal->Translate( aMarker->GetPosition() );
1422  m_gal->SetFillColor( color );
1423  m_gal->SetIsFill( true );
1424  m_gal->SetIsStroke( false );
1425  m_gal->DrawPolygon( polygon );
1426  m_gal->Restore();
1427 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:175
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_marker.h:93
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Class SHAPE_LINE_CHAIN.
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, KIGFX::GAL::DrawPolygon(), MARKER_BASE::GetErrorLevel(), SCH_MARKER::GetPosition(), getRenderColor(), LAYER_ERC_ERR, LAYER_ERC_WARN, KIGFX::PAINTER::m_gal, MARKER_BASE::MARKER_SEVERITY_ERROR, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), MARKER_BASE::ShapeToPolygon(), and KIGFX::GAL::Translate().

◆ draw() [21/23]

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

Definition at line 1393 of file sch_painter.cpp.

1394 {
1395  m_gal->Save();
1396  m_gal->Translate( aBitmap->GetPosition() );
1397 
1398  // When the image scale factor is not 1.0, we need to modify the actual
1399  // as the image scale factor is similar to a local zoom
1400  double img_scale = aBitmap->GetImageScale();
1401 
1402  if( img_scale != 1.0 )
1403  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1404 
1405  m_gal->DrawBitmap( *aBitmap->GetImage() );
1406 
1407  m_gal->Restore();
1408 }
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:152
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:65
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void Restore()
Restore the context.
double GetImageScale() const
Definition: sch_bitmap.h:94
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.

References KIGFX::GAL::DrawBitmap(), SCH_BITMAP::GetImage(), SCH_BITMAP::GetImageScale(), SCH_BITMAP::GetPosition(), KIGFX::PAINTER::m_gal, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::Scale(), and KIGFX::GAL::Translate().

◆ draw() [22/23]

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

Definition at line 918 of file sch_painter.cpp.

919 {
920  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), false );
921 
922  int width = aLine->GetPenSize();
923 
924  m_gal->SetIsStroke( true );
926  m_gal->SetLineWidth( width );
927 
928  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID )
929  {
930  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
931  }
932  else
933  {
934  VECTOR2D start = aLine->GetStartPoint();
935  VECTOR2D end = aLine->GetEndPoint();
936 
937  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
938  clip.Normalize();
939 
940  double theta = atan2( end.y - start.y, end.x - start.x );
941  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
942 
943  switch( aLine->GetLineStyle() )
944  {
945  default:
946  case PLOTDASHTYPE_DASH:
947  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
948  break;
949  case PLOTDASHTYPE_DOT:
950  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
951  break;
953  strokes[0] = DASH_MARK_LEN( width );
954  strokes[2] = DOT_MARK_LEN( width );
955  break;
956  }
957 
958  for( size_t i = 0; i < 10000; ++i )
959  {
960  // Calculations MUST be done in doubles to keep from accumulating rounding
961  // errors as we go.
962  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
963  start.y + strokes[ i % 4 ] * sin( theta ) );
964 
965  // Drawing each segment can be done rounded to ints.
966  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
967  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
968 
969  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
970  break;
971  else if( i % 2 == 0 )
972  m_gal->DrawLine( segStart, segEnd );
973 
974  start = next;
975  }
976  }
977 
978  if( aLine->IsStartDangling() )
980 
981  if( aLine->IsEndDangling() )
983 }
CITER next(CITER it)
Definition: ptree.cpp:130
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
wxPoint GetStartPoint() const
Definition: sch_line.h:90
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
#define DASH_MARK_LEN(aLineWidth)
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:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsEndDangling() const
Definition: sch_line.h:174
#define DOT_MARK_LEN(aLineWidth)
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:193
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.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsStartDangling() const
Definition: sch_line.h:173
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define DASH_GAP_LEN(aLineWidth)
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_line.cpp:310
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetLineStyle() const
Definition: sch_line.cpp:283
static void drawDanglingSymbol(GAL *aGal, const wxPoint &aPos)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References ClipLine(), color, DASH_GAP_LEN, DASH_MARK_LEN, DOT_MARK_LEN, KIGFX::drawDanglingSymbol(), KIGFX::GAL::DrawLine(), SCH_LINE::GetEndPoint(), SCH_ITEM::GetLayer(), SCH_LINE::GetLineStyle(), SCH_LINE::GetPenSize(), getRenderColor(), SCH_LINE::GetStartPoint(), i, SCH_LINE::IsEndDangling(), SCH_LINE::IsStartDangling(), KiROUND(), KIGFX::PAINTER::m_gal, next(), EDA_RECT::Normalize(), PLOTDASHTYPE_DASH, PLOTDASHTYPE_DASHDOT, PLOTDASHTYPE_DOT, PLOTDASHTYPE_SOLID, KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [23/23]

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

Definition at line 1366 of file sch_painter.cpp.

1367 {
1368  COLOR4D color = aEntry->Type() == SCH_BUS_BUS_ENTRY_T
1369  ? getRenderColor( aEntry, LAYER_BUS, false )
1370  : getRenderColor( aEntry, LAYER_WIRE, false );
1371 
1373  m_gal->SetIsStroke( true );
1374  m_gal->SetLineWidth( aEntry->GetPenSize() );
1375  m_gal->SetIsFill( false );
1376 
1377  VECTOR2D pos = aEntry->GetPosition();
1378  VECTOR2D endPos = aEntry->m_End();
1379 
1380  m_gal->DrawLine( pos, endPos );
1381 
1382  // Draw dangling symbols:
1383  m_gal->SetLineWidth ( 1.0 );
1384 
1385  if( aEntry->IsDanglingStart() )
1387 
1388  if( aEntry->IsDanglingEnd() )
1390 }
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:35
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
int color
Definition: DXF_plotter.cpp:62
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:52
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual int GetPenSize() const
Function GetPenSize virtual pure.
Definition: sch_item.h:212
bool IsDanglingStart() const
Definition: sch_bus_entry.h:51
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint m_End() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetPosition() const override
Function GetPosition.

References color, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), SCH_ITEM::GetPenSize(), SCH_BUS_ENTRY_BASE::GetPosition(), getRenderColor(), SCH_BUS_ENTRY_BASE::IsDanglingEnd(), SCH_BUS_ENTRY_BASE::IsDanglingStart(), LAYER_BUS, LAYER_WIRE, SCH_BUS_ENTRY_BASE::m_End(), KIGFX::PAINTER::m_gal, SCH_BUS_BUS_ENTRY_T, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), TARGET_BUSENTRY_RADIUS, and EDA_ITEM::Type().

◆ getRenderColor()

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

Definition at line 226 of file sch_painter.cpp.

227 {
228  if( aItem->IsBrightened() )
230 
231  const SCH_LINE* line = dynamic_cast<const SCH_LINE*>( aItem );
232  COLOR4D color = line ? line->GetLineColor() : m_schSettings.GetLayerColor( aLayer );
233 
234  if( aItem->IsSelected() )
235  {
236  return color.Brightened( 0.5 );
237  }
238  else if( aItem->IsHighlighted() )
239  {
240  if ( aOnBackgroundLayer )
241  return COLOR4D( color.GetBrightness(), 0.0, 0.0, 0.3 );
242  else
243  return COLOR4D( 1.0, 0.3, 0.3, 1.0 );
244  }
245 
246  return color;
247 }
COLOR4D GetLineColor() const
Definition: sch_line.cpp:257
bool IsSelected() const
Definition: base_struct.h:227
int color
Definition: DXF_plotter.cpp:62
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
bool IsBrightened() const
Definition: base_struct.h:230
bool IsHighlighted() const
Definition: base_struct.h:229
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, KIGFX::RENDER_SETTINGS::GetLayerColor(), SCH_LINE::GetLineColor(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsHighlighted(), EDA_ITEM::IsSelected(), LAYER_BRIGHTENED, and m_schSettings.

Referenced by draw(), and setColors().

◆ GetSettings()

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

Function GetSettings Returns pointer to current settings that are going to be used when drawing items.

Returns
Current rendering settings.

Implements KIGFX::PAINTER.

Definition at line 131 of file sch_painter.h.

132  {
133  return &m_schSettings;
134  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169

References m_schSettings.

◆ isUnitAndConversionShown()

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

Definition at line 206 of file sch_painter.cpp.

207 {
208  if( m_schSettings.m_ShowUnit // showing a specific unit
209  && aItem->GetUnit() // item is unit-specific
210  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
211  {
212  return false;
213  }
214 
215  if( m_schSettings.m_ShowConvert // showing a specific conversion
216  && aItem->GetConvert() // item is conversion-specific
217  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
218  {
219  return false;
220  }
221 
222  return true;
223 }
int GetUnit() const
int GetConvert() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:169

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().

◆ setColors()

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

Definition at line 307 of file sch_painter.cpp.

308 {
309  if( aLayer == LAYER_DEVICE_BACKGROUND && aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
310  {
312 
313  // These actions place the item over others, so allow a modest transparency here
314  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
315  color = color.WithAlpha( 0.75 );
316 
317  m_gal->SetIsFill( true );
319 
320  m_gal->SetIsStroke( false );
321  return true;
322  }
323  else if( aLayer == LAYER_DEVICE )
324  {
325  COLOR4D color = getRenderColor( aItem, LAYER_DEVICE, false );
326 
328  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
330 
331  if( aItem->GetPenSize() > 0 )
332  {
333  m_gal->SetIsStroke( true );
334  m_gal->SetLineWidth( aItem->GetPenSize() );
335  }
336  else
337  m_gal->SetIsStroke( false );
338 
339  return true;
340  }
341 
342  return false;
343 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aOnBackgroundLayer)
bool IsMoving() const
Definition: base_struct.h:224
int color
Definition: DXF_plotter.cpp:62
FILL_T GetFillMode() const
bool IsDragging() const
Definition: base_struct.h:225
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool IsResized() const
Definition: base_struct.h:228
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual int GetPenSize() const =0
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, LIB_ITEM::GetFillMode(), LIB_ITEM::GetPenSize(), getRenderColor(), EDA_ITEM::IsDragging(), EDA_ITEM::IsMoving(), EDA_ITEM::IsResized(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, KIGFX::PAINTER::m_gal, 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

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

Parameters
aGalis the new GAL instance.

Definition at line 328 of file painter.h.

329  {
330  m_gal = aGal;
331  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360

References KIGFX::PAINTER::m_gal.

◆ triLine()

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

Definition at line 300 of file sch_painter.cpp.

301 {
302  m_gal->DrawLine( a, b );
303  m_gal->DrawLine( b, c );
304 }
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:360

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

Referenced by draw().

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 363 of file painter.h.

◆ m_gal

GAL* KIGFX::PAINTER::m_gal
protectedinherited

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

DrawLine, DrawCircle, etc.)

Definition at line 360 of file painter.h.

Referenced by Draw(), draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawApertureMacro(), KIGFX::GERBVIEW_PAINTER::drawFlashedShape(), KIGFX::GERBVIEW_PAINTER::drawPolygon(), setColors(), KIGFX::PAINTER::SetGAL(), and triLine().

◆ m_schSettings

SCH_RENDER_SETTINGS KIGFX::SCH_PAINTER::m_schSettings
private

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