KiCad PCB EDA Suite
KIGFX::SCH_PAINTER Class Reference

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

#include <sch_painter.h>

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

Public Member Functions

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

Protected Attributes

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

Private Member Functions

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

Private Attributes

SCH_RENDER_SETTINGS m_schSettings
 

Detailed Description

Class SCH_PAINTER Contains methods for drawing schematic-specific items.

Definition at line 116 of file sch_painter.h.

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 136 of file sch_painter.cpp.

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

Member Function Documentation

◆ ApplySettings()

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

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

Parameters
aSettingsare settings to be applied.

Implements KIGFX::PAINTER.

Definition at line 125 of file sch_painter.h.

126  {
127  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
128  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175

References m_schSettings.

◆ Draw()

bool KIGFX::SCH_PAINTER::Draw ( const VIEW_ITEM aItem,
int  aLayer 
)
overridevirtual

Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the item.

Parameters
aItemis an item to be drawn.
aLayertells which layer is currently rendered so that draw functions may know what to draw (eg. for pads there are separate layers for holes, because they have other dimensions then the pad itself.

Implements KIGFX::PAINTER.

Definition at line 145 of file sch_painter.cpp.

146 {
147  auto item2 = static_cast<const EDA_ITEM*>( aItem );
148  auto item = const_cast<EDA_ITEM*>( item2 );
149 
151 
152 #ifdef CONNECTIVITY_DEBUG
153 
154  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
155  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
156 
157  if( conn )
158  {
159  auto pos = item->GetBoundingBox().Centre();
160  auto label = conn->Name( true );
161 
165  m_gal->SetLineWidth( 2 );
166  m_gal->SetGlyphSize( VECTOR2D( 20, 20 ) );
167  m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
168  }
169 
170 #endif
171 
172  switch( item->Type() )
173  {
199 
200  default: return false;
201  }
202 
203  return false;
204 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
Part library alias object definition.
Define a symbol library graphical text item.
Definition: lib_text.h:40
Field object used in symbol libraries.
Definition: lib_field.h:59
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
Define a library symbol object.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h: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:79
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:35
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

Referenced by draw().

◆ draw() [1/22]

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

Definition at line 408 of file sch_painter.cpp.

409 {
410  if( !isUnitAndConversionShown( aRect ) )
411  return;
412 
413  if( setDeviceColors( aRect, aLayer ) )
414  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
415 
416 }
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
wxPoint GetEnd() const
Definition: lib_rectangle.h:89
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
static VECTOR2D mapCoords(const wxPoint &aCoord)
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
wxPoint GetPosition() const override
Definition: lib_rectangle.h:76

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

Referenced by draw().

◆ draw() [2/22]

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

Definition at line 614 of file sch_painter.cpp.

615 {
616  if( !isUnitAndConversionShown( aPin ) )
617  return;
618 
619  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
620 
621  if( drawingShadows && !aPin->IsSelected() )
622  return;
623 
624  VECTOR2I pos = mapCoords( aPin->GetPosition() );
625  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
626 
627  if( !aPin->IsVisible() )
628  {
630  {
631  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
632  }
633  else
634  {
635  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
636  drawPinDanglingSymbol( pos, drawingShadows );
637 
638  return;
639  }
640  }
641 
642  VECTOR2I p0;
643  VECTOR2I dir;
644  int len = aPin->GetLength();
645  int shape = aPin->GetShape();
646  int orient = aPin->GetOrientation();
647 
648  switch( orient )
649  {
650  case PIN_UP:
651  p0 = VECTOR2I( pos.x, pos.y - len );
652  dir = VECTOR2I(0, 1);
653  break;
654  case PIN_DOWN:
655  p0 = VECTOR2I( pos.x, pos.y + len );
656  dir = VECTOR2I(0, -1);
657  break;
658  case PIN_LEFT:
659  p0 = VECTOR2I( pos.x - len, pos.y );
660  dir = VECTOR2I(1, 0);
661  break;
662  default:
663  case PIN_RIGHT:
664  p0 = VECTOR2I( pos.x + len, pos.y );
665  dir = VECTOR2I(-1, 0);
666  break;
667  }
668 
669  VECTOR2D pc;
670 
671  m_gal->SetIsStroke( true );
672  m_gal->SetIsFill( false );
673  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
675  m_gal->SetFontBold( false );
676  m_gal->SetFontItalic( false );
677 
678  const int radius = ExternalPinDecoSize( *aPin );
679  const int diam = radius*2;
680  const int clock_size = InternalPinDecoSize( *aPin );
681 
682  if( shape == PINSHAPE_INVERTED )
683  {
684  m_gal->DrawCircle( p0 + dir * radius, radius );
685  m_gal->DrawLine( p0 + dir * ( diam ), pos );
686  }
687  else if( shape == PINSHAPE_FALLING_EDGE_CLOCK )
688  {
689  pc = p0 + dir * clock_size ;
690 
691  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
692  pc,
693  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
694 
695  m_gal->DrawLine( pos, pc );
696  }
697  else
698  {
699  m_gal->DrawLine( p0, pos );
700  }
701 
702  if( shape == PINSHAPE_CLOCK )
703  {
704  if (!dir.y)
705  {
706  triLine( p0 + VECTOR2D( 0, clock_size ),
707  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
708  p0 + VECTOR2D( 0, -clock_size ) );
709  }
710  else
711  {
712  triLine( p0 + VECTOR2D( clock_size, 0 ),
713  p0 + VECTOR2D( 0, -dir.y * clock_size ),
714  p0 + VECTOR2D( -clock_size, 0 ) );
715  }
716  }
717 
718  if( shape == PINSHAPE_INPUT_LOW )
719  {
720  if(!dir.y)
721  {
722  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
723  p0 + VECTOR2D(dir.x, -1) * diam,
724  p0 );
725  }
726  else /* MapX1 = 0 */
727  {
728  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
729  p0 + VECTOR2D(-1, dir.y) * diam,
730  p0 );
731  }
732  }
733 
734  if( shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
735  {
736  if( !dir.y ) // Horizontal pin
737  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
738  else // Vertical pin
739  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
740  }
741 
742  if( shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
743  {
744  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
745  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
746  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
747  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
748  }
749 
750  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
751  {
752  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
753  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
754  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
755  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
756 
757  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
758  }
759 
760  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
761  drawPinDanglingSymbol( pos, drawingShadows );
762 
763  // Draw the labels
764 
765  LIB_PART* libEntry = aPin->GetParent();
766  int textOffset = libEntry->GetPinNameOffset();
767 
768  float nameLineWidth = getLineWidth( aPin, drawingShadows );
769  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
770  float numLineWidth = getLineWidth( aPin, drawingShadows );
771  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
772 
773  #define PIN_TEXT_MARGIN 4.0
774 
775  // Four locations around a pin where text can be drawn
776  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
777  int size[4] = { 0, 0, 0, 0 };
778  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
779  COLOR4D colour[4];
780  wxString text[4];
781 
782  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
783  if( textOffset )
784  {
785  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
786  thickness[INSIDE] = nameLineWidth;
787  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
788  text [INSIDE] = aPin->GetName();
789 
790  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
791  thickness[ABOVE] = numLineWidth;
792  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
793  text [ABOVE] = aPin->GetNumber();
794  }
795  // Otherwise pin NAMES go above and pin NUMBERS go below
796  else
797  {
798  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
799  thickness[ABOVE] = nameLineWidth;
800  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
801  text [ABOVE] = aPin->GetName();
802 
803  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
804  thickness[BELOW] = numLineWidth;
805  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
806  text [BELOW] = aPin->GetNumber();
807  }
808 
810  {
811  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
812  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
813  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
814  text [OUTSIDE] = aPin->GetElectricalTypeName();
815  }
816 
817  if( !aPin->IsVisible() )
818  {
819  for( COLOR4D& c : colour )
820  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
821  }
822 
823  int insideOffset = textOffset;
824  int outsideOffset = 10;
825  float lineThickness = (float) GetDefaultLineThickness();
826  float aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + lineThickness ) / 2.0;
827  float belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + lineThickness ) / 2.0;
828 
829  if( drawingShadows )
830  {
831  for( float& t : thickness )
832  t += getShadowWidth();
833 
834  insideOffset -= KiROUND( getShadowWidth() / 2 );
835  outsideOffset -= KiROUND( getShadowWidth() / 2 );
836  }
837 
838  #define SET_DC( i ) \
839  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
840  m_gal->SetLineWidth( thickness[i] ); \
841  m_gal->SetStrokeColor( colour[i] )
842 
843  switch( orient )
844  {
845  case PIN_LEFT:
846  if( size[INSIDE] )
847  {
848  SET_DC( INSIDE );
851  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
852  }
853  if( size[OUTSIDE] )
854  {
855  SET_DC( OUTSIDE );
858  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
859  }
860  if( size[ABOVE] )
861  {
862  SET_DC( ABOVE );
865  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
866  }
867  if( size[BELOW] )
868  {
869  SET_DC( BELOW );
872  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
873  }
874  break;
875 
876  case PIN_RIGHT:
877  if( size[INSIDE] )
878  {
879  SET_DC( INSIDE );
883  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
884  }
885  if( size[OUTSIDE] )
886  {
887  SET_DC( OUTSIDE );
890  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
891  }
892  if( size[ABOVE] )
893  {
894  SET_DC( ABOVE );
897  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
898  }
899  if( size[BELOW] )
900  {
901  SET_DC( BELOW );
904  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
905  }
906  break;
907 
908  case PIN_DOWN:
909  if( size[INSIDE] )
910  {
911  SET_DC( INSIDE );
914  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2);
915  }
916  if( size[OUTSIDE] )
917  {
918  SET_DC( OUTSIDE );
921  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2);
922  }
923  if( size[ABOVE] )
924  {
925  SET_DC( ABOVE );
928  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
929  }
930  if( size[BELOW] )
931  {
932  SET_DC( BELOW );
935  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
936  }
937  break;
938 
939  case PIN_UP:
940  if( size[INSIDE] )
941  {
942  SET_DC( INSIDE );
945  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2);
946  }
947  if( size[OUTSIDE] )
948  {
949  SET_DC( OUTSIDE );
952  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2);
953  }
954  if( size[ABOVE] )
955  {
956  SET_DC( ABOVE );
959  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
960  }
961  if( size[BELOW] )
962  {
963  SET_DC( BELOW );
966  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
967  }
968  break;
969 
970  default:
971  wxFAIL_MSG( "Unknown pin orientation" );
972  }
973 }
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
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
Define a library symbol object.
#define OUTSIDE
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:343
int GetNameTextSize() const
Definition: lib_pin.h:175
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Definition: lib_pin.h:427
const wxString & GetNumber() const
Definition: lib_pin.h:177
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:232
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetNumberTextSize() const
Definition: lib_pin.h:202
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:149
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
#define max(a, b)
Definition: auxiliary.h:86
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
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:175
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(), 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, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenPins, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, KIGFX::mapCoords(), max, OUTSIDE, PIN_DOWN, PIN_LEFT, PIN_NC, PIN_RIGHT, PIN_TEXT_MARGIN, PIN_UP, PINSHAPE_CLOCK, PINSHAPE_FALLING_EDGE_CLOCK, PINSHAPE_INPUT_LOW, PINSHAPE_INVERTED, PINSHAPE_NONLOGIC, PINSHAPE_OUTPUT_LOW, SET_DC, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), LIB_PART::ShowPinNames(), LIB_PART::ShowPinNumbers(), KIGFX::GAL::StrokeText(), TARGET_PIN_RADIUS, triLine(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [3/22]

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

Definition at line 419 of file sch_painter.cpp.

420 {
421  if( !isUnitAndConversionShown( aCircle ) )
422  return;
423 
424  if( setDeviceColors( aCircle, aLayer ) )
425  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
426 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
wxPoint GetPosition() const override
Definition: lib_circle.h:75
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
int GetRadius() const
Definition: lib_circle.h:91
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

◆ draw() [4/22]

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

Definition at line 303 of file sch_painter.cpp.

304 {
305  if( !aUnit )
306  aUnit = m_schSettings.m_ShowUnit;
307 
308  if( !aConvert )
309  aConvert = m_schSettings.m_ShowConvert;
310 
311  for( auto& item : aPart->GetDrawItems() )
312  {
313  if( !aDrawFields && item.Type() == LIB_FIELD_T )
314  continue;
315 
316  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
317  continue;
318 
319  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
320  continue;
321 
322  Draw( &item, aLayer );
323  }
324 }
virtual bool Draw(const VIEW_ITEM *, int) override
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175

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

◆ draw() [5/22]

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

Definition at line 327 of file sch_painter.cpp.

328 {
329  LIB_PART* comp = aAlias->GetPart();
330 
331  draw( comp, aLayer, false );
332 
333  LIB_FIELDS fields;
334  comp->GetFields( fields );
335 
336  if( !aAlias->IsRoot() )
337  {
338  fields[ VALUE ].SetText( aAlias->GetName() );
339  fields[ DATASHEET ].SetText( aAlias->GetDocFileName() );
340  }
341 
342  for( LIB_FIELD& field : fields )
343  draw( &field, aLayer );
344 }
name of datasheet
Field object used in symbol libraries.
Definition: lib_field.h:59
const wxString & GetDocFileName() const
bool IsRoot() const override
For symbols having aliases, IsRoot() indicates the principal item.
#define VALUE
Define a library symbol object.
LIB_PART * GetPart() const
Get the shared LIB_PART.
const wxString & GetName() const override
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:214
void draw(LIB_RECTANGLE *aRect, int aLayer)
void GetFields(LIB_FIELDS &aList)
Return a list of fields within this part.

References DATASHEET, draw(), LIB_ALIAS::GetDocFileName(), LIB_PART::GetFields(), LIB_ALIAS::GetName(), LIB_ALIAS::GetPart(), LIB_ALIAS::IsRoot(), and VALUE.

◆ draw() [6/22]

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

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

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

Definition at line 429 of file sch_painter.cpp.

430 {
431  if( !isUnitAndConversionShown( aArc ) )
432  return;
433 
434  if( setDeviceColors( aArc, aLayer ) )
435  {
436  int sai = aArc->GetFirstRadiusAngle();
437  int eai = aArc->GetSecondRadiusAngle();
438 
449  if( !TRANSFORM().MapAngles( &sai, &eai ) )
450  {
451  LIB_ARC new_arc( *aArc );
452 
453  new_arc.SetStart( aArc->GetEnd() );
454  new_arc.SetEnd( aArc->GetStart() );
455  new_arc.CalcRadiusAngles();
456  sai = new_arc.GetFirstRadiusAngle();
457  eai = new_arc.GetSecondRadiusAngle();
458  TRANSFORM().MapAngles( &sai, &eai );
459  }
460 
461  double sa = (double) sai * M_PI / 1800.0;
462  double ea = (double) eai * M_PI / 1800.0 ;
463 
464  VECTOR2D pos = mapCoords( aArc->GetPosition() );
465 
466  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
467  }
468 }
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() [7/22]

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

Definition at line 471 of file sch_painter.cpp.

472 {
473  if( !isUnitAndConversionShown( aLine ) )
474  return;
475 
476  if( setDeviceColors( aLine, aLayer ) )
477  {
478  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
479  std::deque<VECTOR2D> vtx;
480 
481  for( auto p : pts )
482  vtx.push_back( mapCoords( p ) );
483 
484  m_gal->DrawPolygon( vtx );
485  }
486 }
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:60
static VECTOR2D mapCoords(const wxPoint &aCoord)
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

References KIGFX::GAL::DrawPolygon(), LIB_POLYLINE::GetPolyPoints(), isUnitAndConversionShown(), KIGFX::PAINTER::m_gal, KIGFX::mapCoords(), and setDeviceColors().

◆ draw() [8/22]

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

Definition at line 489 of file sch_painter.cpp.

490 {
491  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
492 
493  if( drawingShadows && !aField->IsSelected() )
494  return;
495 
496  if( !isUnitAndConversionShown( aField ) )
497  return;
498 
499  // Must check layer as fields are sometimes drawn by their parent rather than
500  // directly from the view.
501  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
502  int layers_count;
503  bool foundLayer = false;
504 
505  aField->ViewGetLayers( layers, layers_count );
506 
507  for( int i = 0; i < layers_count; ++i )
508  {
509  if( layers[i] == aLayer )
510  foundLayer = true;
511  }
512 
513  if( !foundLayer )
514  return;
515 
516  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
517 
518  if( !aField->IsVisible() )
519  {
521  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
522  else
523  return;
524  }
525 
526  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
527  m_gal->SetIsFill( false );
528  m_gal->SetIsStroke( true );
530  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
531  m_gal->SetFontItalic( aField->IsItalic() );
532 
534  m_gal->SetVerticalJustify( aField->GetVertJustify( ) );
535 
536  auto pos = mapCoords( aField->GetPosition() );
537  double orient = aField->GetTextAngleRadians();
538 
539  m_gal->StrokeText( aField->GetText(), pos, orient );
540 
541  // Draw the umbilical line
542  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
543  {
545  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
546  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
547  }
548 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:233
wxPoint GetPosition() const override
Definition: lib_field.h:179
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:230
int color
Definition: DXF_plotter.cpp:62
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:701
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: lib_field.cpp: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.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:223
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:597
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, KIGFX::GAL::DrawLine(), EDA_TEXT::GetHorizJustify(), getLineWidth(), LIB_FIELD::GetPosition(), getRenderColor(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), i, EDA_TEXT::IsItalic(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), isUnitAndConversionShown(), EDA_TEXT::IsVisible(), LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, KIGFX::SCH_RENDER_SETTINGS::m_ShowUmbilicals, KIGFX::mapCoords(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), KIGFX::GAL::StrokeText(), KIGFX::VIEW::VIEW_MAX_LAYERS, and LIB_FIELD::ViewGetLayers().

◆ draw() [9/22]

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

Definition at line 551 of file sch_painter.cpp.

552 {
553  if( !isUnitAndConversionShown( aText ) )
554  return;
555 
556  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
557 
558  if( drawingShadows && !aText->IsSelected() )
559  return;
560 
561  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
562 
563  if( !aText->IsVisible() )
564  {
566  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
567  else
568  return;
569  }
570 
571  EDA_RECT bBox = aText->GetBoundingBox();
572  bBox.RevertYAxis();
573  VECTOR2D pos = mapCoords( bBox.Centre() );
574  double orient = aText->GetTextAngleRadians();
575 
578  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
579  m_gal->SetIsFill( false );
580  m_gal->SetIsStroke( true );
582  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
583  m_gal->SetFontBold( aText->IsBold() );
584  m_gal->SetFontItalic( aText->IsItalic() );
585  m_gal->StrokeText( aText->GetText(), pos, orient );
586 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
bool IsSelected() const
Definition: base_struct.h:233
bool IsVisible() const
Definition: eda_text.h:170
int color
Definition: DXF_plotter.cpp:62
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h: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.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:223
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:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [10/22]

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

Definition at line 976 of file sch_painter.cpp.

977 {
978  if( !isUnitAndConversionShown( aCurve ) )
979  return;
980 
981  if( setDeviceColors( aCurve, aLayer ) )
982  {
983  BEZIER_POLY poly ( aCurve->GetPoints() );
984  std::vector<wxPoint> pts;
985  std::deque<VECTOR2D> pts_xformed;
986  poly.GetPoly( pts );
987 
988  for( const auto &p : pts )
989  pts_xformed.push_back( mapCoords( p ) );
990 
991  m_gal->DrawPolygon( pts_xformed );
992  }
993 }
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:72
static VECTOR2D mapCoords(const wxPoint &aCoord)
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool isUnitAndConversionShown(const LIB_ITEM *aItem)

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

◆ draw() [11/22]

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

Definition at line 1228 of file sch_painter.cpp.

1229 {
1230  PART_SPTR originalPartSptr = aComp->GetPartRef().lock();
1231 
1232  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1233  LIB_PART* originalPart = originalPartSptr ? originalPartSptr.get() : dummy();
1234 
1235  // Copy the source so we can re-orient and translate it.
1236  LIB_PART tempPart( *originalPart );
1237 
1238  tempPart.SetFlags( aComp->GetFlags() );
1239 
1240  orientPart( &tempPart, aComp->GetOrientation());
1241 
1242  for( auto& tempItem : tempPart.GetDrawItems() )
1243  {
1244  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1245  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition()));
1246  }
1247 
1248  // Copy the pin info from the component to the temp pins
1249  LIB_PINS tempPins;
1250  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1251  const SCH_PINS& compPins = aComp->GetPins();
1252 
1253  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1254  {
1255  LIB_PIN* tempPin = tempPins[ i ];
1256  const SCH_PIN& compPin = compPins[ i ];
1257 
1258  tempPin->ClearFlags();
1259  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1260 
1261  if( compPin.IsDangling() )
1262  tempPin->SetFlags( IS_DANGLING );
1263  }
1264 
1265  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1266 
1267  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1268  std::vector<SCH_FIELD*> fields;
1269  aComp->GetFields( fields, false );
1270 
1271  for( SCH_FIELD* field : fields )
1272  draw( field, aLayer );
1273 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
PART_REF & GetPartRef()
int GetOrientation()
Get the display symbol orientation.
std::vector< SCH_PIN > SCH_PINS
A container for several SCH_PIN items.
Definition: sch_component.h:51
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
bool IsDangling() const override
Definition: sch_pin.h: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
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
Define a library symbol object.
static VECTOR2D mapCoords(const wxPoint &aCoord)
static void orientPart(LIB_PART *part, int orientation)
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:149
size_t i
Definition: json11.cpp:597
wxPoint GetPosition() const override
Function GetPosition.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:267

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

◆ draw() [12/22]

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

Definition at line 1010 of file sch_painter.cpp.

1011 {
1012  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1013 
1014  if( drawingShadows && !aJct->IsSelected() )
1015  return;
1016 
1017  COLOR4D color;
1018  auto conn = aJct->Connection( *g_CurrentSheet );
1019 
1020  if( conn && conn->IsBus() )
1021  color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
1022  else
1023  color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
1024 
1025  m_gal->SetIsStroke( drawingShadows );
1026  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1028  m_gal->SetIsFill( !drawingShadows );
1029  m_gal->SetFillColor( color );
1031 }
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() [13/22]

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

Definition at line 1276 of file sch_painter.cpp.

1277 {
1278  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1279 
1280  if( drawingShadows && !aField->IsSelected() )
1281  return;
1282 
1283  switch( aField->GetId() )
1284  {
1285  case REFERENCE: aLayer = LAYER_REFERENCEPART; break;
1286  case VALUE: aLayer = LAYER_VALUEPART; break;
1287  default: aLayer = LAYER_FIELDS; break;
1288  }
1289 
1290  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1291 
1292  if( !aField->IsVisible() )
1293  {
1295  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1296  else
1297  return;
1298  }
1299 
1300  if( aField->IsVoid() )
1301  return;
1302 
1303  // Calculate the text orientation according to the component orientation.
1304  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1305  int orient = (int) aField->GetTextAngle();
1306 
1307  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1308  {
1309  if( orient == TEXT_ANGLE_HORIZ )
1310  orient = TEXT_ANGLE_VERT;
1311  else
1312  orient = TEXT_ANGLE_HORIZ;
1313  }
1314 
1315  /* Calculate the text justification, according to the component orientation/mirror.
1316  * Tthis is a bit complicated due to cumulative calculations:
1317  * - numerous cases (mirrored or not, rotation)
1318  * - the DrawGraphicText function recalculate also H and H justifications according to the
1319  * text orientation.
1320  * - When a component is mirrored, the text is not mirrored and justifications are
1321  * complicated to calculate
1322  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1323  * to know the text coordinate considered as centered
1324  */
1325  EDA_RECT boundaryBox = aField->GetBoundingBox();
1326  wxPoint textpos = boundaryBox.Centre();
1327 
1331  m_gal->SetIsFill( false );
1332  m_gal->SetIsStroke( true );
1333  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1334  m_gal->SetFontBold( aField->IsBold() );
1335  m_gal->SetFontItalic( aField->IsItalic() );
1336  m_gal->SetTextMirrored( aField->IsMirrored() );
1337  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
1338  m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI/2 : 0 );
1339 
1340  // Draw the umbilical line
1341  if( aField->IsMoving() )
1342  {
1344  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1345  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1346  }
1347 }
#define TEXT_ANGLE_HORIZ
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
bool IsMirrored() const
Definition: eda_text.h:173
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:233
#define TEXT_ANGLE_VERT
bool IsVisible() const
Definition: eda_text.h:170
bool IsMoving() const
Definition: base_struct.h:230
int color
Definition: DXF_plotter.cpp:62
double GetTextAngle() const
Definition: eda_text.h:158
int GetId() const
Definition: sch_field.h:108
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
Field Reference of part, i.e. "IC21".
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:257
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:164
int y1
Definition: transform.h:49
void SetFontBold(const bool aBold)
Set bold property of current font.
#define VALUE
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
TRANSFORM & GetTransform() const
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:223
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:194
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:75
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
wxPoint GetPosition() const override
Function GetPosition.
wxPoint Centre() const
Definition: eda_rect.h: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:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References EDA_RECT::Centre(), color, KIGFX::GAL::DrawLine(), SCH_FIELD::GetBoundingBox(), SCH_FIELD::GetFullyQualifiedText(), SCH_FIELD::GetId(), getLineWidth(), EDA_ITEM::GetParent(), SCH_COMPONENT::GetPosition(), getRenderColor(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), SCH_COMPONENT::GetTransform(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), SCH_FIELD::IsVoid(), LAYER_FIELDS, LAYER_HIDDEN, LAYER_REFERENCEPART, LAYER_SELECTION_SHADOWS, LAYER_VALUEPART, KIGFX::PAINTER::m_gal, KIGFX::RENDER_SETTINGS::m_outlineWidth, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, REFERENCE, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextMirrored(), KIGFX::GAL::SetVerticalJustify(), KIGFX::GAL::StrokeText(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, VALUE, and TRANSFORM::y1.

◆ draw() [14/22]

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

Definition at line 1106 of file sch_painter.cpp.

1107 {
1108  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1109 
1110  if( drawingShadows && !aText->IsSelected() )
1111  return;
1112 
1113  switch( aText->Type() )
1114  {
1115  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1116  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1117  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1118  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1119  default: aLayer = LAYER_NOTES; break;
1120  }
1121 
1122  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1123  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
1124 
1125  if( conn && conn->IsBus() )
1126  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1127 
1128  if( !aText->IsVisible() )
1129  {
1131  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1132  else
1133  return;
1134  }
1135 
1136  m_gal->SetIsFill( false );
1137  m_gal->SetIsStroke( true );
1138  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
1140  m_gal->SetTextAttributes( aText );
1141 
1142  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1143  wxString shownText( aText->GetShownText() );
1144 
1145  if( drawingShadows )
1146  {
1147  switch( aText->GetLabelSpinStyle() )
1148  {
1149  case 0:
1150  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1151  text_offset.x -= getShadowWidth() / 2;
1152  else
1153  text_offset.x += getShadowWidth() / 2;
1154  break;
1155  case 1:
1156  text_offset.y += getShadowWidth() / 2;
1157  break;
1158  case 2:
1159  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1160  text_offset.x += getShadowWidth() / 2;
1161  else
1162  text_offset.x -= getShadowWidth() / 2;
1163  break;
1164  case 3:
1165  text_offset.y -= getShadowWidth() / 2;
1166  break;
1167  }
1168  }
1169 
1170  if( !shownText.IsEmpty() )
1171  m_gal->StrokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1172 
1173  if( aText->IsDangling() )
1174  drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
1175 }
bool IsDangling() const override
Definition: sch_text.h:185
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
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
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:128
double GetTextAngleRadians() const
Definition: eda_text.h:161
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
const wxPoint & GetTextPos() const
Definition: eda_text.h: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:175
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References color, SCH_ITEM::Connection(), drawDanglingSymbol(), g_CurrentSheet, SCH_TEXT::GetLabelSpinStyle(), getLineWidth(), getRenderColor(), SCH_TEXT::GetSchematicTextOffset(), getShadowWidth(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngleRadians(), EDA_TEXT::GetTextPos(), SCH_CONNECTION::IsBus(), SCH_TEXT::IsDangling(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), LAYER_BUS, LAYER_GLOBLABEL, LAYER_HIDDEN, LAYER_HIERLABEL, LAYER_LOCLABEL, LAYER_NOTES, LAYER_SELECTION_SHADOWS, LAYER_SHEETLABEL, KIGFX::PAINTER::m_gal, m_schSettings, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, SCH_TEXT_T, KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTextAttributes(), KIGFX::GAL::StrokeText(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [15/22]

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

Definition at line 1378 of file sch_painter.cpp.

1379 {
1380  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1381 
1382  if( drawingShadows && !aLabel->IsSelected() )
1383  return;
1384 
1385  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1386 
1387  SCH_CONNECTION* conn = aLabel->Connection( *g_CurrentSheet );
1388 
1389  if( conn && conn->IsBus() )
1390  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1391 
1392  std::vector<wxPoint> pts;
1393  std::deque<VECTOR2D> pts2;
1394 
1395  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1396 
1397  for( auto p : pts )
1398  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1399 
1400  m_gal->SetIsFill( true );
1402  m_gal->SetIsStroke( true );
1403  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1405  m_gal->DrawPolyline( pts2 );
1406 
1407  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1408 }
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:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [16/22]

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

Definition at line 1350 of file sch_painter.cpp.

1351 {
1352  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1353 
1354  if( drawingShadows && !aLabel->IsSelected() )
1355  return;
1356 
1357  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1358 
1359  std::vector<wxPoint> pts;
1360  std::deque<VECTOR2D> pts2;
1361 
1362  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1363 
1364  for( auto p : pts )
1365  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1366 
1367  m_gal->SetIsFill( true );
1369  m_gal->SetIsStroke( true );
1370  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1372  m_gal->DrawPolyline( pts2 );
1373 
1374  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1375 }
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:175
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

◆ draw() [17/22]

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

Definition at line 1410 of file sch_painter.cpp.

1411 {
1412  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1413 
1414  if( aLayer == LAYER_HIERLABEL || drawingShadows )
1415  {
1416  for( auto& sheetPin : aSheet->GetPins() )
1417  {
1418  if( drawingShadows && !aSheet->IsSelected() && !sheetPin.IsSelected() )
1419  continue;
1420 
1421  int width = aSheet->GetPenSize();
1422  wxPoint initial_pos = sheetPin.GetTextPos();
1423  wxPoint offset_pos = initial_pos;
1424 
1425  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1426  switch( sheetPin.GetEdge() )
1427  {
1428  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1429  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1430  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1431  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1432  default: break;
1433  }
1434 
1435  sheetPin.SetTextPos( offset_pos );
1436  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1437  m_gal->DrawLine( offset_pos, initial_pos );
1438  sheetPin.SetTextPos( initial_pos );
1439  }
1440  }
1441 
1442  if( drawingShadows && !aSheet->IsSelected() )
1443  return;
1444 
1445  VECTOR2D pos = aSheet->GetPosition();
1446  VECTOR2D size = aSheet->GetSize();
1447 
1448  if( aLayer == LAYER_SHEET_BACKGROUND )
1449  {
1450  m_gal->SetIsStroke( aSheet->IsSelected() );
1453 
1454  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1455  {
1456  // Select a fill color working well with black and white background color,
1457  // both in Opengl and Cairo
1458  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1459  m_gal->SetIsFill( true );
1460  }
1461  else
1462  {
1463  // Could be modified later, when sheets can have their own fill color
1464  m_gal->SetIsFill( false );
1465  }
1466 
1467  m_gal->DrawRectangle( pos, pos + size );
1468  }
1469 
1470  if( aLayer == LAYER_SHEET || drawingShadows )
1471  {
1472  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1473  m_gal->SetIsStroke( true );
1474  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1475  m_gal->SetIsFill( false );
1476 
1477  m_gal->DrawRectangle( pos, pos + size );
1478 
1479  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1480  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1481  double nameAngle = 0.0;
1482 
1483  if( aSheet->IsVerticalOrientation() )
1484  nameAngle = M_PI/2;
1485 
1486  if( drawingShadows )
1487  {
1488  if( aSheet->IsVerticalOrientation() )
1489  {
1490  pos_sheetname.y += getShadowWidth() / 2;
1491  pos_filename.y += getShadowWidth() / 2;
1492  }
1493  else
1494  {
1495  pos_sheetname.x -= getShadowWidth() / 2;
1496  pos_filename.x -= getShadowWidth() / 2;
1497  }
1498  }
1499 
1500  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
1501 
1502  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1503 
1506 
1507  auto txtSize = aSheet->GetSheetNameSize();
1508 
1509  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1510  m_gal->SetFontBold( false );
1511  m_gal->SetFontItalic( false );
1512 
1513  m_gal->StrokeText( text, pos_sheetname, nameAngle );
1514 
1515  txtSize = aSheet->GetFileNameSize();
1516  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1517  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) );
1519 
1520  text = wxT( "File: " ) + aSheet->GetFileName();
1521  m_gal->StrokeText( text, pos_filename, nameAngle );
1522  }
1523 }
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.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:543
wxPoint GetFileNamePosition()
Definition: sch_sheet.cpp:418
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:646
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
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(), getShadowWidth(), SCH_SHEET::GetSheetNamePosition(), SCH_SHEET::GetSheetNameSize(), SCH_SHEET::GetSize(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), SCH_SHEET::IsVerticalOrientation(), KiROUND(), LAYER_HIERLABEL, LAYER_SELECTION_SHADOWS, LAYER_SHEET, LAYER_SHEET_BACKGROUND, LAYER_SHEETFILENAME, LAYER_SHEETNAME, KIGFX::PAINTER::m_gal, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), SHEET_BOTTOM_SIDE, SHEET_LEFT_SIDE, SHEET_RIGHT_SIDE, SHEET_TOP_SIDE, KIGFX::GAL::StrokeText(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [18/22]

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

Definition at line 1526 of file sch_painter.cpp.

1527 {
1528  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1529 
1530  if( drawingShadows && !aNC->IsSelected() )
1531  return;
1532 
1533  m_gal->SetIsStroke( true );
1534  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1535  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1536  m_gal->SetIsFill( false );
1537 
1538  VECTOR2D p = aNC->GetPosition();
1539  int delta = aNC->GetSize() / 2;
1540 
1541  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1542  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1543 }
bool IsSelected() const
Definition: base_struct.h:233
wxPoint GetPosition() const override
Function GetPosition.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
int GetSize() const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.

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

◆ draw() [19/22]

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

Definition at line 1624 of file sch_painter.cpp.

1625 {
1626  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1627 
1628  if( drawingShadows && !aMarker->IsSelected() )
1629  return;
1630 
1632  aLayer = LAYER_ERC_ERR;
1633  else
1634  aLayer = LAYER_ERC_WARN;
1635 
1636  COLOR4D color = getRenderColor( aMarker, aLayer, drawingShadows );
1637 
1638  m_gal->Save();
1639  m_gal->Translate( aMarker->GetPosition() );
1640  m_gal->SetIsFill( !drawingShadows );
1641  m_gal->SetFillColor( color );
1642  m_gal->SetIsStroke( drawingShadows );
1643  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1645 
1646  SHAPE_LINE_CHAIN polygon;
1647  aMarker->ShapeToPolygon( polygon );
1648 
1649  m_gal->DrawPolygon( polygon );
1650  m_gal->Restore();
1651 }
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() [20/22]

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

Definition at line 1579 of file sch_painter.cpp.

1580 {
1581  m_gal->Save();
1582  m_gal->Translate( aBitmap->GetPosition() );
1583 
1584  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1585  // factor is similar to a local zoom
1586  double img_scale = aBitmap->GetImageScale();
1587 
1588  if( img_scale != 1.0 )
1589  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1590 
1591  if( aLayer == LAYER_DRAW_BITMAPS )
1592  {
1593  m_gal->DrawBitmap( *aBitmap->GetImage() );
1594  }
1595 
1596  if( aLayer == LAYER_SELECTION_SHADOWS )
1597  {
1598  if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
1599  {
1600  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1601  m_gal->SetIsStroke( true );
1604  m_gal->SetIsFill( false );
1605 
1606  // Draws a bounding box.
1607  VECTOR2D bm_size( aBitmap->GetSize() );
1608  // bm_size is the actual image size in UI.
1609  // but m_gal scale was previously set to img_scale
1610  // so recalculate size relative to this image size.
1611  bm_size.x /= img_scale;
1612  bm_size.y /= img_scale;
1613  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1614  VECTOR2D end = origin + bm_size;
1615 
1616  m_gal->DrawRectangle( origin, end );
1617  }
1618  }
1619 
1620  m_gal->Restore();
1621 }
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() [21/22]

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

Definition at line 1034 of file sch_painter.cpp.

1035 {
1036  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1037 
1038  if( drawingShadows && !aLine->IsSelected() )
1039  return;
1040 
1041  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1042  float width = getLineWidth( aLine, drawingShadows );
1043 
1044  m_gal->SetIsStroke( true );
1046  m_gal->SetLineWidth( width );
1047 
1048  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID || drawingShadows )
1049  {
1050  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1051  }
1052  else
1053  {
1054  VECTOR2D start = aLine->GetStartPoint();
1055  VECTOR2D end = aLine->GetEndPoint();
1056 
1057  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1058  clip.Normalize();
1059 
1060  double theta = atan2( end.y - start.y, end.x - start.x );
1061  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1062 
1063  switch( aLine->GetLineStyle() )
1064  {
1065  default:
1066  case PLOTDASHTYPE_DASH:
1067  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1068  break;
1069  case PLOTDASHTYPE_DOT:
1070  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1071  break;
1072  case PLOTDASHTYPE_DASHDOT:
1073  strokes[0] = DASH_MARK_LEN( width );
1074  strokes[2] = DOT_MARK_LEN( width );
1075  break;
1076  }
1077 
1078  for( size_t i = 0; i < 10000; ++i )
1079  {
1080  // Calculations MUST be done in doubles to keep from accumulating rounding
1081  // errors as we go.
1082  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1083  start.y + strokes[ i % 4 ] * sin( theta ) );
1084 
1085  // Drawing each segment can be done rounded to ints.
1086  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1087  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1088 
1089  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1090  break;
1091  else if( i % 2 == 0 )
1092  m_gal->DrawLine( segStart, segEnd );
1093 
1094  start = next;
1095  }
1096  }
1097 
1098  if( aLine->IsStartDangling() )
1099  drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
1100 
1101  if( aLine->IsEndDangling() )
1102  drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
1103 }
CITER next(CITER it)
Definition: ptree.cpp:130
wxPoint GetStartPoint() const
Definition: sch_line.h:95
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:181
#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:180
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
#define DASH_GAP_LEN(aLineWidth)
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int GetLineStyle() const
Definition: sch_line.cpp:289
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:98

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

◆ draw() [22/22]

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

Definition at line 1546 of file sch_painter.cpp.

1547 {
1548  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1549 
1550  if( drawingShadows && !aEntry->IsSelected() )
1551  return;
1552 
1553  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1554 
1555  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1556  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1557 
1558  m_gal->SetIsStroke( true );
1559  m_gal->SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
1561  m_gal->SetIsFill( false );
1562 
1563  VECTOR2D pos = aEntry->GetPosition();
1564  VECTOR2D endPos = aEntry->m_End();
1565 
1566  m_gal->DrawLine( pos, endPos );
1567 
1568  // Draw dangling symbols:
1569  m_gal->SetLineWidth ( getLineWidth( aEntry, drawingShadows ) );
1570 
1571  if( aEntry->IsDanglingStart() )
1573 
1574  if( aEntry->IsDanglingEnd() )
1576 }
#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 998 of file sch_painter.cpp.

999 {
1000  wxPoint radius( DANGLING_SYMBOL_SIZE, DANGLING_SYMBOL_SIZE );
1001 
1002  m_gal->SetIsStroke( true );
1003  m_gal->SetIsFill( false );
1004  m_gal->SetLineWidth ( aDrawingShadows ? getShadowWidth() : 1.0F );
1005 
1006  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1007 }
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 604 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ getLineWidth() [1/2]

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

Definition at line 267 of file sch_painter.cpp.

268 {
269  float width = (float) aItem->GetPenSize();
270 
271  if( aItem->IsSelected() && aDrawingShadows )
272  width += getShadowWidth();
273 
274  return width;
275 }
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 278 of file sch_painter.cpp.

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

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

◆ getRenderColor()

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

Definition at line 237 of file sch_painter.cpp.

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

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

Referenced by draw(), and setDeviceColors().

◆ GetSettings()

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

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

Returns
Current rendering settings.

Implements KIGFX::PAINTER.

Definition at line 131 of file sch_painter.h.

132  {
133  return &m_schSettings;
134  }
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175

References m_schSettings.

◆ getShadowWidth()

float KIGFX::SCH_PAINTER::getShadowWidth ( )
private

Definition at line 227 of file sch_painter.cpp.

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

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

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

◆ getTextThickness()

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

Definition at line 289 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ isUnitAndConversionShown()

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

Definition at line 207 of file sch_painter.cpp.

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

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

Referenced by draw().

◆ setDeviceColors()

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

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

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

Referenced by draw().

◆ SetGAL()

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

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

Parameters
aGalis the new GAL instance.

Definition at line 333 of file painter.h.

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

References KIGFX::PAINTER::m_gal.

◆ triLine()

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

Definition at line 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: