KiCad PCB EDA Suite
KIGFX::SCH_PAINTER Class Reference

Class SCH_PAINTER Contains methods for drawing schematic-specific items. More...

#include <sch_painter.h>

Inheritance diagram for KIGFX::SCH_PAINTER:
KIGFX::PAINTER

Public Member Functions

 SCH_PAINTER (GAL *aGal)
 
virtual bool Draw (const VIEW_ITEM *, int) override
 Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the item. More...
 
virtual void ApplySettings (const RENDER_SETTINGS *aSettings) override
 Function ApplySettings Loads colors and display modes settings that are going to be used when drawing items. More...
 
virtual SCH_RENDER_SETTINGSGetSettings () override
 Function GetSettings Returns pointer to current settings that are going to be used when drawing items. More...
 
void SetGAL (GAL *aGal)
 Function SetGAL Changes Graphics Abstraction Layer used for drawing items for a new one. More...
 

Protected Attributes

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

Private Member Functions

void draw (LIB_RECTANGLE *aRect, int aLayer)
 
void draw (LIB_PIN *aPin, int aLayer)
 
void draw (LIB_CIRCLE *aCircle, int aLayer)
 
void draw (LIB_PART *aPart, int, bool aDrawFields=true, int aUnit=0, int aConvert=0)
 
void draw (LIB_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

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

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

Member Function Documentation

◆ ApplySettings()

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

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

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 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 148 of file sch_painter.cpp.

149 {
150  auto item2 = static_cast<const EDA_ITEM*>( aItem );
151  auto item = const_cast<EDA_ITEM*>( item2 );
152 
154 
155 #ifdef CONNECTIVITY_DEBUG
156 
157  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
158  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
159 
160  if( conn )
161  {
162  auto pos = item->GetBoundingBox().Centre();
163  auto label = conn->Name( true );
164 
168  m_gal->SetLineWidth( 2 );
169  m_gal->SetGlyphSize( VECTOR2D( 20, 20 ) );
170  m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
171  }
172 
173 #endif
174 
175  switch( item->Type() )
176  {
201 
202  default: return false;
203  }
204 
205  return false;
206 }
Class 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:586
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:209
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
#define HANDLE_ITEM(type_id, type_name)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: sch_painter.cpp:82
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:35
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References g_CurrentSheet, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, HANDLE_ITEM, KIGFX::SCH_RENDER_SETTINGS::ImportLegacyColors(), LIB_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 416 of file sch_painter.cpp.

417 {
418  if( !isUnitAndConversionShown( aRect ) )
419  return;
420 
421  if( setDeviceColors( aRect, aLayer ) )
422  {
423  fillIfSelection( aLayer );
424  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
425  }
426 }
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 645 of file sch_painter.cpp.

646 {
647  if( !isUnitAndConversionShown( aPin ) )
648  return;
649 
650  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
651 
652  if( drawingShadows && !aPin->IsSelected() )
653  return;
654 
655  VECTOR2I pos = mapCoords( aPin->GetPosition() );
656  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
657 
658  if( !aPin->IsVisible() )
659  {
661  {
662  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
663  }
664  else
665  {
666  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
667  drawPinDanglingSymbol( pos, drawingShadows );
668 
669  return;
670  }
671  }
672 
673  VECTOR2I p0;
674  VECTOR2I dir;
675  int len = aPin->GetLength();
676  int orient = aPin->GetOrientation();
677 
678  switch( orient )
679  {
680  case PIN_UP:
681  p0 = VECTOR2I( pos.x, pos.y - len );
682  dir = VECTOR2I( 0, 1 );
683  break;
684 
685  case PIN_DOWN:
686  p0 = VECTOR2I( pos.x, pos.y + len );
687  dir = VECTOR2I( 0, -1 );
688  break;
689 
690  case PIN_LEFT:
691  p0 = VECTOR2I( pos.x - len, pos.y );
692  dir = VECTOR2I( 1, 0 );
693  break;
694 
695  default:
696  case PIN_RIGHT:
697  p0 = VECTOR2I( pos.x + len, pos.y );
698  dir = VECTOR2I( -1, 0 );
699  break;
700  }
701 
702  VECTOR2D pc;
703 
704  m_gal->SetIsStroke( true );
705  m_gal->SetIsFill( false );
706  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
708  m_gal->SetFontBold( false );
709  m_gal->SetFontItalic( false );
710 
711  const int radius = ExternalPinDecoSize( *aPin );
712  const int diam = radius*2;
713  const int clock_size = InternalPinDecoSize( *aPin );
714 
715  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
716  {
717  m_gal->DrawLine( p0, pos );
718 
719  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
720  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
721  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
722  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
723 
724  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
725  }
726  else
727  {
728  switch( aPin->GetShape() )
729  {
730  case PINSHAPE_LINE:
731  m_gal->DrawLine( p0, pos );
732  break;
733 
734  case PINSHAPE_INVERTED:
735  m_gal->DrawCircle( p0 + dir * radius, radius );
736  m_gal->DrawLine( p0 + dir * ( diam ), pos );
737  break;
738 
740  pc = p0 - dir * clock_size ;
741 
742  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
743  pc,
744  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
745 
746  m_gal->DrawCircle( p0 + dir * radius, radius );
747  m_gal->DrawLine( p0 + dir * ( diam ), pos );
748  break;
749 
750  case PINSHAPE_CLOCK_LOW:
752  pc = p0 - dir * clock_size ;
753 
754  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
755  pc,
756  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
757 
758  if( !dir.y )
759  {
760  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
761  p0 + VECTOR2D(dir.x, -1) * diam,
762  p0 );
763  }
764  else /* MapX1 = 0 */
765  {
766  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
767  p0 + VECTOR2D(-1, dir.y) * diam,
768  p0 );
769  }
770 
771  m_gal->DrawLine( p0, pos );
772  break;
773 
774  case PINSHAPE_CLOCK:
775  m_gal->DrawLine( p0, pos );
776 
777  if( !dir.y )
778  {
779  triLine( p0 + VECTOR2D( 0, clock_size ),
780  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
781  p0 + VECTOR2D( 0, -clock_size ) );
782  }
783  else
784  {
785  triLine( p0 + VECTOR2D( clock_size, 0 ),
786  p0 + VECTOR2D( 0, -dir.y * clock_size ),
787  p0 + VECTOR2D( -clock_size, 0 ) );
788  }
789  break;
790 
791  case PINSHAPE_INPUT_LOW:
792  m_gal->DrawLine( p0, pos );
793 
794  if( !dir.y )
795  {
796  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
797  p0 + VECTOR2D(dir.x, -1) * diam,
798  p0 );
799  }
800  else /* MapX1 = 0 */
801  {
802  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
803  p0 + VECTOR2D(-1, dir.y) * diam,
804  p0 );
805  }
806  break;
807 
808  case PINSHAPE_OUTPUT_LOW: // IEEE symbol "Active Low Output"
809  m_gal->DrawLine( p0, pos );
810 
811  if( !dir.y ) // Horizontal pin
812  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
813  else // Vertical pin
814  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
815  break;
816 
817  case PINSHAPE_NONLOGIC: // NonLogic pin symbol
818  m_gal->DrawLine( p0, pos );
819 
820  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
821  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
822  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
823  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
824  break;
825  }
826  }
827 
828 
829  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
830  drawPinDanglingSymbol( pos, drawingShadows );
831 
832  LIB_PART* libEntry = aPin->GetParent();
833 
834  // Draw the labels
835  if( drawingShadows && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() )
837  return;
838 
839  int textOffset = libEntry->GetPinNameOffset();
840 
841  float nameLineWidth = getLineWidth( aPin, drawingShadows );
842  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
843  float numLineWidth = getLineWidth( aPin, drawingShadows );
844  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
845 
846  #define PIN_TEXT_MARGIN 4.0
847 
848  // Four locations around a pin where text can be drawn
849  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
850  int size[4] = { 0, 0, 0, 0 };
851  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
852  COLOR4D colour[4];
853  wxString text[4];
854 
855  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
856  if( textOffset )
857  {
858  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
859  thickness[INSIDE] = nameLineWidth;
860  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
861  text [INSIDE] = aPin->GetName();
862 
863  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
864  thickness[ABOVE] = numLineWidth;
865  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
866  text [ABOVE] = aPin->GetNumber();
867  }
868  // Otherwise pin NAMES go above and pin NUMBERS go below
869  else
870  {
871  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
872  thickness[ABOVE] = nameLineWidth;
873  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
874  text [ABOVE] = aPin->GetName();
875 
876  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
877  thickness[BELOW] = numLineWidth;
878  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
879  text [BELOW] = aPin->GetNumber();
880  }
881 
883  {
884  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
885  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
886  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
887  text [OUTSIDE] = aPin->GetElectricalTypeName();
888  }
889 
890  if( !aPin->IsVisible() )
891  {
892  for( COLOR4D& c : colour )
893  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
894  }
895 
896  int insideOffset = textOffset;
897  int outsideOffset = 10;
898  float lineThickness = (float) GetDefaultLineThickness();
899  float aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + lineThickness ) / 2.0;
900  float belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + lineThickness ) / 2.0;
901 
902  if( drawingShadows )
903  {
904  for( float& t : thickness )
905  t += getShadowWidth();
906 
907  insideOffset -= KiROUND( getShadowWidth() / 2 );
908  outsideOffset -= KiROUND( getShadowWidth() / 2 );
909  }
910 
911  #define SET_DC( i ) \
912  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
913  m_gal->SetLineWidth( thickness[i] ); \
914  m_gal->SetStrokeColor( colour[i] )
915 
916  switch( orient )
917  {
918  case PIN_LEFT:
919  if( size[INSIDE] )
920  {
921  SET_DC( INSIDE );
924  strokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
925  }
926  if( size[OUTSIDE] )
927  {
928  SET_DC( OUTSIDE );
931  strokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
932  }
933  if( size[ABOVE] )
934  {
935  SET_DC( ABOVE );
938  strokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
939  }
940  if( size[BELOW] )
941  {
942  SET_DC( BELOW );
945  strokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
946  }
947  break;
948 
949  case PIN_RIGHT:
950  if( size[INSIDE] )
951  {
952  SET_DC( INSIDE );
956  strokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
957  }
958  if( size[OUTSIDE] )
959  {
960  SET_DC( OUTSIDE );
963  strokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
964  }
965  if( size[ABOVE] )
966  {
967  SET_DC( ABOVE );
970  strokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
971  }
972  if( size[BELOW] )
973  {
974  SET_DC( BELOW );
977  strokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
978  }
979  break;
980 
981  case PIN_DOWN:
982  if( size[INSIDE] )
983  {
984  SET_DC( INSIDE );
987  strokeText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
988  }
989  if( size[OUTSIDE] )
990  {
991  SET_DC( OUTSIDE );
994  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
995  }
996  if( size[ABOVE] )
997  {
998  SET_DC( ABOVE );
1001  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
1002  }
1003  if( size[BELOW] )
1004  {
1005  SET_DC( BELOW );
1008  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
1009  }
1010  break;
1011 
1012  case PIN_UP:
1013  if( size[INSIDE] )
1014  {
1015  SET_DC( INSIDE );
1018  strokeText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
1019  }
1020  if( size[OUTSIDE] )
1021  {
1022  SET_DC( OUTSIDE );
1025  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
1026  }
1027  if( size[ABOVE] )
1028  {
1029  SET_DC( ABOVE );
1032  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
1033  }
1034  if( size[BELOW] )
1035  {
1036  SET_DC( BELOW );
1039  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
1040  }
1041  break;
1042 
1043  default:
1044  wxFAIL_MSG( "Unknown pin orientation" );
1045  }
1046 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
int GetPinNameOffset()
bool IsSelected() const
Definition: base_struct.h:233
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
int GetOrientation() const
Definition: lib_pin.h:204
LIB_PART * GetParent() const
Definition: lib_item.h:177
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:216
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
static int InternalPinDecoSize(const LIB_PIN &aPin)
Definition: lib_pin.h:55
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
#define SET_DC(i)
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN.
Definition: lib_pin.h:349
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static int ExternalPinDecoSize(const LIB_PIN &aPin)
bool ShowPinNames()
void SetFontBold(const bool aBold)
Set bold property of current font.
bool ShowPinNumbers()
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:64
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxString const GetElectricalTypeName() const
return a translated string for messages giving the electrical type of the pin.
Definition: lib_pin.h:256
const wxString & GetName() const
Definition: lib_pin.h:149
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:427
const wxString & GetNumber() const
Definition: lib_pin.h:177
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:232
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:202
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:149
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
#define max(a, b)
Definition: auxiliary.h:86
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
bool GetSelectionDrawChildItems()
Draw selected child items or not.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:268
#define INSIDE
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:210
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References Clamp_Text_PenSize(), EDA_ITEM::ClearFlags(), color, KIGFX::GAL::DrawCircle(), KIGFX::GAL::DrawLine(), drawPinDanglingSymbol(), KIGFX::ExternalPinDecoSize(), GetDefaultLineThickness(), LIB_PIN::GetElectricalTypeName(), 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(), INSIDE, KIGFX::InternalPinDecoSize(), IS_DANGLING, LIB_PIN::IsPowerConnection(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), LIB_PIN::IsVisible(), KiROUND(), LAYER_HIDDEN, LAYER_NOTES, LAYER_PIN, LAYER_PINNAM, LAYER_PINNUM, LAYER_SELECTION_SHADOWS, LIB_PART_T, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenPins, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, KIGFX::mapCoords(), max, OUTSIDE, PIN_DOWN, PIN_LEFT, PIN_NC, PIN_RIGHT, PIN_TEXT_MARGIN, PIN_UP, PINSHAPE_CLOCK, PINSHAPE_CLOCK_LOW, PINSHAPE_FALLING_EDGE_CLOCK, PINSHAPE_INPUT_LOW, PINSHAPE_INVERTED, PINSHAPE_INVERTED_CLOCK, PINSHAPE_LINE, PINSHAPE_NONLOGIC, PINSHAPE_OUTPUT_LOW, SET_DC, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), LIB_PART::ShowPinNames(), LIB_PART::ShowPinNumbers(), 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 429 of file sch_painter.cpp.

