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

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 159 of file sch_painter.cpp.

159  :
160  KIGFX::PAINTER( aGal ),
161  m_schematic( nullptr )
162 { }
SCHEMATIC * m_schematic
Definition: sch_painter.h:206
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 142 of file sch_painter.h.

143  {
144  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
145  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

170 {
171  auto item2 = dynamic_cast<const EDA_ITEM*>( aItem );
172  auto item = const_cast<EDA_ITEM*>( item2 );
173 
174  if( !item2 )
175  return false;
176 
177 #ifdef CONNECTIVITY_DEBUG
178 
179  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
180  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
181 
182  if( conn )
183  {
184  auto pos = item->GetBoundingBox().Centre();
185  auto label = conn->Name( true );
186 
190  m_gal->SetLineWidth( Mils2ui( 2 ) );
191  m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
192  m_gal->StrokeText( conn->Name( true ), pos, 0.0, 0 );
193  }
194 
195 #endif
196 
197  switch( item->Type() )
198  {
223 
224  default: return false;
225  }
226 
227  return false;
228 }
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:80
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 507 of file sch_painter.cpp.

508 {
509  if( !isUnitAndConversionShown( aRect ) )
510  return;
511 
512  if( setDeviceColors( aRect, aLayer ) )
513  {
514  fillIfSelection( aLayer );
515  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
516  }
517 }
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)
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)
wxPoint GetPosition() const override
Definition: lib_rectangle.h:74

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

