KiCad PCB EDA Suite
KIGFX::SCH_PAINTER Class Reference

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
 Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item. More...
 
virtual SCH_RENDER_SETTINGSGetSettings () override
 Return a pointer to current settings that are going to be used when drawing items. More...
 
void SetSchematic (SCHEMATIC *aSchematic)
 
void SetGAL (GAL *aGal)
 Changes Graphics Abstraction Layer used for drawing items for a new one. More...
 

Static Public Attributes

static std::vector< KICAD_Tg_ScaledSelectionTypes
 

Protected Attributes

GALm_gal
 Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg. More...
 

Private Member Functions

void draw (const EDA_ITEM *, int, bool aDimmed)
 
void draw (const LIB_PIN *aPin, int aLayer, bool aDimmed)
 
void draw (const LIB_SHAPE *aCircle, int aLayer, bool aDimmed)
 
void draw (const LIB_SYMBOL *aSymbol, int, bool aDrawFields=true, int aUnit=0, int aConvert=0, bool aDimmed=false)
 
void draw (const LIB_FIELD *aField, int aLayer, bool aDimmed)
 
void draw (const LIB_TEXT *aText, int aLayer, bool aDimmed)
 
void draw (const LIB_TEXTBOX *aTextBox, int aLayer, bool aDimmed)
 
void draw (const SCH_SYMBOL *aSymbol, int aLayer)
 
void draw (const SCH_JUNCTION *aJct, int aLayer)
 
void draw (const SCH_FIELD *aField, int aLayer, bool aDimmed)
 
void draw (const SCH_SHAPE *aShape, int aLayer)
 
void draw (const SCH_TEXTBOX *aTextBox, int aLayer)
 
void draw (const SCH_TEXT *aText, int aLayer)
 
void draw (const SCH_LABEL *aText, int aLayer)
 
void draw (const SCH_DIRECTIVE_LABEL *aLabel, int aLayer)
 
void draw (const SCH_HIERLABEL *aLabel, int aLayer)
 
void draw (const SCH_GLOBALLABEL *aLabel, int aLayer)
 
void draw (const SCH_SHEET *aSheet, int aLayer)
 
void draw (const SCH_NO_CONNECT *aNC, int aLayer)
 
void draw (const SCH_MARKER *aMarker, int aLayer)
 
void draw (const SCH_BITMAP *aBitmap, int aLayer)
 
void draw (const SCH_LINE *aLine, int aLayer)
 
void draw (const SCH_BUS_ENTRY_BASE *aEntry, int aLayer)
 
void drawPinDanglingSymbol (const VECTOR2I &aPos, const COLOR4D &aColor, bool aDrawingShadows, bool aBrightened)
 
void drawDanglingSymbol (const VECTOR2I &aPos, const COLOR4D &aColor, int aWidth, bool aDangling, bool aDrawingShadows, bool aBrightened)
 
int internalPinDecoSize (const LIB_PIN &aPin)
 
int externalPinDecoSize (const LIB_PIN &aPin)
 
bool nonCached (const EDA_ITEM *aItem)
 
bool isUnitAndConversionShown (const LIB_ITEM *aItem) const
 
float getShadowWidth (bool aForHighlight) const
 
COLOR4D getRenderColor (const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows, bool aDimmed=false) const
 
KIFONT::FONTgetFont (const EDA_TEXT *aText) const
 
float getLineWidth (const EDA_ITEM *aItem, bool aDrawingShadows) const
 
float getTextThickness (const EDA_ITEM *aItem) const
 
bool setDeviceColors (const LIB_ITEM *aItem, int aLayer, bool aDimmed)
 
void triLine (const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
 
void strokeText (const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttributes)
 
void bitmapText (const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttributes)
 
void boxText (const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttrs)
 

Private Attributes

SCH_RENDER_SETTINGS m_schSettings
 
SCHEMATICm_schematic
 

Detailed Description

Contains methods for drawing schematic-specific items.

Definition at line 133 of file sch_painter.h.

Constructor & Destructor Documentation

◆ SCH_PAINTER()

KIGFX::SCH_PAINTER::SCH_PAINTER ( GAL aGal)

Definition at line 184 of file sch_painter.cpp.

184 :
185 KIGFX::PAINTER( aGal ),
186 m_schematic( nullptr )
187{ }
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:58
SCHEMATIC * m_schematic
Definition: sch_painter.h:206

Member Function Documentation

◆ bitmapText()

void KIGFX::SCH_PAINTER::bitmapText ( const wxString &  aText,
const VECTOR2D aPosition,
const TEXT_ATTRIBUTES aAttributes 
)
private

Definition at line 605 of file sch_painter.cpp.

607{
608 // Bitmap font has different metrics from the stroke font so we compensate a bit before
609 // stroking
610 m_gal->SetGlyphSize( VECTOR2I( aAttrs.m_Size.x, KiROUND( aAttrs.m_Size.y * 1.05 ) ) );
611 m_gal->SetLineWidth( (float) aAttrs.m_StrokeWidth * 1.35f );
612
613 m_gal->SetHorizontalJustify( aAttrs.m_Halign );
614 m_gal->SetVerticalJustify( aAttrs.m_Valign );
615
616 m_gal->BitmapText( aText, aPosition, aAttrs.m_Angle );
617}
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void SetGlyphSize(const VECTOR2I aSize)
virtual void BitmapText(const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
Draw a text using a bitmap font.
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:101
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References KiROUND(), TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ boxText()

void KIGFX::SCH_PAINTER::boxText ( const wxString &  aText,
const VECTOR2D aPosition,
const TEXT_ATTRIBUTES aAttrs 
)
private

Definition at line 620 of file sch_painter.cpp.

622{
623 KIFONT::FONT* font = aAttrs.m_Font;
624
625 if( !font )
626 {
627 font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
628 aAttrs.m_Italic );
629 }
630
631 VECTOR2I extents = font->StringBoundaryLimits( aText, aAttrs.m_Size, aAttrs.m_StrokeWidth,
632 aAttrs.m_Bold, aAttrs.m_Italic );
633 BOX2I box( aPosition, VECTOR2I( extents.x, aAttrs.m_Size.y ) );
634
635 switch( aAttrs.m_Halign )
636 {
637 case GR_TEXT_H_ALIGN_LEFT: break;
638 case GR_TEXT_H_ALIGN_CENTER: box.SetX( box.GetX() - box.GetWidth() / 2 ); break;
639 case GR_TEXT_H_ALIGN_RIGHT: box.SetX( box.GetX() - box.GetWidth() ); break;
640 }
641
642 switch( aAttrs.m_Valign )
643 {
644 case GR_TEXT_V_ALIGN_TOP: break;
645 case GR_TEXT_V_ALIGN_CENTER: box.SetY( box.GetY() - box.GetHeight() / 2 ); break;
646 case GR_TEXT_V_ALIGN_BOTTOM: box.SetY( box.GetY() - box.GetHeight() ); break;
647 }
648
649 // Give the highlight a bit of margin.
650 box.Inflate( 0, aAttrs.m_StrokeWidth * 2 );
651
652 box.Normalize(); // Make h and v sizes always >= 0
653 box = box.GetBoundingBoxRotated( (VECTOR2I) aPosition, aAttrs.m_Angle );
654 box.RevertYAxis();
655
656 m_gal->SetIsFill( true );
657 m_gal->SetIsStroke( false );
658 m_gal->DrawRectangle( mapCoords( box.GetOrigin() ), mapCoords( box.GetEnd() ) );
659}
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic) const
Compute the boundary limits of aText (the bounding box of all shapes).
Definition: font.cpp:271
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
EESCHEMA_SETTINGS * eeconfig()
Definition: sch_painter.cpp:74
static VECTOR2D mapCoords(const VECTOR2D &aCoord)
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP

References KIGFX::eeconfig(), BOX2< Vec >::GetBoundingBoxRotated(), BOX2< Vec >::GetEnd(), KIFONT::FONT::GetFont(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, BOX2< Vec >::Inflate(), TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Bold, TEXT_ATTRIBUTES::m_Font, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, KIGFX::mapCoords(), BOX2< Vec >::Normalize(), BOX2< Vec >::RevertYAxis(), BOX2< Vec >::SetX(), BOX2< Vec >::SetY(), KIFONT::FONT::StringBoundaryLimits(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [1/23]

void KIGFX::SCH_PAINTER::draw ( const EDA_ITEM aItem,
int  aLayer,
bool  aDimmed 
)
private

Definition at line 201 of file sch_painter.cpp.

202{
203
204#ifdef CONNECTIVITY_DEBUG
205
206 auto sch_item = dynamic_cast<const SCH_ITEM*>( aItem );
207 auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
208
209 if( conn )
210 {
211 auto pos = aItem->GetBoundingBox().Centre();
212 auto label = conn->Name( true );
213
217 m_gal->SetLineWidth( Mils2ui( 2 ) );
218 m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
219 m_gal->StrokeText( conn->Name( true ), pos, 0.0, 0 );
220 }
221
222#endif
223
225 {
226 BOX2I box = aItem->GetBoundingBox();
227
228 if( aItem->Type() == SCH_SYMBOL_T )
229 box = static_cast<const SCH_SYMBOL*>( aItem )->GetBodyBoundingBox();
230
231 m_gal->SetIsFill( false );
232 m_gal->SetIsStroke( true );
233 m_gal->SetStrokeColor( aItem->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
234 : COLOR4D( 0.2, 0.2, 0.2, 1 ) );
236 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
237 }
238
239 switch( aItem->Type() )
240 {
241 case LIB_SYMBOL_T:
242 draw( static_cast<const LIB_SYMBOL*>( aItem ), aLayer );
243 break;
244 case LIB_SHAPE_T:
245 draw( static_cast<const LIB_SHAPE*>( aItem ), aLayer, aDimmed );
246 break;
247 case LIB_PIN_T:
248 draw( static_cast<const LIB_PIN*>( aItem ), aLayer, aDimmed );
249 break;
250 case LIB_FIELD_T:
251 draw( static_cast<const LIB_FIELD*>( aItem ), aLayer, aDimmed );
252 break;
253 case LIB_TEXT_T:
254 draw( static_cast<const LIB_TEXT*>( aItem ), aLayer, aDimmed );
255 break;
256 case LIB_TEXTBOX_T:
257 draw( static_cast<const LIB_TEXTBOX*>( aItem ), aLayer, aDimmed );
258 break;
259 case SCH_SYMBOL_T:
260 draw( static_cast<const SCH_SYMBOL*>( aItem ), aLayer );
261 break;
262 case SCH_JUNCTION_T:
263 draw( static_cast<const SCH_JUNCTION*>( aItem ), aLayer );
264 break;
265 case SCH_LINE_T:
266 draw( static_cast<const SCH_LINE*>( aItem ), aLayer );
267 break;
268 case SCH_SHAPE_T:
269 draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer );
270 break;
271 case SCH_TEXT_T:
272 draw( static_cast<const SCH_TEXT*>( aItem ), aLayer );
273 break;
274 case SCH_TEXTBOX_T:
275 draw( static_cast<const SCH_TEXTBOX*>( aItem ), aLayer );
276 break;
277 case SCH_LABEL_T:
278 draw( static_cast<const SCH_LABEL*>( aItem ), aLayer );
279 break;
281 draw( static_cast<const SCH_DIRECTIVE_LABEL*>( aItem ), aLayer );
282 break;
283 case SCH_FIELD_T:
284 draw( static_cast<const SCH_FIELD*>( aItem ), aLayer, aDimmed );
285 break;
286 case SCH_HIER_LABEL_T:
287 draw( static_cast<const SCH_HIERLABEL*>( aItem ), aLayer );
288 break;
290 draw( static_cast<const SCH_GLOBALLABEL*>( aItem ), aLayer );
291 break;
292 case SCH_SHEET_T:
293 draw( static_cast<const SCH_SHEET*>( aItem ), aLayer );
294 break;
295 case SCH_SHEET_PIN_T:
296 draw( static_cast<const SCH_HIERLABEL*>( aItem ), aLayer );
297 break;
298 case SCH_NO_CONNECT_T:
299 draw( static_cast<const SCH_NO_CONNECT*>( aItem ), aLayer );
300 break;
302 draw( static_cast<const SCH_BUS_ENTRY_BASE*>( aItem ), aLayer );
303 break;
305 draw( static_cast<const SCH_BUS_ENTRY_BASE*>( aItem ), aLayer );
306 break;
307 case SCH_BITMAP_T:
308 draw( static_cast<const SCH_BITMAP*>( aItem ), aLayer );
309 break;
310 case SCH_MARKER_T:
311 draw( static_cast<const SCH_MARKER*>( aItem ), aLayer );
312 break;
313
314 default: return;
315 }
316}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185
Vec Centre() const
Definition: box2.h:70
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsSelected() const
Definition: eda_item.h:106
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
bool GetDrawBoundingBoxes() const
void draw(const EDA_ITEM *, int, bool aDimmed)
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:205
Field object used in symbol libraries.
Definition: lib_field.h:61
Define a library symbol object.
Definition: lib_symbol.h:99
Define a symbol library graphical text item.
Definition: lib_text.h:40
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:146
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
Schematic symbol object.
Definition: sch_symbol.h:81
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
@ LIGHTRED
Definition: color4d.h:65
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
@ SCH_LINE_T
Definition: typeinfo.h:146
@ LIB_SYMBOL_T
Definition: typeinfo.h:198
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:143
@ LIB_TEXT_T
Definition: typeinfo.h:200
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ LIB_TEXTBOX_T
Definition: typeinfo.h:201
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:154
@ SCH_LABEL_T
Definition: typeinfo.h:151
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ LIB_SHAPE_T
Definition: typeinfo.h:199
@ SCH_MARKER_T
Definition: typeinfo.h:141
@ SCH_SHAPE_T
Definition: typeinfo.h:147
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:145
@ LIB_PIN_T
Definition: typeinfo.h:202
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_TEXT_T
Definition: typeinfo.h:150
@ LIB_FIELD_T
Definition: typeinfo.h:208
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:144
@ SCH_BITMAP_T
Definition: typeinfo.h:148
@ SCH_TEXTBOX_T
Definition: typeinfo.h:149
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152
@ SCH_JUNCTION_T
Definition: typeinfo.h:142
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617

References BOX2< Vec >::Centre(), SCH_ITEM::Connection(), draw(), KIGFX::GAL::DrawRectangle(), SCH_SYMBOL::GetBodyBoundingBox(), EDA_ITEM::GetBoundingBox(), KIGFX::RENDER_SETTINGS::GetDrawBoundingBoxes(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, EDA_ITEM::IsSelected(), LIB_FIELD_T, LIB_PIN_T, LIB_SHAPE_T, LIB_SYMBOL_T, LIB_TEXT_T, LIB_TEXTBOX_T, LIGHTRED, KIGFX::PAINTER::m_gal, m_schSettings, EDA_IU_SCALE::MilsToIU(), SCH_BITMAP_T, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_DIRECTIVE_LABEL_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_SHAPE_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_TEXT_T, SCH_TEXTBOX_T, schIUScale, KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetVerticalJustify(), and EDA_ITEM::Type().

Referenced by draw(), and Draw().

◆ draw() [2/23]

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

Definition at line 931 of file sch_painter.cpp.

932{
933 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
934
935 if( drawingShadows && !( aField->IsBrightened() || aField->IsSelected() ) )
936 return;
937
938 if( !isUnitAndConversionShown( aField ) )
939 return;
940
941 // Must check layer as fields are sometimes drawn by their parent rather than
942 // directly from the view.
944 int layers_count;
945 bool foundLayer = false;
946
947 aField->ViewGetLayers( layers, layers_count );
948
949 for( int i = 0; i < layers_count; ++i )
950 {
951 if( layers[i] == aLayer )
952 foundLayer = true;
953 }
954
955 if( !foundLayer )
956 return;
957
958 COLOR4D color = getRenderColor( aField, aLayer, drawingShadows, aDimmed );
959
960 if( !( aField->IsVisible() || aField->IsForceVisible() ) )
961 {
962 if( m_schSettings.m_IsSymbolEditor || eeconfig()->m_Appearance.show_hidden_fields )
963 color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows, aDimmed );
964 else
965 return;
966 }
967
970
971 BOX2I bbox = aField->GetBoundingBox();
972
973 if( drawingShadows && getFont( aField )->IsOutline() )
974 {
975 bbox.Inflate( KiROUND( getTextThickness( aField ) * 2 ) );
976
977 m_gal->SetIsStroke( false );
978 m_gal->SetIsFill( true );
979 m_gal->DrawRectangle( bbox.GetPosition(), bbox.GetEnd() );
980 }
981 else
982 {
983 VECTOR2I textpos = bbox.Centre();
984 TEXT_ATTRIBUTES attrs( aField->GetAttributes() );
985
986 attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER;
987 attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER;
988 attrs.m_StrokeWidth = KiROUND( getTextThickness( aField ) );
989
990 if( drawingShadows )
991 attrs.m_StrokeWidth += getShadowWidth( !aField->IsSelected() );
992
993 strokeText( UnescapeString( aField->GetShownText() ), textpos, attrs );
994 }
995
996 // Draw the umbilical line when in the schematic editor
997 if( aField->IsMoving() && m_schematic )
998 {
1000 m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
1001 m_gal->DrawLine( bbox.Centre(), VECTOR2I( 0, 0 ) );
1002 }
1003}
int color
Definition: DXF_plotter.cpp:57
const Vec & GetPosition() const
Definition: box2.h:184
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
bool IsBrightened() const
Definition: eda_item.h:108
bool IsForceVisible() const
Definition: eda_item.h:201
bool IsMoving() const
Definition: eda_item.h:104
virtual bool IsVisible() const
Definition: eda_text.h:136
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
float getShadowWidth(bool aForHighlight) const
KIFONT::FONT * getFont(const EDA_TEXT *aText) const
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
void strokeText(const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttributes)
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows, bool aDimmed=false) const
float getTextThickness(const EDA_ITEM *aItem) const
static constexpr int VIEW_MAX_LAYERS
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:727
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: lib_field.cpp:444
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_field.cpp:419
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: lib_field.cpp:408
@ LAYER_SCHEMATIC_ANCHOR
Definition: layer_ids.h:386
@ LAYER_HIDDEN
Definition: layer_ids.h:380
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:381
wxString UnescapeString(const wxString &aSource)