430 {
431  if( !isUnitAndConversionShown( aCircle ) )
432  return;
433 
434  if( setDeviceColors( aCircle, aLayer ) )
435  {
436  fillIfSelection( aLayer );
437  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
438  }
439 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetPosition() const override
Definition: lib_circle.h:75
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:91
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

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

443 {
444  if( !isUnitAndConversionShown( aArc ) )
445  return;
446 
447  if( setDeviceColors( aArc, aLayer ) )
448  {
449  int sai = aArc->GetFirstRadiusAngle();
450  int eai = aArc->GetSecondRadiusAngle();
451 
462  if( !TRANSFORM().MapAngles( &sai, &eai ) )
463  {
464  LIB_ARC new_arc( *aArc );
465 
466  new_arc.SetStart( aArc->GetEnd() );
467  new_arc.SetEnd( aArc->GetStart() );
468  new_arc.CalcRadiusAngles();
469  sai = new_arc.GetFirstRadiusAngle();
470  eai = new_arc.GetSecondRadiusAngle();
471  TRANSFORM().MapAngles( &sai, &eai );
472  }
473 
474  double sa = (double) sai * M_PI / 1800.0;
475  double ea = (double) eai * M_PI / 1800.0 ;
476 
477  VECTOR2D pos = mapCoords( aArc->GetPosition() );
478 
479  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
480  }
481 }
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
int GetSecondRadiusAngle() const
Definition: lib_arc.h:111
Class for 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:80
wxPoint GetPosition() const override
Definition: lib_arc.h:92

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

◆ draw() [6/21]

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

Definition at line 484 of file sch_painter.cpp.

485 {
486  if( !isUnitAndConversionShown( aLine ) )
487  return;
488 
489  if( setDeviceColors( aLine, aLayer ) )
490  {
491  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
492  std::deque<VECTOR2D> vtx;
493 
494  for( auto p : pts )
495  vtx.push_back( mapCoords( p ) );
496 
497  fillIfSelection( aLayer );
498  m_gal->DrawPolygon( vtx );
499  }
500 }
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 503 of file sch_painter.cpp.

504 {
505  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
506 
507  if( drawingShadows && !aField->IsSelected() )
508  return;
509 
510  if( !isUnitAndConversionShown( aField ) )
511  return;
512 
513  // Must check layer as fields are sometimes drawn by their parent rather than
514  // directly from the view.
515  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
516  int layers_count;
517  bool foundLayer = false;
518 
519  aField->ViewGetLayers( layers, layers_count );
520 
521  for( int i = 0; i < layers_count; ++i )
522  {
523  if( layers[i] == aLayer )
524  foundLayer = true;
525  }
526 
527  if( !foundLayer )
528  return;
529 
530  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
531 
532  if( !aField->IsVisible() )
533  {
534  if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
535  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
536  else
537  return;
538  }
539 
540  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
541  m_gal->SetIsFill( false );
542  m_gal->SetIsStroke( true );
544 
545  auto pos = mapCoords( aField->GetPosition() );
546 
547  if( drawingShadows && GetSelectionTextAsBox() )
548  {
549  EDA_RECT boundaryBox = aField->GetBoundingBox();
550 
551  m_gal->SetIsFill( true );
553  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
554  boundaryBox.RevertYAxis();
555 
557  mapCoords( boundaryBox.GetPosition() ), mapCoords( boundaryBox.GetEnd() ) );
558  }
559  else
560  {
561  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
562  m_gal->SetFontItalic( aField->IsItalic() );
563 
566 
567  double orient = aField->GetTextAngleRadians();
568 
569  strokeText( aField->GetText(), pos, orient );
570  }
571 
572  // Draw the umbilical line
573  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
574  {
576  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
577  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
578  }
579 }
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:185
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:233
wxPoint GetPosition() const override
Definition: lib_field.h:179
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:230
int color
Definition: DXF_plotter.cpp:62
bool IsBrightened() const
Definition: base_struct.h:236
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:184
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
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)
size_t i
Definition: json11.cpp:649
Class 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
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
Class 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(), i, 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 582 of file sch_painter.cpp.