744 {
745  if( !isUnitAndConversionShown( aPin ) )
746  return;
747 
748  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
749 
750  if( drawingShadows && !aPin->IsSelected() )
751  return;
752 
753  VECTOR2I pos = mapCoords( aPin->GetPosition() );
754  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
755 
756  if( !aPin->IsVisible() )
757  {
759  {
760  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
761  }
762  else
763  {
764  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
765  drawPinDanglingSymbol( pos, drawingShadows );
766 
767  return;
768  }
769  }
770 
771  VECTOR2I p0;
772  VECTOR2I dir;
773  int len = aPin->GetLength();
774  int orient = aPin->GetOrientation();
775 
776  switch( orient )
777  {
778  case PIN_UP:
779  p0 = VECTOR2I( pos.x, pos.y - len );
780  dir = VECTOR2I( 0, 1 );
781  break;
782 
783  case PIN_DOWN:
784  p0 = VECTOR2I( pos.x, pos.y + len );
785  dir = VECTOR2I( 0, -1 );
786  break;
787 
788  case PIN_LEFT:
789  p0 = VECTOR2I( pos.x - len, pos.y );
790  dir = VECTOR2I( 1, 0 );
791  break;
792 
793  default:
794  case PIN_RIGHT:
795  p0 = VECTOR2I( pos.x + len, pos.y );
796  dir = VECTOR2I( -1, 0 );
797  break;
798  }
799 
800  VECTOR2D pc;
801 
802  m_gal->SetIsStroke( true );
803  m_gal->SetIsFill( false );
804  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
806  m_gal->SetFontBold( false );
807  m_gal->SetFontItalic( false );
808 
809  const int radius = externalPinDecoSize( *aPin );
810  const int diam = radius*2;
811  const int clock_size = internalPinDecoSize( *aPin );
812 
813  if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
814  {
815  m_gal->DrawLine( p0, pos );
816 
817  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
818  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
819  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
820  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
821 
822  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
823  }
824  else
825  {
826  switch( aPin->GetShape() )
827  {
829  m_gal->DrawLine( p0, pos );
830  break;
831 
833  m_gal->DrawCircle( p0 + dir * radius, radius );
834  m_gal->DrawLine( p0 + dir * ( diam ), pos );
835  break;
836 
838  pc = p0 - dir * clock_size ;
839 
840  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
841  pc,
842  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
843 
844  m_gal->DrawCircle( p0 + dir * radius, radius );
845  m_gal->DrawLine( p0 + dir * ( diam ), pos );
846  break;
847 
850  pc = p0 - dir * clock_size ;
851 
852  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
853  pc,
854  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
855 
856  if( !dir.y )
857  {
858  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
859  p0 + VECTOR2D(dir.x, -1) * diam,
860  p0 );
861  }
862  else /* MapX1 = 0 */
863  {
864  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
865  p0 + VECTOR2D(-1, dir.y) * diam,
866  p0 );
867  }
868 
869  m_gal->DrawLine( p0, pos );
870  break;
871 
873  m_gal->DrawLine( p0, pos );
874 
875  if( !dir.y )
876  {
877  triLine( p0 + VECTOR2D( 0, clock_size ),
878  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
879  p0 + VECTOR2D( 0, -clock_size ) );
880  }
881  else
882  {
883  triLine( p0 + VECTOR2D( clock_size, 0 ),
884  p0 + VECTOR2D( 0, -dir.y * clock_size ),
885  p0 + VECTOR2D( -clock_size, 0 ) );
886  }
887  break;
888 
890  m_gal->DrawLine( p0, pos );
891 
892  if( !dir.y )
893  {
894  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
895  p0 + VECTOR2D(dir.x, -1) * diam,
896  p0 );
897  }
898  else /* MapX1 = 0 */
899  {
900  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
901  p0 + VECTOR2D(-1, dir.y) * diam,
902  p0 );
903  }
904  break;
905 
906  case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
907  m_gal->DrawLine( p0, pos );
908 
909  if( !dir.y ) // Horizontal pin
910  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
911  else // Vertical pin
912  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
913  break;
914 
915  case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
916  m_gal->DrawLine( p0, pos );
917 
918  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
919  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
920  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
921  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
922  break;
923  }
924  }
925 
926 
927  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
928  drawPinDanglingSymbol( pos, drawingShadows );
929 
930  LIB_PART* libEntry = aPin->GetParent();
931 
932  // Draw the labels
933  if( drawingShadows && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() )
935  return;
936 
937  int textOffset = libEntry->GetPinNameOffset();
938 
939  float nameLineWidth = getLineWidth( aPin, drawingShadows );
940  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
941  float numLineWidth = getLineWidth( aPin, drawingShadows );
942  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
943 
944  #define PIN_TEXT_MARGIN 4.0
945 
946  // Four locations around a pin where text can be drawn
947  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
948  int size[4] = { 0, 0, 0, 0 };
949  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
950  COLOR4D colour[4];
951  wxString text[4];
952 
953  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
954  if( textOffset )
955  {
956  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
957  thickness[INSIDE] = nameLineWidth;
958  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
959  text [INSIDE] = aPin->GetName();
960 
961  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
962  thickness[ABOVE] = numLineWidth;
963  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
964  text [ABOVE] = aPin->GetNumber();
965  }
966  // Otherwise pin NAMES go above and pin NUMBERS go below
967  else
968  {
969  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
970  thickness[ABOVE] = nameLineWidth;
971  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
972  text [ABOVE] = aPin->GetName();
973 
974  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
975  thickness[BELOW] = numLineWidth;
976  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
977  text [BELOW] = aPin->GetNumber();
978  }
979 
981  {
982  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
983  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
984  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
985  text [OUTSIDE] = aPin->GetElectricalTypeName();
986  }
987 
988  if( !aPin->IsVisible() )
989  {
990  for( COLOR4D& c : colour )
991  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
992  }
993 
994  int insideOffset = textOffset;
995  int outsideOffset = 10;
996  float lineThickness = (float) m_schSettings.GetDefaultPenWidth();
997  float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + lineThickness ) / 2.0;
998  float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[BELOW] + lineThickness ) / 2.0;
999 
1000  if( drawingShadows )
1001  {
1002  for( float& t : thickness )
1003  t += getShadowWidth();
1004 
1005  insideOffset -= KiROUND( getShadowWidth() / 2 );
1006  outsideOffset -= KiROUND( getShadowWidth() / 2 );
1007  }
1008 
1009  #define SET_DC( i ) \
1010  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
1011  m_gal->SetLineWidth( thickness[i] ); \
1012  m_gal->SetStrokeColor( colour[i] )
1013 
1014  switch( orient )
1015  {
1016  case PIN_LEFT:
1017  if( size[INSIDE] )
1018  {
1019  SET_DC( INSIDE );
1022  strokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
1023  }
1024  if( size[OUTSIDE] )
1025  {
1026  SET_DC( OUTSIDE );
1029  strokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
1030  }
1031  if( size[ABOVE] )
1032  {
1033  SET_DC( ABOVE );
1036  strokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
1037  }
1038  if( size[BELOW] )
1039  {
1040  SET_DC( BELOW );
1043  strokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
1044  }
1045  break;
1046 
1047  case PIN_RIGHT:
1048  if( size[INSIDE] )
1049  {
1050  SET_DC( INSIDE );
1054  strokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
1055  }
1056  if( size[OUTSIDE] )
1057  {
1058  SET_DC( OUTSIDE );
1061  strokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
1062  }
1063  if( size[ABOVE] )
1064  {
1065  SET_DC( ABOVE );
1068  strokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
1069  }
1070  if( size[BELOW] )
1071  {
1072  SET_DC( BELOW );
1075  strokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
1076  }
1077  break;
1078 
1079  case PIN_DOWN:
1080  if( size[INSIDE] )
1081  {
1082  SET_DC( INSIDE );
1085  strokeText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
1086  }
1087  if( size[OUTSIDE] )
1088  {
1089  SET_DC( OUTSIDE );
1092  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
1093  }
1094  if( size[ABOVE] )
1095  {
1096  SET_DC( ABOVE );
1099  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
1100  }
1101  if( size[BELOW] )
1102  {
1103  SET_DC( BELOW );
1106  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
1107  }
1108  break;
1109 
1110  case PIN_UP:
1111  if( size[INSIDE] )
1112  {
1113  SET_DC( INSIDE );
1116  strokeText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
1117  }
1118  if( size[OUTSIDE] )
1119  {
1120  SET_DC( OUTSIDE );
1123  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
1124  }
1125  if( size[ABOVE] )
1126  {
1127  SET_DC( ABOVE );
1130  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
1131  }
1132  if( size[BELOW] )
1133  {
1134  SET_DC( BELOW );
1137  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
1138  }
1139  break;
1140 
1141  default:
1142  wxFAIL_MSG( "Unknown pin orientation" );
1143  }
1144 }
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:125
LIB_PART * GetParent() const
Definition: lib_item.h:182
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:128
int color
Definition: DXF_plotter.cpp:61
Definition: lib_pin.h:50
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:230
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
Definition: lib_pin.h:142
const wxString & GetName() const
Definition: lib_pin.h:156
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
Definition: lib_pin.h:147
int GetNameTextSize() const
Definition: lib_pin.h:174
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Definition: lib_pin.h:254
int externalPinDecoSize(const LIB_PIN &aPin)
const wxString & GetNumber() const
Definition: lib_pin.h:165
ELECTRICAL_PINTYPE GetType() const
Definition: lib_pin.h:134
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:177
#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.
int GetLength() const
Definition: lib_pin.h:131
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:38
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
static constexpr int Millimeter2iu(double mm)
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204
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(), Millimeter2iu(), 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 520 of file sch_painter.cpp.