References BOX2< Vec >::Centre(), color, KIGFX::eeconfig(), EDA_TEXT::GetAttributes(), LIB_FIELD::GetBoundingBox(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetPosition(), LIB_FIELD::GetShownText(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, BOX2< Vec >::Inflate(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsForceVisible(), EDA_ITEM::IsMoving(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), KiROUND(), LAYER_HIDDEN, LAYER_SCHEMATIC_ANCHOR, LAYER_SELECTION_SHADOWS, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, UnescapeString(), KIGFX::VIEW::VIEW_MAX_LAYERS, and LIB_FIELD::ViewGetLayers().

◆ draw() [3/23]

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

Definition at line 1228 of file sch_painter.cpp.

1229{
1230 if( !isUnitAndConversionShown( aPin ) )
1231 return;
1232
1233 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1234 bool drawingDangling = aLayer == LAYER_DANGLING;
1235 bool isDangling = m_schSettings.m_IsSymbolEditor || aPin->HasFlag( IS_DANGLING );
1236
1237 if( drawingShadows && !( aPin->IsBrightened() || aPin->IsSelected() ) )
1238 return;
1239
1240 VECTOR2I pos = mapCoords( aPin->GetPosition() );
1241 COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows, aDimmed );
1242
1243 if( !aPin->IsVisible() )
1244 {
1245 if( !m_schematic || eeconfig()->m_Appearance.show_hidden_pins )
1246 {
1247 color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
1248 }
1249 else
1250 {
1251 if( drawingDangling && isDangling && aPin->IsPowerConnection() )
1252 drawPinDanglingSymbol( pos, color, drawingShadows, aPin->IsBrightened() );
1253
1254 return;
1255 }
1256 }
1257
1258 if( drawingDangling )
1259 {
1260 if( isDangling )
1261 drawPinDanglingSymbol( pos, color, drawingShadows, aPin->IsBrightened() );
1262
1263 return;
1264 }
1265
1266 VECTOR2I p0;
1267 VECTOR2I dir;
1268 int len = aPin->GetLength();
1269 int orient = aPin->GetOrientation();
1270
1271 switch( orient )
1272 {
1273 case PIN_UP:
1274 p0 = VECTOR2I( pos.x, pos.y - len );
1275 dir = VECTOR2I( 0, 1 );
1276 break;
1277
1278 case PIN_DOWN:
1279 p0 = VECTOR2I( pos.x, pos.y + len );
1280 dir = VECTOR2I( 0, -1 );
1281 break;
1282
1283 case PIN_LEFT:
1284 p0 = VECTOR2I( pos.x - len, pos.y );
1285 dir = VECTOR2I( 1, 0 );
1286 break;
1287
1288 default:
1289 case PIN_RIGHT:
1290 p0 = VECTOR2I( pos.x + len, pos.y );
1291 dir = VECTOR2I( -1, 0 );
1292 break;
1293 }
1294
1295 VECTOR2D pc;
1296
1297 m_gal->SetIsStroke( true );
1298 m_gal->SetIsFill( false );
1299 m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
1301 m_gal->SetFontBold( false );
1302 m_gal->SetFontUnderlined( false );
1303 m_gal->SetFontItalic( false );
1304
1305 const int radius = externalPinDecoSize( *aPin );
1306 const int diam = radius*2;
1307 const int clock_size = internalPinDecoSize( *aPin );
1308
1309 if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
1310 {
1311 m_gal->DrawLine( p0, pos );
1312
1313 m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
1314 pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
1315 m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
1316 pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
1317 }
1318 else
1319 {
1320 switch( aPin->GetShape() )
1321 {
1323 m_gal->DrawLine( p0, pos );
1324 break;
1325
1327 m_gal->DrawCircle( p0 + dir * radius, radius );
1328 m_gal->DrawLine( p0 + dir * ( diam ), pos );
1329 break;
1330
1332 pc = p0 - dir * clock_size ;
1333
1334 triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
1335 pc,
1336 p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
1337
1338 m_gal->DrawCircle( p0 + dir * radius, radius );
1339 m_gal->DrawLine( p0 + dir * ( diam ), pos );
1340 break;
1341
1344 pc = p0 - dir * clock_size ;
1345
1346 triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
1347 pc,
1348 p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
1349
1350 if( !dir.y )
1351 {
1352 triLine( p0 + VECTOR2D(dir.x, 0) * diam,
1353 p0 + VECTOR2D(dir.x, -1) * diam,
1354 p0 );
1355 }
1356 else /* MapX1 = 0 */
1357 {
1358 triLine( p0 + VECTOR2D( 0, dir.y) * diam,
1359 p0 + VECTOR2D(-1, dir.y) * diam,
1360 p0 );
1361 }
1362
1363 m_gal->DrawLine( p0, pos );
1364 break;
1365
1367 m_gal->DrawLine( p0, pos );
1368
1369 if( !dir.y )
1370 {
1371 triLine( p0 + VECTOR2D( 0, clock_size ),
1372 p0 + VECTOR2D( -dir.x * clock_size, 0 ),
1373 p0 + VECTOR2D( 0, -clock_size ) );
1374 }
1375 else
1376 {
1377 triLine( p0 + VECTOR2D( clock_size, 0 ),
1378 p0 + VECTOR2D( 0, -dir.y * clock_size ),
1379 p0 + VECTOR2D( -clock_size, 0 ) );
1380 }
1381 break;
1382
1384 m_gal->DrawLine( p0, pos );
1385
1386 if( !dir.y )
1387 {
1388 triLine( p0 + VECTOR2D(dir.x, 0) * diam,
1389 p0 + VECTOR2D(dir.x, -1) * diam,
1390 p0 );
1391 }
1392 else /* MapX1 = 0 */
1393 {
1394 triLine( p0 + VECTOR2D( 0, dir.y) * diam,
1395 p0 + VECTOR2D(-1, dir.y) * diam,
1396 p0 );
1397 }
1398 break;
1399
1400 case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
1401 m_gal->DrawLine( p0, pos );
1402
1403 if( !dir.y ) // Horizontal pin
1404 m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
1405 else // Vertical pin
1406 m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
1407 break;
1408
1409 case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
1410 m_gal->DrawLine( p0, pos );
1411
1412 m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
1413 p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
1414 m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
1415 p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
1416 break;
1417 }
1418 }
1419
1420 LIB_SYMBOL* libEntry = aPin->GetParent();
1421
1422 // Draw the labels
1423
1424 if( libEntry->Type() == LIB_SYMBOL_T )
1425 {
1426 if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children )
1427 return;
1428 }
1429
1430 float penWidth = (float) m_schSettings.GetDefaultPenWidth();
1431 int textOffset = libEntry->GetPinNameOffset();
1432 float nameStrokeWidth = getLineWidth( aPin, false );
1433 float numStrokeWidth = getLineWidth( aPin, false );
1434 bool showPinNames = libEntry->ShowPinNames();
1435 bool showPinNumbers = m_schSettings.m_ShowPinNumbers || libEntry->ShowPinNumbers();
1436
1437 nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), true );
1438 numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), true );
1439
1441
1442 // Four locations around a pin where text can be drawn
1443 enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
1444 int size[4] = { 0, 0, 0, 0 };
1445 float thickness[4] = { numStrokeWidth, numStrokeWidth, numStrokeWidth, numStrokeWidth };
1446 COLOR4D colour[4];
1447 wxString text[4];
1448
1449 // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
1450 if( textOffset )
1451 {
1452 size [INSIDE] = showPinNames ? aPin->GetNameTextSize() : 0;
1453 thickness[INSIDE] = nameStrokeWidth;
1454 colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
1455 text [INSIDE] = aPin->GetShownName();
1456
1457 size [ABOVE] = showPinNumbers ? aPin->GetNumberTextSize() : 0;
1458 thickness[ABOVE] = numStrokeWidth;
1459 colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
1460 text [ABOVE] = aPin->GetShownNumber();
1461 }
1462 // Otherwise pin NAMES go above and pin NUMBERS go below
1463 else
1464 {
1465 size [ABOVE] = showPinNames ? aPin->GetNameTextSize() : 0;
1466 thickness[ABOVE] = nameStrokeWidth;
1467 colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
1468 text [ABOVE] = aPin->GetShownName();
1469
1470 size [BELOW] = showPinNumbers ? aPin->GetNumberTextSize() : 0;
1471 thickness[BELOW] = numStrokeWidth;
1472 colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
1473 text [BELOW] = aPin->GetShownNumber();
1474 }
1475
1477 {
1478 size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, schIUScale.mmToIU( 0.7 ) );
1479 thickness[OUTSIDE] = float( size[OUTSIDE] ) / 8.0f;
1480 colour [OUTSIDE] = getRenderColor( aPin, LAYER_PRIVATE_NOTES, drawingShadows, aDimmed );
1482 }
1483
1484 // Rendering text is expensive (particularly when using outline fonts). At small effective
1485 // sizes (ie: zoomed out) the visual differences between outline and/or stroke fonts and the
1486 // bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
1487 // performance gain becomes more significant.
1488 #define BITMAP_FONT_SIZE_THRESHOLD 3.5
1489
1490 bool renderTextAsBitmap = size[0] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD
1494
1495 if( !aPin->IsVisible() )
1496 {
1497 for( COLOR4D& c : colour )
1498 c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
1499 }
1500
1501 float insideOffset = (float) textOffset - thickness[INSIDE] / 2.0f;
1502 float outsideOffset = PIN_TEXT_MARGIN + TARGET_PIN_RADIUS - thickness[OUTSIDE] / 2.0f;
1503 float aboveOffset = PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[ABOVE] / 2.0f;
1504 float belowOffset = PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[BELOW] / 2.0f;
1505
1506 if( isDangling )
1507 outsideOffset += TARGET_PIN_RADIUS / 2.0f;
1508
1509 if( drawingShadows )
1510 {
1511 float shadowWidth = getShadowWidth( aPin->IsBrightened() );
1512
1513 for( float& t : thickness )
1514 t += shadowWidth;
1515 }
1516
1517 auto drawText =
1518 [&]( int i, const VECTOR2D& aPos, GR_TEXT_H_ALIGN_T hAlign, GR_TEXT_V_ALIGN_T vAlign,
1519 const EDA_ANGLE& aAngle )
1520 {
1521 if( text[i].IsEmpty() )
1522 return;
1523
1524 // Which of these gets used depends on the font technology, so set both
1525 m_gal->SetStrokeColor( colour[i] );
1526 m_gal->SetFillColor( colour[i] );
1527
1528 TEXT_ATTRIBUTES attrs;
1529 attrs.m_Size = VECTOR2I( size[i], size[i] );
1530 attrs.m_Halign = hAlign;
1531 attrs.m_Valign = vAlign;
1532 attrs.m_Angle = aAngle;
1533 attrs.m_StrokeWidth = KiROUND( thickness[i] );
1534 KIFONT::FONT* font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, attrs.m_Bold,
1535 attrs.m_Italic );
1536
1537 if( drawingShadows && !font->IsOutline() )
1538 {
1539 strokeText( text[i], aPos, attrs );
1540 }
1541 else if( drawingShadows )
1542 {
1543 boxText( text[i], aPos, attrs );
1544 }
1545 else if( nonCached( aPin ) && renderTextAsBitmap )
1546 {
1547 bitmapText( text[i], aPos, attrs );
1548 const_cast<LIB_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
1549 }
1550 else
1551 {
1552 strokeText( text[i], aPos, attrs );
1553 const_cast<LIB_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
1554 }
1555 };
1556
1557 switch( orient )
1558 {
1559 case PIN_LEFT:
1560 if( size[INSIDE] )
1561 {
1562 drawText( INSIDE, pos + VECTOR2D( -insideOffset - (float) len, 0 ),
1564 }
1565 if( size[OUTSIDE] )
1566 {
1567 drawText( OUTSIDE, pos + VECTOR2D( outsideOffset, 0 ),
1569 }
1570 if( size[ABOVE] )
1571 {
1572 drawText( ABOVE, pos + VECTOR2D( -len / 2.0, -aboveOffset ),
1574 }
1575 if( size[BELOW] )
1576 {
1577 drawText( BELOW, pos + VECTOR2D( -len / 2.0, belowOffset ),
1579 }
1580 break;
1581
1582 case PIN_RIGHT:
1583 if( size[INSIDE] )
1584 {
1585 drawText( INSIDE, pos + VECTOR2D( insideOffset + (float) len, 0 ),
1587 }
1588 if( size[OUTSIDE] )
1589 {
1590 drawText( OUTSIDE, pos + VECTOR2D( -outsideOffset, 0 ),
1592 }
1593 if( size[ABOVE] )
1594 {
1595 drawText( ABOVE, pos + VECTOR2D( len / 2.0, -aboveOffset ),
1597 }
1598 if( size[BELOW] )
1599 {
1600 drawText( BELOW, pos + VECTOR2D( len / 2.0, belowOffset ),
1602 }
1603 break;
1604
1605 case PIN_DOWN:
1606 if( size[INSIDE] )
1607 {
1608 drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + (float) len ),
1610 }
1611 if( size[OUTSIDE] )
1612 {
1613 drawText( OUTSIDE, pos + VECTOR2D( 0, -outsideOffset ),
1615 }
1616 if( size[ABOVE] )
1617 {
1618 drawText( ABOVE, pos + VECTOR2D( -aboveOffset, len / 2.0 ),
1620 }
1621 if( size[BELOW] )
1622 {
1623 drawText( BELOW, pos + VECTOR2D( belowOffset, len / 2.0 ),
1625 }
1626 break;
1627
1628 case PIN_UP:
1629 if( size[INSIDE] )
1630 {
1631 drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - (float) len ),
1633 }
1634 if( size[OUTSIDE] )
1635 {
1636 drawText( OUTSIDE, pos + VECTOR2D( 0, outsideOffset ),
1638 }
1639 if( size[ABOVE] )
1640 {
1641 drawText( ABOVE, pos + VECTOR2D( -aboveOffset, -len / 2.0 ),
1643 }
1644 if( size[BELOW] )
1645 {
1646 drawText( BELOW, pos + VECTOR2D( belowOffset, -len / 2.0 ),
1648 }
1649 break;
1650
1651 default:
1652 wxFAIL_MSG( "Unknown pin orientation" );
1653 }
1654}
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:143
virtual bool IsOutline() const
Definition: font.h:113
void SetFontBold(const bool aBold)
void SetFontUnderlined(bool aUnderlined)
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
void SetFontItalic(bool aItalic)
double GetWorldScale() const
Get the world scale.
int GetDefaultPenWidth() const
void drawPinDanglingSymbol(const VECTOR2I &aPos, const COLOR4D &aColor, bool aDrawingShadows, bool aBrightened)
void bitmapText(const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttributes)
int externalPinDecoSize(const LIB_PIN &aPin)
void boxText(const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttrs)
float getLineWidth(const EDA_ITEM *aItem, bool aDrawingShadows) const
int internalPinDecoSize(const LIB_PIN &aPin)
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
bool nonCached(const EDA_ITEM *aItem)
LIB_SYMBOL * GetParent() const
Definition: lib_item.h:168
int GetLength() const
Definition: lib_pin.h:80
ELECTRICAL_PINTYPE GetType() const
Definition: lib_pin.h:90
int GetOrientation() const
Definition: lib_pin.h:74
wxString GetShownNumber() const
Definition: lib_pin.h:123
int GetNumberTextSize() const
Definition: lib_pin.h:135
wxString GetShownName() const
Definition: lib_pin.cpp:175
VECTOR2I GetPosition() const override
Definition: lib_pin.h:222
wxString const GetElectricalTypeName() const
Definition: lib_pin.h:98
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:77
bool IsVisible() const
Definition: lib_pin.h:103
int GetNameTextSize() const
Definition: lib_pin.h:132
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:197
int GetPinNameOffset() const
Definition: lib_symbol.h:617
bool ShowPinNames() const
Definition: lib_symbol.h:625
bool ShowPinNumbers() const
Definition: lib_symbol.h:633
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:419
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:420
#define IS_SHOWN_AS_BITMAP
#define IS_DANGLING
indicates a pin is dangling
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
Definition: gr_text.cpp:75
@ LAYER_DANGLING
Definition: layer_ids.h:368
@ LAYER_PINNUM
Definition: layer_ids.h:350
@ LAYER_PINNAM
Definition: layer_ids.h:351
@ LAYER_PRIVATE_NOTES
Definition: layer_ids.h:359
@ LAYER_PIN
Definition: layer_ids.h:361
#define PIN_TEXT_MARGIN
Definition: lib_pin.cpp:41
@ PIN_LEFT
Definition: lib_pin.h:46
@ PIN_RIGHT
Definition: lib_pin.h:45
@ PIN_UP
Definition: lib_pin.h:47
@ PIN_DOWN
Definition: lib_pin.h:48
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:35
@ OUTSIDE
Text appears outside the dimension line (default)
@ PT_NC
not connected (must be left open)
#define BITMAP_FONT_SIZE_THRESHOLD
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
GR_TEXT_H_ALIGN_T
GR_TEXT_V_ALIGN_T

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, BITMAP_FONT_SIZE_THRESHOLD, Clamp_Text_PenSize(), CLOCK, CLOCK_LOW, color, KIGFX::eeconfig(), externalPinDecoSize(), FALLING_EDGE_CLOCK, LIB_PIN::GetElectricalTypeName(), KIFONT::FONT::GetFont(), LIB_PIN::GetLength(), LIB_PIN::GetNameTextSize(), LIB_PIN::GetNumberTextSize(), LIB_PIN::GetOrientation(), LIB_ITEM::GetParent(), LIB_SYMBOL::GetPinNameOffset(), LIB_PIN::GetPosition(), LIB_PIN::GetShape(), LIB_PIN::GetShownName(), LIB_PIN::GetShownNumber(), LIB_PIN::GetType(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_ITEM::HasFlag(), INPUT_LOW, internalPinDecoSize(), INVERTED, INVERTED_CLOCK, IS_DANGLING, IS_SHOWN_AS_BITMAP, EDA_ITEM::IsBrightened(), KIFONT::FONT::IsOutline(), LIB_PIN::IsPowerConnection(), EDA_ITEM::IsSelected(), LIB_PIN::IsVisible(), KiROUND(), LAYER_DANGLING, LAYER_HIDDEN, LAYER_PIN, LAYER_PINNAM, LAYER_PINNUM, LAYER_PRIVATE_NOTES, LAYER_SELECTION_SHADOWS, LIB_SYMBOL_T, LINE, TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Bold, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, KIGFX::mapCoords(), EDA_IU_SCALE::MilsToIU(), EDA_IU_SCALE::mmToIU(), NONLOGIC, OUTPUT_LOW, OUTSIDE, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_TEXT_MARGIN, PIN_UP, PT_NC, schIUScale, LIB_SYMBOL::ShowPinNames(), LIB_SYMBOL::ShowPinNumbers(), TARGET_PIN_RADIUS, text, EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [4/23]

void KIGFX::SCH_PAINTER::draw ( const LIB_SHAPE aCircle,
int  aLayer,
bool  aDimmed 
)
private

Definition at line 783 of file sch_painter.cpp.

784{
785 if( !isUnitAndConversionShown( aShape ) )
786 return;
787
788 if( aShape->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
789 return;
790
791 if( !setDeviceColors( aShape, aLayer, aDimmed ) )
792 return;
793
794 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
795 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
796 COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows, aDimmed );
797
798 auto drawShape =
799 [&]( const LIB_SHAPE* shape )
800 {
801 switch( shape->GetShape() )
802 {
803 case SHAPE_T::ARC:
804 {
805 EDA_ANGLE startAngle;
806 EDA_ANGLE endAngle;
807 shape->CalcArcAngles( startAngle, endAngle );
808
809 TRANSFORM().MapAngles( &startAngle, &endAngle );
810
811 m_gal->DrawArc( mapCoords( shape->GetCenter() ), shape->GetRadius(),
812 startAngle, endAngle );
813 }
814 break;
815
816 case SHAPE_T::CIRCLE:
817 m_gal->DrawCircle( mapCoords( shape->GetPosition() ), shape->GetRadius() );
818 break;
819
820 case SHAPE_T::RECT:
821 m_gal->DrawRectangle( mapCoords( shape->GetPosition() ),
822 mapCoords( shape->GetEnd() ) );
823 break;
824
825 case SHAPE_T::POLY:
826 {
827 const SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 );
828 std::deque<VECTOR2D> mappedPts;
829
830 for( const VECTOR2I& pt : poly.CPoints() )
831 mappedPts.push_back( mapCoords( pt ) );
832
833 m_gal->DrawPolygon( mappedPts );
834 }
835 break;
836
837 case SHAPE_T::BEZIER:
838 {
839 std::deque<VECTOR2D> mappedPts;
840
841 for( const VECTOR2I& p : shape->GetBezierPoints() )
842 mappedPts.push_back( mapCoords( p ) );
843
844 m_gal->DrawPolygon( mappedPts );
845 }
846 break;
847
848 default:
849 UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() );
850 }
851 };
852
853 if( aLayer == LAYER_SELECTION_SHADOWS )
854 {
855 if( eeconfig()->m_Selection.fill_shapes )
856 {
857 // Consider a NAND gate. We have no idea which side of the arc is "inside"
858 // so we can't reliably fill.
859 if( aShape->GetShape() == SHAPE_T::ARC )
860 m_gal->SetIsFill( aShape->IsFilled() );
861 else
862 m_gal->SetIsFill( true );
863 }
864 else
865 {
866 m_gal->SetIsStroke( true );
867 m_gal->SetIsFill( false );
868 m_gal->SetLineWidth( getLineWidth( aShape, true ) );
870 }
871
872 drawShape( aShape );
873 }
874 else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
875 {
876 if( aShape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
877 {
878 m_gal->SetIsFill( true );
879 m_gal->SetIsStroke( false );
880 drawShape( aShape );
881 }
882 }
883 else if( aLayer == LAYER_DEVICE || aLayer == LAYER_PRIVATE_NOTES )
884 {
885 float lineWidth = getLineWidth( aShape, drawingShadows );
886
887 if( lineWidth > 0 )
888 {
889 m_gal->SetIsFill( false );
890 m_gal->SetIsStroke( true );
891 m_gal->SetLineWidth( lineWidth );
893
894 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
895 {
896 drawShape( aShape );
897 }
898 else
899 {
900 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
901
902 for( SHAPE* shape : shapes )
903 {
904 STROKE_PARAMS::Stroke( shape, lineStyle, KiROUND( lineWidth ), &m_schSettings,
905 [&]( const VECTOR2I& a, const VECTOR2I& b )
906 {
907 // DrawLine has problem with 0 length lines so enforce minimum
908 if( a == b )
909 m_gal->DrawLine( mapCoords( a+1 ), mapCoords( b ) );
910 else
911 m_gal->DrawLine( mapCoords( a ), mapCoords( b ) );
912 } );
913 }
914
915 for( SHAPE* shape : shapes )
916 delete shape;
917 }
918 }
919
920 if( aShape->GetFillMode() == FILL_T::FILLED_SHAPE
921 || aShape->GetFillMode() == FILL_T::FILLED_WITH_COLOR )
922 {
923 m_gal->SetIsFill( true );
924 m_gal->SetIsStroke( false );
925 drawShape( aShape );
926 }
927 }
928}
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle)
Draw an arc.
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer, bool aDimmed)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const std::vector< VECTOR2I > & CPoints() const
An abstract shape on 2D plane.
Definition: shape.h:123
static void Stroke(const SHAPE *aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:47
bool MapAngles(EDA_ANGLE *aAngle1, EDA_ANGLE *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:82
@ FILLED_WITH_COLOR
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
@ LAYER_DEVICE
Definition: layer_ids.h:357
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:372
@ LAYER_NOTES_BACKGROUND
Definition: layer_ids.h:360
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48

References ARC, BEZIER, CIRCLE, color, SHAPE_LINE_CHAIN::CPoints(), KIGFX::eeconfig(), FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, FILLED_WITH_COLOR, FIRST_TYPE, EDA_SHAPE::GetFillMode(), STROKE_PARAMS::GetPlotStyle(), EDA_SHAPE::GetShape(), LIB_SHAPE::GetStroke(), EDA_SHAPE::IsFilled(), LIB_ITEM::IsPrivate(), KiROUND(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, LAYER_NOTES_BACKGROUND, LAYER_PRIVATE_NOTES, LAYER_SELECTION_SHADOWS, LIB_SHAPE::MakeEffectiveShapes(), TRANSFORM::MapAngles(), KIGFX::mapCoords(), POLY, RECT, STROKE_PARAMS::Stroke(), and UNIMPLEMENTED_FOR.

◆ draw() [5/23]

void KIGFX::SCH_PAINTER::draw ( const LIB_SYMBOL aSymbol,
int  aLayer,
bool  aDrawFields = true,
int  aUnit = 0,
int  aConvert = 0,
bool  aDimmed = false 
)
private

Definition at line 669 of file sch_painter.cpp.

671{
672 if( !aUnit )
674
675 if( !aConvert )
676 aConvert = m_schSettings.m_ShowConvert;
677
678 std::unique_ptr< LIB_SYMBOL > tmpSymbol;
679 const LIB_SYMBOL* drawnSymbol = aSymbol;
680
681 if( aSymbol->IsAlias() )
682 {
683 tmpSymbol = aSymbol->Flatten();
684 drawnSymbol = tmpSymbol.get();
685 }
686
687 for( const LIB_ITEM& item : drawnSymbol->GetDrawItems() )
688 {
689 if( !aDrawFields && item.Type() == LIB_FIELD_T )
690 continue;
691
692 if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
693 continue;
694
695 if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
696 continue;
697
698 draw( &item, aLayer, aDimmed );
699 }
700}
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
bool IsAlias() const
Definition: lib_symbol.h:188
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:508
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:456

References LIB_SYMBOL::Flatten(), LIB_SYMBOL::GetDrawItems(), LIB_SYMBOL::IsAlias(), and LIB_FIELD_T.

◆ draw() [6/23]

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

Definition at line 1006 of file sch_painter.cpp.

1007{
1008 if( !isUnitAndConversionShown( aText ) )
1009 return;
1010
1011 if( aText->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
1012 return;
1013
1014 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1015
1016 if( drawingShadows && !( aText->IsBrightened() || aText->IsSelected() ) )
1017 return;
1018
1019 COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed );
1020
1021 if( !aText->IsVisible() )
1022 {
1023 if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
1024 color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows, aDimmed );
1025 else
1026 return;
1027 }
1028
1029 BOX2I bBox = aText->GetBoundingBox();
1030
1033
1034 if( drawingShadows && getFont( aText )->IsOutline() )
1035 {
1036 bBox.Inflate( KiROUND( getTextThickness( aText ) * 2 ) );
1037
1038 m_gal->SetIsStroke( false );
1039 m_gal->SetIsFill( true );
1040 m_gal->DrawRectangle( bBox.GetPosition(), bBox.GetEnd() );
1041 }
1042 else
1043 {
1044 wxString shownText( aText->GetShownText() );
1045 VECTOR2D pos = bBox.Centre();
1046 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
1047
1048 attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) );
1049
1050 if( drawingShadows )
1051 attrs.m_StrokeWidth += getShadowWidth( !aText->IsSelected() );
1052
1053 if( attrs.m_Angle == ANGLE_VERTICAL )
1054 {
1055 switch( attrs.m_Halign )
1056 {
1057 case GR_TEXT_H_ALIGN_LEFT: pos.y = bBox.GetBottom(); break;
1058 case GR_TEXT_H_ALIGN_CENTER: pos.y = ( bBox.GetTop() + bBox.GetBottom() ) / 2; break;
1059 case GR_TEXT_H_ALIGN_RIGHT: pos.y = bBox.GetTop(); break;
1060 }
1061 }
1062 else
1063 {
1064 switch( attrs.m_Halign )
1065 {
1066 case GR_TEXT_H_ALIGN_LEFT: pos.x = bBox.GetLeft(); break;
1067 case GR_TEXT_H_ALIGN_CENTER: pos.x = ( bBox.GetLeft() + bBox.GetRight() ) / 2; break;
1068 case GR_TEXT_H_ALIGN_RIGHT: pos.x = bBox.GetRight(); break;
1069 }
1070 }
1071
1072 // Because the text vertical position is the bounding box center, the text is drawn as
1073 // vertically centered.
1075
1076 strokeText( shownText, pos, attrs );
1077 }
1078}
coord_type GetTop() const
Definition: box2.h:194
coord_type GetRight() const
Definition: box2.h:189
coord_type GetLeft() const
Definition: box2.h:193
coord_type GetBottom() const
Definition: box2.h:190
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
bool IsPrivate() const
Definition: lib_item.h:279
const BOX2I GetBoundingBox() const override
Definition: lib_text.cpp:453

References ANGLE_VERTICAL, BOX2< Vec >::Centre(), color, KIGFX::eeconfig(), EDA_TEXT::GetAttributes(), BOX2< Vec >::GetBottom(), LIB_TEXT::GetBoundingBox(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetPosition(), BOX2< Vec >::GetRight(), EDA_TEXT::GetShownText(), BOX2< Vec >::GetTop(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, BOX2< Vec >::Inflate(), EDA_ITEM::IsBrightened(), LIB_ITEM::IsPrivate(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), KiROUND(), LAYER_HIDDEN, LAYER_SELECTION_SHADOWS, TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [7/23]

void KIGFX::SCH_PAINTER::draw ( const LIB_TEXTBOX aTextBox,
int  aLayer,
bool  aDimmed 
)
private

Definition at line 1081 of file sch_painter.cpp.

1082{
1083 if( !isUnitAndConversionShown( aTextBox ) )
1084 return;
1085
1086 if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
1087 return;
1088
1089 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1090
1091 if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) )
1092 return;
1093
1095 COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows, aDimmed );
1096 float borderWidth = getLineWidth( aTextBox, drawingShadows );
1097
1098 auto drawText =
1099 [&]()
1100 {
1101 wxString shownText = aTextBox->GetShownText();
1102 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
1103
1104 attrs.m_Angle = aTextBox->GetDrawRotation();
1105 attrs.m_StrokeWidth = KiROUND( getTextThickness( aTextBox ) );
1106
1107 strokeText( shownText, aTextBox->GetDrawPos(), attrs );
1108 };
1109
1112
1113 if( aLayer == LAYER_SELECTION_SHADOWS )
1114 {
1115 m_gal->SetIsFill( true );
1116 m_gal->SetIsStroke( false );
1117 m_gal->SetLineWidth( borderWidth );
1118
1119 m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ),
1120 mapCoords( aTextBox->GetEnd() ) );
1121 }
1122 else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
1123 {
1124 if( aTextBox->IsFilled() )
1125 {
1126 m_gal->SetIsFill( true );
1127 m_gal->SetIsStroke( false );
1128 m_gal->SetLineWidth( borderWidth );
1129
1130 m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ),
1131 mapCoords( aTextBox->GetEnd() ) );
1132 }
1133 }
1134 else if( aLayer == LAYER_DEVICE || aLayer == LAYER_PRIVATE_NOTES )
1135 {
1136 drawText();
1137
1138 if( borderWidth > 0 )
1139 {
1140 COLOR4D borderColor = aTextBox->GetStroke().GetColor();
1141 PLOT_DASH_TYPE borderStyle = aTextBox->GetStroke().GetPlotStyle();
1142
1144 || borderColor == COLOR4D::UNSPECIFIED )
1145 {
1146 borderColor = m_schSettings.GetLayerColor( aLayer );
1147 }
1148
1149 if( aDimmed )
1150 {
1151 borderColor.Desaturate( );
1152 borderColor = borderColor.Mix( bg, 0.5f );
1153 }
1154
1155 m_gal->SetIsFill( false );
1156 m_gal->SetIsStroke( true );
1157 m_gal->SetStrokeColor( borderColor );
1158 m_gal->SetLineWidth( borderWidth );
1159
1160 if( borderStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1161 {
1162 m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ),
1163 mapCoords( aTextBox->GetEnd() ) );
1164 }
1165 else
1166 {
1167 std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
1168
1169 for( SHAPE* shape : shapes )
1170 {
1171 STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ),
1173 [&]( const VECTOR2I& a, const VECTOR2I& b )
1174 {
1175 // DrawLine has problem with 0 length lines so enforce minimum
1176 if( a == b )
1177 m_gal->DrawLine( mapCoords( a+1 ), mapCoords( b ) );
1178 else
1179 m_gal->DrawLine( mapCoords( a ), mapCoords( b ) );
1180 } );
1181 }
1182
1183 for( SHAPE* shape : shapes )
1184 delete shape;
1185 }
1186 }
1187 }
1188}
bool IsFilled() const
Definition: eda_shape.h:90
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:317
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:396
COLOR4D & Desaturate()
Removes color (in HSL model)
Definition: color4d.cpp:530
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:311
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
STROKE_PARAMS GetStroke() const
Definition: lib_shape.h:52
VECTOR2I GetPosition() const override
Definition: lib_shape.h:85
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the LIB_SHAPE.
Definition: lib_shape.h:96
VECTOR2I GetDrawPos() const override
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
KIGFX::COLOR4D GetColor() const
PLOT_DASH_TYPE GetPlotStyle() const
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376