583 {
584  if( !isUnitAndConversionShown( aText ) )
585  return;
586 
587  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
588 
589  if( drawingShadows && !aText->IsSelected() )
590  return;
591 
592  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
593 
594  if( !aText->IsVisible() )
595  {
597  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
598  else
599  return;
600  }
601 
602  EDA_RECT bBox = aText->GetBoundingBox();
603  bBox.RevertYAxis();
604  VECTOR2D pos = mapCoords( bBox.Centre() );
605  double orient = aText->GetTextAngleRadians();
606 
609  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
610  m_gal->SetIsFill( false );
611  m_gal->SetIsStroke( true );
613  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
614  m_gal->SetFontBold( aText->IsBold() );
615  m_gal->SetFontItalic( aText->IsItalic() );
616  strokeText( aText->GetText(), pos, orient );
617 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
bool IsSelected() const
Definition: base_struct.h:233
bool IsVisible() const
Definition: eda_text.h:170
int color
Definition: DXF_plotter.cpp:62
bool IsBrightened() const
Definition: base_struct.h:236
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:586
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)
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
wxPoint Centre() const
Definition: eda_rect.h: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
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

1050 {
1051  if( !isUnitAndConversionShown( aCurve ) )
1052  return;
1053 
1054  if( setDeviceColors( aCurve, aLayer ) )
1055  {
1056  BEZIER_POLY poly ( aCurve->GetPoints() );
1057  std::vector<wxPoint> pts;
1058  std::deque<VECTOR2D> pts_xformed;
1059  poly.GetPoly( pts );
1060 
1061  for( const auto &p : pts )
1062  pts_xformed.push_back( mapCoords( p ) );
1063 
1064  m_gal->DrawPolygon( pts_xformed );
1065  }
1066 }
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 1314 of file sch_painter.cpp.

1315 {
1316  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1317  LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
1318 
1319  // Copy the source so we can re-orient and translate it.
1320  LIB_PART tempPart( *originalPart );
1321 
1322  tempPart.SetFlags( aComp->GetFlags() );
1323 
1324  orientPart( &tempPart, aComp->GetOrientation() );
1325 
1326  for( auto& tempItem : tempPart.GetDrawItems() )
1327  {
1328  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1329  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition() ) );
1330  }
1331 
1332  // Copy the pin info from the component to the temp pins
1333  LIB_PINS tempPins;
1334  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1335  const SCH_PINS& compPins = aComp->GetPins();
1336 
1337  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1338  {
1339  LIB_PIN* tempPin = tempPins[ i ];
1340  const SCH_PIN& compPin = compPins[ i ];
1341 
1342  tempPin->ClearFlags();
1343  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1344 
1345  if( compPin.IsDangling() )
1346  tempPin->SetFlags( IS_DANGLING );
1347  }
1348 
1349  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1350 
1351  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1352  std::vector<SCH_FIELD*> fields;
1353  aComp->GetFields( fields, false );
1354 
1355  for( SCH_FIELD* field : fields )
1356  draw( field, aLayer );
1357 }
Class 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:51
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
bool IsDangling() const override
Definition: sch_pin.h:86
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int GetUnit() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
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
size_t i
Definition: json11.cpp:649
wxPoint GetPosition() const override
Function GetPosition.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:267