521 {
522  if( !isUnitAndConversionShown( aCircle ) )
523  return;
524 
525  if( setDeviceColors( aCircle, aLayer ) )
526  {
527  fillIfSelection( aLayer );
528  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
529  }
530 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetPosition() const override
Definition: lib_circle.h:72
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:88
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

References KIGFX::GAL::DrawCircle(), 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 397 of file sch_painter.cpp.

398 {
399  if( !aUnit )
400  aUnit = m_schSettings.m_ShowUnit;
401 
402  if( !aConvert )
403  aConvert = m_schSettings.m_ShowConvert;
404 
405  std::unique_ptr< LIB_PART > tmpPart;
406  LIB_PART* drawnPart = aPart;
407 
408  if( aPart->IsAlias() )
409  {
410  tmpPart = aPart->Flatten();
411  drawnPart = tmpPart.get();
412  }
413 
414  for( auto& item : drawnPart->GetDrawItems() )
415  {
416  if( !aDrawFields && item.Type() == LIB_FIELD_T )
417  continue;
418 
419  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
420  continue;
421 
422  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
423  continue;
424 
425  Draw( &item, aLayer );
426  }
427 }
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:204

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

534 {
535  if( !isUnitAndConversionShown( aArc ) )
536  return;
537 
538  if( setDeviceColors( aArc, aLayer ) )
539  {
540  int sai = aArc->GetFirstRadiusAngle();
541  int eai = aArc->GetSecondRadiusAngle();
542 
553  if( !TRANSFORM().MapAngles( &sai, &eai ) )
554  {
555  LIB_ARC new_arc( *aArc );
556 
557  new_arc.SetStart( aArc->GetEnd() );
558  new_arc.SetEnd( aArc->GetStart() );
559  new_arc.CalcRadiusAngles();
560  sai = new_arc.GetFirstRadiusAngle();
561  eai = new_arc.GetSecondRadiusAngle();
562  TRANSFORM().MapAngles( &sai, &eai );
563  }
564 
565  double sa = (double) sai * M_PI / 1800.0;
566  double ea = (double) eai * M_PI / 1800.0 ;
567 
568  VECTOR2D pos = mapCoords( aArc->GetPosition() );
569 
570  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
571  }
572 }
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
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
wxPoint GetPosition() const override
Definition: lib_arc.h:90

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

576 {
577  if( !isUnitAndConversionShown( aLine ) )
578  return;
579 
580  if( setDeviceColors( aLine, aLayer ) )
581  {
582  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
583  std::deque<VECTOR2D> vtx;
584 
585  for( auto p : pts )
586  vtx.push_back( mapCoords( p ) );
587 
588  fillIfSelection( aLayer );
589  m_gal->DrawPolygon( vtx );
590  }
591 }
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 594 of file sch_painter.cpp.

595 {
596  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
597 
598  if( drawingShadows && !aField->IsSelected() )
599  return;
600 
601  if( !isUnitAndConversionShown( aField ) )
602  return;
603 
604  // Must check layer as fields are sometimes drawn by their parent rather than
605  // directly from the view.
606  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
607  int layers_count;
608  bool foundLayer = false;
609 
610  aField->ViewGetLayers( layers, layers_count );
611 
612  for( int i = 0; i < layers_count; ++i )
613  {
614  if( layers[i] == aLayer )
615  foundLayer = true;
616  }
617 
618  if( !foundLayer )
619  return;
620 
621  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
622 
623  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
624  {
626  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
627  else
628  return;
629  }
630 
631  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
632  m_gal->SetIsFill( false );
633  m_gal->SetIsStroke( true );
635 
636  auto pos = mapCoords( aField->GetPosition() );
637 
638  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
639  {
640  EDA_RECT boundaryBox = aField->GetBoundingBox();
641 
642  m_gal->SetIsFill( true );
644  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
645  boundaryBox.RevertYAxis();
646 
647  m_gal->DrawRectangle( mapCoords( boundaryBox.GetPosition() ),
648  mapCoords( boundaryBox.GetEnd() ) );
649  }
650  else
651  {
652  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
653  m_gal->SetFontItalic( aField->IsItalic() );
654 
657 
658  double orient = aField->GetTextAngleRadians();
659 
660  strokeText( aField->GetText(), pos, orient );
661  }
662 
663  // Draw the umbilical line
664  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
665  {
667  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
668  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
669  }
670 }
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:200
bool IsSelected() const
Definition: base_struct.h:203
wxPoint GetPosition() const override
Definition: lib_field.h:180
bool IsVisible() const
Definition: eda_text.h:186
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()
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:697
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:180
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:199
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxSize & GetTextSize() const
Definition: eda_text.h:239
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:177
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:127
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204
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 673 of file sch_painter.cpp.

674 {
675  if( !isUnitAndConversionShown( aText ) )
676  return;
677 
678  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
679 
680  if( drawingShadows && !aText->IsSelected() )
681  return;
682 
683  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
684 
685  if( !aText->IsVisible() )
686  {
688  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
689  else
690  return;
691  }
692 
693  EDA_RECT bBox = aText->GetBoundingBox();
694  bBox.RevertYAxis();
695  VECTOR2D pos = mapCoords( bBox.Centre() );
696  double orient = aText->GetTextAngleRadians();
697 
700  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
701  m_gal->SetIsFill( false );
702  m_gal->SetIsStroke( true );
704  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
705  m_gal->SetFontBold( aText->IsBold() );
706  m_gal->SetFontItalic( aText->IsItalic() );
707  strokeText( aText->GetText(), pos, orient );
708 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:183
bool IsSelected() const
Definition: base_struct.h:203
bool IsVisible() const
Definition: eda_text.h:186
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:180
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:239
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:177
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:360
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:127
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204
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 1147 of file sch_painter.cpp.

1148 {
1149  if( !isUnitAndConversionShown( aCurve ) )
1150  return;
1151 
1152  if( setDeviceColors( aCurve, aLayer ) )
1153  {
1154  BEZIER_POLY poly ( aCurve->GetPoints() );
1155  std::vector<wxPoint> pts;
1156  std::deque<VECTOR2D> pts_xformed;
1157  poly.GetPoly( pts );
1158 
1159  for( const auto &p : pts )
1160  pts_xformed.push_back( mapCoords( p ) );
1161 
1162  m_gal->DrawPolygon( pts_xformed );
1163  }
1164 }
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 1408 of file sch_painter.cpp.

1409 {
1410  int unit = aComp->GetUnitSelection( &m_schematic->CurrentSheet() );
1411  int convert = aComp->GetConvert();
1412 
1413  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1414  LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
1415  LIB_PINS originalPins;
1416  originalPart->GetPins( originalPins, unit, convert );
1417 
1418  // Copy the source so we can re-orient and translate it.
1419  LIB_PART tempPart( *originalPart );
1420  LIB_PINS tempPins;
1421  tempPart.GetPins( tempPins, unit, convert );
1422 
1423  tempPart.SetFlags( aComp->GetFlags() );
1424 
1425  orientPart( &tempPart, aComp->GetOrientation() );
1426 
1427  for( auto& tempItem : tempPart.GetDrawItems() )
1428  {
1429  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1430  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition() ) );
1431  }
1432 
1433  // Copy the pin info from the component to the temp pins
1434  for( unsigned i = 0; i < tempPins.size(); ++ i )
1435  {
1436  SCH_PIN* compPin = aComp->GetPin( originalPins[ i ] );
1437  LIB_PIN* tempPin = tempPins[ i ];
1438 
1439  tempPin->ClearFlags();
1440  tempPin->SetFlags( compPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1441 
1442  tempPin->SetName( compPin->GetName() );
1443  tempPin->SetType( compPin->GetType() );
1444  tempPin->SetShape( compPin->GetShape() );
1445 
1446  if( compPin->IsDangling() )
1447  tempPin->SetFlags( IS_DANGLING );
1448  }
1449 
1450  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1451 
1452  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1453  for( SCH_FIELD& field : aComp->GetFields() )
1454  draw( &field, aLayer );
1455 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCHEMATIC * m_schematic
Definition: sch_painter.h:206
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
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition: lib_pin.h:129
SCH_PIN * GetPin(const wxString &number)
Find a symbol pin by number.
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:94
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
int GetUnit() const
void SetType(ELECTRICAL_PINTYPE aType)
Definition: lib_pin.h:135
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
Define a library symbol object.
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:83
std::unique_ptr< LIB_PART > & GetPartRef()
static VECTOR2D mapCoords(const wxPoint &aCoord)
static void orientPart(LIB_PART *part, int orientation)
void SetName(const wxString &aName)
Definition: lib_pin.h:157
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:145
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:74
wxPoint GetPosition() const override
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
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
wxString GetName() const
Definition: sch_pin.cpp:65
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:119

References EDA_ITEM::ClearFlags(), SCHEMATIC::CurrentSheet(), draw(), KIGFX::dummy(), SCH_COMPONENT::GetConvert(), LIB_PART::GetDrawItems(), SCH_COMPONENT::GetFields(), EDA_ITEM::GetFlags(), SCH_PIN::GetName(), SCH_COMPONENT::GetOrientation(), SCH_COMPONENT::GetPartRef(), SCH_COMPONENT::GetPin(), LIB_PART::GetPins(), SCH_COMPONENT::GetPosition(), SCH_PIN::GetShape(), SCH_PIN::GetType(), SCH_COMPONENT::GetUnit(), SCH_COMPONENT::GetUnitSelection(), IS_DANGLING, SCH_PIN::IsDangling(), m_schematic, KIGFX::mapCoords(), KIGFX::orientPart(), EDA_ITEM::SetFlags(), LIB_PIN::SetName(), LIB_PIN::SetShape(), and LIB_PIN::SetType().

◆ draw() [11/21]

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

Definition at line 1183 of file sch_painter.cpp.

1184 {
1185  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1186 
1187  if( drawingShadows && !aJct->IsSelected() )
1188  return;
1189 
1190  COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows );
1191 
1192  int junctionSize = aJct->GetDiameter() / 2;
1193 
1194  m_gal->SetIsStroke( drawingShadows );
1195  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1197  m_gal->SetIsFill( !drawingShadows );
1198  m_gal->SetFillColor( color );
1199  m_gal->DrawCircle( aJct->GetPosition(), junctionSize );
1200 }
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
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.
wxPoint GetPosition() const override
Definition: sch_junction.h:95
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:279
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.
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::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 1458 of file sch_painter.cpp.

1459 {
1460  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1461 
1462  if( drawingShadows && !aField->IsSelected() )
1463  return;
1464 
1465  aLayer = aField->GetLayer();
1466 
1467  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1468 
1469  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
1470  {
1472  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1473  else
1474  return;
1475  }
1476 
1477  if( aField->IsVoid() )
1478  return;
1479 
1480  if( drawingShadows && aField->GetParent()->IsSelected()
1482  {
1483  return;
1484  }
1485 
1486  // Calculate the text orientation according to the parent orientation.
1487  int orient = (int) aField->GetTextAngle();
1488 
1489  if( aField->GetParent() && aField->GetParent()->Type() == SCH_COMPONENT_T )
1490  {
1491  if( static_cast<SCH_COMPONENT*>( aField->GetParent() )->GetTransform().y1 )
1492  {
1493  // Rotate component 90 degrees.
1494  if( orient == TEXT_ANGLE_HORIZ )
1495  orient = TEXT_ANGLE_VERT;
1496  else
1497  orient = TEXT_ANGLE_HORIZ;
1498  }
1499  }
1500 
1501  /* Calculate the text justification, according to the component orientation/mirror.
1502  * This is a bit complicated due to cumulative calculations:
1503  * - numerous cases (mirrored or not, rotation)
1504  * - the DrawGraphicText function recalculate also H and H justifications according to the
1505  * text orientation.
1506  * - When a component is mirrored, the text is not mirrored and justifications are
1507  * complicated to calculate
1508  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1509  * to know the text coordinate considered as centered
1510  */
1511  EDA_RECT boundaryBox = aField->GetBoundingBox();
1512  wxPoint textpos = boundaryBox.Centre();
1513 
1515  m_gal->SetIsStroke( true );
1516 
1517  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
1518  {
1519  m_gal->SetIsFill( true );
1520  m_gal->SetFillColor( color );
1521  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1522  boundaryBox.RevertYAxis();
1523 
1524  m_gal->DrawRectangle( mapCoords( boundaryBox.GetPosition() ),
1525  mapCoords( boundaryBox.GetEnd() ) );
1526  }
1527  else
1528  {
1531  m_gal->SetIsFill( false );
1532  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1533  m_gal->SetFontBold( aField->IsBold() );
1534  m_gal->SetFontItalic( aField->IsItalic() );
1535  m_gal->SetTextMirrored( aField->IsMirrored() );
1536  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
1537 
1538  strokeText( aField->GetShownText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
1539  }
1540 
1541  // Draw the umbilical line
1542  if( aField->IsMoving() )
1543  {
1544  wxPoint parentPos = aField->GetParentPosition();
1545 
1547  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1548  m_gal->DrawLine( textpos, parentPos );
1549  }
1550 }
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:183
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:185
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsMirrored() const
Definition: eda_text.h:189
bool IsSelected() const
Definition: base_struct.h:203
bool IsVisible() const
Definition: eda_text.h:186
bool IsMoving() const
Definition: base_struct.h:200
int color
Definition: DXF_plotter.cpp:61
double GetTextAngle() const
Definition: eda_text.h:174
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()
#define TEXT_ANGLE_VERT
Definition: common.h:186
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:311
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:180
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:239
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:279
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:252
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:619
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204
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 1278 of file sch_painter.cpp.

1279 {
1280  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1281 
1282  if( drawingShadows && !aText->IsSelected() )
1283  return;
1284 
1285  switch( aText->Type() )
1286  {
1287  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1288  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1289  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1290  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1291  default: aLayer = LAYER_NOTES; break;
1292  }
1293 
1294  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1295 
1296  if( m_schematic )
1297  {
1298  SCH_CONNECTION* conn = aText->Connection( m_schematic->CurrentSheet() );
1299 
1300  if( conn && conn->IsBus() )
1301  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1302  }
1303 
1304  if( !( aText->IsVisible() || aText->IsForceVisible() ) )
1305  {
1307  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1308  else
1309  return;
1310  }
1311 
1312  m_gal->SetIsFill( false );
1313  m_gal->SetIsStroke( true );
1314  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
1316  m_gal->SetTextAttributes( aText );
1317 
1318  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset( &m_schSettings );
1319  wxString shownText( aText->GetShownText() );
1320 
1321  if( drawingShadows )
1322  {
1324  {
1325  EDA_RECT bBox = aText->GetBoundingBox();
1326 
1327  m_gal->SetIsFill( true );
1328  m_gal->SetFillColor( color );
1329  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1330  bBox.RevertYAxis();
1331 
1332  m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1333  return;
1334  }
1335 
1336  switch( aText->GetLabelSpinStyle() )
1337  {
1338  case LABEL_SPIN_STYLE::LEFT: text_offset.x += getShadowWidth() / 2; break;
1339  case LABEL_SPIN_STYLE::UP: text_offset.y += getShadowWidth() / 2; break;
1340  case LABEL_SPIN_STYLE::RIGHT: text_offset.x -= getShadowWidth() / 2; break;
1341  case LABEL_SPIN_STYLE::BOTTOM: text_offset.y -= getShadowWidth() / 2; break;
1342  }
1343  }
1344 
1345  if( !shownText.IsEmpty() )
1346  {
1347  strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1348  }
1349 
1350  if( aText->IsDangling() )
1351  {
1352  drawDanglingSymbol( aText->GetTextPos(), Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1353  drawingShadows );
1354  }
1355 }
bool IsDangling() const override
Definition: sch_text.h:304
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
SCHEMATIC * m_schematic
Definition: sch_painter.h:206
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:186
virtual wxPoint GetSchematicTextOffset(RENDER_SETTINGS *aSettings) const
Definition: sch_text.cpp:157
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:234
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:438
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:483
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:150
double GetTextAngleRadians() const
Definition: eda_text.h:177
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:248
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:119
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 1589 of file sch_painter.cpp.

1590 {
1591  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1592 
1593  if( drawingShadows && !aLabel->IsSelected() )
1594  return;
1595 
1596  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1597 
1598  if( m_schematic )
1599  {
1600  SCH_CONNECTION* conn = aLabel->Connection( m_schematic->CurrentSheet() );
1601 
1602  if( conn && conn->IsBus() )
1603  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1604  }
1605 
1606  std::vector<wxPoint> pts;
1607  std::deque<VECTOR2D> pts2;
1608 
1609  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1610 
1611  for( auto p : pts )
1612  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1613 
1614  m_gal->SetIsFill( true );
1616  m_gal->SetIsStroke( true );
1617  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1619  m_gal->DrawPolyline( pts2 );
1620 
1621  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1622 }
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:206
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:150
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:248
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:1124
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:204
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:119
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 1553 of file sch_painter.cpp.

1554 {
1555  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1556 
1557  if( drawingShadows && !aLabel->IsSelected() )
1558  return;
1559 
1560  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1561 
1562  std::vector<wxPoint> pts;
1563  std::deque<VECTOR2D> pts2;
1564 
1565  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1566 
1567  for( auto p : pts )
1568  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1569 
1570  // the text is drawn inside the graphic shape.
1571  // On Cairo the graphic shape is filled by the background
1572  // before drawing the text ().
1573  // However if the text is selected, it is draw twice:
1574  // first, on LAYER_SELECTION_SHADOWS
1575  // second, on the text layer.
1576  // the second must not erase the first drawing.
1577  bool fillBg = ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected();
1578  m_gal->SetIsFill( fillBg );
1580  m_gal->SetIsStroke( true );
1581  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1583  m_gal->DrawPolyline( pts2 );
1584 
1585  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1586 }
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:908
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:248
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:204
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 1624 of file sch_painter.cpp.

1625 {
1626  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1627 
1628  if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS )
1629  {
1630  for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
1631  {
1632  if( drawingShadows && !aSheet->IsSelected() && !sheetPin->IsSelected() )
1633  continue;
1634 
1635  if( drawingShadows && aSheet->IsSelected()
1637  {
1638  break;
1639  }
1640 
1641  int width = std::max( aSheet->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
1642  wxPoint initial_pos = sheetPin->GetTextPos();
1643  wxPoint offset_pos = initial_pos;
1644 
1645  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1646  switch( sheetPin->GetEdge() )
1647  {
1648  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1649  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1650  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1651  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1652  default: break;
1653  }
1654 
1655  sheetPin->SetTextPos( offset_pos );
1656  draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
1657  m_gal->DrawLine( offset_pos, initial_pos );
1658  sheetPin->SetTextPos( initial_pos );
1659  }
1660  }
1661 
1662  VECTOR2D pos = aSheet->GetPosition();
1663  VECTOR2D size = aSheet->GetSize();
1664 
1665  if( aLayer == LAYER_SHEET_BACKGROUND )
1666  {
1668  m_gal->SetIsFill( true );
1669  m_gal->SetIsStroke( false );
1670 
1671  m_gal->DrawRectangle( pos, pos + size );
1672  }
1673 
1674  if( aLayer == LAYER_SHEET || aLayer == LAYER_SELECTION_SHADOWS )
1675  {
1676  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1677  m_gal->SetIsStroke( true );
1678  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1679  m_gal->SetIsFill( false );
1680 
1681  m_gal->DrawRectangle( pos, pos + size );
1682 
1683  if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children && aSheet->IsSelected() )
1684  return;
1685 
1686  for( SCH_FIELD& field : aSheet->GetFields() )
1687  draw( &field, aLayer );
1688  }
1689 }
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:491
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
wxPoint GetPosition() const override
Definition: sch_sheet.h:567
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:362
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
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:204

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

1693 {
1694  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1695 
1696  if( drawingShadows && !aNC->IsSelected() )
1697  return;
1698 
1699  m_gal->SetIsStroke( true );
1700  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1701  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1702  m_gal->SetIsFill( false );
1703 
1704  VECTOR2D p = aNC->GetPosition();
1705  int delta = std::max( aNC->GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
1706 
1707  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1708  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1709 }
bool IsSelected() const
Definition: base_struct.h:203
wxPoint GetPosition() const override
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.
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:204

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

1801 {
1802  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1803 
1804  if( drawingShadows && !aMarker->IsSelected() )
1805  return;
1806 
1807  COLOR4D color = getRenderColor( aMarker, aMarker->GetColorLayer(), drawingShadows );
1808 
1809  m_gal->Save();
1810  m_gal->Translate( aMarker->GetPosition() );
1811  m_gal->SetIsFill( !drawingShadows );
1812  m_gal->SetFillColor( color );
1813  m_gal->SetIsStroke( drawingShadows );
1814  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1816 
1817  SHAPE_LINE_CHAIN polygon;
1818  aMarker->ShapeToPolygon( polygon );
1819 
1820  m_gal->DrawPolygon( polygon );
1821  m_gal->Restore();
1822 }
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
wxPoint GetPosition() const override
Definition: sch_marker.h:101
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.
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 1755 of file sch_painter.cpp.

1756 {
1757  m_gal->Save();
1758  m_gal->Translate( aBitmap->GetPosition() );
1759 
1760  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1761  // factor is similar to a local zoom
1762  double img_scale = aBitmap->GetImageScale();
1763 
1764  if( img_scale != 1.0 )
1765  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1766 
1767  if( aLayer == LAYER_DRAW_BITMAPS )
1768  {
1769  m_gal->DrawBitmap( *aBitmap->GetImage() );
1770  }
1771 
1772  if( aLayer == LAYER_SELECTION_SHADOWS )
1773  {
1774  if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
1775  {
1776  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1777  m_gal->SetIsStroke( true );
1780  m_gal->SetIsFill( false );
1781 
1782  // Draws a bounding box.
1783  VECTOR2D bm_size( aBitmap->GetSize() );
1784  // bm_size is the actual image size in UI.
1785  // but m_gal scale was previously set to img_scale
1786  // so recalculate size relative to this image size.
1787  bm_size.x /= img_scale;
1788  bm_size.y /= img_scale;
1789  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1790  VECTOR2D end = origin + bm_size;
1791 
1792  m_gal->DrawRectangle( origin, end );
1793  }
1794  }
1795 
1796  m_gal->Restore();
1797 }
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
wxPoint GetPosition() const override
Definition: sch_bitmap.h:140
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.
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 1203 of file sch_painter.cpp.

1204 {
1205  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1206 
1207  if( drawingShadows && !aLine->IsSelected() )
1208  return;
1209 
1210  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1211  float width = getLineWidth( aLine, drawingShadows );
1212  PLOT_DASH_TYPE lineStyle = aLine->GetEffectiveLineStyle();
1213 
1214  m_gal->SetIsStroke( true );
1216  m_gal->SetLineWidth( width );
1217 
1218  if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1219  {
1220  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1221  }
1222  else
1223  {
1224  VECTOR2D start = aLine->GetStartPoint();
1225  VECTOR2D end = aLine->GetEndPoint();
1226 
1227  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1228  clip.Normalize();
1229 
1230  double theta = atan2( end.y - start.y, end.x - start.x );
1231  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1232 
1233  switch( lineStyle )
1234  {
1235  default:
1236  case PLOT_DASH_TYPE::DASH:
1237  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1238  break;
1239  case PLOT_DASH_TYPE::DOT:
1240  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1241  break;
1243  strokes[0] = DASH_MARK_LEN( width );
1244  strokes[2] = DOT_MARK_LEN( width );
1245  break;
1246  }
1247 
1248  for( size_t i = 0; i < 10000; ++i )
1249  {
1250  // Calculations MUST be done in doubles to keep from accumulating rounding
1251  // errors as we go.
1252  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1253  start.y + strokes[ i % 4 ] * sin( theta ) );
1254 
1255  // Drawing each segment can be done rounded to ints.
1256  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1257  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1258 
1259  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1260  break;
1261  else if( i % 2 == 0 )
1262  m_gal->DrawLine( segStart, segEnd );
1263 
1264  start = next;
1265  }
1266  }
1267 
1268  if( aLine->IsStartDangling() )
1269  drawDanglingSymbol( aLine->GetStartPoint(), getLineWidth( aLine, drawingShadows ),
1270  drawingShadows );
1271 
1272  if( aLine->IsEndDangling() )
1273  drawDanglingSymbol( aLine->GetEndPoint(), getLineWidth( aLine, drawingShadows ),
1274  drawingShadows );
1275 }
CITER next(CITER it)
Definition: ptree.cpp:126
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.
bool IsEndDangling() const
Definition: sch_line.h:195
#define DOT_MARK_LEN(aLineWidth)
PLOT_DASH_TYPE
Enum for choosing dashed line type.
Definition: plotter.h:87
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:279
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Definition: sch_line.cpp:255
bool IsStartDangling() const
Definition: sch_line.h:194
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::GetEffectiveLineStyle(), SCH_LINE::GetEndPoint(), SCH_ITEM::GetLayer(), 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 1712 of file sch_painter.cpp.

1713 {
1714  SCH_LINE line;
1715  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1716 
1717  if( drawingShadows && !aEntry->IsSelected() )
1718  return;
1719 
1720  line.SetLayer( aEntry->Type() == SCH_BUS_WIRE_ENTRY_T ? LAYER_WIRE : LAYER_BUS );
1721 
1722  if( aEntry->IsSelected() )
1723  line.SetSelected();
1724  else if( aEntry->IsBrightened() )
1725  line.SetBrightened();
1726 
1727  line.SetStartPoint( aEntry->GetPosition() );
1728  line.SetEndPoint( aEntry->GetEnd() );
1729  line.SetStroke( aEntry->GetStroke() );
1730 
1731  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1732 
1733  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1734  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1735 
1736  line.SetLineColor( color );
1737  line.SetLineStyle( aEntry->GetStrokeStyle() );
1738 
1739  draw( &line, aLayer );
1740 
1741  m_gal->SetIsFill( false );
1742  m_gal->SetIsStroke( true );
1743  m_gal->SetLineWidth( drawingShadows ? getShadowWidth() : 1.0F );
1744 
1745  if( aEntry->IsDanglingStart() )
1746  m_gal->DrawCircle( aEntry->GetPosition(),
1747  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1748 
1749  if( aEntry->IsDanglingEnd() )
1750  m_gal->DrawCircle( aEntry->GetEnd(),
1751  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1752 }
#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
int color
Definition: DXF_plotter.cpp:61
void SetBrightened()
Definition: base_struct.h:209
bool IsBrightened() const
Definition: base_struct.h:205
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.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:98
PLOT_DASH_TYPE GetStrokeStyle() const
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:237
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:286
#define F(x, y, z)
Definition: md5_hash.cpp:15
void SetLineColor(const COLOR4D &aColor)
Definition: sch_line.cpp:187
virtual int GetPenWidth() const
Definition: sch_item.h:296
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_line.h:129
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.
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
wxPoint GetEnd() const
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
wxPoint GetPosition() const override

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

◆ drawDanglingSymbol()

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

Definition at line 1169 of file sch_painter.cpp.

1170 {
1171  wxPoint radius( aWidth + Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1172  aWidth + Mils2iu( DANGLING_SYMBOL_SIZE /2 ) );
1173 
1174  m_gal->SetIsStroke( true );
1175  m_gal->SetIsFill( false );
1176  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth()
1178 
1179  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1180 }
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
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

Referenced by draw().

◆ drawPinDanglingSymbol()

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

Definition at line 732 of file sch_painter.cpp.

733 {
734  m_gal->SetIsFill( false );
735  m_gal->SetIsStroke( true );
736  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth()
738 
740 }
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.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:38
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

Referenced by draw().

◆ externalPinDecoSize()

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

Definition at line 722 of file sch_painter.cpp.

723 {
726 
727  return aPin.GetNumberTextSize() / 2;
728 }
int GetNumberTextSize() const
Definition: lib_pin.h:177
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

501 {
502  if( aLayer == LAYER_SELECTION_SHADOWS && eeconfig()->m_Selection.fill_shapes )
503  m_gal->SetIsFill( true );
504 }
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 321 of file sch_painter.cpp.

322 {
323  float width = (float) std::max( aItem->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
324 
325  if( aItem->IsSelected() && aDrawingShadows )
326  width += getShadowWidth();
327 
328  return width;
329 }
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:204

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

333 {
334  wxCHECK( aItem, static_cast<float>( m_schSettings.m_DefaultWireThickness ) );
335 
336  float width = (float) aItem->GetPenWidth();
337 
338  if( aItem->IsSelected() && aDrawingShadows )
339  width += getShadowWidth();
340 
341  return std::max( width, 1.0f );
342 }
bool IsSelected() const
Definition: base_struct.h:203
virtual int GetPenWidth() const
Definition: sch_item.h:296
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

◆ getRenderColor()

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

Definition at line 261 of file sch_painter.cpp.

262 {
264 
265  if( aItem->Type() == SCH_LINE_T )
266  {
267  COLOR4D lineColor = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
268 
269  if( lineColor != COLOR4D::UNSPECIFIED )
270  color = lineColor;
271  }
272  else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
273  {
274  COLOR4D busEntryColor = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetStrokeColor();
275 
276  if( busEntryColor != COLOR4D::UNSPECIFIED )
277  color = busEntryColor;
278  }
279  else if( aItem->Type() == SCH_JUNCTION_T )
280  {
281  COLOR4D junctionColor = static_cast<const SCH_JUNCTION*>( aItem )->GetColor();
282 
283  if( junctionColor != COLOR4D::UNSPECIFIED )
284  color = junctionColor;
285  }
286  else if( aItem->Type() == SCH_SHEET_T )
287  {
288  SCH_SHEET* sheet = (SCH_SHEET*) aItem;
289 
291  color = m_schSettings.GetLayerColor( aLayer );
292  else if( aLayer == LAYER_SHEET )
293  color = sheet->GetBorderColor();
294  else if( aLayer == LAYER_SHEET_BACKGROUND )
295  color = sheet->GetBackgroundColor();
296 
297  if( color == COLOR4D::UNSPECIFIED )
298  color = m_schSettings.GetLayerColor( aLayer );
299  }
300 
301  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
302  {
304 
305  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
306  color = color.WithAlpha( 0.2 );
307  }
308  else if( aItem->IsSelected() )
309  {
310  if( aDrawingShadows )
312  }
313 
315  color = color.Darken( 0.5f );
316 
317  return color;
318 }
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
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:204
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, 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 148 of file sch_painter.h.

149  {
150  return &m_schSettings;
151  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

References m_schSettings.

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

◆ getShadowWidth()

float KIGFX::SCH_PAINTER::getShadowWidth ( )
private

Definition at line 251 of file sch_painter.cpp.

252 {
253  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
254 
255  // For best visuals the selection width must be a cross between the zoom level and the
256  // default line width.
257  return (float) fabs( matrix.GetScale().x * 2.75 ) + Mils2iu( eeconfig()->m_Selection.thickness );
258 }
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 345 of file sch_painter.cpp.

346 {
347  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
348 
349  if( aItem->IsSelected() && aDrawingShadows )
350  width += getShadowWidth();
351 
352  return width;
353 }
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:157
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

357 {
358  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
359 
360  if( aItem->IsSelected() && aDrawingShadows )
361  width += getShadowWidth();
362 
363  return width;
364 }
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:157
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

368 {
369  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
371 
372  if( aItem->IsSelected() && aDrawingShadows )
373  width += getShadowWidth();
374 
375  return width;
376 }
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:157
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

380 {
381  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
383 
384  if( aItem->IsSelected() && aDrawingShadows )
385  width += getShadowWidth();
386 
387  return width;
388 }
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:157
int GetDefaultPenWidth() const
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

712 {
715 
716  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
717 }
int GetNameTextSize() const
Definition: lib_pin.h:174
int GetNumberTextSize() const
Definition: lib_pin.h:177
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204

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

232 {
233  if( m_schSettings.m_ShowUnit // showing a specific unit
234  && aItem->GetUnit() // item is unit-specific
235  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
236  {
237  return false;
238  }
239 
240  if( m_schSettings.m_ShowConvert // showing a specific conversion
241  && aItem->GetConvert() // item is conversion-specific
242  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
243  {
244  return false;
245  }
246 
247  return true;
248 }
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:204

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

444 {
445  switch( aLayer )
446  {
448  if( aItem->IsSelected() )
449  {
450  m_gal->SetIsFill( false );
451  m_gal->SetIsStroke( true );
452  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
453  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
454  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
455  return true;
456  }
457 
458  return false;
459 
461  if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
462  {
463  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
464 
465  // These actions place the item over others, so allow a modest transparency here
466  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
467  fillColor = fillColor.WithAlpha( 0.75 );
468 
470  m_gal->SetFillColor( fillColor );
471  m_gal->SetIsStroke( false );
472  return true;
473  }
474 
475  return false;
476 
477  case LAYER_DEVICE:
478  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
479  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
480 
481  if( aItem->GetPenWidth() > 0 || aItem->GetFillMode() == NO_FILL )
482  {
483  m_gal->SetIsStroke( true );
484  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
485  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
486  }
487  else
488  {
489  m_gal->SetIsStroke( false );
490  }
491 
492  return true;
493 
494  default:
495  return false;
496  }
497 }
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 153 of file sch_painter.h.

154  {
155  m_schematic = aSchematic;
156  }
SCHEMATIC * m_schematic
Definition: sch_painter.h:206

References m_schematic.

◆ strokeText()

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

Definition at line 391 of file sch_painter.cpp.

392 {
393  m_gal->StrokeText( aText, aPosition, aAngle );
394 }
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 436 of file sch_painter.cpp.

437 {
438  m_gal->DrawLine( a, b );
439  m_gal->DrawLine( b, c );
440 }
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 206 of file sch_painter.h.

Referenced by draw(), and SetSchematic().

◆ m_schSettings


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