References color, KIGFX::COLOR4D::Desaturate(), FIRST_TYPE, EDA_TEXT::GetAttributes(), STROKE_PARAMS::GetColor(), LIB_TEXTBOX::GetDrawPos(), EDA_TEXT::GetDrawRotation(), EDA_SHAPE::GetEnd(), STROKE_PARAMS::GetPlotStyle(), LIB_SHAPE::GetPosition(), LIB_TEXTBOX::GetShownText(), LIB_SHAPE::GetStroke(), EDA_ITEM::IsBrightened(), EDA_SHAPE::IsFilled(), LIB_ITEM::IsPrivate(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, LAYER_NOTES_BACKGROUND, LAYER_PRIVATE_NOTES, LAYER_SCHEMATIC_BACKGROUND, LAYER_SELECTION_SHADOWS, TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_StrokeWidth, LIB_SHAPE::MakeEffectiveShapes(), KIGFX::mapCoords(), KIGFX::COLOR4D::Mix(), and STROKE_PARAMS::Stroke().

◆ draw() [8/23]

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

Definition at line 2803 of file sch_painter.cpp.

2804{
2805 m_gal->Save();
2806 m_gal->Translate( aBitmap->GetPosition() );
2807
2808 // When the image scale factor is not 1.0, we need to modify the actual as the image scale
2809 // factor is similar to a local zoom
2810 double img_scale = aBitmap->GetImageScale();
2811
2812 if( img_scale != 1.0 )
2813 m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
2814
2815 if( aLayer == LAYER_DRAW_BITMAPS )
2816 {
2817 m_gal->DrawBitmap( *aBitmap->GetImage() );
2818 }
2819
2820 if( aLayer == LAYER_SELECTION_SHADOWS )
2821 {
2822 if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
2823 {
2824 COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
2825 m_gal->SetIsStroke( true );
2827 m_gal->SetLineWidth ( getShadowWidth( aBitmap->IsBrightened() ) );
2828 m_gal->SetIsFill( false );
2829
2830 // Draws a bounding box.
2831 VECTOR2D bm_size( aBitmap->GetSize() );
2832 // bm_size is the actual image size in UI.
2833 // but m_gal scale was previously set to img_scale
2834 // so recalculate size relative to this image size.
2835 bm_size.x /= img_scale;
2836 bm_size.y /= img_scale;
2837 VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
2838 VECTOR2D end = origin + bm_size;
2839
2840 m_gal->DrawRectangle( origin, end );
2841 }
2842 }
2843
2844 m_gal->Restore();
2845}
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void Restore()
Restore the context.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void DrawBitmap(const BITMAP_BASE &aBitmap, double alphaBlend=1.0)
Draw a bitmap image.
virtual void Save()
Save the context.
double GetImageScale() const
Definition: sch_bitmap.h:66
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:136
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
VECTOR2I GetSize() const
Definition: sch_bitmap.cpp:131
@ LAYER_DRAW_BITMAPS
to handle and draw images bitmaps
Definition: layer_ids.h:223

References color, SCH_BITMAP::GetImage(), SCH_BITMAP::GetImageScale(), SCH_BITMAP::GetPosition(), SCH_BITMAP::GetSize(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsSelected(), LAYER_DRAW_BITMAPS, LAYER_SELECTION_SHADOWS, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [9/23]

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

Definition at line 2744 of file sch_painter.cpp.

2745{
2747 SCH_LINE line( VECTOR2I(), layer );
2748 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2749 bool drawingDangling = aLayer == LAYER_DANGLING;
2750
2751 if( drawingShadows && !( aEntry->IsBrightened() || aEntry->IsSelected() ) )
2752 return;
2753
2754 if( aEntry->IsSelected() )
2755 {
2756 line.SetSelected();
2757 // Never show unselected endpoints on bus entries
2758 line.SetFlags( STARTPOINT | ENDPOINT );
2759 }
2760 else if( aEntry->IsBrightened() )
2761 line.SetBrightened();
2762
2763 line.SetStartPoint( aEntry->GetPosition() );
2764 line.SetEndPoint( aEntry->GetEnd() );
2765 line.SetStroke( aEntry->GetStroke() );
2766 line.SetLineWidth( KiROUND( getLineWidth( aEntry, false ) ) );
2767
2768 COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
2769
2770 if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
2771 color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
2772
2773 if( drawingDangling )
2774 {
2775 m_gal->SetIsFill( false );
2776 m_gal->SetIsStroke( true );
2777 m_gal->SetStrokeColor( color.Brightened( 0.3 ) );
2778 m_gal->SetLineWidth( drawingShadows ? getShadowWidth( aEntry->IsBrightened() )
2780
2781 if( aEntry->IsDanglingStart() )
2782 {
2783 m_gal->DrawCircle( aEntry->GetPosition(),
2784 aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
2785 }
2786
2787 if( aEntry->IsDanglingEnd() )
2788 {
2789 m_gal->DrawCircle( aEntry->GetEnd(),
2790 aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
2791 }
2792 }
2793 else
2794 {
2795 line.SetLineColor( color );
2796 line.SetLineStyle( aEntry->GetLineStyle() );
2797
2798 draw( &line, aLayer );
2799 }
2800}
float GetDanglineSymbolThickness() const
Definition: sch_painter.h:99
PLOT_DASH_TYPE GetLineStyle() const
VECTOR2I GetPosition() const override
bool IsDanglingStart() const
Definition: sch_bus_entry.h:43
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:77
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:44
VECTOR2I GetEnd() const
virtual int GetPenWidth() const
Definition: sch_item.h:263
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:341
@ LAYER_WIRE
Definition: layer_ids.h:344
@ LAYER_BUS
Definition: layer_ids.h:345
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:31

References color, ENDPOINT, SCH_BUS_ENTRY_BASE::GetEnd(), SCH_BUS_ENTRY_BASE::GetLineStyle(), SCH_ITEM::GetPenWidth(), SCH_BUS_ENTRY_BASE::GetPosition(), SCH_BUS_ENTRY_BASE::GetStroke(), EDA_ITEM::IsBrightened(), SCH_BUS_ENTRY_BASE::IsDanglingEnd(), SCH_BUS_ENTRY_BASE::IsDanglingStart(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_BUS, LAYER_DANGLING, LAYER_SELECTION_SHADOWS, LAYER_WIRE, SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, EDA_ITEM::SetBrightened(), SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), SCH_LINE::SetLineColor(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), EDA_ITEM::SetSelected(), SCH_LINE::SetStartPoint(), SCH_LINE::SetStroke(), STARTPOINT, TARGET_BUSENTRY_RADIUS, and EDA_ITEM::Type().

◆ draw() [10/23]

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

Definition at line 2583 of file sch_painter.cpp.

2584{
2585 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2586
2587 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2588 {
2589 for( const SCH_FIELD& field : aLabel->GetFields() )
2590 draw( &field, aLayer, false );
2591 }
2592
2593 if( isFieldsLayer( aLayer ) )
2594 return;
2595
2596 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2597 return;
2598
2599 COLOR4D color = getRenderColor( aLabel, LAYER_NETCLASS_REFS, drawingShadows );
2600
2601 if( aLayer == LAYER_DANGLING )
2602 {
2603 if( aLabel->IsDangling() )
2604 {
2607 drawingShadows, aLabel->IsBrightened() );
2608 }
2609
2610 return;
2611 }
2612
2613 std::vector<VECTOR2I> pts;
2614 std::deque<VECTOR2D> pts2;
2615
2616 aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
2617
2618 for( const VECTOR2I& p : pts )
2619 pts2.emplace_back( VECTOR2D( p.x, p.y ) );
2620
2621 m_gal->SetIsFill( false );
2623 m_gal->SetIsStroke( true );
2624 m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
2626
2627 if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_DOT )
2628 {
2629 m_gal->DrawLine( pts2[0], pts2[1] );
2630 m_gal->SetIsFill( true );
2631 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
2632 }
2633 else if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_ROUND )
2634 {
2635 m_gal->DrawLine( pts2[0], pts2[1] );
2636 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
2637 }
2638 else
2639 {
2640 m_gal->DrawPolyline( pts2 );
2641 }
2642}
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
void drawDanglingSymbol(const VECTOR2I &aPos, const COLOR4D &aColor, int aWidth, bool aDangling, bool aDrawingShadows, bool aBrightened)
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_label.cpp:1102
bool IsDangling() const override
Definition: sch_label.h:177
LABEL_FLAG_SHAPE GetShape() const override
Definition: sch_label.h:73
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:90
#define DANGLING_SYMBOL_SIZE
< The size of the rectangle indicating an unconnected wire or label
@ LAYER_NETCLASS_REFS
Definition: layer_ids.h:356
static bool isFieldsLayer(int aLayer)
@ F_DOT
Definition: sch_text.h:104
@ F_ROUND
Definition: sch_text.h:105
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129

References color, SCH_DIRECTIVE_LABEL::CreateGraphicShape(), DANGLING_SYMBOL_SIZE, KIGFX::eeconfig(), EuclideanNorm(), F_DOT, F_ROUND, SCH_LABEL_BASE::GetFields(), SCH_LABEL_BASE::GetShape(), EDA_TEXT::GetTextPos(), EDA_ITEM::IsBrightened(), SCH_LABEL_BASE::IsDangling(), KIGFX::isFieldsLayer(), EDA_ITEM::IsSelected(), LAYER_DANGLING, LAYER_NETCLASS_REFS, LAYER_SELECTION_SHADOWS, EDA_IU_SCALE::MilsToIU(), and schIUScale.

◆ draw() [11/23]

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

Definition at line 2338 of file sch_painter.cpp.

2339{
2340 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2341
2342 if( drawingShadows && !( aField->IsBrightened() || aField->IsSelected() ) )
2343 return;
2344
2345 if( !drawingShadows && aField->GetLayer() != aLayer )
2346 return;
2347
2348 aLayer = aField->GetLayer();
2349
2350 COLOR4D color = getRenderColor( aField, aLayer, drawingShadows, aDimmed );
2351
2352 if( !( aField->IsVisible() || aField->IsForceVisible() ) )
2353 {
2354 if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
2355 color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows, aDimmed );
2356 else
2357 return;
2358 }
2359
2360 wxString shownText = aField->GetShownText();
2361
2362 if( shownText.IsEmpty() )
2363 return;
2364
2365 if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children )
2366 return;
2367
2368 // Calculate the text orientation according to the parent orientation.
2369 EDA_ANGLE orient = aField->GetTextAngle();
2370
2371 if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
2372 {
2373 if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 )
2374 {
2375 // Rotate symbol 90 degrees.
2376 if( orient.IsHorizontal() )
2377 orient = ANGLE_VERTICAL;
2378 else
2379 orient = ANGLE_HORIZONTAL;
2380 }
2381 }
2382
2383 /*
2384 * Calculate the text justification, according to the symbol orientation/mirror.
2385 * This is a bit complicated due to cumulative calculations:
2386 * - numerous cases (mirrored or not, rotation)
2387 * - the DrawGraphicText function recalculate also H and H justifications according to the
2388 * text orientation.
2389 * - when symbol is mirrored, the text is not mirrored and justifications are complicated
2390 * to calculate so the easier way is to use no justifications (centered text) and use
2391 * GetBoundingBox to know the text coordinate considered as centered
2392 */
2393 BOX2I bbox = aField->GetBoundingBox();
2394
2395 if( aField->GetParent() && aField->GetParent()->Type() == SCH_GLOBAL_LABEL_T )
2396 {
2397 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( aField->GetParent() );
2398 bbox.Offset( label->GetSchematicTextOffset( &m_schSettings ) );
2399 }
2400
2403
2404 if( drawingShadows && getFont( aField )->IsOutline() )
2405 {
2406 BOX2I shadow_box = bbox;
2407 shadow_box.Inflate( KiROUND( getTextThickness( aField ) * 2 ) );
2408 shadow_box.RevertYAxis();
2409
2410 m_gal->SetIsStroke( false );
2411 m_gal->SetIsFill( true );
2412 m_gal->DrawRectangle( mapCoords( shadow_box.GetPosition() ), mapCoords( shadow_box.GetEnd() ) );
2413 }
2414 else
2415 {
2416 VECTOR2I textpos = bbox.Centre();
2417 TEXT_ATTRIBUTES attributes = aField->GetAttributes();
2418
2419 attributes.m_Halign = GR_TEXT_H_ALIGN_CENTER;
2420 attributes.m_Valign = GR_TEXT_V_ALIGN_CENTER;
2421 attributes.m_StrokeWidth = KiROUND( getTextThickness( aField ) );
2422 attributes.m_Angle = orient;
2423
2424 if( drawingShadows )
2425 attributes.m_StrokeWidth += getShadowWidth( !aField->IsSelected() );
2426
2427 if( aField->IsHypertext() && aField->IsRollover() )
2428 {
2431 attributes.m_Underlined = true;
2432 }
2433
2434 if( nonCached( aField ) && aField->RenderAsBitmap( m_gal->GetWorldScale() ) )
2435 {
2436 bitmapText( shownText, textpos, attributes );
2437 const_cast<SCH_FIELD*>( aField )->SetFlags( IS_SHOWN_AS_BITMAP );
2438 }
2439 else
2440 {
2441 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2442
2443 if( !aField->IsHypertext() )
2444 cache = aField->GetRenderCache( shownText, textpos, attributes );
2445
2446 if( cache )
2447 {
2448 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
2449 m_gal->DrawGlyph( *glyph );
2450 }
2451 else
2452 {
2453 strokeText( shownText, textpos, attributes );
2454 }
2455
2456 const_cast<SCH_FIELD*>( aField )->ClearFlags( IS_SHOWN_AS_BITMAP );
2457 }
2458 }
2459
2460 // Draw the umbilical line
2461 if( aField->IsMoving() )
2462 {
2463 VECTOR2I parentPos = aField->GetParentPosition();
2464
2466 m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
2467 m_gal->DrawLine( bbox.Centre(), parentPos );
2468 }
2469}
void Offset(coord_type dx, coord_type dy)
Definition: box2.h:224
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: box2.h:689
bool IsHorizontal() const
Definition: eda_angle.h:174
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
bool IsRollover() const
Definition: eda_item.h:110
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual void DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth=0, int aTotal=1)
Draw a polygon representing a font glyph.
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:175
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:448
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.h:95
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) const
Definition: sch_field.cpp:276
VECTOR2I GetParentPosition() const
Definition: sch_field.cpp:1077
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Definition: sch_label.cpp:1259
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:246
bool RenderAsBitmap(double aWorldScale) const override
Definition: sch_item.cpp:294
TRANSFORM & GetTransform()
Definition: sch_symbol.h:283
int y1
Definition: transform.h:50
@ LAYER_HOVERED
Definition: layer_ids.h:378

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, BOX2< Vec >::Centre(), color, KIGFX::eeconfig(), EDA_TEXT::GetAttributes(), SCH_FIELD::GetBoundingBox(), BOX2< Vec >::GetEnd(), SCH_ITEM::GetLayer(), EDA_ITEM::GetParent(), SCH_FIELD::GetParentPosition(), BOX2< Vec >::GetPosition(), SCH_FIELD::GetRenderCache(), SCH_GLOBALLABEL::GetSchematicTextOffset(), SCH_FIELD::GetShownText(), EDA_TEXT::GetTextAngle(), SCH_SYMBOL::GetTransform(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, BOX2< Vec >::Inflate(), IS_SHOWN_AS_BITMAP, EDA_ITEM::IsBrightened(), EDA_ITEM::IsForceVisible(), EDA_ANGLE::IsHorizontal(), SCH_FIELD::IsHypertext(), EDA_ITEM::IsMoving(), EDA_ITEM::IsRollover(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), KiROUND(), LAYER_HIDDEN, LAYER_HOVERED, LAYER_SCHEMATIC_ANCHOR, LAYER_SELECTION_SHADOWS, TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Underlined, TEXT_ATTRIBUTES::m_Valign, KIGFX::mapCoords(), BOX2< Vec >::Offset(), SCH_ITEM::RenderAsBitmap(), BOX2< Vec >::RevertYAxis(), SCH_GLOBAL_LABEL_T, SCH_SYMBOL_T, EDA_ITEM::Type(), and TRANSFORM::y1.

◆ draw() [12/23]

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

Definition at line 2472 of file sch_painter.cpp.

2473{
2474 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2475
2476 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2477 {
2478 for( const SCH_FIELD& field : aLabel->GetFields() )
2479 draw( &field, aLayer, false );
2480 }
2481
2482 if( isFieldsLayer( aLayer ) )
2483 return;
2484
2485 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2486 return;
2487
2488 COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
2489
2490 std::vector<VECTOR2I> pts;
2491 std::deque<VECTOR2D> pts2;
2492
2493 aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
2494
2495 for( const VECTOR2I& p : pts )
2496 pts2.emplace_back( VECTOR2D( p.x, p.y ) );
2497
2498 // The text is drawn inside the graphic shape.
2499 // On Cairo the graphic shape is filled by the background before drawing the text.
2500 // However if the text is selected, it is draw twice: first on LAYER_SELECTION_SHADOWS
2501 // and second on the text layer. The second must not erase the first drawing.
2502 bool fillBg = ( ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected() )
2503 && aLayer != LAYER_DANGLING;
2504 m_gal->SetIsFill( fillBg );
2506 m_gal->SetIsStroke( true );
2507 m_gal->SetLineWidth( getTextThickness( aLabel ) );
2509 m_gal->DrawPolyline( pts2 );
2510
2511 draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
2512}
void CreateGraphicShape(const RENDER_SETTINGS *aRenderSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_label.cpp:1435
@ LAYER_GLOBLABEL
Definition: layer_ids.h:348

References color, SCH_GLOBALLABEL::CreateGraphicShape(), KIGFX::eeconfig(), SCH_LABEL_BASE::GetFields(), EDA_TEXT::GetTextPos(), EDA_ITEM::IsBrightened(), KIGFX::isFieldsLayer(), EDA_ITEM::IsSelected(), LAYER_DANGLING, LAYER_GLOBLABEL, LAYER_SCHEMATIC_BACKGROUND, and LAYER_SELECTION_SHADOWS.

◆ draw() [13/23]

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

Definition at line 2535 of file sch_painter.cpp.

2536{
2537 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2538
2539 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2540 {
2541 for( const SCH_FIELD& field : aLabel->GetFields() )
2542 draw( &field, aLayer, false );
2543 }
2544
2545 if( isFieldsLayer( aLayer ) )
2546 return;
2547
2548 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2549 return;
2550
2551 COLOR4D color = getRenderColor( aLabel, LAYER_HIERLABEL, drawingShadows );
2552
2553 if( m_schematic )
2554 {
2555 SCH_CONNECTION* conn = nullptr;
2556
2557 if( !aLabel->IsConnectivityDirty() )
2558 conn = aLabel->Connection();
2559
2560 if( conn && conn->IsBus() )
2561 color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
2562 }
2563
2564 std::vector<VECTOR2I> pts;
2565 std::deque<VECTOR2D> pts2;
2566
2567 aLabel->CreateGraphicShape( &m_schSettings, pts, (VECTOR2I)aLabel->GetTextPos() );
2568
2569 for( const VECTOR2I& p : pts )
2570 pts2.emplace_back( VECTOR2D( p.x, p.y ) );
2571
2572 m_gal->SetIsFill( true );
2574 m_gal->SetIsStroke( true );
2575 m_gal->SetLineWidth( getTextThickness( aLabel ) );
2577 m_gal->DrawPolyline( pts2 );
2578
2579 draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
2580}
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool IsBus() const
void CreateGraphicShape(const RENDER_SETTINGS *aSettings, std::vector< VECTOR2I > &aPoints, const VECTOR2I &aPos) const override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_label.cpp:1531
bool IsConnectivityDirty() const
Definition: sch_item.h:413
@ LAYER_HIERLABEL
Definition: layer_ids.h:349

References color, SCH_ITEM::Connection(), SCH_HIERLABEL::CreateGraphicShape(), KIGFX::eeconfig(), SCH_LABEL_BASE::GetFields(), EDA_TEXT::GetTextPos(), EDA_ITEM::IsBrightened(), SCH_CONNECTION::IsBus(), SCH_ITEM::IsConnectivityDirty(), KIGFX::isFieldsLayer(), EDA_ITEM::IsSelected(), LAYER_BUS, LAYER_HIERLABEL, LAYER_SCHEMATIC_BACKGROUND, and LAYER_SELECTION_SHADOWS.

◆ draw() [14/23]

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

Definition at line 1682 of file sch_painter.cpp.

1683{
1684 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1685
1686 if( drawingShadows && !( aJct->IsBrightened() || aJct->IsSelected() ) )
1687 return;
1688
1689 COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows );
1690
1691 int junctionSize = aJct->GetEffectiveDiameter() / 2;
1692
1693 if( junctionSize > 1 )
1694 {
1695 m_gal->SetIsStroke( drawingShadows );
1696 m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1698 m_gal->SetIsFill( !drawingShadows );
1700 m_gal->DrawCircle( aJct->GetPosition(), junctionSize );
1701 }
1702}
int GetEffectiveDiameter() const
VECTOR2I GetPosition() const override
Definition: sch_junction.h:102

References color, SCH_JUNCTION::GetEffectiveDiameter(), SCH_ITEM::GetLayer(), SCH_JUNCTION::GetPosition(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsSelected(), and LAYER_SELECTION_SHADOWS.

◆ draw() [15/23]

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

Definition at line 2515 of file sch_painter.cpp.

2516{
2517 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2518
2519 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2520 {
2521 for( const SCH_FIELD& field : aLabel->GetFields() )
2522 draw( &field, aLayer, false );
2523 }
2524
2525 if( isFieldsLayer( aLayer ) )
2526 return;
2527
2528 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2529 return;
2530
2531 draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer );
2532}

References KIGFX::eeconfig(), SCH_LABEL_BASE::GetFields(), EDA_ITEM::IsBrightened(), KIGFX::isFieldsLayer(), EDA_ITEM::IsSelected(), and LAYER_SELECTION_SHADOWS.

◆ draw() [16/23]

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

Definition at line 1705 of file sch_painter.cpp.

1706{
1707 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1708 bool drawingDangling = aLayer == LAYER_DANGLING;
1709
1710 if( drawingShadows && !( aLine->IsBrightened() || aLine->IsSelected() ) )
1711 return;
1712
1713 // Line end dangling status isn't updated until the line is finished drawing,
1714 // so don't warn them about ends that are probably connected
1715 if( aLine->IsNew() && drawingDangling )
1716 return;
1717
1718 COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1719 float width = getLineWidth( aLine, drawingShadows );
1720 PLOT_DASH_TYPE lineStyle = aLine->GetEffectiveLineStyle();
1721
1722 if( ( drawingDangling || drawingShadows ) && !aLine->IsNew() )
1723 {
1724 if( ( aLine->IsWire() && aLine->IsStartDangling() )
1725 || ( drawingShadows && aLine->IsSelected() && !aLine->HasFlag( STARTPOINT ) ) )
1726 {
1727 COLOR4D danglingColor =
1728 ( drawingShadows && !aLine->HasFlag( STARTPOINT ) ) ? color.Inverted() : color;
1729 drawDanglingSymbol( aLine->GetStartPoint(), danglingColor,
1730 KiROUND( getLineWidth( aLine, drawingShadows ) ),
1731 aLine->IsWire() && aLine->IsStartDangling(), drawingShadows,
1732 aLine->IsBrightened() );
1733 }
1734
1735 if( ( aLine->IsWire() && aLine->IsEndDangling() )
1736 || ( drawingShadows && aLine->IsSelected() && !aLine->HasFlag( ENDPOINT ) ) )
1737 {
1738 COLOR4D danglingColor =
1739 ( drawingShadows && !aLine->HasFlag( ENDPOINT ) ) ? color.Inverted() : color;
1740 drawDanglingSymbol( aLine->GetEndPoint(), danglingColor,
1741 KiROUND( getLineWidth( aLine, drawingShadows ) ),
1742 aLine->IsWire() && aLine->IsEndDangling(), drawingShadows,
1743 aLine->IsBrightened() );
1744 }
1745 }
1746
1747 if( drawingDangling )
1748 return;
1749
1750 m_gal->SetIsStroke( true );
1752 m_gal->SetLineWidth( width );
1753
1754 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1755 {
1756 m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1757 }
1758 else
1759 {
1760 SHAPE_SEGMENT line( aLine->GetStartPoint(), aLine->GetEndPoint() );
1761
1762 STROKE_PARAMS::Stroke( &line, lineStyle, KiROUND( width ), &m_schSettings,
1763 [&]( const VECTOR2I& a, const VECTOR2I& b )
1764 {
1765 // DrawLine has problem with 0 length lines
1766 // so draw a line with a minimal length
1767 if( a == b )
1768 m_gal->DrawLine( a+1, b );
1769 else
1770 m_gal->DrawLine( a, b );
1771 } );
1772 }
1773}
bool IsNew() const
Definition: eda_item.h:103
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:937
bool IsStartDangling() const
Definition: sch_line.h:257
VECTOR2I GetEndPoint() const
Definition: sch_line.h:143
VECTOR2I GetStartPoint() const
Definition: sch_line.h:138
bool IsEndDangling() const
Definition: sch_line.h:258
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Definition: sch_line.cpp:272

References color, ENDPOINT, FIRST_TYPE, SCH_LINE::GetEffectiveLineStyle(), SCH_LINE::GetEndPoint(), SCH_ITEM::GetLayer(), SCH_LINE::GetStartPoint(), EDA_ITEM::HasFlag(), EDA_ITEM::IsBrightened(), SCH_LINE::IsEndDangling(), EDA_ITEM::IsNew(), EDA_ITEM::IsSelected(), SCH_LINE::IsStartDangling(), SCH_LINE::IsWire(), KiROUND(), LAYER_DANGLING, LAYER_SELECTION_SHADOWS, STARTPOINT, and STROKE_PARAMS::Stroke().

◆ draw() [17/23]

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

Definition at line 2848 of file sch_painter.cpp.

2849{
2850 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2851
2852 if( drawingShadows && !( aMarker->IsBrightened() || aMarker->IsSelected() ) )
2853 return;
2854
2855 COLOR4D color = getRenderColor( aMarker, aMarker->GetColorLayer(), drawingShadows );
2856
2857 m_gal->Save();
2858 m_gal->Translate( aMarker->GetPosition() );
2859 m_gal->SetIsFill( !drawingShadows );
2861 m_gal->SetIsStroke( drawingShadows );
2862 m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
2864
2865 SHAPE_LINE_CHAIN polygon;
2866 aMarker->ShapeToPolygon( polygon );
2867
2868 m_gal->DrawPolygon( polygon );
2869 m_gal->Restore();
2870}
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
SCH_LAYER_ID GetColorLayer() const
Definition: sch_marker.cpp:209
VECTOR2I GetPosition() const override
Definition: sch_marker.h:104

References color, SCH_MARKER::GetColorLayer(), SCH_MARKER::GetPosition(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsSelected(), LAYER_SELECTION_SHADOWS, and MARKER_BASE::ShapeToPolygon().

◆ draw() [18/23]

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

Definition at line 2724 of file sch_painter.cpp.

2725{
2726 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2727
2728 if( drawingShadows && !( aNC->IsBrightened() || aNC->IsSelected() ) )
2729 return;
2730
2731 m_gal->SetIsStroke( true );
2732 m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
2733 m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
2734 m_gal->SetIsFill( false );
2735
2736 VECTOR2D p = aNC->GetPosition();
2737 int delta = std::max( aNC->GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
2738
2739 m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
2740 m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
2741}
int GetSize() const
VECTOR2I GetPosition() const override
@ LAYER_NOCONNECT
Definition: layer_ids.h:367
constexpr int delta

References delta, SCH_NO_CONNECT::GetPosition(), SCH_NO_CONNECT::GetSize(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsSelected(), LAYER_NOCONNECT, and LAYER_SELECTION_SHADOWS.

◆ draw() [19/23]

void KIGFX::SCH_PAINTER::draw ( const SCH_SHAPE aShape,
int  aLayer 
)
private

Definition at line 1776 of file sch_painter.cpp.

1777{
1778 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1779 PLOT_DASH_TYPE lineStyle = aShape->GetEffectiveLineStyle();
1780 COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows );
1781
1782 if( drawingShadows && !( aShape->IsBrightened() || aShape->IsSelected() ) )
1783 return;
1784
1785 auto drawShape =
1786 [&]( const SCH_SHAPE* shape )
1787 {
1788 switch( shape->GetShape() )
1789 {
1790 case SHAPE_T::ARC:
1791 {
1792 EDA_ANGLE startAngle;
1793 EDA_ANGLE endAngle;
1794 aShape->CalcArcAngles( startAngle, endAngle );
1795
1796 m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(), startAngle,
1797 endAngle );
1798 break;
1799 }
1800
1801 case SHAPE_T::CIRCLE:
1802 m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() );
1803 break;
1804
1805 case SHAPE_T::RECT:
1806 m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() );
1807 break;
1808
1809 case SHAPE_T::POLY:
1810 {
1811 std::deque<VECTOR2D> pts;
1812
1813 for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
1814 pts.push_back( pt );
1815
1816 m_gal->DrawPolygon( pts );
1817 break;
1818 }
1819
1820 case SHAPE_T::BEZIER:
1821 {
1822 std::deque<VECTOR2D> pts;
1823
1824 for( const VECTOR2I &p : shape->GetPolyShape().Outline( 0 ).CPoints() )
1825 pts.push_back( p );
1826
1827 m_gal->DrawPolygon( pts );
1828 break;
1829 }
1830
1831 default:
1832 UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() );
1833 }
1834 };
1835
1836 if( aLayer == LAYER_SELECTION_SHADOWS )
1837 {
1838 if( eeconfig()->m_Selection.fill_shapes )
1839 {
1840 // Consider a NAND gate. We have no idea which side of the arc is "inside"
1841 // so we can't reliably fill.
1842 if( aShape->GetShape() == SHAPE_T::ARC )
1843 m_gal->SetIsFill( aShape->IsFilled() );
1844 else
1845 m_gal->SetIsFill( true );
1846
1847 m_gal->SetIsStroke( false );
1849 }
1850 else
1851 {
1852 m_gal->SetIsStroke( true );
1853 m_gal->SetIsFill( false );
1854 m_gal->SetLineWidth( getLineWidth( aShape, true ) );
1856 }
1857
1858 drawShape( aShape );
1859 }
1860 else if( aLayer == LAYER_NOTES_BACKGROUND )
1861 {
1862 if( aShape->IsFilled() )
1863 {
1864 m_gal->SetIsFill( true );
1865 m_gal->SetIsStroke( false );
1867
1868 drawShape( aShape );
1869 }
1870 }
1871 else if( aLayer == LAYER_NOTES )
1872 {
1873 float lineWidth = getLineWidth( aShape, drawingShadows );
1874
1875 if( lineWidth > 0 )
1876 {
1877 m_gal->SetIsFill( false );
1878 m_gal->SetIsStroke( true );
1879 m_gal->SetLineWidth( lineWidth );
1881
1882 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1883 {
1884 drawShape( aShape );
1885 }
1886 else
1887 {
1888 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1889
1890 for( SHAPE* shape : shapes )
1891 {
1892 STROKE_PARAMS::Stroke( shape, lineStyle, KiROUND( lineWidth ), &m_schSettings,
1893 [&]( const VECTOR2I& a, const VECTOR2I& b )
1894 {
1895 // DrawLine has problem with 0 length lines so enforce minimum
1896 if( a == b )
1897 m_gal->DrawLine( a+1, b );
1898 else
1899 m_gal->DrawLine( a, b );
1900 } );
1901 }
1902
1903 for( SHAPE* shape : shapes )
1904 delete shape;
1905 }
1906 }
1907 }
1908}
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:289
void CalcArcAngles(EDA_ANGLE &aStartAngle, EDA_ANGLE &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:502
int GetRadius() const
Definition: eda_shape.cpp:523
SHAPE_T GetShape() const
Definition: eda_shape.h:113
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Definition: sch_shape.h:67
VECTOR2I GetCenter() const
Definition: sch_shape.h:80
@ LAYER_NOTES
Definition: layer_ids.h:358

References ARC, BEZIER, EDA_SHAPE::CalcArcAngles(), CIRCLE, color, KIGFX::eeconfig(), FIRST_TYPE, SCH_SHAPE::GetCenter(), SCH_SHAPE::GetEffectiveLineStyle(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), EDA_ITEM::IsBrightened(), EDA_SHAPE::IsFilled(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_NOTES, LAYER_NOTES_BACKGROUND, LAYER_SELECTION_SHADOWS, EDA_SHAPE::MakeEffectiveShapes(), POLY, RECT, STROKE_PARAMS::Stroke(), and UNIMPLEMENTED_FOR.

◆ draw() [20/23]

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

Definition at line 2645 of file sch_painter.cpp.

2646{
2647 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2648
2649 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2650 {
2651 for( const SCH_FIELD& field : aSheet->GetFields() )
2652 draw( &field, aLayer, false );
2653 }
2654
2655 if( isFieldsLayer( aLayer ) )
2656 return;
2657
2658 if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS )
2659 {
2660 for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
2661 {
2662 if( drawingShadows )
2663 {
2664 if( ( aSheet->IsBrightened() || aSheet->IsSelected() )
2665 && eeconfig()->m_Selection.draw_selected_children )
2666 {
2667 // fall through to draw
2668 }
2669 else if( sheetPin->IsBrightened() || sheetPin->IsSelected() )
2670 {
2671 // fall through to draw
2672 }
2673 else
2674 {
2675 continue;
2676 }
2677 }
2678
2679 int width = std::max( aSheet->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
2680 VECTOR2I initial_pos = sheetPin->GetTextPos();
2681 VECTOR2I offset_pos = initial_pos;
2682
2683 // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
2684 switch( sheetPin->GetSide() )
2685 {
2686 case SHEET_SIDE::TOP: offset_pos.y += KiROUND( width / 2.0 ); break;
2687 case SHEET_SIDE::BOTTOM: offset_pos.y -= KiROUND( width / 2.0 ); break;
2688 case SHEET_SIDE::RIGHT: offset_pos.x -= KiROUND( width / 2.0 ); break;
2689 case SHEET_SIDE::LEFT: offset_pos.x += KiROUND( width / 2.0 ); break;
2690 default: break;
2691 }
2692
2693 sheetPin->SetTextPos( offset_pos );
2694 draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
2695 m_gal->DrawLine( offset_pos, initial_pos );
2696 sheetPin->SetTextPos( initial_pos );
2697 }
2698 }
2699
2700 VECTOR2D pos = aSheet->GetPosition();
2701 VECTOR2D size = aSheet->GetSize();
2702
2703 if( aLayer == LAYER_SHEET_BACKGROUND )
2704 {
2706 m_gal->SetIsFill( true );
2707 m_gal->SetIsStroke( false );
2708
2709 m_gal->DrawRectangle( pos, pos + size );
2710 }
2711
2712 if( aLayer == LAYER_SHEET || aLayer == LAYER_SELECTION_SHADOWS )
2713 {
2714 m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
2715 m_gal->SetIsStroke( true );
2716 m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
2717 m_gal->SetIsFill( false );
2718
2719 m_gal->DrawRectangle( pos, pos + size );
2720 }
2721}
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
int GetPenWidth() const override
Definition: sch_sheet.cpp:594
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
VECTOR2I GetPosition() const override
Definition: sch_sheet.h:368
wxSize GetSize() const
Definition: sch_sheet.h:108
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:175
@ LAYER_SHEET_BACKGROUND
Definition: layer_ids.h:373
@ LAYER_SHEET
Definition: layer_ids.h:362

References BOTTOM, KIGFX::eeconfig(), SCH_SHEET::GetFields(), SCH_SHEET::GetPenWidth(), SCH_SHEET::GetPins(), SCH_SHEET::GetPosition(), SCH_SHEET::GetSize(), EDA_ITEM::IsBrightened(), KIGFX::isFieldsLayer(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_HIERLABEL, LAYER_SELECTION_SHADOWS, LAYER_SHEET, LAYER_SHEET_BACKGROUND, LEFT, RIGHT, TOP, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ draw() [21/23]

void KIGFX::SCH_PAINTER::draw ( const SCH_SYMBOL aSymbol,
int  aLayer 
)
private

Definition at line 2227 of file sch_painter.cpp.

2228{
2229 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2230
2231 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2232 {
2233 for( const SCH_FIELD& field : aSymbol->GetFields() )
2234 draw( &field, aLayer, aSymbol->GetDNP() );
2235 }
2236
2237 if( isFieldsLayer( aLayer ) )
2238 return;
2239
2240 if( drawingShadows && !( aSymbol->IsBrightened() || aSymbol->IsSelected() ) )
2241 {
2242 // Don't exit here; symbol may still have selected pins
2243 // return;
2244 }
2245
2246 int unit = aSymbol->GetUnitSelection( &m_schematic->CurrentSheet() );
2247 int convert = aSymbol->GetConvert();
2248
2249 // Use dummy symbol if the actual couldn't be found (or couldn't be locked).
2250 LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ?
2251 aSymbol->GetLibSymbolRef().get() : dummy();
2252 LIB_PINS originalPins;
2253 originalSymbol->GetPins( originalPins, unit, convert );
2254
2255 // Copy the source so we can re-orient and translate it.
2256 LIB_SYMBOL tempSymbol( *originalSymbol );
2257 LIB_PINS tempPins;
2258 tempSymbol.GetPins( tempPins, unit, convert );
2259
2260 tempSymbol.SetFlags( aSymbol->GetFlags() );
2261
2262 orientSymbol( &tempSymbol, aSymbol->GetOrientation() );
2263
2264 for( LIB_ITEM& tempItem : tempSymbol.GetDrawItems() )
2265 {
2266 tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
2267 tempItem.MoveTo( tempItem.GetPosition() + (VECTOR2I) mapCoords( aSymbol->GetPosition() ) );
2268
2269 if( tempItem.Type() == LIB_TEXT_T )
2270 {
2271 LIB_TEXT* textItem = static_cast<LIB_TEXT*>( &tempItem );
2272
2273 if( textItem->HasTextVars() )
2274 textItem->SetText( expandLibItemTextVars( textItem->GetText(), aSymbol ) );
2275 }
2276 else if( tempItem.Type() == LIB_TEXTBOX_T )
2277 {
2278 LIB_TEXTBOX* textboxItem = static_cast<LIB_TEXTBOX*>( &tempItem );
2279
2280 if( textboxItem->HasTextVars() )
2281 textboxItem->SetText( expandLibItemTextVars( textboxItem->GetText(), aSymbol ) );
2282 }
2283 }
2284
2285 // Copy the pin info from the symbol to the temp pins
2286 for( unsigned i = 0; i < tempPins.size(); ++ i )
2287 {
2288 SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
2289 LIB_PIN* tempPin = tempPins[ i ];
2290
2291 tempPin->ClearFlags();
2292 tempPin->SetFlags( symbolPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
2293 // IS_SHOWN_AS_BITMAP
2294
2295 tempPin->SetName( symbolPin->GetShownName() );
2296 tempPin->SetType( symbolPin->GetType() );
2297 tempPin->SetShape( symbolPin->GetShape() );
2298
2299 if( symbolPin->IsDangling() )
2300 tempPin->SetFlags( IS_DANGLING );
2301 else
2302 tempPin->ClearFlags( IS_DANGLING );
2303 }
2304
2305 draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert(), aSymbol->GetDNP() );
2306
2307 for( unsigned i = 0; i < tempPins.size(); ++i )
2308 {
2309 SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
2310 LIB_PIN* tempPin = tempPins[ i ];
2311
2312 symbolPin->ClearFlags();
2313 tempPin->ClearFlags( IS_DANGLING ); // Clear this temporary flag
2314 symbolPin->SetFlags( tempPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
2315 // IS_SHOWN_AS_BITMAP
2316 }
2317
2318 if( aSymbol->GetDNP() )
2319 {
2320 BOX2I bbox = aSymbol->GetBodyAndPinsBoundingBox();
2321
2322 m_gal->SetIsStroke( true );
2323 m_gal->SetIsFill( true );
2324 COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
2325
2328
2329 m_gal->DrawSegment( bbox.GetOrigin(), bbox.GetEnd(),
2331 m_gal->DrawSegment( bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
2332 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
2334 }
2335}
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:142
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:103
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition: lib_pin.h:78
void SetName(const wxString &aName)
Definition: lib_pin.h:114
void SetType(ELECTRICAL_PINTYPE aType)
Definition: lib_pin.h:91
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:834
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:122
bool IsDangling() const override
Definition: sch_pin.h:103
wxString GetShownName() const
Definition: sch_pin.cpp:94
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:126
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:117
int GetUnit() const
Definition: sch_symbol.h:228
int GetConvert() const
Definition: sch_symbol.h:270
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:712
int GetOrientation() const
Get the display symbol orientation.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:771
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:879
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:192
bool GetDNP() const
Definition: sch_symbol.h:753
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
@ LAYER_ERC_ERR
Definition: layer_ids.h:370
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:54
static LIB_SYMBOL * dummy()
Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
static void orientSymbol(LIB_SYMBOL *symbol, int orientation)
wxString expandLibItemTextVars(const wxString &aSourceText, const SCH_SYMBOL *aSymbolContext)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References EDA_ITEM::ClearFlags(), convert, DEFAULT_LINE_WIDTH_MILS, dummy, KIGFX::eeconfig(), KIGFX::expandLibItemTextVars(), SCH_SYMBOL::GetBodyAndPinsBoundingBox(), COLOR_SETTINGS::GetColor(), SCH_SYMBOL::GetConvert(), SCH_SYMBOL::GetDNP(), LIB_SYMBOL::GetDrawItems(), BOX2< Vec >::GetEnd(), SCH_SYMBOL::GetFields(), EDA_ITEM::GetFlags(), BOX2< Vec >::GetHeight(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SYMBOL::GetOrientation(), BOX2< Vec >::GetOrigin(), SCH_SYMBOL::GetPin(), LIB_SYMBOL::GetPins(), SCH_SYMBOL::GetPosition(), SCH_PIN::GetShape(), SCH_PIN::GetShownName(), EDA_TEXT::GetText(), SCH_PIN::GetType(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitSelection(), BOX2< Vec >::GetWidth(), EDA_TEXT::HasTextVars(), IS_DANGLING, EDA_ITEM::IsBrightened(), SCH_PIN::IsDangling(), KIGFX::isFieldsLayer(), EDA_ITEM::IsSelected(), LAYER_ERC_ERR, LAYER_SELECTION_SHADOWS, LIB_TEXT_T, LIB_TEXTBOX_T, KIGFX::mapCoords(), EDA_IU_SCALE::MilsToIU(), KIGFX::orientSymbol(), Pgm(), schIUScale, EDA_ITEM::SetFlags(), LIB_PIN::SetName(), LIB_PIN::SetShape(), EDA_TEXT::SetText(), and LIB_PIN::SetType().

◆ draw() [22/23]

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

Definition at line 1911 of file sch_painter.cpp.

1912{
1913 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1914 bool drawingDangling = aLayer == LAYER_DANGLING;
1915
1916 if( drawingShadows && !( aText->IsBrightened() || aText->IsSelected() ) )
1917 return;
1918
1919 switch( aText->Type() )
1920 {
1921 case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1922 case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1923 case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1924 case SCH_DIRECTIVE_LABEL_T: aLayer = LAYER_NETCLASS_REFS; break;
1925 case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1926 default: aLayer = LAYER_NOTES; break;
1927 }
1928
1929 COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1930
1931 if( m_schematic )
1932 {
1933 SCH_CONNECTION* conn = nullptr;
1934
1935 if( !aText->IsConnectivityDirty() )
1936 conn = aText->Connection();
1937
1938 if( conn && conn->IsBus() )
1939 color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1940 }
1941
1942 if( !( aText->IsVisible() || aText->IsForceVisible() ) )
1943 {
1944 if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields )
1945 color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1946 else
1947 return;
1948 }
1949
1950 if( drawingDangling )
1951 {
1952 if( aText->IsDangling() )
1953 {
1956 drawingShadows, aText->IsBrightened() );
1957 }
1958
1959 return;
1960 }
1961
1964
1965 wxString shownText( aText->GetShownText() );
1966 VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings );
1967 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
1968 KIFONT::FONT* font = getFont( aText );
1969
1970 attrs.m_Angle = aText->GetDrawRotation();
1971 attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) );
1972
1973 if( drawingShadows && !font->IsOutline() )
1974 {
1975 m_gal->SetIsFill( false );
1976 m_gal->SetIsStroke( true );
1977 attrs.m_StrokeWidth += getShadowWidth( !aText->IsSelected() );
1978 attrs.m_Underlined = false;
1979 strokeText( shownText, aText->GetDrawPos() + text_offset, attrs );
1980
1981 }
1982 else if( drawingShadows )
1983 {
1984 BOX2I bBox = aText->GetBoundingBox();
1985 bBox.Inflate( KiROUND( getTextThickness( aText ) * 2 ) );
1986 bBox.RevertYAxis();
1987
1988 m_gal->SetIsStroke( false );
1989 m_gal->SetIsFill( true );
1990 m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1991 }
1992 else
1993 {
1994 if( aText->IsHypertext() && aText->IsRollover() )
1995 {
1998 attrs.m_Underlined = true;
1999 }
2000
2001 // Adjust text drawn in an outline font to more closely mimic the positioning of
2002 // SCH_FIELD text.
2003 if( font->IsOutline() && aText->Type() == SCH_TEXT_T )
2004 {
2005 BOX2I firstLineBBox = aText->GetTextBox( 0 );
2006 int sizeDiff = firstLineBBox.GetHeight() - aText->GetTextSize().y;
2007 int adjust = KiROUND( sizeDiff * 0.4 );
2008 VECTOR2I adjust_offset( 0, - adjust );
2009
2010 RotatePoint( adjust_offset, aText->GetDrawRotation() );
2011 text_offset += adjust_offset;
2012 }
2013
2014 if( nonCached( aText )
2015 && aText->RenderAsBitmap( m_gal->GetWorldScale() )
2016 && !shownText.Contains( wxT( "\n" ) ) )
2017 {
2018 bitmapText( shownText, aText->GetDrawPos() + text_offset, attrs );
2019 const_cast<SCH_TEXT*>( aText )->SetFlags( IS_SHOWN_AS_BITMAP );
2020 }
2021 else
2022 {
2023 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2024
2025 if( !aText->IsHypertext() && font->IsOutline() )
2026 cache = aText->GetRenderCache( font, shownText, text_offset );
2027
2028 if( cache )
2029 {
2030 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
2031 m_gal->DrawGlyph( *glyph );
2032 }
2033 else
2034 {
2035 strokeText( shownText, aText->GetDrawPos() + text_offset, attrs );
2036 }
2037
2038 const_cast<SCH_TEXT*>( aText )->ClearFlags( IS_SHOWN_AS_BITMAP );
2039 }
2040 }
2041}
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:503
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
Definition: eda_text.cpp:451
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:318
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
virtual bool IsDangling() const
Definition: sch_item.h:342
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_text.h:133
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:342
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:321
virtual VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Definition: sch_text.cpp:134
@ LAYER_SHEETLABEL
Definition: layer_ids.h:366
@ LAYER_LOCLABEL
Definition: layer_ids.h:347
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References color, SCH_ITEM::Connection(), DANGLING_SYMBOL_SIZE, KIGFX::eeconfig(), EDA_TEXT::GetAttributes(), SCH_TEXT::GetBoundingBox(), EDA_TEXT::GetDrawPos(), EDA_TEXT::GetDrawRotation(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetPosition(), EDA_TEXT::GetRenderCache(), SCH_TEXT::GetSchematicTextOffset(), SCH_TEXT::GetShownText(), EDA_TEXT::GetTextBox(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), BOX2< Vec >::Inflate(), IS_SHOWN_AS_BITMAP, EDA_ITEM::IsBrightened(), SCH_CONNECTION::IsBus(), SCH_ITEM::IsConnectivityDirty(), SCH_ITEM::IsDangling(), EDA_ITEM::IsForceVisible(), SCH_TEXT::IsHypertext(), KIFONT::FONT::IsOutline(), EDA_ITEM::IsRollover(), EDA_ITEM::IsSelected(), EDA_TEXT::IsVisible(), KiROUND(), LAYER_BUS, LAYER_DANGLING, LAYER_GLOBLABEL, LAYER_HIDDEN, LAYER_HIERLABEL, LAYER_HOVERED, LAYER_LOCLABEL, LAYER_NETCLASS_REFS, LAYER_NOTES, LAYER_SELECTION_SHADOWS, LAYER_SHEETLABEL, TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Underlined, KIGFX::mapCoords(), EDA_IU_SCALE::MilsToIU(), SCH_ITEM::RenderAsBitmap(), BOX2< Vec >::RevertYAxis(), RotatePoint(), SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, SCH_TEXT_T, schIUScale, EDA_ITEM::Type(), and VECTOR2< T >::y.

◆ draw() [23/23]

void KIGFX::SCH_PAINTER::draw ( const SCH_TEXTBOX aTextBox,
int  aLayer 
)
private

Definition at line 2044 of file sch_painter.cpp.

2045{
2046 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2047 COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows );
2048 float borderWidth = getLineWidth( aTextBox, drawingShadows );
2049
2050 KIFONT::FONT* font = aTextBox->GetFont();
2051
2052 if( !font )
2053 {
2055 aTextBox->IsItalic() );
2056 }
2057
2058 auto drawText =
2059 [&]()
2060 {
2061 wxString shownText = aTextBox->GetShownText();
2062 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
2063
2064 attrs.m_Angle = aTextBox->GetDrawRotation();
2065 attrs.m_StrokeWidth = KiROUND( getTextThickness( aTextBox ) );
2066
2067 if( aTextBox->IsHypertext() && aTextBox->IsRollover() )
2068 {
2071 attrs.m_Underlined = true;
2072 }
2073
2074 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2075
2076 if( !aTextBox->IsHypertext() && font->IsOutline() )
2077 cache = aTextBox->GetRenderCache( font, shownText );
2078
2079 if( cache )
2080 {
2081 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
2082 m_gal->DrawGlyph( *glyph );
2083 }
2084 else
2085 {
2086 strokeText( shownText, aTextBox->GetDrawPos(), attrs );
2087 }
2088 };
2089
2090 if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) )
2091 return;
2092
2095
2096 if( aLayer == LAYER_SELECTION_SHADOWS )
2097 {
2098 m_gal->SetIsFill( true );
2099 m_gal->SetIsStroke( false );
2100 m_gal->SetLineWidth( borderWidth );
2101
2102 m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
2103 }
2104 else if( aLayer == LAYER_NOTES_BACKGROUND )
2105 {
2106 if( aTextBox->IsFilled() )
2107 {
2108 m_gal->SetIsFill( true );
2109 m_gal->SetIsStroke( false );
2110 m_gal->SetLineWidth( borderWidth );
2111
2112 m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
2113 }
2114 }
2115 else if( aLayer == LAYER_NOTES )
2116 {
2117 drawText();
2118
2119 if( borderWidth > 0 )
2120 {
2121 COLOR4D borderColor = aTextBox->GetStroke().GetColor();
2122 PLOT_DASH_TYPE borderStyle = aTextBox->GetEffectiveLineStyle();
2123
2125 || borderColor == COLOR4D::UNSPECIFIED )
2126 {
2127 borderColor = m_schSettings.GetLayerColor( aLayer );
2128 }
2129
2130 m_gal->SetIsFill( false );
2131 m_gal->SetIsStroke( true );
2132 m_gal->SetStrokeColor( borderColor );
2133 m_gal->SetLineWidth( borderWidth );
2134
2135 if( borderStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
2136 {
2137 m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
2138 }
2139 else
2140 {
2141 std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
2142
2143 for( SHAPE* shape : shapes )
2144 {
2145 STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ),
2147 [&]( const VECTOR2I& a, const VECTOR2I& b )
2148 {
2149 // DrawLine has problem with 0 length lines so enforce minimum
2150 if( a == b )
2151 m_gal->DrawLine( a+1, b );
2152 else
2153 m_gal->DrawLine( a, b );
2154 } );
2155 }
2156
2157 for( SHAPE* shape : shapes )
2158 delete shape;
2159 }
2160 }
2161 }
2162}
bool IsItalic() const
Definition: eda_text.h:130
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
bool IsBold() const
Definition: eda_text.h:133
const wxString & GetDefaultFont() const
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:64
VECTOR2I GetPosition() const override
Definition: sch_shape.h:77
VECTOR2I GetDrawPos() const override
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_textbox.h:60
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.

