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, bool aIsDangling=true, bool isMoving=false)
 
void draw (LIB_CIRCLE *aCircle, int aLayer)
 
void draw (LIB_ITEM *, int aLayer)
 
void draw (LIB_PART *aComp, int, bool aDrawFields=true, int aUnit=0, int aConvert=0, std::vector< bool > *aDanglingPinFlags=nullptr)
 
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_LABEL *aLabel, 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)
 
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 113 of file sch_painter.h.

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 154 of file sch_painter.cpp.

154  :
155  KIGFX::PAINTER (aGal)
156 { }
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 122 of file sch_painter.h.

123  {
124  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
125  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166

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 163 of file sch_painter.cpp.

164 {
165  auto item2 = static_cast<const EDA_ITEM*>( aItem );
166  auto item = const_cast<EDA_ITEM*>( item2 );
167 
169 
170  switch( item->Type() )
171  {
197 
198  default: return false;
199  }
200 
201  return false;
202 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:56
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
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
Define a library symbol object.
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:209
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:41
#define HANDLE_ITEM(type_id, type_name)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:70
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: sch_painter.cpp:77
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:39

References 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, 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_HIERARCHICAL_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, and SCH_TEXT_T.

Referenced by draw().

◆ draw() [1/24]

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

Definition at line 340 of file sch_painter.cpp.

341 {
342  if( !isUnitAndConversionShown( aRect ) )
343  return;
344 
345  if( setColors( aRect, aLayer ) )
346  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
347 
348 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool setColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetEnd() const
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:91

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

Referenced by draw().

◆ draw() [2/24]

void KIGFX::SCH_PAINTER::draw ( LIB_PIN aPin,
int  aLayer,
bool  aIsDangling = true,
bool  isMoving = false 
)
private

Definition at line 509 of file sch_painter.cpp.

510 {
511  if( aLayer != LAYER_DEVICE )
512  return;
513 
514  if( !isUnitAndConversionShown( aPin ) )
515  return;
516 
517  if( aPin->IsMoving() )
518  isMoving = true;
519 
520  VECTOR2I pos = mapCoords( aPin->GetPosition() );
521 
523 
524  if( !aPin->IsVisible() )
525  {
527  {
529  }
530  else
531  {
532  if( aIsDangling && aPin->IsPowerConnection() )
534 
535  return;
536  }
537  }
538 
539  VECTOR2I p0, dir;
540  int len = aPin->GetLength();
541  int width = aPin->GetPenSize();
542  int shape = aPin->GetShape();
543  int orient = aPin->GetOrientation();
544 
545  switch( orient )
546  {
547  case PIN_UP:
548  p0 = VECTOR2I( pos.x, pos.y - len );
549  dir = VECTOR2I(0, 1);
550  break;
551  case PIN_DOWN:
552  p0 = VECTOR2I( pos.x, pos.y + len );
553  dir = VECTOR2I(0, -1);
554  break;
555  case PIN_LEFT:
556  p0 = VECTOR2I( pos.x - len, pos.y );
557  dir = VECTOR2I(1, 0);
558  break;
559  case PIN_RIGHT:
560  p0 = VECTOR2I( pos.x + len, pos.y );
561  dir = VECTOR2I(-1, 0);
562  break;
563  }
564 
565  VECTOR2D pc;
566 
567  m_gal->SetIsStroke( true );
568  m_gal->SetIsFill( false );
569  m_gal->SetLineWidth( width );
571  m_gal->SetFontBold( false );
572  m_gal->SetFontItalic( false );
573 
574  const int radius = ExternalPinDecoSize( *aPin );
575  const int diam = radius*2;
576  const int clock_size = InternalPinDecoSize( *aPin );
577 
578  if( shape == PINSHAPE_INVERTED )
579  {
580  m_gal->DrawCircle( p0 + dir * radius, radius );
581  m_gal->DrawLine( p0 + dir * ( diam ), pos );
582  }
583  else if( shape == PINSHAPE_FALLING_EDGE_CLOCK )
584  {
585  pc = p0 + dir * clock_size ;
586 
587  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
588  pc,
589  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
590 
591  m_gal->DrawLine( pos, pc );
592  }
593  else
594  {
595  m_gal->DrawLine( p0, pos );
596  }
597 
598  if( shape == PINSHAPE_CLOCK )
599  {
600  if (!dir.y)
601  {
602  triLine( p0 + VECTOR2D( 0, clock_size ),
603  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
604  p0 + VECTOR2D( 0, -clock_size ) );
605  }
606  else
607  {
608  triLine( p0 + VECTOR2D( clock_size, 0 ),
609  p0 + VECTOR2D( 0, -dir.y * clock_size ),
610  p0 + VECTOR2D( -clock_size, 0 ) );
611  }
612  }
613 
614  if( shape == PINSHAPE_INPUT_LOW )
615  {
616  if(!dir.y)
617  {
618  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
619  p0 + VECTOR2D(dir.x, -1) * diam,
620  p0 );
621  }
622  else /* MapX1 = 0 */
623  {
624  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
625  p0 + VECTOR2D(-1, dir.y) * diam,
626  p0 );
627  }
628  }
629 
630  if( shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
631  {
632  if( !dir.y ) // Horizontal pin
633  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
634  else // Vertical pin
635  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
636  }
637 
638  if( shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
639  {
640  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
641  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
642  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
643  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
644  }
645 
646  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
647  {
648  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
649  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
650  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
651  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
652 
653  aIsDangling = false; // PIN_NC pin type is always not connected and dangling.
654  }
655 
656  if( aIsDangling && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
658 
659  // Draw the labels
660 
661  LIB_PART* libEntry = aPin->GetParent();
662  int textOffset = libEntry->GetPinNameOffset();
663 
664  int nameLineWidth = aPin->GetPenSize();
665  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
666  int numLineWidth = aPin->GetPenSize();
667  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
668 
669  #define PIN_TEXT_MARGIN 4
670 
671  // Four locations around a pin where text can be drawn
672  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
673  int size[4] = { 0, 0, 0, 0 };
674  int thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
675  COLOR4D colour[4];
676  wxString text[4];
677 
678  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
679  if( textOffset )
680  {
681  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
682  thickness[INSIDE] = nameLineWidth;
684  text [INSIDE] = aPin->GetName();
685 
686  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
687  thickness[ABOVE] = numLineWidth;
688  colour [ABOVE] = m_schSettings.GetLayerColor( LAYER_PINNUM );
689  text [ABOVE] = aPin->GetNumber();
690  }
691  // Otherwise pin NAMES go above and pin NUMBERS go below
692  else
693  {
694  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
695  thickness[ABOVE] = nameLineWidth;
696  colour [ABOVE] = m_schSettings.GetLayerColor( LAYER_PINNAM );
697  text [ABOVE] = aPin->GetName();
698 
699  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
700  thickness[BELOW] = numLineWidth;
701  colour [BELOW] = m_schSettings.GetLayerColor( LAYER_PINNUM );
702  text [BELOW] = aPin->GetNumber();
703  }
704 
706  {
707  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
708  thickness[OUTSIDE] = size[OUTSIDE] / 6;
710  text [OUTSIDE] = aPin->GetElectricalTypeName();
711  }
712 
713  if( !aPin->IsVisible() )
714  {
715  for( COLOR4D& c : colour )
717  }
718  else if( isMoving )
719  {
720  for( COLOR4D& c : colour )
721  c = getOverlayColor( aPin, c, false );
722  }
723 
724  int insideOffset = textOffset;
725  int outsideOffset = 10;
726  int aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + GetDefaultLineThickness() ) / 2;
727  int belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + GetDefaultLineThickness() ) / 2;
728 
729  #define SET_DC( i ) \
730  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
731  m_gal->SetLineWidth( thickness[i] ); \
732  m_gal->SetStrokeColor( colour[i] );
733 
734  switch( orient )
735  {
736  case PIN_LEFT:
737  if( size[INSIDE] )
738  {
739  SET_DC( INSIDE );
742  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
743  }
744  if( size[OUTSIDE] )
745  {
746  SET_DC( OUTSIDE );
749  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
750  }
751  if( size[ABOVE] )
752  {
753  SET_DC( ABOVE );
756  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
757  }
758  if( size[BELOW] )
759  {
760  SET_DC( BELOW );
763  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
764  }
765  break;
766 
767  case PIN_RIGHT:
768  if( size[INSIDE] )
769  {
770  SET_DC( INSIDE );
774  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
775  }
776  if( size[OUTSIDE] )
777  {
778  SET_DC( OUTSIDE );
781  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
782  }
783  if( size[ABOVE] )
784  {
785  SET_DC( ABOVE );
788  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
789  }
790  if( size[BELOW] )
791  {
792  SET_DC( BELOW );
795  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
796  }
797  break;
798 
799  case PIN_DOWN:
800  if( size[INSIDE] )
801  {
802  SET_DC( INSIDE );
805  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2);
806  }
807  if( size[OUTSIDE] )
808  {
809  SET_DC( OUTSIDE );
812  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2);
813  }
814  if( size[ABOVE] )
815  {
816  SET_DC( ABOVE );
819  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
820  }
821  if( size[BELOW] )
822  {
823  SET_DC( BELOW );
826  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
827  }
828  break;
829 
830  case PIN_UP:
831  if( size[INSIDE] )
832  {
833  SET_DC( INSIDE );
836  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2);
837  }
838  if( size[OUTSIDE] )
839  {
840  SET_DC( OUTSIDE );
843  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2);
844  }
845  if( size[ABOVE] )
846  {
847  SET_DC( ABOVE );
850  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
851  }
852  if( size[BELOW] )
853  {
854  SET_DC( BELOW );
857  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
858  }
859  break;
860 
861  default:
862  wxFAIL_MSG( "Unknown pin orientation" );
863  }
864 }
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:221
LIB_PART * GetParent() const
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:235
bool IsMoving() const
Definition: base_struct.h:221
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:368
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:564
void SetFontBold(const bool aBold)
Set bold property of current font.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
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:275
const wxString & GetName() const
Definition: lib_pin.h:166
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:362
int GetNameTextSize() const
Definition: lib_pin.h:192
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:463
const wxString & GetNumber() const
Definition: lib_pin.h:194
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:251
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:219
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 SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
#define INSIDE
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define PIN_TEXT_MARGIN
int GetLength()
Definition: lib_pin.h:301
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References Clamp_Text_PenSize(), color, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), KIGFX::drawPinDanglingSymbol(), KIGFX::ExternalPinDecoSize(), GetDefaultLineThickness(), LIB_PIN::GetElectricalTypeName(), KIGFX::RENDER_SETTINGS::GetLayerColor(), LIB_PIN::GetLength(), LIB_PIN::GetName(), LIB_PIN::GetNameTextSize(), LIB_PIN::GetNumber(), LIB_PIN::GetNumberTextSize(), LIB_PIN::GetOrientation(), KIGFX::getOverlayColor(), LIB_ITEM::GetParent(), LIB_PIN::GetPenSize(), LIB_PART::GetPinNameOffset(), LIB_PIN::GetPosition(), 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(), EDA_ITEM::IsMoving(), 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/24]

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

