KiCad PCB EDA Suite
sch_painter.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 CERN
5  * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 
28 #include <sch_item.h>
29 
30 #include <lib_item.h>
31 #include <lib_rectangle.h>
32 #include <lib_pin.h>
33 #include <lib_circle.h>
34 #include <lib_polyline.h>
35 #include <lib_arc.h>
36 #include <lib_field.h>
37 #include <lib_text.h>
38 #include <lib_bezier.h>
39 #include <sch_line.h>
40 #include <sch_component.h>
41 #include <sch_field.h>
42 #include <sch_junction.h>
43 #include <sch_text.h>
44 #include <sch_no_connect.h>
45 #include <sch_bus_entry.h>
46 #include <sch_bitmap.h>
47 #include <sch_sheet.h>
48 #include <gr_text.h>
50 #include <lib_edit_frame.h>
51 #include <plotter.h>
52 #include <template_fieldnames.h>
53 #include <class_libentry.h>
54 #include <class_library.h>
55 #include <sch_edit_frame.h>
56 #include <view/view.h>
58 #include <colors_design_settings.h>
59 #include <connection_graph.h>
61 #include <bezier_curves.h>
62 
63 #include "sch_painter.h"
64 
65 namespace KIGFX
66 {
67 
69  m_ShowUnit( 0 ),
70  m_ShowConvert( 0 )
71 {
72  ImportLegacyColors( nullptr );
73 
74  m_ShowHiddenText = true;
75  m_ShowHiddenPins = true;
77  m_ShowUmbilicals = true;
78  m_ShowDisabled = false;
79 }
80 
81 
83 {
84  for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
85  m_layerColors[ layer ] = ::GetLayerColor( static_cast<SCH_LAYER_ID>( layer ) );
86 
87  for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
88  m_layerColors[ layer ] = ::GetLayerColor( static_cast<SCH_LAYER_ID>( layer ) );
89 
91 }
92 
93 
94 const COLOR4D& SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
95 {
96  return m_layerColors[ aLayer ];
97 }
98 
99 
113 static LIB_PART* dummy()
114 {
115  static LIB_PART* part;
116 
117  if( !part )
118  {
119  part = new LIB_PART( wxEmptyString );
120 
121  LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
122 
123  square->MoveTo( wxPoint( -200, 200 ) );
124  square->SetEndPosition( wxPoint( 200, -200 ) );
125 
126  LIB_TEXT* text = new LIB_TEXT( part );
127 
128  text->SetTextSize( wxSize( 150, 150 ) );
129  text->SetText( wxString( wxT( "??" ) ) );
130 
131  part->AddDrawItem( square );
132  part->AddDrawItem( text );
133  }
134 
135  return part;
136 }
137 
138 
140  KIGFX::PAINTER( aGal )
141 { }
142 
143 
144 #define HANDLE_ITEM( type_id, type_name ) \
145  case type_id: draw( (type_name *) item, aLayer ); break
146 
147 
148 bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
149 {
150  auto item2 = static_cast<const EDA_ITEM*>( aItem );
151  auto item = const_cast<EDA_ITEM*>( item2 );
152 
154 
155 #ifdef CONNECTIVITY_DEBUG
156 
157  auto sch_item = dynamic_cast<SCH_ITEM*>( item );
158  auto conn = sch_item ? sch_item->Connection( *g_CurrentSheet ) : nullptr;
159 
160  if( conn )
161  {
162  auto pos = item->GetBoundingBox().Centre();
163  auto label = conn->Name( true );
164 
168  m_gal->SetLineWidth( 2 );
169  m_gal->SetGlyphSize( VECTOR2D( 20, 20 ) );
170  m_gal->StrokeText( conn->Name( true ), pos, 0.0 );
171  }
172 
173 #endif
174 
175  switch( item->Type() )
176  {
201 
202  default: return false;
203  }
204 
205  return false;
206 }
207 
208 
210 {
211  if( m_schSettings.m_ShowUnit // showing a specific unit
212  && aItem->GetUnit() // item is unit-specific
213  && aItem->GetUnit() != m_schSettings.m_ShowUnit )
214  {
215  return false;
216  }
217 
218  if( m_schSettings.m_ShowConvert // showing a specific conversion
219  && aItem->GetConvert() // item is conversion-specific
220  && aItem->GetConvert() != m_schSettings.m_ShowConvert )
221  {
222  return false;
223  }
224 
225  return true;
226 }
227 
228 
230 {
231  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
232 
233  // For best visuals the selection width must be a cross between the zoom level and the
234  // default line width.
235  return static_cast<float>( fabs( matrix.GetScale().x * 2.75 ) + GetSelectionThickness() );
236 }
237 
238 
239 COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows )
240 {
241  static COLOR4D highlightColor( 1.0, 0.3, 0.3, 1.0 );
242 
244 
245  if( aItem->Type() == SCH_LINE_T )
246  color = static_cast<const SCH_LINE*>( aItem )->GetLineColor();
247 
248  if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc.
249  {
251 
252  if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_SHEET_BACKGROUND )
253  color = color.WithAlpha( 0.2 );
254  }
255  else if( aItem->IsSelected() )
256  {
257  if( aDrawingShadows )
259  }
260  else if( aItem->IsHighlighted() ) // Cross-probing
261  {
262  color = highlightColor;
263  }
264 
266  color = color.Darken( 0.5f );
267 
268  return color;
269 }
270 
271 
272 float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows )
273 {
274  float width = (float) aItem->GetPenSize();
275 
276  if( aItem->IsSelected() && aDrawingShadows )
277  width += getShadowWidth();
278 
279  return width;
280 }
281 
282 
283 float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows )
284 {
285  float width = (float) aItem->GetPenSize();
286 
287  if( aItem->IsSelected() && aDrawingShadows )
288  width += getShadowWidth();
289 
290  return width;
291 }
292 
293 
294 float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows )
295 {
296  float width = (float) aItem->GetThickness();
297 
298  if( width == 0 )
299  width = (float) GetDefaultLineThickness();
300 
301  if( aItem->IsSelected() && aDrawingShadows )
302  width += getShadowWidth();
303 
304  return width;
305 }
306 
307 
308 void SCH_PAINTER::strokeText( const wxString& aText, const VECTOR2D& aPosition, double aAngle )
309 {
310  m_gal->StrokeText( aText, aPosition, aAngle, GetTextMarkupFlags() );
311 }
312 
313 
314 void SCH_PAINTER::draw( LIB_PART *aPart, int aLayer, bool aDrawFields, int aUnit, int aConvert )
315 {
316  if( !aUnit )
317  aUnit = m_schSettings.m_ShowUnit;
318 
319  if( !aConvert )
320  aConvert = m_schSettings.m_ShowConvert;
321 
322  std::unique_ptr< LIB_PART > tmpPart;
323  LIB_PART* drawnPart = aPart;
324 
325  if( aPart->IsAlias() )
326  {
327  tmpPart = aPart->Flatten();
328  drawnPart = tmpPart.get();
329  }
330 
331  for( auto& item : drawnPart->GetDrawItems() )
332  {
333  if( !aDrawFields && item.Type() == LIB_FIELD_T )
334  continue;
335 
336  if( aUnit && item.GetUnit() && aUnit != item.GetUnit() )
337  continue;
338 
339  if( aConvert && item.GetConvert() && aConvert != item.GetConvert() )
340  continue;
341 
342  Draw( &item, aLayer );
343  }
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  m_gal->SetFillColor( 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 
410 {
412  m_gal->SetIsFill( true );
413 }
414 
415 
416 void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer )
417 {
418  if( !isUnitAndConversionShown( aRect ) )
419  return;
420 
421  if( setDeviceColors( aRect, aLayer ) )
422  {
423  fillIfSelection( aLayer );
424  m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) );
425  }
426 }
427 
428 
429 void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer )
430 {
431  if( !isUnitAndConversionShown( aCircle ) )
432  return;
433 
434  if( setDeviceColors( aCircle, aLayer ) )
435  {
436  fillIfSelection( aLayer );
437  m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() );
438  }
439 }
440 
441 
442 void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
443 {
444  if( !isUnitAndConversionShown( aArc ) )
445  return;
446 
447  if( setDeviceColors( aArc, aLayer ) )
448  {
449  int sai = aArc->GetFirstRadiusAngle();
450  int eai = aArc->GetSecondRadiusAngle();
451 
462  if( !TRANSFORM().MapAngles( &sai, &eai ) )
463  {
464  LIB_ARC new_arc( *aArc );
465 
466  new_arc.SetStart( aArc->GetEnd() );
467  new_arc.SetEnd( aArc->GetStart() );
468  new_arc.CalcRadiusAngles();
469  sai = new_arc.GetFirstRadiusAngle();
470  eai = new_arc.GetSecondRadiusAngle();
471  TRANSFORM().MapAngles( &sai, &eai );
472  }
473 
474  double sa = (double) sai * M_PI / 1800.0;
475  double ea = (double) eai * M_PI / 1800.0 ;
476 
477  VECTOR2D pos = mapCoords( aArc->GetPosition() );
478 
479  m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea );
480  }
481 }
482 
483 
484 void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer )
485 {
486  if( !isUnitAndConversionShown( aLine ) )
487  return;
488 
489  if( setDeviceColors( aLine, aLayer ) )
490  {
491  const std::vector<wxPoint>& pts = aLine->GetPolyPoints();
492  std::deque<VECTOR2D> vtx;
493 
494  for( auto p : pts )
495  vtx.push_back( mapCoords( p ) );
496 
497  fillIfSelection( aLayer );
498  m_gal->DrawPolygon( vtx );
499  }
500 }
501 
502 
503 void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer )
504 {
505  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
506 
507  if( drawingShadows && !aField->IsSelected() )
508  return;
509 
510  if( !isUnitAndConversionShown( aField ) )
511  return;
512 
513  // Must check layer as fields are sometimes drawn by their parent rather than
514  // directly from the view.
515  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS];
516  int layers_count;
517  bool foundLayer = false;
518 
519  aField->ViewGetLayers( layers, layers_count );
520 
521  for( int i = 0; i < layers_count; ++i )
522  {
523  if( layers[i] == aLayer )
524  foundLayer = true;
525  }
526 
527  if( !foundLayer )
528  return;
529 
530  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
531 
532  if( !aField->IsVisible() )
533  {
534  if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
535  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
536  else
537  return;
538  }
539 
540  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
541  m_gal->SetIsFill( false );
542  m_gal->SetIsStroke( true );
544 
545  auto pos = mapCoords( aField->GetPosition() );
546 
547  if( drawingShadows && GetSelectionTextAsBox() )
548  {
549  EDA_RECT boundaryBox = aField->GetBoundingBox();
550 
551  m_gal->SetIsFill( true );
553  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
554  boundaryBox.RevertYAxis();
555 
557  mapCoords( boundaryBox.GetPosition() ), mapCoords( boundaryBox.GetEnd() ) );
558  }
559  else
560  {
561  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
562  m_gal->SetFontItalic( aField->IsItalic() );
563 
566 
567  double orient = aField->GetTextAngleRadians();
568 
569  strokeText( aField->GetText(), pos, orient );
570  }
571 
572  // Draw the umbilical line
573  if( aField->IsMoving() && m_schSettings.m_ShowUmbilicals )
574  {
576  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
577  m_gal->DrawLine( pos, wxPoint( 0, 0 ) );
578  }
579 }
580 
581 
582 void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer )
583 {
584  if( !isUnitAndConversionShown( aText ) )
585  return;
586 
587  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
588 
589  if( drawingShadows && !aText->IsSelected() )
590  return;
591 
592  COLOR4D color = getRenderColor( aText, LAYER_DEVICE, drawingShadows );
593 
594  if( !aText->IsVisible() )
595  {
597  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
598  else
599  return;
600  }
601 
602  EDA_RECT bBox = aText->GetBoundingBox();
603  bBox.RevertYAxis();
604  VECTOR2D pos = mapCoords( bBox.Centre() );
605  double orient = aText->GetTextAngleRadians();
606 
609  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
610  m_gal->SetIsFill( false );
611  m_gal->SetIsStroke( true );
613  m_gal->SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
614  m_gal->SetFontBold( aText->IsBold() );
615  m_gal->SetFontItalic( aText->IsItalic() );
616  strokeText( aText->GetText(), pos, orient );
617 }
618 
619 
620 static int InternalPinDecoSize( const LIB_PIN &aPin )
621 {
622  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
623 }
624 
625 
626 // Utility for getting the size of the 'external' pin decorators (as a radius)
627 // i.e. the negation circle, the polarity 'slopes' and the nonlogic marker
628 static int ExternalPinDecoSize( const LIB_PIN &aPin )
629 {
630  return aPin.GetNumberTextSize() / 2;
631 }
632 
633 
634 // Draw the target (an open circle) for a pin which has no connection or is being moved.
635 void SCH_PAINTER::drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows )
636 {
637  m_gal->SetIsFill( false );
638  m_gal->SetIsStroke( true );
639  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
640 
642 }
643 
644 
645 void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
646 {
647  if( !isUnitAndConversionShown( aPin ) )
648  return;
649 
650  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
651 
652  if( drawingShadows && !aPin->IsSelected() )
653  return;
654 
655  VECTOR2I pos = mapCoords( aPin->GetPosition() );
656  COLOR4D color = getRenderColor( aPin, LAYER_PIN, drawingShadows );
657 
658  if( !aPin->IsVisible() )
659  {
661  {
662  color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
663  }
664  else
665  {
666  if( aPin->HasFlag( IS_DANGLING ) && aPin->IsPowerConnection() )
667  drawPinDanglingSymbol( pos, drawingShadows );
668 
669  return;
670  }
671  }
672 
673  VECTOR2I p0;
674  VECTOR2I dir;
675  int len = aPin->GetLength();
676  int orient = aPin->GetOrientation();
677 
678  switch( orient )
679  {
680  case PIN_UP:
681  p0 = VECTOR2I( pos.x, pos.y - len );
682  dir = VECTOR2I( 0, 1 );
683  break;
684 
685  case PIN_DOWN:
686  p0 = VECTOR2I( pos.x, pos.y + len );
687  dir = VECTOR2I( 0, -1 );
688  break;
689 
690  case PIN_LEFT:
691  p0 = VECTOR2I( pos.x - len, pos.y );
692  dir = VECTOR2I( 1, 0 );
693  break;
694 
695  default:
696  case PIN_RIGHT:
697  p0 = VECTOR2I( pos.x + len, pos.y );
698  dir = VECTOR2I( -1, 0 );
699  break;
700  }
701 
702  VECTOR2D pc;
703 
704  m_gal->SetIsStroke( true );
705  m_gal->SetIsFill( false );
706  m_gal->SetLineWidth( getLineWidth( aPin, drawingShadows ) );
708  m_gal->SetFontBold( false );
709  m_gal->SetFontItalic( false );
710 
711  const int radius = ExternalPinDecoSize( *aPin );
712  const int diam = radius*2;
713  const int clock_size = InternalPinDecoSize( *aPin );
714 
715  if( aPin->GetType() == PIN_NC ) // Draw a N.C. symbol
716  {
717  m_gal->DrawLine( p0, pos );
718 
719  m_gal->DrawLine( pos + VECTOR2D( -1, -1 ) * TARGET_PIN_RADIUS,
720  pos + VECTOR2D( 1, 1 ) * TARGET_PIN_RADIUS );
721  m_gal->DrawLine( pos + VECTOR2D( 1, -1 ) * TARGET_PIN_RADIUS ,
722  pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
723 
724  aPin->ClearFlags( IS_DANGLING ); // PIN_NC pin type is always not connected and dangling.
725  }
726  else
727  {
728  switch( aPin->GetShape() )
729  {
730  case PINSHAPE_LINE:
731  m_gal->DrawLine( p0, pos );
732  break;
733 
734  case PINSHAPE_INVERTED:
735  m_gal->DrawCircle( p0 + dir * radius, radius );
736  m_gal->DrawLine( p0 + dir * ( diam ), pos );
737  break;
738 
740  pc = p0 - dir * clock_size ;
741 
742  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
743  pc,
744  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
745 
746  m_gal->DrawCircle( p0 + dir * radius, radius );
747  m_gal->DrawLine( p0 + dir * ( diam ), pos );
748  break;
749 
750  case PINSHAPE_CLOCK_LOW:
752  pc = p0 - dir * clock_size ;
753 
754  triLine( p0 + VECTOR2D( dir.y, -dir.x) * clock_size,
755  pc,
756  p0 + VECTOR2D( -dir.y, dir.x) * clock_size );
757 
758  if( !dir.y )
759  {
760  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
761  p0 + VECTOR2D(dir.x, -1) * diam,
762  p0 );
763  }
764  else /* MapX1 = 0 */
765  {
766  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
767  p0 + VECTOR2D(-1, dir.y) * diam,
768  p0 );
769  }
770 
771  m_gal->DrawLine( p0, pos );
772  break;
773 
774  case PINSHAPE_CLOCK:
775  m_gal->DrawLine( p0, pos );
776 
777  if( !dir.y )
778  {
779  triLine( p0 + VECTOR2D( 0, clock_size ),
780  p0 + VECTOR2D( -dir.x * clock_size, 0 ),
781  p0 + VECTOR2D( 0, -clock_size ) );
782  }
783  else
784  {
785  triLine( p0 + VECTOR2D( clock_size, 0 ),
786  p0 + VECTOR2D( 0, -dir.y * clock_size ),
787  p0 + VECTOR2D( -clock_size, 0 ) );
788  }
789  break;
790 
791  case PINSHAPE_INPUT_LOW:
792  m_gal->DrawLine( p0, pos );
793 
794  if( !dir.y )
795  {
796  triLine( p0 + VECTOR2D(dir.x, 0) * diam,
797  p0 + VECTOR2D(dir.x, -1) * diam,
798  p0 );
799  }
800  else /* MapX1 = 0 */
801  {
802  triLine( p0 + VECTOR2D( 0, dir.y) * diam,
803  p0 + VECTOR2D(-1, dir.y) * diam,
804  p0 );
805  }
806  break;
807 
808  case PINSHAPE_OUTPUT_LOW: // IEEE symbol "Active Low Output"
809  m_gal->DrawLine( p0, pos );
810 
811  if( !dir.y ) // Horizontal pin
812  m_gal->DrawLine( p0 - VECTOR2D( 0, diam ), p0 + VECTOR2D( dir.x, 0 ) * diam );
813  else // Vertical pin
814  m_gal->DrawLine( p0 - VECTOR2D( diam, 0 ), p0 + VECTOR2D( 0, dir.y ) * diam );
815  break;
816 
817  case PINSHAPE_NONLOGIC: // NonLogic pin symbol
818  m_gal->DrawLine( p0, pos );
819 
820  m_gal->DrawLine( p0 - VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius,
821  p0 + VECTOR2D( dir.x + dir.y, dir.y - dir.x ) * radius );
822  m_gal->DrawLine( p0 - VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius,
823  p0 + VECTOR2D( dir.x - dir.y, dir.x + dir.y ) * radius );
824  break;
825  }
826  }
827 
828 
829  if( aPin->HasFlag( IS_DANGLING ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
830  drawPinDanglingSymbol( pos, drawingShadows );
831 
832  LIB_PART* libEntry = aPin->GetParent();
833 
834  // Draw the labels
835  if( drawingShadows && ( libEntry->Type() == LIB_PART_T || libEntry->IsSelected() )
837  return;
838 
839  int textOffset = libEntry->GetPinNameOffset();
840 
841  float nameLineWidth = getLineWidth( aPin, drawingShadows );
842  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, aPin->GetNameTextSize(), false );
843  float numLineWidth = getLineWidth( aPin, drawingShadows );
844  numLineWidth = Clamp_Text_PenSize( numLineWidth, aPin->GetNumberTextSize(), false );
845 
846  #define PIN_TEXT_MARGIN 4.0
847 
848  // Four locations around a pin where text can be drawn
849  enum { INSIDE = 0, OUTSIDE, ABOVE, BELOW };
850  int size[4] = { 0, 0, 0, 0 };
851  float thickness[4] = { numLineWidth, numLineWidth, numLineWidth, numLineWidth };
852  COLOR4D colour[4];
853  wxString text[4];
854 
855  // TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
856  if( textOffset )
857  {
858  size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
859  thickness[INSIDE] = nameLineWidth;
860  colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
861  text [INSIDE] = aPin->GetName();
862 
863  size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
864  thickness[ABOVE] = numLineWidth;
865  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
866  text [ABOVE] = aPin->GetNumber();
867  }
868  // Otherwise pin NAMES go above and pin NUMBERS go below
869  else
870  {
871  size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
872  thickness[ABOVE] = nameLineWidth;
873  colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
874  text [ABOVE] = aPin->GetName();
875 
876  size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
877  thickness[BELOW] = numLineWidth;
878  colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
879  text [BELOW] = aPin->GetNumber();
880  }
881 
883  {
884  size [OUTSIDE] = std::max( aPin->GetNameTextSize() * 3 / 4, Millimeter2iu( 0.7 ) );
885  thickness[OUTSIDE] = float( size[OUTSIDE] ) / 6.0F;
886  colour [OUTSIDE] = getRenderColor( aPin, LAYER_NOTES, drawingShadows );
887  text [OUTSIDE] = aPin->GetElectricalTypeName();
888  }
889 
890  if( !aPin->IsVisible() )
891  {
892  for( COLOR4D& c : colour )
893  c = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows );
894  }
895 
896  int insideOffset = textOffset;
897  int outsideOffset = 10;
898  float lineThickness = (float) GetDefaultLineThickness();
899  float aboveOffset = PIN_TEXT_MARGIN + ( thickness[ABOVE] + lineThickness ) / 2.0;
900  float belowOffset = PIN_TEXT_MARGIN + ( thickness[BELOW] + lineThickness ) / 2.0;
901 
902  if( drawingShadows )
903  {
904  for( float& t : thickness )
905  t += getShadowWidth();
906 
907  insideOffset -= KiROUND( getShadowWidth() / 2 );
908  outsideOffset -= KiROUND( getShadowWidth() / 2 );
909  }
910 
911  #define SET_DC( i ) \
912  m_gal->SetGlyphSize( VECTOR2D( size[i], size[i] ) ); \
913  m_gal->SetLineWidth( thickness[i] ); \
914  m_gal->SetStrokeColor( colour[i] )
915 
916  switch( orient )
917  {
918  case PIN_LEFT:
919  if( size[INSIDE] )
920  {
921  SET_DC( INSIDE );
924  strokeText( text[INSIDE], pos + VECTOR2D( -insideOffset - len, 0 ), 0 );
925  }
926  if( size[OUTSIDE] )
927  {
928  SET_DC( OUTSIDE );
931  strokeText( text[OUTSIDE], pos + VECTOR2D( outsideOffset, 0 ), 0 );
932  }
933  if( size[ABOVE] )
934  {
935  SET_DC( ABOVE );
938  strokeText( text[ABOVE], pos + VECTOR2D( -len / 2.0, -aboveOffset ), 0 );
939  }
940  if( size[BELOW] )
941  {
942  SET_DC( BELOW );
945  strokeText( text[BELOW], pos + VECTOR2D( -len / 2.0, belowOffset ), 0 );
946  }
947  break;
948 
949  case PIN_RIGHT:
950  if( size[INSIDE] )
951  {
952  SET_DC( INSIDE );
956  strokeText( text[INSIDE], pos + VECTOR2D( insideOffset + len, 0 ), 0 );
957  }
958  if( size[OUTSIDE] )
959  {
960  SET_DC( OUTSIDE );
963  strokeText( text[OUTSIDE], pos + VECTOR2D( -outsideOffset, 0 ), 0 );
964  }
965  if( size[ABOVE] )
966  {
967  SET_DC( ABOVE );
970  strokeText( text[ABOVE], pos + VECTOR2D( len / 2.0, -aboveOffset ), 0 );
971  }
972  if( size[BELOW] )
973  {
974  SET_DC( BELOW );
977  strokeText( text[BELOW], pos + VECTOR2D( len / 2.0, belowOffset ), 0 );
978  }
979  break;
980 
981  case PIN_DOWN:
982  if( size[INSIDE] )
983  {
984  SET_DC( INSIDE );
987  strokeText( text[INSIDE], pos + VECTOR2D( 0, insideOffset + len ), M_PI / 2 );
988  }
989  if( size[OUTSIDE] )
990  {
991  SET_DC( OUTSIDE );
994  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, -outsideOffset ), M_PI / 2 );
995  }
996  if( size[ABOVE] )
997  {
998  SET_DC( ABOVE );
1001  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, len / 2.0 ), M_PI / 2 );
1002  }
1003  if( size[BELOW] )
1004  {
1005  SET_DC( BELOW );
1008  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, len / 2.0 ), M_PI / 2 );
1009  }
1010  break;
1011 
1012  case PIN_UP:
1013  if( size[INSIDE] )
1014  {
1015  SET_DC( INSIDE );
1018  strokeText( text[INSIDE], pos + VECTOR2D( 0, -insideOffset - len ), M_PI / 2 );
1019  }
1020  if( size[OUTSIDE] )
1021  {
1022  SET_DC( OUTSIDE );
1025  strokeText( text[OUTSIDE], pos + VECTOR2D( 0, outsideOffset ), M_PI / 2 );
1026  }
1027  if( size[ABOVE] )
1028  {
1029  SET_DC( ABOVE );
1032  strokeText( text[ABOVE], pos + VECTOR2D( -aboveOffset, -len / 2.0 ), M_PI / 2 );
1033  }
1034  if( size[BELOW] )
1035  {
1036  SET_DC( BELOW );
1039  strokeText( text[BELOW], pos + VECTOR2D( belowOffset, -len / 2.0 ), M_PI / 2 );
1040  }
1041  break;
1042 
1043  default:
1044  wxFAIL_MSG( "Unknown pin orientation" );
1045  }
1046 }
1047 
1048 
1049 void SCH_PAINTER::draw( LIB_BEZIER *aCurve, int aLayer )
1050 {
1051  if( !isUnitAndConversionShown( aCurve ) )
1052  return;
1053 
1054  if( setDeviceColors( aCurve, aLayer ) )
1055  {
1056  BEZIER_POLY poly ( aCurve->GetPoints() );
1057  std::vector<wxPoint> pts;
1058  std::deque<VECTOR2D> pts_xformed;
1059  poly.GetPoly( pts );
1060 
1061  for( const auto &p : pts )
1062  pts_xformed.push_back( mapCoords( p ) );
1063 
1064  m_gal->DrawPolygon( pts_xformed );
1065  }
1066 }
1067 
1068 
1069 // Draw the target (an open square) for a wire or label which has no connection or is
1070 // being moved.
1071 void SCH_PAINTER::drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows )
1072 {
1073  wxPoint radius( DANGLING_SYMBOL_SIZE, DANGLING_SYMBOL_SIZE );
1074 
1075  m_gal->SetIsStroke( true );
1076  m_gal->SetIsFill( false );
1077  m_gal->SetLineWidth( aDrawingShadows ? getShadowWidth() : 1.0F );
1078 
1079  m_gal->DrawRectangle( aPos - radius, aPos + radius );
1080 }
1081 
1082 
1083 void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer )
1084 {
1085  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1086 
1087  if( drawingShadows && !aJct->IsSelected() )
1088  return;
1089 
1090  COLOR4D color;
1091  auto conn = aJct->Connection( *g_CurrentSheet );
1092 
1093  if( conn && conn->IsBus() )
1094  color = getRenderColor( aJct, LAYER_BUS, drawingShadows );
1095  else
1096  color = getRenderColor( aJct, LAYER_JUNCTION, drawingShadows );
1097 
1098  m_gal->SetIsStroke( drawingShadows );
1099  m_gal->SetLineWidth( getLineWidth( aJct, drawingShadows ) );
1101  m_gal->SetIsFill( !drawingShadows );
1102  m_gal->SetFillColor( color );
1104 }
1105 
1106 
1107 void SCH_PAINTER::draw( SCH_LINE *aLine, int aLayer )
1108 {
1109  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1110 
1111  if( drawingShadows && !aLine->IsSelected() )
1112  return;
1113 
1114  COLOR4D color = getRenderColor( aLine, aLine->GetLayer(), drawingShadows );
1115  float width = getLineWidth( aLine, drawingShadows );
1116 
1117  m_gal->SetIsStroke( true );
1119  m_gal->SetLineWidth( width );
1120 
1121  if( aLine->GetLineStyle() <= PLOTDASHTYPE_SOLID || drawingShadows )
1122  {
1123  m_gal->DrawLine( aLine->GetStartPoint(), aLine->GetEndPoint() );
1124  }
1125  else
1126  {
1127  VECTOR2D start = aLine->GetStartPoint();
1128  VECTOR2D end = aLine->GetEndPoint();
1129 
1130  EDA_RECT clip( (wxPoint)start, wxSize( end.x - start.x, end.y - start.y ) );
1131  clip.Normalize();
1132 
1133  double theta = atan2( end.y - start.y, end.x - start.x );
1134  double strokes[] = { 1.0, DASH_GAP_LEN( width ), 1.0, DASH_GAP_LEN( width ) };
1135 
1136  switch( aLine->GetLineStyle() )
1137  {
1138  default:
1139  case PLOTDASHTYPE_DASH:
1140  strokes[0] = strokes[2] = DASH_MARK_LEN( width );
1141  break;
1142  case PLOTDASHTYPE_DOT:
1143  strokes[0] = strokes[2] = DOT_MARK_LEN( width );
1144  break;
1145  case PLOTDASHTYPE_DASHDOT:
1146  strokes[0] = DASH_MARK_LEN( width );
1147  strokes[2] = DOT_MARK_LEN( width );
1148  break;
1149  }
1150 
1151  for( size_t i = 0; i < 10000; ++i )
1152  {
1153  // Calculations MUST be done in doubles to keep from accumulating rounding
1154  // errors as we go.
1155  VECTOR2D next( start.x + strokes[ i % 4 ] * cos( theta ),
1156  start.y + strokes[ i % 4 ] * sin( theta ) );
1157 
1158  // Drawing each segment can be done rounded to ints.
1159  wxPoint segStart( KiROUND( start.x ), KiROUND( start.y ) );
1160  wxPoint segEnd( KiROUND( next.x ), KiROUND( next.y ) );
1161 
1162  if( ClipLine( &clip, segStart.x, segStart.y, segEnd.x, segEnd.y ) )
1163  break;
1164  else if( i % 2 == 0 )
1165  m_gal->DrawLine( segStart, segEnd );
1166 
1167  start = next;
1168  }
1169  }
1170 
1171  if( aLine->IsStartDangling() )
1172  drawDanglingSymbol( aLine->GetStartPoint(), drawingShadows );
1173 
1174  if( aLine->IsEndDangling() )
1175  drawDanglingSymbol( aLine->GetEndPoint(), drawingShadows );
1176 }
1177 
1178 
1179 void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
1180 {
1181  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1182 
1183  if( drawingShadows && !aText->IsSelected() )
1184  return;
1185 
1186  switch( aText->Type() )
1187  {
1188  case SCH_SHEET_PIN_T: aLayer = LAYER_SHEETLABEL; break;
1189  case SCH_HIER_LABEL_T: aLayer = LAYER_HIERLABEL; break;
1190  case SCH_GLOBAL_LABEL_T: aLayer = LAYER_GLOBLABEL; break;
1191  case SCH_LABEL_T: aLayer = LAYER_LOCLABEL; break;
1192  default: aLayer = LAYER_NOTES; break;
1193  }
1194 
1195  COLOR4D color = getRenderColor( aText, aLayer, drawingShadows );
1196  SCH_CONNECTION* conn = aText->Connection( *g_CurrentSheet );
1197 
1198  if( conn && conn->IsBus() )
1199  color = getRenderColor( aText, LAYER_BUS, drawingShadows );
1200 
1201  if( !aText->IsVisible() )
1202  {
1203  if( m_schSettings.m_ShowHiddenText || aText->IsBrightened() )
1204  color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows );
1205  else
1206  return;
1207  }
1208 
1209  m_gal->SetIsFill( false );
1210  m_gal->SetIsStroke( true );
1211  m_gal->SetLineWidth( getLineWidth( aText, drawingShadows ) );
1213  m_gal->SetTextAttributes( aText );
1214 
1215  VECTOR2D text_offset = aText->GetTextPos() + aText->GetSchematicTextOffset();
1216  wxString shownText( aText->GetShownText() );
1217 
1218  if( drawingShadows )
1219  {
1220  if( GetSelectionTextAsBox() )
1221  {
1222  EDA_RECT bBox = aText->GetBoundingBox();
1223 
1224  m_gal->SetIsFill( true );
1225  m_gal->SetFillColor( color );
1226  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1227  bBox.RevertYAxis();
1228 
1229  m_gal->DrawRectangle( mapCoords( bBox.GetPosition() ), mapCoords( bBox.GetEnd() ) );
1230  return;
1231  }
1232 
1233  switch( aText->GetLabelSpinStyle() )
1234  {
1235  case 0:
1236  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1237  text_offset.x -= getShadowWidth() / 2;
1238  else
1239  text_offset.x += getShadowWidth() / 2;
1240  break;
1241  case 1:
1242  text_offset.y += getShadowWidth() / 2;
1243  break;
1244  case 2:
1245  if( aText->Type() == SCH_LABEL_T || aText->Type() == SCH_TEXT_T )
1246  text_offset.x += getShadowWidth() / 2;
1247  else
1248  text_offset.x -= getShadowWidth() / 2;
1249  break;
1250  case 3:
1251  text_offset.y -= getShadowWidth() / 2;
1252  break;
1253  }
1254  }
1255 
1256  if( !shownText.IsEmpty() )
1257  strokeText( shownText, text_offset, aText->GetTextAngleRadians() );
1258 
1259  if( aText->IsDangling() )
1260  drawDanglingSymbol( aText->GetTextPos(), drawingShadows );
1261 }
1262 
1263 
1264 static void orientPart( LIB_PART* part, int orientation )
1265 {
1266  struct ORIENT
1267  {
1268  int flag;
1269  int n_rots;
1270  int mirror_x;
1271  int mirror_y;
1272  }
1273  orientations[] =
1274  {
1275  { CMP_ORIENT_0, 0, 0, 0 },
1276  { CMP_ORIENT_90, 1, 0, 0 },
1277  { CMP_ORIENT_180, 2, 0, 0 },
1278  { CMP_ORIENT_270, 3, 0, 0 },
1279  { CMP_MIRROR_X + CMP_ORIENT_0, 0, 1, 0 },
1280  { CMP_MIRROR_X + CMP_ORIENT_90, 1, 1, 0 },
1281  { CMP_MIRROR_Y, 0, 0, 1 },
1282  { CMP_MIRROR_X + CMP_ORIENT_270, 3, 1, 0 },
1283  { CMP_MIRROR_Y + CMP_ORIENT_0, 0, 0, 1 },
1284  { CMP_MIRROR_Y + CMP_ORIENT_90, 1, 0, 1 },
1285  { CMP_MIRROR_Y + CMP_ORIENT_180, 2, 0, 1 },
1286  { CMP_MIRROR_Y + CMP_ORIENT_270, 3, 0, 1 }
1287  };
1288 
1289  ORIENT o = orientations[ 0 ];
1290 
1291  for( auto& i : orientations )
1292  {
1293  if( i.flag == orientation )
1294  {
1295  o = i;
1296  break;
1297  }
1298  }
1299 
1300  for( auto& item : part->GetDrawItems() )
1301  {
1302  for( int i = 0; i < o.n_rots; i++ )
1303  item.Rotate( wxPoint(0, 0 ), true );
1304 
1305  if( o.mirror_x )
1306  item.MirrorVertical( wxPoint( 0, 0 ) );
1307 
1308  if( o.mirror_y )
1309  item.MirrorHorizontal( wxPoint( 0, 0 ) );
1310  }
1311 }
1312 
1313 
1314 void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
1315 {
1316  // Use dummy part if the actual couldn't be found (or couldn't be locked).
1317  LIB_PART* originalPart = aComp->GetPartRef() ? aComp->GetPartRef().get() : dummy();
1318 
1319  // Copy the source so we can re-orient and translate it.
1320  LIB_PART tempPart( *originalPart );
1321 
1322  tempPart.SetFlags( aComp->GetFlags() );
1323 
1324  orientPart( &tempPart, aComp->GetOrientation() );
1325 
1326  for( auto& tempItem : tempPart.GetDrawItems() )
1327  {
1328  tempItem.SetFlags( aComp->GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1329  tempItem.MoveTo( tempItem.GetPosition() + (wxPoint) mapCoords( aComp->GetPosition() ) );
1330  }
1331 
1332  // Copy the pin info from the component to the temp pins
1333  LIB_PINS tempPins;
1334  tempPart.GetPins( tempPins, aComp->GetUnit(), aComp->GetConvert() );
1335  const SCH_PINS& compPins = aComp->GetPins();
1336 
1337  for( unsigned i = 0; i < tempPins.size() && i < compPins.size(); ++ i )
1338  {
1339  LIB_PIN* tempPin = tempPins[ i ];
1340  const SCH_PIN& compPin = compPins[ i ];
1341 
1342  tempPin->ClearFlags();
1343  tempPin->SetFlags( compPin.GetFlags() ); // SELECTED, HIGHLIGHTED, BRIGHTENED
1344 
1345  if( compPin.IsDangling() )
1346  tempPin->SetFlags( IS_DANGLING );
1347  }
1348 
1349  draw( &tempPart, aLayer, false, aComp->GetUnit(), aComp->GetConvert() );
1350 
1351  // The fields are SCH_COMPONENT-specific so don't need to be copied/oriented/translated
1352  std::vector<SCH_FIELD*> fields;
1353  aComp->GetFields( fields, false );
1354 
1355  for( SCH_FIELD* field : fields )
1356  draw( field, aLayer );
1357 }
1358 
1359 
1360 void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer )
1361 {
1362  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1363 
1364  if( drawingShadows && !aField->IsSelected() )
1365  return;
1366 
1367  switch( aField->GetId() )
1368  {
1369  case REFERENCE: aLayer = LAYER_REFERENCEPART; break;
1370  case VALUE: aLayer = LAYER_VALUEPART; break;
1371  default: aLayer = LAYER_FIELDS; break;
1372  }
1373 
1374  COLOR4D color = getRenderColor( aField, aLayer, drawingShadows );
1375 
1376  if( !aField->IsVisible() )
1377  {
1378  if( m_schSettings.m_ShowHiddenText || aField->IsBrightened() )
1379  color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows );
1380  else
1381  return;
1382  }
1383 
1384  if( aField->IsVoid() )
1385  return;
1386 
1387  SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) aField->GetParent();
1388 
1389  if( drawingShadows && parentComponent->IsSelected() && !GetSelectionDrawChildItems() )
1390  return;
1391 
1392  // Calculate the text orientation according to the component orientation.
1393  int orient = (int) aField->GetTextAngle();
1394 
1395  if( parentComponent->GetTransform().y1 ) // Rotate component 90 degrees.
1396  {
1397  if( orient == TEXT_ANGLE_HORIZ )
1398  orient = TEXT_ANGLE_VERT;
1399  else
1400  orient = TEXT_ANGLE_HORIZ;
1401  }
1402 
1403  /* Calculate the text justification, according to the component orientation/mirror.
1404  * Tthis is a bit complicated due to cumulative calculations:
1405  * - numerous cases (mirrored or not, rotation)
1406  * - the DrawGraphicText function recalculate also H and H justifications according to the
1407  * text orientation.
1408  * - When a component is mirrored, the text is not mirrored and justifications are
1409  * complicated to calculate
1410  * so the easier way is to use no justifications (centered text) and use GetBoundingBox
1411  * to know the text coordinate considered as centered
1412  */
1413  EDA_RECT boundaryBox = aField->GetBoundingBox();
1414  wxPoint textpos = boundaryBox.Centre();
1415 
1417  m_gal->SetIsStroke( true );
1418  m_gal->SetLineWidth( getLineWidth( aField, drawingShadows ) );
1419 
1420  if( drawingShadows && GetSelectionTextAsBox() )
1421  {
1422  m_gal->SetIsFill( true );
1423  m_gal->SetFillColor( color );
1424  m_gal->SetLineWidth( m_gal->GetLineWidth() * 0.5 );
1425  boundaryBox.RevertYAxis();
1426 
1428  mapCoords( boundaryBox.GetPosition() ), mapCoords( boundaryBox.GetEnd() ) );
1429  }
1430  else
1431  {
1434  m_gal->SetIsFill( false );
1435  m_gal->SetGlyphSize( VECTOR2D( aField->GetTextSize() ) );
1436  m_gal->SetFontBold( aField->IsBold() );
1437  m_gal->SetFontItalic( aField->IsItalic() );
1438  m_gal->SetTextMirrored( aField->IsMirrored() );
1439 
1440  strokeText( aField->GetFullyQualifiedText(), textpos,
1441  orient == TEXT_ANGLE_VERT ? M_PI / 2 : 0 );
1442  }
1443 
1444  // Draw the umbilical line
1445  if( aField->IsMoving() )
1446  {
1448  m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );
1449  m_gal->DrawLine( textpos, parentComponent->GetPosition() );
1450  }
1451 }
1452 
1453 
1454 void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer )
1455 {
1456  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1457 
1458  if( drawingShadows && !aLabel->IsSelected() )
1459  return;
1460 
1461  COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
1462 
1463  std::vector<wxPoint> pts;
1464  std::deque<VECTOR2D> pts2;
1465 
1466  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1467 
1468  for( auto p : pts )
1469  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1470 
1471  m_gal->SetIsFill( true );
1473  m_gal->SetIsStroke( true );
1474  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1476  m_gal->DrawPolyline( pts2 );
1477 
1478  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1479 }
1480 
1481 
1482 void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
1483 {
1484  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1485 
1486  if( drawingShadows && !aLabel->IsSelected() )
1487  return;
1488 
1489  COLOR4D color = getRenderColor( aLabel, LAYER_SHEETLABEL, drawingShadows );
1490 
1491  SCH_CONNECTION* conn = aLabel->Connection( *g_CurrentSheet );
1492 
1493  if( conn && conn->IsBus() )
1494  color = getRenderColor( aLabel, LAYER_BUS, drawingShadows );
1495 
1496  std::vector<wxPoint> pts;
1497  std::deque<VECTOR2D> pts2;
1498 
1499  aLabel->CreateGraphicShape( pts, aLabel->GetTextPos() );
1500 
1501  for( auto p : pts )
1502  pts2.emplace_back( VECTOR2D( p.x, p.y ) );
1503 
1504  m_gal->SetIsFill( true );
1506  m_gal->SetIsStroke( true );
1507  m_gal->SetLineWidth( getTextThickness( aLabel, drawingShadows ) );
1509  m_gal->DrawPolyline( pts2 );
1510 
1511  draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
1512 }
1513 
1514 void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
1515 {
1516  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1517 
1518  if( aLayer == LAYER_HIERLABEL || drawingShadows )
1519  {
1520  for( auto& sheetPin : aSheet->GetPins() )
1521  {
1522  if( drawingShadows && !aSheet->IsSelected() && !sheetPin.IsSelected() )
1523  continue;
1524 
1525  if( drawingShadows && !GetSelectionDrawChildItems() && aSheet->IsSelected() )
1526  break;
1527 
1528  int width = aSheet->GetPenSize();
1529  wxPoint initial_pos = sheetPin.GetTextPos();
1530  wxPoint offset_pos = initial_pos;
1531 
1532  // For aesthetic reasons, the SHEET_PIN is drawn with a small offset of width / 2
1533  switch( sheetPin.GetEdge() )
1534  {
1535  case SHEET_TOP_SIDE: offset_pos.y += KiROUND( width / 2.0 ); break;
1536  case SHEET_BOTTOM_SIDE: offset_pos.y -= KiROUND( width / 2.0 ); break;
1537  case SHEET_RIGHT_SIDE: offset_pos.x -= KiROUND( width / 2.0 ); break;
1538  case SHEET_LEFT_SIDE: offset_pos.x += KiROUND( width / 2.0 ); break;
1539  default: break;
1540  }
1541 
1542  sheetPin.SetTextPos( offset_pos );
1543  draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
1544  m_gal->DrawLine( offset_pos, initial_pos );
1545  sheetPin.SetTextPos( initial_pos );
1546  }
1547  }
1548 
1549  if( drawingShadows && !aSheet->IsSelected() )
1550  return;
1551 
1552  VECTOR2D pos = aSheet->GetPosition();
1553  VECTOR2D size = aSheet->GetSize();
1554 
1555  if( aLayer == LAYER_SHEET_BACKGROUND )
1556  {
1557  m_gal->SetIsStroke( aSheet->IsSelected() );
1560 
1561  if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
1562  {
1563  // Select a fill color working well with black and white background color,
1564  // both in Opengl and Cairo
1565  m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) );
1566  m_gal->SetIsFill( true );
1567  }
1568  else
1569  {
1570  // Could be modified later, when sheets can have their own fill color
1572  m_gal->SetIsFill( aSheet->IsSelected() && GetSelectionFillShapes() );
1573  }
1574 
1575  m_gal->DrawRectangle( pos, pos + size );
1576  }
1577 
1578  if( aLayer == LAYER_SHEET || drawingShadows )
1579  {
1580  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET, drawingShadows ) );
1581  m_gal->SetIsStroke( true );
1582  m_gal->SetLineWidth( getLineWidth( aSheet, drawingShadows ) );
1583  m_gal->SetIsFill( false );
1584 
1585  m_gal->DrawRectangle( pos, pos + size );
1586 
1587  VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
1588  VECTOR2D pos_filename = aSheet->GetFileNamePosition();
1589  double nameAngle = 0.0;
1590 
1591  if( aSheet->IsVerticalOrientation() )
1592  nameAngle = M_PI/2;
1593 
1594  if( drawingShadows )
1595  {
1597  return;
1598 
1599  if( aSheet->IsVerticalOrientation() )
1600  {
1601  pos_sheetname.y += getShadowWidth() / 2;
1602  pos_filename.y += getShadowWidth() / 2;
1603  }
1604  else
1605  {
1606  pos_sheetname.x -= getShadowWidth() / 2;
1607  pos_filename.x -= getShadowWidth() / 2;
1608  }
1609  }
1610 
1611  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETNAME, drawingShadows ) );
1612 
1613  auto text = wxT( "Sheet: " ) + aSheet->GetName();
1614 
1617 
1618  auto txtSize = aSheet->GetSheetNameSize();
1619 
1620  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1621  m_gal->SetFontBold( false );
1622  m_gal->SetFontItalic( false );
1623 
1624  strokeText( text, pos_sheetname, nameAngle );
1625 
1626  txtSize = aSheet->GetFileNameSize();
1627  m_gal->SetGlyphSize( VECTOR2D( txtSize, txtSize ) );
1628  m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEETFILENAME, drawingShadows ) );
1630 
1631  text = wxT( "File: " ) + aSheet->GetFileName();
1632  strokeText( text, pos_filename, nameAngle );
1633  }
1634 }
1635 
1636 
1637 void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer )
1638 {
1639  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1640 
1641  if( drawingShadows && !aNC->IsSelected() )
1642  return;
1643 
1644  m_gal->SetIsStroke( true );
1645  m_gal->SetLineWidth( getLineWidth( aNC, drawingShadows ) );
1646  m_gal->SetStrokeColor( getRenderColor( aNC, LAYER_NOCONNECT, drawingShadows ) );
1647  m_gal->SetIsFill( false );
1648 
1649  VECTOR2D p = aNC->GetPosition();
1650  int delta = aNC->GetSize() / 2;
1651 
1652  m_gal->DrawLine( p + VECTOR2D( -delta, -delta ), p + VECTOR2D( delta, delta ) );
1653  m_gal->DrawLine( p + VECTOR2D( -delta, delta ), p + VECTOR2D( delta, -delta ) );
1654 }
1655 
1656 
1657 void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
1658 {
1659  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1660 
1661  if( drawingShadows && !aEntry->IsSelected() )
1662  return;
1663 
1664  COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows );
1665 
1666  if( aEntry->Type() == SCH_BUS_BUS_ENTRY_T )
1667  color = getRenderColor( aEntry, LAYER_BUS, drawingShadows );
1668 
1669  m_gal->SetIsStroke( true );
1670  m_gal->SetLineWidth( getLineWidth( aEntry, drawingShadows ) );
1672  m_gal->SetIsFill( false );
1673 
1674  VECTOR2D pos = aEntry->GetPosition();
1675  VECTOR2D endPos = aEntry->m_End();
1676 
1677  m_gal->DrawLine( pos, endPos );
1678 
1679  // Draw dangling symbols:
1680  m_gal->SetLineWidth ( getLineWidth( aEntry, drawingShadows ) );
1681 
1682  if( aEntry->IsDanglingStart() )
1684 
1685  if( aEntry->IsDanglingEnd() )
1687 }
1688 
1689 
1690 void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer )
1691 {
1692  m_gal->Save();
1693  m_gal->Translate( aBitmap->GetPosition() );
1694 
1695  // When the image scale factor is not 1.0, we need to modify the actual as the image scale
1696  // factor is similar to a local zoom
1697  double img_scale = aBitmap->GetImageScale();
1698 
1699  if( img_scale != 1.0 )
1700  m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
1701 
1702  if( aLayer == LAYER_DRAW_BITMAPS )
1703  {
1704  m_gal->DrawBitmap( *aBitmap->GetImage() );
1705  }
1706 
1707  if( aLayer == LAYER_SELECTION_SHADOWS )
1708  {
1709  if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
1710  {
1711  COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
1712  m_gal->SetIsStroke( true );
1715  m_gal->SetIsFill( false );
1716 
1717  // Draws a bounding box.
1718  VECTOR2D bm_size( aBitmap->GetSize() );
1719  // bm_size is the actual image size in UI.
1720  // but m_gal scale was previously set to img_scale
1721  // so recalculate size relative to this image size.
1722  bm_size.x /= img_scale;
1723  bm_size.y /= img_scale;
1724  VECTOR2D origin( -bm_size.x / 2.0, -bm_size.y / 2.0 );
1725  VECTOR2D end = origin + bm_size;
1726 
1727  m_gal->DrawRectangle( origin, end );
1728  }
1729  }
1730 
1731  m_gal->Restore();
1732 }
1733 
1734 
1735 void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
1736 {
1737  bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS;
1738 
1739  if( drawingShadows && !aMarker->IsSelected() )
1740  return;
1741 
1743  aLayer = LAYER_ERC_ERR;
1744  else
1745  aLayer = LAYER_ERC_WARN;
1746 
1747  COLOR4D color = getRenderColor( aMarker, aLayer, drawingShadows );
1748 
1749  m_gal->Save();
1750  m_gal->Translate( aMarker->GetPosition() );
1751  m_gal->SetIsFill( !drawingShadows );
1752  m_gal->SetFillColor( color );
1753  m_gal->SetIsStroke( drawingShadows );
1754  m_gal->SetLineWidth( getLineWidth( aMarker, drawingShadows ) );
1756 
1757  SHAPE_LINE_CHAIN polygon;
1758  aMarker->ShapeToPolygon( polygon );
1759 
1760  m_gal->DrawPolygon( polygon );
1761  m_gal->Restore();
1762 }
1763 
1764 
1765 }; // 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
bool GetSelectionTextAsBox()
Draw selected text items as box.
float GetLineWidth() const
Get the line width.
#define TARGET_BUSENTRY_RADIUS
Definition: sch_bus_entry.h:35
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
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
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:58
wxPoint GetStartPoint() const
Definition: sch_line.h:99
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:94
#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
int GetTextMarkupFlags()
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
Definition: lib_pin.h:55
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_field.cpp:315
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape.
Add new GAL layers here.
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
void fillIfSelection(int aLayer)
bool IsDanglingEnd() const
Definition: sch_bus_entry.h:52
bool IsDragging() const
Definition: base_struct.h:231
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
const wxPoint GetEnd() const
Definition: eda_rect.h:116
void SetFontBold(const bool aBold)
Set bold property of current font.
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: lib_field.cpp:340
int GetUnit() const
Definition: lib_item.h: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:185
const wxSize & GetTextSize() const
Definition: eda_text.h:223
const wxPoint GetPosition() const
Definition: eda_rect.h:115
bool IsResized() const
Definition: base_struct.h:234
int GetSize() const
int GetSelectionThickness()
Selection highlight thickness.
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.
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
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
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.
#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
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
int GetRadius() const
Definition: lib_circle.h:91
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_text.cpp:422
std::unique_ptr< LIB_PART > & GetPartRef()
wxPoint m_End() const
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
int GetNameTextSize() const
Definition: lib_pin.h:175
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
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:661
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 GetSelectionFillShapes()
Draw selected shapes as filled or not.
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
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 GetSelectionDrawChildItems()
Draw selected child items or not.
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:221
#define HANDLE_ITEM(type_id, type_name)
bool IsStartDangling() const
Definition: sch_line.h:184
double GetImageScale() const
Definition: sch_bitmap.h:71
wxPoint GetSheetNamePosition()
Definition: sch_sheet.cpp:399
size_t i
Definition: json11.cpp:649
bool IsAlias() const
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:82
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:178
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:102