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
 Function GetSettings Returns pointer to current settings that are going to be used when drawing items. More...
 
void SetGAL (GAL *aGal)
 Function SetGAL Changes Graphics Abstraction Layer used for drawing items for a new one. More...
 

Protected Attributes

GALm_gal
 Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg. More...
 
COLOR4D m_brightenedColor
 Color of brightened item frame. More...
 

Private Member Functions

void draw (LIB_RECTANGLE *aRect, int aLayer)
 
void draw (LIB_PIN *aPin, int aLayer)
 
void draw (LIB_CIRCLE *aCircle, int aLayer)
 
void draw (LIB_PART *aPart, int, bool aDrawFields=true, int aUnit=0, int aConvert=0)
 
void draw (LIB_ARC *aArc, int aLayer)
 
void draw (LIB_POLYLINE *aLine, int aLayer)
 
void draw (LIB_FIELD *aField, int aLayer)
 
void draw (LIB_TEXT *aText, int aLayer)
 
void draw (LIB_BEZIER *aCurve, int aLayer)
 
void draw (SCH_COMPONENT *aComp, int aLayer)
 
void draw (SCH_JUNCTION *aJct, int aLayer)
 
void draw (SCH_FIELD *aField, int aLayer)
 
void draw (SCH_TEXT *aText, int aLayer)
 
void draw (SCH_HIERLABEL *aLabel, int aLayer)
 
void draw (SCH_GLOBALLABEL *aLabel, int aLayer)
 
void draw (SCH_SHEET *aSheet, int aLayer)
 
void draw (SCH_NO_CONNECT *aNC, int aLayer)
 
void draw (SCH_MARKER *aMarker, int aLayer)
 
void draw (SCH_BITMAP *aBitmap, int aLayer)
 
void draw (SCH_LINE *aLine, int aLayer)
 
void draw (SCH_BUS_ENTRY_BASE *aEntry, int aLayer)
 
void drawPinDanglingSymbol (const VECTOR2I &aPos, bool aDrawingShadows)
 
void drawDanglingSymbol (const wxPoint &aPos, bool aDrawingShadows)
 
bool isUnitAndConversionShown (const LIB_ITEM *aItem)
 
float getShadowWidth ()
 