References color, FIRST_TYPE, EDA_TEXT::GetAttributes(), STROKE_PARAMS::GetColor(), SCH_TEXTBOX::GetDrawPos(), EDA_TEXT::GetDrawRotation(), SCH_SHAPE::GetEffectiveLineStyle(), EDA_SHAPE::GetEnd(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), SCH_SHAPE::GetPosition(), EDA_TEXT::GetRenderCache(), SCH_TEXTBOX::GetShownText(), SCH_SHAPE::GetStroke(), EDA_TEXT::IsBold(), EDA_ITEM::IsBrightened(), EDA_SHAPE::IsFilled(), SCH_TEXTBOX::IsHypertext(), EDA_TEXT::IsItalic(), KIFONT::FONT::IsOutline(), EDA_ITEM::IsRollover(), EDA_ITEM::IsSelected(), KiROUND(), LAYER_HOVERED, LAYER_NOTES, LAYER_NOTES_BACKGROUND, LAYER_SELECTION_SHADOWS, TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Underlined, EDA_SHAPE::MakeEffectiveShapes(), and STROKE_PARAMS::Stroke().

◆ Draw()

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

Takes an instance of VIEW_ITEM and passes it to a function that knows 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 189 of file sch_painter.cpp.

190{
191 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
192
193 if( !item )
194 return false;
195
196 draw( item, aLayer, false );
197
198 return false;
199}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85

References draw().

◆ drawDanglingSymbol()

void KIGFX::SCH_PAINTER::drawDanglingSymbol ( const VECTOR2I aPos,
const COLOR4D aColor,
int  aWidth,
bool  aDangling,
bool  aDrawingShadows,
bool  aBrightened 
)
private

Definition at line 1659 of file sch_painter.cpp.

1661{
1662 int size = aDangling ? DANGLING_SYMBOL_SIZE : UNSELECTED_END_SIZE;
1663
1664 if( !aDangling )
1665 aWidth /= 2;
1666
1667 VECTOR2I radius( aWidth + schIUScale.MilsToIU( size / 2 ),
1668 aWidth + schIUScale.MilsToIU( size / 2 ) );
1669
1670 // Dangling symbols must be drawn in a slightly different colour so they can be seen when
1671 // they overlap with a junction dot.
1672 m_gal->SetStrokeColor( aColor.Brightened( 0.3 ) );
1673 m_gal->SetIsStroke( true );
1674 m_gal->SetIsFill( false );
1675 m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
1677
1678 m_gal->DrawRectangle( aPos - radius, aPos + radius );
1679}
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:284
#define UNSELECTED_END_SIZE
The default pin len value when creating pins(can be changed in preference menu)

References KIGFX::COLOR4D::Brightened(), DANGLING_SYMBOL_SIZE, EDA_IU_SCALE::MilsToIU(), schIUScale, and UNSELECTED_END_SIZE.