Definition at line 351 of file sch_painter.cpp.

352 {
353  if( !isUnitAndConversionShown( aCircle ) )
354  return;
355 
356  if( setColors( aCircle, aLayer ) )
357  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
358 }
bool setColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_circle.h:86
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:103
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/24]

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

◆ draw() [5/24]

void KIGFX::SCH_PAINTER::draw ( LIB_PART aComp,
int  aLayer,
bool  aDrawFields = true,
int  aUnit = 0,
int  aConvert = 0,
std::vector< bool > *  aDanglingPinFlags = nullptr 
)
private

Definition at line 225 of file sch_painter.cpp.

227 {
228  if( !aUnit )
229  aUnit = m_schSettings.m_ShowUnit;
230 
231  if( !aConvert )
232  aConvert = m_schSettings.m_ShowConvert;
233 
234  size_t pinIndex = 0;
235 
236  for( auto& item : aComp->GetDrawItems() )
237  {
238  if( !aDrawFields && item.Type() == LIB_FIELD_T )
239  continue;
240 
241  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
242  continue;
243 
244  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
245  continue;
246 
247  if( item.Type() == LIB_PIN_T )
248  {
249  auto pin = static_cast<LIB_PIN*>( &item );
250  bool dangling = true;
251 
252  if( aDanglingPinFlags && pinIndex < aDanglingPinFlags->size() )
253  dangling = (*aDanglingPinFlags)[ pinIndex ];
254 
255  draw( pin, aLayer, dangling, aComp->IsMoving() );
256  pinIndex++;
257  }
258  else
259  Draw( &item, aLayer );
260  }
261 }
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...
bool IsMoving() const
Definition: base_struct.h:221
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
void draw(LIB_RECTANGLE *aRect, int aLayer)
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166

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