COLOR4D getRenderColor (const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
 
float getLineWidth (const LIB_ITEM *aItem, bool aDrawingShadows)
 
float getLineWidth (const SCH_ITEM *aItem, bool aDrawingShadows)
 
float getTextThickness (const SCH_TEXT *aItem, bool aDrawingShadows)
 
bool setDeviceColors (const LIB_ITEM *aItem, int aLayer)
 
void 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
 

Detailed Description

SCH_PAINTER Contains methods for drawing schematic-specific items.

Definition at line 118 of file sch_painter.h.

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 141 of file sch_painter.cpp.

141  :
142  KIGFX::PAINTER( aGal )
143 { }
PAINTER contains all the knowledge about how to draw graphical object onto any particular output devi...
Definition: painter.h:313

Member Function Documentation

◆ ApplySettings()

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

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

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 127 of file sch_painter.h.

128  {
129  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
130  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178

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

151 {
152  auto item2 = static_cast<const EDA_ITEM*>( aItem );
153  auto item = const_cast<EDA_ITEM*>( item2 );
154 
156 
157 #ifdef CONNECTIVITY_DEBUG
158 
159  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
160  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
161 
162  if( conn )
163  {
164  auto pos = item->GetBoundingBox().Centre();
165  auto label = conn->Name( true );
166 
170  m_gal->SetLineWidth( Mils2ui( 2 ) );
171  m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
172  m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
173  }
174 
175 #endif
176 
177  switch( item->Type() )
178  {
203 
204  default: return false;
205  }
206 
207  return false;
208 }
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
Define a library symbol object.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.
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:206
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:38
#define HANDLE_ITEM(type_id, type_name)
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: sch_painter.cpp:84
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:35
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References g_CurrentSheet, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, HANDLE_ITEM, KIGFX::SCH_RENDER_SETTINGS::ImportLegacyColors(), LIB_ARC_T, LIB_BEZIER_T, LIB_CIRCLE_T, LIB_FIELD_T, LIB_PART_T, LIB_PIN_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, LIB_TEXT_T, LIGHTRED, KIGFX::PAINTER::m_gal, m_schSettings, SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_TEXT_T, KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), and KIGFX::GAL::StrokeText().

Referenced by draw().

◆ draw() [1/21]

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

Definition at line 419 of file sch_painter.cpp.

420 {
421  if( !isUnitAndConversionShown( aRect ) )
422  return;
423 
424  if( setDeviceColors( aRect, aLayer ) )
425  {
426  fillIfSelection( aLayer );
427  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
428  }
429 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
wxPoint GetEnd() const
Definition: lib_rectangle.h:89
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
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:365
static VECTOR2D mapCoords(const wxPoint &aCoord)
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
wxPoint GetPosition() const override
Definition: lib_rectangle.h:76

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

649 {
650  if( !isUnitAndConversionShown( aPin ) )
651  return;
652 
653  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
654 
655  if( drawingShadows && !aPin->IsSelected() )
656  return;
657 
658  VECTOR2I pos = mapCoords( aPin->GetPosition() );
659  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
660 
661  if( !aPin->IsVisible() )
662  {
664  {
665  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
666  }
667  else
668  {
669  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
670  drawPinDanglingSymbol( pos, drawingShadows );
671 
672  return;
673  }
674  }
675 
676  VECTOR2I p0;
677  VECTOR2I dir;
678  int len = aPin->GetLength();
679  int orient = aPin->GetOrientation();
680 
681  switch( orient )
682  {
683  case PIN_UP:
684  p0 = VECTOR2I( pos.x, pos.y - len );
685  dir = VECTOR2I( 0, 1 );
686  break;
687 
688  case PIN_DOWN:
689  p0 = VECTOR2I( pos.x, pos.y + len );
690  dir = VECTOR2I( 0, -1 );
691  break;
692 
693  case PIN_LEFT:
694  p0 = VECTOR2I( pos.x - len, pos.y );
695  dir = VECTOR2I( 1, 0 );
696  break;
697 
698  default:
699  case PIN_RIGHT:
700  p0 = VECTOR2I( pos.x + len, pos.y );
701  dir = VECTOR2I( -1, 0 );
702  break;
703  }
704 
705  VECTOR2D pc;
706 
707  m_gal->SetIsStroke( true );
708  m_gal->SetIsFill( false );
709  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
711  m_gal->SetFontBold( false );
712  m_gal->SetFontItalic( false );
713 
714  const int radius = ExternalPinDecoSize( *aPin );
715  const int diam = radius*2;
716  const int clock_size = InternalPinDecoSize( *aPin );
717 
718  if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
719  {
720  m_gal->DrawLine( p0, pos );
721 
722  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
723  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
724  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
725  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
726 
727  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
728  }
729  else
730  {
731  switch( aPin->GetShape() )
732  {
734  m_gal->DrawLine( p0, pos );
735  break;
736 
738  m_gal->DrawCircle( p0 + dir * radius, radius );
739  m_gal->DrawLine( p0 + dir * ( diam ), pos );
740  break;
741 
743  pc = p0 - dir * clock_size ;
744 
745  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
746  pc,
747  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
748 
749  m_gal->DrawCircle( p0 + dir * radius, radius );
750  m_gal->DrawLine( p0 + dir * ( diam ), pos );
751  break;
752 
755  pc = p0 - dir * clock_size ;
756 
757  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
758  pc,
759  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
760 
761  if( !dir.y )
762  {
763  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
764  p0 + VECTOR2D(dir.x, -1) * diam,
765  p0 );
766  }
767  else /* MapX1 = 0 */
768  {
769  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
770  p0 + VECTOR2D(-1, dir.y) * diam,
771  p0 );
772  }
773 
774  m_gal->DrawLine( p0, pos );
775  break;
776 
778  m_gal->DrawLine( p0, pos );
779 
780  if( !dir.y )
781  {
782  triLine( p0 + VECTOR2D( 0, clock_size ),
783  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
784  p0 + VECTOR2D( 0, -clock_size ) );
785  }
786  else
787  {
788  triLine( p0 + VECTOR2D( clock_size, 0 ),
789  p0 + VECTOR2D( 0, -dir.y * clock_size ),
790  p0 + VECTOR2D( -clock_size, 0 ) );
791  }
792  break;
793 
795  m_gal->DrawLine( p0, pos );
796 
797  if( !dir.y )
798  {
799  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
800  p0 + VECTOR2D(dir.x, -1) * diam,
801  p0 );
802  }
803  else /* MapX1 = 0 */
804  {
805  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
806  p0 + VECTOR2D(-1, dir.y) * diam,
807  p0 );
808  }
809  break;
810 
811  case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
812  m_gal->DrawLine( p0, pos );
813 
814  if( !dir.y ) // Horizontal pin
815  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
816  else // Vertical pin
817  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
818  break;
819 
820  case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
821  m_gal->DrawLine( p0, pos );
822 
823  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
824  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
825  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
826  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
827  break;
828  }
829  }
830 
831 
832  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
833  drawPinDanglingSymbol( pos, drawingShadows );
834 
835  LIB_PART* libEntry = aPin->GetParent();
836 
837  // Draw the labels
838  if( drawingShadows && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() )
840  return;
841 
842  int textOffset = libEntry->GetPinNameOffset();
843 
844  float nameLineWidth = getLineWidth( aPin, drawingShadows );
845  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
846  float numLineWidth = getLineWidth( aPin, drawingShadows );
847  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
848 
849  #define PIN_TEXT_MARGIN 4.0
850 
851  // Four locations around a pin where text can be drawn
852  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
853  int size[4] = { 0, 0, 0, 0 };
854  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
855  COLOR4D colour[4];
856  wxString text[4];
857 
858  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
859  if( textOffset )
860  {
861  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
862  thickness[INSIDE] = nameLineWidth;
863  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
864  text [INSIDE] = aPin->GetName();
865 
866  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
867  thickness[ABOVE] = numLineWidth;
868  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
869  text [ABOVE] = aPin->GetNumber();
870  }
871  // Otherwise pin NAMES go above and pin NUMBERS go below
872  else
873  {
874  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
875  thickness[ABOVE] = nameLineWidth;
876  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
877  text [ABOVE] = aPin->GetName();
878 
879  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
880  thickness[BELOW] = numLineWidth;
881  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
882  text [BELOW] = aPin->GetNumber();
883  }
884 
886  {
887  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
888  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
889  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
890  text [OUTSIDE] = aPin->GetElectricalTypeName();
891  }
892 
893  if( !aPin->IsVisible() )
894  {
895  for( COLOR4D& c : colour )
896  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
897  }
898 
899  int insideOffset = textOffset;
900  int outsideOffset = 10;
901  float lineThickness = (float) GetDefaultLineThickness();
902  float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + lineThickness ) / 2.0;
903  float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[BELOW] + lineThickness ) / 2.0;
904 
905  if( drawingShadows )
906  {
907  for( float& t : thickness )
908  t += getShadowWidth();
909 
910  insideOffset -= KiROUND( getShadowWidth() / 2 );
911  outsideOffset -= KiROUND( getShadowWidth() / 2 );
912  }
913 
914  #define SET_DC( i ) \
915  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
916  m_gal->SetLineWidth( thickness[i] ); \
917  m_gal->SetStrokeColor( colour[i] )
918 
919  switch( orient )
920  {
921  case PIN_LEFT:
922  if( size[INSIDE] )
923  {
924  SET_DC( INSIDE );
927  strokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
928  }
929  if( size[OUTSIDE] )
930  {
931  SET_DC( OUTSIDE );
934  strokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
935  }
936  if( size[ABOVE] )
937  {
938  SET_DC( ABOVE );
941  strokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
942  }
943  if( size[BELOW] )
944  {
945  SET_DC( BELOW );
948  strokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
949  }
950  break;
951 
952  case PIN_RIGHT:
953  if( size[INSIDE] )
954  {
955  SET_DC( INSIDE );
959  strokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
960  }
961  if( size[OUTSIDE] )
962  {
963  SET_DC( OUTSIDE );
966  strokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
967  }
968  if( size[ABOVE] )
969  {
970  SET_DC( ABOVE );
973  strokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
974  }
975  if( size[BELOW] )
976  {
977  SET_DC( BELOW );
980  strokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
981  }
982  break;
983 
984  case PIN_DOWN:
985  if( size[INSIDE] )
986  {
987  SET_DC( INSIDE );
990  strokeText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
991  }
992  if( size[OUTSIDE] )
993  {
994  SET_DC( OUTSIDE );
997  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
998  }
999  if( size[ABOVE] )
1000  {
1001  SET_DC( ABOVE );
1004  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
1005  }
1006  if( size[BELOW] )
1007  {
1008  SET_DC( BELOW );
1011  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
1012  }
1013  break;
1014 
1015  case PIN_UP:
1016  if( size[INSIDE] )
1017  {
1018  SET_DC( INSIDE );
1021  strokeText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
1022  }
1023  if( size[OUTSIDE] )
1024  {
1025  SET_DC( OUTSIDE );
1028  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
1029  }
1030  if( size[ABOVE] )
1031  {
1032  SET_DC( ABOVE );
1035  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
1036  }
1037  if( size[BELOW] )
1038  {
1039  SET_DC( BELOW );
1042  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
1043  }
1044  break;
1045 
1046  default:
1047  wxFAIL_MSG( "Unknown pin orientation" );
1048  }
1049 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int GetPinNameOffset()
bool IsSelected() const
Definition: base_struct.h:223
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
int GetOrientation() const
Definition: lib_pin.h:204
LIB_PART * GetParent() const
Definition: lib_item.h:176
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:216
int color
Definition: DXF_plotter.cpp:61
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
static int InternalPinDecoSize(const LIB_PIN &aPin)
Definition: lib_pin.h:55
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
#define SET_DC(i)
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN.
Definition: lib_pin.h:349
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static int ExternalPinDecoSize(const LIB_PIN &aPin)
bool ShowPinNames()
void SetFontBold(const bool aBold)
Set bold property of current font.
bool ShowPinNumbers()
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:81
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxString const GetElectricalTypeName() const
return a translated string for messages giving the electrical type of the pin.
Definition: lib_pin.h:256
const wxString & GetName() const
Definition: lib_pin.h:149
Define a library symbol object.
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
#define OUTSIDE
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:343
int GetNameTextSize() const
Definition: lib_pin.h:175
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Definition: lib_pin.h:429
const wxString & GetNumber() const
Definition: lib_pin.h:177
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:232
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:202
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:149
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
bool GetSelectionDrawChildItems()
Draw selected child items or not.
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:61
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:256
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:258
#define INSIDE
not connected (must be left open)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define PIN_TEXT_MARGIN
int GetLength()
Definition: lib_pin.h:282
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References Clamp_Text_PenSize(), EDA_ITEM::ClearFlags(), CLOCK, CLOCK_LOW, color, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), drawPinDanglingSymbol(), KIGFX::ExternalPinDecoSize(), FALLING_EDGE_CLOCK, GetDefaultLineThickness(), 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(), GetSelectionDrawChildItems(), 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, KIGFX::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, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenPins, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, KIGFX::mapCoords(), NONLOGIC, OUTPUT_LOW, OUTSIDE, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_TEXT_MARGIN, PIN_UP, PT_NC, SET_DC, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), LIB_PART::ShowPinNames(), LIB_PART::ShowPinNumbers(), strokeText(), TARGET_PIN_RADIUS, triLine(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [3/21]

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

Definition at line 432 of file sch_painter.cpp.

433 {
434  if( !isUnitAndConversionShown( aCircle ) )
435  return;
436 
437  if( setDeviceColors( aCircle, aLayer ) )
438  {
439  fillIfSelection( aLayer );
440  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
441  }
442 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetPosition() const override
Definition: lib_circle.h:76
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:365
int GetRadius() const
Definition: lib_circle.h:92
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 317 of file sch_painter.cpp.

318 {
319  if( !aUnit )
320  aUnit = m_schSettings.m_ShowUnit;
321 
322  if( !aConvert )
323  aConvert = m_schSettings.m_ShowConvert;
324 
325  std::unique_ptr< LIB_PART > tmpPart;
326  LIB_PART* drawnPart = aPart;
327 
328  if( aPart->IsAlias() )
329  {
330  tmpPart = aPart->Flatten();
331  drawnPart = tmpPart.get();
332  }
333 
334  for( auto& item : drawnPart->GetDrawItems() )
335  {
336  if( !aDrawFields && item.Type() == LIB_FIELD_T )
337  continue;
338 
339  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
340  continue;
341 
342  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
343  continue;
344 
345  Draw( &item, aLayer );
346  }
347 }
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:178

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

446 {
447  if( !isUnitAndConversionShown( aArc ) )
448  return;
449 
450  if( setDeviceColors( aArc, aLayer ) )
451  {
452  int sai = aArc->GetFirstRadiusAngle();
453  int eai = aArc->GetSecondRadiusAngle();
454 
465  if( !TRANSFORM().MapAngles( &sai, &eai ) )
466  {
467  LIB_ARC new_arc( *aArc );
468 
469  new_arc.SetStart( aArc->GetEnd() );
470  new_arc.SetEnd( aArc->GetStart() );
471  new_arc.CalcRadiusAngles();
472  sai = new_arc.GetFirstRadiusAngle();
473  eai = new_arc.GetSecondRadiusAngle();
474  TRANSFORM().MapAngles( &sai, &eai );
475  }
476 
477  double sa = (double) sai * M_PI / 1800.0;
478  double ea = (double) eai * M_PI / 1800.0 ;
479 
480  VECTOR2D pos = mapCoords( aArc->GetPosition() );
481 
482  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
483  }
484 }
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
int GetSecondRadiusAngle() const
Definition: lib_arc.h:111
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
wxPoint GetStart() const
Definition: lib_arc.h:113
static VECTOR2D mapCoords(const wxPoint &aCoord)
int GetRadius() const
Definition: lib_arc.h:105
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
wxPoint GetEnd() const
Definition: lib_arc.h:116
int GetFirstRadiusAngle() const
Definition: lib_arc.h:108
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:81
wxPoint GetPosition() const override
Definition: lib_arc.h:92

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

◆ draw() [6/21]

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

Definition at line 487 of file sch_painter.cpp.

488 {
489  if( !isUnitAndConversionShown( aLine ) )
490  return;
491 
492  if( setDeviceColors( aLine, aLayer ) )
493  {
494  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
495  std::deque<VECTOR2D> vtx;
496 
497  for( auto p : pts )
498  vtx.push_back( mapCoords( p ) );
499 
500  fillIfSelection( aLayer );
501  m_gal->DrawPolygon( vtx );
502  }
503 }
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:365
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:60
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

507 {
508  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
509 
510  if( drawingShadows && !aField->IsSelected() )
511  return;
512 
513  if( !isUnitAndConversionShown( aField ) )
514  return;
515 
516  // Must check layer as fields are sometimes drawn by their parent rather than
517  // directly from the view.
518  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
519  int layers_count;
520  bool foundLayer = false;
521 
522  aField->ViewGetLayers( layers, layers_count );
523 
524  for( int i = 0; i < layers_count; ++i )
525  {
526  if( layers[i] == aLayer )
527  foundLayer = true;
528  }
529 
530  if( !foundLayer )
531  return;
532 
533  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
534 
535  if( !aField->IsVisible() )
536  {
537  if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
538  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
539  else
540  return;
541  }
542 
543  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
544  m_gal->SetIsFill( false );
545  m_gal->SetIsStroke( true );
547 
548  auto pos = mapCoords( aField->GetPosition() );
549 
550  if( drawingShadows && GetSelectionTextAsBox() )
551  {
552  EDA_RECT boundaryBox = aField->GetBoundingBox();
553 
554  m_gal->SetIsFill( true );
556  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
557  boundaryBox.RevertYAxis();
558 
560  mapCoords( boundaryBox.GetPosition() ), mapCoords( boundaryBox.GetEnd() ) );
561  }
562  else
563  {
564  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
565  m_gal->SetFontItalic( aField->IsItalic() );
566 
569 
570  double orient = aField->GetTextAngleRadians();
571 
572  strokeText( aField->GetText(), pos, orient );
573  }
574 
575  // Draw the umbilical line
576  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
577  {
579  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
580  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
581  }
582 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool GetSelectionTextAsBox()
Draw selected text items as box.
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:184
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:223
wxPoint GetPosition() const override
Definition: lib_field.h:179
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:220
int color
Definition: DXF_plotter.cpp:61
bool IsBrightened() const
Definition: base_struct.h:226
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
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:701
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
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:183
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxSize & GetTextSize() const
Definition: eda_text.h:223
const wxPoint GetPosition() const
Definition: eda_rect.h:115
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
double GetTextAngleRadians() const
Definition: eda_text.h:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), LIB_FIELD::GetBoundingBox(), EDA_RECT::GetEnd(), EDA_TEXT::GetHorizJustify(), getLineWidth(), KIGFX::GAL::GetLineWidth(), EDA_RECT::GetPosition(), LIB_FIELD::GetPosition(), getRenderColor(), GetSelectionTextAsBox(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_ITEM::IsBrightened(), EDA_TEXT::IsItalic(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), EDA_TEXT::IsVisible(), LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::SCH_RENDER_SETTINGS::m_ShowUmbilicals, KIGFX::mapCoords(), 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(), 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 585 of file sch_painter.cpp.

586 {
587  if( !isUnitAndConversionShown( aText ) )
588  return;
589 
590  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
591 
592  if( drawingShadows && !aText->IsSelected() )
593  return;
594 
595  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
596 
597  if( !aText->IsVisible() )
598  {
600  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
601  else
602  return;
603  }
604 
605  EDA_RECT bBox = aText->GetBoundingBox();
606  bBox.RevertYAxis();
607  VECTOR2D pos = mapCoords( bBox.Centre() );
608  double orient = aText->GetTextAngleRadians();
609 
612  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
613  m_gal->SetIsFill( false );
614  m_gal->SetIsStroke( true );
616  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
617  m_gal->SetFontBold( aText->IsBold() );
618  m_gal->SetFontItalic( aText->IsItalic() );
619  strokeText( aText->GetText(), pos, orient );
620 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
bool IsSelected() const
Definition: base_struct.h:223
bool IsVisible() const
Definition: eda_text.h:170
int color
Definition: DXF_plotter.cpp:61
bool IsBrightened() const
Definition: base_struct.h:226
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const wxSize & GetTextSize() const
Definition: eda_text.h:223
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
double GetTextAngleRadians() const
Definition: eda_text.h:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:271
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
wxPoint Centre() const
Definition: eda_rect.h: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:123
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References EDA_RECT::Centre(), color, LIB_TEXT::GetBoundingBox(), getLineWidth(), getRenderColor(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_ITEM::IsBrightened(), 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 1052 of file sch_painter.cpp.

1053 {
1054  if( !isUnitAndConversionShown( aCurve ) )
1055  return;
1056 
1057  if( setDeviceColors( aCurve, aLayer ) )
1058  {
1059  BEZIER_POLY poly ( aCurve->GetPoints() );
1060  std::vector<wxPoint> pts;
1061  std::deque<VECTOR2D> pts_xformed;
1062  poly.GetPoly( pts );
1063 
1064  for( const auto &p : pts )
1065  pts_xformed.push_back( mapCoords( p ) );
1066 
1067  m_gal->DrawPolygon( pts_xformed );
1068  }
1069 }
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:72
static VECTOR2D mapCoords(const wxPoint &aCoord)
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

◆ draw() [10/21]

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

Definition at line 1311 of file sch_painter.cpp.

1312 {
1313  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1314  LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
1315 
1316  // Copy the source so we can re-orient and translate it.
1317  LIB_PART tempPart( *originalPart );
1318 
1319  tempPart.SetFlags( aComp->GetFlags() );
1320 
1321  orientPart( &tempPart, aComp->GetOrientation() );
1322 
1323  for( auto& tempItem : tempPart.GetDrawItems() )
1324  {
1325  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1326  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition() ) );
1327  }
1328 
1329  // Copy the pin info from the component to the temp pins
1330  LIB_PINS tempPins;
1331  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1332  const SCH_PINS& compPins = aComp->GetPins();
1333 
1334  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1335  {
1336  LIB_PIN* tempPin = tempPins[ i ];
1337  const SCH_PIN& compPin = compPins[ i ];
1338 
1339  tempPin->ClearFlags();
1340  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1341 
1342  if( compPin.IsDangling() )
1343  tempPin->SetFlags( IS_DANGLING );
1344  }
1345 
1346  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1347 
1348  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1349  std::vector<SCH_FIELD*> fields;
1350  aComp->GetFields( fields, false );
1351 
1352  for( SCH_FIELD* field : fields )
1353  draw( field, aLayer );
1354 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
int GetOrientation()
Get the display symbol orientation.
std::vector< SCH_PIN > SCH_PINS
A container for several SCH_PIN items.
Definition: sch_component.h:67
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:54
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:87
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int GetUnit() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
Define a library symbol object.
std::unique_ptr< LIB_PART > & GetPartRef()
static VECTOR2D mapCoords(const wxPoint &aCoord)
static void orientPart(LIB_PART *part, int orientation)
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:149
wxPoint GetPosition() const override
Function GetPosition.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:256
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:257

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

◆ draw() [11/21]

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

Definition at line 1086 of file sch_painter.cpp.

1087 {
1088  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1089 
1090  if( drawingShadows && !aJct->IsSelected() )
1091  return;
1092 
1093  COLOR4D color;
1094  auto conn = aJct->Connection( *g_CurrentSheet );
1095 
1096  if( conn && conn->IsBus() )
1097  color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
1098  else
1099  color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
1100 
1101  m_gal->SetIsStroke( drawingShadows );
1102  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1104  m_gal->SetIsFill( !drawingShadows );
1105  m_gal->SetFillColor( color );
1107 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:223
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:100
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet Note: the returned value can ...
Definition: sch_item.cpp:128
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
static int GetEffectiveSymbolSize()
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [12/21]

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

Definition at line 1357 of file sch_painter.cpp.

1358 {
1359  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1360 
1361  if( drawingShadows && !aField->IsSelected() )
1362  return;
1363 
1364  switch( aField->GetId() )
1365  {
1366  case REFERENCE: aLayer = LAYER_REFERENCEPART; break;
1367  case VALUE: aLayer = LAYER_VALUEPART; break;
1368  default: aLayer = LAYER_FIELDS; break;
1369  }
1370 
1371  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1372 
1373  if( !aField->IsVisible() )
1374  {
1375  if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
1376  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1377  else
1378  return;
1379  }
1380 
1381  if( aField->IsVoid() )
1382  return;
1383 
1384  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1385 
1386  if( drawingShadows && parentComponent->IsSelected() && !GetSelectionDrawChildItems() )
1387  return;
1388 
1389  // Calculate the text orientation according to the component orientation.
1390  int orient = (int) aField->GetTextAngle();
1391 
1392  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1393  {
1394  if( orient == TEXT_ANGLE_HORIZ )
1395  orient = TEXT_ANGLE_VERT;
1396  else
1397  orient = TEXT_ANGLE_HORIZ;
1398  }
1399 
1400  /* Calculate the text justification, according to the component orientation/mirror.
1401  * Tthis is a bit complicated due to cumulative calculations:
1402  * - numerous cases (mirrored or not, rotation)
1403  * - the DrawGraphicText function recalculate also H and H justifications according to the
1404  * text orientation.
1405  * - When a component is mirrored, the text is not mirrored and justifications are
1406  * complicated to calculate
1407  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1408  * to know the text coordinate considered as centered
1409  */
1410  EDA_RECT boundaryBox = aField->GetBoundingBox();
1411  wxPoint textpos = boundaryBox.Centre();
1412 
1414  m_gal->SetIsStroke( true );
1415  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
1416 
1417  if( drawingShadows && GetSelectionTextAsBox() )
1418  {
1419  m_gal->SetIsFill( true );
1420  m_gal->SetFillColor( color );
1421  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1422  boundaryBox.RevertYAxis();
1423 
1425  mapCoords( boundaryBox.GetPosition() ), mapCoords( boundaryBox.GetEnd() ) );
1426  }
1427  else
1428  {
1431  m_gal->SetIsFill( false );
1432  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1433  m_gal->SetFontBold( aField->IsBold() );
1434  m_gal->SetFontItalic( aField->IsItalic() );
1435  m_gal->SetTextMirrored( aField->IsMirrored() );
1436 
1437  strokeText( aField->GetFullyQualifiedText(), textpos,
1438  orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
1439  }
1440 
1441  // Draw the umbilical line
1442  if( aField->IsMoving() )
1443  {
1445  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1446  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1447  }
1448 }
#define TEXT_ANGLE_HORIZ
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
bool GetSelectionTextAsBox()
Draw selected text items as box.
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:173
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:223
#define TEXT_ANGLE_VERT
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:220
int color
Definition: DXF_plotter.cpp:61
double GetTextAngle() const
Definition: eda_text.h:158
int GetId() const
Definition: sch_field.h:108
bool IsBrightened() const
Definition: base_struct.h:226
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
Field Reference of part, i.e. "IC21".
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:257
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
int y1
Definition: transform.h:49
const wxPoint GetEnd() const
Definition: eda_rect.h:116
void SetFontBold(const bool aBold)
Set bold property of current font.
#define VALUE
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
TRANSFORM & GetTransform() const
const wxSize & GetTextSize() const
Definition: eda_text.h:223
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:215
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:194
bool GetSelectionDrawChildItems()
Draw selected child items or not.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:75
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
wxPoint GetPosition() const override
Function GetPosition.
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.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References EDA_RECT::Centre(), color, KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), SCH_FIELD::GetBoundingBox(), EDA_RECT::GetEnd(), SCH_FIELD::GetFullyQualifiedText(), SCH_FIELD::GetId(), getLineWidth(), KIGFX::GAL::GetLineWidth(), EDA_ITEM::GetParent(), EDA_RECT::GetPosition(), SCH_COMPONENT::GetPosition(), getRenderColor(), GetSelectionDrawChildItems(), GetSelectionTextAsBox(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), SCH_COMPONENT::GetTransform(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_ITEM::IsBrightened(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), SCH_FIELD::IsVoid(), LAYER_FIELDS, LAYER_HIDDEN, LAYER_REFERENCEPART, LAYER_SELECTION_SHADOWS, LAYER_VALUEPART, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::mapCoords(), REFERENCE, EDA_RECT::RevertYAxis(), 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, VALUE, and TRANSFORM::y1.

◆ draw() [13/21]

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

Definition at line 1182 of file sch_painter.cpp.

1183 {
1184  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1185 
1186  if( drawingShadows && !aText->IsSelected() )
1187  return;
1188 
1189  switch( aText->Type() )
1190  {
1191  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1192  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1193  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1194  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1195  default: aLayer = LAYER_NOTES; break;
1196  }
1197 
1198  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1199  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
1200 
1201  if( conn && conn->IsBus() )
1202  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1203 
1204  if( !aText->IsVisible() )
1205  {
1206  if( m_schSettings.m_ShowHiddenText || aText->IsBrightened() )
1207  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1208  else
1209  return;
1210  }
1211 
1212  m_gal->SetIsFill( false );
1213  m_gal->SetIsStroke( true );
1214  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
1216  m_gal->SetTextAttributes( aText );
1217 
1218  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1219  wxString shownText( aText->GetShownText() );
1220 
1221  if( drawingShadows )
1222  {
1223  if( GetSelectionTextAsBox() )
1224  {
1225  EDA_RECT bBox = aText->GetBoundingBox();
1226 
1227  m_gal->SetIsFill( true );
1228  m_gal->SetFillColor( color );
1229  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1230  bBox.RevertYAxis();
1231 
1232  m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1233  return;
1234  }
1235 
1236  switch( aText->GetLabelSpinStyle() )
1237  {
1239  text_offset.x += getShadowWidth() / 2;
1240  break;
1241  case LABEL_SPIN_STYLE::UP:
1242  text_offset.y += getShadowWidth() / 2;
1243  break;
1245  text_offset.x -= getShadowWidth() / 2;
1246  break;
1248  text_offset.y -= getShadowWidth() / 2;
1249  break;
1250  }
1251  }
1252 
1253  if( !shownText.IsEmpty() )
1254  strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1255 
1256  if( aText->IsDangling() )
1257  drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
1258 }
bool IsDangling() const override
Definition: sch_text.h:302
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool GetSelectionTextAsBox()
Draw selected text items as box.
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:223
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
bool IsVisible() const
Definition: eda_text.h:170
int color
Definition: DXF_plotter.cpp:61
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:137
bool IsBrightened() const
Definition: base_struct.h:226
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
const wxPoint GetEnd() const
Definition: eda_rect.h:116
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
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:238
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:402
static VECTOR2D mapCoords(const wxPoint &aCoord)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet Note: the returned value can ...
Definition: sch_item.cpp:128
double GetTextAngleRadians() const
Definition: eda_text.h:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References LABEL_SPIN_STYLE::BOTTOM, color, SCH_ITEM::Connection(), drawDanglingSymbol(), KIGFX::GAL::DrawRectangle(), g_CurrentSheet, SCH_TEXT::GetBoundingBox(), EDA_RECT::GetEnd(), SCH_TEXT::GetLabelSpinStyle(), getLineWidth(), KIGFX::GAL::GetLineWidth(), EDA_RECT::GetPosition(), getRenderColor(), SCH_TEXT::GetSchematicTextOffset(), GetSelectionTextAsBox(), getShadowWidth(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), EDA_ITEM::IsBrightened(), SCH_CONNECTION::IsBus(), SCH_TEXT::IsDangling(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), LAYER_BUS, LAYER_GLOBLABEL, LAYER_HIDDEN, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, LAYER_SELECTION_SHADOWS, LAYER_SHEETLABEL, LABEL_SPIN_STYLE::LEFT, KIGFX::PAINTER::m_gal, m_schSettings, 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(), 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 1487 of file sch_painter.cpp.

1488 {
1489  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1490 
1491  if( drawingShadows && !aLabel->IsSelected() )
1492  return;
1493 
1494  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1495 
1496  SCH_CONNECTION* conn = aLabel->Connection( *g_CurrentSheet );
1497 
1498  if( conn && conn->IsBus() )
1499  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1500 
1501  std::vector<wxPoint> pts;
1502  std::deque<VECTOR2D> pts2;
1503 
1504  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1505 
1506  for( auto p : pts )
1507  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1508 
1509  m_gal->SetIsFill( true );
1511  m_gal->SetIsStroke( true );
1512  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1514  m_gal->DrawPolyline( pts2 );
1515 
1516  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1517 }
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:223
int color
Definition: DXF_plotter.cpp:61
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:221
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VECTOR2< double > VECTOR2D
Definition: vector2d.h: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
Retrieves the connection associated with this object in the given sheet Note: the returned value can ...
Definition: sch_item.cpp:128
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1080
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:232
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:178
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [15/21]

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

Definition at line 1451 of file sch_painter.cpp.

1452 {
1453  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1454 
1455  if( drawingShadows && !aLabel->IsSelected() )
1456  return;
1457 
1458  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1459 
1460  std::vector<wxPoint> pts;
1461  std::deque<VECTOR2D> pts2;
1462 
1463  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1464 
1465  for( auto p : pts )
1466  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1467 
1468  // the text is drawn inside the graphic shape.
1469  // On Cairo the graphic shape is filled by the background
1470  // before drawing the text ().
1471  // However if the text is selected, it is draw twice:
1472  // first, on LAYER_SELECTION_SHADOWS
1473  // second, on the text layer.
1474  // the second must not erase the first drawing.
1475  bool fillBg = ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected();
1476  m_gal->SetIsFill( fillBg );
1478  m_gal->SetIsStroke( true );
1479  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1481  m_gal->DrawPolyline( pts2 );
1482 
1483  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1484 }
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:223
int color
Definition: DXF_plotter.cpp:61
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:221
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:834
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:232
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:178
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [16/21]

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

Definition at line 1519 of file sch_painter.cpp.

1520 {
1521  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1522 
1523  if( aLayer == LAYER_HIERLABEL || drawingShadows )
1524  {
1525  for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
1526  {
1527  if( drawingShadows && !aSheet->IsSelected() && !sheetPin->IsSelected() )
1528  continue;
1529 
1530  if( drawingShadows && !GetSelectionDrawChildItems() && aSheet->IsSelected() )
1531  break;
1532 
1533  int width = aSheet->GetPenSize();
1534  wxPoint initial_pos = sheetPin->GetTextPos();
1535  wxPoint offset_pos = initial_pos;
1536 
1537  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1538  switch( sheetPin->GetEdge() )
1539  {
1540  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1541  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1542  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1543  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1544  default: break;
1545  }
1546 
1547  sheetPin->SetTextPos( offset_pos );
1548  draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
1549  m_gal->DrawLine( offset_pos, initial_pos );
1550  sheetPin->SetTextPos( initial_pos );
1551  }
1552  }
1553 
1554  if( drawingShadows && !aSheet->IsSelected() )
1555  return;
1556 
1557  VECTOR2D pos = aSheet->GetPosition();
1558  VECTOR2D size = aSheet->GetSize();
1559 
1560  if( aLayer == LAYER_SHEET_BACKGROUND )
1561  {
1562  m_gal->SetIsStroke( aSheet->IsSelected() );
1565 
1566  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1567  {
1568  // Select a fill color working well with black and white background color,
1569  // both in Opengl and Cairo
1570  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1571  m_gal->SetIsFill( true );
1572  }
1573  else
1574  {
1575  // Could be modified later, when sheets can have their own fill color
1577  m_gal->SetIsFill( aSheet->IsSelected() && GetSelectionFillShapes() );
1578  }
1579 
1580  m_gal->DrawRectangle( pos, pos + size );
1581  }
1582 
1583  if( aLayer == LAYER_SHEET || drawingShadows )
1584  {
1585  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1586  m_gal->SetIsStroke( true );
1587  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1588  m_gal->SetIsFill( false );
1589 
1590  m_gal->DrawRectangle( pos, pos + size );
1591 
1592  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1593  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1594  double nameAngle = 0.0;
1595 
1596  if( aSheet->IsVerticalOrientation() )
1597  nameAngle = M_PI/2;
1598 
1599  if( drawingShadows )
1600  {
1602  return;
1603 
1604  if( aSheet->IsVerticalOrientation() )
1605  {
1606  pos_sheetname.y += getShadowWidth() / 2;
1607  pos_filename.y += getShadowWidth() / 2;
1608  }
1609  else
1610  {
1611  pos_sheetname.x -= getShadowWidth() / 2;
1612  pos_filename.x -= getShadowWidth() / 2;
1613  }
1614  }
1615 
1616  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
1617 
1618  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1619 
1622 
1623  auto txtSize = aSheet->GetSheetNameSize();
1624 
1625  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1626  m_gal->SetFontBold( false );
1627  m_gal->SetFontItalic( false );
1628 
1629  strokeText( text, pos_sheetname, nameAngle );
1630 
1631  txtSize = aSheet->GetFileNameSize();
1632  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1633  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) );
1635 
1636  text = wxT( "File: " ) + aSheet->GetFileName();
1637  strokeText( text, pos_filename, nameAngle );
1638  }
1639 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:223
bool IsMoving() const
Definition: base_struct.h:220
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_sheet.cpp:382
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetFileNameSize() const
Definition: sch_sheet.h:275
void SetFontBold(const bool aBold)
Set bold property of current font.
int GetSheetNameSize() const
Definition: sch_sheet.h:272
wxString GetName() const
Definition: sch_sheet.h:269
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:538
wxPoint GetFileNamePosition()
Definition: sch_sheet.cpp:407
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:616
bool GetSelectionFillShapes()
Draw selected shapes as filled or not.
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:332
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool GetSelectionDrawChildItems()
Draw selected child items or not.
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:221
wxPoint GetSheetNamePosition()
Definition: sch_sheet.cpp:388
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:61
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void draw(LIB_RECTANGLE *aRect, int aLayer)
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxSize GetSize()
Definition: sch_sheet.h:280
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References draw(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), SCH_SHEET::GetFileName(), SCH_SHEET::GetFileNamePosition(), SCH_SHEET::GetFileNameSize(), getLineWidth(), SCH_SHEET::GetName(), SCH_SHEET::GetPenSize(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), getRenderColor(), GetSelectionDrawChildItems(), GetSelectionFillShapes(), getShadowWidth(), SCH_SHEET::GetSheetNamePosition(), SCH_SHEET::GetSheetNameSize(), SCH_SHEET::GetSize(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), SCH_SHEET::IsVerticalOrientation(), KiROUND(), LAYER_HIERLABEL, LAYER_SELECTION_SHADOWS, LAYER_SHEET, LAYER_SHEET_BACKGROUND, LAYER_SHEETFILENAME, LAYER_SHEETNAME, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), SHEET_BOTTOM_SIDE, SHEET_LEFT_SIDE, SHEET_RIGHT_SIDE, SHEET_TOP_SIDE, strokeText(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

◆ draw() [17/21]

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

Definition at line 1642 of file sch_painter.cpp.

1643 {
1644  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1645 
1646  if( drawingShadows && !aNC->IsSelected() )
1647  return;
1648 
1649  m_gal->SetIsStroke( true );
1650  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1651  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1652  m_gal->SetIsFill( false );
1653 
1654  VECTOR2D p = aNC->GetPosition();
1655  int delta = aNC->GetSize() / 2;
1656 
1657  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1658  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1659 }
bool IsSelected() const
Definition: base_struct.h:223
wxPoint GetPosition() const override
Function GetPosition.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h: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)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.

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

◆ draw() [18/21]

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

Definition at line 1740 of file sch_painter.cpp.

1741 {
1742  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1743 
1744  if( drawingShadows && !aMarker->IsSelected() )
1745  return;
1746 
1748  aLayer = LAYER_ERC_ERR;
1749  else
1750  aLayer = LAYER_ERC_WARN;
1751 
1752  COLOR4D color = getRenderColor( aMarker, aLayer, drawingShadows );
1753 
1754  m_gal->Save();
1755  m_gal->Translate( aMarker->GetPosition() );
1756  m_gal->SetIsFill( !drawingShadows );
1757  m_gal->SetFillColor( color );
1758  m_gal->SetIsStroke( drawingShadows );
1759  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1761 
1762  SHAPE_LINE_CHAIN polygon;
1763  aMarker->ShapeToPolygon( polygon );
1764 
1765  m_gal->DrawPolygon( polygon );
1766  m_gal->Restore();
1767 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:223
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:174
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_marker.h:98
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
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:39

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

◆ draw() [19/21]

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

Definition at line 1695 of file sch_painter.cpp.

1696 {
1697  m_gal->Save();
1698  m_gal->Translate( aBitmap->GetPosition() );
1699 
1700  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1701  // factor is similar to a local zoom
1702  double img_scale = aBitmap->GetImageScale();
1703 
1704  if( img_scale != 1.0 )
1705  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1706 
1707  if( aLayer == LAYER_DRAW_BITMAPS )
1708  {
1709  m_gal->DrawBitmap( *aBitmap->GetImage() );
1710  }
1711 
1712  if( aLayer == LAYER_SELECTION_SHADOWS )
1713  {
1714  if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
1715  {
1716  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1717  m_gal->SetIsStroke( true );
1720  m_gal->SetIsFill( false );
1721 
1722  // Draws a bounding box.
1723  VECTOR2D bm_size( aBitmap->GetSize() );
1724  // bm_size is the actual image size in UI.
1725  // but m_gal scale was previously set to img_scale
1726  // so recalculate size relative to this image size.
1727  bm_size.x /= img_scale;
1728  bm_size.y /= img_scale;
1729  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1730  VECTOR2D end = origin + bm_size;
1731 
1732  m_gal->DrawRectangle( origin, end );
1733  }
1734  }
1735 
1736  m_gal->Restore();
1737 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:223
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:226
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:140
bool IsHighlighted() const
Definition: base_struct.h:225
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxSize GetSize() const
Definition: sch_bitmap.cpp:123
VECTOR2< double > VECTOR2D
Definition: vector2d.h: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:39

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::IsHighlighted(), EDA_ITEM::IsSelected(), LAYER_DRAW_BITMAPS, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::Restore(), KIGFX::GAL::Save(), KIGFX::GAL::Scale(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::Translate(), and VECTOR2< T >::x.

◆ draw() [20/21]

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

Definition at line 1110 of file sch_painter.cpp.

1111 {
1112  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1113 
1114  if( drawingShadows && !aLine->IsSelected() )
1115  return;
1116 
1117  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1118  float width = getLineWidth( aLine, drawingShadows );
1119 
1120  m_gal->SetIsStroke( true );
1122  m_gal->SetLineWidth( width );
1123 
1124  if( aLine->GetLineStyle() <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1125  {
1126  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1127  }
1128  else
1129  {
1130  VECTOR2D start = aLine->GetStartPoint();
1131  VECTOR2D end = aLine->GetEndPoint();
1132 
1133  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1134  clip.Normalize();
1135 
1136  double theta = atan2( end.y - start.y, end.x - start.x );
1137  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1138 
1139  switch( aLine->GetLineStyle() )
1140  {
1141  default:
1142  case PLOT_DASH_TYPE::DASH:
1143  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1144  break;
1145  case PLOT_DASH_TYPE::DOT:
1146  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1147  break;
1149  strokes[0] = DASH_MARK_LEN( width );
1150  strokes[2] = DOT_MARK_LEN( width );
1151  break;
1152  }
1153 
1154  for( size_t i = 0; i < 10000; ++i )
1155  {
1156  // Calculations MUST be done in doubles to keep from accumulating rounding
1157  // errors as we go.
1158  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1159  start.y + strokes[ i % 4 ] * sin( theta ) );
1160 
1161  // Drawing each segment can be done rounded to ints.
1162  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1163  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1164 
1165  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1166  break;
1167  else if( i % 2 == 0 )
1168  m_gal->DrawLine( segStart, segEnd );
1169 
1170  start = next;
1171  }
1172  }
1173 
1174  if( aLine->IsStartDangling() )
1175  drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
1176 
1177  if( aLine->IsEndDangling() )
1178  drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
1179 }
CITER next(CITER it)
Definition: ptree.cpp:130
wxPoint GetStartPoint() const
Definition: sch_line.h:97
bool IsSelected() const
Definition: base_struct.h:223
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
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:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
PLOT_DASH_TYPE GetLineStyle() const
Definition: sch_line.cpp:287
bool IsEndDangling() const
Definition: sch_line.h:184
#define DOT_MARK_LEN(aLineWidth)
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:212
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsStartDangling() const
Definition: sch_line.h:183
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:61
#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:39
wxPoint GetEndPoint() const
Definition: sch_line.h:100

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

◆ draw() [21/21]

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

Definition at line 1662 of file sch_painter.cpp.

1663 {
1664  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1665 
1666  if( drawingShadows && !aEntry->IsSelected() )
1667  return;
1668 
1669  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1670 
1671  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1672  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1673 
1674  m_gal->SetIsStroke( true );
1675  m_gal->SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
1677  m_gal->SetIsFill( false );
1678 
1679  VECTOR2D pos = aEntry->GetPosition();
1680  VECTOR2D endPos = aEntry->m_End();
1681 
1682  m_gal->DrawLine( pos, endPos );
1683 
1684  // Draw dangling symbols:
1685  m_gal->SetLineWidth ( getLineWidth( aEntry, drawingShadows ) );
1686 
1687  if( aEntry->IsDanglingStart() )
1689 
1690  if( aEntry->IsDanglingEnd() )
1692 }
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:35
bool IsSelected() const
Definition: base_struct.h:223
int color
Definition: DXF_plotter.cpp:61
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:52
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsDanglingStart() const
Definition: sch_bus_entry.h:51
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint m_End() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetPosition() const override
Function GetPosition.

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

◆ drawDanglingSymbol()

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

Definition at line 1074 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ drawPinDanglingSymbol()

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

Definition at line 638 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ fillIfSelection()

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

Definition at line 412 of file sch_painter.cpp.

413 {
415  m_gal->SetIsFill( true );
416 }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool GetSelectionFillShapes()
Draw selected shapes as filled or not.

References GetSelectionFillShapes(), 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 275 of file sch_painter.cpp.

276 {
277  float width = (float) aItem->GetPenSize();
278 
279  if( aItem->IsSelected() && aDrawingShadows )
280  width += getShadowWidth();
281 
282  return width;
283 }
bool IsSelected() const
Definition: base_struct.h:223
virtual int GetPenSize() const =0

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

Referenced by draw(), and setDeviceColors().

◆ getLineWidth() [2/2]

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

Definition at line 286 of file sch_painter.cpp.

287 {
288  float width = (float) aItem->GetPenSize();
289 
290  if( aItem->IsSelected() && aDrawingShadows )
291  width += getShadowWidth();
292 
293  return width;
294 }
bool IsSelected() const
Definition: base_struct.h:223
virtual int GetPenSize() const
Function GetPenSize virtual pure.
Definition: sch_item.h:231

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

◆ getRenderColor()

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

Definition at line 242 of file sch_painter.cpp.

243 {
244  static COLOR4D highlightColor( 1.0, 0.3, 0.3, 1.0 );
245 
247 
248  if( aItem->Type() == SCH_LINE_T )
249  color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
250 
251  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
252  {
254 
255  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
256  color = color.WithAlpha( 0.2 );
257  }
258  else if( aItem->IsSelected() )
259  {
260  if( aDrawingShadows )
262  }
263  else if( aItem->IsHighlighted() ) // Cross-probing
264  {
265  color = highlightColor;
266  }
267 
269  color = color.Darken( 0.5f );
270 
271  return color;
272 }
bool IsSelected() const
Definition: base_struct.h:223
int color
Definition: DXF_plotter.cpp:61
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:221
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:247
bool IsBrightened() const
Definition: base_struct.h:226
bool IsHighlighted() const
Definition: base_struct.h:225
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

Referenced by draw(), and setDeviceColors().

◆ GetSettings()

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

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

Returns
Current rendering settings.

Implements KIGFX::PAINTER.

Definition at line 133 of file sch_painter.h.

134  {
135  return &m_schSettings;
136  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178

References m_schSettings.

◆ getShadowWidth()

float KIGFX::SCH_PAINTER::getShadowWidth ( )
private

Definition at line 231 of file sch_painter.cpp.

232 {
233  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
234 
235  // For best visuals the selection width must be a cross between the zoom level and the
236  // default line width.
237  return static_cast<float>(
238  fabs( matrix.GetScale().x * 2.75 ) + GetSelectionThickness() );
239 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
int GetSelectionThickness()
Selection highlight thickness.

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

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

◆ getTextThickness()

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

Definition at line 297 of file sch_painter.cpp.

298 {
299  float width = (float) aItem->GetThickness();
300 
301  if( width == 0 )
302  width = (float) GetDefaultLineThickness();
303 
304  if( aItem->IsSelected() && aDrawingShadows )
305  width += getShadowWidth();
306 
307  return width;
308 }
bool IsSelected() const
Definition: base_struct.h:223
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148

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

Referenced by draw().

◆ isUnitAndConversionShown()

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

Definition at line 211 of file sch_painter.cpp.

212 {
213  if( m_schSettings.m_ShowUnit // showing a specific unit
214  && aItem->GetUnit() // item is unit-specific
215  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
216  {
217  return false;
218  }
219 
220  if( m_schSettings.m_ShowConvert // showing a specific conversion
221  && aItem->GetConvert() // item is conversion-specific
222  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
223  {
224  return false;
225  }
226 
227  return true;
228 }
int GetUnit() const
Definition: lib_item.h:300
int GetConvert() const
Definition: lib_item.h:303
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178

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

364 {
365  switch( aLayer )
366  {
368  if( aItem->IsSelected() )
369  {
370  m_gal->SetIsFill( false );
371  m_gal->SetIsStroke( true );
372  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
373  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
374  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
375  return true;
376  }
377 
378  return false;
379 
381  if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
382  {
383  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
384 
385  // These actions place the item over others, so allow a modest transparency here
386  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
387  fillColor = fillColor.WithAlpha( 0.75 );
388 
390  m_gal->SetFillColor( fillColor );
391  m_gal->SetIsStroke( false );
392  return true;
393  }
394 
395  return false;
396 
397  case LAYER_DEVICE:
398  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
399  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
400  m_gal->SetIsStroke( aItem->GetPenSize() > 0 );
401  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
402  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
403 
404  return true;
405 
406  default:
407  return false;
408  }
409 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:223
bool IsMoving() const
Definition: base_struct.h:220
FILL_T GetFillMode() const
Definition: lib_item.h:306
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:247
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsDragging() const
Definition: base_struct.h:221
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
bool IsResized() const
Definition: base_struct.h:224
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual int GetPenSize() const =0
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, LIB_ITEM::GetFillMode(), getLineWidth(), LIB_ITEM::GetPenSize(), getRenderColor(), EDA_ITEM::IsDragging(), EDA_ITEM::IsMoving(), EDA_ITEM::IsResized(), EDA_ITEM::IsSelected(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), and KIGFX::COLOR4D::WithAlpha().

Referenced by draw().

◆ SetGAL()

void KIGFX::PAINTER::SetGAL ( GAL aGal)
inlineinherited

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

Parameters
aGalis the new GAL instance.

Definition at line 333 of file painter.h.

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

References KIGFX::PAINTER::m_gal.

◆ strokeText()

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

Definition at line 311 of file sch_painter.cpp.

312 {
313  m_gal->StrokeText( aText, aPosition, aAngle, GetTextMarkupFlags() );
314 }
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
int GetTextMarkupFlags()
Definition: gr_text.cpp:55
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.

References GetTextMarkupFlags(), 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 356 of file sch_painter.cpp.

357 {
358  m_gal->DrawLine( a, b );
359  m_gal->DrawLine( b, c );
360 }
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365

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

Referenced by draw().

Member Data Documentation

◆ m_brightenedColor

COLOR4D KIGFX::PAINTER::m_brightenedColor
protectedinherited

Color of brightened item frame.

Definition at line 368 of file painter.h.

◆ m_gal

GAL* KIGFX::PAINTER::m_gal
protectedinherited

◆ m_schSettings

SCH_RENDER_SETTINGS KIGFX::SCH_PAINTER::m_schSettings
private

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