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_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)
 
void drawPinDanglingSymbol (const VECTOR2I &aPos, bool aDrawingShadows)
 
void drawDanglingSymbol (const wxPoint &aPos, bool aDrawingShadows)
 
bool isUnitAndConversionShown (const LIB_ITEM *aItem)
 
float getShadowWidth ()
 
COLOR4D getRenderColor (const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
 
float getLineWidth (const LIB_ITEM *aItem, bool aDrawingShadows)
 
float getLineWidth (const SCH_ITEM *aItem, bool aDrawingShadows)
 
float getTextThickness (const SCH_TEXT *aItem, bool aDrawingShadows)
 
bool setDeviceColors (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 136 of file sch_painter.cpp.

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

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:175

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

146 {
147  auto item2 = static_cast<const EDA_ITEM*>( aItem );
148  auto item = const_cast<EDA_ITEM*>( item2 );
149 
151 
152 #ifdef CONNECTIVITY_DEBUG
153 
154  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
155  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
156 
157  if( conn )
158  {
159  auto pos = item->GetBoundingBox().Centre();
160  auto label = conn->Name( true );
161 
165  m_gal->SetLineWidth( 2 );
166  m_gal->SetGlyphSize( VECTOR2D( 20, 20 ) );
167  m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
168  }
169 
170 #endif
171 
172  switch( item->Type() )
173  {
199 
200  default: return false;
201  }
202 
203  return false;
204 }
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:40
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:365
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:204
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:175
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:35
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/22]

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

Definition at line 409 of file sch_painter.cpp.

410 {
411  if( !isUnitAndConversionShown( aRect ) )
412  return;
413 
414  if( setDeviceColors( aRect, aLayer ) )
415  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
416 
417 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
wxPoint GetEnd() const
Definition: lib_rectangle.h:89
bool setDeviceColors(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:365
static VECTOR2D mapCoords(const wxPoint &aCoord)
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
wxPoint GetPosition() const override
Definition: lib_rectangle.h:76

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

Referenced by draw().

◆ draw() [2/22]

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

Definition at line 607 of file sch_painter.cpp.

608 {
609  if( !isUnitAndConversionShown( aPin ) )
610  return;
611 
612  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
613 
614  if( drawingShadows && !aPin->IsSelected() )
615  return;
616 
617  VECTOR2I pos = mapCoords( aPin->GetPosition() );
618  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
619 
620  if( !aPin->IsVisible() )
621  {
623  {
624  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
625  }
626  else
627  {
628  if( ( aPin->GetFlags() & IS_DANGLING ) && aPin->IsPowerConnection() )
629  drawPinDanglingSymbol( pos, drawingShadows );
630 
631  return;
632  }
633  }
634 
635  VECTOR2I p0;
636  VECTOR2I dir;
637  int len = aPin->GetLength();
638  int shape = aPin->GetShape();
639  int orient = aPin->GetOrientation();
640 
641  switch( orient )
642  {
643  case PIN_UP:
644  p0 = VECTOR2I( pos.x, pos.y - len );
645  dir = VECTOR2I(0, 1);
646  break;
647  case PIN_DOWN:
648  p0 = VECTOR2I( pos.x, pos.y + len );
649  dir = VECTOR2I(0, -1);
650  break;
651  case PIN_LEFT:
652  p0 = VECTOR2I( pos.x - len, pos.y );
653  dir = VECTOR2I(1, 0);
654  break;
655  default:
656  case PIN_RIGHT:
657  p0 = VECTOR2I( pos.x + len, pos.y );
658  dir = VECTOR2I(-1, 0);
659  break;
660  }
661 
662  VECTOR2D pc;
663 
664  m_gal->SetIsStroke( true );
665  m_gal->SetIsFill( false );
666  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
668  m_gal->SetFontBold( false );
669  m_gal->SetFontItalic( false );
670 
671  const int radius = ExternalPinDecoSize( *aPin );
672  const int diam = radius*2;
673  const int clock_size = InternalPinDecoSize( *aPin );
674 
675  if( shape == PINSHAPE_INVERTED )
676  {
677  m_gal->DrawCircle( p0 + dir * radius, radius );
678  m_gal->DrawLine( p0 + dir * ( diam ), pos );
679  }
680  else if( shape == PINSHAPE_FALLING_EDGE_CLOCK )
681  {
682  pc = p0 + dir * clock_size ;
683 
684  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
685  pc,
686  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
687 
688  m_gal->DrawLine( pos, pc );
689  }
690  else
691  {
692  m_gal->DrawLine( p0, pos );
693  }
694 
695  if( shape == PINSHAPE_CLOCK )
696  {
697  if (!dir.y)
698  {
699  triLine( p0 + VECTOR2D( 0, clock_size ),
700  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
701  p0 + VECTOR2D( 0, -clock_size ) );
702  }
703  else
704  {
705  triLine( p0 + VECTOR2D( clock_size, 0 ),
706  p0 + VECTOR2D( 0, -dir.y * clock_size ),
707  p0 + VECTOR2D( -clock_size, 0 ) );
708  }
709  }
710 
711  if( shape == PINSHAPE_INPUT_LOW )
712  {
713  if(!dir.y)
714  {
715  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
716  p0 + VECTOR2D(dir.x, -1) * diam,
717  p0 );
718  }
719  else /* MapX1 = 0 */
720  {
721  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
722  p0 + VECTOR2D(-1, dir.y) * diam,
723  p0 );
724  }
725  }
726 
727  if( shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
728  {
729  if( !dir.y ) // Horizontal pin
730  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
731  else // Vertical pin
732  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
733  }
734 
735  if( shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
736  {
737  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
738  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
739  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
740  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
741  }
742 
743  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
744  {
745  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
746  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
747  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
748  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
749 
750  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
751  }
752 
753  if( ( aPin->GetFlags() & IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
754  drawPinDanglingSymbol( pos, drawingShadows );
755 
756  // Draw the labels
757 
758  LIB_PART* libEntry = aPin->GetParent();
759  int textOffset = libEntry->GetPinNameOffset();
760 
761  float nameLineWidth = getLineWidth( aPin, drawingShadows );
762  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
763  float numLineWidth = getLineWidth( aPin, drawingShadows );
764  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
765 
766  #define PIN_TEXT_MARGIN 4.0
767 
768  // Four locations around a pin where text can be drawn
769  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
770  int size[4] = { 0, 0, 0, 0 };
771  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
772  COLOR4D colour[4];
773  wxString text[4];
774 
775  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
776  if( textOffset )
777  {
778  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
779  thickness[INSIDE] = nameLineWidth;
780  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
781  text [INSIDE] = aPin->GetName();
782 
783  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
784  thickness[ABOVE] = numLineWidth;
785  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
786  text [ABOVE] = aPin->GetNumber();
787  }
788  // Otherwise pin NAMES go above and pin NUMBERS go below
789  else
790  {
791  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
792  thickness[ABOVE] = nameLineWidth;
793  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
794  text [ABOVE] = aPin->GetName();
795 
796  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
797  thickness[BELOW] = numLineWidth;
798  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
799  text [BELOW] = aPin->GetNumber();
800  }
801 
803  {
804  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
805  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
806  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
807  text [OUTSIDE] = aPin->GetElectricalTypeName();
808  }
809 
810  if( !aPin->IsVisible() )
811  {
812  for( COLOR4D& c : colour )
813  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
814  }
815 
816  int insideOffset = textOffset;
817  int outsideOffset = 10;
818  float lineThickness = (float) GetDefaultLineThickness();
819  float aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + lineThickness ) / 2.0;
820  float belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + lineThickness ) / 2.0;
821 
822  if( drawingShadows )
823  {
824  for( float& t : thickness )
825  t += getShadowWidth();
826 
827  insideOffset -= KiROUND( getShadowWidth() / 2 );
828  outsideOffset -= KiROUND( getShadowWidth() / 2 );
829  }
830 
831  #define SET_DC( i ) \
832  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
833  m_gal->SetLineWidth( thickness[i] ); \
834  m_gal->SetStrokeColor( colour[i] )
835 
836  switch( orient )
837  {
838  case PIN_LEFT:
839  if( size[INSIDE] )
840  {
841  SET_DC( INSIDE );
844  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
845  }
846  if( size[OUTSIDE] )
847  {
848  SET_DC( OUTSIDE );
851  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
852  }
853  if( size[ABOVE] )
854  {
855  SET_DC( ABOVE );
858  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
859  }
860  if( size[BELOW] )
861  {
862  SET_DC( BELOW );
865  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
866  }
867  break;
868 
869  case PIN_RIGHT:
870  if( size[INSIDE] )
871  {
872  SET_DC( INSIDE );
876  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
877  }
878  if( size[OUTSIDE] )
879  {
880  SET_DC( OUTSIDE );
883  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
884  }
885  if( size[ABOVE] )
886  {
887  SET_DC( ABOVE );
890  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
891  }
892  if( size[BELOW] )
893  {
894  SET_DC( BELOW );
897  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
898  }
899  break;
900 
901  case PIN_DOWN:
902  if( size[INSIDE] )
903  {
904  SET_DC( INSIDE );
907  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2);
908  }
909  if( size[OUTSIDE] )
910  {
911  SET_DC( OUTSIDE );
914  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2);
915  }
916  if( size[ABOVE] )
917  {
918  SET_DC( ABOVE );
921  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
922  }
923  if( size[BELOW] )
924  {
925  SET_DC( BELOW );
928  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
929  }
930  break;
931 
932  case PIN_UP:
933  if( size[INSIDE] )
934  {
935  SET_DC( INSIDE );
938  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2);
939  }
940  if( size[OUTSIDE] )
941  {
942  SET_DC( OUTSIDE );
945  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2);
946  }
947  if( size[ABOVE] )
948  {
949  SET_DC( ABOVE );
952  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
953  }
954  if( size[BELOW] )
955  {
956  SET_DC( BELOW );
959  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
960  }
961  break;
962 
963  default:
964  wxFAIL_MSG( "Unknown pin orientation" );
965  }
966 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int GetPinNameOffset()
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
bool IsSelected() const
Definition: base_struct.h:233
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
int GetOrientation() const
Definition: lib_pin.h:204
LIB_PART * GetParent() const
Definition: lib_item.h:177
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:216
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
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)
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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:349
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static int ExternalPinDecoSize(const LIB_PIN &aPin)
bool ShowPinNames()
void SetFontBold(const bool aBold)
Set bold property of current font.
bool ShowPinNumbers()
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:64
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:256
const wxString & GetName() const
Definition: lib_pin.h:149
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.
#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:343
int GetNameTextSize() const
Definition: lib_pin.h:175
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
Definition: lib_pin.h:427
const wxString & GetNumber() const
Definition: lib_pin.h:177
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:232
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:202
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:149
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)
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
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:267
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define PIN_TEXT_MARGIN
int GetLength()
Definition: lib_pin.h:282
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
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(), drawPinDanglingSymbol(), KIGFX::ExternalPinDecoSize(), GetDefaultLineThickness(), LIB_PIN::GetElectricalTypeName(), EDA_ITEM::GetFlags(), LIB_PIN::GetLength(), getLineWidth(), LIB_PIN::GetName(), LIB_PIN::GetNameTextSize(), LIB_PIN::GetNumber(), LIB_PIN::GetNumberTextSize(), LIB_PIN::GetOrientation(), LIB_ITEM::GetParent(), LIB_PART::GetPinNameOffset(), LIB_PIN::GetPosition(), getRenderColor(), getShadowWidth(), 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(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), LIB_PIN::IsVisible(), KiROUND(), LAYER_HIDDEN, LAYER_NOTES, LAYER_PIN, LAYER_PINNAM, LAYER_PINNUM, LAYER_SELECTION_SHADOWS, 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/22]

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

Definition at line 420 of file sch_painter.cpp.

421 {
422  if( !isUnitAndConversionShown( aCircle ) )
423  return;
424 
425  if( setDeviceColors( aCircle, aLayer ) )
426  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
427 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetPosition() const override
Definition: lib_circle.h:75
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
int GetRadius() const
Definition: lib_circle.h:91
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 setDeviceColors().

◆ draw() [4/22]

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

Definition at line 304 of file sch_painter.cpp.

305 {
306  if( !aUnit )
307  aUnit = m_schSettings.m_ShowUnit;
308 
309  if( !aConvert )
310  aConvert = m_schSettings.m_ShowConvert;
311 
312  for( auto& item : aPart->GetDrawItems() )
313  {
314  if( !aDrawFields && item.Type() == LIB_FIELD_T )
315  continue;
316 
317  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
318  continue;
319 
320  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
321  continue;
322 
323  Draw( &item, aLayer );
324  }
325 }
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:175

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

◆ draw() [5/22]

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

Definition at line 328 of file sch_painter.cpp.

329 {
330  LIB_PART* comp = aAlias->GetPart();
331 
332  draw( comp, aLayer, false );
333 
334  LIB_FIELDS fields;
335  comp->GetFields( fields );
336 
337  if( !aAlias->IsRoot() )
338  {
339  fields[ VALUE ].SetText( aAlias->GetName() );
340  fields[ DATASHEET ].SetText( aAlias->GetDocFileName() );
341  }
342 
343  for( LIB_FIELD& field : fields )
344  draw( &field, aLayer );
345 }
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:214
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() [6/22]

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

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

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

Definition at line 430 of file sch_painter.cpp.

431 {
432  if( !isUnitAndConversionShown( aArc ) )
433  return;
434 
435  if( setDeviceColors( aArc, aLayer ) )
436  {
437  int sai = aArc->GetFirstRadiusAngle();
438  int eai = aArc->GetSecondRadiusAngle();
439 
450  if( !TRANSFORM().MapAngles( &sai, &eai ) )
451  {
452  LIB_ARC new_arc( *aArc );
453 
454  new_arc.SetStart( aArc->GetEnd() );
455  new_arc.SetEnd( aArc->GetStart() );
456  new_arc.CalcRadiusAngles();
457  sai = new_arc.GetFirstRadiusAngle();
458  eai = new_arc.GetSecondRadiusAngle();
459  TRANSFORM().MapAngles( &sai, &eai );
460  }
461 
462  double sa = (double) sai * M_PI / 1800.0;
463  double ea = (double) eai * M_PI / 1800.0 ;
464 
465  VECTOR2D pos = mapCoords( aArc->GetPosition() );
466 
467  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
468  }
469 }
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
bool setDeviceColors(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:365
int GetSecondRadiusAngle() const
Definition: lib_arc.h:111
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
wxPoint GetStart() const
Definition: lib_arc.h:113
static VECTOR2D mapCoords(const wxPoint &aCoord)
int GetRadius() const
Definition: lib_arc.h:105
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
wxPoint GetEnd() const
Definition: lib_arc.h:116
int GetFirstRadiusAngle() const
Definition: lib_arc.h:108
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:80
wxPoint GetPosition() const override
Definition: lib_arc.h:92

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

◆ draw() [7/22]

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

Definition at line 472 of file sch_painter.cpp.

473 {
474  if( !isUnitAndConversionShown( aLine ) )
475  return;
476 
477  if( setDeviceColors( aLine, aLayer ) )
478  {
479  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
480  std::deque<VECTOR2D> vtx;
481 
482  for( auto p : pts )
483  vtx.push_back( mapCoords( p ) );
484 
485  m_gal->DrawPolygon( vtx );
486  }
487 }
bool setDeviceColors(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:365
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:60
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 setDeviceColors().

◆ draw() [8/22]

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

Definition at line 490 of file sch_painter.cpp.

491 {
492  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
493 
494  if( drawingShadows && !aField->IsSelected() )
495  return;
496 
497  // Must check layer as fields are sometimes drawn by their parent rather than
498  // directly from the view.
499  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
500  int layers_count;
501  aField->ViewGetLayers( layers, layers_count );
502 
503  if( aLayer != layers[0] )
504  return;
505 
506  if( !isUnitAndConversionShown( aField ) )
507  return;
508 
509  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
510 
511  if( !aField->IsVisible() )
512  {
514  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
515  else
516  return;
517  }
518 
519  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
520  m_gal->SetIsFill( false );
521  m_gal->SetIsStroke( true );
523  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
524  m_gal->SetFontItalic( aField->IsItalic() );
525 
527  m_gal->SetVerticalJustify( aField->GetVertJustify( ) );
528 
529  auto pos = mapCoords( aField->GetPosition() );
530  double orient = aField->GetTextAngleRadians();
531 
532  m_gal->StrokeText( aField->GetText(), pos, orient );
533 
534  // Draw the umbilical line
535  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
536  {
538  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
539  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
540  }
541 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:233
wxPoint GetPosition() const override
Definition: lib_field.h:179
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:230
int color
Definition: DXF_plotter.cpp:62
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:701
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
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:341
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
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:221
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:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
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.
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
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(), getLineWidth(), LIB_FIELD::GetPosition(), getRenderColor(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsItalic(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), EDA_TEXT::IsVisible(), LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::SCH_RENDER_SETTINGS::m_ShowUmbilicals, KIGFX::mapCoords(), 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() [9/22]

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

Definition at line 544 of file sch_painter.cpp.

545 {
546  if( !isUnitAndConversionShown( aText ) )
547  return;
548 
549  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
550 
551  if( drawingShadows && !aText->IsSelected() )
552  return;
553 
554  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
555 
556  if( !aText->IsVisible() )
557  {
559  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
560  else
561  return;
562  }
563 
564  EDA_RECT bBox = aText->GetBoundingBox();
565  bBox.RevertYAxis();
566  VECTOR2D pos = mapCoords( bBox.Centre() );
567  double orient = aText->GetTextAngleRadians();
568 
571  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
572  m_gal->SetIsFill( false );
573  m_gal->SetIsStroke( true );
575  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
576  m_gal->SetFontBold( aText->IsBold() );
577  m_gal->SetFontItalic( aText->IsItalic() );
578  m_gal->StrokeText( aText->GetText(), pos, orient );
579 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
bool IsSelected() const
Definition: base_struct.h:233
bool IsVisible() const
Definition: eda_text.h:170
int color
Definition: DXF_plotter.cpp:62
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:144
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
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:221
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:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:271
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
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.
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [10/22]

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

Definition at line 969 of file sch_painter.cpp.

970 {
971  if( !isUnitAndConversionShown( aCurve ) )
972  return;
973 
974  if( setDeviceColors( aCurve, aLayer ) )
975  {
976  BEZIER_POLY poly ( aCurve->GetPoints() );
977  std::vector<wxPoint> pts;
978  std::deque<VECTOR2D> pts_xformed;
979  poly.GetPoly( pts );
980 
981  for( const auto &p : pts )
982  pts_xformed.push_back( mapCoords( p ) );
983 
984  m_gal->DrawPolygon( pts_xformed );
985  }
986 }
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
bool setDeviceColors(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:365
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:72
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 setDeviceColors().

◆ draw() [11/22]

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

Definition at line 1221 of file sch_painter.cpp.

1222 {
1223  PART_SPTR originalPartSptr = aComp->GetPartRef().lock();
1224 
1225  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1226  LIB_PART* originalPart = originalPartSptr ? originalPartSptr.get() : dummy();
1227 
1228  // Copy the source so we can re-orient and translate it.
1229  LIB_PART tempPart( *originalPart );
1230 
1231  tempPart.SetFlags( aComp->GetFlags() );
1232 
1233  orientPart( &tempPart, aComp->GetOrientation());
1234 
1235  for( auto& tempItem : tempPart.GetDrawItems() )
1236  {
1237  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1238  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition()));
1239  }
1240 
1241  // Copy the pin info from the component to the temp pins
1242  LIB_PINS tempPins;
1243  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1244  const SCH_PINS& compPins = aComp->GetPins();
1245 
1246  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1247  {
1248  LIB_PIN* tempPin = tempPins[ i ];
1249  const SCH_PIN& compPin = compPins[ i ];
1250 
1251  tempPin->ClearFlags();
1252  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1253 
1254  if( compPin.IsDangling() )
1255  tempPin->SetFlags( IS_DANGLING );
1256  }
1257 
1258  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1259 
1260  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1261  std::vector<SCH_FIELD*> fields;
1262  aComp->GetFields( fields, false );
1263 
1264  for( SCH_FIELD* field : fields )
1265  draw( field, aLayer );
1266 }
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
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
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:265
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)
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:149
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:266
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:267

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() [12/22]

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

Definition at line 1003 of file sch_painter.cpp.

1004 {
1005  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1006 
1007  if( drawingShadows && !aJct->IsSelected() )
1008  return;
1009 
1010  COLOR4D color;
1011  auto conn = aJct->Connection( *g_CurrentSheet );
1012 
1013  if( conn && conn->IsBus() )
1014  color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
1015  else
1016  color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
1017 
1018  m_gal->SetIsStroke( drawingShadows );
1019  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1021  m_gal->SetIsFill( !drawingShadows );
1022  m_gal->SetFillColor( color );
1024 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:233
int color
Definition: DXF_plotter.cpp:62
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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.
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:128
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
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(), getLineWidth(), SCH_JUNCTION::GetPosition(), getRenderColor(), EDA_ITEM::IsSelected(), LAYER_BUS, LAYER_JUNCTION, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), and KIGFX::GAL::SetStrokeColor().

◆ draw() [13/22]

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

Definition at line 1269 of file sch_painter.cpp.

1270 {
1271  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1272 
1273  if( drawingShadows && !aField->IsSelected() )
1274  return;
1275 
1276  switch( aField->GetId() )
1277  {
1278  case REFERENCE: aLayer = LAYER_REFERENCEPART; break;
1279  case VALUE: aLayer = LAYER_VALUEPART; break;
1280  default: aLayer = LAYER_FIELDS; break;
1281  }
1282 
1283  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1284 
1285  if( !aField->IsVisible() )
1286  {
1288  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1289  else
1290  return;
1291  }
1292 
1293  if( aField->IsVoid() )
1294  return;
1295 
1296  // Calculate the text orientation according to the component orientation.
1297  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1298  int orient = (int) aField->GetTextAngle();
1299 
1300  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1301  {
1302  if( orient == TEXT_ANGLE_HORIZ )
1303  orient = TEXT_ANGLE_VERT;
1304  else
1305  orient = TEXT_ANGLE_HORIZ;
1306  }
1307 
1308  /* Calculate the text justification, according to the component orientation/mirror.
1309  * Tthis is a bit complicated due to cumulative calculations:
1310  * - numerous cases (mirrored or not, rotation)
1311  * - the DrawGraphicText function recalculate also H and H justifications according to the
1312  * text orientation.
1313  * - When a component is mirrored, the text is not mirrored and justifications are
1314  * complicated to calculate
1315  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1316  * to know the text coordinate considered as centered
1317  */
1318  EDA_RECT boundaryBox = aField->GetBoundingBox();
1319  wxPoint textpos = boundaryBox.Centre();
1320 
1324  m_gal->SetIsFill( false );
1325  m_gal->SetIsStroke( true );
1326  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1327  m_gal->SetFontBold( aField->IsBold() );
1328  m_gal->SetFontItalic( aField->IsItalic() );
1329  m_gal->SetTextMirrored( aField->IsMirrored() );
1330  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
1331  m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI/2 : 0 );
1332 
1333  // Draw the umbilical line
1334  if( aField->IsMoving() )
1335  {
1337  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1338  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1339  }
1340 }
#define TEXT_ANGLE_HORIZ
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
bool IsMirrored() const
Definition: eda_text.h:173
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:233
#define TEXT_ANGLE_VERT
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:230
int color
Definition: DXF_plotter.cpp:62
double GetTextAngle() const
Definition: eda_text.h:158
int GetId() const
Definition: sch_field.h:103
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
Field Reference of part, i.e. "IC21".
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:257
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
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:221
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
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:194
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:75
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
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:175
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(), getLineWidth(), EDA_ITEM::GetParent(), 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_ITEM::IsSelected(), EDA_TEXT::IsVisible(), SCH_FIELD::IsVoid(), LAYER_FIELDS, LAYER_HIDDEN, LAYER_REFERENCEPART, LAYER_SELECTION_SHADOWS, 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() [14/22]

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

Definition at line 1099 of file sch_painter.cpp.

1100 {
1101  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1102 
1103  if( drawingShadows && !aText->IsSelected() )
1104  return;
1105 
1106  switch( aText->Type() )
1107  {
1108  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1109  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1110  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1111  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1112  default: aLayer = LAYER_NOTES; break;
1113  }
1114 
1115  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1116  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
1117 
1118  if( conn && conn->IsBus() )
1119  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1120 
1121  if( !aText->IsVisible() )
1122  {
1124  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1125  else
1126  return;
1127  }
1128 
1129  m_gal->SetIsFill( false );
1130  m_gal->SetIsStroke( true );
1131  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
1133  m_gal->SetTextAttributes( aText );
1134 
1135  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1136  wxString shownText( aText->GetShownText() );
1137 
1138  if( drawingShadows )
1139  {
1140  switch( aText->GetLabelSpinStyle() )
1141  {
1142  case 0:
1143  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1144  text_offset.x -= getShadowWidth() / 2;
1145  else
1146  text_offset.x += getShadowWidth() / 2;
1147  break;
1148  case 1:
1149  text_offset.y += getShadowWidth() / 2;
1150  break;
1151  case 2:
1152  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1153  text_offset.x += getShadowWidth() / 2;
1154  else
1155  text_offset.x -= getShadowWidth() / 2;
1156  break;
1157  case 3:
1158  text_offset.y -= getShadowWidth() / 2;
1159  break;
1160  }
1161  }
1162 
1163  if( !shownText.IsEmpty() )
1164  m_gal->StrokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1165 
1166  if( aText->IsDangling() )
1167  drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
1168 }
bool IsDangling() const override
Definition: sch_text.h:180
bool IsSelected() const
Definition: base_struct.h:233
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
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:170
int color
Definition: DXF_plotter.cpp:62
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:147
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetLabelSpinStyle() const
Definition: sch_text.h:119
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:128
double GetTextAngleRadians() const
Definition: eda_text.h:161
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).
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
const wxPoint & GetTextPos() const
Definition: eda_text.h:230
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, SCH_ITEM::Connection(), drawDanglingSymbol(), g_CurrentSheet, SCH_TEXT::GetLabelSpinStyle(), getLineWidth(), getRenderColor(), SCH_TEXT::GetSchematicTextOffset(), getShadowWidth(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), SCH_CONNECTION::IsBus(), SCH_TEXT::IsDangling(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), LAYER_BUS, LAYER_GLOBLABEL, LAYER_HIDDEN, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, LAYER_SELECTION_SHADOWS, 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, SCH_TEXT_T, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), KIGFX::GAL::StrokeText(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [15/22]

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

Definition at line 1371 of file sch_painter.cpp.

1372 {
1373  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1374 
1375  if( drawingShadows && !aLabel->IsSelected() )
1376  return;
1377 
1378  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1379 
1380  SCH_CONNECTION* conn = aLabel->Connection( *g_CurrentSheet );
1381 
1382  if( conn && conn->IsBus() )
1383  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1384 
1385  std::vector<wxPoint> pts;
1386  std::deque<VECTOR2D> pts2;
1387 
1388  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1389 
1390  for( auto p : pts )
1391  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1392 
1393  m_gal->SetIsFill( true );
1395  m_gal->SetIsStroke( true );
1396  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1398  m_gal->DrawPolyline( pts2 );
1399 
1400  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1401 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
bool IsSelected() const
Definition: base_struct.h:233
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:221
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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.
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:128
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1068
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:230
void draw(LIB_RECTANGLE *aRect, int aLayer)
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [16/22]

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

Definition at line 1343 of file sch_painter.cpp.

1344 {
1345  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1346 
1347  if( drawingShadows && !aLabel->IsSelected() )
1348  return;
1349 
1350  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1351 
1352  std::vector<wxPoint> pts;
1353  std::deque<VECTOR2D> pts2;
1354 
1355  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1356 
1357  for( auto p : pts )
1358  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1359 
1360  m_gal->SetIsFill( true );
1362  m_gal->SetIsStroke( true );
1363  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1365  m_gal->DrawPolyline( pts2 );
1366 
1367  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1368 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
bool IsSelected() const
Definition: base_struct.h:233
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:221
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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:836
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint & GetTextPos() const
Definition: eda_text.h:230
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:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [17/22]

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

Definition at line 1403 of file sch_painter.cpp.

1404 {
1405  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1406 
1407  if( aLayer == LAYER_HIERLABEL || drawingShadows )
1408  {
1409  for( auto& sheetPin : aSheet->GetPins() )
1410  {
1411  if( drawingShadows && !aSheet->IsSelected() && !sheetPin.IsSelected() )
1412  continue;
1413 
1414  int width = aSheet->GetPenSize();
1415  wxPoint initial_pos = sheetPin.GetTextPos();
1416  wxPoint offset_pos = initial_pos;
1417 
1418  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1419  switch( sheetPin.GetEdge() )
1420  {
1421  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1422  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1423  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1424  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1425  default: break;
1426  }
1427 
1428  sheetPin.SetTextPos( offset_pos );
1429  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1430  m_gal->DrawLine( offset_pos, initial_pos );
1431  sheetPin.SetTextPos( initial_pos );
1432  }
1433  }
1434 
1435  if( drawingShadows && !aSheet->IsSelected() )
1436  return;
1437 
1438  VECTOR2D pos = aSheet->GetPosition();
1439  VECTOR2D size = aSheet->GetSize();
1440 
1441  if( aLayer == LAYER_SHEET_BACKGROUND )
1442  {
1443  m_gal->SetIsStroke( aSheet->IsSelected() );
1446 
1447  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1448  {
1449  // Select a fill color working well with black and white background color,
1450  // both in Opengl and Cairo
1451  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1452  m_gal->SetIsFill( true );
1453  }
1454  else
1455  {
1456  // Could be modified later, when sheets can have their own fill color
1457  m_gal->SetIsFill( false );
1458  }
1459 
1460  m_gal->DrawRectangle( pos, pos + size );
1461  }
1462 
1463  if( aLayer == LAYER_SHEET || drawingShadows )
1464  {
1465  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1466  m_gal->SetIsStroke( true );
1467  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1468  m_gal->SetIsFill( false );
1469 
1470  m_gal->DrawRectangle( pos, pos + size );
1471 
1472  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1473  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1474  double nameAngle = 0.0;
1475 
1476  if( aSheet->IsVerticalOrientation() )
1477  nameAngle = M_PI/2;
1478 
1479  if( drawingShadows )
1480  {
1481  if( aSheet->IsVerticalOrientation() )
1482  {
1483  pos_sheetname.y += getShadowWidth() / 2;
1484  pos_filename.y += getShadowWidth() / 2;
1485  }
1486  else
1487  {
1488  pos_sheetname.x -= getShadowWidth() / 2;
1489  pos_filename.x -= getShadowWidth() / 2;
1490  }
1491  }
1492 
1493  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
1494 
1495  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1496 
1499 
1500  auto txtSize = aSheet->GetSheetNameSize();
1501 
1502  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1503  m_gal->SetFontBold( false );
1504  m_gal->SetFontItalic( false );
1505 
1506  m_gal->StrokeText( text, pos_sheetname, nameAngle );
1507 
1508  txtSize = aSheet->GetFileNameSize();
1509  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1510  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) );
1512 
1513  text = wxT( "File: " ) + aSheet->GetFileName();
1514  m_gal->StrokeText( text, pos_filename, nameAngle );
1515  }
1516 }
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:325
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
bool IsSelected() const
Definition: base_struct.h:233
bool IsMoving() const
Definition: base_struct.h:230
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
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetFileNameSize() const
Definition: sch_sheet.h:268
void SetFontBold(const bool aBold)
Set bold property of current font.
int GetSheetNameSize() const
Definition: sch_sheet.h:265
wxString GetName() const
Definition: sch_sheet.h:262
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:533
wxPoint GetFileNamePosition()
Definition: sch_sheet.cpp:408
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:629
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
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
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:273
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(), getLineWidth(), SCH_SHEET::GetName(), SCH_SHEET::GetPenSize(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), getRenderColor(), getShadowWidth(), SCH_SHEET::GetSheetNamePosition(), SCH_SHEET::GetSheetNameSize(), SCH_SHEET::GetSize(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), SCH_SHEET::IsVerticalOrientation(), KiROUND(), LAYER_HIERLABEL, LAYER_SELECTION_SHADOWS, 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(), SHEET_BOTTOM_SIDE, SHEET_LEFT_SIDE, SHEET_RIGHT_SIDE, SHEET_TOP_SIDE, KIGFX::GAL::StrokeText(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [18/22]

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

Definition at line 1519 of file sch_painter.cpp.

1520 {
1521  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1522 
1523  if( drawingShadows && !aNC->IsSelected() )
1524  return;
1525 
1526  m_gal->SetIsStroke( true );
1527  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1528  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1529  m_gal->SetIsFill( false );
1530 
1531  VECTOR2D p = aNC->GetPosition();
1532  int delta = aNC->GetSize() / 2;
1533 
1534  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1535  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1536 }
bool IsSelected() const
Definition: base_struct.h:233
wxPoint GetPosition() const override
Function GetPosition.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.

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

◆ draw() [19/22]

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

Definition at line 1617 of file sch_painter.cpp.

1618 {
1619  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1620 
1621  if( drawingShadows && !aMarker->IsSelected() )
1622  return;
1623 
1625  aLayer = LAYER_ERC_ERR;
1626  else
1627  aLayer = LAYER_ERC_WARN;
1628 
1629  COLOR4D color = getRenderColor( aMarker, aLayer, drawingShadows );
1630 
1631  m_gal->Save();
1632  m_gal->Translate( aMarker->GetPosition() );
1633  m_gal->SetIsFill( !drawingShadows );
1634  m_gal->SetFillColor( color );
1635  m_gal->SetIsStroke( drawingShadows );
1636  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1638 
1639  SHAPE_LINE_CHAIN polygon;
1640  aMarker->ShapeToPolygon( polygon );
1641 
1642  m_gal->DrawPolygon( polygon );
1643  m_gal->Restore();
1644 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:233
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:175
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_marker.h:93
int color
Definition: DXF_plotter.cpp:62
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
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 SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Class SHAPE_LINE_CHAIN.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
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(), getLineWidth(), SCH_MARKER::GetPosition(), getRenderColor(), EDA_ITEM::IsSelected(), LAYER_ERC_ERR, LAYER_ERC_WARN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, MARKER_BASE::MARKER_SEVERITY_ERROR, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), MARKER_BASE::ShapeToPolygon(), and KIGFX::GAL::Translate().

◆ draw() [20/22]

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

Definition at line 1572 of file sch_painter.cpp.

1573 {
1574  m_gal->Save();
1575  m_gal->Translate( aBitmap->GetPosition() );
1576 
1577  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1578  // factor is similar to a local zoom
1579  double img_scale = aBitmap->GetImageScale();
1580 
1581  if( img_scale != 1.0 )
1582  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1583 
1584  if( aLayer == LAYER_DRAW_BITMAPS )
1585  {
1586  m_gal->DrawBitmap( *aBitmap->GetImage() );
1587  }
1588 
1589  if( aLayer == LAYER_SELECTION_SHADOWS )
1590  {
1591  if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
1592  {
1593  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1594  m_gal->SetIsStroke( true );
1597  m_gal->SetIsFill( false );
1598 
1599  // Draws a bounding box.
1600  VECTOR2D bm_size( aBitmap->GetSize() );
1601  // bm_size is the actual image size in UI.
1602  // but m_gal scale was previously set to img_scale
1603  // so recalculate size relative to this image size.
1604  bm_size.x /= img_scale;
1605  bm_size.y /= img_scale;
1606  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1607  VECTOR2D end = origin + bm_size;
1608 
1609  m_gal->DrawRectangle( origin, end );
1610  }
1611  }
1612 
1613  m_gal->Restore();
1614 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:233
to handle and draw images bitmaps
int color
Definition: DXF_plotter.cpp:62
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
bool IsBrightened() const
Definition: base_struct.h:236
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:135
bool IsHighlighted() const
Definition: base_struct.h:235
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxSize GetSize() const
Definition: sch_bitmap.cpp:123
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
static ptrdiff_t bm_size(const potrace_bitmap_t *bm)
Definition: bitmap.h:76
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
double GetImageScale() const
Definition: sch_bitmap.h:71
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 bm_size(), color, KIGFX::GAL::DrawBitmap(), KIGFX::GAL::DrawRectangle(), SCH_BITMAP::GetImage(), SCH_BITMAP::GetImageScale(), SCH_BITMAP::GetPosition(), getRenderColor(), getShadowWidth(), SCH_BITMAP::GetSize(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsHighlighted(), EDA_ITEM::IsSelected(), LAYER_DRAW_BITMAPS, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::Scale(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and KIGFX::GAL::Translate().

◆ draw() [21/22]

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

Definition at line 1027 of file sch_painter.cpp.

1028 {
1029  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1030 
1031  if( drawingShadows && !aLine->IsSelected() )
1032  return;
1033 
1034  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1035  float width = getLineWidth( aLine, drawingShadows );
1036 
1037  m_gal->SetIsStroke( true );
1039  m_gal->SetLineWidth( width );
1040 
1041  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID || drawingShadows )
1042  {
1043  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1044  }
1045  else
1046  {
1047  VECTOR2D start = aLine->GetStartPoint();
1048  VECTOR2D end = aLine->GetEndPoint();
1049 
1050  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1051  clip.Normalize();
1052 
1053  double theta = atan2( end.y - start.y, end.x - start.x );
1054  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1055 
1056  switch( aLine->GetLineStyle() )
1057  {
1058  default:
1059  case PLOTDASHTYPE_DASH:
1060  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1061  break;
1062  case PLOTDASHTYPE_DOT:
1063  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1064  break;
1065  case PLOTDASHTYPE_DASHDOT:
1066  strokes[0] = DASH_MARK_LEN( width );
1067  strokes[2] = DOT_MARK_LEN( width );
1068  break;
1069  }
1070 
1071  for( size_t i = 0; i < 10000; ++i )
1072  {
1073  // Calculations MUST be done in doubles to keep from accumulating rounding
1074  // errors as we go.
1075  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1076  start.y + strokes[ i % 4 ] * sin( theta ) );
1077 
1078  // Drawing each segment can be done rounded to ints.
1079  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1080  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1081 
1082  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1083  break;
1084  else if( i % 2 == 0 )
1085  m_gal->DrawLine( segStart, segEnd );
1086 
1087  start = next;
1088  }
1089  }
1090 
1091  if( aLine->IsStartDangling() )
1092  drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
1093 
1094  if( aLine->IsEndDangling() )
1095  drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
1096 }
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:115
wxPoint GetStartPoint() const
Definition: sch_line.h:90
bool IsSelected() const
Definition: base_struct.h:233
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
int color
Definition: DXF_plotter.cpp:62
#define DASH_MARK_LEN(aLineWidth)
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsEndDangling() const
Definition: sch_line.h:176
#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:175
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
#define DASH_GAP_LEN(aLineWidth)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetLineStyle() const
Definition: sch_line.cpp:289
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, drawDanglingSymbol(), KIGFX::GAL::DrawLine(), SCH_LINE::GetEndPoint(), SCH_ITEM::GetLayer(), SCH_LINE::GetLineStyle(), getLineWidth(), getRenderColor(), SCH_LINE::GetStartPoint(), i, SCH_LINE::IsEndDangling(), EDA_ITEM::IsSelected(), SCH_LINE::IsStartDangling(), KiROUND(), LAYER_SELECTION_SHADOWS, 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() [22/22]

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

Definition at line 1539 of file sch_painter.cpp.

1540 {
1541  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1542 
1543  if( drawingShadows && !aEntry->IsSelected() )
1544  return;
1545 
1546  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1547 
1548  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1549  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1550 
1551  m_gal->SetIsStroke( true );
1552  m_gal->SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
1554  m_gal->SetIsFill( false );
1555 
1556  VECTOR2D pos = aEntry->GetPosition();
1557  VECTOR2D endPos = aEntry->m_End();
1558 
1559  m_gal->DrawLine( pos, endPos );
1560 
1561  // Draw dangling symbols:
1562  m_gal->SetLineWidth ( getLineWidth( aEntry, drawingShadows ) );
1563 
1564  if( aEntry->IsDanglingStart() )
1566 
1567  if( aEntry->IsDanglingEnd() )
1569 }
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:35
bool IsSelected() const
Definition: base_struct.h:233
int color
Definition: DXF_plotter.cpp:62
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
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.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
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(), getLineWidth(), SCH_BUS_ENTRY_BASE::GetPosition(), getRenderColor(), SCH_BUS_ENTRY_BASE::IsDanglingEnd(), SCH_BUS_ENTRY_BASE::IsDanglingStart(), EDA_ITEM::IsSelected(), LAYER_BUS, LAYER_SELECTION_SHADOWS, 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().

◆ drawDanglingSymbol()

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

Definition at line 991 of file sch_painter.cpp.

992 {
993  wxPoint radius( DANGLING_SYMBOL_SIZE, DANGLING_SYMBOL_SIZE );
994 
995  m_gal->SetIsStroke( true );
996  m_gal->SetIsFill( false );
997  m_gal->SetLineWidth ( aDrawingShadows ? getShadowWidth() : 1.0F );
998 
999  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1000 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
#define DANGLING_SYMBOL_SIZE
Definition: general.h:45
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define F(x, y, z)
Definition: md5_hash.cpp:15
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.

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

Referenced by draw().

◆ drawPinDanglingSymbol()

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

Definition at line 597 of file sch_painter.cpp.

598 {
599  m_gal->SetIsFill( false );
600  m_gal->SetIsStroke( true );
601  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
602 
604 }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define F(x, y, z)
Definition: md5_hash.cpp:15
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.

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

Referenced by draw().

◆ getLineWidth() [1/2]

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

Definition at line 268 of file sch_painter.cpp.

269 {
270  float width = (float) aItem->GetPenSize();
271 
272  if( aItem->IsSelected() && aDrawingShadows )
273  width += getShadowWidth();
274 
275  return width;
276 }
bool IsSelected() const
Definition: base_struct.h:233
virtual int GetPenSize() const =0

References LIB_ITEM::GetPenSize(), getShadowWidth(), and EDA_ITEM::IsSelected().

Referenced by draw(), and setDeviceColors().

◆ getLineWidth() [2/2]

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

Definition at line 279 of file sch_painter.cpp.

280 {
281  float width = (float) aItem->GetPenSize();
282 
283  if( aItem->IsSelected() && aDrawingShadows )
284  width += getShadowWidth();
285 
286  return width;
287 }
bool IsSelected() const
Definition: base_struct.h:233
virtual int GetPenSize() const
Function GetPenSize virtual pure.
Definition: sch_item.h:212

References SCH_ITEM::GetPenSize(), getShadowWidth(), and EDA_ITEM::IsSelected().

◆ getRenderColor()

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

Definition at line 237 of file sch_painter.cpp.

238 {
239  static COLOR4D highlightColor( 1.0, 0.3, 0.3, 1.0 );
240  static COLOR4D selectionColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
241 
243 
244  if( aItem->Type() == SCH_LINE_T )
245  color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
246 
247  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
248  {
250 
251  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
252  color = color.WithAlpha( 0.2 );
253  }
254  else if( aItem->IsSelected() )
255  {
256  if( aDrawingShadows )
257  color = selectionColor.WithAlpha( 0.8 );
258  }
259  else if( aItem->IsHighlighted() ) // Cross-probing
260  {
261  color = highlightColor;
262  }
263 
264  return color;
265 }
bool IsSelected() const
Definition: base_struct.h:233
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:221
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:247
bool IsBrightened() const
Definition: base_struct.h:236
bool IsHighlighted() const
Definition: base_struct.h:235
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, KIGFX::RENDER_SETTINGS::GetLayerColor(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsHighlighted(), EDA_ITEM::IsSelected(), LAYER_BRIGHTENED, LAYER_DEVICE_BACKGROUND, LAYER_SHEET_BACKGROUND, m_schSettings, SCH_LINE_T, EDA_ITEM::Type(), and KIGFX::COLOR4D::WithAlpha().

Referenced by draw(), and setDeviceColors().

◆ 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:175

References m_schSettings.

◆ getShadowWidth()

float KIGFX::SCH_PAINTER::getShadowWidth ( )
private

Definition at line 227 of file sch_painter.cpp.

228 {
229  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
230 
231  // For best visuals the selection width must be a cross between the zoom level and the
232  // default line width.
233  return (float) ( ( fabs( matrix.GetScale().x * 5.5 ) + GetDefaultLineThickness() ) / 2.0 );
234 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365

References GetDefaultLineThickness(), MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), KIGFX::PAINTER::m_gal, and VECTOR2< T >::x.

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

◆ getTextThickness()

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

Definition at line 290 of file sch_painter.cpp.

291 {
292  float width = (float) aItem->GetThickness();
293 
294  if( width == 0 )
295  width = (float) GetDefaultLineThickness();
296 
297  if( aItem->IsSelected() && aDrawingShadows )
298  width += getShadowWidth();
299 
300  return width;
301 }
bool IsSelected() const
Definition: base_struct.h:233
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148

References GetDefaultLineThickness(), getShadowWidth(), EDA_TEXT::GetThickness(), and EDA_ITEM::IsSelected().

Referenced by draw().

◆ isUnitAndConversionShown()

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

Definition at line 207 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ setDeviceColors()

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

Definition at line 361 of file sch_painter.cpp.

362 {
363  switch( aLayer )
364  {
366  if( aItem->IsSelected() )
367  {
368  m_gal->SetIsFill( false );
369  m_gal->SetIsStroke( true );
370  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
371  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
372  return true;
373  }
374 
375  return false;
376 
378  if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
379  {
380  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
381 
382  // These actions place the item over others, so allow a modest transparency here
383  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
384  fillColor = fillColor.WithAlpha( 0.75 );
385 
387  m_gal->SetFillColor( fillColor );
388  m_gal->SetIsStroke( false );
389  return true;
390  }
391 
392  return false;
393 
394  case LAYER_DEVICE:
395  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
396  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
397  m_gal->SetIsStroke( aItem->GetPenSize() > 0 );
398  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
399  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
400 
401  return true;
402 
403  default:
404  return false;
405  }
406 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:233
bool IsMoving() const
Definition: base_struct.h:230
FILL_T GetFillMode() const
Definition: lib_item.h:307
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:247
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsDragging() const
Definition: base_struct.h:231
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool IsResized() const
Definition: base_struct.h:234
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual int GetPenSize() const =0
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
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 FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, LIB_ITEM::GetFillMode(), getLineWidth(), LIB_ITEM::GetPenSize(), getRenderColor(), EDA_ITEM::IsDragging(), EDA_ITEM::IsMoving(), EDA_ITEM::IsResized(), EDA_ITEM::IsSelected(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and KIGFX::COLOR4D::WithAlpha().

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 333 of file painter.h.

334  {
335  m_gal = aGal;
336  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365

References KIGFX::PAINTER::m_gal.

◆ triLine()

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

Definition at line 354 of file sch_painter.cpp.

355 {
356  m_gal->DrawLine( a, b );
357  m_gal->DrawLine( b, c );
358 }
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:365

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 368 of file painter.h.

◆ m_gal

GAL* KIGFX::PAINTER::m_gal
protectedinherited

◆ m_schSettings

SCH_RENDER_SETTINGS KIGFX::SCH_PAINTER::m_schSettings
private

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