◆ draw() [6/24]

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

Definition at line 264 of file sch_painter.cpp.

265 {
266  LIB_PART* comp = aAlias->GetPart();
267 
268  draw( comp, aLayer, false );
269 
270  LIB_FIELDS fields;
271  comp->GetFields( fields );
272 
273  if( !aAlias->IsRoot() )
274  {
275  fields[ VALUE ].SetText( aAlias->GetName() );
276  fields[ DATASHEET ].SetText( aAlias->GetDocFileName() );
277  }
278 
279  for( LIB_FIELD& field : fields )
280  draw( &field, aLayer );
281 }
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:259
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/24]

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

Definition at line 361 of file sch_painter.cpp.

362 {
363  if( !isUnitAndConversionShown( aArc ) )
364  return;
365 
366  int sai = aArc->GetFirstRadiusAngle();
367  int eai = aArc->GetSecondRadiusAngle();
368 
369  if( TRANSFORM().MapAngles( &sai, &eai ) )
370  std::swap( sai, eai );
371 
372  double sa = (double) sai * M_PI / 1800.0;
373  double ea = (double) eai * M_PI / 1800.0 ;
374 
375  VECTOR2D pos = mapCoords( aArc->GetPosition() );
376 
377  if( setColors( aArc, aLayer ) )
378  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
379 }
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:146
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:138
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
int GetFirstRadiusAngle() const
Definition: lib_arc.h:142
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_arc.h:121

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/24]

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

Definition at line 382 of file sch_painter.cpp.

383 {
384  if( !isUnitAndConversionShown( aLine ) )
385  return;
386 
387  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
388  std::deque<VECTOR2D> vtx;
389 
390  for( auto p : pts )
391  vtx.push_back( mapCoords( p ) );
392 
393  if( setColors( aLine, aLayer ) )
394  m_gal->DrawPolygon( vtx );
395 }
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:68
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/24]

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

Definition at line 398 of file sch_painter.cpp.

