KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_painter.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014 CERN
5 * Copyright (C) 2019-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27
28#include <trigo.h>
29#include <connection_graph.h>
31#include <callback_gal.h>
33#include <geometry/shape_rect.h>
34#include <gr_text.h>
35#include <sch_pin.h>
36#include <math/util.h>
37#include <pgm_base.h>
38#include <sch_bitmap.h>
39#include <sch_bus_entry.h>
40#include <sch_symbol.h>
41#include <sch_edit_frame.h>
42#include <sch_field.h>
43#include <sch_junction.h>
44#include <sch_line.h>
45#include <sch_shape.h>
46#include <sch_marker.h>
47#include <sch_no_connect.h>
48#include <sch_sheet.h>
49#include <sch_sheet_pin.h>
50#include <sch_text.h>
51#include <sch_textbox.h>
52#include <sch_table.h>
53#include <schematic.h>
55#include <view/view.h>
56#include <kiface_base.h>
57#include <default_values.h>
58#include <advanced_config.h>
60#include <stroke_params.h>
61#include "sch_painter.h"
62#include "common.h"
63
65
66namespace KIGFX
67{
68
70{
71 return dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
72}
73
74
75std::vector<KICAD_T> SCH_PAINTER::g_ScaledSelectionTypes = {
94};
95
96
111{
112 static LIB_SYMBOL* symbol;
113
114 if( !symbol )
115 {
116 symbol = new LIB_SYMBOL( wxEmptyString );
117
118 SCH_SHAPE* square = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE );
119
120 square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
121 square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
122 symbol->AddDrawItem( square );
123
124 SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??" ), LAYER_DEVICE );
125
126 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
127 symbol->AddDrawItem( text );
128 }
129
130 return symbol;
131}
132
133
135 KIGFX::PAINTER( aGal ),
136 m_schematic( nullptr )
137{ }
138
139
140bool SCH_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
141{
142 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
143
144 if( !item )
145 return false;
146
147 draw( item, aLayer, false );
148
149 return false;
150}
151
152void SCH_PAINTER::draw( const EDA_ITEM* aItem, int aLayer, bool aDimmed )
153{
154
155#ifdef CONNECTIVITY_DEBUG
156
157 auto sch_item = dynamic_cast<const SCH_ITEM*>( aItem );
158 auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
159
160 if( conn )
161 {
162 auto pos = aItem->GetBoundingBox().Centre();
163 auto label = conn->Name( true );
164
168 m_gal->SetLineWidth( Mils2ui( 2 ) );
169 m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
170 m_gal->StrokeText( conn->Name( true ), pos, 0.0, 0 );
171 }
172
173#endif
174
175 // Enable draw bounding box on request. Some bboxes are handled locally.
176 bool drawBoundingBox = m_schSettings.GetDrawBoundingBoxes();
177
178 switch( aItem->Type() )
179 {
180 case LIB_SYMBOL_T:
181 draw( static_cast<const LIB_SYMBOL*>( aItem ), aLayer );
182 break;
183 case SCH_PIN_T:
184 drawBoundingBox = false;
185 draw( static_cast<const SCH_PIN*>( aItem ), aLayer, aDimmed );
186 break;
187 case SCH_SYMBOL_T:
188 draw( static_cast<const SCH_SYMBOL*>( aItem ), aLayer );
189 break;
190 case SCH_JUNCTION_T:
191 draw( static_cast<const SCH_JUNCTION*>( aItem ), aLayer );
192 break;
193 case SCH_LINE_T:
194 draw( static_cast<const SCH_LINE*>( aItem ), aLayer );
195 break;
196 case SCH_SHAPE_T:
197 draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer, aDimmed );
198 break;
199 case SCH_RULE_AREA_T:
200 draw( static_cast<const SCH_SHAPE*>( aItem ), aLayer, aDimmed );
201 break;
202 case SCH_TEXT_T:
203 draw( static_cast<const SCH_TEXT*>( aItem ), aLayer, aDimmed );
204 break;
205 case SCH_TEXTBOX_T:
206 draw( static_cast<const SCH_TEXTBOX*>( aItem ), aLayer, aDimmed );
207 break;
208 case SCH_TABLE_T:
209 draw( static_cast<const SCH_TABLE*>( aItem ), aLayer, aDimmed );
210 break;
211 case SCH_LABEL_T:
212 draw( static_cast<const SCH_LABEL*>( aItem ), aLayer );
213 break;
215 draw( static_cast<const SCH_DIRECTIVE_LABEL*>( aItem ), aLayer );
216 break;
217 case SCH_FIELD_T:
218 draw( static_cast<const SCH_FIELD*>( aItem ), aLayer, aDimmed );
219 break;
220 case SCH_HIER_LABEL_T:
221 draw( static_cast<const SCH_HIERLABEL*>( aItem ), aLayer );
222 break;
224 draw( static_cast<const SCH_GLOBALLABEL*>( aItem ), aLayer );
225 break;
226 case SCH_SHEET_T:
227 draw( static_cast<const SCH_SHEET*>( aItem ), aLayer );
228 break;
229 case SCH_SHEET_PIN_T:
230 draw( static_cast<const SCH_HIERLABEL*>( aItem ), aLayer );
231 break;
232 case SCH_NO_CONNECT_T:
233 draw( static_cast<const SCH_NO_CONNECT*>( aItem ), aLayer );
234 break;
236 draw( static_cast<const SCH_BUS_ENTRY_BASE*>( aItem ), aLayer );
237 break;
239 draw( static_cast<const SCH_BUS_ENTRY_BASE*>( aItem ), aLayer );
240 break;
241 case SCH_BITMAP_T:
242 draw( static_cast<const SCH_BITMAP*>( aItem ), aLayer );
243 break;
244 case SCH_MARKER_T:
245 draw( static_cast<const SCH_MARKER*>( aItem ), aLayer );
246 break;
247
248 default: return;
249 }
250
251 if( drawBoundingBox )
252 drawItemBoundingBox( aItem );
253}
254
255
257{
258 if( const SCH_ITEM* item = dynamic_cast<const SCH_ITEM*>( aItem ) )
259 {
260 if( item->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
261 return;
262 }
263
264 BOX2I box = aItem->GetBoundingBox();
265
266 if( aItem->Type() == SCH_SYMBOL_T )
267 box = static_cast<const SCH_SYMBOL*>( aItem )->GetBodyBoundingBox();
268
269 m_gal->SetIsFill( false );
270 m_gal->SetIsStroke( true );
271 m_gal->SetStrokeColor( aItem->IsSelected() ? COLOR4D( 1.0, 0.2, 0.2, 1 )
272 : COLOR4D( 0.2, 0.2, 0.2, 1 ) );
274 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
275}
276
277
279{
280 // TODO: it would be nice to have a more definitive test for this, but we've currently got
281 // no access to the VIEW_GROUP to see if it's cached or not.
282 return aItem->IsSelected();
283}
284
285
287{
288 if( m_schSettings.m_ShowUnit // showing a specific unit
289 && aItem->GetUnit() // item is unit-specific
290 && aItem->GetUnit() != m_schSettings.m_ShowUnit )
291 {
292 return false;
293 }
294
295 if( m_schSettings.m_ShowBodyStyle // showing a specific body style
296 && aItem->GetBodyStyle() // item is body-style-specific
298 {
299 return false;
300 }
301
302 return true;
303}
304
305
307{
308 if( KIFONT::FONT* font = aItem->GetFont() )
309 return font;
310
312 aItem->IsItalic() );
313}
314
315
316float SCH_PAINTER::getShadowWidth( bool aForHighlight ) const
317{
318 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
319
320 int milsWidth = aForHighlight ? eeconfig()->m_Selection.highlight_thickness
322
323 // For best visuals the selection width must be a cross between the zoom level and the
324 // default line width.
325 return (float) std::fabs( matrix.GetScale().x * milsWidth ) + schIUScale.MilsToIU( milsWidth );
326}
327
328
329COLOR4D SCH_PAINTER::getRenderColor( const SCH_ITEM* aItem, int aLayer, bool aDrawingShadows,
330 bool aDimmed ) const
331{
333 // Graphic items of a SYMBOL frequently use the LAYER_DEVICE layer color
334 // (i.e. when no specific color is set)
335 bool isSymbolChild = aItem->GetParentSymbol() != nullptr;
336
337 if( aItem->Type() == SCH_LINE_T )
338 {
339 color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
340 }
341 else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
342 {
343 color = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetBusEntryColor();
344 }
345 else if( aItem->Type() == SCH_JUNCTION_T )
346 {
347 color = static_cast<const SCH_JUNCTION*>( aItem )->GetJunctionColor();
348 }
350 {
351 if( aItem->Type() == SCH_SHEET_T )
352 {
353 const SCH_SHEET* sheet = static_cast<const SCH_SHEET*>( aItem );
354
355 if( aLayer == LAYER_SHEET_BACKGROUND )
356 color = sheet->GetBackgroundColor();
357 else
358 color = sheet->GetBorderColor();
359 }
360 else if( aItem->Type() == SCH_SHAPE_T || aItem->Type() == SCH_RULE_AREA_T )
361 {
362 const SCH_SHAPE* shape = static_cast<const SCH_SHAPE*>( aItem );
363
364 if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
365 {
366 if( !isSymbolChild || shape->GetFillColor() != COLOR4D::UNSPECIFIED )
367 color = shape->GetFillColor();
368
369 if( isSymbolChild && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
370 color = shape->GetStroke().GetColor();
371 }
372 else
373 {
374 if( !isSymbolChild || shape->GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
375 color = shape->GetStroke().GetColor();
376 }
377
378 // A filled shape means filled; if they didn't specify a fill colour then use the
379 // border colour.
381 {
382 if( aItem->Type() == SCH_RULE_AREA_T )
383 {
385 }
386 else
387 {
389 : LAYER_NOTES );
390 }
391 }
392 }
393 else if( aItem->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
394 {
395 color = static_cast<const SCH_LABEL_BASE*>( aItem )->GetLabelColor();
396 }
397 else if( aItem->Type() == SCH_FIELD_T )
398 {
399 color = static_cast<const SCH_FIELD*>( aItem )->GetFieldColor();
400 }
401 else if( aItem->Type() == SCH_TEXTBOX_T || aItem->Type() == SCH_TABLECELL_T )
402 {
403 const SCH_TEXTBOX* textBox = dynamic_cast<const SCH_TEXTBOX*>( aItem );
404
405 if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
406 color = textBox->GetFillColor();
407 else if( !isSymbolChild || textBox->GetTextColor() != COLOR4D::UNSPECIFIED )
408 color = textBox->GetTextColor();
409 }
410 else if( const EDA_TEXT* otherTextItem = dynamic_cast<const EDA_TEXT*>( aItem ) )
411 {
412 if( !isSymbolChild || otherTextItem->GetTextColor() != COLOR4D::UNSPECIFIED )
413 color = otherTextItem->GetTextColor();
414 }
415 }
416
418 color = m_schSettings.GetLayerColor( aLayer );
419
420 if( aItem->IsBrightened() ) // Selection disambiguation, net highlighting, etc.
421 {
422 color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
423
424 if( aDrawingShadows )
425 {
426 if( aItem->IsSelected() )
427 color = m_schSettings.GetLayerColor( LAYER_SELECTION_SHADOWS );
428 else
429 color = color.WithAlpha( 0.15 );
430 }
431 else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
432 {
433 color = color.WithAlpha( 0.2 );
434 }
435 }
436 else if( aItem->IsSelected() && aDrawingShadows )
437 {
438 if( aDrawingShadows )
439 color = m_schSettings.GetLayerColor( LAYER_SELECTION_SHADOWS );
440 }
441 else if( aItem->IsSelected() && ( aLayer == LAYER_DEVICE_BACKGROUND
442 || aLayer == LAYER_SHEET_BACKGROUND ) )
443 {
444 // Selected items will be painted over all other items, so make backgrounds translucent so
445 // that non-selected overlapping objects are visible
446 color = color.WithAlpha( 0.5 );
447 }
448
449 if( m_schSettings.m_ShowDisabled
450 || ( m_schSettings.m_ShowGraphicsDisabled && aItem->Type() != SCH_FIELD_T ) )
451 {
452 color = color.Darken( 0.5f );
453 }
454
455 if( aDimmed && !( aItem->IsSelected() && aDrawingShadows ) )
456 {
457 COLOR4D sheetColour = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
458 color.Desaturate();
459 color = color.Mix( sheetColour, 0.5f );
460 }
461
462 if( aItem->GetForcedTransparency() > 0.0 )
463 color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForcedTransparency() ) );
464
465 return color;
466}
467
468
469float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const
470{
471 wxCHECK( aItem, static_cast<float>( schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) ) );
472
473 int pen = aItem->GetEffectivePenWidth( &m_schSettings );
474 float width = pen;
475
476 if( aItem->IsBrightened() || aItem->IsSelected() )
477 {
478 if( aDrawingShadows && aItem->IsType( g_ScaledSelectionTypes ) )
479 width += getShadowWidth( aItem->IsBrightened() );
480 }
481
482 return width;
483}
484
485
486float SCH_PAINTER::getTextThickness( const SCH_ITEM* aItem ) const
487{
488 int pen = m_schSettings.GetDefaultPenWidth();
489
490 switch( aItem->Type() )
491 {
492 case SCH_FIELD_T:
493 pen = static_cast<const SCH_FIELD*>( aItem )->GetEffectiveTextPenWidth( pen );
494 break;
495
496 case SCH_TEXT_T:
497 pen = static_cast<const SCH_TEXT*>( aItem )->GetEffectiveTextPenWidth( pen );
498 break;
499
500 case SCH_LABEL_T:
503 case SCH_HIER_LABEL_T:
504 case SCH_SHEET_PIN_T:
505 pen = static_cast<const SCH_LABEL_BASE*>( aItem )->GetEffectiveTextPenWidth( pen );
506 break;
507
508 case SCH_TEXTBOX_T:
509 case SCH_TABLECELL_T:
510 pen = static_cast<const SCH_TEXTBOX*>( aItem )->GetEffectiveTextPenWidth( pen );
511 break;
512
513 default:
514 UNIMPLEMENTED_FOR( aItem->GetClass() );
515 }
516
517 return (float) pen;
518}
519
520
521int SCH_PAINTER::getOperatingPointTextSize() const
522{
523 int docTextSize = schIUScale.MilsToIU( 50 );
524 int screenTextSize = std::abs( (int) m_gal->GetScreenWorldMatrix().GetScale().y * 7 );
525
526 // 66% zoom-relative
527 return KiROUND( ( docTextSize + screenTextSize * 2 ) / 3 );
528}
529
530
531static bool isFieldsLayer( int aLayer )
532{
533 return aLayer == LAYER_REFERENCEPART
534 || aLayer == LAYER_VALUEPART
535 || aLayer == LAYER_INTERSHEET_REFS
536 || aLayer == LAYER_NETCLASS_REFS
537 || aLayer == LAYER_FIELDS
538 || aLayer == LAYER_SHEETNAME
539 || aLayer == LAYER_SHEETFILENAME
540 || aLayer == LAYER_SHEETFIELDS;
541}
542
543
544void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition,
545 const TEXT_ATTRIBUTES& aAttrs,
546 const KIFONT::METRICS& aFontMetrics )
547{
548 KIFONT::FONT* font = aAttrs.m_Font;
549
550 if( !font )
551 {
552 font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
553 aAttrs.m_Italic );
554 }
555
556 m_gal->SetIsFill( font->IsOutline() );
557 m_gal->SetIsStroke( font->IsStroke() );
558
559 font->Draw( m_gal, aText, aPosition, aAttrs, aFontMetrics );
560}
561
562
563void SCH_PAINTER::bitmapText( const wxString& aText, const VECTOR2D& aPosition,
564 const TEXT_ATTRIBUTES& aAttrs )
565{
566 // Bitmap font has different metrics from the stroke font so we compensate a bit before
567 // stroking
568 m_gal->SetGlyphSize( VECTOR2I( aAttrs.m_Size.x, KiROUND( aAttrs.m_Size.y * 1.05 ) ) );
569 m_gal->SetLineWidth( (float) aAttrs.m_StrokeWidth * 1.35f );
570
571 m_gal->SetHorizontalJustify( aAttrs.m_Halign );
572 m_gal->SetVerticalJustify( aAttrs.m_Valign );
573
574 m_gal->BitmapText( aText, aPosition, aAttrs.m_Angle );
575}
576
577
578void SCH_PAINTER::knockoutText( const wxString& aText, const VECTOR2D& aPosition,
579 const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
580{
581 TEXT_ATTRIBUTES attrs( aAttrs );
582 KIFONT::FONT* font = aAttrs.m_Font;
583
584 if( !font )
585 {
586 font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, attrs.m_Bold,
587 attrs.m_Italic );
588 }
589
591 SHAPE_POLY_SET knockouts;
592
593 CALLBACK_GAL callback_gal( empty_opts,
594 // Polygon callback
595 [&]( const SHAPE_LINE_CHAIN& aPoly )
596 {
597 knockouts.AddOutline( aPoly );
598 } );
599
600 callback_gal.SetIsFill( false );
601 callback_gal.SetIsStroke( true );
602 callback_gal.SetLineWidth( (float) attrs.m_StrokeWidth );
603 font->Draw( &callback_gal, aText, aPosition, attrs, aFontMetrics );
604
605 BOX2I bbox = knockouts.BBox( attrs.m_StrokeWidth * 2 );
606 SHAPE_POLY_SET finalPoly;
607
608 finalPoly.NewOutline();
609 finalPoly.Append( bbox.GetLeft(), bbox.GetTop() );
610 finalPoly.Append( bbox.GetRight(), bbox.GetTop() );
611 finalPoly.Append( bbox.GetRight(), bbox.GetBottom() );
612 finalPoly.Append( bbox.GetLeft(), bbox.GetBottom() );
613
614 finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
616
617 m_gal->SetIsStroke( false );
618 m_gal->SetIsFill( true );
619 m_gal->SetFillColor( attrs.m_Color );
620 m_gal->DrawPolygon( finalPoly );
621}
622
623
624void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition,
625 const TEXT_ATTRIBUTES& aAttrs, const KIFONT::METRICS& aFontMetrics )
626{
627 KIFONT::FONT* font = aAttrs.m_Font;
628
629 if( !font )
630 {
631 font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font, aAttrs.m_Bold,
632 aAttrs.m_Italic );
633 }
634
635 VECTOR2I extents = font->StringBoundaryLimits( aText, aAttrs.m_Size, aAttrs.m_StrokeWidth,
636 aAttrs.m_Bold, aAttrs.m_Italic, aFontMetrics );
637 BOX2I box( aPosition, VECTOR2I( extents.x, aAttrs.m_Size.y ) );
638
639 switch( aAttrs.m_Halign )
640 {
641 case GR_TEXT_H_ALIGN_LEFT: break;
642 case GR_TEXT_H_ALIGN_CENTER: box.SetX( box.GetX() - box.GetWidth() / 2 ); break;
643 case GR_TEXT_H_ALIGN_RIGHT: box.SetX( box.GetX() - box.GetWidth() ); break;
644 case GR_TEXT_H_ALIGN_INDETERMINATE: wxFAIL_MSG( wxT( "Legal only in dialogs" ) ); break;
645 }
646
647 switch( aAttrs.m_Valign )
648 {
649 case GR_TEXT_V_ALIGN_TOP: break;
650 case GR_TEXT_V_ALIGN_CENTER: box.SetY( box.GetY() - box.GetHeight() / 2 ); break;
651 case GR_TEXT_V_ALIGN_BOTTOM: box.SetY( box.GetY() - box.GetHeight() ); break;
652 case GR_TEXT_V_ALIGN_INDETERMINATE: wxFAIL_MSG( wxT( "Legal only in dialogs" ) ); break;
653 }
654
655 // Give the highlight a bit of margin.
656 box.Inflate( 0, aAttrs.m_StrokeWidth * 2 );
657
658 box.Normalize(); // Make h and v sizes always >= 0
659 box = box.GetBoundingBoxRotated( aPosition, aAttrs.m_Angle );
660
661 m_gal->SetIsFill( true );
662 m_gal->SetIsStroke( false );
663 m_gal->DrawRectangle( box.GetOrigin(), box.GetEnd() );
664}
665
666
667void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c )
668{
669 m_gal->DrawLine( a, b );
670 m_gal->DrawLine( b, c );
671}
672
673
674void SCH_PAINTER::draw( const LIB_SYMBOL* aSymbol, int aLayer, bool aDrawFields, int aUnit,
675 int aBodyStyle, bool aDimmed )
676{
677 if( !aUnit )
678 aUnit = m_schSettings.m_ShowUnit;
679
680 if( !aBodyStyle )
681 aBodyStyle = m_schSettings.m_ShowBodyStyle;
682
683 std::unique_ptr< LIB_SYMBOL > tmpSymbol;
684 const LIB_SYMBOL* drawnSymbol = aSymbol;
685
686 if( aSymbol->IsAlias() )
687 {
688 tmpSymbol = aSymbol->Flatten();
689 drawnSymbol = tmpSymbol.get();
690 }
691
692 // The parent must exist on the union of all its children's draw layers. But that doesn't
693 // mean we want to draw each child on the union.
694 auto childOnLayer =
695 []( const SCH_ITEM& item, int layer )
696 {
697 int layers[512], layers_count;
698 item.ViewGetLayers( layers, layers_count );
699
700 for( int ii = 0; ii < layers_count; ++ii )
701 {
702 if( layers[ii] == layer )
703 return true;
704 }
705
706 return false;
707 };
708
709 for( const SCH_ITEM& item : drawnSymbol->GetDrawItems() )
710 {
711 if( !aDrawFields && item.Type() == SCH_FIELD_T )
712 continue;
713
714 if( !childOnLayer( item, aLayer ) )
715 continue;
716
717 if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
718 continue;
719
720 if( aBodyStyle && item.GetBodyStyle() && aBodyStyle != item.GetBodyStyle() )
721 continue;
722
723 draw( &item, aLayer, aDimmed );
724 }
725}
726
727
728bool SCH_PAINTER::setDeviceColors( const SCH_ITEM* aItem, int aLayer, bool aDimmed )
729{
730 COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
731 const EDA_SHAPE* shape = dynamic_cast<const EDA_SHAPE*>( aItem );
732
733 switch( aLayer )
734 {
736 if( aItem->IsBrightened() || aItem->IsSelected() )
737 {
738 m_gal->SetIsFill( false );
739 m_gal->SetIsStroke( true );
740 m_gal->SetLineWidth( getLineWidth( aItem, true ) );
741 m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true, aDimmed ) );
742 m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true, aDimmed ) );
743 return true;
744 }
745
746 return false;
747
750 if( shape )
751 {
753 {
754 return false; // FILLED_SHAPE and FILLED_WITH_COLOR rendered below on
755 // LAYER_NOTES or LAYER_DEVICE
756 }
757
758 m_gal->SetIsFill( true );
759 m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false, aDimmed ) );
760 m_gal->SetIsStroke( false );
761 return true;
762 }
763
764 return false;
765
766 case LAYER_NOTES:
768 case LAYER_DEVICE:
769 m_gal->SetIsFill( shape && ( shape->GetFillMode() == FILL_T::FILLED_SHAPE
770 || shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR ) );
771
772 if( shape && shape->GetFillMode() == FILL_T::FILLED_SHAPE )
773 {
774 m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false, aDimmed ) );
775 }
776 else if( shape && shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR )
777 {
778 COLOR4D fillColour = shape->GetFillColor();
779 double transparency = aItem->GetForcedTransparency();
780
781 if( transparency > 0.0 )
782 fillColour = fillColour.WithAlpha( fillColour.a * ( 1.0 - transparency ) );
783
784 if( m_schSettings.m_OverrideItemColors )
785 {
786 fillColour = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false, aDimmed );
787 }
788 else if( aDimmed )
789 {
790 fillColour = fillColour.Mix( bg, 0.5f );
791 fillColour.Desaturate();
792 }
793
794 m_gal->SetFillColor( fillColour );
795 }
796
797 if( aItem->GetPenWidth() >= 0 || !shape || !shape->IsFilled() )
798 {
799 m_gal->SetIsStroke( true );
800 m_gal->SetLineWidth( getLineWidth( aItem, false ) );
801 m_gal->SetStrokeColor( getRenderColor( aItem, aLayer, false, aDimmed ) );
802 }
803 else
804 {
805 m_gal->SetIsStroke( false );
806 }
807
808 return true;
809
810 default:
811 return false;
812 }
813}
814
815
816int SCH_PAINTER::internalPinDecoSize( const SCH_PIN &aPin )
817{
818 if( m_schSettings.m_PinSymbolSize > 0 )
819 return m_schSettings.m_PinSymbolSize;
820
821 return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
822}
823
824
825// Utility for getting the size of the 'external' pin decorators (as a radius)
826// i.e. the negation circle, the polarity 'slopes' and the nonlogic marker
827int SCH_PAINTER::externalPinDecoSize( const SCH_PIN &aPin )
828{
829 if( m_schSettings.m_PinSymbolSize > 0 )
830 return m_schSettings.m_PinSymbolSize;
831
832 return aPin.GetNumberTextSize() / 2;
833}
834
835
836// Draw the target (an open circle) for a pin which has no connection or is being moved.
837void SCH_PAINTER::drawPinDanglingIndicator( const VECTOR2I& aPos, const COLOR4D& aColor,
838 bool aDrawingShadows, bool aBrightened )
839{
840 // Dangling symbols must be drawn in a slightly different colour so they can be seen when
841 // they overlap with a junction dot.
842 m_gal->SetStrokeColor( aColor.Brightened( 0.3 ) );
843
844 m_gal->SetIsFill( false );
845 m_gal->SetIsStroke( true );
846 m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
847 : m_schSettings.GetDanglingIndicatorThickness() );
848
849 m_gal->DrawCircle( aPos, TARGET_PIN_RADIUS );
850}
851
852
853void SCH_PAINTER::draw( const SCH_PIN* aPin, int aLayer, bool aDimmed )
854{
855 // Don't draw pins from a selection view-group. Pins in a schematic must always be drawn
856 // from their parent symbol's m_part.
857 if( dynamic_cast<const SCH_SYMBOL*>( aPin->GetParentSymbol() ) )
858 return;
859
860 if( !isUnitAndConversionShown( aPin ) )
861 return;
862
863 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
864
865 if( m_schSettings.IsPrinting() && drawingShadows )
866 return;
867
868 bool drawingDangling = aLayer == LAYER_DANGLING;
869 bool drawingOP = aLayer == LAYER_OP_CURRENTS;
870 bool isDangling = m_schSettings.m_IsSymbolEditor || aPin->HasFlag( IS_DANGLING );
871
872 if( drawingShadows && !( aPin->IsBrightened() || aPin->IsSelected() ) )
873 return;
874
875 VECTOR2I pos = aPin->GetPosition();
876 COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows, aDimmed );
877
878 if( !aPin->IsVisible() )
879 {
880 if( m_schSettings.IsPrinting() )
881 return;
882
883 bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_pins
884 : m_schSettings.m_ShowHiddenPins;
885
886 if( force_show )
887 {
888 color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
889 }
890 else
891 {
892 if( drawingDangling && isDangling && aPin->IsGlobalPower() )
893 drawPinDanglingIndicator( pos, color, drawingShadows, aPin->IsBrightened() );
894
895 return;
896 }
897 }
898
899 if( drawingDangling )
900 {
901 if( isDangling )
902 drawPinDanglingIndicator( pos, color, drawingShadows, aPin->IsBrightened() );
903
904 return;
905 }
906
907 if( m_schSettings.GetDrawBoundingBoxes() )
908 drawItemBoundingBox( aPin );
909
910 VECTOR2I p0 = aPin->GetPinRoot();
911 VECTOR2I dir( sign( pos.x - p0.x ), sign( pos.y - p0.y ) );
912 int len = aPin->GetLength();
913
914 if( drawingOP && !aPin->GetOperatingPoint().IsEmpty() )
915 {
916 int textSize = getOperatingPointTextSize();
917 VECTOR2I mid = ( p0 + pos ) / 2;
918 int textOffset = KiROUND( textSize * 0.22 );
919 TEXT_ATTRIBUTES attrs;
920
921 if( len > textSize )
922 {
923 if( dir.x == 0 )
924 {
925 mid.x += KiROUND( textOffset * 1.2 );
927 }
928 else
929 {
930 mid.y -= KiROUND( textOffset * 1.2 );
931 attrs.m_Angle = ANGLE_VERTICAL;
932 }
933
936
937 attrs.m_Font = KIFONT::FONT::GetFont(); // always use stroke font for performance
938 attrs.m_Size = VECTOR2I( textSize, textSize );
939 attrs.m_StrokeWidth = GetPenSizeForDemiBold( textSize );
940 attrs.m_Color = m_schSettings.GetLayerColor( LAYER_OP_CURRENTS );
941
942 knockoutText( aPin->GetOperatingPoint(), mid, attrs, aPin->GetFontMetrics() );
943 }
944 }
945
946 if( drawingOP )
947 return;
948
949 VECTOR2D pc;
950
951 m_gal->SetIsStroke( true );
952 m_gal->SetIsFill( false );
953 m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
954 m_gal->SetStrokeColor( color );
955 m_gal->SetFontBold( false );
956 m_gal->SetFontUnderlined( false );
957 m_gal->SetFontItalic( false );
958
959 const int radius = externalPinDecoSize( *aPin );
960 const int diam = radius*2;
961 const int clock_size = internalPinDecoSize( *aPin );
962
963 if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
964 {
965 m_gal->DrawLine( p0, pos );
966
967 m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
968 pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
969 m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
970 pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
971 }
972 else
973 {
974 switch( aPin->GetShape() )
975 {
976 default:
978 m_gal->DrawLine( p0, pos );
979 break;
980
982 m_gal->DrawCircle( p0 + dir * radius, radius );
983 m_gal->DrawLine( p0 + dir * ( diam ), pos );
984 break;
985
987 pc = p0 - dir * clock_size ;
988
989 triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
990 pc,
991 p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
992
993 m_gal->DrawCircle( p0 + dir * radius, radius );
994 m_gal->DrawLine( p0 + dir * ( diam ), pos );
995 break;
996
999 pc = p0 - dir * clock_size ;
1000
1001 triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
1002 pc,
1003 p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
1004
1005 if( !dir.y )
1006 {
1007 triLine( p0 + VECTOR2D(dir.x, 0) * diam,
1008 p0 + VECTOR2D(dir.x, -1) * diam,
1009 p0 );
1010 }
1011 else /* MapX1 = 0 */
1012 {
1013 triLine( p0 + VECTOR2D( 0, dir.y) * diam,
1014 p0 + VECTOR2D(-1, dir.y) * diam,
1015 p0 );
1016 }
1017
1018 m_gal->DrawLine( p0, pos );
1019 break;
1020
1022 m_gal->DrawLine( p0, pos );
1023
1024 if( !dir.y )
1025 {
1026 triLine( p0 + VECTOR2D( 0, clock_size ),
1027 p0 + VECTOR2D( -dir.x * clock_size, 0 ),
1028 p0 + VECTOR2D( 0, -clock_size ) );
1029 }
1030 else
1031 {
1032 triLine( p0 + VECTOR2D( clock_size, 0 ),
1033 p0 + VECTOR2D( 0, -dir.y * clock_size ),
1034 p0 + VECTOR2D( -clock_size, 0 ) );
1035 }
1036 break;
1037
1039 m_gal->DrawLine( p0, pos );
1040
1041 if( !dir.y )
1042 {
1043 triLine( p0 + VECTOR2D(dir.x, 0) * diam,
1044 p0 + VECTOR2D(dir.x, -1) * diam,
1045 p0 );
1046 }
1047 else /* MapX1 = 0 */
1048 {
1049 triLine( p0 + VECTOR2D( 0, dir.y) * diam,
1050 p0 + VECTOR2D(-1, dir.y) * diam,
1051 p0 );
1052 }
1053 break;
1054
1055 case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
1056 m_gal->DrawLine( p0, pos );
1057
1058 if( !dir.y ) // Horizontal pin
1059 m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
1060 else // Vertical pin
1061 m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
1062 break;
1063
1064 case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
1065 m_gal->DrawLine( p0, pos );
1066
1067 m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
1068 p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
1069 m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
1070 p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
1071 break;
1072 }
1073 }
1074
1075 if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children )
1076 return;
1077
1078 // Draw the labels
1079 const SYMBOL* symbol = aPin->GetParentSymbol();
1080 float penWidth = (float) m_schSettings.GetDefaultPenWidth();
1081 int textOffset = symbol->GetPinNameOffset();
1082 float nameStrokeWidth = getLineWidth( aPin, false );
1083 float numStrokeWidth = getLineWidth( aPin, false );
1084 bool showPinNames = symbol->GetShowPinNames();
1085 bool showPinNumbers = m_schSettings.m_ShowPinNumbers || symbol->GetShowPinNumbers();
1086
1087 nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), true );
1088 numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), true );
1089
1090 float PIN_TEXT_MARGIN = schIUScale.MilsToIU( KiROUND( 24 * m_schSettings.m_TextOffsetRatio ) );
1091
1092 // Four locations around a pin where text can be drawn
1093 enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
1094 int size[4] = { 0, 0, 0, 0 };
1095 float thickness[4] = { numStrokeWidth, numStrokeWidth, numStrokeWidth, numStrokeWidth };
1096 COLOR4D colour[4];
1097 wxString text[4];
1098
1099 // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
1100 if( textOffset )
1101 {
1102 size [INSIDE] = showPinNames ? aPin->GetNameTextSize() : 0;
1103 thickness[INSIDE] = nameStrokeWidth;
1104 colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
1105 text [INSIDE] = aPin->GetShownName();
1106
1107 size [ABOVE] = showPinNumbers ? aPin->GetNumberTextSize() : 0;
1108 thickness[ABOVE] = numStrokeWidth;
1109 colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
1110 text [ABOVE] = aPin->GetShownNumber();
1111 }
1112 // Otherwise if both are shown pin NAMES go above and pin NUMBERS go below
1113 else if( showPinNames && showPinNumbers )
1114 {
1115 size [ABOVE] = aPin->GetNameTextSize();
1116 thickness[ABOVE] = nameStrokeWidth;
1117 colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
1118 text [ABOVE] = aPin->GetShownName();
1119
1120 size [BELOW] = aPin->GetNumberTextSize();
1121 thickness[BELOW] = numStrokeWidth;
1122 colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
1123 text [BELOW] = aPin->GetShownNumber();
1124 }
1125 else if( showPinNames )
1126 {
1127 size [ABOVE] = aPin->GetNameTextSize();
1128 thickness[ABOVE] = nameStrokeWidth;
1129 colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows, aDimmed );
1130 text [ABOVE] = aPin->GetShownName();
1131 }
1132 else if( showPinNumbers )
1133 {
1134 size [ABOVE] = aPin->GetNumberTextSize();
1135 thickness[ABOVE] = numStrokeWidth;
1136 colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows, aDimmed );
1137 text [ABOVE] = aPin->GetShownNumber();
1138 }
1139
1140 if( m_schSettings.m_ShowPinsElectricalType )
1141 {
1142 size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, schIUScale.mmToIU( 0.7 ) );
1143 thickness[OUTSIDE] = float( size[OUTSIDE] ) / 8.0f;
1144 colour [OUTSIDE] = getRenderColor( aPin, LAYER_PRIVATE_NOTES, drawingShadows, aDimmed );
1146 }
1147
1148 // Rendering text is expensive (particularly when using outline fonts). At small effective
1149 // sizes (ie: zoomed out) the visual differences between outline and/or stroke fonts and the
1150 // bitmap font becomes immaterial, and there's often more to draw when zoomed out so the
1151 // performance gain becomes more significant.
1152 #define BITMAP_FONT_SIZE_THRESHOLD 3.5
1153
1154 bool renderTextAsBitmap = size[0] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD
1155 && size[1] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD
1156 && size[2] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD
1157 && size[3] * m_gal->GetWorldScale() < BITMAP_FONT_SIZE_THRESHOLD;
1158
1159 if( !aPin->IsVisible() )
1160 {
1161 for( COLOR4D& c : colour )
1162 c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed );
1163 }
1164
1165 float insideOffset = (float) textOffset - thickness[INSIDE] / 2.0f;
1166 float outsideOffset = PIN_TEXT_MARGIN + TARGET_PIN_RADIUS - thickness[OUTSIDE] / 2.0f;
1167 float aboveOffset = PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[ABOVE] / 2.0f;
1168 float belowOffset = PIN_TEXT_MARGIN + penWidth / 2.0f + thickness[BELOW] / 2.0f;
1169
1170 if( isDangling )
1171 outsideOffset += TARGET_PIN_RADIUS / 2.0f;
1172
1173 if( drawingShadows )
1174 {
1175 float shadowWidth = getShadowWidth( aPin->IsBrightened() );
1176
1177 for( float& t : thickness )
1178 t += shadowWidth;
1179
1180 // Due to the fact a shadow text in position INSIDE or OUTSIDE is drawn left or right aligned,
1181 // it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
1182 // texts drawn as GR_TEXT_H_ALIGN_CENTER do not need a specific offset.
1183 // this offset is shadowWidth/2 but for some reason we need to slightly modify this offset
1184 // for a better look (better alignment of shadow shape), for KiCad font only
1185 if( !KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font )->IsOutline() )
1186 {
1187 const float adjust = 1.2f; // Value chosen after tests
1188 float shadowOffset = shadowWidth/2.0f * adjust;
1189 insideOffset -= shadowOffset;
1190 outsideOffset -= shadowOffset;
1191 }
1192 }
1193
1194 auto drawText =
1195 [&]( int i, const VECTOR2D& aPos, GR_TEXT_H_ALIGN_T hAlign, GR_TEXT_V_ALIGN_T vAlign,
1196 const EDA_ANGLE& aAngle )
1197 {
1198 if( text[i].IsEmpty() )
1199 return;
1200
1201 // Which of these gets used depends on the font technology, so set both
1202 m_gal->SetStrokeColor( colour[i] );
1203 m_gal->SetFillColor( colour[i] );
1204
1205 TEXT_ATTRIBUTES attrs;
1206 attrs.m_Font = KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font );
1207 attrs.m_Size = VECTOR2I( size[i], size[i] );
1208 attrs.m_Halign = hAlign;
1209 attrs.m_Valign = vAlign;
1210 attrs.m_Angle = aAngle;
1211 attrs.m_StrokeWidth = KiROUND( thickness[i] );
1212
1213 if( drawingShadows && !attrs.m_Font->IsOutline() )
1214 {
1215 strokeText( text[i], aPos, attrs, aPin->GetFontMetrics() );
1216 }
1217 else if( drawingShadows )
1218 {
1219 boxText( text[i], aPos, attrs, aPin->GetFontMetrics() );
1220 }
1221 else if( nonCached( aPin ) && renderTextAsBitmap )
1222 {
1223 bitmapText( text[i], aPos, attrs );
1224 const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
1225 }
1226 else
1227 {
1228 strokeText( text[i], aPos, attrs, aPin->GetFontMetrics() );
1229 const_cast<SCH_PIN*>( aPin )->SetFlags( IS_SHOWN_AS_BITMAP );
1230 }
1231 };
1232
1233 switch( aPin->GetOrientation() )
1234 {
1236 if( size[INSIDE] )
1237 {
1238 drawText( INSIDE, pos + VECTOR2D( -insideOffset - (float) len, 0 ),
1240 }
1241 if( size[OUTSIDE] )
1242 {
1243 drawText( OUTSIDE, pos + VECTOR2D( outsideOffset, 0 ),
1245 }
1246 if( size[ABOVE] )
1247 {
1248 drawText( ABOVE, pos + VECTOR2D( -len / 2.0, -aboveOffset ),
1250 }
1251 if( size[BELOW] )
1252 {
1253 drawText( BELOW, pos + VECTOR2D( -len / 2.0, belowOffset ),
1255 }
1256 break;
1257
1259 if( size[INSIDE] )
1260 {
1261 drawText( INSIDE, pos + VECTOR2D( insideOffset + (float) len, 0 ),
1263 }
1264 if( size[OUTSIDE] )
1265 {
1266 drawText( OUTSIDE, pos + VECTOR2D( -outsideOffset, 0 ),
1268 }
1269 if( size[ABOVE] )
1270 {
1271 drawText( ABOVE, pos + VECTOR2D( len / 2.0, -aboveOffset ),
1273 }
1274 if( size[BELOW] )
1275 {
1276 drawText( BELOW, pos + VECTOR2D( len / 2.0, belowOffset ),
1278 }
1279 break;
1280
1282 if( size[INSIDE] )
1283 {
1284 drawText( INSIDE, pos + VECTOR2D( 0, insideOffset + (float) len ),
1286 }
1287 if( size[OUTSIDE] )
1288 {
1289 drawText( OUTSIDE, pos + VECTOR2D( 0, -outsideOffset ),
1291 }
1292 if( size[ABOVE] )
1293 {
1294 drawText( ABOVE, pos + VECTOR2D( -aboveOffset, len / 2.0 ),
1296 }
1297 if( size[BELOW] )
1298 {
1299 drawText( BELOW, pos + VECTOR2D( belowOffset, len / 2.0 ),
1301 }
1302 break;
1303
1305 if( size[INSIDE] )
1306 {
1307 drawText( INSIDE, pos + VECTOR2D( 0, -insideOffset - (float) len ),
1309 }
1310 if( size[OUTSIDE] )
1311 {
1312 drawText( OUTSIDE, pos + VECTOR2D( 0, outsideOffset ),
1314 }
1315 if( size[ABOVE] )
1316 {
1317 drawText( ABOVE, pos + VECTOR2D( -aboveOffset, -len / 2.0 ),
1319 }
1320 if( size[BELOW] )
1321 {
1322 drawText( BELOW, pos + VECTOR2D( belowOffset, -len / 2.0 ),
1324 }
1325 break;
1326
1327 default:
1328 wxFAIL_MSG( "Unknown pin orientation" );
1329 }
1330}
1331
1332
1333// Draw the target (an open square) for a wire or label which has no connection or is
1334// being moved.
1335void SCH_PAINTER::drawDanglingIndicator( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth,
1336 bool aDangling, bool aDrawingShadows, bool aBrightened )
1337{
1338 if( m_schSettings.IsPrinting() )
1339 return;
1340
1341 int size = aDangling ? DANGLING_SYMBOL_SIZE : UNSELECTED_END_SIZE;
1342
1343 if( !aDangling )
1344 aWidth /= 2;
1345
1346 VECTOR2I radius( aWidth + schIUScale.MilsToIU( size / 2 ),
1347 aWidth + schIUScale.MilsToIU( size / 2 ) );
1348
1349 // Dangling symbols must be drawn in a slightly different colour so they can be seen when
1350 // they overlap with a junction dot.
1351 m_gal->SetStrokeColor( aColor.Brightened( 0.3 ) );
1352 m_gal->SetIsStroke( true );
1353 m_gal->SetIsFill( false );
1354 m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth( aBrightened )
1355 : m_schSettings.GetDanglingIndicatorThickness() );
1356
1357 m_gal->DrawRectangle( aPos - radius, aPos + radius );
1358}
1359
1360
1361void SCH_PAINTER::draw( const SCH_JUNCTION* aJct, int aLayer )
1362{
1363 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1364
1365 if( m_schSettings.IsPrinting() && drawingShadows )
1366 return;
1367
1368 if( drawingShadows && !( aJct->IsBrightened() || aJct->IsSelected() ) )
1369 return;
1370
1371 COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows );
1372
1373 int junctionSize = aJct->GetEffectiveDiameter() / 2;
1374
1375 if( junctionSize > 1 )
1376 {
1377 m_gal->SetIsStroke( drawingShadows );
1378 m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1379 m_gal->SetStrokeColor( color );
1380 m_gal->SetIsFill( !drawingShadows );
1381 m_gal->SetFillColor( color );
1382 m_gal->DrawCircle( aJct->GetPosition(), junctionSize );
1383 }
1384}
1385
1386
1387void SCH_PAINTER::draw( const SCH_LINE* aLine, int aLayer )
1388{
1389 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1390
1391 if( m_schSettings.IsPrinting() && drawingShadows )
1392 return;
1393
1394 bool drawingDangling = aLayer == LAYER_DANGLING;
1395 bool drawingOP = aLayer == LAYER_OP_VOLTAGES;
1396
1397 if( drawingShadows && !( aLine->IsBrightened() || aLine->IsSelected() ) )
1398 return;
1399
1400 // Line end dangling status isn't updated until the line is finished drawing, so don't warn
1401 // them about ends that are probably connected
1402 if( aLine->IsNew() && drawingDangling )
1403 return;
1404
1405 COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1406 float width = getLineWidth( aLine, drawingShadows );
1407 LINE_STYLE lineStyle = aLine->GetEffectiveLineStyle();
1408
1409 if( ( drawingDangling || drawingShadows ) && !aLine->IsNew() )
1410 {
1411 if( ( aLine->IsWire() && aLine->IsStartDangling() )
1412 || ( drawingShadows && aLine->IsSelected() && !aLine->HasFlag( STARTPOINT ) ) )
1413 {
1414 COLOR4D indicatorColor( color );
1415
1416 if( drawingShadows && !aLine->HasFlag( STARTPOINT ) )
1417 indicatorColor.Invert();
1418
1419 drawDanglingIndicator( aLine->GetStartPoint(), indicatorColor, KiROUND( width ),
1420 aLine->IsWire() && aLine->IsStartDangling(), drawingShadows,
1421 aLine->IsBrightened() );
1422 }
1423
1424 if( ( aLine->IsWire() && aLine->IsEndDangling() )
1425 || ( drawingShadows && aLine->IsSelected() && !aLine->HasFlag( ENDPOINT ) ) )
1426 {
1427 COLOR4D indicatorColor( color );
1428
1429 if( drawingShadows && !aLine->HasFlag( ENDPOINT ) )
1430 indicatorColor.Invert();
1431
1432 drawDanglingIndicator( aLine->GetEndPoint(), indicatorColor, KiROUND( width ),
1433 aLine->IsWire() && aLine->IsEndDangling(), drawingShadows,
1434 aLine->IsBrightened() );
1435 }
1436 }
1437
1438 if( drawingDangling )
1439 return;
1440
1441 if( drawingOP && !aLine->GetOperatingPoint().IsEmpty() )
1442 {
1443 int textSize = getOperatingPointTextSize();
1444 VECTOR2I pos = aLine->GetMidPoint();
1445 int textOffset = KiROUND( textSize * 0.22 );
1446 TEXT_ATTRIBUTES attrs;
1447
1448 if( aLine->GetStartPoint().y == aLine->GetEndPoint().y )
1449 {
1450 pos.y -= textOffset;
1453 }
1454 else
1455 {
1456 pos.x += KiROUND( textOffset * 1.2 );
1459 }
1460
1461 attrs.m_Font = KIFONT::FONT::GetFont(); // always use stroke font for performance
1462 attrs.m_Size = VECTOR2I( textSize, textSize );
1463 attrs.m_StrokeWidth = GetPenSizeForDemiBold( textSize );
1464 attrs.m_Color = m_schSettings.GetLayerColor( LAYER_OP_VOLTAGES );
1465
1466 knockoutText( aLine->GetOperatingPoint(), pos, attrs, aLine->GetFontMetrics() );
1467 }
1468
1469 if( drawingOP )
1470 return;
1471
1472 m_gal->SetIsStroke( true );
1473 m_gal->SetStrokeColor( color );
1474 m_gal->SetLineWidth( width );
1475
1476 if( lineStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows )
1477 {
1478 m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1479 }
1480 else
1481 {
1482 SHAPE_SEGMENT line( aLine->GetStartPoint(), aLine->GetEndPoint() );
1483
1484 STROKE_PARAMS::Stroke( &line, lineStyle, KiROUND( width ), &m_schSettings,
1485 [&]( const VECTOR2I& a, const VECTOR2I& b )
1486 {
1487 // DrawLine has problem with 0 length lines so enforce minimum
1488 if( a == b )
1489 m_gal->DrawLine( a+1, b );
1490 else
1491 m_gal->DrawLine( a, b );
1492 } );
1493 }
1494}
1495
1496
1497void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer, bool aDimmed )
1498{
1499 if( !isUnitAndConversionShown( aShape ) )
1500 return;
1501
1502 if( aShape->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
1503 return;
1504
1505 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1506
1507 if( m_schSettings.IsPrinting() && drawingShadows )
1508 return;
1509
1510 LINE_STYLE lineStyle = aShape->GetEffectiveLineStyle();
1511 COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows );
1512
1513 if( drawingShadows && !( aShape->IsBrightened() || aShape->IsSelected() ) )
1514 return;
1515
1516 auto drawShape =
1517 [&]( const SCH_SHAPE* shape )
1518 {
1519 switch( shape->GetShape() )
1520 {
1521 case SHAPE_T::ARC:
1522 {
1523 VECTOR2D start = shape->GetStart();
1524 VECTOR2D mid = shape->GetArcMid();
1525 VECTOR2D end = shape->GetEnd();
1526 VECTOR2D center = CalcArcCenter( start, mid, end );
1527
1528 EDA_ANGLE startAngle( start - center );
1529 EDA_ANGLE midAngle( mid - center );
1530 EDA_ANGLE endAngle( end - center );
1531
1532 EDA_ANGLE angle1 = midAngle - startAngle;
1533 EDA_ANGLE angle2 = endAngle - midAngle;
1534
1535 EDA_ANGLE angle = angle1.Normalize180() + angle2.Normalize180();
1536
1537 m_gal->DrawArc( center, ( start - center ).EuclideanNorm(), startAngle, angle );
1538 break;
1539 }
1540
1541 case SHAPE_T::CIRCLE:
1542 m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() );
1543 break;
1544
1545 case SHAPE_T::RECTANGLE:
1546 m_gal->DrawRectangle( shape->GetPosition(), shape->GetEnd() );
1547 break;
1548
1549 case SHAPE_T::POLY:
1550 {
1551 const std::vector<SHAPE*> polySegments = shape->MakeEffectiveShapes( true );
1552 std::deque<VECTOR2D> pts;
1553
1554 for( SHAPE* polySegment : polySegments )
1555 pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegment )->GetSeg().A );
1556
1557 pts.push_back( static_cast<SHAPE_SEGMENT*>( polySegments.back() )->GetSeg().B );
1558
1559 for( SHAPE* polySegment : polySegments )
1560 delete polySegment;
1561
1562 m_gal->DrawPolygon( pts );
1563 break;
1564 }
1565
1566 case SHAPE_T::BEZIER:
1567 {
1568 m_gal->DrawCurve( shape->GetStart(), shape->GetBezierC1(),
1569 shape->GetBezierC2(), shape->GetEnd() );
1570 break;
1571 }
1572
1573 default:
1574 UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() );
1575 }
1576 };
1577
1578 if( aLayer == LAYER_SELECTION_SHADOWS )
1579 {
1580 if( eeconfig()->m_Selection.fill_shapes )
1581 {
1582 // Consider a NAND gate. We have no idea which side of the arc is "inside"
1583 // so we can't reliably fill.
1584 if( aShape->GetShape() == SHAPE_T::ARC )
1585 m_gal->SetIsFill( aShape->IsFilled() );
1586 else
1587 m_gal->SetIsFill( true );
1588
1589 m_gal->SetIsStroke( false );
1590 m_gal->SetFillColor( color );
1591 }
1592 else
1593 {
1594 m_gal->SetIsStroke( true );
1595 m_gal->SetIsFill( false );
1596 m_gal->SetLineWidth( getLineWidth( aShape, true ) );
1597 m_gal->SetStrokeColor( color );
1598 }
1599
1600 drawShape( aShape );
1601 }
1602 else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
1603 {
1604 switch( aShape->GetFillMode() )
1605 {
1606 case FILL_T::NO_FILL:
1607 break;
1608
1610 // Fill in the foreground layer
1611 break;
1612
1615 // Do not fill the shape in B&W print mode, to avoid to visible items inside the shape
1616 if( !m_schSettings.PrintBlackAndWhiteReq() )
1617 {
1619 color = m_schSettings.GetLayerColor( LAYER_DEVICE_BACKGROUND );
1620
1621 m_gal->SetIsFill( true );
1622 m_gal->SetIsStroke( false );
1623 m_gal->SetFillColor( color );
1624
1625 drawShape( aShape );
1626 }
1627 break;
1628 }
1629 }
1630 else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES || aLayer == LAYER_PRIVATE_NOTES
1631 || aLayer == LAYER_RULE_AREAS )
1632 {
1633 // Shapes filled with the device colour must be filled in the foreground
1634 if( aShape->GetFillMode() == FILL_T::FILLED_SHAPE )
1635 {
1636 m_gal->SetIsFill( true );
1637 m_gal->SetIsStroke( false );
1638 m_gal->SetFillColor( color );
1639
1640 drawShape( aShape );
1641 }
1642
1643 float lineWidth = getLineWidth( aShape, drawingShadows );
1644
1645 if( lineWidth > 0 )
1646 {
1647 m_gal->SetIsFill( false );
1648 m_gal->SetIsStroke( true );
1649 m_gal->SetLineWidth( lineWidth );
1650 m_gal->SetStrokeColor( color );
1651
1652 if( lineStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows )
1653 {
1654 drawShape( aShape );
1655 }
1656 else
1657 {
1658 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
1659
1660 for( SHAPE* shape : shapes )
1661 {
1662 STROKE_PARAMS::Stroke( shape, lineStyle, KiROUND( lineWidth ), &m_schSettings,
1663 [this]( const VECTOR2I& a, const VECTOR2I& b )
1664 {
1665 // DrawLine has problem with 0 length lines so enforce minimum
1666 if( a == b )
1667 m_gal->DrawLine( a+1, b );
1668 else
1669 m_gal->DrawLine( a, b );
1670 } );
1671 }
1672
1673 for( SHAPE* shape : shapes )
1674 delete shape;
1675 }
1676 }
1677 }
1678}
1679
1680
1681void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer, bool aDimmed )
1682{
1683 if( !isUnitAndConversionShown( aText ) )
1684 return;
1685
1686 if( aText->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
1687 return;
1688
1689 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1690
1691 if( m_schSettings.IsPrinting() && drawingShadows )
1692 return;
1693
1694 if( drawingShadows && !( aText->IsBrightened() || aText->IsSelected() ) )
1695 return;
1696
1697 switch( aText->Type() )
1698 {
1699 case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1700 case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1701 case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1702 case SCH_DIRECTIVE_LABEL_T: aLayer = LAYER_NETCLASS_REFS; break;
1703 case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1704 case SCH_TEXT_T: aLayer = aText->GetParentSymbol() ? LAYER_DEVICE
1705 : LAYER_NOTES; break;
1706 default: aLayer = LAYER_NOTES; break;
1707 }
1708
1709 COLOR4D color = getRenderColor( aText, aLayer, drawingShadows, aDimmed );
1710
1711 if( m_schematic )
1712 {
1713 SCH_CONNECTION* conn = nullptr;
1714
1715 if( !aText->IsConnectivityDirty() )
1716 conn = aText->Connection();
1717
1718 if( conn && conn->IsBus() )
1719 color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1720 }
1721
1722 if( !( aText->IsVisible() || aText->IsForceVisible() ) )
1723 {
1724 if( m_schSettings.m_IsSymbolEditor || eeconfig()->m_Appearance.show_hidden_fields )
1725 color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1726 else
1727 return;
1728 }
1729
1730 m_gal->SetStrokeColor( color );
1731 m_gal->SetFillColor( color );
1732
1733 wxString shownText( aText->GetShownText( true ) );
1734 VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings );
1735 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
1736 KIFONT::FONT* font = getFont( aText );
1737
1738 attrs.m_Angle = aText->GetDrawRotation();
1739 attrs.m_StrokeWidth = KiROUND( getTextThickness( aText ) );
1740
1741 if( drawingShadows && font->IsOutline() )
1742 {
1743 BOX2I bBox = aText->GetBoundingBox();
1744 bBox.Inflate( KiROUND( getTextThickness( aText ) * 2 ) );
1745
1746 m_gal->SetIsStroke( false );
1747 m_gal->SetIsFill( true );
1748 m_gal->DrawRectangle( bBox.GetPosition(), bBox.GetEnd() );
1749 }
1750 else if( aText->GetLayer() == LAYER_DEVICE )
1751 {
1752 BOX2I bBox = aText->GetBoundingBox();
1753 VECTOR2D pos = bBox.Centre();
1754
1755 // Due to the fact a shadow text can be drawn left or right aligned, it needs to be
1756 // offset by shadowWidth/2 to be drawn at the same place as normal text.
1757 // For some reason we need to slightly modify this offset for a better look (better
1758 // alignment of shadow shape), for KiCad font only.
1759 double shadowOffset = 0.0;
1760
1761 if( drawingShadows )
1762 {
1763 double shadowWidth = getShadowWidth( !aText->IsSelected() );
1764 attrs.m_StrokeWidth += getShadowWidth( !aText->IsSelected() );
1765
1766 const double adjust = 1.2f; // Value chosen after tests
1767 shadowOffset = shadowWidth/2.0f * adjust;
1768 }
1769
1770 if( attrs.m_Angle == ANGLE_VERTICAL )
1771 {
1772 switch( attrs.m_Halign )
1773 {
1775 pos.y = bBox.GetBottom() + shadowOffset;
1776 break;
1778 pos.y = ( bBox.GetTop() + bBox.GetBottom() ) / 2.0;
1779 break;
1781 pos.y = bBox.GetTop() - shadowOffset;
1782 break;
1784 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
1785 break;
1786 }
1787 }
1788 else
1789 {
1790 switch( attrs.m_Halign )
1791 {
1793 pos.x = bBox.GetLeft() - shadowOffset;
1794 break;
1796 pos.x = ( bBox.GetLeft() + bBox.GetRight() ) / 2.0;
1797 break;
1799 pos.x = bBox.GetRight() + shadowOffset;
1800 break;
1802 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
1803 break;
1804 }
1805 }
1806
1807 // Because the text vertical position is the bounding box center, the text is drawn as
1808 // vertically centered.
1810
1811 strokeText( shownText, pos, attrs, aText->GetFontMetrics() );
1812 }
1813 else if( drawingShadows )
1814 {
1815 m_gal->SetIsFill( false );
1816 m_gal->SetIsStroke( true );
1817 attrs.m_StrokeWidth += KiROUND( getShadowWidth( !aText->IsSelected() ) );
1818 attrs.m_Underlined = false;
1819
1820 // Fudge factors to match 6.0 positioning
1821 // New text stroking has width dependent offset but we need to center the shadow on the
1822 // stroke. NB this offset is in font.cpp also.
1823 int fudge = KiROUND( getShadowWidth( !aText->IsSelected() ) / 1.52 );
1824
1825 if( attrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && attrs.m_Angle == ANGLE_0 )
1826 text_offset.x -= fudge;
1827 else if( attrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && attrs.m_Angle == ANGLE_90 )
1828 text_offset.y -= fudge;
1829 else if( attrs.m_Halign == GR_TEXT_H_ALIGN_RIGHT && attrs.m_Angle == ANGLE_0 )
1830 text_offset.x += fudge;
1831 else if( attrs.m_Halign == GR_TEXT_H_ALIGN_LEFT && attrs.m_Angle == ANGLE_90 )
1832 text_offset.y += fudge;
1833
1834 strokeText( shownText, aText->GetDrawPos() + text_offset, attrs, aText->GetFontMetrics() );
1835 }
1836 else
1837 {
1838 if( aText->IsHypertext() && aText->IsRollover() )
1839 {
1840 m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
1841 m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
1842 attrs.m_Underlined = true;
1843 }
1844
1845 // Adjust text drawn in an outline font to more closely mimic the positioning of
1846 // SCH_FIELD text.
1847 if( font->IsOutline() && aText->Type() == SCH_TEXT_T )
1848 {
1849 BOX2I firstLineBBox = aText->GetTextBox( 0 );
1850 int sizeDiff = firstLineBBox.GetHeight() - aText->GetTextSize().y;
1851 int adjust = KiROUND( sizeDiff * 0.4 );
1852 VECTOR2I adjust_offset( 0, - adjust );
1853
1854 RotatePoint( adjust_offset, aText->GetDrawRotation() );
1855 text_offset += adjust_offset;
1856 }
1857
1858 if( nonCached( aText )
1859 && aText->RenderAsBitmap( m_gal->GetWorldScale() )
1860 && !shownText.Contains( wxT( "\n" ) ) )
1861 {
1862 bitmapText( shownText, aText->GetDrawPos() + text_offset, attrs );
1863 const_cast<SCH_TEXT*>( aText )->SetFlags( IS_SHOWN_AS_BITMAP );
1864 }
1865 else
1866 {
1867 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
1868
1869 if( !aText->IsHypertext() && font->IsOutline() )
1870 cache = aText->GetRenderCache( font, shownText, text_offset );
1871
1872 if( cache )
1873 {
1874 m_gal->SetLineWidth( attrs.m_StrokeWidth );
1875 m_gal->DrawGlyphs( *cache );
1876 }
1877 else
1878 {
1879 strokeText( shownText, aText->GetDrawPos() + text_offset, attrs,
1880 aText->GetFontMetrics() );
1881 }
1882
1883 const_cast<SCH_TEXT*>( aText )->ClearFlags( IS_SHOWN_AS_BITMAP );
1884 }
1885 }
1886}
1887
1888
1889void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer, bool aDimmed )
1890{
1891 if( aTextBox->Type() == SCH_TABLECELL_T )
1892 {
1893 const SCH_TABLECELL* cell = static_cast<const SCH_TABLECELL*>( aTextBox );
1894
1895 if( cell->GetColSpan() == 0 || cell->GetRowSpan() == 0 )
1896 return;
1897 }
1898
1899 if( !isUnitAndConversionShown( aTextBox ) )
1900 return;
1901
1902 if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor )
1903 return;
1904
1905 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1906
1907 if( m_schSettings.IsPrinting() && drawingShadows )
1908 return;
1909
1910 COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows, aDimmed );
1911 COLOR4D bg = m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND );
1912 float borderWidth = getLineWidth( aTextBox, drawingShadows );
1913 KIFONT::FONT* font = getFont( aTextBox );
1914
1915 auto drawText =
1916 [&]()
1917 {
1918 wxString shownText = aTextBox->GetShownText( true );
1919 TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
1920
1921 attrs.m_Angle = aTextBox->GetDrawRotation();
1922 attrs.m_StrokeWidth = KiROUND( getTextThickness( aTextBox ) );
1923
1924 if( aTextBox->IsHypertext() && aTextBox->IsRollover() )
1925 {
1926 m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
1927 m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
1928 attrs.m_Underlined = true;
1929 }
1930
1931 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
1932
1933 if( !aTextBox->IsHypertext() && font->IsOutline() )
1934 cache = aTextBox->GetRenderCache( font, shownText );
1935
1936 if( cache )
1937 {
1938 m_gal->SetLineWidth( attrs.m_StrokeWidth );
1939 m_gal->DrawGlyphs( *cache );
1940 }
1941 else
1942 {
1943 strokeText( shownText, aTextBox->GetDrawPos(), attrs, aTextBox->GetFontMetrics() );
1944 }
1945 };
1946
1947 if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) )
1948 return;
1949
1950 m_gal->SetFillColor( color );
1951 m_gal->SetStrokeColor( color );
1952
1953 if( aLayer == LAYER_SELECTION_SHADOWS )
1954 {
1955 m_gal->SetIsFill( true );
1956 m_gal->SetIsStroke( false );
1957 m_gal->SetLineWidth( borderWidth );
1958
1959 m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
1960 }
1961 else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND )
1962 {
1963 // Do not fill the shape in B&W print mode, to avoid to visible items
1964 // inside the shape
1965 if( aTextBox->IsFilled() && !m_schSettings.PrintBlackAndWhiteReq() )
1966 {
1967 m_gal->SetIsFill( true );
1968 m_gal->SetIsStroke( false );
1969 m_gal->SetLineWidth( borderWidth );
1970
1971 m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
1972 }
1973 }
1974 else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES || aLayer == LAYER_PRIVATE_NOTES )
1975 {
1976 drawText();
1977
1978 if( aTextBox->Type() != SCH_TABLECELL_T && borderWidth > 0 )
1979 {
1980 COLOR4D borderColor = aTextBox->GetStroke().GetColor();
1981 LINE_STYLE borderStyle = aTextBox->GetEffectiveLineStyle();
1982 double transparency = aTextBox->GetForcedTransparency();
1983
1984 if( m_schSettings.m_OverrideItemColors || aTextBox->IsBrightened()
1985 || borderColor == COLOR4D::UNSPECIFIED )
1986 {
1987 borderColor = m_schSettings.GetLayerColor( aLayer );
1988 }
1989
1990 if( transparency > 0.0 )
1991 borderColor = borderColor.WithAlpha( borderColor.a * ( 1.0 - transparency ) );
1992
1993 if( aDimmed )
1994 {
1995 borderColor = borderColor.Mix( bg, 0.5f );
1996 borderColor.Desaturate( );
1997 }
1998
1999 m_gal->SetIsFill( false );
2000 m_gal->SetIsStroke( true );
2001 m_gal->SetStrokeColor( borderColor );
2002 m_gal->SetLineWidth( borderWidth );
2003
2004 if( borderStyle <= LINE_STYLE::FIRST_TYPE || drawingShadows )
2005 {
2006 m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() );
2007 }
2008 else
2009 {
2010 std::vector<SHAPE*> shapes = aTextBox->MakeEffectiveShapes( true );
2011
2012 for( SHAPE* shape : shapes )
2013 {
2014 STROKE_PARAMS::Stroke( shape, borderStyle, KiROUND( borderWidth ),
2015 &m_schSettings,
2016 [this]( const VECTOR2I& a, const VECTOR2I& b )
2017 {
2018 // DrawLine has problem with 0 length lines so enforce minimum
2019 if( a == b )
2020 m_gal->DrawLine( a+1, b );
2021 else
2022 m_gal->DrawLine( a, b );
2023 } );
2024 }
2025
2026 for( SHAPE* shape : shapes )
2027 delete shape;
2028 }
2029 }
2030 }
2031}
2032
2033
2034void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed )
2035{
2036 for( SCH_TABLECELL* cell : aTable->GetCells() )
2037 draw( cell, aLayer, aDimmed );
2038
2039 if( aLayer == LAYER_SELECTION_SHADOWS )
2040 return;
2041
2042 VECTOR2I pos = aTable->GetPosition();
2043 VECTOR2I end = aTable->GetEnd();
2044
2045 int lineWidth;
2046 COLOR4D color;
2047 LINE_STYLE lineStyle;
2048
2049 auto setupStroke =
2050 [&]( const STROKE_PARAMS& stroke )
2051 {
2052 lineWidth = stroke.GetWidth();
2053 color = stroke.GetColor();
2054 lineStyle = stroke.GetLineStyle();
2055
2056 if( lineWidth == 0 )
2057 lineWidth = m_schSettings.GetDefaultPenWidth();
2058
2060 color = m_schSettings.GetLayerColor( LAYER_NOTES );
2061
2062 if( lineStyle == LINE_STYLE::DEFAULT )
2063 lineStyle = LINE_STYLE::SOLID;
2064
2065 m_gal->SetIsFill( false );
2066 m_gal->SetIsStroke( true );
2067 m_gal->SetStrokeColor( color );
2068 m_gal->SetLineWidth( (float) lineWidth );
2069 };
2070
2071 auto strokeShape =
2072 [&]( const SHAPE& shape )
2073 {
2074 STROKE_PARAMS::Stroke( &shape, lineStyle, lineWidth, &m_schSettings,
2075 [&]( const VECTOR2I& a, const VECTOR2I& b )
2076 {
2077 // DrawLine has problem with 0 length lines so enforce minimum
2078 if( a == b )
2079 m_gal->DrawLine( a+1, b );
2080 else
2081 m_gal->DrawLine( a, b );
2082 } );
2083 };
2084
2085 auto strokeLine =
2086 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
2087 {
2088 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
2089 {
2090 m_gal->DrawLine( ptA, ptB );
2091 }
2092 else
2093 {
2094 SHAPE_SEGMENT seg( ptA, ptB );
2095 strokeShape( seg );
2096 }
2097 };
2098
2099 auto strokeRect =
2100 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB )
2101 {
2102 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
2103 {
2104 m_gal->DrawRectangle( ptA, ptB );
2105 }
2106 else
2107 {
2108 SHAPE_RECT rect( BOX2I( ptA, ptB - ptA ) );
2109 strokeShape( rect );
2110 }
2111 };
2112
2113 if( aTable->GetSeparatorsStroke().GetWidth() >= 0 )
2114 {
2115 setupStroke( aTable->GetSeparatorsStroke() );
2116
2117 if( aTable->StrokeColumns() )
2118 {
2119 for( int col = 0; col < aTable->GetColCount() - 1; ++col )
2120 {
2121 for( int row = 0; row < aTable->GetRowCount(); ++row )
2122 {
2123 SCH_TABLECELL* cell = aTable->GetCell( row, col );
2124 VECTOR2I topRight( cell->GetEndX(), cell->GetStartY() );
2125
2126 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
2127 strokeLine( topRight, cell->GetEnd() );
2128 }
2129 }
2130 }
2131
2132 if( aTable->StrokeRows() )
2133 {
2134 for( int row = 0; row < aTable->GetRowCount() - 1; ++row )
2135 {
2136 for( int col = 0; col < aTable->GetColCount(); ++col )
2137 {
2138 SCH_TABLECELL* cell = aTable->GetCell( row, col );
2139 VECTOR2I botLeft( cell->GetStartX(), cell->GetEndY() );
2140
2141 if( cell->GetColSpan() > 0 && cell->GetRowSpan() > 0 )
2142 strokeLine( botLeft, cell->GetEnd() );
2143 }
2144 }
2145 }
2146 }
2147
2148 if( aTable->GetBorderStroke().GetWidth() >= 0 )
2149 {
2150 setupStroke( aTable->GetBorderStroke() );
2151
2152 if( aTable->StrokeHeader() )
2153 {
2154 SCH_TABLECELL* cell = aTable->GetCell( 0, 0 );
2155 strokeLine( VECTOR2I( pos.x, cell->GetEndY() ), VECTOR2I( end.x, cell->GetEndY() ) );
2156 }
2157
2158 if( aTable->StrokeExternal() )
2159 strokeRect( pos, end );
2160 }
2161}
2162
2163
2164wxString SCH_PAINTER::expandLibItemTextVars( const wxString& aSourceText,
2165 const SCH_SYMBOL* aSymbolContext )
2166{
2167 std::function<bool( wxString* )> symbolResolver =
2168 [&]( wxString* token ) -> bool
2169 {
2170 return aSymbolContext->ResolveTextVar( &m_schematic->CurrentSheet(), token );
2171 };
2172
2173 return ExpandTextVars( aSourceText, &symbolResolver );
2174}
2175
2176
2177void SCH_PAINTER::draw( const SCH_SYMBOL* aSymbol, int aLayer )
2178{
2179 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2180
2181 if( m_schSettings.IsPrinting() && drawingShadows )
2182 return;
2183
2184 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2185 {
2186 for( const SCH_FIELD& field : aSymbol->GetFields() )
2187 draw( &field, aLayer, aSymbol->GetDNP() );
2188 }
2189
2190 if( isFieldsLayer( aLayer ) )
2191 return;
2192
2193 if( drawingShadows && !( aSymbol->IsBrightened() || aSymbol->IsSelected() ) )
2194 {
2195 // Don't exit here; symbol may still have selected pins
2196 // return;
2197 }
2198
2199 int unit = aSymbol->GetUnitSelection( &m_schematic->CurrentSheet() );
2200 int bodyStyle = aSymbol->GetBodyStyle();
2201
2202 // Use dummy symbol if the actual couldn't be found (or couldn't be locked).
2203 LIB_SYMBOL* originalSymbol = aSymbol->GetLibSymbolRef() ? aSymbol->GetLibSymbolRef().get()
2204 : dummy();
2205 std::vector<SCH_PIN*> originalPins = originalSymbol->GetPins( unit, bodyStyle );
2206
2207 // Copy the source so we can re-orient and translate it.
2208 LIB_SYMBOL tempSymbol( *originalSymbol );
2209 std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( unit, bodyStyle );
2210
2211 tempSymbol.SetFlags( aSymbol->GetFlags() );
2212
2213 OrientAndMirrorSymbolItems( &tempSymbol, aSymbol->GetOrientation() );
2214
2215 for( SCH_ITEM& tempItem : tempSymbol.GetDrawItems() )
2216 {
2217 tempItem.SetFlags( aSymbol->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
2218 tempItem.Move( aSymbol->GetPosition() );
2219
2220 if( tempItem.Type() == SCH_TEXT_T )
2221 {
2222 SCH_TEXT* textItem = static_cast<SCH_TEXT*>( &tempItem );
2223
2224 if( textItem->HasTextVars() )
2225 textItem->SetText( expandLibItemTextVars( textItem->GetText(), aSymbol ) );
2226 }
2227 else if( tempItem.Type() == SCH_TEXTBOX_T )
2228 {
2229 SCH_TEXTBOX* textboxItem = static_cast<SCH_TEXTBOX*>( &tempItem );
2230
2231 if( textboxItem->HasTextVars() )
2232 textboxItem->SetText( expandLibItemTextVars( textboxItem->GetText(), aSymbol ) );
2233 }
2234 }
2235
2236 // Copy the pin info from the symbol to the temp pins
2237 for( unsigned i = 0; i < tempPins.size(); ++ i )
2238 {
2239 SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
2240 SCH_PIN* tempPin = tempPins[ i ];
2241
2242 tempPin->ClearFlags();
2243 tempPin->SetFlags( symbolPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
2244 // IS_SHOWN_AS_BITMAP
2245
2246 tempPin->SetName( expandLibItemTextVars( symbolPin->GetShownName(), aSymbol ) );
2247 tempPin->SetType( symbolPin->GetType() );
2248 tempPin->SetShape( symbolPin->GetShape() );
2249
2250 if( symbolPin->IsDangling() )
2251 tempPin->SetFlags( IS_DANGLING );
2252 else
2253 tempPin->ClearFlags( IS_DANGLING );
2254
2255 tempPin->SetOperatingPoint( symbolPin->GetOperatingPoint() );
2256 }
2257
2258 draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetBodyStyle(), aSymbol->GetDNP() );
2259
2260 for( unsigned i = 0; i < tempPins.size(); ++i )
2261 {
2262 SCH_PIN* symbolPin = aSymbol->GetPin( originalPins[ i ] );
2263 SCH_PIN* tempPin = tempPins[ i ];
2264
2265 symbolPin->ClearFlags();
2266 tempPin->ClearFlags( IS_DANGLING ); // Clear this temporary flag
2267 symbolPin->SetFlags( tempPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED,
2268 // IS_SHOWN_AS_BITMAP
2269 }
2270
2271 if( aSymbol->GetDNP() )
2272 {
2273 BOX2I bbox = aSymbol->GetBodyBoundingBox();
2274 BOX2I pins = aSymbol->GetBodyAndPinsBoundingBox();
2275 VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), pins.GetEnd().x - bbox.GetEnd().x ),
2276 std::max( bbox.GetY() - pins.GetY(), pins.GetEnd().y - bbox.GetEnd().y ) );
2277
2278 margins.x = std::max( margins.x * 0.6, margins.y * 0.3 );
2279 margins.y = std::max( margins.y * 0.6, margins.x * 0.3 );
2280 bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) );
2281
2282 VECTOR2I pt1 = bbox.GetOrigin();
2283 VECTOR2I pt2 = bbox.GetEnd();
2284
2285 m_gal->PushDepth();
2286 m_gal->AdvanceDepth();
2287 m_gal->SetIsStroke( true );
2288 m_gal->SetIsFill( true );
2289 m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_DNP_MARKER ) );
2290 m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_DNP_MARKER ) );
2291
2292 m_gal->DrawSegment( pt1, pt2, 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) );
2293 std::swap( pt1.x, pt2.x );
2294 m_gal->DrawSegment( pt1, pt2, 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS ) );
2295 m_gal->PopDepth();
2296 }
2297}
2298
2299
2300void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed )
2301{
2302 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2303
2304 if( m_schSettings.IsPrinting() && drawingShadows )
2305 return;
2306
2307 if( drawingShadows && !( aField->IsBrightened() || aField->IsSelected() ) )
2308 return;
2309
2310 if( !isUnitAndConversionShown( aField ) )
2311 return;
2312
2313 // Must check layer as fields are sometimes drawn by their parent rather than directly
2314 // from the view.
2315 int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
2316 int layers_count;
2317 bool foundLayer = false;
2318
2319 aField->ViewGetLayers( layers, layers_count );
2320
2321 for( int i = 0; i < layers_count; ++i )
2322 {
2323 if( layers[i] == aLayer )
2324 foundLayer = true;
2325 }
2326
2327 if( !foundLayer )
2328 return;
2329
2330 aLayer = aField->GetLayer();
2331
2332 COLOR4D color = getRenderColor( aField, aLayer, drawingShadows, aDimmed );
2333
2334 if( !( aField->IsVisible() || aField->IsForceVisible() ) )
2335 {
2336 bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_fields
2337 : m_schSettings.m_ShowHiddenFields;
2338
2339 if( force_show )
2340 color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows, aDimmed );
2341 else
2342 return;
2343 }
2344
2345 wxString shownText = aField->GetShownText( true );
2346
2347 if( shownText.IsEmpty() )
2348 return;
2349
2350 // Calculate the text orientation according to the parent orientation.
2351 EDA_ANGLE orient = aField->GetTextAngle();
2352
2353 if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T )
2354 {
2355 if( static_cast<SCH_SYMBOL*>( aField->GetParent() )->GetTransform().y1 )
2356 {
2357 // Rotate symbol 90 degrees.
2358 if( orient.IsHorizontal() )
2359 orient = ANGLE_VERTICAL;
2360 else
2361 orient = ANGLE_HORIZONTAL;
2362 }
2363 }
2364
2365 /*
2366 * Calculate the text justification, according to the symbol orientation/mirror.
2367 * This is a bit complicated due to cumulative calculations:
2368 * - numerous cases (mirrored or not, rotation)
2369 * - the DrawGraphicText function recalculate also H and H justifications according to the
2370 * text orientation.
2371 * - when symbol is mirrored, the text is not mirrored and justifications are complicated
2372 * to calculate so the easier way is to use no justifications (centered text) and use
2373 * GetBoundingBox to know the text coordinate considered as centered
2374 */
2375 BOX2I bbox = aField->GetBoundingBox();
2376
2377 if( aField->GetParent() && aField->GetParent()->Type() == SCH_GLOBAL_LABEL_T )
2378 {
2379 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( aField->GetParent() );
2380 bbox.Offset( label->GetSchematicTextOffset( &m_schSettings ) );
2381 }
2382
2383 if( m_schSettings.GetDrawBoundingBoxes() )
2384 drawItemBoundingBox( aField );
2385
2386 m_gal->SetStrokeColor( color );
2387 m_gal->SetFillColor( color );
2388
2389 if( drawingShadows && getFont( aField )->IsOutline() )
2390 {
2391 BOX2I shadow_box = bbox;
2392 shadow_box.Inflate( KiROUND( getTextThickness( aField ) * 2 ) );
2393
2394 m_gal->SetIsStroke( false );
2395 m_gal->SetIsFill( true );
2396 m_gal->DrawRectangle( shadow_box.GetPosition(), shadow_box.GetEnd() );
2397 }
2398 else
2399 {
2400 VECTOR2I textpos = bbox.Centre();
2401 TEXT_ATTRIBUTES attributes = aField->GetAttributes();
2402
2403 attributes.m_Halign = GR_TEXT_H_ALIGN_CENTER;
2404 attributes.m_Valign = GR_TEXT_V_ALIGN_CENTER;
2405 attributes.m_StrokeWidth = KiROUND( getTextThickness( aField ) );
2406 attributes.m_Angle = orient;
2407
2408 if( drawingShadows )
2409 attributes.m_StrokeWidth += getShadowWidth( !aField->IsSelected() );
2410
2411 if( aField->IsHypertext() && aField->IsRollover() )
2412 {
2413 m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
2414 m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_HOVERED ) );
2415 attributes.m_Underlined = true;
2416 }
2417
2418 if( nonCached( aField ) && aField->RenderAsBitmap( m_gal->GetWorldScale() ) )
2419 {
2420 bitmapText( shownText, textpos, attributes );
2421 const_cast<SCH_FIELD*>( aField )->SetFlags( IS_SHOWN_AS_BITMAP );
2422 }
2423 else
2424 {
2425 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
2426
2427 if( !aField->IsHypertext() )
2428 cache = aField->GetRenderCache( shownText, textpos, attributes );
2429
2430 if( cache )
2431 {
2432 m_gal->SetLineWidth( attributes.m_StrokeWidth );
2433 m_gal->DrawGlyphs( *cache );
2434 }
2435 else
2436 {
2437 strokeText( shownText, textpos, attributes, aField->GetFontMetrics() );
2438 }
2439
2440 const_cast<SCH_FIELD*>( aField )->ClearFlags( IS_SHOWN_AS_BITMAP );
2441 }
2442 }
2443
2444 // Draw the umbilical line
2445 if( aField->IsMoving() && m_schematic )
2446 {
2447 VECTOR2I parentPos = aField->GetParentPosition();
2448
2449 m_gal->SetLineWidth( m_schSettings.GetOutlineWidth() );
2450 m_gal->SetStrokeColor( getRenderColor( aField, LAYER_SCHEMATIC_ANCHOR, drawingShadows ) );
2451 m_gal->DrawLine( bbox.Centre(), parentPos );
2452 }
2453}
2454
2455
2456void SCH_PAINTER::draw( const SCH_GLOBALLABEL* aLabel, int aLayer )
2457{
2458 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2459
2460 if( m_schSettings.IsPrinting() && drawingShadows )
2461 return;
2462
2463 bool drawingDangling = aLayer == LAYER_DANGLING;
2464
2465 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2466 {
2467 for( const SCH_FIELD& field : aLabel->GetFields() )
2468 draw( &field, aLayer, false );
2469 }
2470
2471 if( isFieldsLayer( aLayer ) )
2472 return;
2473
2474 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2475 return;
2476
2477 COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
2478
2479 if( drawingDangling )
2480 {
2481 if( aLabel->IsDangling() )
2482 {
2483 drawDanglingIndicator( aLabel->GetTextPos(), color,
2485 drawingShadows, aLabel->IsBrightened() );
2486 }
2487
2488 return;
2489 }
2490
2491 std::vector<VECTOR2I> pts;
2492 std::deque<VECTOR2D> pts2;
2493
2494 aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
2495
2496 for( const VECTOR2I& p : pts )
2497 pts2.emplace_back( VECTOR2D( p.x, p.y ) );
2498
2499 m_gal->SetIsStroke( true );
2500 m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
2501 m_gal->SetStrokeColor( color );
2502
2503 if( drawingShadows )
2504 {
2505 m_gal->SetIsFill( eeconfig()->m_Selection.fill_shapes );
2506 m_gal->SetFillColor( color );
2507 m_gal->DrawPolygon( pts2 );
2508 }
2509 else
2510 {
2511 m_gal->SetIsFill( false );
2512 m_gal->DrawPolyline( pts2 );
2513 }
2514
2515 draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer, false );
2516}
2517
2518
2519void SCH_PAINTER::draw( const SCH_LABEL* aLabel, int aLayer )
2520{
2521 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2522
2523 if( m_schSettings.IsPrinting() && drawingShadows )
2524 return;
2525
2526 bool drawingDangling = aLayer == LAYER_DANGLING;
2527
2528 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2529 {
2530 for( const SCH_FIELD& field : aLabel->GetFields() )
2531 draw( &field, aLayer, false );
2532 }
2533
2534 if( isFieldsLayer( aLayer ) )
2535 return;
2536
2537 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2538 return;
2539
2540 COLOR4D color = getRenderColor( aLabel, LAYER_HIERLABEL, drawingShadows );
2541
2542 if( drawingDangling )
2543 {
2544 if( aLabel->IsDangling() )
2545 {
2546 drawDanglingIndicator( aLabel->GetTextPos(), color,
2548 drawingShadows, aLabel->IsBrightened() );
2549 }
2550
2551 return;
2552 }
2553
2554 draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer, false );
2555}
2556
2557
2558void SCH_PAINTER::draw( const SCH_HIERLABEL* aLabel, int aLayer )
2559{
2560 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2561
2562 if( m_schSettings.IsPrinting() && drawingShadows )
2563 return;
2564
2565 bool drawingDangling = aLayer == LAYER_DANGLING;
2566
2567 if( !( drawingShadows || drawingDangling ) || eeconfig()->m_Selection.draw_selected_children )
2568 {
2569 for( const SCH_FIELD& field : aLabel->GetFields() )
2570 draw( &field, aLayer, false );
2571 }
2572
2573 if( isFieldsLayer( aLayer ) )
2574 return;
2575
2576 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2577 return;
2578
2579 COLOR4D color = getRenderColor( aLabel, LAYER_HIERLABEL, drawingShadows );
2580
2581 if( drawingDangling )
2582 {
2583 if( aLabel->IsDangling() )
2584 {
2585 drawDanglingIndicator( aLabel->GetTextPos(), color,
2587 drawingShadows, aLabel->IsBrightened() );
2588 }
2589
2590 return;
2591 }
2592
2593 if( m_schematic )
2594 {
2595 SCH_CONNECTION* conn = nullptr;
2596
2597 if( !aLabel->IsConnectivityDirty() )
2598 conn = aLabel->Connection();
2599
2600 if( conn && conn->IsBus() )
2601 color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
2602 }
2603
2604 std::vector<VECTOR2I> pts;
2605 std::deque<VECTOR2D> pts2;
2606
2607 aLabel->CreateGraphicShape( &m_schSettings, pts, (VECTOR2I)aLabel->GetTextPos() );
2608
2609 for( const VECTOR2I& p : pts )
2610 pts2.emplace_back( VECTOR2D( p.x, p.y ) );
2611
2612 m_gal->SetIsFill( true );
2613 m_gal->SetFillColor( m_schSettings.GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) );
2614 m_gal->SetIsStroke( true );
2615 m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
2616 m_gal->SetStrokeColor( color );
2617 m_gal->DrawPolyline( pts2 );
2618
2619 draw( static_cast<const SCH_TEXT*>( aLabel ), aLayer, false );
2620}
2621
2622
2623void SCH_PAINTER::draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer )
2624{
2625 if( !eeconfig()->m_Appearance.show_directive_labels && !aLabel->IsSelected() )
2626 return;
2627
2628 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2629
2630 if( m_schSettings.IsPrinting() && drawingShadows )
2631 return;
2632
2633 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2634 {
2635 for( const SCH_FIELD& field : aLabel->GetFields() )
2636 draw( &field, aLayer, false );
2637 }
2638
2639 if( isFieldsLayer( aLayer ) )
2640 return;
2641
2642 if( drawingShadows && !( aLabel->IsBrightened() || aLabel->IsSelected() ) )
2643 return;
2644
2645 COLOR4D color = getRenderColor( aLabel, LAYER_NETCLASS_REFS, drawingShadows );
2646
2647 if( aLayer == LAYER_DANGLING )
2648 {
2649 if( aLabel->IsDangling() )
2650 {
2651 drawDanglingIndicator( aLabel->GetTextPos(), color,
2653 drawingShadows, aLabel->IsBrightened() );
2654 }
2655
2656 return;
2657 }
2658
2659 std::vector<VECTOR2I> pts;
2660 std::deque<VECTOR2D> pts2;
2661
2662 aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
2663
2664 for( const VECTOR2I& p : pts )
2665 pts2.emplace_back( VECTOR2D( p.x, p.y ) );
2666
2667 m_gal->SetIsFill( false );
2668 m_gal->SetFillColor( color );
2669 m_gal->SetIsStroke( true );
2670 m_gal->SetLineWidth( getLineWidth( aLabel, drawingShadows ) );
2671 m_gal->SetStrokeColor( color );
2672
2673 if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_DOT )
2674 {
2675 m_gal->DrawLine( pts2[0], pts2[1] );
2676 m_gal->SetIsFill( true );
2677 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
2678 }
2679 else if( aLabel->GetShape() == LABEL_FLAG_SHAPE::F_ROUND )
2680 {
2681 m_gal->DrawLine( pts2[0], pts2[1] );
2682 m_gal->DrawCircle( pts2[2], ( pts2[2] - pts2[1] ).EuclideanNorm() );
2683 }
2684 else
2685 {
2686 m_gal->DrawPolyline( pts2 );
2687 }
2688}
2689
2690
2691void SCH_PAINTER::draw( const SCH_SHEET* aSheet, int aLayer )
2692{
2693 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2694
2695 if( m_schSettings.IsPrinting() && drawingShadows )
2696 return;
2697
2698 if( !drawingShadows || eeconfig()->m_Selection.draw_selected_children )
2699 {
2700 for( const SCH_FIELD& field : aSheet->GetFields() )
2701 draw( &field, aLayer, false );
2702
2703 for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
2704 draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
2705 }
2706
2707 if( isFieldsLayer( aLayer ) )
2708 return;
2709
2710 VECTOR2D pos = aSheet->GetPosition();
2711 VECTOR2D size = aSheet->GetSize();
2712
2713 if( aLayer == LAYER_SHEET_BACKGROUND )
2714 {
2715 // Do not fill the shape in B&W print mode, to avoid to visible items
2716 // inside the shape
2717 if( !m_schSettings.PrintBlackAndWhiteReq() )
2718 {
2719 m_gal->SetFillColor( getRenderColor( aSheet, LAYER_SHEET_BACKGROUND, true ) );
2720 m_gal->SetIsFill( true );
2721 m_gal->SetIsStroke( false );
2722
2723 m_gal->DrawRectangle( pos, pos + size );
2724 }
2725 }
2726
2727 if( aLayer == LAYER_SHEET || aLayer == LAYER_SELECTION_SHADOWS )
2728 {
2729 m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
2730 m_gal->SetIsStroke( true );
2731 m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
2732 m_gal->SetIsFill( false );
2733
2734 m_gal->DrawRectangle( pos, pos + size );
2735 }
2736}
2737
2738
2739void SCH_PAINTER::draw( const SCH_NO_CONNECT* aNC, int aLayer )
2740{
2741 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2742
2743 if( m_schSettings.IsPrinting() && drawingShadows )
2744 return;
2745
2746 if( drawingShadows && !( aNC->IsBrightened() || aNC->IsSelected() ) )
2747 return;
2748
2749 m_gal->SetIsStroke( true );
2750 m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
2751 m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
2752 m_gal->SetIsFill( false );
2753
2754 VECTOR2D p = aNC->GetPosition();
2755 int delta = std::max( aNC->GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
2756
2757 m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
2758 m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
2759}
2760
2761
2762void SCH_PAINTER::draw( const SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
2763{
2765 SCH_LINE line( VECTOR2I(), layer );
2766 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2767
2768 if( m_schSettings.IsPrinting() && drawingShadows )
2769 return;
2770
2771 bool drawingDangling = aLayer == LAYER_DANGLING;
2772
2773 if( drawingShadows && !( aEntry->IsBrightened() || aEntry->IsSelected() ) )
2774 return;
2775
2776 if( aEntry->IsSelected() )
2777 {
2778 line.SetSelected();
2779 // Never show unselected endpoints on bus entries
2780 line.SetFlags( STARTPOINT | ENDPOINT );
2781 }
2782 else if( aEntry->IsBrightened() )
2783 line.SetBrightened();
2784
2785 line.SetStartPoint( aEntry->GetPosition() );
2786 line.SetEndPoint( aEntry->GetEnd() );
2787 line.SetStroke( aEntry->GetStroke() );
2788 line.SetLineWidth( KiROUND( getLineWidth( aEntry, false ) ) );
2789
2790 COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
2791
2792 if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
2793 color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
2794
2795 if( drawingDangling )
2796 {
2797 m_gal->SetIsFill( false );
2798 m_gal->SetIsStroke( true );
2799 m_gal->SetStrokeColor( color.Brightened( 0.3 ) );
2800 m_gal->SetLineWidth( m_schSettings.GetDanglingIndicatorThickness() );
2801
2802 if( aEntry->IsDanglingStart() )
2803 {
2804 m_gal->DrawCircle( aEntry->GetPosition(),
2805 aEntry->GetPenWidth() + KiROUND( TARGET_BUSENTRY_RADIUS / 2.0 ) );
2806 }
2807
2808 if( aEntry->IsDanglingEnd() )
2809 {
2810 m_gal->DrawCircle( aEntry->GetEnd(),
2811 aEntry->GetPenWidth() + KiROUND( TARGET_BUSENTRY_RADIUS / 2.0 ) );
2812 }
2813 }
2814 else
2815 {
2816 line.SetLineColor( color );
2817 line.SetLineStyle( aEntry->GetLineStyle() );
2818
2819 draw( &line, aLayer );
2820 }
2821}
2822
2823
2824void SCH_PAINTER::draw( const SCH_BITMAP* aBitmap, int aLayer )
2825{
2826 m_gal->Save();
2827 m_gal->Translate( aBitmap->GetPosition() );
2828
2829 // When the image scale factor is not 1.0, we need to modify the actual as the image scale
2830 // factor is similar to a local zoom
2831 double img_scale = aBitmap->GetImageScale();
2832
2833 if( img_scale != 1.0 )
2834 m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
2835
2836 if( aLayer == LAYER_DRAW_BITMAPS )
2837 {
2838 m_gal->DrawBitmap( *aBitmap->GetImage() );
2839 }
2840
2841 if( aLayer == LAYER_SELECTION_SHADOWS )
2842 {
2843 if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
2844 {
2845 COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
2846 m_gal->SetIsStroke( true );
2847 m_gal->SetStrokeColor( color );
2848 m_gal->SetLineWidth ( getShadowWidth( aBitmap->IsBrightened() ) );
2849 m_gal->SetIsFill( false );
2850
2851 // Draws a bounding box.
2852 VECTOR2D bm_size( aBitmap->GetSize() );
2853 // bm_size is the actual image size in UI.
2854 // but m_gal scale was previously set to img_scale
2855 // so recalculate size relative to this image size.
2856 bm_size.x /= img_scale;
2857 bm_size.y /= img_scale;
2858 VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
2859 VECTOR2D end = origin + bm_size;
2860
2861 m_gal->DrawRectangle( origin, end );
2862 }
2863 }
2864
2865 m_gal->Restore();
2866}
2867
2868
2869void SCH_PAINTER::draw( const SCH_MARKER* aMarker, int aLayer )
2870{
2871 bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
2872
2873 if( m_schSettings.IsPrinting() && drawingShadows )
2874 return;
2875
2876 if( drawingShadows && !( aMarker->IsBrightened() || aMarker->IsSelected() ) )
2877 return;
2878
2879 COLOR4D color = getRenderColor( aMarker, aMarker->GetColorLayer(), drawingShadows );
2880
2881 m_gal->Save();
2882 m_gal->Translate( aMarker->GetPosition() );
2883 m_gal->SetIsFill( !drawingShadows );
2884 m_gal->SetFillColor( color );
2885 m_gal->SetIsStroke( drawingShadows );
2886 m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
2887 m_gal->SetStrokeColor( color );
2888
2889 SHAPE_LINE_CHAIN polygon;
2890 aMarker->ShapeToPolygon( polygon );
2891
2892 m_gal->DrawPolygon( polygon );
2893 m_gal->Restore();
2894}
2895
2896
2897}; // namespace KIGFX
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
double square(double x)
BOX2< VECTOR2I > BOX2I
Definition: box2.h:877
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:136
const Vec & GetPosition() const
Definition: box2.h:201
const Vec & GetOrigin() const
Definition: box2.h:200
void Offset(coord_type dx, coord_type dy)
Definition: box2.h:249
size_type GetHeight() const
Definition: box2.h:205
void SetX(coord_type val)
Definition: box2.h:260
void SetY(coord_type val)
Definition: box2.h:265
coord_type GetTop() const
Definition: box2.h:219
size_type GetWidth() const
Definition: box2.h:204
coord_type GetY() const
Definition: box2.h:198
const Vec GetEnd() const
Definition: box2.h:202
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:541
coord_type GetX() const
Definition: box2.h:197
Vec Centre() const
Definition: box2.h:87
coord_type GetRight() const
Definition: box2.h:207
coord_type GetLeft() const
Definition: box2.h:218
const BOX2< Vec > GetBoundingBoxRotated(const VECTOR2I &aRotCenter, const EDA_ANGLE &aAngle) const
Useful to calculate bounding box of rotated items, when rotation is not cardinal.
Definition: box2.h:685
coord_type GetBottom() const
Definition: box2.h:212
bool IsHorizontal() const
Definition: eda_angle.h:180
EDA_ANGLE Normalize180()
Definition: eda_angle.h:294
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:126
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:128
bool IsSelected() const
Definition: eda_item.h:109
void SetSelected()
Definition: eda_item.h:118
void SetBrightened()
Definition: eda_item.h:119
EDA_ITEM * GetParent() const
Definition: eda_item.h:102
bool IsRollover() const
Definition: eda_item.h:113
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:130
bool IsBrightened() const
Definition: eda_item.h:111
bool IsForceVisible() const
Definition: eda_item.h:194
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:129
bool IsMoving() const
Definition: eda_item.h:107
bool IsNew() const
Definition: eda_item.h:106
int GetStartY() const
Definition: eda_shape.h:126
FILL_T GetFillMode() const
Definition: eda_shape.h:102
int GetEndX() const
Definition: eda_shape.h:164
bool IsFilled() const
Definition: eda_shape.h:91
SHAPE_T GetShape() const
Definition: eda_shape.h:120
int GetEndY() const
Definition: eda_shape.h:163
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:162
COLOR4D GetFillColor() const
Definition: eda_shape.h:106
int GetStartX() const
Definition: eda_shape.h:127
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:83
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:234
COLOR4D GetTextColor() const
Definition: eda_text.h:231
bool IsItalic() const
Definition: eda_text.h:144
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
virtual bool IsVisible() const
Definition: eda_text.h:151
KIFONT::FONT * GetFont() const
Definition: eda_text.h:211
BOX2I GetTextBox(int aLine=-1) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:565
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:510
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:340
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:341
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:117
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:195
bool IsBold() const
Definition: eda_text.h:148
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:181
VECTOR2I GetTextSize() const
Definition: eda_text.h:222
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:146
virtual bool IsStroke() const
Definition: font.h:138
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const
Draw a string.
Definition: font.cpp:257
virtual bool IsOutline() const
Definition: font.h:139
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const METRICS &aFontMetrics) const
Compute the boundary limits of aText (the bounding box of all shapes).
Definition: font.cpp:434
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
Definition: color4d.h:311
COLOR4D & Invert()
Makes the color inverted, alpha remains the same.
Definition: color4d.h:242
double a
Alpha component.
Definition: color4d.h:395
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:268
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:398
COLOR4D & Desaturate()
Removes color (in HSL model)
Definition: color4d.cpp:511
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:295
Abstract interface for drawing on a 2D-surface.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
void SetGlyphSize(const VECTOR2I aSize)
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:59
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:102
const wxString & GetDefaultFont() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
bool GetDrawBoundingBoxes() const
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.
COLOR4D getRenderColor(const SCH_ITEM *aItem, int aLayer, bool aDrawingShadows, bool aDimmed=false) const
float getShadowWidth(bool aForHighlight) const
KIFONT::FONT * getFont(const EDA_TEXT *aText) const
void draw(const EDA_ITEM *, int, bool aDimmed)
static std::vector< KICAD_T > g_ScaledSelectionTypes
Definition: sch_painter.h:141
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:144
bool nonCached(const EDA_ITEM *aItem)
SCH_PAINTER(GAL *aGal)
void drawItemBoundingBox(const EDA_ITEM *aItem)
bool isUnitAndConversionShown(const SCH_ITEM *aItem) const
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
double GetForcedTransparency() const
Definition: view_item.h:157
static constexpr int VIEW_MAX_LAYERS
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:729
Define a library symbol object.
Definition: lib_symbol.h:77
std::vector< SCH_PIN * > GetPins(int aUnit=0, int aBodyStyle=0) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:982
bool IsAlias() const
Definition: lib_symbol.h:194
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:486
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:579
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:969
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...
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:295
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
double GetImageScale() const
Definition: sch_bitmap.h:67
VECTOR2I GetPosition() const override
Definition: sch_bitmap.h:145
BITMAP_BASE * GetImage() const
Definition: sch_bitmap.h:54
VECTOR2I GetSize() const
Definition: sch_bitmap.cpp:146
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
LINE_STYLE 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:81
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:44
int GetPenWidth() const override
VECTOR2I GetEnd() const
Class for a wire to bus entry.
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:1676
virtual bool IsDangling() const override
Determines dangling state from connectivity and cached connected rule areas.
Definition: sch_label.cpp:1829
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:586
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: sch_field.cpp:528
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.h:101
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_field.cpp:197
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) const
Definition: sch_field.cpp:352
VECTOR2I GetParentPosition() const
Definition: sch_field.cpp:1423
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:1981
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:1871
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:2091
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
virtual int GetPenWidth() const
Definition: sch_item.h:300
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:161
int GetBodyStyle() const
Definition: sch_item.h:240
int GetUnit() const
Definition: sch_item.h:237
bool IsPrivate() const
Definition: sch_item.h:243
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:289
bool RenderAsBitmap(double aWorldScale) const override
Definition: sch_item.cpp:484
bool IsConnectivityDirty() const
Definition: sch_item.h:518
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_item.cpp:197
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:216
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:184
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:461
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:470
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:189
int GetEffectiveDiameter() const
VECTOR2I GetPosition() const override
Definition: sch_junction.h:107
bool IsDangling() const override
Definition: sch_label.h:319
LABEL_FLAG_SHAPE GetShape() const
Definition: sch_label.h:172
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:196
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
void SetStartPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:136
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:976
bool IsStartDangling() const
Definition: sch_line.h:252
void SetLineColor(const COLOR4D &aColor)
Definition: sch_line.cpp:248
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:320
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_line.cpp:307
VECTOR2I GetMidPoint() const
Definition: sch_line.h:138
VECTOR2I GetEndPoint() const
Definition: sch_line.h:140
VECTOR2I GetStartPoint() const
Definition: sch_line.h:135
bool IsEndDangling() const
Definition: sch_line.h:253
void SetLineStyle(const LINE_STYLE aStyle)
Definition: sch_line.cpp:291
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_line.h:176
void SetEndPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:141
const wxString & GetOperatingPoint() const
Definition: sch_line.h:300
SCH_LAYER_ID GetColorLayer() const
Definition: sch_marker.cpp:222
VECTOR2I GetPosition() const override
Definition: sch_marker.h:106
int GetSize() const
VECTOR2I GetPosition() const override
int GetNumberTextSize() const
Definition: sch_pin.cpp:499
int GetLength() const
Definition: sch_pin.cpp:278
wxString GetShownNumber() const
Definition: sch_pin.cpp:458
const wxString & GetOperatingPoint() const
Definition: sch_pin.h:283
void SetName(const wxString &aName)
Definition: sch_pin.cpp:364
bool IsGlobalPower() const
Return whether this pin forms a global power connection: i.e., is part of a power symbol and of type ...
Definition: sch_pin.h:179
bool IsVisible() const
Definition: sch_pin.cpp:340
VECTOR2I GetPinRoot() const
Definition: sch_pin.cpp:521
wxString GetElectricalTypeName() const
Definition: sch_pin.cpp:326
bool IsDangling() const override
Definition: sch_pin.h:260
PIN_ORIENTATION GetOrientation() const
Definition: sch_pin.cpp:245
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition: sch_pin.h:87
VECTOR2I GetPosition() const override
Definition: sch_pin.cpp:237
int GetNameTextSize() const
Definition: sch_pin.cpp:477
wxString GetShownName() const
Definition: sch_pin.cpp:444
void SetOperatingPoint(const wxString &aText)
Definition: sch_pin.h:284
void SetType(ELECTRICAL_PINTYPE aType)
Definition: sch_pin.h:100
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:258
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:291
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition: sch_shape.h:97
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_shape.h:60
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:55
VECTOR2I GetPosition() const override
Definition: sch_shape.h:70
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
VECTOR2I GetSize() const
Definition: sch_sheet.h:112
VECTOR2I GetPosition() const override
Definition: sch_sheet.h:376
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:118
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:121
Schematic symbol object.
Definition: sch_symbol.h:105
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:779
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
TRANSFORM & GetTransform()
Definition: sch_symbol.h:282
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:837
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:959
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:213
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
int GetColSpan() const
Definition: sch_tablecell.h:61
int GetRowSpan() const
Definition: sch_tablecell.h:64
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition: sch_table.h:72
bool StrokeExternal() const
Definition: sch_table.h:54
std::vector< SCH_TABLECELL * > GetCells() const
Definition: sch_table.h:141
const STROKE_PARAMS & GetBorderStroke() const
Definition: sch_table.h:60
VECTOR2I GetPosition() const override
Definition: sch_table.cpp:115
VECTOR2I GetEnd() const
Definition: sch_table.cpp:121
int GetColCount() const
Definition: sch_table.h:104
SCH_TABLECELL * GetCell(int aRow, int aCol) const
Definition: sch_table.h:131
bool StrokeColumns() const
Definition: sch_table.h:84
bool StrokeRows() const
Definition: sch_table.h:87
int GetRowCount() const
Definition: sch_table.h:106
bool StrokeHeader() const
Definition: sch_table.h:57
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
VECTOR2I GetDrawPos() const override
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_textbox.h:86
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_text.h:78
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_text.cpp:384
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_text.cpp:405
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:71
VECTOR2I B
Definition: seg.h:50
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void Fracture(POLYGON_MODE aFastMode)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
const SEG & GetSeg() const
An abstract shape on 2D plane.
Definition: shape.h:126
Simple container to manage line stroke parameters.
Definition: stroke_params.h:81
int GetWidth() const
Definition: stroke_params.h:91
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:97
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:34
int GetPinNameOffset() const
Definition: symbol.h:118
bool GetDNP() const
Set or clear the 'Do Not Populate' flaga.
Definition: symbol.h:153
virtual bool GetShowPinNames() const
Definition: symbol.h:124
virtual bool GetShowPinNumbers() const
Definition: symbol.h:130
KIGFX::COLOR4D m_Color
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
int y1
Definition: transform.h:49
@ LIGHTRED
Definition: color4d.h:65
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
The common library.
#define DANGLING_SYMBOL_SIZE
< The size of the rectangle indicating an unconnected wire or label
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define UNSELECTED_END_SIZE
The default pin len value when creating pins(can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:435
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:437
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:432
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:431
#define IS_SHOWN_AS_BITMAP
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_DANGLING
indicates a pin is dangling
#define STARTPOINT
When a line is selected, these flags indicate which.
@ ARC
use RECTANGLE instead of RECT to avoid collision in a Windows header
@ FILLED_WITH_COLOR
@ FILLED_WITH_BG_BODYCOLOR
@ FILLED_SHAPE
int GetPenSizeForDemiBold(int aTextSize)
Definition: gr_text.cpp:46
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:87
@ LAYER_DRAW_BITMAPS
to handle and draw images bitmaps
Definition: layer_ids.h:227
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_DANGLING
Definition: layer_ids.h:381
@ LAYER_SHEETNAME
Definition: layer_ids.h:376
@ LAYER_SCHEMATIC_ANCHOR
Definition: layer_ids.h:400
@ LAYER_SHEETLABEL
Definition: layer_ids.h:379
@ LAYER_PINNUM
Definition: layer_ids.h:362
@ LAYER_RULE_AREAS
Definition: layer_ids.h:369
@ LAYER_DEVICE
Definition: layer_ids.h:370
@ LAYER_SHEET_BACKGROUND
Definition: layer_ids.h:387
@ LAYER_BRIGHTENED
Definition: layer_ids.h:393
@ LAYER_HIDDEN
Definition: layer_ids.h:394
@ LAYER_HIERLABEL
Definition: layer_ids.h:361
@ LAYER_PINNAM
Definition: layer_ids.h:363
@ LAYER_PRIVATE_NOTES
Definition: layer_ids.h:372
@ LAYER_HOVERED
Definition: layer_ids.h:392
@ LAYER_GLOBLABEL
Definition: layer_ids.h:360
@ LAYER_WIRE
Definition: layer_ids.h:356
@ LAYER_NOTES
Definition: layer_ids.h:371
@ LAYER_PIN
Definition: layer_ids.h:374
@ LAYER_VALUEPART
Definition: layer_ids.h:365
@ LAYER_BUS
Definition: layer_ids.h:357
@ LAYER_FIELDS
Definition: layer_ids.h:366
@ LAYER_DEVICE_BACKGROUND
Definition: layer_ids.h:386
@ LAYER_LOCLABEL
Definition: layer_ids.h:359
@ LAYER_SHEETFIELDS
Definition: layer_ids.h:378
@ LAYER_REFERENCEPART
Definition: layer_ids.h:364
@ LAYER_NETCLASS_REFS
Definition: layer_ids.h:368
@ LAYER_NOTES_BACKGROUND
Definition: layer_ids.h:373
@ LAYER_OP_CURRENTS
Definition: layer_ids.h:402
@ LAYER_SHEET
Definition: layer_ids.h:375
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:395
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:390
@ LAYER_INTERSHEET_REFS
Definition: layer_ids.h:367
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:401
@ LAYER_SHEETFILENAME
Definition: layer_ids.h:377
@ LAYER_DNP_MARKER
Definition: layer_ids.h:382
@ LAYER_NOCONNECT
Definition: layer_ids.h:380
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
static LIB_SYMBOL * dummy()
Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
EESCHEMA_SETTINGS * eeconfig()
Definition: sch_painter.cpp:69
static bool isFieldsLayer(int aLayer)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:424
@ OUTSIDE
Text appears outside the dimension line (default)
see class PGM_BASE
@ PT_NC
not connected (must be left open)
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:31
@ F_DOT
Definition: sch_label.h:101
@ F_ROUND
Definition: sch_label.h:102
#define BITMAP_FONT_SIZE_THRESHOLD
static int externalPinDecoSize(const RENDER_SETTINGS *aSettings, const SCH_PIN &aPin)
Utility for getting the size of the 'external' pin decorators (as a radius)
Definition: sch_pin.cpp:87
#define PIN_TEXT_MARGIN
Definition: sch_pin.cpp:42
static int internalPinDecoSize(const RENDER_SETTINGS *aSettings, const SCH_PIN &aPin)
Utility for getting the size of the 'internal' pin decorators (as a radius)
Definition: sch_pin.cpp:74
#define TARGET_PIN_RADIUS
Definition: sch_pin.h:35
std::vector< FAB_LAYER_COLOR > dummy
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
void OrientAndMirrorSymbolItems(LIB_SYMBOL *aSymbol, int aOrientation)
Rotate and/or mirror graphic objects of LIB_SYMBOL aSymbol according to aOrientMirror.
constexpr int delta
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
GR_TEXT_V_ALIGN_T
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:228
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:520
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:128
@ SCH_TABLE_T
Definition: typeinfo.h:165
@ SCH_LINE_T
Definition: typeinfo.h:163
@ LIB_SYMBOL_T
Definition: typeinfo.h:148
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:160
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_TABLECELL_T
Definition: typeinfo.h:166
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:171
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_MARKER_T
Definition: typeinfo.h:158
@ SCH_SHAPE_T
Definition: typeinfo.h:149
@ SCH_RULE_AREA_T
Definition: typeinfo.h:170
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:162
@ SCH_LABEL_LOCATE_ANY_T
Definition: typeinfo.h:190
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:161
@ SCH_BITMAP_T
Definition: typeinfo.h:164
@ SCH_TEXTBOX_T
Definition: typeinfo.h:152
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
@ SCH_JUNCTION_T
Definition: typeinfo.h:159
@ SCH_PIN_T
Definition: typeinfo.h:153
int sign(T val)
Definition: util.h:168
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:118
VECTOR2< double > VECTOR2D
Definition: vector2d.h:601
VECTOR2< int > VECTOR2I
Definition: vector2d.h:602