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 
242 
243  if( aItem->Type() == SCH_LINE_T )
244  color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
245 
246  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
247  {
249 
250  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
251  color = color.WithAlpha( 0.2 );
252  }
253  else if( aItem->IsSelected() )
254  {
255  if( aDrawingShadows )
257  }
258  else if( aItem->IsHighlighted() ) // Cross-probing
259  {
260  color = highlightColor;
261  }
262 
263  return color;
264 }
265 
266 
267 float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows )
268 {
269  float width = (float) aItem->GetPenSize();
270 
271  if( aItem->IsSelected() && aDrawingShadows )
272  width += getShadowWidth();
273 
274  return width;
275 }
276 
277 
278 float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows )
279 {
280  float width = (float) aItem->GetPenSize();
281 
282  if( aItem->IsSelected() && aDrawingShadows )
283  width += getShadowWidth();
284 
285  return width;
286 }
287 
288 
289 float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows )
290 {
291  float width = (float) aItem->GetThickness();
292 
293  if( width == 0 )
294  width = (float) GetDefaultLineThickness();
295 
296  if( aItem->IsSelected() && aDrawingShadows )
297  width += getShadowWidth();
298 
299  return width;
300 }
301 
302 
303 void SCH_PAINTER::draw( LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit, int aConvert )
304 {
305  if( !aUnit )
306  aUnit = m_schSettings.m_ShowUnit;
307 
308  if( !aConvert )
309  aConvert = m_schSettings.m_ShowConvert;
310 
311  for( auto& item : aPart->GetDrawItems() )
312  {
313  if( !aDrawFields && item.Type() == LIB_FIELD_T )
314  continue;
315 
316  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
317  continue;
318 
319  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
320  continue;
321 
322  Draw( &item, aLayer );
323  }
324 }
325 
326 
327 void SCH_PAINTER::draw( LIB_ALIAS *aAlias, int aLayer )
328 {
329  LIB_PART* comp = aAlias->GetPart();
330 
331  draw( comp, aLayer, false );
332 
333  LIB_FIELDS fields;
334  comp->GetFields( fields );
335 
336  if( !aAlias->IsRoot() )
337  {
338  fields[ VALUE ].SetText( aAlias->GetName() );
339  fields[ DATASHEET ].SetText( aAlias->GetDocFileName() );
340  }
341 
342  for( LIB_FIELD& field : fields )
343  draw( &field, aLayer );
344 }
345 
346 
347 static VECTOR2D mapCoords( const wxPoint& aCoord )
348 {
349  return VECTOR2D( aCoord.x, -aCoord.y );
350 }
351 
352 
353 void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c )
354 {
355  m_gal->DrawLine( a, b );
356  m_gal->DrawLine( b, c );
357 }
358 
359 
360 bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer )
361 {
362  switch( aLayer )
363  {
365  if( aItem->IsSelected() )
366  {
367  m_gal->SetIsFill( false );
368  m_gal->SetIsStroke( true );
369  m_gal->SetLineWidth( getLineWidth( aItem, true ) );
370  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, true ) );
371  return true;
372  }
373 
374  return false;
375 
377  if( aItem->GetFillMode() == FILLED_WITH_BG_BODYCOLOR )
378  {
379  COLOR4D fillColor = getRenderColor( aItem, LAYER_DEVICE_BACKGROUND, false );
380 
381  // These actions place the item over others, so allow a modest transparency here
382  if( aItem->IsMoving() || aItem->IsDragging() || aItem->IsResized() )
383  fillColor = fillColor.WithAlpha( 0.75 );
384 
386  m_gal->SetFillColor( fillColor );
387  m_gal->SetIsStroke( false );
388  return true;
389  }
390 
391  return false;
392 
393  case LAYER_DEVICE:
394  m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE );
395  m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
396  m_gal->SetIsStroke( aItem->GetPenSize() > 0 );
397  m_gal->SetLineWidth( getLineWidth( aItem, false ) );
398  m_gal->SetStrokeColor( getRenderColor( aItem, LAYER_DEVICE, false ) );
399 
400  return true;
401 
402  default:
403  return false;
404  }
405 }
406 
407 
408 void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer )
409 {
410  if( !isUnitAndConversionShown( aRect ) )
411  return;
412 
413  if( setDeviceColors( aRect, aLayer ) )
414  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
415 
416 }
417 
418 
419 void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer )
420 {
421  if( !isUnitAndConversionShown( aCircle ) )
422  return;
423 
424  if( setDeviceColors( aCircle, aLayer ) )
425  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
426 }
427 
428 
429 void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
430 {
431  if( !isUnitAndConversionShown( aArc ) )
432  return;
433 
434  if( setDeviceColors( aArc, aLayer ) )
435  {
436  int sai = aArc->GetFirstRadiusAngle();
437  int eai = aArc->GetSecondRadiusAngle();
438 
449  if( !TRANSFORM().MapAngles( &sai, &eai ) )
450  {
451  LIB_ARC new_arc( *aArc );
452 
453  new_arc.SetStart( aArc->GetEnd() );
454  new_arc.SetEnd( aArc->GetStart() );
455  new_arc.CalcRadiusAngles();
456  sai = new_arc.GetFirstRadiusAngle();
457  eai = new_arc.GetSecondRadiusAngle();
458  TRANSFORM().MapAngles( &sai, &eai );
459  }
460 
461  double sa = (double) sai * M_PI / 1800.0;
462  double ea = (double) eai * M_PI / 1800.0 ;
463 
464  VECTOR2D pos = mapCoords( aArc->GetPosition() );
465 
466  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
467  }
468 }
469 
470 
471 void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer )
472 {
473  if( !isUnitAndConversionShown( aLine ) )
474  return;
475 
476  if( setDeviceColors( aLine, aLayer ) )
477  {
478  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
479  std::deque<VECTOR2D> vtx;
480 
481  for( auto p : pts )
482  vtx.push_back( mapCoords( p ) );
483 
484  m_gal->DrawPolygon( vtx );
485  }
486 }
487 
488 
489 void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer )
490 {
491  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
492 
493  if( drawingShadows && !aField->IsSelected() )
494  return;
495 
496  if( !isUnitAndConversionShown( aField ) )
497  return;
498 
499  // Must check layer as fields are sometimes drawn by their parent rather than
500  // directly from the view.
501  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
502  int layers_count;
503  bool foundLayer = false;
504 
505  aField->ViewGetLayers( layers, layers_count );
506 
507  for( int i = 0; i < layers_count; ++i )
508  {
509  if( layers[i] == aLayer )
510  foundLayer = true;
511  }
512 
513  if( !foundLayer )
514  return;
515 
516  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
517 
518  if( !aField->IsVisible() )
519  {
521  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
522  else
523  return;
524  }
525 
526  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
527  m_gal->SetIsFill( false );
528  m_gal->SetIsStroke( true );
530  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
531  m_gal->SetFontItalic( aField->IsItalic() );
532 
534  m_gal->SetVerticalJustify( aField->GetVertJustify( ) );
535 
536  auto pos = mapCoords( aField->GetPosition() );
537  double orient = aField->GetTextAngleRadians();
538 
539  m_gal->StrokeText( aField->GetText(), pos, orient );
540 
541  // Draw the umbilical line
542  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
543  {
545  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
546  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
547  }
548 }
549 
550 
551 void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer )
552 {
553  if( !isUnitAndConversionShown( aText ) )
554  return;
555 
556  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
557 
558  if( drawingShadows && !aText->IsSelected() )
559  return;
560 
561  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
562 
563  if( !aText->IsVisible() )
564  {
566  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
567  else
568  return;
569  }
570 
571  EDA_RECT bBox = aText->GetBoundingBox();
572  bBox.RevertYAxis();
573  VECTOR2D pos = mapCoords( bBox.Centre() );
574  double orient = aText->GetTextAngleRadians();
575 
578  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
579  m_gal->SetIsFill( false );
580  m_gal->SetIsStroke( true );
582  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
583  m_gal->SetFontBold( aText->IsBold() );
584  m_gal->SetFontItalic( aText->IsItalic() );
585  m_gal->StrokeText( aText->GetText(), pos, orient );
586 }
587 
588 
589 static int InternalPinDecoSize( const LIB_PIN &aPin )
590 {
591  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
592 }
593 
594 
595 // Utility for getting the size of the 'external' pin decorators (as a radius)
596 // i.e. the negation circle, the polarity 'slopes' and the nonlogic marker
597 static int ExternalPinDecoSize( const LIB_PIN &aPin )
598 {
599  return aPin.GetNumberTextSize() / 2;
600 }
601 
602 
603 // Draw the target (an open circle) for a pin which has no connection or is being moved.
604 void SCH_PAINTER::drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows )
605 {
606  m_gal->SetIsFill( false );
607  m_gal->SetIsStroke( true );
608  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
609 
611 }
612 
613 
614 void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
615 {
616  if( !isUnitAndConversionShown( aPin ) )
617  return;
618 
619  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
620 
621  if( drawingShadows && !aPin->IsSelected() )
622  return;
623 
624  VECTOR2I pos = mapCoords( aPin->GetPosition() );
625  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
626 
627  if( !aPin->IsVisible() )
628  {
630  {
631  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
632  }
633  else
634  {
635  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
636  drawPinDanglingSymbol( pos, drawingShadows );
637 
638  return;
639  }
640  }
641 
642  VECTOR2I p0;
643  VECTOR2I dir;
644  int len = aPin->GetLength();
645  int shape = aPin->GetShape();
646  int orient = aPin->GetOrientation();
647 
648  switch( orient )
649  {
650  case PIN_UP:
651  p0 = VECTOR2I( pos.x, pos.y - len );
652  dir = VECTOR2I(0, 1);
653  break;
654  case PIN_DOWN:
655  p0 = VECTOR2I( pos.x, pos.y + len );
656  dir = VECTOR2I(0, -1);
657  break;
658  case PIN_LEFT:
659  p0 = VECTOR2I( pos.x - len, pos.y );
660  dir = VECTOR2I(1, 0);
661  break;
662  default:
663  case PIN_RIGHT:
664  p0 = VECTOR2I( pos.x + len, pos.y );
665  dir = VECTOR2I(-1, 0);
666  break;
667  }
668 
669  VECTOR2D pc;
670 
671  m_gal->SetIsStroke( true );
672  m_gal->SetIsFill( false );
673  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
675  m_gal->SetFontBold( false );
676  m_gal->SetFontItalic( false );
677 
678  const int radius = ExternalPinDecoSize( *aPin );
679  const int diam = radius*2;
680  const int clock_size = InternalPinDecoSize( *aPin );
681 
682  if( shape == PINSHAPE_INVERTED )
683  {
684  m_gal->DrawCircle( p0 + dir * radius, radius );
685  m_gal->DrawLine( p0 + dir * ( diam ), pos );
686  }
687  else if( shape == PINSHAPE_FALLING_EDGE_CLOCK )
688  {
689  pc = p0 + dir * clock_size ;
690 
691  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
692  pc,
693  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
694 
695  m_gal->DrawLine( pos, pc );
696  }
697  else
698  {
699  m_gal->DrawLine( p0, pos );
700  }
701 
702  if( shape == PINSHAPE_CLOCK )
703  {
704  if (!dir.y)
705  {
706  triLine( p0 + VECTOR2D( 0, clock_size ),
707  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
708  p0 + VECTOR2D( 0, -clock_size ) );
709  }
710  else
711  {
712  triLine( p0 + VECTOR2D( clock_size, 0 ),
713  p0 + VECTOR2D( 0, -dir.y * clock_size ),
714  p0 + VECTOR2D( -clock_size, 0 ) );
715  }
716  }
717 
718  if( shape == PINSHAPE_INPUT_LOW )
719  {
720  if(!dir.y)
721  {
722  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
723  p0 + VECTOR2D(dir.x, -1) * diam,
724  p0 );
725  }
726  else /* MapX1 = 0 */
727  {
728  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
729  p0 + VECTOR2D(-1, dir.y) * diam,
730  p0 );
731  }
732  }
733 
734  if( shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
735  {
736  if( !dir.y ) // Horizontal pin
737  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
738  else // Vertical pin
739  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
740  }
741 
742  if( shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
743  {
744  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
745  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
746  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
747  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
748  }
749 
750  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
751  {
752  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
753  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
754  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
755  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
756 
757  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
758  }
759 
760  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
761  drawPinDanglingSymbol( pos, drawingShadows );
762 
763  // Draw the labels
764 
765  LIB_PART* libEntry = aPin->GetParent();
766  int textOffset = libEntry->GetPinNameOffset();
767 
768  float nameLineWidth = getLineWidth( aPin, drawingShadows );
769  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
770  float numLineWidth = getLineWidth( aPin, drawingShadows );
771  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
772 
773  #define PIN_TEXT_MARGIN 4.0
774 
775  // Four locations around a pin where text can be drawn
776  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
777  int size[4] = { 0, 0, 0, 0 };
778  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
779  COLOR4D colour[4];
780  wxString text[4];
781 
782  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
783  if( textOffset )
784  {
785  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
786  thickness[INSIDE] = nameLineWidth;
787  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
788  text [INSIDE] = aPin->GetName();
789 
790  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
791  thickness[ABOVE] = numLineWidth;
792  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
793  text [ABOVE] = aPin->GetNumber();
794  }
795  // Otherwise pin NAMES go above and pin NUMBERS go below
796  else
797  {
798  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
799  thickness[ABOVE] = nameLineWidth;
800  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
801  text [ABOVE] = aPin->GetName();
802 
803  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
804  thickness[BELOW] = numLineWidth;
805  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
806  text [BELOW] = aPin->GetNumber();
807  }
808 
810  {
811  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
812  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
813  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
814  text [OUTSIDE] = aPin->GetElectricalTypeName();
815  }
816 
817  if( !aPin->IsVisible() )
818  {
819  for( COLOR4D& c : colour )
820  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
821  }
822 
823  int insideOffset = textOffset;
824  int outsideOffset = 10;
825  float lineThickness = (float) GetDefaultLineThickness();
826  float aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + lineThickness ) / 2.0;
827  float belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + lineThickness ) / 2.0;
828 
829  if( drawingShadows )
830  {
831  for( float& t : thickness )
832  t += getShadowWidth();
833 
834  insideOffset -= KiROUND( getShadowWidth() / 2 );
835  outsideOffset -= KiROUND( getShadowWidth() / 2 );
836  }
837 
838  #define SET_DC( i ) \
839  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
840  m_gal->SetLineWidth( thickness[i] ); \
841  m_gal->SetStrokeColor( colour[i] )
842 
843  switch( orient )
844  {
845  case PIN_LEFT:
846  if( size[INSIDE] )
847  {
848  SET_DC( INSIDE );
851  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
852  }
853  if( size[OUTSIDE] )
854  {
855  SET_DC( OUTSIDE );
858  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
859  }
860  if( size[ABOVE] )
861  {
862  SET_DC( ABOVE );
865  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
866  }
867  if( size[BELOW] )
868  {
869  SET_DC( BELOW );
872  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
873  }
874  break;
875 
876  case PIN_RIGHT:
877  if( size[INSIDE] )
878  {
879  SET_DC( INSIDE );
883  m_gal->StrokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
884  }
885  if( size[OUTSIDE] )
886  {
887  SET_DC( OUTSIDE );
890  m_gal->StrokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
891  }
892  if( size[ABOVE] )
893  {
894  SET_DC( ABOVE );
897  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
898  }
899  if( size[BELOW] )
900  {
901  SET_DC( BELOW );
904  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
905  }
906  break;
907 
908  case PIN_DOWN:
909  if( size[INSIDE] )
910  {
911  SET_DC( INSIDE );
914  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2);
915  }
916  if( size[OUTSIDE] )
917  {
918  SET_DC( OUTSIDE );
921  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2);
922  }
923  if( size[ABOVE] )
924  {
925  SET_DC( ABOVE );
928  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
929  }
930  if( size[BELOW] )
931  {
932  SET_DC( BELOW );
935  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
936  }
937  break;
938 
939  case PIN_UP:
940  if( size[INSIDE] )
941  {
942  SET_DC( INSIDE );
945  m_gal->StrokeText ( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2);
946  }
947  if( size[OUTSIDE] )
948  {
949  SET_DC( OUTSIDE );
952  m_gal->StrokeText ( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2);
953  }
954  if( size[ABOVE] )
955  {
956  SET_DC( ABOVE );
959  m_gal->StrokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
960  }
961  if( size[BELOW] )
962  {
963  SET_DC( BELOW );
966  m_gal->StrokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
967  }
968  break;
969 
970  default:
971  wxFAIL_MSG( "Unknown pin orientation" );
972  }
973 }
974 
975 
976 void SCH_PAINTER::draw( LIB_BEZIER *aCurve, int aLayer )
977 {
978  if( !isUnitAndConversionShown( aCurve ) )
979  return;
980 
981  if( setDeviceColors( aCurve, aLayer ) )
982  {
983  BEZIER_POLY poly ( aCurve->GetPoints() );
984  std::vector<wxPoint> pts;
985  std::deque<VECTOR2D> pts_xformed;
986  poly.GetPoly( pts );
987 
988  for( const auto &p : pts )
989  pts_xformed.push_back( mapCoords( p ) );
990 
991  m_gal->DrawPolygon( pts_xformed );
992  }
993 }
994 
995 
996 // Draw the target (an open square) for a wire or label which has no connection or is
997 // being moved.
998 void SCH_PAINTER::drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows )
999 {
1000  wxPoint radius( DANGLING_SYMBOL_SIZE, DANGLING_SYMBOL_SIZE );
1001 
1002  m_gal->SetIsStroke( true );
1003  m_gal->SetIsFill( false );
1004  m_gal->SetLineWidth ( aDrawingShadows ? getShadowWidth() : 1.0F );
1005 
1006  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1007 }
1008 
1009 
1010 void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer )
1011 {
1012  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1013 
1014  if( drawingShadows && !aJct->IsSelected() )
1015  return;
1016 
1017  COLOR4D color;
1018  auto conn = aJct->Connection( *g_CurrentSheet );
1019 
1020  if( conn && conn->IsBus() )
1021  color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
1022  else
1023  color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
1024 
1025  m_gal->SetIsStroke( drawingShadows );
1026  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1028  m_gal->SetIsFill( !drawingShadows );
1029  m_gal->SetFillColor( color );
1031 }
1032 
1033 
1034 void SCH_PAINTER::draw( SCH_LINE *aLine, int aLayer )
1035 {
1036  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1037 
1038  if( drawingShadows && !aLine->IsSelected() )
1039  return;
1040 
1041  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1042  float width = getLineWidth( aLine, drawingShadows );
1043 
1044  m_gal->SetIsStroke( true );
1046  m_gal->SetLineWidth( width );
1047 
1048  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID || drawingShadows )
1049  {
1050  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1051  }
1052  else
1053  {
1054  VECTOR2D start = aLine->GetStartPoint();
1055  VECTOR2D end = aLine->GetEndPoint();
1056 
1057  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1058  clip.Normalize();
1059 
1060  double theta = atan2( end.y - start.y, end.x - start.x );
1061  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1062 
1063  switch( aLine->GetLineStyle() )
1064  {
1065  default:
1066  case PLOTDASHTYPE_DASH:
1067  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1068  break;
1069  case PLOTDASHTYPE_DOT:
1070  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1071  break;
1072  case PLOTDASHTYPE_DASHDOT:
1073  strokes[0] = DASH_MARK_LEN( width );
1074  strokes[2] = DOT_MARK_LEN( width );
1075  break;
1076  }
1077 
1078  for( size_t i = 0; i < 10000; ++i )
1079  {
1080  // Calculations MUST be done in doubles to keep from accumulating rounding
1081  // errors as we go.
1082  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1083  start.y + strokes[ i % 4 ] * sin( theta ) );
1084 
1085  // Drawing each segment can be done rounded to ints.
1086  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1087  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1088 
1089  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1090  break;
1091  else if( i % 2 == 0 )
1092  m_gal->DrawLine( segStart, segEnd );
1093 
1094  start = next;
1095  }
1096  }
1097 
1098  if( aLine->IsStartDangling() )
1099  drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
1100 
1101  if( aLine->IsEndDangling() )
1102  drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
1103 }
1104 
1105 
1106 void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
1107 {
1108  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1109 
1110  if( drawingShadows && !aText->IsSelected() )
1111  return;
1112 
1113  switch( aText->Type() )
1114  {
1115  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1116  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1117  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1118  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1119  default: aLayer = LAYER_NOTES; break;
1120  }
1121 
1122  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1123  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
1124 
1125  if( conn && conn->IsBus() )
1126  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1127 
1128  if( !aText->IsVisible() )
1129  {
1131  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1132  else
1133  return;
1134  }
1135 
1136  m_gal->SetIsFill( false );
1137  m_gal->SetIsStroke( true );
1138  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
1140  m_gal->SetTextAttributes( aText );
1141 
1142  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1143  wxString shownText( aText->GetShownText() );
1144 
1145  if( drawingShadows )
1146  {
1147  switch( aText->GetLabelSpinStyle() )
1148  {
1149  case 0:
1150  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1151  text_offset.x -= getShadowWidth() / 2;
1152  else
1153  text_offset.x += getShadowWidth() / 2;
1154  break;
1155  case 1:
1156  text_offset.y += getShadowWidth() / 2;
1157  break;
1158  case 2:
1159  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1160  text_offset.x += getShadowWidth() / 2;
1161  else
1162  text_offset.x -= getShadowWidth() / 2;
1163  break;
1164  case 3:
1165  text_offset.y -= getShadowWidth() / 2;
1166  break;
1167  }
1168  }
1169 
1170  if( !shownText.IsEmpty() )
1171  m_gal->StrokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1172 
1173  if( aText->IsDangling() )
1174  drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
1175 }
1176 
1177 
1178 static void orientPart( LIB_PART* part, int orientation )
1179 {
1180  struct ORIENT
1181  {
1182  int flag;
1183  int n_rots;
1184  int mirror_x;
1185  int mirror_y;
1186  }
1187  orientations[] =
1188  {
1189  { CMP_ORIENT_0, 0, 0, 0 },
1190  { CMP_ORIENT_90, 1, 0, 0 },
1191  { CMP_ORIENT_180, 2, 0, 0 },
1192  { CMP_ORIENT_270, 3, 0, 0 },
1193  { CMP_MIRROR_X + CMP_ORIENT_0, 0, 1, 0 },
1194  { CMP_MIRROR_X + CMP_ORIENT_90, 1, 1, 0 },
1195  { CMP_MIRROR_Y, 0, 0, 1 },
1196  { CMP_MIRROR_X + CMP_ORIENT_270, 3, 1, 0 },
1197  { CMP_MIRROR_Y + CMP_ORIENT_0, 0, 0, 1 },
1198  { CMP_MIRROR_Y + CMP_ORIENT_90, 1, 0, 1 },
1199  { CMP_MIRROR_Y + CMP_ORIENT_180, 2, 0, 1 },
1200  { CMP_MIRROR_Y + CMP_ORIENT_270, 3, 0, 1 }
1201  };
1202 
1203  ORIENT o = orientations[ 0 ];
1204 
1205  for( auto& i : orientations )
1206  {
1207  if( i.flag == orientation )
1208  {
1209  o = i;
1210  break;
1211  }
1212  }
1213 
1214  for( auto& item : part->GetDrawItems() )
1215  {
1216  for( int i = 0; i < o.n_rots; i++ )
1217  item.Rotate( wxPoint(0, 0 ), true );
1218 
1219  if( o.mirror_x )
1220  item.MirrorVertical( wxPoint( 0, 0 ) );
1221 
1222  if( o.mirror_y )
1223  item.MirrorHorizontal( wxPoint( 0, 0 ) );
1224  }
1225 }
1226 
1227 
1228 void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
1229 {
1230  PART_SPTR originalPartSptr = aComp->GetPartRef().lock();
1231 
1232  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1233  LIB_PART* originalPart = originalPartSptr ? originalPartSptr.get() : dummy();
1234 
1235  // Copy the source so we can re-orient and translate it.
1236  LIB_PART tempPart( *originalPart );
1237 
1238  tempPart.SetFlags( aComp->GetFlags() );
1239 
1240  orientPart( &tempPart, aComp->GetOrientation());
1241 
1242  for( auto& tempItem : tempPart.GetDrawItems() )
1243  {
1244  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1245  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition()));
1246  }
1247 
1248  // Copy the pin info from the component to the temp pins
1249  LIB_PINS tempPins;
1250  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1251  const SCH_PINS& compPins = aComp->GetPins();
1252 
1253  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1254  {
1255  LIB_PIN* tempPin = tempPins[ i ];
1256  const SCH_PIN& compPin = compPins[ i ];
1257 
1258  tempPin->ClearFlags();
1259  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1260 
1261  if( compPin.IsDangling() )
1262  tempPin->SetFlags( IS_DANGLING );
1263  }
1264 
1265  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1266 
1267  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1268  std::vector<SCH_FIELD*> fields;
1269  aComp->GetFields( fields, false );
1270 
1271  for( SCH_FIELD* field : fields )
1272  draw( field, aLayer );
1273 }
1274 
1275 
1276 void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer )
1277 {
1278  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1279 
1280  if( drawingShadows && !aField->IsSelected() )
1281  return;
1282 
1283  switch( aField->GetId() )
1284  {
1285  case REFERENCE: aLayer = LAYER_REFERENCEPART; break;
1286  case VALUE: aLayer = LAYER_VALUEPART; break;
1287  default: aLayer = LAYER_FIELDS; break;
1288  }
1289 
1290  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1291 
1292  if( !aField->IsVisible() )
1293  {
1295  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1296  else
1297  return;
1298  }
1299 
1300  if( aField->IsVoid() )
1301  return;
1302 
1303  // Calculate the text orientation according to the component orientation.
1304  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1305  int orient = (int) aField->GetTextAngle();
1306 
1307  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1308  {
1309  if( orient == TEXT_ANGLE_HORIZ )
1310  orient = TEXT_ANGLE_VERT;
1311  else
1312  orient = TEXT_ANGLE_HORIZ;
1313  }
1314 
1315  /* Calculate the text justification, according to the component orientation/mirror.
1316  * Tthis is a bit complicated due to cumulative calculations:
1317  * - numerous cases (mirrored or not, rotation)
1318  * - the DrawGraphicText function recalculate also H and H justifications according to the
1319  * text orientation.
1320  * - When a component is mirrored, the text is not mirrored and justifications are
1321  * complicated to calculate
1322  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1323  * to know the text coordinate considered as centered
1324  */
1325  EDA_RECT boundaryBox = aField->GetBoundingBox();
1326  wxPoint textpos = boundaryBox.Centre();
1327 
1331  m_gal->SetIsFill( false );
1332  m_gal->SetIsStroke( true );
1333  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1334  m_gal->SetFontBold( aField->IsBold() );
1335  m_gal->SetFontItalic( aField->IsItalic() );
1336  m_gal->SetTextMirrored( aField->IsMirrored() );
1337  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
1338  m_gal->StrokeText( aField->GetFullyQualifiedText(), textpos, orient == TEXT_ANGLE_VERT ? M_PI/2 : 0 );
1339 
1340  // Draw the umbilical line
1341  if( aField->IsMoving() )
1342  {
1344  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1345  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1346  }
1347 }
1348 
1349 
1350 void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer )
1351 {
1352  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1353 
1354  if( drawingShadows && !aLabel->IsSelected() )
1355  return;
1356 
1357  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1358 
1359  std::vector<wxPoint> pts;
1360  std::deque<VECTOR2D> pts2;
1361 
1362  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1363 
1364  for( auto p : pts )
1365  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1366 
1367  m_gal->SetIsFill( true );
1369  m_gal->SetIsStroke( true );
1370  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1372  m_gal->DrawPolyline( pts2 );
1373 
1374  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1375 }
1376 
1377 
1378 void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
1379 {
1380  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1381 
1382  if( drawingShadows && !aLabel->IsSelected() )
1383  return;
1384 
1385  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1386 
1387  SCH_CONNECTION* conn = aLabel->Connection( *g_CurrentSheet );
1388 
1389  if( conn && conn->IsBus() )
1390  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1391 
1392  std::vector<wxPoint> pts;
1393  std::deque<VECTOR2D> pts2;
1394 
1395  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1396 
1397  for( auto p : pts )
1398  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1399 
1400  m_gal->SetIsFill( true );
1402  m_gal->SetIsStroke( true );
1403  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1405  m_gal->DrawPolyline( pts2 );
1406 
1407  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1408 }
1409 
1410 void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
1411 {
1412  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1413 
1414  if( aLayer == LAYER_HIERLABEL || drawingShadows )
1415  {
1416  for( auto& sheetPin : aSheet->GetPins() )
1417  {
1418  if( drawingShadows && !aSheet->IsSelected() && !sheetPin.IsSelected() )
1419  continue;
1420 
1421  int width = aSheet->GetPenSize();
1422  wxPoint initial_pos = sheetPin.GetTextPos();
1423  wxPoint offset_pos = initial_pos;
1424 
1425  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1426  switch( sheetPin.GetEdge() )
1427  {
1428  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1429  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1430  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1431  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1432  default: break;
1433  }
1434 
1435  sheetPin.SetTextPos( offset_pos );
1436  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1437  m_gal->DrawLine( offset_pos, initial_pos );
1438  sheetPin.SetTextPos( initial_pos );
1439  }
1440  }
1441 
1442  if( drawingShadows && !aSheet->IsSelected() )
1443  return;
1444 
1445  VECTOR2D pos = aSheet->GetPosition();
1446  VECTOR2D size = aSheet->GetSize();
1447 
1448  if( aLayer == LAYER_SHEET_BACKGROUND )
1449  {
1450  m_gal->SetIsStroke( aSheet->IsSelected() );
1453 
1454  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1455  {
1456  // Select a fill color working well with black and white background color,
1457  // both in Opengl and Cairo
1458  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1459  m_gal->SetIsFill( true );
1460  }
1461  else
1462  {
1463  // Could be modified later, when sheets can have their own fill color
1464  m_gal->SetIsFill( false );
1465  }
1466 
1467  m_gal->DrawRectangle( pos, pos + size );
1468  }
1469 
1470  if( aLayer == LAYER_SHEET || drawingShadows )
1471  {
1472  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1473  m_gal->SetIsStroke( true );
1474  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1475  m_gal->SetIsFill( false );
1476 
1477  m_gal->DrawRectangle( pos, pos + size );
1478 
1479  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1480  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1481  double nameAngle = 0.0;
1482 
1483  if( aSheet->IsVerticalOrientation() )
1484  nameAngle = M_PI/2;
1485 
1486  if( drawingShadows )
1487  {
1488  if( aSheet->IsVerticalOrientation() )
1489  {
1490  pos_sheetname.y += getShadowWidth() / 2;
1491  pos_filename.y += getShadowWidth() / 2;
1492  }
1493  else
1494  {
1495  pos_sheetname.x -= getShadowWidth() / 2;
1496  pos_filename.x -= getShadowWidth() / 2;
1497  }
1498  }
1499 
1500  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
1501 
1502  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1503 
1506 
1507  auto txtSize = aSheet->GetSheetNameSize();
1508 
1509  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1510  m_gal->SetFontBold( false );
1511  m_gal->SetFontItalic( false );
1512 
1513  m_gal->StrokeText( text, pos_sheetname, nameAngle );
1514 
1515  txtSize = aSheet->GetFileNameSize();
1516  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1517  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) );
1519 
1520  text = wxT( "File: " ) + aSheet->GetFileName();
1521  m_gal->StrokeText( text, pos_filename, nameAngle );
1522  }
1523 }
1524 
1525 
1526 void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer )
1527 {
1528  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1529 
1530  if( drawingShadows && !aNC->IsSelected() )
1531  return;
1532 
1533  m_gal->SetIsStroke( true );
1534  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1535  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1536  m_gal->SetIsFill( false );
1537 
1538  VECTOR2D p = aNC->GetPosition();
1539  int delta = aNC->GetSize() / 2;
1540 
1541  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1542  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1543 }
1544 
1545 
1546 void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
1547 {
1548  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1549 
1550  if( drawingShadows && !aEntry->IsSelected() )
1551  return;
1552 
1553  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1554 
1555  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1556  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1557 
1558  m_gal->SetIsStroke( true );
1559  m_gal->SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
1561  m_gal->SetIsFill( false );
1562 
1563  VECTOR2D pos = aEntry->GetPosition();
1564  VECTOR2D endPos = aEntry->m_End();
1565 
1566  m_gal->DrawLine( pos, endPos );
1567 
1568  // Draw dangling symbols:
1569  m_gal->SetLineWidth ( getLineWidth( aEntry, drawingShadows ) );
1570 
1571  if( aEntry->IsDanglingStart() )
1573 
1574  if( aEntry->IsDanglingEnd() )
1576 }
1577 
1578 
1579 void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer )
1580 {
1581  m_gal->Save();
1582  m_gal->Translate( aBitmap->GetPosition() );
1583 
1584  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1585  // factor is similar to a local zoom
1586  double img_scale = aBitmap->GetImageScale();
1587 
1588  if( img_scale != 1.0 )
1589  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1590 
1591  if( aLayer == LAYER_DRAW_BITMAPS )
1592  {
1593  m_gal->DrawBitmap( *aBitmap->GetImage() );
1594  }
1595 
1596  if( aLayer == LAYER_SELECTION_SHADOWS )
1597  {
1598  if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
1599  {
1600  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1601  m_gal->SetIsStroke( true );
1604  m_gal->SetIsFill( false );
1605 
1606  // Draws a bounding box.
1607  VECTOR2D bm_size( aBitmap->GetSize() );
1608  // bm_size is the actual image size in UI.
1609  // but m_gal scale was previously set to img_scale
1610  // so recalculate size relative to this image size.
1611  bm_size.x /= img_scale;
1612  bm_size.y /= img_scale;
1613  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1614  VECTOR2D end = origin + bm_size;
1615 
1616  m_gal->DrawRectangle( origin, end );
1617  }
1618  }
1619 
1620  m_gal->Restore();
1621 }
1622 
1623 
1624 void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
1625 {
1626  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1627 
1628  if( drawingShadows && !aMarker->IsSelected() )
1629  return;
1630 
1632  aLayer = LAYER_ERC_ERR;
1633  else
1634  aLayer = LAYER_ERC_WARN;
1635 
1636  COLOR4D color = getRenderColor( aMarker, aLayer, drawingShadows );
1637 
1638  m_gal->Save();
1639  m_gal->Translate( aMarker->GetPosition() );
1640  m_gal->SetIsFill( !drawingShadows );
1641  m_gal->SetFillColor( color );
1642  m_gal->SetIsStroke( drawingShadows );
1643  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1645 
1646  SHAPE_LINE_CHAIN polygon;
1647  aMarker->ShapeToPolygon( polygon );
1648 
1649  m_gal->DrawPolygon( polygon );
1650  m_gal->Restore();
1651 }
1652 
1653 
1654 }; // 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:185
#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:335
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
wxPoint GetStartPoint() const
Definition: sch_line.h:95
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:98
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:108
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:149
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:222
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:140
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int GetPenSize() const override
Function GetPenSize virtual pure.
Definition: sch_sheet.cpp:393
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:209
bool IsDangling() const override
Definition: sch_pin.h:86
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:278
int GetLabelSpinStyle() const
Definition: sch_text.h:124
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:340
int GetUnit() const
Definition: lib_item.h:301
#define VALUE
int GetUnit() const
int GetSheetNameSize() const
Definition: sch_sheet.h:275
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:313
bool ShowPinNumbers()
Class for transforming 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:126
wxString GetName() const
Definition: sch_sheet.h:272
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:100
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:181
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
const wxSize & GetTextSize() const
Definition: eda_text.h:223
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:844
#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:543
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:418
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:209
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:646
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:1079
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:180
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:399
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:62
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:232
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.
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:268
#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:283
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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
Class 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:98