399 {
400  // Must check layer as fields are sometimes drawn by their parent rather than
401  // directly from the view.
402  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS], layers_count;
403  aField->ViewGetLayers( layers, layers_count );
404 
405  if( aLayer != layers[0] )
406  return;
407 
408  if( !isUnitAndConversionShown( aField ) )
409  return;
410 
411  auto color = getOverlayColor( aField, aField->GetDefaultColor(), false );
412 
413  if( !aField->IsVisible() )
414  {
417  else
418  return;
419  }
420 
421  int linewidth = aField->GetPenSize();
422 
423  m_gal->SetLineWidth( linewidth );
424  m_gal->SetIsFill( false );
425  m_gal->SetIsStroke( true );
427  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
428  m_gal->SetFontItalic( aField->IsItalic() );
429 
431  m_gal->SetVerticalJustify( aField->GetVertJustify( ) );
432 
433  auto pos = mapCoords( aField->GetPosition() );
434  double orient = aField->GetTextAngleRadians();
435 
436  m_gal->StrokeText( aField->GetText(), pos, orient );
437 
438  // Draw the umbilical line
439  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
440  {
442  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
443  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
444  }
445 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
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:221
bool IsMoving() const
Definition: base_struct.h:221
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
COLOR4D GetDefaultColor() override
Definition: lib_field.cpp:424
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:166
bool IsItalic() const
Definition: eda_text.h:183
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
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:411
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
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:228
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:180
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:166
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, KIGFX::GAL::DrawLine(), LIB_FIELD::GetDefaultColor(), EDA_TEXT::GetHorizJustify(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), LIB_FIELD::GetPenSize(), LIB_FIELD::GetPosition(), 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/24]

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

Definition at line 448 of file sch_painter.cpp.

449 {
450  if( !isUnitAndConversionShown( aText ) )
451  return;
452 
453  auto color = getOverlayColor( aText, m_schSettings.GetLayerColor( LAYER_DEVICE ), false );
454 
455  if( !aText->IsVisible() )
456  {
459  else
460  return;
461  }
462 
463  int linewidth = aText->GetPenSize();
464  EDA_RECT bBox = aText->GetBoundingBox();
465  bBox.RevertYAxis();
466  VECTOR2D pos = mapCoords( bBox.Centre() );
467  double orient = aText->GetTextAngleRadians();
468 
471  m_gal->SetLineWidth( linewidth );
472  m_gal->SetIsFill( false );
473  m_gal->SetIsStroke( true );
475  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
476  m_gal->SetFontBold( aText->IsBold() );
477  m_gal->SetFontItalic( aText->IsItalic() );
478  m_gal->StrokeText( aText->GetText(), pos, orient );
479 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:186
bool IsVisible() const
Definition: eda_text.h:189
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
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:183
void SetFontBold(const bool aBold)
Set bold property of current font.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
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:228
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:213
double GetTextAngleRadians() const
Definition: eda_text.h:180
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:312
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:166

References EDA_RECT::Centre(), color, LIB_TEXT::GetBoundingBox(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), LIB_TEXT::GetPenSize(), 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/24]

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

Definition at line 867 of file sch_painter.cpp.

868 {
869  if( !isUnitAndConversionShown( aCurve ) )
870  return;
871 
872  if( setColors( aCurve, aLayer ) )
873  {
874  BEZIER_POLY poly ( aCurve->GetPoints() );
875  std::vector<wxPoint> pts;
876  std::deque<VECTOR2D> pts_xformed;
877  poly.GetPoly( pts );
878 
879  for( const auto &p : pts )
880  {
881  pts_xformed.push_back( mapCoords( p ) );
882  }
883 
884  m_gal->DrawPolygon( pts_xformed );
885  }
886 }
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:77
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/24]

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

Definition at line 1089 of file sch_painter.cpp.