References EDA_ITEM::ClearFlags(), draw(), KIGFX::dummy(), SCH_COMPONENT::GetConvert(), LIB_PART::GetDrawItems(), SCH_COMPONENT::GetFields(), EDA_ITEM::GetFlags(), SCH_COMPONENT::GetOrientation(), SCH_COMPONENT::GetPartRef(), LIB_PART::GetPins(), SCH_COMPONENT::GetPins(), SCH_COMPONENT::GetPosition(), SCH_COMPONENT::GetUnit(), i, 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 1083 of file sch_painter.cpp.

1084 {
1085  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1086 
1087  if( drawingShadows && !aJct->IsSelected() )
1088  return;
1089 
1090  COLOR4D color;
1091  auto conn = aJct->Connection( *g_CurrentSheet );
1092 
1093  if( conn && conn->IsBus() )
1094  color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
1095  else
1096  color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
1097 
1098  m_gal->SetIsStroke( drawingShadows );
1099  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1101  m_gal->SetIsFill( !drawingShadows );
1102  m_gal->SetFillColor( color );
1104 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:233
int color
Definition: DXF_plotter.cpp:62
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:100
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:128
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
static int GetEffectiveSymbolSize()
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [12/21]

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

Definition at line 1360 of file sch_painter.cpp.

1361 {
1362  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1363 
1364  if( drawingShadows && !aField->IsSelected() )
1365  return;
1366 
1367  switch( aField->GetId() )
1368  {
1369  case REFERENCE: aLayer = LAYER_REFERENCEPART; break;
1370  case VALUE: aLayer = LAYER_VALUEPART; break;
1371  default: aLayer = LAYER_FIELDS; break;
1372  }
1373 
1374  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1375 
1376  if( !aField->IsVisible() )
1377  {
1378  if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
1379  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1380  else
1381  return;
1382  }
1383 
1384  if( aField->IsVoid() )
1385  return;
1386 
1387  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1388 
1389  if( drawingShadows && parentComponent->IsSelected() && !GetSelectionDrawChildItems() )
1390  return;
1391 
1392  // Calculate the text orientation according to the component orientation.
1393  int orient = (int) aField->GetTextAngle();
1394 
1395  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1396  {
1397  if( orient == TEXT_ANGLE_HORIZ )
1398  orient = TEXT_ANGLE_VERT;
1399  else
1400  orient = TEXT_ANGLE_HORIZ;
1401  }
1402 
1403  /* Calculate the text justification, according to the component orientation/mirror.
1404  * Tthis is a bit complicated due to cumulative calculations:
1405  * - numerous cases (mirrored or not, rotation)
1406  * - the DrawGraphicText function recalculate also H and H justifications according to the
1407  * text orientation.
1408  * - When a component is mirrored, the text is not mirrored and justifications are
1409  * complicated to calculate
1410  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1411  * to know the text coordinate considered as centered
1412  */
1413  EDA_RECT boundaryBox = aField->GetBoundingBox();
1414  wxPoint textpos = boundaryBox.Centre();
1415 
1417  m_gal->SetIsStroke( true );
1418  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
1419 
1420  if( drawingShadows && GetSelectionTextAsBox() )
1421  {
1422  m_gal->SetIsFill( true );
1423  m_gal->SetFillColor( color );
1424  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1425  boundaryBox.RevertYAxis();
1426 
1428  mapCoords( boundaryBox.GetPosition() ), mapCoords( boundaryBox.GetEnd() ) );
1429  }
1430  else
1431  {
1434  m_gal->SetIsFill( false );
1435  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1436  m_gal->SetFontBold( aField->IsBold() );
1437  m_gal->SetFontItalic( aField->IsItalic() );
1438  m_gal->SetTextMirrored( aField->IsMirrored() );
1439 
1440  strokeText( aField->GetFullyQualifiedText(), textpos,
1441  orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
1442  }
1443 
1444  // Draw the umbilical line
1445  if( aField->IsMoving() )
1446  {
1448  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1449  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1450  }
1451 }
#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:233
#define TEXT_ANGLE_VERT
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:230
int color
Definition: DXF_plotter.cpp:62
double GetTextAngle() const
Definition: eda_text.h:158
int GetId() const
Definition: sch_field.h:108
bool IsBrightened() const
Definition: base_struct.h:236
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:586
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:220
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
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.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:75
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
wxPoint GetPosition() const override
Function GetPosition.
wxPoint Centre() const
Definition: eda_rect.h: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
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References EDA_RECT::Centre(), color, KIGFX::GAL::DrawLine(), 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 1179 of file sch_painter.cpp.

1180 {
1181  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1182 
1183  if( drawingShadows && !aText->IsSelected() )
1184  return;
1185 
1186  switch( aText->Type() )
1187  {
1188  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1189  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1190  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1191  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1192  default: aLayer = LAYER_NOTES; break;
1193  }
1194 
1195  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1196  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
1197 
1198  if( conn && conn->IsBus() )
1199  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1200 
1201  if( !aText->IsVisible() )
1202  {
1203  if( m_schSettings.m_ShowHiddenText || aText->IsBrightened() )
1204  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1205  else
1206  return;
1207  }
1208 
1209  m_gal->SetIsFill( false );
1210  m_gal->SetIsStroke( true );
1211  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
1213  m_gal->SetTextAttributes( aText );
1214 
1215  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1216  wxString shownText( aText->GetShownText() );
1217 
1218  if( drawingShadows )
1219  {
1220  if( GetSelectionTextAsBox() )
1221  {
1222  EDA_RECT bBox = aText->GetBoundingBox();
1223 
1224  m_gal->SetIsFill( true );
1225  m_gal->SetFillColor( color );
1226  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1227  bBox.RevertYAxis();
1228 
1229  m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1230  return;
1231  }
1232 
1233  switch( aText->GetLabelSpinStyle() )
1234  {
1235  case 0:
1236  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1237  text_offset.x -= getShadowWidth() / 2;
1238  else
1239  text_offset.x += getShadowWidth() / 2;
1240  break;
1241  case 1:
1242  text_offset.y += getShadowWidth() / 2;
1243  break;
1244  case 2:
1245  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1246  text_offset.x += getShadowWidth() / 2;
1247  else
1248  text_offset.x -= getShadowWidth() / 2;
1249  break;
1250  case 3:
1251  text_offset.y -= getShadowWidth() / 2;
1252  break;
1253  }
1254  }
1255 
1256  if( !shownText.IsEmpty() )
1257  strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1258 
1259  if( aText->IsDangling() )
1260  drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
1261 }
bool IsDangling() const override
Definition: sch_text.h:185
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:233
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
bool IsVisible() const
Definition: eda_text.h:170
int color
Definition: DXF_plotter.cpp:62
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:149
bool IsBrightened() const
Definition: base_struct.h:236
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.
int GetLabelSpinStyle() const
Definition: sch_text.h:124
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)
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:422
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.
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).
Class 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
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129
bool IsBus() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, SCH_ITEM::Connection(), drawDanglingSymbol(), 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, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::mapCoords(), EDA_RECT::RevertYAxis(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, SCH_TEXT_T, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), strokeText(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [14/21]

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

Definition at line 1482 of file sch_painter.cpp.

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

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

◆ draw() [15/21]

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

Definition at line 1454 of file sch_painter.cpp.

1455 {
1456  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1457 
1458  if( drawingShadows && !aLabel->IsSelected() )
1459  return;
1460 
1461  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1462 
1463  std::vector<wxPoint> pts;
1464  std::deque<VECTOR2D> pts2;
1465 
1466  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1467 
1468  for( auto p : pts )
1469  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1470 
1471  m_gal->SetIsFill( true );
1473  m_gal->SetIsStroke( true );
1474  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1476  m_gal->DrawPolyline( pts2 );
1477 
1478  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1479 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
bool IsSelected() const
Definition: base_struct.h:233
int color
Definition: DXF_plotter.cpp:62
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
Definition: painter.h:221
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:844
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
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [16/21]

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

Definition at line 1514 of file sch_painter.cpp.

1515 {
1516  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1517 
1518  if( aLayer == LAYER_HIERLABEL || drawingShadows )
1519  {
1520  for( auto& sheetPin : aSheet->GetPins() )
1521  {
1522  if( drawingShadows && !aSheet->IsSelected() && !sheetPin.IsSelected() )
1523  continue;
1524 
1525  if( drawingShadows && !GetSelectionDrawChildItems() && aSheet->IsSelected() )
1526  break;
1527 
1528  int width = aSheet->GetPenSize();
1529  wxPoint initial_pos = sheetPin.GetTextPos();
1530  wxPoint offset_pos = initial_pos;
1531 
1532  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1533  switch( sheetPin.GetEdge() )
1534  {
1535  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1536  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1537  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1538  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1539  default: break;
1540  }
1541 
1542  sheetPin.SetTextPos( offset_pos );
1543  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1544  m_gal->DrawLine( offset_pos, initial_pos );
1545  sheetPin.SetTextPos( initial_pos );
1546  }
1547  }
1548 
1549  if( drawingShadows && !aSheet->IsSelected() )
1550  return;
1551 
1552  VECTOR2D pos = aSheet->GetPosition();
1553  VECTOR2D size = aSheet->GetSize();
1554 
1555  if( aLayer == LAYER_SHEET_BACKGROUND )
1556  {
1557  m_gal->SetIsStroke( aSheet->IsSelected() );
1560 
1561  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1562  {
1563  // Select a fill color working well with black and white background color,
1564  // both in Opengl and Cairo
1565  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1566  m_gal->SetIsFill( true );
1567  }
1568  else
1569  {
1570  // Could be modified later, when sheets can have their own fill color
1572  m_gal->SetIsFill( aSheet->IsSelected() && GetSelectionFillShapes() );
1573  }
1574 
1575  m_gal->DrawRectangle( pos, pos + size );
1576  }
1577 
1578  if( aLayer == LAYER_SHEET || drawingShadows )
1579  {
1580  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1581  m_gal->SetIsStroke( true );
1582  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1583  m_gal->SetIsFill( false );
1584 
1585  m_gal->DrawRectangle( pos, pos + size );
1586 
1587  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1588  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1589  double nameAngle = 0.0;
1590 
1591  if( aSheet->IsVerticalOrientation() )
1592  nameAngle = M_PI/2;
1593 
1594  if( drawingShadows )
1595  {
1597  return;
1598 
1599  if( aSheet->IsVerticalOrientation() )
1600  {
1601  pos_sheetname.y += getShadowWidth() / 2;
1602  pos_filename.y += getShadowWidth() / 2;
1603  }
1604  else
1605  {
1606  pos_sheetname.x -= getShadowWidth() / 2;
1607  pos_filename.x -= getShadowWidth() / 2;
1608  }
1609  }
1610 
1611  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
1612 
1613  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1614 
1617 
1618  auto txtSize = aSheet->GetSheetNameSize();
1619 
1620  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1621  m_gal->SetFontBold( false );
1622  m_gal->SetFontItalic( false );
1623 
1624  strokeText( text, pos_sheetname, nameAngle );
1625 
1626  txtSize = aSheet->GetFileNameSize();
1627  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1628  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) );
1630 
1631  text = wxT( "File: " ) + aSheet->GetFileName();
1632  strokeText( text, pos_filename, nameAngle );
1633  }
1634 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
SCH_SHEET_PINS & GetPins()
Definition: sch_sheet.h:335
bool IsSelected() const
Definition: base_struct.h:233
bool IsMoving() const
Definition: base_struct.h:230
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_sheet.cpp:393
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:278
void SetFontBold(const bool aBold)
Set bold property of current font.
int GetSheetNameSize() const
Definition: sch_sheet.h:275
wxString GetName() const
Definition: sch_sheet.h:272
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
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.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:543
wxPoint GetFileNamePosition()
Definition: sch_sheet.cpp:418
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:661
bool GetSelectionFillShapes()
Draw selected shapes as filled or not.
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:399
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void draw(LIB_RECTANGLE *aRect, int aLayer)
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
wxSize GetSize()
Definition: sch_sheet.h:283
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References draw(), KIGFX::GAL::DrawLine(), KIGFX::GAL::DrawRectangle(), SCH_SHEET::GetFileName(), SCH_SHEET::GetFileNamePosition(), SCH_SHEET::GetFileNameSize(), getLineWidth(), SCH_SHEET::GetName(), SCH_SHEET::GetPenSize(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), getRenderColor(), 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(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [17/21]

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

Definition at line 1637 of file sch_painter.cpp.

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

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

◆ draw() [18/21]

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

Definition at line 1735 of file sch_painter.cpp.

1736 {
1737  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1738 
1739  if( drawingShadows && !aMarker->IsSelected() )
1740  return;
1741 
1743  aLayer = LAYER_ERC_ERR;
1744  else
1745  aLayer = LAYER_ERC_WARN;
1746 
1747  COLOR4D color = getRenderColor( aMarker, aLayer, drawingShadows );
1748 
1749  m_gal->Save();
1750  m_gal->Translate( aMarker->GetPosition() );
1751  m_gal->SetIsFill( !drawingShadows );
1752  m_gal->SetFillColor( color );
1753  m_gal->SetIsStroke( drawingShadows );
1754  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1756 
1757  SHAPE_LINE_CHAIN polygon;
1758  aMarker->ShapeToPolygon( polygon );
1759 
1760  m_gal->DrawPolygon( polygon );
1761  m_gal->Restore();
1762 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
bool IsSelected() const
Definition: base_struct.h:233
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:175
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_marker.h:98
int color
Definition: DXF_plotter.cpp:62
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Class SHAPE_LINE_CHAIN.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [19/21]

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

Definition at line 1690 of file sch_painter.cpp.

1691 {
1692  m_gal->Save();
1693  m_gal->Translate( aBitmap->GetPosition() );
1694 
1695  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1696  // factor is similar to a local zoom
1697  double img_scale = aBitmap->GetImageScale();
1698 
1699  if( img_scale != 1.0 )
1700  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1701 
1702  if( aLayer == LAYER_DRAW_BITMAPS )
1703  {
1704  m_gal->DrawBitmap( *aBitmap->GetImage() );
1705  }
1706 
1707  if( aLayer == LAYER_SELECTION_SHADOWS )
1708  {
1709  if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
1710  {
1711  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1712  m_gal->SetIsStroke( true );
1715  m_gal->SetIsFill( false );
1716 
1717  // Draws a bounding box.
1718  VECTOR2D bm_size( aBitmap->GetSize() );
1719  // bm_size is the actual image size in UI.
1720  // but m_gal scale was previously set to img_scale
1721  // so recalculate size relative to this image size.
1722  bm_size.x /= img_scale;
1723  bm_size.y /= img_scale;
1724  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1725  VECTOR2D end = origin + bm_size;
1726 
1727  m_gal->DrawRectangle( origin, end );
1728  }
1729  }
1730 
1731  m_gal->Restore();
1732 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
bool IsSelected() const
Definition: base_struct.h:233
to handle and draw images bitmaps
int color
Definition: DXF_plotter.cpp:62
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
bool IsBrightened() const
Definition: base_struct.h:236
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:140
bool IsHighlighted() const
Definition: base_struct.h:235
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxSize GetSize() const
Definition: sch_bitmap.cpp:123
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
static ptrdiff_t bm_size(const potrace_bitmap_t *bm)
Definition: bitmap.h:76
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void Restore()
Restore the context.
double GetImageScale() const
Definition: sch_bitmap.h:71
virtual void Save()
Save the context.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [20/21]

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

Definition at line 1107 of file sch_painter.cpp.

1108 {
1109  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1110 
1111  if( drawingShadows && !aLine->IsSelected() )
1112  return;
1113 
1114  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1115  float width = getLineWidth( aLine, drawingShadows );
1116 
1117  m_gal->SetIsStroke( true );
1119  m_gal->SetLineWidth( width );
1120 
1121  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID || drawingShadows )
1122  {
1123  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1124  }
1125  else
1126  {
1127  VECTOR2D start = aLine->GetStartPoint();
1128  VECTOR2D end = aLine->GetEndPoint();
1129 
1130  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1131  clip.Normalize();
1132 
1133  double theta = atan2( end.y - start.y, end.x - start.x );
1134  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1135 
1136  switch( aLine->GetLineStyle() )
1137  {
1138  default:
1139  case PLOTDASHTYPE_DASH:
1140  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1141  break;
1142  case PLOTDASHTYPE_DOT:
1143  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1144  break;
1145  case PLOTDASHTYPE_DASHDOT:
1146  strokes[0] = DASH_MARK_LEN( width );
1147  strokes[2] = DOT_MARK_LEN( width );
1148  break;
1149  }
1150 
1151  for( size_t i = 0; i < 10000; ++i )
1152  {
1153  // Calculations MUST be done in doubles to keep from accumulating rounding
1154  // errors as we go.
1155  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1156  start.y + strokes[ i % 4 ] * sin( theta ) );
1157 
1158  // Drawing each segment can be done rounded to ints.
1159  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1160  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1161 
1162  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1163  break;
1164  else if( i % 2 == 0 )
1165  m_gal->DrawLine( segStart, segEnd );
1166 
1167  start = next;
1168  }
1169  }
1170 
1171  if( aLine->IsStartDangling() )
1172  drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
1173 
1174  if( aLine->IsEndDangling() )
1175  drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
1176 }
CITER next(CITER it)
Definition: ptree.cpp:130
wxPoint GetStartPoint() const
Definition: sch_line.h:99
bool IsSelected() const
Definition: base_struct.h:233
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
int color
Definition: DXF_plotter.cpp:62
#define DASH_MARK_LEN(aLineWidth)
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsEndDangling() const
Definition: sch_line.h:185
#define DOT_MARK_LEN(aLineWidth)
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:193
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool IsStartDangling() const
Definition: sch_line.h:184
size_t i
Definition: json11.cpp:649
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
#define DASH_GAP_LEN(aLineWidth)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetLineStyle() const
Definition: sch_line.cpp:289
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetEndPoint() const
Definition: sch_line.h:102

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

◆ draw() [21/21]

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

Definition at line 1657 of file sch_painter.cpp.

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

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

◆ drawDanglingSymbol()

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

Definition at line 1071 of file sch_painter.cpp.

1072 {
1073  wxPoint radius( DANGLING_SYMBOL_SIZE, DANGLING_SYMBOL_SIZE );
1074 
1075  m_gal->SetIsStroke( true );
1076  m_gal->SetIsFill( false );
1077  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
1078 
1079  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1080 }
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 635 of file sch_painter.cpp.

636 {
637  m_gal->SetIsFill( false );
638  m_gal->SetIsStroke( true );
639  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
640 
642 }
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 409 of file sch_painter.cpp.

410 {
412  m_gal->SetIsFill( true );
413 }
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 272 of file sch_painter.cpp.

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

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

Referenced by draw(), and setDeviceColors().

◆ getLineWidth() [2/2]

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

Definition at line 283 of file sch_painter.cpp.

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

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

◆ getRenderColor()

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

Definition at line 239 of file sch_painter.cpp.

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

References color, KIGFX::RENDER_SETTINGS::GetLayerColor(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsHighlighted(), EDA_ITEM::IsSelected(), LAYER_BRIGHTENED, LAYER_DEVICE_BACKGROUND, LAYER_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 229 of file sch_painter.cpp.

230 {
231  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
232 
233  // For best visuals the selection width must be a cross between the zoom level and the
234  // default line width.
235  return static_cast<float>( fabs( matrix.GetScale().x * 2.75 ) + GetSelectionThickness() );
236 }
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 294 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ isUnitAndConversionShown()

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

Definition at line 209 of file sch_painter.cpp.

210 {
211  if( m_schSettings.m_ShowUnit // showing a specific unit
212  && aItem->GetUnit() // item is unit-specific
213  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
214  {
215  return false;
216  }
217 
218  if( m_schSettings.m_ShowConvert // showing a specific conversion
219  && aItem->GetConvert() // item is conversion-specific
220  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
221  {
222  return false;
223  }
224 
225  return true;
226 }
int GetUnit() const
Definition: lib_item.h:301
int GetConvert() const
Definition: lib_item.h:304
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h: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 360 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ SetGAL()

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

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

Parameters
aGalis the new GAL instance.

Definition at line 333 of file painter.h.

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

References KIGFX::PAINTER::m_gal.

◆ strokeText()

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

Definition at line 308 of file sch_painter.cpp.

309 {
310  m_gal->StrokeText( aText, aPosition, aAngle, GetTextMarkupFlags() );
311 }
int GetTextMarkupFlags()
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 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 353 of file sch_painter.cpp.

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