◆ drawPinDanglingSymbol()

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

Definition at line 1212 of file sch_painter.cpp.

1214{
1215 // Dangling symbols must be drawn in a slightly different colour so they can be seen when
1216 // they overlap with a junction dot.
1217 m_gal->SetStrokeColor( aColor.Brightened( 0.3 ) );
1218
1219 m_gal->SetIsFill( false );
1220 m_gal->SetIsStroke( true );
1221 m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
1223
1225}

References KIGFX::COLOR4D::Brightened(), and TARGET_PIN_RADIUS.

◆ externalPinDecoSize()

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

Definition at line 1202 of file sch_painter.cpp.

1203{
1206
1207 return aPin.GetNumberTextSize() / 2;
1208}

References LIB_PIN::GetNumberTextSize().

◆ getFont()

KIFONT::FONT * KIGFX::SCH_PAINTER::getFont ( const EDA_TEXT aText) const
private

Definition at line 347 of file sch_painter.cpp.

348{
349 KIFONT::FONT* retval = aItem->GetFont();
350
351 if( !retval )
352 retval = KIFONT::FONT::GetFont( m_schSettings.GetDefaultFont(), aItem->IsBold(),
353 aItem->IsItalic() );
354
355 return retval;
356}

References KIGFX::RENDER_SETTINGS::GetDefaultFont(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), and m_schSettings.

◆ getLineWidth()

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

Definition at line 497 of file sch_painter.cpp.

498{
499 wxCHECK( aItem, static_cast<float>( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) ) );
500
501 int pen = 0;
502
503 if( dynamic_cast<const LIB_ITEM*>( aItem ) )
504 pen = static_cast<const LIB_ITEM*>( aItem )->GetEffectivePenWidth( &m_schSettings );
505 else if( dynamic_cast<const SCH_ITEM*>( aItem ) )
506 pen = static_cast<const SCH_ITEM*>( aItem )->GetPenWidth();
507 else
508 UNIMPLEMENTED_FOR( aItem->GetClass() );
509
510 float width = pen;
511
512 if( aItem->IsBrightened() || aItem->IsSelected() )
513 {
514 if( aDrawingShadows && aItem->IsType( g_ScaledSelectionTypes ) )
515 width += getShadowWidth( aItem->IsBrightened() );
516 }
517
518 return width;
519}
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
virtual wxString GetClass() const =0
Return the class name.
static std::vector< KICAD_T > g_ScaledSelectionTypes
Definition: sch_painter.h:202

References DEFAULT_LINE_WIDTH_MILS, EDA_ITEM::GetClass(), SCH_ITEM::GetPenWidth(), EDA_ITEM::IsBrightened(), EDA_ITEM::IsSelected(), EDA_ITEM::IsType(), EDA_IU_SCALE::MilsToIU(), schIUScale, and UNIMPLEMENTED_FOR.

◆ getRenderColor()

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

Definition at line 372 of file sch_painter.cpp.

374{
376
377 if( aItem->Type() == SCH_LINE_T )
378 {
379 color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
380 }
381 else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
382 {
383 color = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetBusEntryColor();
384 }
385 else if( aItem->Type() == SCH_JUNCTION_T )
386 {
387 color = static_cast<const SCH_JUNCTION*>( aItem )->GetJunctionColor();
388 }
390 {
391 if( aItem->Type() == SCH_SHEET_T )
392 {
393 const SCH_SHEET* sheet = static_cast<const SCH_SHEET*>( aItem );
394
395 if( aLayer == LAYER_SHEET_BACKGROUND )
396 color = sheet->GetBackgroundColor();
397 else
398 color = sheet->GetBorderColor();
399 }
400 else if( aItem->Type() == SCH_SHAPE_T )
401 {
402 const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem );
403
404 if( aLayer == LAYER_NOTES_BACKGROUND )
405 color = shape->GetFillColor();
406 else
407 color = shape->GetStroke().GetColor();
408
409 // A filled shape means filled; if they didn't specify a fill colour then use the
410 // border colour.
413 }
414 else if( aItem->Type() == LIB_SHAPE_T )
415 {
416 const LIB_SHAPE* shape = static_cast<const LIB_SHAPE*>( aItem );
417
418 if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
419 color = shape->GetFillColor();
420 else
421 color = shape->GetStroke().GetColor();
422 }
423 else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
424 {
425 color = static_cast<const SCH_LABEL_BASE*>( aItem )->GetLabelColor();
426 }
427 else if( aItem->Type() == SCH_FIELD_T )
428 {
429 color = static_cast<const SCH_FIELD*>( aItem )->GetFieldColor();
430 }
431 else if( aItem->Type() == SCH_TEXTBOX_T )
432 {
433 const SCH_TEXTBOX* textBox = static_cast<const SCH_TEXTBOX*>( aItem );
434
435 if( aLayer == LAYER_NOTES_BACKGROUND )
436 color = textBox->GetFillColor();
437 else
438 color = textBox->GetTextColor();
439 }
440 else if( aItem->Type() == LIB_TEXTBOX_T )
441 {
442 const LIB_TEXTBOX* textBox = static_cast<const LIB_TEXTBOX*>( aItem );
443
444 if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
445 color = textBox->GetFillColor();
446 else
447 color = textBox->GetTextColor();
448 }
449 else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) )
450 {
451 color = otherTextItem->GetTextColor();
452 }
453 }
454
457
458 if( aItem->IsBrightened() ) // Selection disambiguation, net highlighting, etc.
459 {
461
462 if( aDrawingShadows )
463 {
464 if( aItem->IsSelected() )
466 else
467 color = color.WithAlpha( 0.15 );
468 }
469 else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
470 {
471 color = color.WithAlpha( 0.2 );
472 }
473 }
474 else if( aItem->IsSelected() && aDrawingShadows )
475 {
476 if( aDrawingShadows )
478 }
479
482 {
483 color = color.Darken( 0.5f );
484 }
485
486 if( aDimmed )
487 {
489 color.Desaturate();
490 color = color.Mix( sheetColour, 0.5f );
491 }
492
493 return color;
494}
COLOR4D GetFillColor() const
Definition: eda_shape.h:105
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
COLOR4D GetTextColor() const
Definition: eda_text.h:205
Class for a wire to bus entry.
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:114
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:117
@ LAYER_BRIGHTENED
Definition: layer_ids.h:379
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:175

References color, SCH_SHEET::GetBackgroundColor(), SCH_SHEET::GetBorderColor(), STROKE_PARAMS::GetColor(), EDA_SHAPE::GetFillColor(), KIGFX::RENDER_SETTINGS::GetLayerColor(), LIB_SHAPE::GetStroke(), SCH_SHAPE::GetStroke(), EDA_TEXT::GetTextColor(), EDA_ITEM::IsType(), LAYER_DEVICE_BACKGROUND, LAYER_NOTES, LAYER_NOTES_BACKGROUND, LAYER_SHEET_BACKGROUND, LIB_SHAPE_T, LIB_TEXTBOX_T, KIGFX::SCH_RENDER_SETTINGS::m_OverrideItemColors, m_schSettings, SCH_BUS_WIRE_ENTRY_T, SCH_FIELD_T, SCH_JUNCTION_T, SCH_LABEL_LOCATE_ANY_T, SCH_LINE_T, SCH_SHAPE_T, SCH_SHEET_T, SCH_TEXTBOX_T, EDA_ITEM::Type(), and KIGFX::COLOR4D::UNSPECIFIED.

◆ GetSettings()

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

Return a pointer to current settings that are going to be used when drawing items.

Returns
Current rendering settings.

Implements KIGFX::PAINTER.

Definition at line 142 of file sch_painter.h.

142{ return &m_schSettings; }

References m_schSettings.

◆ getShadowWidth()

float KIGFX::SCH_PAINTER::getShadowWidth ( bool  aForHighlight) const
private

Definition at line 359 of file sch_painter.cpp.

360{
361 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
362
363 int milsWidth = aForHighlight ? eeconfig()->m_Selection.highlight_thickness
365
366 // For best visuals the selection width must be a cross between the zoom level and the
367 // default line width.
368 return (float) std::fabs( matrix.GetScale().x * milsWidth ) + schIUScale.MilsToIU( milsWidth );
369}
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:295

References KIGFX::eeconfig(), MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), EESCHEMA_SETTINGS::SELECTION::highlight_thickness, KIGFX::PAINTER::m_gal, EESCHEMA_SETTINGS::m_Selection, EDA_IU_SCALE::MilsToIU(), schIUScale, EESCHEMA_SETTINGS::SELECTION::selection_thickness, and VECTOR2< T >::x.

◆ getTextThickness()

float KIGFX::SCH_PAINTER::getTextThickness ( const EDA_ITEM aItem) const
private

Definition at line 522 of file sch_painter.cpp.

523{
525
526 switch( aItem->Type() )
527 {
528 case SCH_FIELD_T:
529 pen = static_cast<const SCH_FIELD*>( aItem )->GetEffectiveTextPenWidth( pen );
530 break;
531
532 case SCH_TEXT_T:
533 pen = static_cast<const SCH_TEXT*>( aItem )->GetEffectiveTextPenWidth( pen );
534 break;
535
536 case SCH_LABEL_T:
539 case SCH_HIER_LABEL_T:
540 case SCH_SHEET_PIN_T:
541 pen = static_cast<const SCH_LABEL_BASE*>( aItem )->GetEffectiveTextPenWidth( pen );
542 break;
543
544 case SCH_TEXTBOX_T:
545 pen = static_cast<const SCH_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth( pen );
546 break;
547
548 case LIB_FIELD_T:
549 pen = std::max( pen, static_cast<const LIB_FIELD*>( aItem )->GetEffectiveTextPenWidth() );
550 break;
551
552 case LIB_TEXT_T:
553 pen = std::max( pen, static_cast<const LIB_TEXT*>( aItem )->GetEffectiveTextPenWidth() );
554 break;
555
556 case LIB_TEXTBOX_T:
557 pen = std::max( pen, static_cast<const LIB_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth() );
558 break;
559
560 default:
561 UNIMPLEMENTED_FOR( aItem->GetClass() );
562 }
563
564 return (float) pen;
565}

References EDA_ITEM::GetClass(), LIB_FIELD_T, LIB_TEXT_T, LIB_TEXTBOX_T, SCH_DIRECTIVE_LABEL_T, SCH_FIELD_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_SHEET_PIN_T, SCH_TEXT_T, SCH_TEXTBOX_T, EDA_ITEM::Type(), and UNIMPLEMENTED_FOR.

◆ internalPinDecoSize()

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

Definition at line 1191 of file sch_painter.cpp.

1192{
1195
1196 return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
1197}

References LIB_PIN::GetNameTextSize(), and LIB_PIN::GetNumberTextSize().

◆ isUnitAndConversionShown()

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

Definition at line 327 of file sch_painter.cpp.

328{
329 if( m_schSettings.m_ShowUnit // showing a specific unit
330 && aItem->GetUnit() // item is unit-specific
331 && aItem->GetUnit() != m_schSettings.m_ShowUnit )
332 {
333 return false;
334 }
335
336 if( m_schSettings.m_ShowConvert // showing a specific conversion
337 && aItem->GetConvert() // item is conversion-specific
338 && aItem->GetConvert() != m_schSettings.m_ShowConvert )
339 {
340 return false;
341 }
342
343 return true;
344}
int GetUnit() const
Definition: lib_item.h:273
int GetConvert() const
Definition: lib_item.h:276

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

◆ nonCached()

bool KIGFX::SCH_PAINTER::nonCached ( const EDA_ITEM aItem)
private

Definition at line 319 of file sch_painter.cpp.

320{
321 // TODO: it would be nice to have a more definitive test for this, but we've currently got
322 // no access to the VIEW_GROUP to see if it's cached or not.
323 return aItem->IsSelected();
324}

References EDA_ITEM::IsSelected().

◆ setDeviceColors()

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

Definition at line 703 of file sch_painter.cpp.

704{
705 const EDA_SHAPE* shape = dynamic_cast<const EDA_SHAPE*>( aItem );
706
707 switch( aLayer )
708 {
710 if( aItem->IsBrightened() || aItem->IsSelected() )
711 {
712 m_gal->SetIsFill( false );
713 m_gal->SetIsStroke( true );
714 m_gal->SetLineWidth( getLineWidth( aItem, true ) );
715 m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true, aDimmed ) );
716 m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true, aDimmed ) );
717 return true;
718 }
719
720 return false;
721
724 if( shape )
725 {
727 {
728 return false; // FILLED_SHAPE and FILLED_WITH_COLOR rendered below on
729 // LAYER_NOTES or LAYER_DEVICE
730 }
731
732 m_gal->SetIsFill( true );
733 m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false, aDimmed ) );
734 m_gal->SetIsStroke( false );
735 return true;
736 }
737
738 return false;
739
740 case LAYER_NOTES:
742 case LAYER_DEVICE:
743 m_gal->SetIsFill( shape && ( shape->GetFillMode() == FILL_T::FILLED_SHAPE
744 || shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR ) );
745
746 if( shape && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
747 {
748 m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false, aDimmed ) );
749 }
750 else if( shape && shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR )
751 {
752 COLOR4D fillColour = shape->GetFillColor();
753
754 if( aDimmed )
755 {
756 fillColour = fillColour.Mix(
758 fillColour.Desaturate( );
759 }
760
761 m_gal->SetFillColor( fillColour );
762 }
763
764 if( aItem->GetPenWidth() >= 0 || !shape || !shape->IsFilled() )
765 {
766 m_gal->SetIsStroke( true );
767 m_gal->SetLineWidth( getLineWidth( aItem, false ) );
768 m_gal->SetStrokeColor( getRenderColor( aItem, aLayer, false, aDimmed ) );
769 }
770 else
771 {
772 m_gal->SetIsStroke( false );
773 }
774
775 return true;
776
777 default:
778 return false;
779 }
780}
FILL_T GetFillMode() const
Definition: eda_shape.h:101
virtual int GetPenWidth() const =0

References KIGFX::COLOR4D::Desaturate(), FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, FILLED_WITH_COLOR, EDA_SHAPE::GetFillColor(), EDA_SHAPE::GetFillMode(), LIB_ITEM::GetPenWidth(), EDA_ITEM::IsBrightened(), EDA_SHAPE::IsFilled(), EDA_ITEM::IsSelected(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, LAYER_NOTES, LAYER_NOTES_BACKGROUND, LAYER_PRIVATE_NOTES, LAYER_SCHEMATIC_BACKGROUND, LAYER_SELECTION_SHADOWS, and KIGFX::COLOR4D::Mix().

◆ SetGAL()

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

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

Parameters
aGalis the new GAL instance.

Definition at line 75 of file painter.h.

76 {
77 m_gal = aGal;
78 }

References KIGFX::PAINTER::m_gal.

◆ SetSchematic()

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

Definition at line 144 of file sch_painter.h.

144{ m_schematic = aSchematic; }

References m_schematic.

◆ strokeText()

void KIGFX::SCH_PAINTER::strokeText ( const wxString &  aText,
const VECTOR2D aPosition,
const TEXT_ATTRIBUTES aAttributes 
)
private

Definition at line 587 of file sch_painter.cpp.

589{
590 KIFONT::FONT* font = aAttrs.m_Font;
591
592 if( !font )
593 {
594 font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
595 aAttrs.m_Italic );
596 }
597
598 m_gal->SetIsFill( font->IsOutline() );
599 m_gal->SetIsStroke( font->IsStroke() );
600
601 font->Draw( m_gal, aText, aPosition, aAttrs );
602}
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:159
virtual bool IsStroke() const
Definition: font.h:112

References KIFONT::FONT::Draw(), KIGFX::eeconfig(), KIFONT::FONT::GetFont(), KIFONT::FONT::IsOutline(), KIFONT::FONT::IsStroke(), TEXT_ATTRIBUTES::m_Bold, TEXT_ATTRIBUTES::m_Font, and TEXT_ATTRIBUTES::m_Italic.

◆ triLine()

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

Definition at line 662 of file sch_painter.cpp.

663{
664 m_gal->DrawLine( a, b );
665 m_gal->DrawLine( b, c );
666}

Member Data Documentation

◆ g_ScaledSelectionTypes

◆ m_gal

GAL* KIGFX::PAINTER::m_gal
protectedinherited

◆ m_schematic

SCHEMATIC* KIGFX::SCH_PAINTER::m_schematic
private

Definition at line 206 of file sch_painter.h.

Referenced by SetSchematic().

◆ m_schSettings

SCH_RENDER_SETTINGS KIGFX::SCH_PAINTER::m_schSettings
private

Definition at line 205 of file sch_painter.h.

Referenced by draw(), getFont(), getRenderColor(), GetSettings(), and isUnitAndConversionShown().


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