1090 {
1091  PART_SPTR part = aComp->GetPartRef().lock();
1092 
1093  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1094  // In either case copy it so we can re-orient and translate it.
1095  std::unique_ptr<LIB_PART> temp( new LIB_PART( part ? *part.get() : *dummy() ) );
1096 
1097  if( aComp->IsMoving() )
1098  temp->SetFlags( IS_MOVED );
1099 
1100  if( aComp->IsHighlighted() )
1101  temp->SetFlags( HIGHLIGHTED );
1102 
1103  orientComponent( temp.get(), aComp->GetOrientation() );
1104 
1105  for( auto& item : temp->GetDrawItems() )
1106  {
1107  auto rp = aComp->GetPosition();
1108  auto ip = item.GetPosition();
1109  item.Move( wxPoint( rp.x + ip.x, ip.y - rp.y ) );
1110 
1111  if( item.Type() == LIB_PIN_T )
1112  {
1113  auto pin = static_cast<LIB_PIN*>( &item );
1114  if( aComp->IsPinHighlighted( pin ) )
1115  {
1116  pin->SetFlags( HIGHLIGHTED );
1117  }
1118  }
1119  }
1120 
1121  draw( temp.get(), aLayer, false,
1122  aComp->GetUnit(), aComp->GetConvert(), aComp->GetDanglingPinFlags() );
1123 
1124  // The fields are SCH_COMPONENT-specific and so don't need to be copied/
1125  // oriented/translated.
1126  std::vector<SCH_FIELD*> fields;
1127  aComp->GetFields( fields, false );
1128 
1129  for( SCH_FIELD* field : fields )
1130  {
1131  if( !field->IsMoving() )
1132  draw( field, aLayer );
1133  }
1134 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:56
PART_REF & GetPartRef()
std::vector< bool > * GetDanglingPinFlags()
int GetOrientation()
Get the display symbol orientation.
bool IsMoving() const
Definition: base_struct.h:221
static void orientComponent(LIB_PART *part, int orientation)
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
bool IsHighlighted() const
Definition: base_struct.h:226
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int GetUnit() const
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
Define a library symbol object.
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:137
bool IsPinHighlighted(const LIB_PIN *aPin)
wxPoint GetPosition() const override
Function GetPosition.
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References draw(), KIGFX::dummy(), SCH_COMPONENT::GetConvert(), SCH_COMPONENT::GetDanglingPinFlags(), SCH_COMPONENT::GetFields(), SCH_COMPONENT::GetOrientation(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetPosition(), SCH_COMPONENT::GetUnit(), HIGHLIGHTED, IS_MOVED, EDA_ITEM::IsHighlighted(), EDA_ITEM::IsMoving(), SCH_COMPONENT::IsPinHighlighted(), LIB_PIN_T, and KIGFX::orientComponent().

◆ draw() [13/24]

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

Definition at line 903 of file sch_painter.cpp.

904 {
906 
907  if( aJct->GetState( BRIGHTENED ) )
909  else
910  color = getOverlayColor( aJct, color, false );
911 
912  m_gal->SetIsStroke(true);
913  m_gal->SetIsFill(true);
917 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
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
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:360
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:104
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:138
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.
int GetState(int type) const
Definition: base_struct.h:240
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References BRIGHTENED, color, KIGFX::GAL::DrawCircle(), SCH_JUNCTION::GetEffectiveSymbolSize(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), SCH_JUNCTION::GetPosition(), EDA_ITEM::GetState(), LAYER_BRIGHTENED, LAYER_JUNCTION, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [14/24]

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

Definition at line 1137 of file sch_painter.cpp.

1138 {
1139  COLOR4D color;
1140  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1141 
1142  switch( aField->GetId() )
1143  {
1146  default: color = m_schSettings.GetLayerColor( LAYER_FIELDS ); break;
1147  }
1148 
1149  color = getOverlayColor( aField, color, false );
1150 
1151  if( !aField->IsVisible() )
1152  {
1155  else
1156  return;
1157  }
1158 
1159  if( aField->IsVoid() )
1160  return;
1161 
1162  // Calculate the text orientation according to the component orientation.
1163  int orient = (int) aField->GetTextAngle();
1164 
1165  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1166  {
1167  if( orient == TEXT_ANGLE_HORIZ )
1168  orient = TEXT_ANGLE_VERT;
1169  else
1170  orient = TEXT_ANGLE_HORIZ;
1171  }
1172 
1173  /* Calculate the text justification, according to the component
1174  * orientation/mirror this is a bit complicated due to cumulative
1175  * calculations:
1176  * - numerous cases (mirrored or not, rotation)
1177  * - the DrawGraphicText function recalculate also H and H justifications
1178  * according to the text orientation.
1179  * - When a component is mirrored, the text is not mirrored and
1180  * justifications are complicated to calculate
1181  * so the more easily way is to use no justifications ( Centered text )
1182  * and use GetBoundaryBox to know the text coordinate considered as centered
1183  */
1184  EDA_RECT boundaryBox = aField->GetBoundingBox();
1185  wxPoint textpos = boundaryBox.Centre();
1186  int lineWidth = aField->GetPenSize();
1187 
1191  m_gal->SetIsFill( false );
1192  m_gal->SetIsStroke( true );
1193  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1194  m_gal->SetFontBold( aField->IsBold() );
1195  m_gal->SetFontItalic( aField->IsItalic() );
1196  m_gal->SetTextMirrored( aField->IsMirrored() );
1197  m_gal->SetLineWidth( lineWidth );
1198  m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI/2 : 0 );
1199 
1200  // Draw the umbilical line
1201  if( aField->IsMoving() )
1202  {
1204  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1205  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1206  }
1207 }
#define TEXT_ANGLE_HORIZ
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:186
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_field.cpp:101
bool IsMirrored() const
Definition: eda_text.h:192
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:287
#define TEXT_ANGLE_VERT
bool IsVisible() const
Definition: eda_text.h:189
bool IsMoving() const
Definition: base_struct.h:221
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:177
int GetId() const
Definition: sch_field.h:87
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.h:116
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:183
int y1
Definition: transform.h:49
void SetFontBold(const bool aBold)
Set bold property of current font.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
#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:228
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
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:252
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:70
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:166
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(), KIGFX::getOverlayColor(), EDA_ITEM::GetParent(), SCH_FIELD::GetPenSize(), SCH_COMPONENT::GetPosition(), 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/24]

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

Definition at line 993 of file sch_painter.cpp.

994 {
995  COLOR4D color;
996 
997  switch( aText->Type() )
998  {
1003  default: color = m_schSettings.GetLayerColor( LAYER_NOTES ); break;
1004  }
1005 
1006  if( aText->GetState( BRIGHTENED ) )
1008 
1009  color = getOverlayColor( aText, color, false );
1010 
1011  if( !aText->IsVisible() )
1012  {
1015  else
1016  return;
1017  }
1018 
1020 
1021  if( aText->IsDangling() )
1022  drawDanglingSymbol( m_gal, aText->GetTextPos() );
1023 
1024  wxPoint text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1025  int linewidth = aText->GetPenSize();
1026  wxString shownText( aText->GetShownText() );
1027 
1028  if( !shownText.IsEmpty() )
1029  {
1030  m_gal->SetIsFill( false );
1031  m_gal->SetIsStroke( true );
1032  m_gal->SetTextAttributes( aText );
1033  m_gal->SetLineWidth( linewidth );
1034  m_gal->StrokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1035  }
1036 }
virtual bool IsDangling() const override
Definition: sch_text.h:177
virtual int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_text.cpp:289
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:189
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: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.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
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.
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:138
double GetTextAngleRadians() const
Definition: eda_text.h:180
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetState(int type) const
Definition: base_struct.h:240
static void drawDanglingSymbol(GAL *aGal, const wxPoint &aPos)
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References BRIGHTENED, color, KIGFX::drawDanglingSymbol(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), SCH_TEXT::GetPenSize(), SCH_TEXT::GetSchematicTextOffset(), EDA_TEXT::GetShownText(), EDA_ITEM::GetState(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), SCH_TEXT::IsDangling(), EDA_TEXT::IsVisible(), LAYER_BRIGHTENED, 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_HIERARCHICAL_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/24]

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

