KiCad PCB EDA Suite
KIGFX::SCH_PAINTER Class Reference

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
 
void SetSchematic (SCHEMATIC *aSchematic)
 
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_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, int aWidth, bool aDrawingShadows)
 
int internalPinDecoSize (const LIB_PIN &aPin)
 
int externalPinDecoSize (const LIB_PIN &aPin)
 
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)
 
float getTextThickness (const SCH_FIELD *aItem, bool aDrawingShadows)
 
float getTextThickness (const LIB_FIELD *aItem, bool aDrawingShadows)
 
float getTextThickness (const LIB_TEXT *aItem, bool aDrawingShadows)
 
bool setDeviceColors (const LIB_ITEM *aItem, int aLayer)
 
void fillIfSelection (int aLayer)
 
void triLine (const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
 
void strokeText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 

Private Attributes

SCH_RENDER_SETTINGS m_schSettings
 
SCHEMATICm_schematic
 

Detailed Description

SCH_PAINTER Contains methods for drawing schematic-specific items.

Definition at line 128 of file sch_painter.h.

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 154 of file sch_painter.cpp.

154  :
155  KIGFX::PAINTER( aGal ),
156  m_schematic( nullptr )
157 { }
SCHEMATIC * m_schematic
Definition: sch_painter.h:201
PAINTER contains all the knowledge about how to draw graphical object onto any particular output devi...
Definition: painter.h:58

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

138  {
139  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
140  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

165 {
166  auto item2 = static_cast<const EDA_ITEM*>( aItem );
167  auto item = const_cast<EDA_ITEM*>( item2 );
168 
169 #ifdef CONNECTIVITY_DEBUG
170 
171  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
172  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
173 
174  if( conn )
175  {
176  auto pos = item->GetBoundingBox().Centre();
177  auto label = conn->Name( true );
178 
182  m_gal->SetLineWidth( Mils2ui( 2 ) );
183  m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
184  m_gal->StrokeText( conn->Name( true ), pos, 0.0, 0 );
185  }
186 
187 #endif
188 
189  switch( item->Type() )
190  {
215 
216  default: return false;
217  }
218 
219  return false;
220 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:43
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
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:216
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)
Schematic symbol object.
Definition: sch_component.h:88
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.
Define a bezier curve graphic body item.
Definition: lib_bezier.h:34
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, HANDLE_ITEM, 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, 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/21]

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

Definition at line 523 of file sch_painter.cpp.

524 {
525  if( !isUnitAndConversionShown( aRect ) )
526  return;
527 
528  if( setDeviceColors( aRect, aLayer ) )
529  {
530  fillIfSelection( aLayer );
531  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
532  }
533 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
wxPoint GetEnd() const
Definition: lib_rectangle.h:87
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
const wxPoint GetPosition() const override
Definition: lib_rectangle.h:74
void fillIfSelection(int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
static VECTOR2D mapCoords(const wxPoint &aCoord)
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

Referenced by draw().

◆ draw() [2/21]

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

Definition at line 758 of file sch_painter.cpp.

759 {
760  if( !isUnitAndConversionShown( aPin ) )
761  return;
762 
763  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
764 
765  if( drawingShadows && !aPin->IsSelected() )
766  return;
767 
768  VECTOR2I pos = mapCoords( aPin->GetPosition() );
769  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
770 
771  if( !aPin->IsVisible() )
772  {
774  {
775  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
776  }
777  else
778  {
779  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
780  drawPinDanglingSymbol( pos, drawingShadows );
781 
782  return;
783  }
784  }
785 
786  VECTOR2I p0;
787  VECTOR2I dir;
788  int len = aPin->GetLength();
789  int orient = aPin->GetOrientation();
790 
791  switch( orient )
792  {
793  case PIN_UP:
794  p0 = VECTOR2I( pos.x, pos.y - len );
795  dir = VECTOR2I( 0, 1 );
796  break;
797 
798  case PIN_DOWN:
799  p0 = VECTOR2I( pos.x, pos.y + len );
800  dir = VECTOR2I( 0, -1 );
801  break;
802 
803  case PIN_LEFT:
804  p0 = VECTOR2I( pos.x - len, pos.y );
805  dir = VECTOR2I( 1, 0 );
806  break;
807 
808  default:
809  case PIN_RIGHT:
810  p0 = VECTOR2I( pos.x + len, pos.y );
811  dir = VECTOR2I( -1, 0 );
812  break;
813  }
814 
815  VECTOR2D pc;
816 
817  m_gal->SetIsStroke( true );
818  m_gal->SetIsFill( false );
819  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
821  m_gal->SetFontBold( false );
822  m_gal->SetFontItalic( false );
823 
824  const int radius = externalPinDecoSize( *aPin );
825  const int diam = radius*2;
826  const int clock_size = internalPinDecoSize( *aPin );
827 
828  if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
829  {
830  m_gal->DrawLine( p0, pos );
831 
832  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
833  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
834  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
835  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
836 
837  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
838  }
839  else
840  {
841  switch( aPin->GetShape() )
842  {
844  m_gal->DrawLine( p0, pos );
845  break;
846 
848  m_gal->DrawCircle( p0 + dir * radius, radius );
849  m_gal->DrawLine( p0 + dir * ( diam ), pos );
850  break;
851 
853  pc = p0 - dir * clock_size ;
854 
855  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
856  pc,
857  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
858 
859  m_gal->DrawCircle( p0 + dir * radius, radius );
860  m_gal->DrawLine( p0 + dir * ( diam ), pos );
861  break;
862 
865  pc = p0 - dir * clock_size ;
866 
867  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
868  pc,
869  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
870 
871  if( !dir.y )
872  {
873  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
874  p0 + VECTOR2D(dir.x, -1) * diam,
875  p0 );
876  }
877  else /* MapX1 = 0 */
878  {
879  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
880  p0 + VECTOR2D(-1, dir.y) * diam,
881  p0 );
882  }
883 
884  m_gal->DrawLine( p0, pos );
885  break;
886 
888  m_gal->DrawLine( p0, pos );
889 
890  if( !dir.y )
891  {
892  triLine( p0 + VECTOR2D( 0, clock_size ),
893  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
894  p0 + VECTOR2D( 0, -clock_size ) );
895  }
896  else
897  {
898  triLine( p0 + VECTOR2D( clock_size, 0 ),
899  p0 + VECTOR2D( 0, -dir.y * clock_size ),
900  p0 + VECTOR2D( -clock_size, 0 ) );
901  }
902  break;
903 
905  m_gal->DrawLine( p0, pos );
906 
907  if( !dir.y )
908  {
909  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
910  p0 + VECTOR2D(dir.x, -1) * diam,
911  p0 );
912  }
913  else /* MapX1 = 0 */
914  {
915  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
916  p0 + VECTOR2D(-1, dir.y) * diam,
917  p0 );
918  }
919  break;
920 
921  case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
922  m_gal->DrawLine( p0, pos );
923 
924  if( !dir.y ) // Horizontal pin
925  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
926  else // Vertical pin
927  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
928  break;
929 
930  case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
931  m_gal->DrawLine( p0, pos );
932 
933  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
934  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
935  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
936  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
937  break;
938  }
939  }
940 
941 
942  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
943  drawPinDanglingSymbol( pos, drawingShadows );
944 
945  LIB_PART* libEntry = aPin->GetParent();
946 
947  // Draw the labels
948  if( drawingShadows && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() )
950  return;
951 
952  int textOffset = libEntry->GetPinNameOffset();
953 
954  float nameLineWidth = getLineWidth( aPin, drawingShadows );
955  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
956  float numLineWidth = getLineWidth( aPin, drawingShadows );
957  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
958 
959  #define PIN_TEXT_MARGIN 4.0
960 
961  // Four locations around a pin where text can be drawn
962  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
963  int size[4] = { 0, 0, 0, 0 };
964  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
965  COLOR4D colour[4];
966  wxString text[4];
967 
968  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
969  if( textOffset )
970  {
971  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
972  thickness[INSIDE] = nameLineWidth;
973  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
974  text [INSIDE] = aPin->GetName();
975 
976  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
977  thickness[ABOVE] = numLineWidth;
978  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
979  text [ABOVE] = aPin->GetNumber();
980  }
981  // Otherwise pin NAMES go above and pin NUMBERS go below
982  else
983  {
984  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
985  thickness[ABOVE] = nameLineWidth;
986  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
987  text [ABOVE] = aPin->GetName();
988 
989  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
990  thickness[BELOW] = numLineWidth;
991  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
992  text [BELOW] = aPin->GetNumber();
993  }
994 
996  {
997  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
998  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
999  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
1000  text [OUTSIDE] = aPin->GetElectricalTypeName();
1001  }
1002 
1003  if( !aPin->IsVisible() )
1004  {
1005  for( COLOR4D& c : colour )
1006  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
1007  }
1008 
1009  int insideOffset = textOffset;
1010  int outsideOffset = 10;
1011  float lineThickness = (float) m_schSettings.GetDefaultPenWidth();
1012  float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + lineThickness ) / 2.0;
1013  float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[BELOW] + lineThickness ) / 2.0;
1014 
1015  if( drawingShadows )
1016  {
1017  for( float& t : thickness )
1018  t += getShadowWidth();
1019 
1020  insideOffset -= KiROUND( getShadowWidth() / 2 );
1021  outsideOffset -= KiROUND( getShadowWidth() / 2 );
1022  }
1023 
1024  #define SET_DC( i ) \
1025  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
1026  m_gal->SetLineWidth( thickness[i] ); \
1027  m_gal->SetStrokeColor( colour[i] )
1028 
1029  switch( orient )
1030  {
1031  case PIN_LEFT:
1032  if( size[INSIDE] )
1033  {
1034  SET_DC( INSIDE );
1037  strokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
1038  }
1039  if( size[OUTSIDE] )
1040  {
1041  SET_DC( OUTSIDE );
1044  strokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
1045  }
1046  if( size[ABOVE] )
1047  {
1048  SET_DC( ABOVE );
1051  strokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
1052  }
1053  if( size[BELOW] )
1054  {
1055  SET_DC( BELOW );
1058  strokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
1059  }
1060  break;
1061 
1062  case PIN_RIGHT:
1063  if( size[INSIDE] )
1064  {
1065  SET_DC( INSIDE );
1069  strokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
1070  }
1071  if( size[OUTSIDE] )
1072  {
1073  SET_DC( OUTSIDE );
1076  strokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
1077  }
1078  if( size[ABOVE] )
1079  {
1080  SET_DC( ABOVE );
1083  strokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
1084  }
1085  if( size[BELOW] )
1086  {
1087  SET_DC( BELOW );
1090  strokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
1091  }
1092  break;
1093 
1094  case PIN_DOWN:
1095  if( size[INSIDE] )
1096  {
1097  SET_DC( INSIDE );
1100  strokeText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
1101  }
1102  if( size[OUTSIDE] )
1103  {
1104  SET_DC( OUTSIDE );
1107  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
1108  }
1109  if( size[ABOVE] )
1110  {
1111  SET_DC( ABOVE );
1114  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
1115  }
1116  if( size[BELOW] )
1117  {
1118  SET_DC( BELOW );
1121  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
1122  }
1123  break;
1124 
1125  case PIN_UP:
1126  if( size[INSIDE] )
1127  {
1128  SET_DC( INSIDE );
1131  strokeText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
1132  }
1133  if( size[OUTSIDE] )
1134  {
1135  SET_DC( OUTSIDE );
1138  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
1139  }
1140  if( size[ABOVE] )
1141  {
1142  SET_DC( ABOVE );
1145  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
1146  }
1147  if( size[BELOW] )
1148  {
1149  SET_DC( BELOW );
1152  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
1153  }
1154  break;
1155 
1156  default:
1157  wxFAIL_MSG( "Unknown pin orientation" );
1158  }
1159 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int GetPinNameOffset()
bool IsSelected() const
Definition: base_struct.h:203
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
int GetOrientation() const
Definition: lib_pin.h:206
LIB_PART * GetParent() const
Definition: lib_item.h:182
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:218
int color
Definition: DXF_plotter.cpp:61
Definition: lib_pin.h:58
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
EESCHEMA_SETTINGS * eeconfig()
#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:110
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:351
virtual void SetLineWidth(float aLineWidth)
Set the line width.
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:72
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
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:258
const wxString & GetName() const
Definition: lib_pin.h:151
Define a library symbol object.
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
#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:345
int GetNameTextSize() const
Definition: lib_pin.h:177
const wxPoint GetPosition() const override
Definition: lib_pin.h:430
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
int externalPinDecoSize(const LIB_PIN &aPin)
const wxString & GetNumber() const
Definition: lib_pin.h:179
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:234
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:204
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:145
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
int internalPinDecoSize(const LIB_PIN &aPin)
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:46
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
int GetDefaultPenWidth() const
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:235
#define INSIDE
not connected (must be left open)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define PIN_TEXT_MARGIN
int GetLength()
Definition: lib_pin.h:284
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References Clamp_Text_PenSize(), EDA_ITEM::ClearFlags(), CLOCK, CLOCK_LOW, color, EESCHEMA_SETTINGS::SELECTION::draw_selected_children, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), drawPinDanglingSymbol(), KIGFX::eeconfig(), externalPinDecoSize(), FALLING_EDGE_CLOCK, KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), LIB_PIN::GetElectricalTypeName(), LIB_PIN::GetLength(), getLineWidth(), LIB_PIN::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, EDA_ITEM::HasFlag(), INPUT_LOW, INSIDE, internalPinDecoSize(), INVERTED, INVERTED_CLOCK, 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, LIB_PART_T, LINE, KIGFX::PAINTER::m_gal, m_schSettings, EESCHEMA_SETTINGS::m_Selection, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenPins, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, KIGFX::mapCoords(), NONLOGIC, OUTPUT_LOW, OUTSIDE, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_TEXT_MARGIN, PIN_UP, PT_NC, 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(), strokeText(), TARGET_PIN_RADIUS, triLine(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [3/21]

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

Definition at line 536 of file sch_painter.cpp.

537 {
538  if( !isUnitAndConversionShown( aCircle ) )
539  return;
540 
541  if( setDeviceColors( aCircle, aLayer ) )
542  {
543  fillIfSelection( aLayer );
544  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
545  }
546 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
void fillIfSelection(int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
int GetRadius() const
Definition: lib_circle.h:87
static VECTOR2D mapCoords(const wxPoint &aCoord)
const wxPoint GetPosition() const override
Definition: lib_circle.h:71
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

◆ draw() [4/21]

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

Definition at line 413 of file sch_painter.cpp.

414 {
415  if( !aUnit )
416  aUnit = m_schSettings.m_ShowUnit;
417 
418  if( !aConvert )
419  aConvert = m_schSettings.m_ShowConvert;
420 
421  std::unique_ptr< LIB_PART > tmpPart;
422  LIB_PART* drawnPart = aPart;
423 
424  if( aPart->IsAlias() )
425  {
426  tmpPart = aPart->Flatten();
427  drawnPart = tmpPart.get();
428  }
429 
430  for( auto& item : drawnPart->GetDrawItems() )
431  {
432  if( !aDrawFields && item.Type() == LIB_FIELD_T )
433  continue;
434 
435  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
436  continue;
437 
438  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
439  continue;
440 
441  Draw( &item, aLayer );
442  }
443 }
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.
Define a library symbol object.
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
bool IsAlias() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

◆ draw() [5/21]

void KIGFX::SCH_PAINTER::draw ( 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 549 of file sch_painter.cpp.

550 {
551  if( !isUnitAndConversionShown( aArc ) )
552  return;
553 
554  if( setDeviceColors( aArc, aLayer ) )
555  {
556  int sai = aArc->GetFirstRadiusAngle();
557  int eai = aArc->GetSecondRadiusAngle();
558 
569  if( !TRANSFORM().MapAngles( &sai, &eai ) )
570  {
571  LIB_ARC new_arc( *aArc );
572 
573  new_arc.SetStart( aArc->GetEnd() );
574  new_arc.SetEnd( aArc->GetStart() );
575  new_arc.CalcRadiusAngles();
576  sai = new_arc.GetFirstRadiusAngle();
577  eai = new_arc.GetSecondRadiusAngle();
578  TRANSFORM().MapAngles( &sai, &eai );
579  }
580 
581  double sa = (double) sai * M_PI / 1800.0;
582  double ea = (double) eai * M_PI / 1800.0 ;
583 
584  VECTOR2D pos = mapCoords( aArc->GetPosition() );
585 
586  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
587  }
588 }
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:110
int GetSecondRadiusAngle() const
Definition: lib_arc.h:109
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
const wxPoint GetPosition() const override
Definition: lib_arc.h:90
wxPoint GetStart() const
Definition: lib_arc.h:111
static VECTOR2D mapCoords(const wxPoint &aCoord)
int GetRadius() const
Definition: lib_arc.h:103
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
wxPoint GetEnd() const
Definition: lib_arc.h:114
int GetFirstRadiusAngle() const
Definition: lib_arc.h:106
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:81

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

◆ draw() [6/21]

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

Definition at line 591 of file sch_painter.cpp.

592 {
593  if( !isUnitAndConversionShown( aLine ) )
594  return;
595 
596  if( setDeviceColors( aLine, aLayer ) )
597  {
598  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
599  std::deque<VECTOR2D> vtx;
600 
601  for( auto p : pts )
602  vtx.push_back( mapCoords( p ) );
603 
604  fillIfSelection( aLayer );
605  m_gal->DrawPolygon( vtx );
606  }
607 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
void fillIfSelection(int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
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(), fillIfSelection(), LIB_POLYLINE::GetPolyPoints(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), and setDeviceColors().

◆ draw() [7/21]

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

Definition at line 610 of file sch_painter.cpp.

611 {
612  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
613 
614  if( drawingShadows && !aField->IsSelected() )
615  return;
616 
617  if( !isUnitAndConversionShown( aField ) )
618  return;
619 
620  // Must check layer as fields are sometimes drawn by their parent rather than
621  // directly from the view.
622  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
623  int layers_count;
624  bool foundLayer = false;
625 
626  aField->ViewGetLayers( layers, layers_count );
627 
628  for( int i = 0; i < layers_count; ++i )
629  {
630  if( layers[i] == aLayer )
631  foundLayer = true;
632  }
633 
634  if( !foundLayer )
635  return;
636 
637  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
638 
639  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
640  {
642  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
643  else
644  return;
645  }
646 
647  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
648  m_gal->SetIsFill( false );
649  m_gal->SetIsStroke( true );
651 
652  auto pos = mapCoords( aField->GetPosition() );
653 
654  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
655  {
656  EDA_RECT boundaryBox = aField->GetBoundingBox();
657 
658  m_gal->SetIsFill( true );
660  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
661  boundaryBox.RevertYAxis();
662 
663  m_gal->DrawRectangle( mapCoords( boundaryBox.GetPosition() ),
664  mapCoords( boundaryBox.GetEnd() ) );
665  }
666  else
667  {
668  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
669  m_gal->SetFontItalic( aField->IsItalic() );
670 
673 
674  double orient = aField->GetTextAngleRadians();
675 
676  strokeText( aField->GetText(), pos, orient );
677  }
678 
679  // Draw the umbilical line
680  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
681  {
683  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
684  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
685  }
686 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsSelected() const
Definition: base_struct.h:203
bool IsVisible() const
Definition: eda_text.h:185
bool IsMoving() const
Definition: base_struct.h:200
int color
Definition: DXF_plotter.cpp:61
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_field.cpp:315
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:209
EESCHEMA_SETTINGS * eeconfig()
const wxPoint GetPosition() const override
Definition: lib_field.h:180
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:179
const wxPoint GetEnd() const
Definition: eda_rect.h:116
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:340
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxSize & GetTextSize() const
Definition: eda_text.h:238
const wxPoint GetPosition() const
Definition: eda_rect.h:115
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
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:176
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsForceVisible() const
Definition: base_struct.h:286
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
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
Return the string associated with the text object.
Definition: eda_text.h:126
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [8/21]

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

Definition at line 689 of file sch_painter.cpp.

690 {
691  if( !isUnitAndConversionShown( aText ) )
692  return;
693 
694  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
695 
696  if( drawingShadows && !aText->IsSelected() )
697  return;
698 
699  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
700 
701  if( !aText->IsVisible() )
702  {
704  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
705  else
706  return;
707  }
708 
709  EDA_RECT bBox = aText->GetBoundingBox();
710  bBox.RevertYAxis();
711  VECTOR2D pos = mapCoords( bBox.Centre() );
712  double orient = aText->GetTextAngleRadians();
713 
716  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
717  m_gal->SetIsFill( false );
718  m_gal->SetIsStroke( true );
720  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
721  m_gal->SetFontBold( aText->IsBold() );
722  m_gal->SetFontItalic( aText->IsItalic() );
723  strokeText( aText->GetText(), pos, orient );
724 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:182
bool IsSelected() const
Definition: base_struct.h:203
bool IsVisible() const
Definition: eda_text.h:185
int color
Definition: DXF_plotter.cpp:61
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:209
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:179
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxSize & GetTextSize() const
Definition: eda_text.h:238
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
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:176
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:359
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint Centre() const
Definition: eda_rect.h:62
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
Return the string associated with the text object.
Definition: eda_text.h:126
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [9/21]

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

Definition at line 1162 of file sch_painter.cpp.

1163 {
1164  if( !isUnitAndConversionShown( aCurve ) )
1165  return;
1166 
1167  if( setDeviceColors( aCurve, aLayer ) )
1168  {
1169  BEZIER_POLY poly ( aCurve->GetPoints() );
1170  std::vector<wxPoint> pts;
1171  std::deque<VECTOR2D> pts_xformed;
1172  poly.GetPoly( pts );
1173 
1174  for( const auto &p : pts )
1175  pts_xformed.push_back( mapCoords( p ) );
1176 
1177  m_gal->DrawPolygon( pts_xformed );
1178  }
1179 }
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:110
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:68
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() [10/21]

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

Definition at line 1430 of file sch_painter.cpp.

1431 {
1432  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1433  LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
1434 
1435  // Copy the source so we can re-orient and translate it.
1436  LIB_PART tempPart( *originalPart );
1437 
1438  tempPart.SetFlags( aComp->GetFlags() );
1439 
1440  orientPart( &tempPart, aComp->GetOrientation() );
1441 
1442  for( auto& tempItem : tempPart.GetDrawItems() )
1443  {
1444  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1445  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition() ) );
1446  }
1447 
1448  // Copy the pin info from the component to the temp pins
1449  LIB_PINS tempPins;
1450  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1451  const SCH_PIN_PTRS compPins = aComp->GetSchPins();
1452 
1453  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1454  {
1455  LIB_PIN* tempPin = tempPins[ i ];
1456  const SCH_PIN* compPin = compPins[ i ];
1457 
1458  tempPin->ClearFlags();
1459  tempPin->SetFlags( compPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1460 
1461  if( compPin->IsDangling() )
1462  tempPin->SetFlags( IS_DANGLING );
1463  }
1464 
1465  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1466 
1467  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1468  for( SCH_FIELD& field : aComp->GetFields() )
1469  draw( &field, aLayer );
1470 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
std::vector< SCH_PIN * > SCH_PIN_PTRS
Definition: sch_component.h:71
int GetOrientation()
Get the display symbol orientation.
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:88
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:232
const wxPoint GetPosition() const override
Define a library symbol object.
std::unique_ptr< LIB_PART > & GetPartRef()
static VECTOR2D mapCoords(const wxPoint &aCoord)
static void orientPart(LIB_PART *part, int orientation)
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:145
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:234
SCH_PIN_PTRS GetSchPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.

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(), LIB_PART::GetPins(), SCH_COMPONENT::GetPosition(), SCH_COMPONENT::GetSchPins(), SCH_COMPONENT::GetUnit(), IS_DANGLING, SCH_PIN::IsDangling(), KIGFX::mapCoords(), KIGFX::orientPart(), and EDA_ITEM::SetFlags().

◆ draw() [11/21]

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

Definition at line 1197 of file sch_painter.cpp.

1198 {
1199  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1200 
1201  if( drawingShadows && !aJct->IsSelected() )
1202  return;
1203 
1204  COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows );
1205 
1206  int junctionSize = m_schSettings.m_JunctionSize / 2.0;
1207 
1208  if( aJct->GetDiameter() != 0 )
1209  junctionSize = aJct->GetDiameter() / 2;
1210 
1211  m_gal->SetIsStroke( drawingShadows );
1212  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1214  m_gal->SetIsFill( !drawingShadows );
1215  m_gal->SetFillColor( color );
1216  m_gal->DrawCircle( aJct->GetPosition(), junctionSize );
1217 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:203
int color
Definition: DXF_plotter.cpp:61
int GetDiameter() const
Definition: sch_junction.h:100
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint GetPosition() const override
Definition: sch_junction.h:97
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:271
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.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [12/21]

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

Definition at line 1473 of file sch_painter.cpp.

1474 {
1475  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1476 
1477  if( drawingShadows && !aField->IsSelected() )
1478  return;
1479 
1480  aLayer = aField->GetLayer();
1481 
1482  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1483 
1484  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
1485  {
1487  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1488  else
1489  return;
1490  }
1491 
1492  if( aField->IsVoid() )
1493  return;
1494 
1495  if( drawingShadows && aField->GetParent()->IsSelected()
1497  {
1498  return;
1499  }
1500 
1501  // Calculate the text orientation according to the parent orientation.
1502  int orient = (int) aField->GetTextAngle();
1503 
1504  if( aField->GetParent() && aField->GetParent()->Type() == SCH_COMPONENT_T )
1505  {
1506  if( static_cast<SCH_COMPONENT*>( aField->GetParent() )->GetTransform().y1 )
1507  {
1508  // Rotate component 90 degrees.
1509  if( orient == TEXT_ANGLE_HORIZ )
1510  orient = TEXT_ANGLE_VERT;
1511  else
1512  orient = TEXT_ANGLE_HORIZ;
1513  }
1514  }
1515 
1516  /* Calculate the text justification, according to the component orientation/mirror.
1517  * This is a bit complicated due to cumulative calculations:
1518  * - numerous cases (mirrored or not, rotation)
1519  * - the DrawGraphicText function recalculate also H and H justifications according to the
1520  * text orientation.
1521  * - When a component is mirrored, the text is not mirrored and justifications are
1522  * complicated to calculate
1523  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1524  * to know the text coordinate considered as centered
1525  */
1526  EDA_RECT boundaryBox = aField->GetBoundingBox();
1527  wxPoint textpos = boundaryBox.Centre();
1528 
1530  m_gal->SetIsStroke( true );
1531 
1532  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
1533  {
1534  m_gal->SetIsFill( true );
1535  m_gal->SetFillColor( color );
1536  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1537  boundaryBox.RevertYAxis();
1538 
1539  m_gal->DrawRectangle( mapCoords( boundaryBox.GetPosition() ),
1540  mapCoords( boundaryBox.GetEnd() ) );
1541  }
1542  else
1543  {
1546  m_gal->SetIsFill( false );
1547  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1548  m_gal->SetFontBold( aField->IsBold() );
1549  m_gal->SetFontItalic( aField->IsItalic() );
1550  m_gal->SetTextMirrored( aField->IsMirrored() );
1551  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
1552 
1553  strokeText( aField->GetShownText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
1554  }
1555 
1556  // Draw the umbilical line
1557  if( aField->IsMoving() )
1558  {
1559  wxPoint parentPos = aField->GetParentPosition();
1560 
1562  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1563  m_gal->DrawLine( textpos, parentPos );
1564  }
1565 }
#define TEXT_ANGLE_HORIZ
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:182
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsMirrored() const
Definition: eda_text.h:188
bool IsSelected() const
Definition: base_struct.h:203
#define TEXT_ANGLE_VERT
bool IsVisible() const
Definition: eda_text.h:185
bool IsMoving() const
Definition: base_struct.h:200
int color
Definition: DXF_plotter.cpp:61
double GetTextAngle() const
Definition: eda_text.h:173
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:209
EESCHEMA_SETTINGS * eeconfig()
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:102
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:293
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:179
const wxPoint GetEnd() const
Definition: eda_rect.h:116
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxSize & GetTextSize() const
Definition: eda_text.h:238
const wxPoint GetPosition() const
Definition: eda_rect.h:115
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:271
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsForceVisible() const
Definition: base_struct.h:286
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:234
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint Centre() const
Definition: eda_rect.h:62
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.
wxPoint GetParentPosition() const
Definition: sch_field.cpp:595
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References EDA_RECT::Centre(), color, EESCHEMA_SETTINGS::SELECTION::draw_selected_children, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), KIGFX::eeconfig(), SCH_FIELD::GetBoundingBox(), EDA_RECT::GetEnd(), SCH_ITEM::GetLayer(), KIGFX::GAL::GetLineWidth(), EDA_ITEM::GetParent(), SCH_FIELD::GetParentPosition(), EDA_RECT::GetPosition(), getRenderColor(), SCH_FIELD::GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), getTextThickness(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_ITEM::IsForceVisible(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), SCH_FIELD::IsVoid(), LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, EESCHEMA_SETTINGS::m_Selection, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::mapCoords(), EDA_RECT::RevertYAxis(), SCH_COMPONENT_T, 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::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), strokeText(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, and EDA_ITEM::Type().

◆ draw() [13/21]

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

Definition at line 1294 of file sch_painter.cpp.

1295 {
1296  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1297 
1298  if( drawingShadows && !aText->IsSelected() )
1299  return;
1300 
1301  switch( aText->Type() )
1302  {
1303  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1304  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1305  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1306  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1307  default: aLayer = LAYER_NOTES; break;
1308  }
1309 
1310  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1311 
1312  if( m_schematic )
1313  {
1314  SCH_CONNECTION* conn = aText->Connection( m_schematic->CurrentSheet() );
1315 
1316  if( conn && conn->IsBus() )
1317  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1318  }
1319 
1320  if( !( aText->IsVisible() || aText->IsForceVisible() ) )
1321  {
1323  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1324  else
1325  return;
1326  }
1327 
1328  m_gal->SetIsFill( false );
1329  m_gal->SetIsStroke( true );
1330  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
1332  m_gal->SetTextAttributes( aText );
1333 
1334  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset( &m_schSettings );
1335  wxString shownText( aText->GetShownText() );
1336 
1337  if( drawingShadows )
1338  {
1340  {
1341  EDA_RECT bBox = aText->GetBoundingBox();
1342 
1343  m_gal->SetIsFill( true );
1344  m_gal->SetFillColor( color );
1345  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1346  bBox.RevertYAxis();
1347 
1348  m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1349  return;
1350  }
1351 
1352  switch( aText->GetLabelSpinStyle() )
1353  {
1355  text_offset.x += getShadowWidth() / 2;
1356  break;
1357  case LABEL_SPIN_STYLE::UP:
1358  text_offset.y += getShadowWidth() / 2;
1359  break;
1361  text_offset.x -= getShadowWidth() / 2;
1362  break;
1364  text_offset.y -= getShadowWidth() / 2;
1365  break;
1366  }
1367  }
1368 
1369  if( !shownText.IsEmpty() )
1370  {
1371  strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1372  }
1373 
1374  if( aText->IsDangling() )
1375  drawDanglingSymbol( aText->GetTextPos(), Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1376  drawingShadows );
1377 }
bool IsDangling() const override
Definition: sch_text.h:302
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
SCHEMATIC * m_schematic
Definition: sch_painter.h:201
float GetLineWidth() const
Get the line width.
void drawDanglingSymbol(const wxPoint &aPos, int aWidth, bool aDrawingShadows)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:203
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:185
virtual wxPoint GetSchematicTextOffset(RENDER_SETTINGS *aSettings) const
Definition: sch_text.cpp:161
int color
Definition: DXF_plotter.cpp:61
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:209
EESCHEMA_SETTINGS * eeconfig()
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
const wxPoint GetEnd() const
Definition: eda_rect.h:116
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define DANGLING_SYMBOL_SIZE
const wxPoint GetPosition() const
Definition: eda_rect.h:115
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:232
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:442
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:487
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:147
double GetTextAngleRadians() const
Definition: eda_text.h:176
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsForceVisible() const
Definition: base_struct.h:286
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:122
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [14/21]

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

Definition at line 1604 of file sch_painter.cpp.

1605 {
1606  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1607 
1608  if( drawingShadows && !aLabel->IsSelected() )
1609  return;
1610 
1611  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1612 
1613  if( m_schematic )
1614  {
1615  SCH_CONNECTION* conn = aLabel->Connection( m_schematic->CurrentSheet() );
1616 
1617  if( conn && conn->IsBus() )
1618  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1619  }
1620 
1621  std::vector<wxPoint> pts;
1622  std::deque<VECTOR2D> pts2;
1623 
1624  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1625 
1626  for( auto p : pts )
1627  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1628 
1629  m_gal->SetIsFill( true );
1631  m_gal->SetIsStroke( true );
1632  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1634  m_gal->DrawPolyline( pts2 );
1635 
1636  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1637 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
SCHEMATIC * m_schematic
Definition: sch_painter.h:201
bool IsSelected() const
Definition: base_struct.h:203
int color
Definition: DXF_plotter.cpp:61
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
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
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:147
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:247
void CreateGraphicShape(RENDER_SETTINGS *aSettings, std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1169
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:199
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:122
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [15/21]

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

Definition at line 1568 of file sch_painter.cpp.

1569 {
1570  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1571 
1572  if( drawingShadows && !aLabel->IsSelected() )
1573  return;
1574 
1575  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1576 
1577  std::vector<wxPoint> pts;
1578  std::deque<VECTOR2D> pts2;
1579 
1580  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1581 
1582  for( auto p : pts )
1583  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1584 
1585  // the text is drawn inside the graphic shape.
1586  // On Cairo the graphic shape is filled by the background
1587  // before drawing the text ().
1588  // However if the text is selected, it is draw twice:
1589  // first, on LAYER_SELECTION_SHADOWS
1590  // second, on the text layer.
1591  // the second must not erase the first drawing.
1592  bool fillBg = ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected();
1593  m_gal->SetIsFill( fillBg );
1595  m_gal->SetIsStroke( true );
1596  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1598  m_gal->DrawPolyline( pts2 );
1599 
1600  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1601 }
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:203
int color
Definition: DXF_plotter.cpp:61
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void CreateGraphicShape(RENDER_SETTINGS *aRenderSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:953
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:247
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:199
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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() [16/21]

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

Definition at line 1639 of file sch_painter.cpp.

1640 {
1641  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1642 
1643  if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS )
1644  {
1645  for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
1646  {
1647  if( drawingShadows && !aSheet->IsSelected() && !sheetPin->IsSelected() )
1648  continue;
1649 
1650  if( drawingShadows && aSheet->IsSelected()
1652  {
1653  break;
1654  }
1655 
1656  int width = std::max( aSheet->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
1657  wxPoint initial_pos = sheetPin->GetTextPos();
1658  wxPoint offset_pos = initial_pos;
1659 
1660  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1661  switch( sheetPin->GetEdge() )
1662  {
1663  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1664  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1665  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1666  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1667  default: break;
1668  }
1669 
1670  sheetPin->SetTextPos( offset_pos );
1671  draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
1672  m_gal->DrawLine( offset_pos, initial_pos );
1673  sheetPin->SetTextPos( initial_pos );
1674  }
1675  }
1676 
1677  VECTOR2D pos = aSheet->GetPosition();
1678  VECTOR2D size = aSheet->GetSize();
1679 
1680  if( aLayer == LAYER_SHEET_BACKGROUND )
1681  {
1683  m_gal->SetIsFill( true );
1684  m_gal->SetIsStroke( false );
1685 
1686  m_gal->DrawRectangle( pos, pos + size );
1687  }
1688 
1689  if( aLayer == LAYER_SHEET || aLayer == LAYER_SELECTION_SHADOWS )
1690  {
1691  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1692  m_gal->SetIsStroke( true );
1693  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1694  m_gal->SetIsFill( false );
1695 
1696  m_gal->DrawRectangle( pos, pos + size );
1697 
1698  if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children && aSheet->IsSelected() )
1699  return;
1700 
1701  for( SCH_FIELD& field : aSheet->GetFields() )
1702  draw( &field, aLayer );
1703  }
1704 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:203
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
EESCHEMA_SETTINGS * eeconfig()
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetPenWidth() const override
Definition: sch_sheet.cpp:492
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:362
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint GetPosition() const override
Definition: sch_sheet.h:570
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
int GetDefaultPenWidth() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxSize GetSize()
Definition: sch_sheet.h:284
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

References draw(), EESCHEMA_SETTINGS::SELECTION::draw_selected_children, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), KIGFX::eeconfig(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), SCH_SHEET::GetFields(), getLineWidth(), SCH_SHEET::GetPenWidth(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), getRenderColor(), SCH_SHEET::GetSize(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_HIERLABEL, LAYER_SELECTION_SHADOWS, LAYER_SHEET, LAYER_SHEET_BACKGROUND, KIGFX::PAINTER::m_gal, m_schSettings, EESCHEMA_SETTINGS::m_Selection, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), SHEET_BOTTOM_SIDE, SHEET_LEFT_SIDE, SHEET_RIGHT_SIDE, SHEET_TOP_SIDE, wxPoint::x, and wxPoint::y.

◆ draw() [17/21]

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

Definition at line 1707 of file sch_painter.cpp.

1708 {
1709  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1710 
1711  if( drawingShadows && !aNC->IsSelected() )
1712  return;
1713 
1714  m_gal->SetIsStroke( true );
1715  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1716  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1717  m_gal->SetIsFill( false );
1718 
1719  VECTOR2D p = aNC->GetPosition();
1720  int delta = std::max( aNC->GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
1721 
1722  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1723  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1724 }
bool IsSelected() const
Definition: base_struct.h:203
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetSize() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const wxPoint GetPosition() const override
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
int GetDefaultPenWidth() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

◆ draw() [18/21]

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

Definition at line 1812 of file sch_painter.cpp.

1813 {
1814  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1815 
1816  if( drawingShadows && !aMarker->IsSelected() )
1817  return;
1818 
1819  COLOR4D color = getRenderColor( aMarker, aMarker->GetColorLayer(), drawingShadows );
1820 
1821  m_gal->Save();
1822  m_gal->Translate( aMarker->GetPosition() );
1823  m_gal->SetIsFill( !drawingShadows );
1824  m_gal->SetFillColor( color );
1825  m_gal->SetIsStroke( drawingShadows );
1826  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1828 
1829  SHAPE_LINE_CHAIN polygon;
1830  aMarker->ShapeToPolygon( polygon );
1831 
1832  m_gal->DrawPolygon( polygon );
1833  m_gal->Restore();
1834 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
SCH_LAYER_ID GetColorLayer() const
Definition: sch_marker.cpp:95
bool IsSelected() const
Definition: base_struct.h:203
int color
Definition: DXF_plotter.cpp:61
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint GetPosition() const override
Definition: sch_marker.h:101
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.
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.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [19/21]

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

Definition at line 1767 of file sch_painter.cpp.

1768 {
1769  m_gal->Save();
1770  m_gal->Translate( aBitmap->GetPosition() );
1771 
1772  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1773  // factor is similar to a local zoom
1774  double img_scale = aBitmap->GetImageScale();
1775 
1776  if( img_scale != 1.0 )
1777  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1778 
1779  if( aLayer == LAYER_DRAW_BITMAPS )
1780  {
1781  m_gal->DrawBitmap( *aBitmap->GetImage() );
1782  }
1783 
1784  if( aLayer == LAYER_SELECTION_SHADOWS )
1785  {
1786  if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
1787  {
1788  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1789  m_gal->SetIsStroke( true );
1792  m_gal->SetIsFill( false );
1793 
1794  // Draws a bounding box.
1795  VECTOR2D bm_size( aBitmap->GetSize() );
1796  // bm_size is the actual image size in UI.
1797  // but m_gal scale was previously set to img_scale
1798  // so recalculate size relative to this image size.
1799  bm_size.x /= img_scale;
1800  bm_size.y /= img_scale;
1801  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1802  VECTOR2D end = origin + bm_size;
1803 
1804  m_gal->DrawRectangle( origin, end );
1805  }
1806  }
1807 
1808  m_gal->Restore();
1809 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:203
to handle and draw images bitmaps
int color
Definition: DXF_plotter.cpp:61
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
bool IsBrightened() const
Definition: base_struct.h:205
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxSize GetSize() const
Definition: sch_bitmap.cpp:125
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxPoint GetPosition() const override
Definition: sch_bitmap.h:140
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
double GetImageScale() const
Definition: sch_bitmap.h: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.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

◆ draw() [20/21]

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

Definition at line 1220 of file sch_painter.cpp.

1221 {
1222  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1223 
1224  if( drawingShadows && !aLine->IsSelected() )
1225  return;
1226 
1227  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1228  float width = getLineWidth( aLine, drawingShadows );
1229 
1230  m_gal->SetIsStroke( true );
1232  m_gal->SetLineWidth( width );
1233 
1234  if( aLine->GetLineStyle() <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1235  {
1236  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1237  }
1238  else
1239  {
1240  VECTOR2D start = aLine->GetStartPoint();
1241  VECTOR2D end = aLine->GetEndPoint();
1242 
1243  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1244  clip.Normalize();
1245 
1246  double theta = atan2( end.y - start.y, end.x - start.x );
1247  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1248 
1249  switch( aLine->GetLineStyle() )
1250  {
1251  default:
1252  case PLOT_DASH_TYPE::DASH:
1253  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1254  break;
1255  case PLOT_DASH_TYPE::DOT:
1256  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1257  break;
1259  strokes[0] = DASH_MARK_LEN( width );
1260  strokes[2] = DOT_MARK_LEN( width );
1261  break;
1262  }
1263 
1264  for( size_t i = 0; i < 10000; ++i )
1265  {
1266  // Calculations MUST be done in doubles to keep from accumulating rounding
1267  // errors as we go.
1268  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1269  start.y + strokes[ i % 4 ] * sin( theta ) );
1270 
1271  // Drawing each segment can be done rounded to ints.
1272  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1273  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1274 
1275  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1276  break;
1277  else if( i % 2 == 0 )
1278  m_gal->DrawLine( segStart, segEnd );
1279 
1280  start = next;
1281  }
1282  }
1283 
1284  if( aLine->IsStartDangling() )
1285  drawDanglingSymbol( aLine->GetStartPoint(), getLineWidth( aLine, drawingShadows ),
1286  drawingShadows );
1287 
1288  if( aLine->IsEndDangling() )
1289  drawDanglingSymbol( aLine->GetEndPoint(), getLineWidth( aLine, drawingShadows ),
1290  drawingShadows );
1291 }
CITER next(CITER it)
Definition: ptree.cpp:130
void drawDanglingSymbol(const wxPoint &aPos, int aWidth, bool aDrawingShadows)
wxPoint GetStartPoint() const
Definition: sch_line.h:94
bool IsSelected() const
Definition: base_struct.h:203
int color
Definition: DXF_plotter.cpp:61
#define DASH_MARK_LEN(aLineWidth)
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
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:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
PLOT_DASH_TYPE GetLineStyle() const
Definition: sch_line.cpp:257
bool IsEndDangling() const
Definition: sch_line.h:191
#define DOT_MARK_LEN(aLineWidth)
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:271
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsStartDangling() const
Definition: sch_line.h:190
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
#define DASH_GAP_LEN(aLineWidth)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
wxPoint GetEndPoint() const
Definition: sch_line.h:97

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

◆ draw() [21/21]

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

Definition at line 1727 of file sch_painter.cpp.

1728 {
1729  SCH_LINE line;
1730  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1731 
1732  line.SetLayer( aEntry->Type() == SCH_BUS_WIRE_ENTRY_T ? LAYER_WIRE : LAYER_BUS );
1733 
1734  if( aEntry->IsSelected() )
1735  line.SetSelected();
1736 
1737  line.SetStartPoint( aEntry->GetPosition() );
1738  line.SetEndPoint( aEntry->m_End() );
1739  line.SetStroke( aEntry->GetStroke() );
1740 
1741  if( aEntry->GetStrokeColor() == COLOR4D::UNSPECIFIED )
1742  {
1743  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1744 
1745  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1746  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1747 
1748  line.SetLineColor( color );
1749  }
1750 
1751  draw( &line, aLayer );
1752 
1753  m_gal->SetIsFill( false );
1754  m_gal->SetIsStroke( true );
1755  m_gal->SetLineWidth( drawingShadows ? getShadowWidth() : 1.0 );
1756 
1757  if( aEntry->IsDanglingStart() )
1758  m_gal->DrawCircle( aEntry->GetPosition(),
1759  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1760 
1761  if( aEntry->IsDanglingEnd() )
1762  m_gal->DrawCircle( aEntry->m_End(),
1763  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1764 }
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:37
bool IsSelected() const
Definition: base_struct.h:203
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:78
const wxPoint GetPosition() const override
int color
Definition: DXF_plotter.cpp:61
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:56
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:372
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:98
bool IsDanglingStart() const
Definition: sch_bus_entry.h:55
void SetSelected()
Definition: base_struct.h:208
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:95
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:278
void SetLineColor(const COLOR4D &aColor)
Definition: sch_line.cpp:206
wxPoint m_End() const
virtual int GetPenWidth() const
Definition: sch_item.h:288
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_line.h:125
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
COLOR4D GetStrokeColor() const
Definition: sch_bus_entry.h:84
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References color, draw(), KIGFX::GAL::DrawCircle(), SCH_ITEM::GetPenWidth(), SCH_BUS_ENTRY_BASE::GetPosition(), getRenderColor(), getShadowWidth(), SCH_BUS_ENTRY_BASE::GetStroke(), SCH_BUS_ENTRY_BASE::GetStrokeColor(), 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, SCH_BUS_WIRE_ENTRY_T, SCH_LINE::SetEndPoint(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), SCH_ITEM::SetLayer(), SCH_LINE::SetLineColor(), KIGFX::GAL::SetLineWidth(), EDA_ITEM::SetSelected(), SCH_LINE::SetStartPoint(), SCH_LINE::SetStroke(), TARGET_BUSENTRY_RADIUS, EDA_ITEM::Type(), and KIGFX::COLOR4D::UNSPECIFIED.

◆ drawDanglingSymbol()

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

Definition at line 1184 of file sch_painter.cpp.

1185 {
1186  wxPoint radius( aWidth + Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1187  aWidth + Mils2iu( DANGLING_SYMBOL_SIZE /2 ) );
1188 
1189  m_gal->SetIsStroke( true );
1190  m_gal->SetIsFill( false );
1191  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
1192 
1193  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1194 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define DANGLING_SYMBOL_SIZE
#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 748 of file sch_painter.cpp.

749 {
750  m_gal->SetIsFill( false );
751  m_gal->SetIsStroke( true );
752  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
753 
755 }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
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:46
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().

◆ externalPinDecoSize()

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

Definition at line 738 of file sch_painter.cpp.

739 {
742 
743  return aPin.GetNumberTextSize() / 2;
744 }
int GetNumberTextSize() const
Definition: lib_pin.h:204
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

Referenced by draw().

◆ fillIfSelection()

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

Definition at line 516 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ getLineWidth() [1/2]

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

Definition at line 317 of file sch_painter.cpp.

318 {
319  float width = (float) std::max( aItem->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
320 
321  if( aItem->IsSelected() && aDrawingShadows )
322  width += getShadowWidth();
323 
324  return width;
325 }
virtual int GetPenWidth() const =0
bool IsSelected() const
Definition: base_struct.h:203
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), LIB_ITEM::GetPenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), and m_schSettings.

Referenced by draw(), and setDeviceColors().

◆ getLineWidth() [2/2]

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

Definition at line 328 of file sch_painter.cpp.

329 {
330  wxCHECK( aItem, static_cast<float>( m_schSettings.m_DefaultWireThickness ) );
331 
332  float width;
333  const SCH_LINE* line = dynamic_cast<const SCH_LINE*>( aItem );
334 
335  if( line && aItem->GetLayer() == LAYER_WIRE )
336  {
337  if( line->GetLineSize() != 0 )
338  width = (float) line->GetLineSize();
339  else
340  width = (float) m_schSettings.m_DefaultWireThickness;
341  }
342  else if( line && aItem->GetLayer() == LAYER_BUS )
343  {
344  if( line->GetLineSize() != 0 )
345  width = (float) line->GetLineSize();
346  else
347  width = (float) m_schSettings.m_DefaultBusThickness;
348  }
349  else
350  {
351  width = (float) std::max( aItem->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
352  }
353 
354  if( aItem->IsSelected() && aDrawingShadows )
355  width += getShadowWidth();
356 
357  return width;
358 }
bool IsSelected() const
Definition: base_struct.h:203
virtual int GetPenWidth() const
Definition: sch_item.h:288
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:271
int GetLineSize() const
Definition: sch_line.h:136
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), SCH_ITEM::GetLayer(), SCH_LINE::GetLineSize(), SCH_ITEM::GetPenWidth(), getShadowWidth(), EDA_ITEM::IsSelected(), LAYER_BUS, LAYER_WIRE, KIGFX::SCH_RENDER_SETTINGS::m_DefaultBusThickness, KIGFX::SCH_RENDER_SETTINGS::m_DefaultWireThickness, and m_schSettings.

◆ getRenderColor()

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

Definition at line 253 of file sch_painter.cpp.

254 {
256 
257  if( aItem->Type() == SCH_LINE_T )
258  {
259  COLOR4D lineColor = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
260 
261  if( lineColor != COLOR4D::UNSPECIFIED )
262  color = lineColor;
263  }
264  else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
265  {
266  COLOR4D busEntryColor = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetStrokeColor();
267 
268  if( busEntryColor != COLOR4D::UNSPECIFIED )
269  color = busEntryColor;
270  }
271  else if( aItem->Type() == SCH_JUNCTION_T )
272  {
273  COLOR4D junctionColor = static_cast<const SCH_JUNCTION*>( aItem )->GetColor();
274 
275  if( junctionColor != COLOR4D::UNSPECIFIED )
276  color = junctionColor;
277  }
278  else if( aItem->Type() == SCH_SHEET_T )
279  {
280  SCH_SHEET* sheet = (SCH_SHEET*) aItem;
281 
282  // Lazy fixup of legacy sheets with no color specifications
283  if( sheet->GetBorderColor() == COLOR4D::UNSPECIFIED )
285 
286  if( sheet->GetBackgroundColor() == COLOR4D::UNSPECIFIED )
288 
290  color = m_schSettings.GetLayerColor( aLayer );
291  else if( aLayer == LAYER_SHEET )
292  color = sheet->GetBorderColor();
293  else if( aLayer == LAYER_SHEET_BACKGROUND )
294  color = sheet->GetBackgroundColor();
295  }
296 
297  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
298  {
300 
301  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
302  color = color.WithAlpha( 0.2 );
303  }
304  else if( aItem->IsSelected() )
305  {
306  if( aDrawingShadows )
308  }
309 
311  color = color.Darken( 0.5f );
312 
313  return color;
314 }
bool IsSelected() const
Definition: base_struct.h:203
int color
Definition: DXF_plotter.cpp:61
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:307
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:290
bool IsBrightened() const
Definition: base_struct.h:205
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:372
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:293
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:294
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:291
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

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

Referenced by draw(), and setDeviceColors().

◆ GetSettings()

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

Implements KIGFX::PAINTER.

Definition at line 143 of file sch_painter.h.

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

References m_schSettings.

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

◆ getShadowWidth()

float KIGFX::SCH_PAINTER::getShadowWidth ( )
private

Definition at line 243 of file sch_painter.cpp.

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

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

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

◆ getTextThickness() [1/4]

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

Definition at line 361 of file sch_painter.cpp.

362 {
363  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
364 
365  if( aItem->IsSelected() && aDrawingShadows )
366  width += getShadowWidth();
367 
368  return width;
369 }
bool IsSelected() const
Definition: base_struct.h:203
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

Referenced by draw().

◆ getTextThickness() [2/4]

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

Definition at line 372 of file sch_painter.cpp.

373 {
374  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
375 
376  if( aItem->IsSelected() && aDrawingShadows )
377  width += getShadowWidth();
378 
379  return width;
380 }
bool IsSelected() const
Definition: base_struct.h:203
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

◆ getTextThickness() [3/4]

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

Definition at line 383 of file sch_painter.cpp.

384 {
385  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
387 
388  if( aItem->IsSelected() && aDrawingShadows )
389  width += getShadowWidth();
390 
391  return width;
392 }
bool IsSelected() const
Definition: base_struct.h:203
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

◆ getTextThickness() [4/4]

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

Definition at line 395 of file sch_painter.cpp.

396 {
397  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
399 
400  if( aItem->IsSelected() && aDrawingShadows )
401  width += getShadowWidth();
402 
403  return width;
404 }
bool IsSelected() const
Definition: base_struct.h:203
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

◆ internalPinDecoSize()

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

Definition at line 727 of file sch_painter.cpp.

728 {
731 
732  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
733 }
int GetNameTextSize() const
Definition: lib_pin.h:177
int GetNumberTextSize() const
Definition: lib_pin.h:204
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

Referenced by draw().

◆ isUnitAndConversionShown()

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

Definition at line 223 of file sch_painter.cpp.

224 {
225  if( m_schSettings.m_ShowUnit // showing a specific unit
226  && aItem->GetUnit() // item is unit-specific
227  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
228  {
229  return false;
230  }
231 
232  if( m_schSettings.m_ShowConvert // showing a specific conversion
233  && aItem->GetConvert() // item is conversion-specific
234  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
235  {
236  return false;
237  }
238 
239  return true;
240 }
int GetUnit() const
Definition: lib_item.h:295
int GetConvert() const
Definition: lib_item.h:298
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199

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

460 {
461  switch( aLayer )
462  {
464  if( aItem->IsSelected() )
465  {
466  m_gal->SetIsFill( false );
467  m_gal->SetIsStroke( true );
468  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
469  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
470  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
471  return true;
472  }
473 
474  return false;
475 
477  if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
478  {
479  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
480 
481  // These actions place the item over others, so allow a modest transparency here
482  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
483  fillColor = fillColor.WithAlpha( 0.75 );
484 
486  m_gal->SetFillColor( fillColor );
487  m_gal->SetIsStroke( false );
488  return true;
489  }
490 
491  return false;
492 
493  case LAYER_DEVICE:
494  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
495  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
496 
497  if( aItem->GetPenWidth() > 0 || aItem->GetFillMode() == NO_FILL )
498  {
499  m_gal->SetIsStroke( true );
500  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
501  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
502  }
503  else
504  {
505  m_gal->SetIsStroke( false );
506  }
507 
508  return true;
509 
510  default:
511  return false;
512  }
513 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual int GetPenWidth() const =0
bool IsSelected() const
Definition: base_struct.h:203
bool IsMoving() const
Definition: base_struct.h:200
FILL_T GetFillMode() const
Definition: lib_item.h:301
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:307
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsDragging() const
Definition: base_struct.h:201
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool IsResized() const
Definition: base_struct.h:204
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.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99

References FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, LIB_ITEM::GetFillMode(), getLineWidth(), LIB_ITEM::GetPenWidth(), 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, NO_FILL, 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 78 of file painter.h.

79  {
80  m_gal = aGal;
81  }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110

References KIGFX::PAINTER::m_gal.

◆ SetSchematic()

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

Definition at line 148 of file sch_painter.h.

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

References m_schematic.

◆ strokeText()

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

Definition at line 407 of file sch_painter.cpp.

408 {
409  m_gal->StrokeText( aText, aPosition, aAngle );
410 }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.

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

Referenced by draw().

◆ triLine()

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

Definition at line 452 of file sch_painter.cpp.

453 {
454  m_gal->DrawLine( a, b );
455  m_gal->DrawLine( b, c );
456 }
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:110

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

◆ m_gal

GAL* KIGFX::PAINTER::m_gal
protectedinherited

◆ m_schematic

SCHEMATIC* KIGFX::SCH_PAINTER::m_schematic
private

Definition at line 201 of file sch_painter.h.

Referenced by draw(), and SetSchematic().

◆ m_schSettings


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