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  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 
27 #include <sch_item.h>
28 
29 #include <lib_item.h>
30 #include <lib_rectangle.h>
31 #include <lib_pin.h>
32 #include <lib_circle.h>
33 #include <lib_polyline.h>
34 #include <lib_arc.h>
35 #include <lib_field.h>
36 #include <lib_text.h>
37 #include <lib_bezier.h>
38 #include <sch_line.h>
39 #include <sch_component.h>
40 #include <sch_field.h>
41 #include <sch_junction.h>
42 #include <sch_text.h>
43 #include <sch_no_connect.h>
44 #include <sch_bus_entry.h>
45 #include <sch_bitmap.h>
46 #include <sch_sheet.h>
47 #include <gr_text.h>
49 #include <lib_edit_frame.h>
50 #include <plotter.h>
51 #include <template_fieldnames.h>
52 #include <class_libentry.h>
53 #include <class_library.h>
54 #include <sch_edit_frame.h>
55 #include <view/view.h>
57 #include <colors_design_settings.h>
58 #include <connection_graph.h>
60 #include <bezier_curves.h>
61 
62 #include "sch_painter.h"
63 
64 namespace KIGFX
65 {
66 
68  m_ShowUnit( 0 ), m_ShowConvert( 0 )
69 {
70  ImportLegacyColors( nullptr );
71 
72  m_ShowHiddenText = true;
73  m_ShowHiddenPins = true;
75  m_ShowUmbilicals = true;
76 }
77 
78 
80 {
81  for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
82  m_layerColors[ layer ] = ::GetLayerColor( static_cast<SCH_LAYER_ID>( layer ) );
83 
84  for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
85  m_layerColors[ layer ] = ::GetLayerColor( static_cast<SCH_LAYER_ID>( layer ) );
86 
88 }
89 
90 
91 const COLOR4D& SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
92 {
93  return m_layerColors[ aLayer ];
94 }
95 
96 
110 static LIB_PART* dummy()
111 {
112  static LIB_PART* part;
113 
114  if( !part )
115  {
116  part = new LIB_PART( wxEmptyString );
117 
118  LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
119 
120  square->MoveTo( wxPoint( -200, 200 ));
121  square->SetEndPosition( wxPoint( 200, -200 ) );
122 
123  LIB_TEXT* text = new LIB_TEXT( part );
124 
125  text->SetTextSize( wxSize( 150, 150 ) );
126  text->SetText( wxString( wxT( "??" ) ) );
127 
128  part->AddDrawItem( square );
129  part->AddDrawItem( text );
130  }
131 
132  return part;
133 }
134 
135 
137  KIGFX::PAINTER (aGal)
138 { }
139 
140 
141 #define HANDLE_ITEM( type_id, type_name ) \
142  case type_id: draw( (type_name *) item, aLayer ); break
143 
144 
145 bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
146 {
147  auto item2 = static_cast<const EDA_ITEM*>( aItem );
148  auto item = const_cast<EDA_ITEM*>( item2 );
149 
151 
152 #ifdef CONNECTIVITY_DEBUG
153 
154  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
155  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
156 
157  if( conn )
158  {
159  auto pos = item->GetBoundingBox().Centre();
160  auto label = conn->Name( true );
161 
165  m_gal->SetLineWidth( 2 );
166  m_gal->SetGlyphSize( VECTOR2D( 20, 20 ) );
167  m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
168  }
169 
170 #endif
171 
172  switch( item->Type() )
173  {
199 
200  default: return false;
201  }
202 
203  return false;
204 }
205 
206 
208 {
209  if( m_schSettings.m_ShowUnit // showing a specific unit
210  && aItem->GetUnit() // item is unit-specific
211  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
212  {
213  return false;
214  }
215 
216  if( m_schSettings.m_ShowConvert // showing a specific conversion
217  && aItem->GetConvert() // item is conversion-specific
218  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
219  {
220  return false;
221  }
222 
223  return true;
224 }
225 
226 
228 {
229  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
230 
231  // For best visuals the selection width must be a cross between the zoom level and the
232  // default line width.
233  return (float) ( ( fabs( matrix.GetScale().x * 5.5 ) + GetDefaultLineThickness() ) / 2.0 );
234 }
235 
236 
237 COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows )
238 {
239  static COLOR4D highlightColor( 1.0, 0.3, 0.3, 1.0 );
240  static COLOR4D selectionColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT );
241 
243 
244  if( aItem->Type() == SCH_LINE_T )
245  color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
246 
247  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
248  {
250 
251  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
252  color = color.WithAlpha( 0.2 );
253  }
254  else if( aItem->IsSelected() )
255  {
256  if( aDrawingShadows )
257  color = selectionColor.WithAlpha( 0.8 );
258  }
259  else if( aItem->IsHighlighted() ) // Cross-probing
260  {
261  color = highlightColor;
262  }
263 
264  return color;
265 }
266 
267 
268 float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows )
269 {
270  float width = (float) aItem->GetPenSize();
271 
272  if( aItem->IsSelected() && aDrawingShadows )
273  width += getShadowWidth();
274 
275  return width;
276 }
277 
278 
279 float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows )
280 {
281  float width = (float) aItem->GetPenSize();
282 
283  if( aItem->IsSelected() && aDrawingShadows )
284  width += getShadowWidth();
285 
286  return width;
287 }
288 
289 
290 float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows )
291 {
292  float width = (float) aItem->GetThickness();
293 
294  if( width == 0 )
295  width = (float) GetDefaultLineThickness();
296 
297  if( aItem->IsSelected() && aDrawingShadows )
298  width += getShadowWidth();
299 
300  return width;
301 }
302 
303 
304 void SCH_PAINTER::draw( LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit, int aConvert )
305 {
306  if( !aUnit )
307  aUnit = m_schSettings.m_ShowUnit;
308 
309  if( !aConvert )
310  aConvert = m_schSettings.m_ShowConvert;
311 
312  for( auto& item : aPart->GetDrawItems() )
313  {
314  if( !aDrawFields && item.Type() == LIB_FIELD_T )
315  continue;
316 
317  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
318  continue;
319 
320  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
321  continue;
322 
323  Draw( &item, aLayer );
324  }
325 }
326 
327 
328 void SCH_PAINTER::draw( LIB_ALIAS *aAlias, int aLayer )
329 {
330  LIB_PART* comp = aAlias->GetPart();
331 
332  draw( comp, aLayer, false );
333 
334  LIB_FIELDS fields;
335  comp->GetFields( fields );
336 
337  if( !aAlias->IsRoot() )
338  {
339  fields[ VALUE ].SetText( aAlias->GetName() );
340  fields[ DATASHEET ].SetText( aAlias->GetDocFileName() );
341  }
342 
343  for( LIB_FIELD& field : fields )
344  draw( &field, aLayer );
345 }
346 
347 
348 static VECTOR2D mapCoords( const wxPoint& aCoord )
349 {
350  return VECTOR2D( aCoord.x, -aCoord.y );
351 }
352 
353 
354 void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c )
355 {
356  m_gal->DrawLine( a, b );
357  m_gal->DrawLine( b, c );
358 }
359 
360 
361 bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer )
362 {
363  switch( aLayer )
364  {
366  if( aItem->IsSelected() )
367  {
368  m_gal->SetIsFill( false );
369  m_gal->SetIsStroke( true );
370  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
371  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
372  return true;
373  }
374 
375  return false;
376 
378  if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
379  {
380  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
381 
382  // These actions place the item over others, so allow a modest transparency here
383  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
384  fillColor = fillColor.WithAlpha( 0.75 );
385 
387  m_gal->SetFillColor( fillColor );
388  m_gal->SetIsStroke( false );
389  return true;
390  }
391 
392  return false;
393 
394  case LAYER_DEVICE:
395  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
396  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
397  m_gal->SetIsStroke( aItem->GetPenSize() > 0 );
398  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
399  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
400 
401  return true;
402 
403  default:
404  return false;
405  }
406 }
407 
408 
409 void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer )
410 {
411  if( !isUnitAndConversionShown( aRect ) )
412  return;
413 
414  if( setDeviceColors( aRect, aLayer ) )
415  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
416 
417 }
418 
419 
420 void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer )
421 {
422  if( !isUnitAndConversionShown( aCircle ) )
423  return;
424 
425  if( setDeviceColors( aCircle, aLayer ) )
426  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
427 }
428 
429 
430 void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
431 {
432  if( !isUnitAndConversionShown( aArc ) )
433  return;
434 
435  if( setDeviceColors( aArc, aLayer ) )
436  {
437  int sai = aArc->GetFirstRadiusAngle();
438  int eai = aArc->GetSecondRadiusAngle();
439 
450  if( !TRANSFORM().MapAngles( &sai, &eai ) )
451  {
452  LIB_ARC new_arc( *aArc );
453 
454  new_arc.SetStart( aArc->GetEnd() );
455  new_arc.SetEnd( aArc->GetStart() );
456  new_arc.CalcRadiusAngles();
457  sai = new_arc.GetFirstRadiusAngle();
458  eai = new_arc.GetSecondRadiusAngle();
459  TRANSFORM().MapAngles( &sai, &eai );
460  }
461 
462  double sa = (double) sai * M_PI / 1800.0;
463  double ea = (double) eai * M_PI / 1800.0 ;
464 
465  VECTOR2D pos = mapCoords( aArc->GetPosition() );
466 
467  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
468  }
469 }
470 
471 
472 void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer )
473 {
474  if( !isUnitAndConversionShown( aLine ) )
475  return;
476 
477  if( setDeviceColors( aLine, aLayer ) )
478  {
479  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
480  std::deque<VECTOR2D> vtx;
481 
482  for( auto p : pts )
483  vtx.push_back( mapCoords( p ) );
484 
485  m_gal->DrawPolygon( vtx );
486  }
487 }
488 
489 
490 void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer )
491 {
492  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
493 
494  if( drawingShadows && !aField->IsSelected() )
495  return;
496 
497  // Must check layer as fields are sometimes drawn by their parent rather than
498  // directly from the view.
499  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
500  int layers_count;
501  aField->ViewGetLayers( layers, layers_count );
502 
503  if( aLayer != layers[0] )
504  return;
505 
506  if( !isUnitAndConversionShown( aField ) )
507  return;
508 
509  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
510 
511  if( !aField->IsVisible() )
512  {
514  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
515  else
516  return;
517  }
518 
519  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
520  m_gal->SetIsFill( false );
521  m_gal->SetIsStroke( true );
523  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
524  m_gal->SetFontItalic( aField->IsItalic() );
525 
527  m_gal->SetVerticalJustify( aField->GetVertJustify( ) );
528 
529  auto pos = mapCoords( aField->GetPosition() );
530  double orient = aField->GetTextAngleRadians();
531 
532  m_gal->StrokeText( aField->GetText(), pos, orient );
533 
534  // Draw the umbilical line
535  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
536  {
538  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
539  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
540  }
541 }
542 
543 
544 void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer )
545 {
546  if( !isUnitAndConversionShown( aText ) )
547  return;
548 
549  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
550 
551  if( drawingShadows && !aText->IsSelected() )
552  return;
553 
554  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
555 
556  if( !aText->IsVisible() )
557  {
559  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
560  else
561  return;
562  }
563 
564  EDA_RECT bBox = aText->GetBoundingBox();
565  bBox.RevertYAxis();
566  VECTOR2D pos = mapCoords( bBox.Centre() );
567  double orient = aText->GetTextAngleRadians();
568 
571  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
572  m_gal->SetIsFill( false );
573  m_gal->SetIsStroke( true );
575  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
576  m_gal->SetFontBold( aText->IsBold() );
577  m_gal->SetFontItalic( aText->IsItalic() );
578  m_gal->StrokeText( aText->GetText(), pos, orient );
579 }
580 
581 
582 static int InternalPinDecoSize( const LIB_PIN &aPin )
583 {
584  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
585 }
586 
587 
588 // Utility for getting the size of the 'external' pin decorators (as a radius)
589 // i.e. the negation circle, the polarity 'slopes' and the nonlogic marker
590 static int ExternalPinDecoSize( const LIB_PIN &aPin )
591 {
592  return aPin.GetNumberTextSize() / 2;
593 }
594 
595 
596 // Draw the target (an open circle) for a pin which has no connection or is being moved.
597 void SCH_PAINTER::drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows )
598 {
599  m_gal->SetIsFill( false );
600  m_gal->SetIsStroke( true );
601  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
602 
604 }
605 
606 
607 void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
608 {
609  if( !isUnitAndConversionShown( aPin ) )
610  return;
611 
612  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
613 
614  if( drawingShadows && !aPin->IsSelected() )
615  return;
616 
617  VECTOR2I pos = mapCoords( aPin->GetPosition() );
618  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
619 
620  if( !aPin->IsVisible() )
621  {
623  {
624  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
625  }
626  else
627  {
628  if( ( aPin->GetFlags() & IS_DANGLING ) && aPin->IsPowerConnection() )
629  drawPinDanglingSymbol( pos, drawingShadows );
630 
631  return;
632  }
633  }
634 
635  VECTOR2I p0;
636  VECTOR2I dir;
637  int len = aPin->GetLength();
638  int shape = aPin->GetShape();
639  int orient = aPin->GetOrientation();
640 
641  switch( orient )
642  {
643  case PIN_UP:
644  p0 = VECTOR2I( pos.x, pos.y - len );
645  dir = VECTOR2I(0, 1);
646  break;
647  case PIN_DOWN:
648  p0 = VECTOR2I( pos.x, pos.y + len );
649  dir = VECTOR2I(0, -1);
650  break;
651  case PIN_LEFT:
652  p0 = VECTOR2I( pos.x - len, pos.y );
653  dir = VECTOR2I(1, 0);
654  break;
655  default:
656  case PIN_RIGHT:
657  p0 = VECTOR2I( pos.x + len, pos.y );
658  dir = VECTOR2I(-1, 0);
659  break;
660  }
661 
662  VECTOR2D pc;
663 
664  m_gal->SetIsStroke( true );
665  m_gal->SetIsFill( false );
666  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
668  m_gal->SetFontBold( false );
669  m_gal->SetFontItalic( false );
670 
671  const int radius = ExternalPinDecoSize( *aPin );
672  const int diam = radius*2;
673  const int clock_size = InternalPinDecoSize( *aPin );
674 
675  if( shape == PINSHAPE_INVERTED )
676  {
677  m_gal->DrawCircle( p0 + dir * radius, radius );
678  m_gal->DrawLine( p0 + dir * ( diam ), pos );
679  }
680  else if( shape == PINSHAPE_FALLING_EDGE_CLOCK )
681  {
682  pc = p0 + dir * clock_size ;
683 
684  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
685  pc,
686  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
687 
688  m_gal->DrawLine( pos, pc );
689  }
690  else
691  {
692  m_gal->DrawLine( p0, pos );
693  }
694 
695  if( shape == PINSHAPE_CLOCK )
696  {
697  if (!dir.y)
698  {
699  triLine( p0 + VECTOR2D( 0, clock_size ),
700  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
701  p0 + VECTOR2D( 0, -clock_size ) );
702  }
703  else
704  {
705  triLine( p0 + VECTOR2D( clock_size, 0 ),
706  p0 + VECTOR2D( 0, -dir.y * clock_size ),
707  p0 + VECTOR2D( -clock_size, 0 ) );
708  }
709  }
710 
711  if( shape == PINSHAPE_INPUT_LOW )
712  {
713  if(!dir.y)
714  {
715  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
716  p0 + VECTOR2D(dir.x, -1) * diam,
717  p0 );
718  }
719  else /* MapX1 = 0 */
720  {
721  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
722  p0 + VECTOR2D(-1, dir.y) * diam,
723  p0 );
724  }
725  }
726 
727  if( shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
728  {
729  if( !dir.y ) // Horizontal pin
730  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
731  else // Vertical pin
732  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
733  }
734 
735  if( shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
736  {
737  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
738  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
739  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
740  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
741  }
742 
743  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
744  {
745  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
746  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
747  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
748  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
749 
750  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
751  }
752 
753  if( ( aPin->GetFlags() & IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
754  drawPinDanglingSymbol( pos, drawingShadows );
755 
756  // Draw the labels
757 
758  LIB_PART* libEntry = aPin->GetParent();
759  int textOffset = libEntry->GetPinNameOffset();
760 
761  float nameLineWidth = getLineWidth( aPin, drawingShadows );
762  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
763  float numLineWidth = getLineWidth( aPin, drawingShadows );
764  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
765 
766  #define PIN_TEXT_MARGIN 4.0
767 
768  // Four locations around a pin where text can be drawn
769  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
770  int size[4] = { 0, 0, 0, 0 };
771  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
772  COLOR4D colour[4];
773  wxString text[4];
774 
775  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
776  if( textOffset )
777  {
778  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
779  thickness[INSIDE] = nameLineWidth;
780  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
781  text [INSIDE] = aPin->GetName();
782 
783  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
784  thickness[ABOVE] = numLineWidth;
785  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
786  text [ABOVE] = aPin->GetNumber();
787  }
788  // Otherwise pin NAMES go above and pin NUMBERS go below
789  else
790  {
791  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
792  thickness[ABOVE] = nameLineWidth;
793  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
794  text [ABOVE] = aPin->GetName();
795 
796  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
797  thickness[BELOW] = numLineWidth;
798  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
799  text [BELOW] = aPin->GetNumber();
800  }
801 
803  {
804  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
805  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
806  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
807  text [OUTSIDE] = aPin->GetElectricalTypeName();
808  }
809 
810  if( !aPin->IsVisible() )
811  {
812  for( COLOR4D& c : colour )
813  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
814  }
815 
816  int insideOffset = textOffset;
817  int outsideOffset = 10;
818  float lineThickness = (float) GetDefaultLineThickness();
819  float aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + lineThickness ) / 2.0;
820  float belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + lineThickness ) / 2.0;
821 
822  if( drawingShadows )
823  {
824  for( float& t : thickness )
825  t += getShadowWidth();
826 
827  insideOffset -= KiROUND( getShadowWidth() / 2 );
828  outsideOffset -= KiROUND( getShadowWidth() / 2 );
829  }
830 
831  #define SET_DC( i ) \
832  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
833  m_gal->SetLineWidth( thickness[i] ); \
834  m_gal->SetStrokeColor( colour[i] )
835 
836  switch( orient )
837  {
838  case PIN_LEFT:
839  if( size[INSIDE] )
840  {
841  SET_DC( INSIDE );
844  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
845  }
846  if( size[OUTSIDE] )
847  {
848  SET_DC( OUTSIDE );
851  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
852  }
853  if( size[ABOVE] )
854  {
855  SET_DC( ABOVE );
858  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
859  }
860  if( size[BELOW] )
861  {
862  SET_DC( BELOW );
865  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
866  }
867  break;
868 
869  case PIN_RIGHT:
870  if( size[INSIDE] )
871  {
872  SET_DC( INSIDE );
876  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
877  }
878  if( size[OUTSIDE] )
879  {
880  SET_DC( OUTSIDE );
883  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
884  }
885  if( size[ABOVE] )
886  {
887  SET_DC( ABOVE );
890  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
891  }
892  if( size[BELOW] )
893  {
894  SET_DC( BELOW );
897  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
898  }
899  break;
900 
901  case PIN_DOWN:
902  if( size[INSIDE] )
903  {
904  SET_DC( INSIDE );
907  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2);
908  }
909  if( size[OUTSIDE] )
910  {
911  SET_DC( OUTSIDE );
914  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2);
915  }
916  if( size[ABOVE] )
917  {
918  SET_DC( ABOVE );
921  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
922  }
923  if( size[BELOW] )
924  {
925  SET_DC( BELOW );
928  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
929  }
930  break;
931 
932  case PIN_UP:
933  if( size[INSIDE] )
934  {
935  SET_DC( INSIDE );
938  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2);
939  }
940  if( size[OUTSIDE] )
941  {
942  SET_DC( OUTSIDE );
945  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2);
946  }
947  if( size[ABOVE] )
948  {
949  SET_DC( ABOVE );
952  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
953  }
954  if( size[BELOW] )
955  {
956  SET_DC( BELOW );
959  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
960  }
961  break;
962 
963  default:
964  wxFAIL_MSG( "Unknown pin orientation" );
965  }
966 }
967 
968 
969 void SCH_PAINTER::draw( LIB_BEZIER *aCurve, int aLayer )
970 {
971  if( !isUnitAndConversionShown( aCurve ) )
972  return;
973 
974  if( setDeviceColors( aCurve, aLayer ) )
975  {
976  BEZIER_POLY poly ( aCurve->GetPoints() );
977  std::vector<wxPoint> pts;
978  std::deque<VECTOR2D> pts_xformed;
979  poly.GetPoly( pts );
980 
981  for( const auto &p : pts )
982  pts_xformed.push_back( mapCoords( p ) );
983 
984  m_gal->DrawPolygon( pts_xformed );
985  }
986 }
987 
988 
989 // Draw the target (an open square) for a wire or label which has no connection or is
990 // being moved.
991 void SCH_PAINTER::drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows )
992 {
993  wxPoint radius( DANGLING_SYMBOL_SIZE, DANGLING_SYMBOL_SIZE );
994 
995  m_gal->SetIsStroke( true );
996  m_gal->SetIsFill( false );
997  m_gal->SetLineWidth ( aDrawingShadows ? getShadowWidth() : 1.0F );
998 
999  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1000 }
1001 
1002 
1003 void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer )
1004 {
1005  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1006 
1007  if( drawingShadows && !aJct->IsSelected() )
1008  return;
1009 
1010  COLOR4D color;
1011  auto conn = aJct->Connection( *g_CurrentSheet );
1012 
1013  if( conn && conn->IsBus() )
1014  color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
1015  else
1016  color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
1017 
1018  m_gal->SetIsStroke( drawingShadows );
1019  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1021  m_gal->SetIsFill( !drawingShadows );
1022  m_gal->SetFillColor( color );
1024 }
1025 
1026 
1027 void SCH_PAINTER::draw( SCH_LINE *aLine, int aLayer )
1028 {
1029  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1030 
1031  if( drawingShadows && !aLine->IsSelected() )
1032  return;
1033 
1034  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1035  float width = getLineWidth( aLine, drawingShadows );
1036 
1037  m_gal->SetIsStroke( true );
1039  m_gal->SetLineWidth( width );
1040 
1041  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID || drawingShadows )
1042  {
1043  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1044  }
1045  else
1046  {
1047  VECTOR2D start = aLine->GetStartPoint();
1048  VECTOR2D end = aLine->GetEndPoint();
1049 
1050  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1051  clip.Normalize();
1052 
1053  double theta = atan2( end.y - start.y, end.x - start.x );
1054  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1055 
1056  switch( aLine->GetLineStyle() )
1057  {
1058  default:
1059  case PLOTDASHTYPE_DASH:
1060  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1061  break;
1062  case PLOTDASHTYPE_DOT:
1063  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1064  break;
1065  case PLOTDASHTYPE_DASHDOT:
1066  strokes[0] = DASH_MARK_LEN( width );
1067  strokes[2] = DOT_MARK_LEN( width );
1068  break;
1069  }
1070 
1071  for( size_t i = 0; i < 10000; ++i )
1072  {
1073  // Calculations MUST be done in doubles to keep from accumulating rounding
1074  // errors as we go.
1075  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1076  start.y + strokes[ i % 4 ] * sin( theta ) );
1077 
1078  // Drawing each segment can be done rounded to ints.
1079  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1080  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1081 
1082  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1083  break;
1084  else if( i % 2 == 0 )
1085  m_gal->DrawLine( segStart, segEnd );
1086 
1087  start = next;
1088  }
1089  }
1090 
1091  if( aLine->IsStartDangling() )
1092  drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
1093 
1094  if( aLine->IsEndDangling() )
1095  drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
1096 }
1097 
1098 
1099 void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
1100 {
1101  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1102 
1103  if( drawingShadows && !aText->IsSelected() )
1104  return;
1105 
1106  switch( aText->Type() )
1107  {
1108  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1109  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1110  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1111  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1112  default: aLayer = LAYER_NOTES; break;
1113  }
1114 
1115  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1116  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
1117 
1118  if( conn && conn->IsBus() )
1119  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1120 
1121  if( !aText->IsVisible() )
1122  {
1124  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1125  else
1126  return;
1127  }
1128 
1129  m_gal->SetIsFill( false );
1130  m_gal->SetIsStroke( true );
1131  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
1133  m_gal->SetTextAttributes( aText );
1134 
1135  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1136  wxString shownText( aText->GetShownText() );
1137 
1138  if( drawingShadows )
1139  {
1140  switch( aText->GetLabelSpinStyle() )
1141  {
1142  case 0:
1143  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1144  text_offset.x -= getShadowWidth() / 2;
1145  else
1146  text_offset.x += getShadowWidth() / 2;
1147  break;
1148  case 1:
1149  text_offset.y += getShadowWidth() / 2;
1150  break;
1151  case 2:
1152  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1153  text_offset.x += getShadowWidth() / 2;
1154  else
1155  text_offset.x -= getShadowWidth() / 2;
1156  break;
1157  case 3:
1158  text_offset.y -= getShadowWidth() / 2;
1159  break;
1160  }
1161  }
1162 
1163  if( !shownText.IsEmpty() )
1164  m_gal->StrokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1165 
1166  if( aText->IsDangling() )
1167  drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
1168 }
1169 
1170 
1171 static void orientPart( LIB_PART* part, int orientation )
1172 {
1173  struct ORIENT
1174  {
1175  int flag;
1176  int n_rots;
1177  int mirror_x;
1178  int mirror_y;
1179  }
1180  orientations[] =
1181  {
1182  { CMP_ORIENT_0, 0, 0, 0 },
1183  { CMP_ORIENT_90, 1, 0, 0 },
1184  { CMP_ORIENT_180, 2, 0, 0 },
1185  { CMP_ORIENT_270, 3, 0, 0 },
1186  { CMP_MIRROR_X + CMP_ORIENT_0, 0, 1, 0 },
1187  { CMP_MIRROR_X + CMP_ORIENT_90, 1, 1, 0 },
1188  { CMP_MIRROR_Y, 0, 0, 1 },
1189  { CMP_MIRROR_X + CMP_ORIENT_270, 3, 1, 0 },
1190  { CMP_MIRROR_Y + CMP_ORIENT_0, 0, 0, 1 },
1191  { CMP_MIRROR_Y + CMP_ORIENT_90, 1, 0, 1 },
1192  { CMP_MIRROR_Y + CMP_ORIENT_180, 2, 0, 1 },
1193  { CMP_MIRROR_Y + CMP_ORIENT_270, 3, 0, 1 }
1194  };
1195 
1196  ORIENT o = orientations[ 0 ];
1197 
1198  for( auto& i : orientations )
1199  {
1200  if( i.flag == orientation )
1201  {
1202  o = i;
1203  break;
1204  }
1205  }
1206 
1207  for( auto& item : part->GetDrawItems() )
1208  {
1209  for( int i = 0; i < o.n_rots; i++ )
1210  item.Rotate( wxPoint(0, 0 ), true );
1211 
1212  if( o.mirror_x )
1213  item.MirrorVertical( wxPoint( 0, 0 ) );
1214 
1215  if( o.mirror_y )
1216  item.MirrorHorizontal( wxPoint( 0, 0 ) );
1217  }
1218 }
1219 
1220 
1221 void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
1222 {
1223  PART_SPTR originalPartSptr = aComp->GetPartRef().lock();
1224 
1225  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1226  LIB_PART* originalPart = originalPartSptr ? originalPartSptr.get() : dummy();
1227 
1228  // Copy the source so we can re-orient and translate it.
1229  LIB_PART tempPart( *originalPart );
1230 
1231  tempPart.SetFlags( aComp->GetFlags() );
1232 
1233  orientPart( &tempPart, aComp->GetOrientation());
1234 
1235  for( auto& tempItem : tempPart.GetDrawItems() )
1236  {
1237  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1238  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition()));
1239  }
1240 
1241  // Copy the pin info from the component to the temp pins
1242  LIB_PINS tempPins;
1243  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1244  const SCH_PINS& compPins = aComp->GetPins();
1245 
1246  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1247  {
1248  LIB_PIN* tempPin = tempPins[ i ];
1249  const SCH_PIN& compPin = compPins[ i ];
1250 
1251  tempPin->ClearFlags();
1252  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1253 
1254  if( compPin.IsDangling() )
1255  tempPin->SetFlags( IS_DANGLING );
1256  }
1257 
1258  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1259 
1260  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1261  std::vector<SCH_FIELD*> fields;
1262  aComp->GetFields( fields, false );
1263 
1264  for( SCH_FIELD* field : fields )
1265  draw( field, aLayer );
1266 }
1267 
1268 
1269 void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer )
1270 {
1271  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1272 
1273  if( drawingShadows && !aField->IsSelected() )
1274  return;
1275 
1276  switch( aField->GetId() )
1277  {
1278  case REFERENCE: aLayer = LAYER_REFERENCEPART; break;
1279  case VALUE: aLayer = LAYER_VALUEPART; break;
1280  default: aLayer = LAYER_FIELDS; break;
1281  }
1282 
1283  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1284 
1285  if( !aField->IsVisible() )
1286  {
1288  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1289  else
1290  return;
1291  }
1292 
1293  if( aField->IsVoid() )
1294  return;
1295 
1296  // Calculate the text orientation according to the component orientation.
1297  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1298  int orient = (int) aField->GetTextAngle();
1299 
1300  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1301  {
1302  if( orient == TEXT_ANGLE_HORIZ )
1303  orient = TEXT_ANGLE_VERT;
1304  else
1305  orient = TEXT_ANGLE_HORIZ;
1306  }
1307 
1308  /* Calculate the text justification, according to the component orientation/mirror.
1309  * Tthis is a bit complicated due to cumulative calculations:
1310  * - numerous cases (mirrored or not, rotation)
1311  * - the DrawGraphicText function recalculate also H and H justifications according to the
1312  * text orientation.
1313  * - When a component is mirrored, the text is not mirrored and justifications are
1314  * complicated to calculate
1315  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1316  * to know the text coordinate considered as centered
1317  */
1318  EDA_RECT boundaryBox = aField->GetBoundingBox();
1319  wxPoint textpos = boundaryBox.Centre();
1320 
1324  m_gal->SetIsFill( false );
1325  m_gal->SetIsStroke( true );
1326  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1327  m_gal->SetFontBold( aField->IsBold() );
1328  m_gal->SetFontItalic( aField->IsItalic() );
1329  m_gal->SetTextMirrored( aField->IsMirrored() );
1330  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
1331  m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI/2 : 0 );
1332 
1333  // Draw the umbilical line
1334  if( aField->IsMoving() )
1335  {
1337  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1338  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1339  }
1340 }
1341 
1342 
1343 void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer )
1344 {
1345  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1346 
1347  if( drawingShadows && !aLabel->IsSelected() )
1348  return;
1349 
1350  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1351 
1352  std::vector<wxPoint> pts;
1353  std::deque<VECTOR2D> pts2;
1354 
1355  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1356 
1357  for( auto p : pts )
1358  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1359 
1360  m_gal->SetIsFill( true );
1362  m_gal->SetIsStroke( true );
1363  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1365  m_gal->DrawPolyline( pts2 );
1366 
1367  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1368 }
1369 
1370 
1371 void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
1372 {
1373  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1374 
1375  if( drawingShadows && !aLabel->IsSelected() )
1376  return;
1377 
1378  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1379 
1380  SCH_CONNECTION* conn = aLabel->Connection( *g_CurrentSheet );
1381 
1382  if( conn && conn->IsBus() )
1383  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1384 
1385  std::vector<wxPoint> pts;
1386  std::deque<VECTOR2D> pts2;
1387 
1388  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1389 
1390  for( auto p : pts )
1391  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1392 
1393  m_gal->SetIsFill( true );
1395  m_gal->SetIsStroke( true );
1396  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1398  m_gal->DrawPolyline( pts2 );
1399 
1400  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1401 }
1402 
1403 void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
1404 {
1405  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1406 
1407  if( aLayer == LAYER_HIERLABEL || drawingShadows )
1408  {
1409  for( auto& sheetPin : aSheet->GetPins() )
1410  {
1411  if( drawingShadows && !aSheet->IsSelected() && !sheetPin.IsSelected() )
1412  continue;
1413 
1414  int width = aSheet->GetPenSize();
1415  wxPoint initial_pos = sheetPin.GetTextPos();
1416  wxPoint offset_pos = initial_pos;
1417 
1418  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1419  switch( sheetPin.GetEdge() )
1420  {
1421  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1422  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1423  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1424  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1425  default: break;
1426  }
1427 
1428  sheetPin.SetTextPos( offset_pos );
1429  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1430  m_gal->DrawLine( offset_pos, initial_pos );
1431  sheetPin.SetTextPos( initial_pos );
1432  }
1433  }
1434 
1435  if( drawingShadows && !aSheet->IsSelected() )
1436  return;
1437 
1438  VECTOR2D pos = aSheet->GetPosition();
1439  VECTOR2D size = aSheet->GetSize();
1440 
1441  if( aLayer == LAYER_SHEET_BACKGROUND )
1442  {
1443  m_gal->SetIsStroke( aSheet->IsSelected() );
1446 
1447  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1448  {
1449  // Select a fill color working well with black and white background color,
1450  // both in Opengl and Cairo
1451  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1452  m_gal->SetIsFill( true );
1453  }
1454  else
1455  {
1456  // Could be modified later, when sheets can have their own fill color
1457  m_gal->SetIsFill( false );
1458  }
1459 
1460  m_gal->DrawRectangle( pos, pos + size );
1461  }
1462 
1463  if( aLayer == LAYER_SHEET || drawingShadows )
1464  {
1465  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1466  m_gal->SetIsStroke( true );
1467  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1468  m_gal->SetIsFill( false );
1469 
1470  m_gal->DrawRectangle( pos, pos + size );
1471 
1472  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1473  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1474  double nameAngle = 0.0;
1475 
1476  if( aSheet->IsVerticalOrientation() )
1477  nameAngle = M_PI/2;
1478 
1479  if( drawingShadows )
1480  {
1481  if( aSheet->IsVerticalOrientation() )
1482  {
1483  pos_sheetname.y += getShadowWidth() / 2;
1484  pos_filename.y += getShadowWidth() / 2;
1485  }
1486  else
1487  {
1488  pos_sheetname.x -= getShadowWidth() / 2;
1489  pos_filename.x -= getShadowWidth() / 2;
1490  }
1491  }
1492 
1493  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
1494 
1495  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1496 
1499 
1500  auto txtSize = aSheet->GetSheetNameSize();
1501 
1502  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1503  m_gal->SetFontBold( false );
1504  m_gal->SetFontItalic( false );
1505 
1506  m_gal->StrokeText( text, pos_sheetname, nameAngle );
1507 
1508  txtSize = aSheet->GetFileNameSize();
1509  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1510  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) );
1512 
1513  text = wxT( "File: " ) + aSheet->GetFileName();
1514  m_gal->StrokeText( text, pos_filename, nameAngle );
1515  }
1516 }
1517 
1518 
1519 void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer )
1520 {
1521  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1522 
1523  if( drawingShadows && !aNC->IsSelected() )
1524  return;
1525 
1526  m_gal->SetIsStroke( true );
1527  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1528  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1529  m_gal->SetIsFill( false );
1530 
1531  VECTOR2D p = aNC->GetPosition();
1532  int delta = aNC->GetSize() / 2;
1533 
1534  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1535  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1536 }
1537 
1538 
1539 void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
1540 {
1541  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1542 
1543  if( drawingShadows && !aEntry->IsSelected() )
1544  return;
1545 
1546  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1547 
1548  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1549  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1550 
1551  m_gal->SetIsStroke( true );
1552  m_gal->SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
1554  m_gal->SetIsFill( false );
1555 
1556  VECTOR2D pos = aEntry->GetPosition();
1557  VECTOR2D endPos = aEntry->m_End();
1558 
1559  m_gal->DrawLine( pos, endPos );
1560 
1561  // Draw dangling symbols:
1562  m_gal->SetLineWidth ( getLineWidth( aEntry, drawingShadows ) );
1563 
1564  if( aEntry->IsDanglingStart() )
1566 
1567  if( aEntry->IsDanglingEnd() )
1569 }
1570 
1571 
1572 void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer )
1573 {
1574  m_gal->Save();
1575  m_gal->Translate( aBitmap->GetPosition() );
1576 
1577  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1578  // factor is similar to a local zoom
1579  double img_scale = aBitmap->GetImageScale();
1580 
1581  if( img_scale != 1.0 )
1582  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1583 
1584  if( aLayer == LAYER_DRAW_BITMAPS )
1585  {
1586  m_gal->DrawBitmap( *aBitmap->GetImage() );
1587  }
1588 
1589  if( aLayer == LAYER_SELECTION_SHADOWS )
1590  {
1591  if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
1592  {
1593  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1594  m_gal->SetIsStroke( true );
1597  m_gal->SetIsFill( false );
1598 
1599  // Draws a bounding box.
1600  VECTOR2D bm_size( aBitmap->GetSize() );
1601  // bm_size is the actual image size in UI.
1602  // but m_gal scale was previously set to img_scale
1603  // so recalculate size relative to this image size.
1604  bm_size.x /= img_scale;
1605  bm_size.y /= img_scale;
1606  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1607  VECTOR2D end = origin + bm_size;
1608 
1609  m_gal->DrawRectangle( origin, end );
1610  }
1611  }
1612 
1613  m_gal->Restore();
1614 }
1615 
1616 
1617 void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
1618 {
1619  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1620 
1621  if( drawingShadows && !aMarker->IsSelected() )
1622  return;
1623 
1625  aLayer = LAYER_ERC_ERR;
1626  else
1627  aLayer = LAYER_ERC_WARN;
1628 
1629  COLOR4D color = getRenderColor( aMarker, aLayer, drawingShadows );
1630 
1631  m_gal->Save();
1632  m_gal->Translate( aMarker->GetPosition() );
1633  m_gal->SetIsFill( !drawingShadows );
1634  m_gal->SetFillColor( color );
1635  m_gal->SetIsStroke( drawingShadows );
1636  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1638 
1639  SHAPE_LINE_CHAIN polygon;
1640  aMarker->ShapeToPolygon( polygon );
1641 
1642  m_gal->DrawPolygon( polygon );
1643  m_gal->Restore();
1644 }
1645 
1646 
1647 }; // 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:180
#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:167
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:35
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
Part library alias object definition.
PART_REF & GetPartRef()
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:185
bool IsMirrored() const
Definition: eda_text.h:173
SCH_SHEET_PINS & GetPins()
Definition: sch_sheet.h:325
name of datasheet
int GetPinNameOffset()
int GetOrientation()
Get the display symbol orientation.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
wxPoint GetStartPoint() const
Definition: sch_line.h:90
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:292
bool IsSelected() const
Definition: base_struct.h:233
wxPoint GetEnd() const
Definition: lib_rectangle.h:89
#define TEXT_ANGLE_VERT
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
wxPoint GetPosition() const override
Definition: lib_field.h:179
Handle colors used to draw all items or layers.
wxPoint GetPosition() const override
Function GetPosition.
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:175
to handle and draw images bitmaps
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:265
std::vector< SCH_PIN > SCH_PINS
A container for several SCH_PIN items.
Definition: sch_component.h:51
Define a symbol library graphical text item.
Definition: lib_text.h:40
int GetOrientation() const
Definition: lib_pin.h:204
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
LIB_PART * GetParent() const
Definition: lib_item.h:177
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_marker.h:93
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:170
GRAPHIC_PINSHAPE GetShape() const
Definition: lib_pin.h:216
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
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...
Definition: sch_painter.cpp:91
#define DANGLING_SYMBOL_SIZE
Definition: general.h:45
bool IsMoving() const
Definition: base_struct.h:230
int color
Definition: DXF_plotter.cpp:62
Field object used in symbol libraries.
Definition: lib_field.h:59
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
FILL_T GetFillMode() const
Definition: lib_item.h:307
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.
Definition: painter.h:221
double GetTextAngle() const
Definition: eda_text.h:158
int GetId() const
Definition: sch_field.h:103
static int InternalPinDecoSize(const LIB_PIN &aPin)
wxPoint GetPosition() const override
Definition: lib_circle.h:75
COLOR4D WithAlpha(double aAlpha) const
Function WithAlpha Returns a colour with the same colour, but the given alpha.
Definition: color4d.h:247
virtual wxPoint GetSchematicTextOffset() const
Definition: sch_text.cpp:147
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:537
#define DASH_MARK_LEN(aLineWidth)
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
bool IsBrightened() const
Definition: base_struct.h:236
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:148
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:220
Definition: lib_pin.h:55
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
Add new GAL layers here.
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:135
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_sheet.cpp:383
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:144
bool IsDangling() const override
Definition: sch_pin.h:81
Field Reference of part, i.e. "IC21".
bool IsHighlighted() const
Definition: base_struct.h:235
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
#define SET_DC(i)
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:257
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:52
bool IsDragging() const
Definition: base_struct.h:231
const wxString & GetDocFileName() const
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:701
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
Definition: painter.h:365
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:349
virtual void SetLineWidth(float aLineWidth)
Set the line width.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
bool IsItalic() const
Definition: eda_text.h:164
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:60
static int ExternalPinDecoSize(const LIB_PIN &aPin)
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
int GetFileNameSize() const
Definition: sch_sheet.h:268
int GetLabelSpinStyle() const
Definition: sch_text.h:119
int y1
Definition: transform.h:49
bool ShowPinNames()
int GetSecondRadiusAngle() const
Definition: lib_arc.h:111
bool IsRoot() const override
For symbols having aliases, IsRoot() indicates the principal item.
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:341
int GetUnit() const
Definition: lib_item.h:301
#define VALUE
int GetUnit() const
int GetSheetNameSize() const
Definition: sch_sheet.h:265
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:313
bool ShowPinNumbers()
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
virtual int GetPenSize() const
Function GetPenSize virtual pure.
Definition: sch_item.h:212
wxSize GetSize() const
Definition: sch_bitmap.cpp:123
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:64
bool IsDanglingStart() const
Definition: sch_bus_entry.h:51
void SetEnd(const wxPoint &aPoint)
Definition: lib_arc.h:117
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:184
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:112
wxString GetName() const
Definition: sch_sheet.h:262
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
BITMAP_BASE * GetImage()
Definition: sch_bitmap.h:59
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_junction.h:95
wxString const GetElectricalTypeName() const
return a translated string for messages giving the electrical type of the pin.
Definition: lib_pin.h:256
const wxString & GetName() const
Definition: lib_pin.h:149
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
TRANSFORM & GetTransform() const
Class LIB_PIN definition.
bool IsEndDangling() const
Definition: sch_line.h:176
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:221
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
bool IsResized() const
Definition: base_struct.h:234
int GetSize() const
wxPoint GetStart() const
Definition: lib_arc.h:113
#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.
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:72
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &aPos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:836
#define OUTSIDE
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
a few functions useful in geometry calculations.
#define F(x, y, z)
Definition: md5_hash.cpp:15
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:343
LIB_PART * GetPart() const
Get the shared LIB_PART.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
int GetRadius() const
Definition: lib_circle.h:91
wxPoint m_End() const
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
int GetNameTextSize() const
Definition: lib_pin.h:175
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:533
int GetConvert() const
Definition: lib_item.h:304
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
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:128
void SetEndPosition(const wxPoint &aPosition)
Definition: lib_rectangle.h:57
wxPoint GetFileNamePosition()
Definition: sch_sheet.cpp:408
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:204
int GetRadius() const
Definition: lib_arc.h:105
wxPoint GetPosition() const override
Definition: lib_pin.h:427
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:629
static void orientPart(LIB_PART *part, int orientation)
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:193
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
double GetTextAngleRadians() const
Definition: eda_text.h:161
void Normalize()
Function Normalize ensures that the height ant width are positive.
const wxString & GetNumber() const
Definition: lib_pin.h:177
void CreateGraphicShape(std::vector< wxPoint > &aPoints, const wxPoint &Pos) override
Calculate the graphic shape (a polygon) associated to the text.
Definition: sch_text.cpp:1068
ELECTRICAL_PINTYPE GetType() const
Get the electrical type of the pin.
Definition: lib_pin.h:232
static ptrdiff_t bm_size(const potrace_bitmap_t *bm)
Definition: bitmap.h:76
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:297
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
virtual int GetPenSize() const =0
int GetNumberTextSize() const
Definition: lib_pin.h:202
const wxString & GetName() const override
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:149
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:271
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_field.cpp:194
#define max(a, b)
Definition: auxiliary.h:86
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Class SHAPE_LINE_CHAIN.
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:221
#define HANDLE_ITEM(type_id, type_name)
bool IsStartDangling() const
Definition: sch_line.h:175
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:214
double GetImageScale() const
Definition: sch_bitmap.h:71
wxPoint GetSheetNamePosition()
Definition: sch_sheet.cpp:389
size_t i
Definition: json11.cpp:597
wxPoint GetEnd() const
Definition: lib_arc.h:116
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxString GetFullyQualifiedText() const
Function GetFullyQualifiedText returns the fully qualified field text by allowing for the part suffix...
Definition: sch_field.cpp:75
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
wxPoint GetPosition() const override
Function GetPosition.
#define DASH_GAP_LEN(aLineWidth)
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
wxPoint Centre() const
Definition: eda_rect.h:60
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
const wxPoint & GetTextPos() const
Definition: eda_text.h:230
int GetFirstRadiusAngle() const
Definition: lib_arc.h:108
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:114
int GetConvert() const
void draw(LIB_RECTANGLE *aRect, int aLayer)
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129
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:80
Definition for part library class.
#define INSIDE
bool IsBus() const
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:267
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: sch_painter.cpp:79
static int GetEffectiveSymbolSize()
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:282
int GetLineStyle() const
Definition: sch_line.cpp:289
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
Definitions of the SCH_TEXT class and derivatives for Eeschema.
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
wxSize GetSize()
Definition: sch_sheet.h:273
wxPoint GetPosition() const override
Definition: lib_rectangle.h:76
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:175
void GetFields(LIB_FIELDS &aList)
Return a list of fields within this part.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
Class GAL is the abstract interface for drawing on a 2D-surface.
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:35
wxPoint GetPosition() const override
Definition: lib_arc.h:92
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
wxPoint GetPosition() const override
Function GetPosition.
wxPoint GetEndPoint() const
Definition: sch_line.h:93