KiCad PCB EDA Suite
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-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
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 <sch_item.h>
29 
30 #include <bezier_curves.h>
31 #include <class_libentry.h>
32 #include <class_library.h>
33 #include <connection_graph.h>
37 #include <gr_text.h>
38 #include <lib_arc.h>
39 #include <lib_bezier.h>
40 #include <lib_circle.h>
41 #include <lib_field.h>
42 #include <lib_item.h>
43 #include <lib_pin.h>
44 #include <lib_polyline.h>
45 #include <lib_rectangle.h>
46 #include <lib_text.h>
47 #include <math/util.h>
48 #include <plotter.h>
49 #include <sch_bitmap.h>
50 #include <sch_bus_entry.h>
51 #include <sch_component.h>
52 #include <sch_edit_frame.h>
53 #include <sch_field.h>
54 #include <sch_junction.h>
55 #include <sch_line.h>
56 #include <sch_marker.h>
57 #include <sch_no_connect.h>
58 #include <sch_sheet.h>
59 #include <sch_text.h>
60 #include <schematic.h>
62 #include <view/view.h>
63 #include <kiface_i.h>
64 #include <default_values.h>
65 #include "sch_painter.h"
66 
67 namespace KIGFX
68 {
69 
71  m_ShowUnit( 0 ),
72  m_ShowConvert( 0 ),
73  m_ShowHiddenText( true ),
74  m_ShowHiddenPins( true ),
75  m_ShowPinsElectricalType( true ),
76  m_ShowDisabled( false ),
77  m_ShowUmbilicals( true ),
78  m_OverrideItemColors( false ),
79  m_TextOffsetRatio( 0.08 ),
80  m_DefaultWireThickness( DEFAULT_WIRE_THICKNESS * IU_PER_MILS ),
81  m_DefaultBusThickness( DEFAULT_BUS_THICKNESS * IU_PER_MILS ),
82  m_PinSymbolSize( DEFAULT_TEXT_SIZE * IU_PER_MILS / 2 ),
83  m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS )
84 {
86 }
87 
88 
90 {
91  for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
92  m_layerColors[ layer ] = aSettings->GetColor( layer );
93 
94  for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
95  m_layerColors[ layer ] = aSettings->GetColor( layer );
96 
98 
100 }
101 
102 
103 const COLOR4D& SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
104 {
105  return m_layerColors[ aLayer ];
106 }
107 
108 
110 {
111  return dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
112 }
113 
114 
128 static LIB_PART* dummy()
129 {
130  static LIB_PART* part;
131 
132  if( !part )
133  {
134  part = new LIB_PART( wxEmptyString );
135 
136  LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
137 
138  square->MoveTo( wxPoint( Mils2iu( -200 ), Mils2iu( 200 ) ) );
139  square->SetEndPosition( wxPoint( Mils2iu( 200 ), Mils2iu( -200 ) ) );
140 
141  LIB_TEXT* text = new LIB_TEXT( part );
142 
143  text->SetTextSize( wxSize( Mils2iu( 150 ), Mils2iu( 150 ) ) );
144  text->SetText( wxString( wxT( "??" ) ) );
145 
146  part->AddDrawItem( square );
147  part->AddDrawItem( text );
148  }
149 
150  return part;
151 }
152 
153 
155  KIGFX::PAINTER( aGal ),
156  m_schematic( nullptr )
157 { }
158 
159 
160 #define HANDLE_ITEM( type_id, type_name ) \
161  case type_id: draw( (type_name *) item, aLayer ); break
162 
163 
164 bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
165 {
166  auto item2 = static_cast<const EDA_ITEM*>( aItem );
167  auto item = const_cast<EDA_ITEM*>( item2 );
168 
169 #ifdef CONNECTIVITY_DEBUG
170 
171  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
172  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
173 
174  if( conn )
175  {
176  auto pos = item->GetBoundingBox().Centre();
177  auto label = conn->Name( true );
178 
182  m_gal->SetLineWidth( Mils2ui( 2 ) );
183  m_gal->SetGlyphSize( VECTOR2D( Mils2ui( 20 ), Mils2ui( 20 ) ) );
184  m_gal->StrokeText( conn->Name( true ), pos, 0.0, 0 );
185  }
186 
187 #endif
188 
189  switch( item->Type() )
190  {
215 
216  default: return false;
217  }
218 
219  return false;
220 }
221 
222 
224 {
225  if( m_schSettings.m_ShowUnit // showing a specific unit
226  && aItem->GetUnit() // item is unit-specific
227  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
228  {
229  return false;
230  }
231 
232  if( m_schSettings.m_ShowConvert // showing a specific conversion
233  && aItem->GetConvert() // item is conversion-specific
234  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
235  {
236  return false;
237  }
238 
239  return true;
240 }
241 
242 
244 {
245  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
246 
247  // For best visuals the selection width must be a cross between the zoom level and the
248  // default line width.
249  return (float) fabs( matrix.GetScale().x * 2.75 ) + Mils2iu( eeconfig()->m_Selection.thickness );
250 }
251 
252 
253 COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows )
254 {
256 
257  if( aItem->Type() == SCH_LINE_T )
258  {
259  COLOR4D lineColor = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
260 
261  if( lineColor != COLOR4D::UNSPECIFIED )
262  color = lineColor;
263  }
264  else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
265  {
266  COLOR4D busEntryColor = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem )->GetStrokeColor();
267 
268  if( busEntryColor != COLOR4D::UNSPECIFIED )
269  color = busEntryColor;
270  }
271  else if( aItem->Type() == SCH_JUNCTION_T )
272  {
273  COLOR4D junctionColor = static_cast<const SCH_JUNCTION*>( aItem )->GetColor();
274 
275  if( junctionColor != COLOR4D::UNSPECIFIED )
276  color = junctionColor;
277  }
278  else if( aItem->Type() == SCH_SHEET_T )
279  {
280  SCH_SHEET* sheet = (SCH_SHEET*) aItem;
281 
282  // Lazy fixup of legacy sheets with no color specifications
283  if( sheet->GetBorderColor() == COLOR4D::UNSPECIFIED )
285 
286  if( sheet->GetBackgroundColor() == COLOR4D::UNSPECIFIED )
288 
290  color = m_schSettings.GetLayerColor( aLayer );
291  else if( aLayer == LAYER_SHEET )
292  color = sheet->GetBorderColor();
293  else if( aLayer == LAYER_SHEET_BACKGROUND )
294  color = sheet->GetBackgroundColor();
295  }
296 
297  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
298  {
300 
301  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
302  color = color.WithAlpha( 0.2 );
303  }
304  else if( aItem->IsSelected() )
305  {
306  if( aDrawingShadows )
308  }
309 
311  color = color.Darken( 0.5f );
312 
313  return color;
314 }
315 
316 
317 float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows )
318 {
319  float width = (float) std::max( aItem->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
320 
321  if( aItem->IsSelected() && aDrawingShadows )
322  width += getShadowWidth();
323 
324  return width;
325 }
326 
327 
328 float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows )
329 {
330  wxCHECK( aItem, static_cast<float>( m_schSettings.m_DefaultWireThickness ) );
331 
332  float width;
333  const SCH_LINE* line = dynamic_cast<const SCH_LINE*>( aItem );
334 
335  if( line && aItem->GetLayer() == LAYER_WIRE )
336  {
337  if( line->GetLineSize() != 0 )
338  width = (float) line->GetLineSize();
339  else
340  width = (float) m_schSettings.m_DefaultWireThickness;
341  }
342  else if( line && aItem->GetLayer() == LAYER_BUS )
343  {
344  if( line->GetLineSize() != 0 )
345  width = (float) line->GetLineSize();
346  else
347  width = (float) m_schSettings.m_DefaultBusThickness;
348  }
349  else
350  {
351  width = (float) std::max( aItem->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
352  }
353 
354  if( aItem->IsSelected() && aDrawingShadows )
355  width += getShadowWidth();
356 
357  return width;
358 }
359 
360 
361 float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows )
362 {
363  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
364 
365  if( aItem->IsSelected() && aDrawingShadows )
366  width += getShadowWidth();
367 
368  return width;
369 }
370 
371 
372 float SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows )
373 {
374  float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() );
375 
376  if( aItem->IsSelected() && aDrawingShadows )
377  width += getShadowWidth();
378 
379  return width;
380 }
381 
382 
383 float SCH_PAINTER::getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows )
384 {
385  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
387 
388  if( aItem->IsSelected() && aDrawingShadows )
389  width += getShadowWidth();
390 
391  return width;
392 }
393 
394 
395 float SCH_PAINTER::getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows )
396 {
397  float width = (float) std::max( aItem->GetEffectiveTextPenWidth(),
399 
400  if( aItem->IsSelected() && aDrawingShadows )
401  width += getShadowWidth();
402 
403  return width;
404 }
405 
406 
407 void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, double aAngle )
408 {
409  m_gal->StrokeText( aText, aPosition, aAngle );
410 }
411 
412 
413 void SCH_PAINTER::draw( LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit, int aConvert )
414 {
415  if( !aUnit )
416  aUnit = m_schSettings.m_ShowUnit;
417 
418  if( !aConvert )
419  aConvert = m_schSettings.m_ShowConvert;
420 
421  std::unique_ptr< LIB_PART > tmpPart;
422  LIB_PART* drawnPart = aPart;
423 
424  if( aPart->IsAlias() )
425  {
426  tmpPart = aPart->Flatten();
427  drawnPart = tmpPart.get();
428  }
429 
430  for( auto& item : drawnPart->GetDrawItems() )
431  {
432  if( !aDrawFields && item.Type() == LIB_FIELD_T )
433  continue;
434 
435  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
436  continue;
437 
438  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
439  continue;
440 
441  Draw( &item, aLayer );
442  }
443 }
444 
445 
446 static VECTOR2D mapCoords( const wxPoint& aCoord )
447 {
448  return VECTOR2D( aCoord.x, -aCoord.y );
449 }
450 
451 
452 void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c )
453 {
454  m_gal->DrawLine( a, b );
455  m_gal->DrawLine( b, c );
456 }
457 
458 
459 bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer )
460 {
461  switch( aLayer )
462  {
464  if( aItem->IsSelected() )
465  {
466  m_gal->SetIsFill( false );
467  m_gal->SetIsStroke( true );
468  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
469  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
470  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
471  return true;
472  }
473 
474  return false;
475 
477  if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
478  {
479  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
480 
481  // These actions place the item over others, so allow a modest transparency here
482  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
483  fillColor = fillColor.WithAlpha( 0.75 );
484 
486  m_gal->SetFillColor( fillColor );
487  m_gal->SetIsStroke( false );
488  return true;
489  }
490 
491  return false;
492 
493  case LAYER_DEVICE:
494  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
495  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
496 
497  if( aItem->GetPenWidth() > 0 || aItem->GetFillMode() == NO_FILL )
498  {
499  m_gal->SetIsStroke( true );
500  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
501  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
502  }
503  else
504  {
505  m_gal->SetIsStroke( false );
506  }
507 
508  return true;
509 
510  default:
511  return false;
512  }
513 }
514 
515 
517 {
518  if( aLayer == LAYER_SELECTION_SHADOWS && eeconfig()->m_Selection.fill_shapes )
519  m_gal->SetIsFill( true );
520 }
521 
522 
523 void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer )
524 {
525  if( !isUnitAndConversionShown( aRect ) )
526  return;
527 
528  if( setDeviceColors( aRect, aLayer ) )
529  {
530  fillIfSelection( aLayer );
531  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
532  }
533 }
534 
535 
536 void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer )
537 {
538  if( !isUnitAndConversionShown( aCircle ) )
539  return;
540 
541  if( setDeviceColors( aCircle, aLayer ) )
542  {
543  fillIfSelection( aLayer );
544  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
545  }
546 }
547 
548 
549 void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
550 {
551  if( !isUnitAndConversionShown( aArc ) )
552  return;
553 
554  if( setDeviceColors( aArc, aLayer ) )
555  {
556  int sai = aArc->GetFirstRadiusAngle();
557  int eai = aArc->GetSecondRadiusAngle();
558 
569  if( !TRANSFORM().MapAngles( &sai, &eai ) )
570  {
571  LIB_ARC new_arc( *aArc );
572 
573  new_arc.SetStart( aArc->GetEnd() );
574  new_arc.SetEnd( aArc->GetStart() );
575  new_arc.CalcRadiusAngles();
576  sai = new_arc.GetFirstRadiusAngle();
577  eai = new_arc.GetSecondRadiusAngle();
578  TRANSFORM().MapAngles( &sai, &eai );
579  }
580 
581  double sa = (double) sai * M_PI / 1800.0;
582  double ea = (double) eai * M_PI / 1800.0 ;
583 
584  VECTOR2D pos = mapCoords( aArc->GetPosition() );
585 
586  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
587  }
588 }
589 
590 
591 void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer )
592 {
593  if( !isUnitAndConversionShown( aLine ) )
594  return;
595 
596  if( setDeviceColors( aLine, aLayer ) )
597  {
598  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
599  std::deque<VECTOR2D> vtx;
600 
601  for( auto p : pts )
602  vtx.push_back( mapCoords( p ) );
603 
604  fillIfSelection( aLayer );
605  m_gal->DrawPolygon( vtx );
606  }
607 }
608 
609 
610 void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer )
611 {
612  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
613 
614  if( drawingShadows && !aField->IsSelected() )
615  return;
616 
617  if( !isUnitAndConversionShown( aField ) )
618  return;
619 
620  // Must check layer as fields are sometimes drawn by their parent rather than
621  // directly from the view.
622  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
623  int layers_count;
624  bool foundLayer = false;
625 
626  aField->ViewGetLayers( layers, layers_count );
627 
628  for( int i = 0; i < layers_count; ++i )
629  {
630  if( layers[i] == aLayer )
631  foundLayer = true;
632  }
633 
634  if( !foundLayer )
635  return;
636 
637  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
638 
639  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
640  {
642  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
643  else
644  return;
645  }
646 
647  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
648  m_gal->SetIsFill( false );
649  m_gal->SetIsStroke( true );
651 
652  auto pos = mapCoords( aField->GetPosition() );
653 
654  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
655  {
656  EDA_RECT boundaryBox = aField->GetBoundingBox();
657 
658  m_gal->SetIsFill( true );
660  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
661  boundaryBox.RevertYAxis();
662 
663  m_gal->DrawRectangle( mapCoords( boundaryBox.GetPosition() ),
664  mapCoords( boundaryBox.GetEnd() ) );
665  }
666  else
667  {
668  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
669  m_gal->SetFontItalic( aField->IsItalic() );
670 
673 
674  double orient = aField->GetTextAngleRadians();
675 
676  strokeText( aField->GetText(), pos, orient );
677  }
678 
679  // Draw the umbilical line
680  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
681  {
683  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
684  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
685  }
686 }
687 
688 
689 void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer )
690 {
691  if( !isUnitAndConversionShown( aText ) )
692  return;
693 
694  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
695 
696  if( drawingShadows && !aText->IsSelected() )
697  return;
698 
699  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
700 
701  if( !aText->IsVisible() )
702  {
704  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
705  else
706  return;
707  }
708 
709  EDA_RECT bBox = aText->GetBoundingBox();
710  bBox.RevertYAxis();
711  VECTOR2D pos = mapCoords( bBox.Centre() );
712  double orient = aText->GetTextAngleRadians();
713 
716  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
717  m_gal->SetIsFill( false );
718  m_gal->SetIsStroke( true );
720  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
721  m_gal->SetFontBold( aText->IsBold() );
722  m_gal->SetFontItalic( aText->IsItalic() );
723  strokeText( aText->GetText(), pos, orient );
724 }
725 
726 
728 {
731 
732  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
733 }
734 
735 
736 // Utility for getting the size of the 'external' pin decorators (as a radius)
737 // i.e. the negation circle, the polarity 'slopes' and the nonlogic marker
739 {
742 
743  return aPin.GetNumberTextSize() / 2;
744 }
745 
746 
747 // Draw the target (an open circle) for a pin which has no connection or is being moved.
748 void SCH_PAINTER::drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows )
749 {
750  m_gal->SetIsFill( false );
751  m_gal->SetIsStroke( true );
752  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
753 
755 }
756 
757 
758 void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
759 {
760  if( !isUnitAndConversionShown( aPin ) )
761  return;
762 
763  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
764 
765  if( drawingShadows && !aPin->IsSelected() )
766  return;
767 
768  VECTOR2I pos = mapCoords( aPin->GetPosition() );
769  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
770 
771  if( !aPin->IsVisible() )
772  {
774  {
775  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
776  }
777  else
778  {
779  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
780  drawPinDanglingSymbol( pos, drawingShadows );
781 
782  return;
783  }
784  }
785 
786  VECTOR2I p0;
787  VECTOR2I dir;
788  int len = aPin->GetLength();
789  int orient = aPin->GetOrientation();
790 
791  switch( orient )
792  {
793  case PIN_UP:
794  p0 = VECTOR2I( pos.x, pos.y - len );
795  dir = VECTOR2I( 0, 1 );
796  break;
797 
798  case PIN_DOWN:
799  p0 = VECTOR2I( pos.x, pos.y + len );
800  dir = VECTOR2I( 0, -1 );
801  break;
802 
803  case PIN_LEFT:
804  p0 = VECTOR2I( pos.x - len, pos.y );
805  dir = VECTOR2I( 1, 0 );
806  break;
807 
808  default:
809  case PIN_RIGHT:
810  p0 = VECTOR2I( pos.x + len, pos.y );
811  dir = VECTOR2I( -1, 0 );
812  break;
813  }
814 
815  VECTOR2D pc;
816 
817  m_gal->SetIsStroke( true );
818  m_gal->SetIsFill( false );
819  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
821  m_gal->SetFontBold( false );
822  m_gal->SetFontItalic( false );
823 
824  const int radius = externalPinDecoSize( *aPin );
825  const int diam = radius*2;
826  const int clock_size = internalPinDecoSize( *aPin );
827 
828  if( aPin->GetType() == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
829  {
830  m_gal->DrawLine( p0, pos );
831 
832  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
833  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
834  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
835  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
836 
837  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
838  }
839  else
840  {
841  switch( aPin->GetShape() )
842  {
844  m_gal->DrawLine( p0, pos );
845  break;
846 
848  m_gal->DrawCircle( p0 + dir * radius, radius );
849  m_gal->DrawLine( p0 + dir * ( diam ), pos );
850  break;
851 
853  pc = p0 - dir * clock_size ;
854 
855  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
856  pc,
857  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
858 
859  m_gal->DrawCircle( p0 + dir * radius, radius );
860  m_gal->DrawLine( p0 + dir * ( diam ), pos );
861  break;
862 
865  pc = p0 - dir * clock_size ;
866 
867  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
868  pc,
869  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
870 
871  if( !dir.y )
872  {
873  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
874  p0 + VECTOR2D(dir.x, -1) * diam,
875  p0 );
876  }
877  else /* MapX1 = 0 */
878  {
879  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
880  p0 + VECTOR2D(-1, dir.y) * diam,
881  p0 );
882  }
883 
884  m_gal->DrawLine( p0, pos );
885  break;
886 
888  m_gal->DrawLine( p0, pos );
889 
890  if( !dir.y )
891  {
892  triLine( p0 + VECTOR2D( 0, clock_size ),
893  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
894  p0 + VECTOR2D( 0, -clock_size ) );
895  }
896  else
897  {
898  triLine( p0 + VECTOR2D( clock_size, 0 ),
899  p0 + VECTOR2D( 0, -dir.y * clock_size ),
900  p0 + VECTOR2D( -clock_size, 0 ) );
901  }
902  break;
903 
905  m_gal->DrawLine( p0, pos );
906 
907  if( !dir.y )
908  {
909  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
910  p0 + VECTOR2D(dir.x, -1) * diam,
911  p0 );
912  }
913  else /* MapX1 = 0 */
914  {
915  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
916  p0 + VECTOR2D(-1, dir.y) * diam,
917  p0 );
918  }
919  break;
920 
921  case GRAPHIC_PINSHAPE::OUTPUT_LOW: // IEEE symbol "Active Low Output"
922  m_gal->DrawLine( p0, pos );
923 
924  if( !dir.y ) // Horizontal pin
925  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
926  else // Vertical pin
927  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
928  break;
929 
930  case GRAPHIC_PINSHAPE::NONLOGIC: // NonLogic pin symbol
931  m_gal->DrawLine( p0, pos );
932 
933  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
934  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
935  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
936  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
937  break;
938  }
939  }
940 
941 
942  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
943  drawPinDanglingSymbol( pos, drawingShadows );
944 
945  LIB_PART* libEntry = aPin->GetParent();
946 
947  // Draw the labels
948  if( drawingShadows && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() )
950  return;
951 
952  int textOffset = libEntry->GetPinNameOffset();
953 
954  float nameLineWidth = getLineWidth( aPin, drawingShadows );
955  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
956  float numLineWidth = getLineWidth( aPin, drawingShadows );
957  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
958 
959  #define PIN_TEXT_MARGIN 4.0
960 
961  // Four locations around a pin where text can be drawn
962  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
963  int size[4] = { 0, 0, 0, 0 };
964  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
965  COLOR4D colour[4];
966  wxString text[4];
967 
968  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
969  if( textOffset )
970  {
971  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
972  thickness[INSIDE] = nameLineWidth;
973  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
974  text [INSIDE] = aPin->GetName();
975 
976  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
977  thickness[ABOVE] = numLineWidth;
978  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
979  text [ABOVE] = aPin->GetNumber();
980  }
981  // Otherwise pin NAMES go above and pin NUMBERS go below
982  else
983  {
984  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
985  thickness[ABOVE] = nameLineWidth;
986  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
987  text [ABOVE] = aPin->GetName();
988 
989  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
990  thickness[BELOW] = numLineWidth;
991  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
992  text [BELOW] = aPin->GetNumber();
993  }
994 
996  {
997  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
998  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
999  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
1000  text [OUTSIDE] = aPin->GetElectricalTypeName();
1001  }
1002 
1003  if( !aPin->IsVisible() )
1004  {
1005  for( COLOR4D& c : colour )
1006  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
1007  }
1008 
1009  int insideOffset = textOffset;
1010  int outsideOffset = 10;
1011  float lineThickness = (float) m_schSettings.GetDefaultPenWidth();
1012  float aboveOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[ABOVE] + lineThickness ) / 2.0;
1013  float belowOffset = Mils2iu( PIN_TEXT_MARGIN ) + ( thickness[BELOW] + lineThickness ) / 2.0;
1014 
1015  if( drawingShadows )
1016  {
1017  for( float& t : thickness )
1018  t += getShadowWidth();
1019 
1020  insideOffset -= KiROUND( getShadowWidth() / 2 );
1021  outsideOffset -= KiROUND( getShadowWidth() / 2 );
1022  }
1023 
1024  #define SET_DC( i ) \
1025  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
1026  m_gal->SetLineWidth( thickness[i] ); \
1027  m_gal->SetStrokeColor( colour[i] )
1028 
1029  switch( orient )
1030  {
1031  case PIN_LEFT:
1032  if( size[INSIDE] )
1033  {
1034  SET_DC( INSIDE );
1037  strokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
1038  }
1039  if( size[OUTSIDE] )
1040  {
1041  SET_DC( OUTSIDE );
1044  strokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
1045  }
1046  if( size[ABOVE] )
1047  {
1048  SET_DC( ABOVE );
1051  strokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
1052  }
1053  if( size[BELOW] )
1054  {
1055  SET_DC( BELOW );
1058  strokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
1059  }
1060  break;
1061 
1062  case PIN_RIGHT:
1063  if( size[INSIDE] )
1064  {
1065  SET_DC( INSIDE );
1069  strokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
1070  }
1071  if( size[OUTSIDE] )
1072  {
1073  SET_DC( OUTSIDE );
1076  strokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
1077  }
1078  if( size[ABOVE] )
1079  {
1080  SET_DC( ABOVE );
1083  strokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
1084  }
1085  if( size[BELOW] )
1086  {
1087  SET_DC( BELOW );
1090  strokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
1091  }
1092  break;
1093 
1094  case PIN_DOWN:
1095  if( size[INSIDE] )
1096  {
1097  SET_DC( INSIDE );
1100  strokeText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
1101  }
1102  if( size[OUTSIDE] )
1103  {
1104  SET_DC( OUTSIDE );
1107  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
1108  }
1109  if( size[ABOVE] )
1110  {
1111  SET_DC( ABOVE );
1114  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
1115  }
1116  if( size[BELOW] )
1117  {
1118  SET_DC( BELOW );
1121  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
1122  }
1123  break;
1124 
1125  case PIN_UP:
1126  if( size[INSIDE] )
1127  {
1128  SET_DC( INSIDE );
1131  strokeText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
1132  }
1133  if( size[OUTSIDE] )
1134  {
1135  SET_DC( OUTSIDE );
1138  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
1139  }
1140  if( size[ABOVE] )
1141  {
1142  SET_DC( ABOVE );
1145  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
1146  }
1147  if( size[BELOW] )
1148  {
1149  SET_DC( BELOW );
1152  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
1153  }
1154  break;
1155 
1156  default:
1157  wxFAIL_MSG( "Unknown pin orientation" );
1158  }
1159 }
1160 
1161 
1162 void SCH_PAINTER::draw( LIB_BEZIER *aCurve, int aLayer )
1163 {
1164  if( !isUnitAndConversionShown( aCurve ) )
1165  return;
1166 
1167  if( setDeviceColors( aCurve, aLayer ) )
1168  {
1169  BEZIER_POLY poly ( aCurve->GetPoints() );
1170  std::vector<wxPoint> pts;
1171  std::deque<VECTOR2D> pts_xformed;
1172  poly.GetPoly( pts );
1173 
1174  for( const auto &p : pts )
1175  pts_xformed.push_back( mapCoords( p ) );
1176 
1177  m_gal->DrawPolygon( pts_xformed );
1178  }
1179 }
1180 
1181 
1182 // Draw the target (an open square) for a wire or label which has no connection or is
1183 // being moved.
1184 void SCH_PAINTER::drawDanglingSymbol( const wxPoint& aPos, int aWidth, bool aDrawingShadows )
1185 {
1186  wxPoint radius( aWidth + Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1187  aWidth + Mils2iu( DANGLING_SYMBOL_SIZE /2 ) );
1188 
1189  m_gal->SetIsStroke( true );
1190  m_gal->SetIsFill( false );
1191  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
1192 
1193  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1194 }
1195 
1196 
1197 void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer )
1198 {
1199  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1200 
1201  if( drawingShadows && !aJct->IsSelected() )
1202  return;
1203 
1204  COLOR4D color = getRenderColor( aJct, aJct->GetLayer(), drawingShadows );
1205 
1206  int junctionSize = m_schSettings.m_JunctionSize / 2.0;
1207 
1208  if( aJct->GetDiameter() != 0 )
1209  junctionSize = aJct->GetDiameter() / 2;
1210 
1211  m_gal->SetIsStroke( drawingShadows );
1212  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1214  m_gal->SetIsFill( !drawingShadows );
1215  m_gal->SetFillColor( color );
1216  m_gal->DrawCircle( aJct->GetPosition(), junctionSize );
1217 }
1218 
1219 
1220 void SCH_PAINTER::draw( SCH_LINE *aLine, int aLayer )
1221 {
1222  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1223 
1224  if( drawingShadows && !aLine->IsSelected() )
1225  return;
1226 
1227  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1228  float width = getLineWidth( aLine, drawingShadows );
1229 
1230  m_gal->SetIsStroke( true );
1232  m_gal->SetLineWidth( width );
1233 
1234  if( aLine->GetLineStyle() <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows )
1235  {
1236  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1237  }
1238  else
1239  {
1240  VECTOR2D start = aLine->GetStartPoint();
1241  VECTOR2D end = aLine->GetEndPoint();
1242 
1243  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1244  clip.Normalize();
1245 
1246  double theta = atan2( end.y - start.y, end.x - start.x );
1247  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1248 
1249  switch( aLine->GetLineStyle() )
1250  {
1251  default:
1252  case PLOT_DASH_TYPE::DASH:
1253  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1254  break;
1255  case PLOT_DASH_TYPE::DOT:
1256  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1257  break;
1259  strokes[0] = DASH_MARK_LEN( width );
1260  strokes[2] = DOT_MARK_LEN( width );
1261  break;
1262  }
1263 
1264  for( size_t i = 0; i < 10000; ++i )
1265  {
1266  // Calculations MUST be done in doubles to keep from accumulating rounding
1267  // errors as we go.
1268  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1269  start.y + strokes[ i % 4 ] * sin( theta ) );
1270 
1271  // Drawing each segment can be done rounded to ints.
1272  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1273  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1274 
1275  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1276  break;
1277  else if( i % 2 == 0 )
1278  m_gal->DrawLine( segStart, segEnd );
1279 
1280  start = next;
1281  }
1282  }
1283 
1284  if( aLine->IsStartDangling() )
1285  drawDanglingSymbol( aLine->GetStartPoint(), getLineWidth( aLine, drawingShadows ),
1286  drawingShadows );
1287 
1288  if( aLine->IsEndDangling() )
1289  drawDanglingSymbol( aLine->GetEndPoint(), getLineWidth( aLine, drawingShadows ),
1290  drawingShadows );
1291 }
1292 
1293 
1294 void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
1295 {
1296  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1297 
1298  if( drawingShadows && !aText->IsSelected() )
1299  return;
1300 
1301  switch( aText->Type() )
1302  {
1303  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1304  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1305  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1306  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1307  default: aLayer = LAYER_NOTES; break;
1308  }
1309 
1310  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1311 
1312  if( m_schematic )
1313  {
1314  SCH_CONNECTION* conn = aText->Connection( m_schematic->CurrentSheet() );
1315 
1316  if( conn && conn->IsBus() )
1317  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1318  }
1319 
1320  if( !( aText->IsVisible() || aText->IsForceVisible() ) )
1321  {
1323  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1324  else
1325  return;
1326  }
1327 
1328  m_gal->SetIsFill( false );
1329  m_gal->SetIsStroke( true );
1330  m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) );
1332  m_gal->SetTextAttributes( aText );
1333 
1334  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset( &m_schSettings );
1335  wxString shownText( aText->GetShownText() );
1336 
1337  if( drawingShadows )
1338  {
1340  {
1341  EDA_RECT bBox = aText->GetBoundingBox();
1342 
1343  m_gal->SetIsFill( true );
1344  m_gal->SetFillColor( color );
1345  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1346  bBox.RevertYAxis();
1347 
1348  m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1349  return;
1350  }
1351 
1352  switch( aText->GetLabelSpinStyle() )
1353  {
1355  text_offset.x += getShadowWidth() / 2;
1356  break;
1357  case LABEL_SPIN_STYLE::UP:
1358  text_offset.y += getShadowWidth() / 2;
1359  break;
1361  text_offset.x -= getShadowWidth() / 2;
1362  break;
1364  text_offset.y -= getShadowWidth() / 2;
1365  break;
1366  }
1367  }
1368 
1369  if( !shownText.IsEmpty() )
1370  {
1371  strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1372  }
1373 
1374  if( aText->IsDangling() )
1375  drawDanglingSymbol( aText->GetTextPos(), Mils2iu( DANGLING_SYMBOL_SIZE / 2 ),
1376  drawingShadows );
1377 }
1378 
1379 
1380 static void orientPart( LIB_PART* part, int orientation )
1381 {
1382  struct ORIENT
1383  {
1384  int flag;
1385  int n_rots;
1386  int mirror_x;
1387  int mirror_y;
1388  }
1389  orientations[] =
1390  {
1391  { CMP_ORIENT_0, 0, 0, 0 },
1392  { CMP_ORIENT_90, 1, 0, 0 },
1393  { CMP_ORIENT_180, 2, 0, 0 },
1394  { CMP_ORIENT_270, 3, 0, 0 },
1395  { CMP_MIRROR_X + CMP_ORIENT_0, 0, 1, 0 },
1396  { CMP_MIRROR_X + CMP_ORIENT_90, 1, 1, 0 },
1397  { CMP_MIRROR_Y, 0, 0, 1 },
1398  { CMP_MIRROR_X + CMP_ORIENT_270, 3, 1, 0 },
1399  { CMP_MIRROR_Y + CMP_ORIENT_0, 0, 0, 1 },
1400  { CMP_MIRROR_Y + CMP_ORIENT_90, 1, 0, 1 },
1401  { CMP_MIRROR_Y + CMP_ORIENT_180, 2, 0, 1 },
1402  { CMP_MIRROR_Y + CMP_ORIENT_270, 3, 0, 1 }
1403  };
1404 
1405  ORIENT o = orientations[ 0 ];
1406 
1407  for( auto& i : orientations )
1408  {
1409  if( i.flag == orientation )
1410  {
1411  o = i;
1412  break;
1413  }
1414  }
1415 
1416  for( auto& item : part->GetDrawItems() )
1417  {
1418  for( int i = 0; i < o.n_rots; i++ )
1419  item.Rotate( wxPoint(0, 0 ), true );
1420 
1421  if( o.mirror_x )
1422  item.MirrorVertical( wxPoint( 0, 0 ) );
1423 
1424  if( o.mirror_y )
1425  item.MirrorHorizontal( wxPoint( 0, 0 ) );
1426  }
1427 }
1428 
1429 
1430 void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
1431 {
1432  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1433  LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
1434 
1435  // Copy the source so we can re-orient and translate it.
1436  LIB_PART tempPart( *originalPart );
1437 
1438  tempPart.SetFlags( aComp->GetFlags() );
1439 
1440  orientPart( &tempPart, aComp->GetOrientation() );
1441 
1442  for( auto& tempItem : tempPart.GetDrawItems() )
1443  {
1444  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1445  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition() ) );
1446  }
1447 
1448  // Copy the pin info from the component to the temp pins
1449  LIB_PINS tempPins;
1450  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1451  const SCH_PIN_PTRS compPins = aComp->GetSchPins();
1452 
1453  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1454  {
1455  LIB_PIN* tempPin = tempPins[ i ];
1456  const SCH_PIN* compPin = compPins[ i ];
1457 
1458  tempPin->ClearFlags();
1459  tempPin->SetFlags( compPin->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1460 
1461  if( compPin->IsDangling() )
1462  tempPin->SetFlags( IS_DANGLING );
1463  }
1464 
1465  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1466 
1467  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1468  for( SCH_FIELD& field : aComp->GetFields() )
1469  draw( &field, aLayer );
1470 }
1471 
1472 
1473 void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer )
1474 {
1475  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1476 
1477  if( drawingShadows && !aField->IsSelected() )
1478  return;
1479 
1480  aLayer = aField->GetLayer();
1481 
1482  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1483 
1484  if( !( aField->IsVisible() || aField->IsForceVisible() ) )
1485  {
1487  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1488  else
1489  return;
1490  }
1491 
1492  if( aField->IsVoid() )
1493  return;
1494 
1495  if( drawingShadows && aField->GetParent()->IsSelected()
1497  {
1498  return;
1499  }
1500 
1501  // Calculate the text orientation according to the parent orientation.
1502  int orient = (int) aField->GetTextAngle();
1503 
1504  if( aField->GetParent() && aField->GetParent()->Type() == SCH_COMPONENT_T )
1505  {
1506  if( static_cast<SCH_COMPONENT*>( aField->GetParent() )->GetTransform().y1 )
1507  {
1508  // Rotate component 90 degrees.
1509  if( orient == TEXT_ANGLE_HORIZ )
1510  orient = TEXT_ANGLE_VERT;
1511  else
1512  orient = TEXT_ANGLE_HORIZ;
1513  }
1514  }
1515 
1516  /* Calculate the text justification, according to the component orientation/mirror.
1517  * This is a bit complicated due to cumulative calculations:
1518  * - numerous cases (mirrored or not, rotation)
1519  * - the DrawGraphicText function recalculate also H and H justifications according to the
1520  * text orientation.
1521  * - When a component is mirrored, the text is not mirrored and justifications are
1522  * complicated to calculate
1523  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1524  * to know the text coordinate considered as centered
1525  */
1526  EDA_RECT boundaryBox = aField->GetBoundingBox();
1527  wxPoint textpos = boundaryBox.Centre();
1528 
1530  m_gal->SetIsStroke( true );
1531 
1532  if( drawingShadows && eeconfig()->m_Selection.text_as_box )
1533  {
1534  m_gal->SetIsFill( true );
1535  m_gal->SetFillColor( color );
1536  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1537  boundaryBox.RevertYAxis();
1538 
1539  m_gal->DrawRectangle( mapCoords( boundaryBox.GetPosition() ),
1540  mapCoords( boundaryBox.GetEnd() ) );
1541  }
1542  else
1543  {
1546  m_gal->SetIsFill( false );
1547  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1548  m_gal->SetFontBold( aField->IsBold() );
1549  m_gal->SetFontItalic( aField->IsItalic() );
1550  m_gal->SetTextMirrored( aField->IsMirrored() );
1551  m_gal->SetLineWidth( getTextThickness( aField, drawingShadows ) );
1552 
1553  strokeText( aField->GetShownText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
1554  }
1555 
1556  // Draw the umbilical line
1557  if( aField->IsMoving() )
1558  {
1559  wxPoint parentPos = aField->GetParentPosition();
1560 
1562  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1563  m_gal->DrawLine( textpos, parentPos );
1564  }
1565 }
1566 
1567 
1568 void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer )
1569 {
1570  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1571 
1572  if( drawingShadows && !aLabel->IsSelected() )
1573  return;
1574 
1575  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1576 
1577  std::vector<wxPoint> pts;
1578  std::deque<VECTOR2D> pts2;
1579 
1580  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1581 
1582  for( auto p : pts )
1583  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1584 
1585  // the text is drawn inside the graphic shape.
1586  // On Cairo the graphic shape is filled by the background
1587  // before drawing the text ().
1588  // However if the text is selected, it is draw twice:
1589  // first, on LAYER_SELECTION_SHADOWS
1590  // second, on the text layer.
1591  // the second must not erase the first drawing.
1592  bool fillBg = ( aLayer == LAYER_SELECTION_SHADOWS ) || !aLabel->IsSelected();
1593  m_gal->SetIsFill( fillBg );
1595  m_gal->SetIsStroke( true );
1596  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1598  m_gal->DrawPolyline( pts2 );
1599 
1600  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1601 }
1602 
1603 
1604 void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
1605 {
1606  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1607 
1608  if( drawingShadows && !aLabel->IsSelected() )
1609  return;
1610 
1611  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1612 
1613  if( m_schematic )
1614  {
1615  SCH_CONNECTION* conn = aLabel->Connection( m_schematic->CurrentSheet() );
1616 
1617  if( conn && conn->IsBus() )
1618  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1619  }
1620 
1621  std::vector<wxPoint> pts;
1622  std::deque<VECTOR2D> pts2;
1623 
1624  aLabel->CreateGraphicShape( &m_schSettings, pts, aLabel->GetTextPos() );
1625 
1626  for( auto p : pts )
1627  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1628 
1629  m_gal->SetIsFill( true );
1631  m_gal->SetIsStroke( true );
1632  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1634  m_gal->DrawPolyline( pts2 );
1635 
1636  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1637 }
1638 
1639 void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
1640 {
1641  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1642 
1643  if( aLayer == LAYER_HIERLABEL || aLayer == LAYER_SELECTION_SHADOWS )
1644  {
1645  for( SCH_SHEET_PIN* sheetPin : aSheet->GetPins() )
1646  {
1647  if( drawingShadows && !aSheet->IsSelected() && !sheetPin->IsSelected() )
1648  continue;
1649 
1650  if( drawingShadows && aSheet->IsSelected()
1652  {
1653  break;
1654  }
1655 
1656  int width = std::max( aSheet->GetPenWidth(), m_schSettings.GetDefaultPenWidth() );
1657  wxPoint initial_pos = sheetPin->GetTextPos();
1658  wxPoint offset_pos = initial_pos;
1659 
1660  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1661  switch( sheetPin->GetEdge() )
1662  {
1663  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1664  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1665  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1666  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1667  default: break;
1668  }
1669 
1670  sheetPin->SetTextPos( offset_pos );
1671  draw( static_cast<SCH_HIERLABEL*>( sheetPin ), aLayer );
1672  m_gal->DrawLine( offset_pos, initial_pos );
1673  sheetPin->SetTextPos( initial_pos );
1674  }
1675  }
1676 
1677  VECTOR2D pos = aSheet->GetPosition();
1678  VECTOR2D size = aSheet->GetSize();
1679 
1680  if( aLayer == LAYER_SHEET_BACKGROUND )
1681  {
1683  m_gal->SetIsFill( true );
1684  m_gal->SetIsStroke( false );
1685 
1686  m_gal->DrawRectangle( pos, pos + size );
1687  }
1688 
1689  if( aLayer == LAYER_SHEET || aLayer == LAYER_SELECTION_SHADOWS )
1690  {
1691  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1692  m_gal->SetIsStroke( true );
1693  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1694  m_gal->SetIsFill( false );
1695 
1696  m_gal->DrawRectangle( pos, pos + size );
1697 
1698  if( drawingShadows && !eeconfig()->m_Selection.draw_selected_children && aSheet->IsSelected() )
1699  return;
1700 
1701  for( SCH_FIELD& field : aSheet->GetFields() )
1702  draw( &field, aLayer );
1703  }
1704 }
1705 
1706 
1707 void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer )
1708 {
1709  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1710 
1711  if( drawingShadows && !aNC->IsSelected() )
1712  return;
1713 
1714  m_gal->SetIsStroke( true );
1715  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1716  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1717  m_gal->SetIsFill( false );
1718 
1719  VECTOR2D p = aNC->GetPosition();
1720  int delta = std::max( aNC->GetSize(), m_schSettings.GetDefaultPenWidth() * 3 ) / 2;
1721 
1722  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1723  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1724 }
1725 
1726 
1727 void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
1728 {
1729  SCH_LINE line;
1730  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1731 
1732  line.SetLayer( aEntry->Type() == SCH_BUS_WIRE_ENTRY_T ? LAYER_WIRE : LAYER_BUS );
1733 
1734  if( aEntry->IsSelected() )
1735  line.SetSelected();
1736 
1737  line.SetStartPoint( aEntry->GetPosition() );
1738  line.SetEndPoint( aEntry->m_End() );
1739  line.SetStroke( aEntry->GetStroke() );
1740 
1741  if( aEntry->GetStrokeColor() == COLOR4D::UNSPECIFIED )
1742  {
1743  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1744 
1745  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1746  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1747 
1748  line.SetLineColor( color );
1749  }
1750 
1751  draw( &line, aLayer );
1752 
1753  m_gal->SetIsFill( false );
1754  m_gal->SetIsStroke( true );
1755  m_gal->SetLineWidth( drawingShadows ? getShadowWidth() : 1.0 );
1756 
1757  if( aEntry->IsDanglingStart() )
1758  m_gal->DrawCircle( aEntry->GetPosition(),
1759  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1760 
1761  if( aEntry->IsDanglingEnd() )
1762  m_gal->DrawCircle( aEntry->m_End(),
1763  aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) );
1764 }
1765 
1766 
1767 void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer )
1768 {
1769  m_gal->Save();
1770  m_gal->Translate( aBitmap->GetPosition() );
1771 
1772  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1773  // factor is similar to a local zoom
1774  double img_scale = aBitmap->GetImageScale();
1775 
1776  if( img_scale != 1.0 )
1777  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1778 
1779  if( aLayer == LAYER_DRAW_BITMAPS )
1780  {
1781  m_gal->DrawBitmap( *aBitmap->GetImage() );
1782  }
1783 
1784  if( aLayer == LAYER_SELECTION_SHADOWS )
1785  {
1786  if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
1787  {
1788  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1789  m_gal->SetIsStroke( true );
1792  m_gal->SetIsFill( false );
1793 
1794  // Draws a bounding box.
1795  VECTOR2D bm_size( aBitmap->GetSize() );
1796  // bm_size is the actual image size in UI.
1797  // but m_gal scale was previously set to img_scale
1798  // so recalculate size relative to this image size.
1799  bm_size.x /= img_scale;
1800  bm_size.y /= img_scale;
1801  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1802  VECTOR2D end = origin + bm_size;
1803 
1804  m_gal->DrawRectangle( origin, end );
1805  }
1806  }
1807 
1808  m_gal->Restore();
1809 }
1810 
1811 
1812 void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
1813 {
1814  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1815 
1816  if( drawingShadows && !aMarker->IsSelected() )
1817  return;
1818 
1819  COLOR4D color = getRenderColor( aMarker, aMarker->GetColorLayer(), drawingShadows );
1820 
1821  m_gal->Save();
1822  m_gal->Translate( aMarker->GetPosition() );
1823  m_gal->SetIsFill( !drawingShadows );
1824  m_gal->SetFillColor( color );
1825  m_gal->SetIsStroke( drawingShadows );
1826  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1828 
1829  SHAPE_LINE_CHAIN polygon;
1830  aMarker->ShapeToPolygon( polygon );
1831 
1832  m_gal->DrawPolygon( polygon );
1833  m_gal->Restore();
1834 }
1835 
1836 
1837 }; // namespace KIGFX
virtual bool Draw(const VIEW_ITEM *, int) override
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
bool IsDangling() const override
Definition: sch_text.h:302
#define TEXT_ANGLE_HORIZ
SCH_PAINTER(GAL *aGal)
CITER next(CITER it)
Definition: ptree.cpp:130
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
bool IsBold() const
Definition: eda_text.h:182
virtual int GetPenWidth() const =0
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCHEMATIC * m_schematic
Definition: sch_painter.h:201
std::vector< SCH_PIN * > SCH_PIN_PTRS
Definition: sch_component.h:71
float GetLineWidth() const
Get the line width.
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:37
void drawDanglingSymbol(const wxPoint &aPos, int aWidth, bool aDrawingShadows)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsMirrored() const
Definition: eda_text.h:188
int GetPinNameOffset()
SCH_LAYER_ID GetColorLayer() const
Definition: sch_marker.cpp:95
int GetOrientation()
Get the display symbol orientation.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
wxPoint GetStartPoint() const
Definition: sch_line.h:94
bool IsSelected() const
Definition: base_struct.h:203
wxPoint GetEnd() const
Definition: lib_rectangle.h:87
#define TEXT_ANGLE_VERT
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
to handle and draw images bitmaps
COLOR4D m_layerColors[LAYER_ID_COUNT]
Define a symbol library graphical text item.
Definition: lib_text.h:40
int GetOrientation() const
Definition: lib_pin.h:206
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_bus_entry.h:78
LIB_PART * GetParent() const
Definition: lib_item.h:182
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
void GetPoly(std::vector< wxPoint > &aOutput, int aMinSegLen=0)
Converts Bezier curve to a polygon.
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
bool IsVisible() const
Definition: eda_text.h:185
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:218
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
virtual wxPoint GetSchematicTextOffset(RENDER_SETTINGS *aSettings) const
Definition: sch_text.cpp:161
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
bool IsMoving() const
Definition: base_struct.h:200
const wxPoint GetPosition() const override
int color
Definition: DXF_plotter.cpp:61
Field object used in symbol libraries.
Definition: lib_field.h:59
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
double square(double x)
FILL_T GetFillMode() const
Definition: lib_item.h:301
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
double GetTextAngle() const
Definition: eda_text.h:173
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:307
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:547
int GetDiameter() const
Definition: sch_junction.h:100
#define DASH_MARK_LEN(aLineWidth)
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:290
bool IsBrightened() const
Definition: base_struct.h:205
#define DEFAULT_JUNCTION_DIAM
The default bus and wire enty size in mils.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
Definition: lib_pin.h:58
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_field.cpp:315
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
Add new GAL layers here.
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
const wxPoint GetPosition() const override
Definition: lib_rectangle.h:74
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:209
EESCHEMA_SETTINGS * eeconfig()
bool IsDangling() const override
Definition: sch_pin.h:88
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
#define SET_DC(i)
const wxPoint GetPosition() const override
Definition: lib_field.h:180
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:102
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:293
void fillIfSelection(int aLayer)
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:56
bool IsDragging() const
Definition: base_struct.h:201
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:701
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:110
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN.
Definition: lib_pin.h:351
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:152
virtual void SetLineWidth(float aLineWidth)
Set the line width.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition: color4d.h:372
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:98
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:293
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:43
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
bool IsItalic() const
Definition: eda_text.h:179
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:60
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
bool ShowPinNames()
int GetSecondRadiusAngle() const
Definition: lib_arc.h:109
const wxPoint GetEnd() const
Definition: eda_rect.h:116
void SetFontBold(const bool aBold)
Set bold property of current font.
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: lib_field.cpp:340
int GetUnit() const
Definition: lib_item.h:295
int GetUnit() const
PAINTER contains all the knowledge about how to draw graphical object onto any particular output devi...
Definition: painter.h:58
bool ShowPinNumbers()
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
wxSize GetSize() const
Definition: sch_bitmap.cpp:125
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:72
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:294
bool IsDanglingStart() const
Definition: sch_bus_entry.h:55
void SetEnd(const wxPoint &aPoint)
Definition: lib_arc.h:115
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
void SetSelected()
Definition: base_struct.h:208
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
#define DANGLING_SYMBOL_SIZE
wxString const GetElectricalTypeName() const
return a translated string for messages giving the electrical type of the pin.
Definition: lib_pin.h:258
const wxString & GetName() const
Definition: lib_pin.h:151
PLOT_DASH_TYPE GetLineStyle() const
Definition: sch_line.cpp:257
const wxPoint GetPosition() const override
Definition: lib_arc.h:90
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Class LIB_PIN definition.
bool IsEndDangling() const
Definition: sch_line.h:191
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxPoint GetPosition() const override
Definition: sch_junction.h:97
const wxSize & GetTextSize() const
Definition: eda_text.h:238
int GetPenWidth() const override
Definition: sch_sheet.cpp:492
const wxPoint GetPosition() const override
Definition: sch_marker.h:101
const wxPoint GetPosition() const
Definition: eda_rect.h:115
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:95
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:278
const wxPoint GetPosition() const override
bool IsResized() const
Definition: base_struct.h:204
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
int GetSize() const
wxPoint GetStart() const
Definition: lib_arc.h:111
#define DOT_MARK_LEN(aLineWidth)
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
Define a library symbol object.
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:291
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:68
#define OUTSIDE
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
a few functions useful in geometry calculations.
const wxPoint GetPosition() const override
Definition: sch_bitmap.h:140
#define F(x, y, z)
Definition: md5_hash.cpp:15
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:232
void SetLineColor(const COLOR4D &aColor)
Definition: sch_line.cpp:206
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:345
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
int GetRadius() const
Definition: lib_circle.h:87
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:442
void CreateGraphicShape(RENDER_SETTINGS *aRenderSettings, std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:953
std::unique_ptr< LIB_PART > & GetPartRef()
wxPoint m_End() const
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
int GetNameTextSize() const
Definition: lib_pin.h:177
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
const wxPoint GetPosition() const override
Definition: lib_pin.h:430
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:487
int GetConvert() const
Definition: lib_item.h:298
#define DEFAULT_LINE_THICKNESS
The default wire width in mils. (can be changed in preference menu)
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:147
virtual int GetPenWidth() const
Definition: sch_item.h:288
const wxPoint GetPosition() const override
Definition: lib_circle.h:71
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
#define DEFAULT_BUS_THICKNESS
The default noconnect size in mils.
int GetRadius() const
Definition: lib_arc.h:103
static void orientPart(LIB_PART *part, int orientation)
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:271
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:362
double GetTextAngleRadians() const
Definition: eda_text.h:176
void Normalize()
Function Normalize ensures that the height ant width are positive.
int externalPinDecoSize(const LIB_PIN &aPin)
const wxString & GetNumber() const
Definition: lib_pin.h:179
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:234
void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: sch_painter.cpp:89
COLOR4D GetColor(int aLayer) const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
int GetLineSize() const
Definition: sch_line.h:136
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_line.h:125
bool IsForceVisible() const
Definition: base_struct.h:286
int GetNumberTextSize() const
Definition: lib_pin.h:204
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:145
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:359
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:234
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
SHAPE_LINE_CHAIN.
int internalPinDecoSize(const LIB_PIN &aPin)
#define HANDLE_ITEM(type_id, type_name)
#define DEFAULT_WIRE_THICKNESS
The default bus width in mils. (can be changed in preference menu)
const wxPoint GetPosition() const override
bool IsStartDangling() const
Definition: sch_line.h:190
double GetImageScale() const
Definition: sch_bitmap.h:71
const wxPoint GetPosition() const override
Definition: sch_sheet.h:570
bool IsAlias() const
wxPoint GetEnd() const
Definition: lib_arc.h:114
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Schematic symbol object.
Definition: sch_component.h:88
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
#define IU_PER_MILS
Definition: plotter.cpp:138
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:68
#define DASH_GAP_LEN(aLineWidth)
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:46
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
wxPoint Centre() const
Definition: eda_rect.h:62
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
int GetDefaultPenWidth() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
int GetFirstRadiusAngle() const
Definition: lib_arc.h:106
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:112
#define DEFAULT_TEXT_SIZE
void CreateGraphicShape(RENDER_SETTINGS *aSettings, std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1169
bool GetOverrideSchItemColors() const
COLOR4D GetStrokeColor() const
Definition: sch_bus_entry.h:84
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:81
Definition for part library class.
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:235
#define INSIDE
void SetDefaultPenWidth(int aWidth)
not connected (must be left open)
bool IsBus() const
wxPoint GetParentPosition() const
Definition: sch_field.cpp:595
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:234
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
#define PIN_TEXT_MARGIN
int GetLength()
Definition: lib_pin.h:284
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:186
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
wxSize GetSize()
Definition: sch_sheet.h:284
SCH_PIN_PTRS GetSchPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:199
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
Class GAL is the abstract interface for drawing on a 2D-surface.
Define a bezier curve graphic body item.
Definition: lib_bezier.h:34
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:122
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99
wxPoint GetEndPoint() const
Definition: sch_line.h:97