◆ draw() [17/24]

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

Definition at line 1240 of file sch_painter.cpp.

1241 {
1244  int width = aLabel->GetThickness() ? aLabel->GetThickness() : GetDefaultLineThickness();
1245 
1246  if( aLabel->GetState( BRIGHTENED ) )
1248 
1249  color = getOverlayColor( aLabel, color, false );
1250 
1251  std::vector<wxPoint> pts;
1252  std::deque<VECTOR2D> pts2;
1253 
1254  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1255 
1256  for( auto p : pts )
1257  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1258 
1259  m_gal->SetIsFill( true );
1260  m_gal->SetFillColor( back_color );
1261  m_gal->SetIsStroke( true );
1262  m_gal->SetLineWidth( width );
1264  m_gal->DrawPolyline( pts2 );
1265 
1266  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1267 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
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:167
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.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:138
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1100
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetState(int type) const
Definition: base_struct.h:240
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166

References BRIGHTENED, color, SCH_HIERLABEL::CreateGraphicShape(), draw(), KIGFX::GAL::DrawPolyline(), GetDefaultLineThickness(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), EDA_ITEM::GetState(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetThickness(), LAYER_BRIGHTENED, 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() [18/24]

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

Definition at line 1210 of file sch_painter.cpp.

1211 {
1214  int width = aLabel->GetThickness() ? aLabel->GetThickness() : GetDefaultLineThickness();
1215 
1216  if( aLabel->GetState( BRIGHTENED ) )
1218 
1219  color = getOverlayColor( aLabel, color, false );
1220 
1221  std::vector<wxPoint> pts;
1222  std::deque<VECTOR2D> pts2;
1223 
1224  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1225 
1226  for( auto p : pts )
1227  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1228 
1229  m_gal->SetIsFill( true );
1230  m_gal->SetFillColor( back_color );
1231  m_gal->SetIsStroke( true );
1232  m_gal->SetLineWidth( width );
1234  m_gal->DrawPolyline( pts2 );
1235 
1236  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1237 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
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:167
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.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:138
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:839
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetState(int type) const
Definition: base_struct.h:240
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166

References BRIGHTENED, color, SCH_GLOBALLABEL::CreateGraphicShape(), draw(), KIGFX::GAL::DrawPolyline(), GetDefaultLineThickness(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), EDA_ITEM::GetState(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetThickness(), LAYER_BRIGHTENED, 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() [19/24]

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

Definition at line 1269 of file sch_painter.cpp.

1270 {
1271  VECTOR2D pos = aSheet->GetPosition();
1272  VECTOR2D size = aSheet->GetSize();
1273 
1274  if( aLayer == LAYER_SHEET_BACKGROUND )
1275  {
1276  m_gal->SetIsStroke( false );
1277 
1278  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1279  {
1280  // Select a fill color working well with black and white background color,
1281  // both in Opengl and Cairo
1282  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1283  m_gal->SetIsFill( true );
1284  }
1285  else
1286  {
1287  // Could be modified later, when sheets can have their own fill color
1288  return;
1289  }
1290 
1291  m_gal->DrawRectangle( pos, pos + size );
1292  }
1293  else if( aLayer == LAYER_SHEET )
1294  {
1296  m_gal->SetIsStroke( true );
1297 
1298  m_gal->SetIsFill( false );
1299  m_gal->SetLineWidth( aSheet->GetPenSize() );
1300 
1301  m_gal->DrawRectangle( pos, pos + size );
1302 
1303  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1304  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1305  double nameAngle = 0.0;
1306 
1307  if( aSheet->IsVerticalOrientation() )
1308  nameAngle = -M_PI/2;
1309 
1311 
1312  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1313 
1316 
1317  auto txtSize = aSheet->GetSheetNameSize();
1318 
1319  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1320  m_gal->SetFontBold( false );
1321  m_gal->SetFontItalic( false );
1322 
1323  m_gal->StrokeText( text, pos_sheetname, nameAngle );
1324 
1325  txtSize = aSheet->GetFileNameSize();
1326  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1329 
1330  text = wxT( "File: " ) + aSheet->GetFileName();
1331  m_gal->StrokeText( text, pos_filename, nameAngle );
1332  }
1333  else if( aLayer == LAYER_HIERLABEL )
1334  {
1335  for( auto& sheetPin : aSheet->GetPins() )
1336  {
1337  if( !sheetPin.IsMoving() )
1338  {
1339  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset
1340  // of width / 2
1341  int width = aSheet->GetPenSize();
1342  wxPoint initial_pos = sheetPin.GetTextPos();
1343  wxPoint offset_pos = initial_pos;
1344 
1345  switch( sheetPin.GetEdge() )
1346  {
1347  case SCH_SHEET_PIN::SHEET_TOP_SIDE: offset_pos.y -= width / 2; break;
1348  case SCH_SHEET_PIN::SHEET_BOTTOM_SIDE: offset_pos.y += width / 2; break;
1349  case SCH_SHEET_PIN::SHEET_RIGHT_SIDE: offset_pos.x -= width / 2; break;
1350  case SCH_SHEET_PIN::SHEET_LEFT_SIDE: offset_pos.x += width / 2; break;
1351  default: break;
1352  }
1353 
1354  sheetPin.SetTextPos( offset_pos );
1355  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1356  m_gal->DrawLine( offset_pos, initial_pos );
1357  sheetPin.SetTextPos( initial_pos );
1358  }
1359  }
1360  }
1361 }
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:334
bool IsMoving() const
Definition: base_struct.h:221
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
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:275
void SetFontBold(const bool aBold)
Set bold property of current font.
int GetSheetNameSize() const
Definition: sch_sheet.h:271
wxString GetName() const
Definition: sch_sheet.h:267
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:547
wxPoint GetFileNamePosition()
Definition: sch_sheet.cpp:408
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:662
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:281
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
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(), KIGFX::RENDER_SETTINGS::GetLayerColor(), SCH_SHEET::GetName(), SCH_SHEET::GetPenSize(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), 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, m_schSettings, 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() [20/24]

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

Definition at line 1364 of file sch_painter.cpp.

1365 {
1366  int delta = aNC->GetSize() / 2;
1367  int width = GetDefaultLineThickness();
1368 
1370  m_gal->SetIsStroke( true );
1371  m_gal->SetIsFill( false );
1372  m_gal->SetLineWidth( width );
1373 
1374  VECTOR2D p = aNC->GetPosition();
1375 
1376  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1377  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1378 }
wxPoint GetPosition() const override
Function GetPosition.
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
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.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166

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

◆ draw() [21/24]

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

Definition at line 1428 of file sch_painter.cpp.

1429 {
1430  SHAPE_LINE_CHAIN polygon;
1431  aMarker->ShapeToPolygon( polygon );
1432 
1434 
1437 
1438  m_gal->Save();
1439  m_gal->Translate( aMarker->GetPosition() );
1440  m_gal->SetFillColor( color );
1441  m_gal->SetIsFill( true );
1442  m_gal->SetIsStroke( false );
1443  m_gal->DrawPolygon( polygon );
1444  m_gal->Restore();
1445 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:176
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_marker.h:102
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
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.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
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(), KIGFX::RENDER_SETTINGS::GetLayerColor(), SCH_MARKER::GetPosition(), LAYER_ERC_ERR, LAYER_ERC_WARN, KIGFX::PAINTER::m_gal, m_schSettings, 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() [22/24]

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

Definition at line 1410 of file sch_painter.cpp.

1411 {
1412  m_gal->Save();
1413  m_gal->Translate( aBitmap->GetPosition() );
1414 
1415  // When the image scale factor is not 1.0, we need to modify the actual
1416  // as the image scale factor is similar to a local zoom
1417  double img_scale = aBitmap->GetImageScale();
1418 
1419  if( img_scale != 1.0 )
1420  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1421 
1422  m_gal->DrawBitmap( *aBitmap->GetImage() );
1423 
1424  m_gal->Restore();
1425 }
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:157
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() [23/24]

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

Definition at line 920 of file sch_painter.cpp.

921 {
922  COLOR4D color = aLine->GetLineColor();
923 
924  if( aLine->GetState( BRIGHTENED ) )
926 
927  color = getOverlayColor( aLine, color, false );
928 
929  int width = aLine->GetPenSize();
930 
931  m_gal->SetIsStroke( true );
933  m_gal->SetLineWidth( width );
934 
935  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID )
936  {
937  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
938  }
939  else
940  {
941  VECTOR2D start = aLine->GetStartPoint();
942  VECTOR2D end = aLine->GetEndPoint();
943 
944  EDA_RECT clip( wxPoint( start.x, start.y ), wxSize( end.x - start.x, end.y - start.y ) );
945  clip.Normalize();
946 
947  double theta = atan2( end.y - start.y, end.x - start.x );
948  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
949 
950  switch( aLine->GetLineStyle() )
951  {
952  default:
953  case PLOTDASHTYPE_DASH:
954  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
955  break;
956  case PLOTDASHTYPE_DOT:
957  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
958  break;
960  strokes[0] = DASH_MARK_LEN( width );
961  strokes[2] = DOT_MARK_LEN( width );
962  break;
963  }
964 
965  for( size_t i = 0; i < 10000; ++i )
966  {
967  // Calculations MUST be done in doubles to keep from accumulating rounding
968  // errors as we go.
969  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
970  start.y + strokes[ i % 4 ] * sin( theta ) );
971 
972  // Drawing each segment can be done rounded to ints.
973  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
974  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
975 
976  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
977  break;
978  else if( i % 2 == 0 )
979  m_gal->DrawLine( segStart, segEnd );
980 
981  start = next;
982  }
983  }
984 
985  if( aLine->IsStartDangling() )
987 
988  if( aLine->IsEndDangling() )
990 }
CITER next(CITER it)
Definition: ptree.cpp:130
COLOR4D GetLineColor() const
Definition: sch_line.cpp:243
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:121
wxPoint GetStartPoint() const
Definition: sch_line.h:76
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
#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.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
bool IsEndDangling() const
Definition: sch_line.h:162
#define DOT_MARK_LEN(aLineWidth)
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:138
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:161
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:296
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetLineStyle() const
Definition: sch_line.cpp:269
int GetState(int type) const
Definition: base_struct.h:240
static void drawDanglingSymbol(GAL *aGal, const wxPoint &aPos)
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetEndPoint() const
Definition: sch_line.h:80

References BRIGHTENED, ClipLine(), color, DASH_GAP_LEN, DASH_MARK_LEN, DOT_MARK_LEN, KIGFX::drawDanglingSymbol(), KIGFX::GAL::DrawLine(), SCH_LINE::GetEndPoint(), KIGFX::RENDER_SETTINGS::GetLayerColor(), SCH_LINE::GetLineColor(), SCH_LINE::GetLineStyle(), KIGFX::getOverlayColor(), SCH_LINE::GetPenSize(), SCH_LINE::GetStartPoint(), EDA_ITEM::GetState(), i, SCH_LINE::IsEndDangling(), SCH_LINE::IsStartDangling(), KiROUND(), LAYER_BRIGHTENED, KIGFX::PAINTER::m_gal, m_schSettings, 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() [24/24]

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

Definition at line 1381 of file sch_painter.cpp.

1382 {
1383  COLOR4D color = aEntry->Type() == SCH_BUS_BUS_ENTRY_T ?
1386 
1387  color = getOverlayColor( aEntry, color, false );
1388 
1390  m_gal->SetIsStroke( true );
1391  m_gal->SetLineWidth( aEntry->GetPenSize() );
1392  m_gal->SetIsFill( false );
1393 
1394  VECTOR2D pos = aEntry->GetPosition();
1395  VECTOR2D endPos = aEntry->m_End();
1396 
1397  m_gal->DrawLine( pos, endPos );
1398 
1399  // Draw dangling symbols:
1400  m_gal->SetLineWidth ( 1.0 );
1401 
1402  if( aEntry->IsDanglingStart() )
1404 
1405  if( aEntry->IsDanglingEnd() )
1407 }
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:35
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 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.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
virtual int GetPenSize() const
Function GetPenSize virtual pure.
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.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
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(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), SCH_ITEM::GetPenSize(), SCH_BUS_ENTRY_BASE::GetPosition(), SCH_BUS_ENTRY_BASE::IsDanglingEnd(), SCH_BUS_ENTRY_BASE::IsDanglingStart(), LAYER_BUS, LAYER_WIRE, SCH_BUS_ENTRY_BASE::m_End(), KIGFX::PAINTER::m_gal, m_schSettings, SCH_BUS_BUS_ENTRY_T, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), TARGET_BUSENTRY_RADIUS, and EDA_ITEM::Type().

◆ 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 128 of file sch_painter.h.

129  {
130  return &m_schSettings;
131  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166

References m_schSettings.

◆ isUnitAndConversionShown()

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

Definition at line 205 of file sch_painter.cpp.

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

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 297 of file sch_painter.cpp.

298 {
299  if( aLayer == LAYER_DEVICE_BACKGROUND && aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
300  {
302 
303  // These actions place the item over others, so allow a modest transparency here
304  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
305  color = color.WithAlpha( 0.75 );
306 
307  m_gal->SetIsFill( true );
309 
310  m_gal->SetIsStroke( false );
311  return true;
312  }
313  else if( aLayer == LAYER_DEVICE )
314  {
316 
317  // These actions place the item over others, so allow a modest transparency here
318  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
319  color = color.WithAlpha( 0.75 );
320 
322  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
324 
325  if( aItem->GetPenSize() > 0 )
326  {
327  m_gal->SetIsStroke( true );
328  m_gal->SetLineWidth( aItem->GetPenSize() );
329  }
330  else
331  m_gal->SetIsStroke( false );
332 
333  return true;
334  }
335 
336  return false;
337 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsMoving() const
Definition: base_struct.h:221
int color
Definition: DXF_plotter.cpp:62
FILL_T GetFillMode() const
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:219
bool IsDragging() const
Definition: base_struct.h:222
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.
static const COLOR4D getOverlayColor(const EDA_ITEM *aItem, const COLOR4D &aColor, bool aOnBackgroundLayer)
Definition: sch_painter.cpp:94
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool IsResized() const
Definition: base_struct.h:225
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual int GetPenSize() const =0
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:166
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(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::getOverlayColor(), LIB_ITEM::GetPenSize(), EDA_ITEM::IsDragging(), EDA_ITEM::IsMoving(), EDA_ITEM::IsResized(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, KIGFX::PAINTER::m_gal, m_schSettings, 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 290 of file sch_painter.cpp.

291 {
292  m_gal->DrawLine( a, b );
293  m_gal->DrawLine( b, c );
294 }
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(), 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: