KiCad PCB EDA Suite
Loading...
Searching...
No Matches
router_preview_item.cpp
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2014 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#include "router_preview_item.h"
23
24
25#include <board_item.h>
27#include <gal/color4d.h>
29#include <geometry/shape_rect.h>
32#include <pcb_painter.h>
33#include <trigo.h>
34
35#include "pns_arc.h"
36#include "pns_line.h"
37#include "pns_segment.h"
38#include "pns_via.h"
39#include "pns_kicad_iface.h"
40
41#include <pcb_painter.h>
42#include <netinfo.h>
43#include <layer_ids.h>
44
45using namespace KIGFX;
46
47
49 KIGFX::VIEW* aView, int aFlags, DISPLAY_MODE aMode ) :
51 m_view( aView ),
52 m_iface( aIface ),
53 m_shape( nullptr ),
54 m_hole( nullptr ),
55 m_flags( aFlags ),
56 m_mode( aMode )
57{
58 BOARD_ITEM* boardItem = aItem ? aItem->BoardItem() : nullptr;
59
60 // A PNS::SOLID for an edge-cut item must have 0 width for collision calculations, but when
61 // highlighting an edge we want to show it with its true width
62 if( boardItem && boardItem->IsOnLayer( Edge_Cuts ) )
63 {
64 m_shape = aItem->Shape( -1 )->Clone();
65
66 switch( m_shape->Type() )
67 {
68 case SH_SEGMENT: static_cast<SHAPE_SEGMENT*>( m_shape )->SetWidth( 0 ); break;
69 case SH_ARC: static_cast<SHAPE_ARC*>( m_shape )->SetWidth( 0 ); break;
70 case SH_LINE_CHAIN: static_cast<SHAPE_LINE_CHAIN*>( m_shape )->SetWidth( 0 ); break;
71 default: /* remaining shapes don't have width */ break;
72 }
73 }
74 else if( aItem )
75 {
76 // TODO(JE) padstacks -- need to know the layer here
77 m_shape = aItem->Shape( -1 )->Clone();
78
79 if( aItem->HasHole() )
80 m_hole = aItem->Hole()->Shape( -1 )->Clone();
81 }
82
83 m_clearance = -1;
84 m_originLayer = LAYER_SELECT_OVERLAY;
85 m_layer = chooseLayer();
86
87
88 // initialize variables, overwritten by Update( aItem ), if aItem != NULL
89 m_type = PR_SHAPE;
90 m_width = ( aFlags & PNS_SEMI_SOLID ) ? 1 : 0;
91
92 // Depth follows the drawing layer so a collision marker passes the OpenGL depth test over the overlay
93 m_depth = m_originDepth = aView->GetLayerOrder( m_layer );
94
95 if( aItem )
96 Update( aItem );
97}
98
99
101 KIGFX::VIEW* aView ) :
103 m_view( aView ),
104 m_iface( aIface ),
105 m_flags( 0 ),
107{
108 m_shape = aShape.Clone();
109 m_hole = nullptr;
110
111 m_clearance = -1;
113
114
115 // initialize variables, overwritten by Update( aItem ), if aItem != NULL
117 m_width = 0;
119}
120
121
123{
124 delete m_shape;
125 delete m_hole;
126}
127
128
130{
131 m_originLayer = m_iface->GetBoardLayerFromPNSLayer( aItem->Layers().Start() );
132
133 if( const PNS::LINE* l = dyn_cast<const PNS::LINE*>( aItem ) )
134 {
135 if( !l->SegmentCount() )
136 return;
137 }
138 else if( const PNS::VIA* v = dyn_cast<const PNS::VIA*>( aItem ) )
139 {
140 if( v->IsVirtual() )
141 return;
142 }
143
144 if( m_originLayer < 0 )
145 m_originLayer = 0;
146
149 m_color.a = 0.8;
150 m_depth = m_originDepth - ( ( aItem->Layers().Start() + 1 ) * LayerDepthFactor );
151
152 switch( aItem->Kind() )
153 {
156 m_width = static_cast<const PNS::LINE*>( aItem )->Width();
157 break;
158
159 case PNS::ITEM::ARC_T:
161 m_width = static_cast<const PNS::ARC*>( aItem )->Width();
162 break;
163
166 m_width = static_cast<const PNS::SEGMENT*>( aItem )->Width();
167 break;
168
169 case PNS::ITEM::VIA_T:
170 {
173 m_width = 0;
174 m_color = COLOR4D( 0.7, 0.7, 0.7, 0.8 );
175 m_depth = m_originDepth - ( static_cast<double>( PCB_LAYER_ID_COUNT ) * LayerDepthFactor );
176
177 delete m_shape;
178 m_shape = nullptr;
179
180 auto via = static_cast<const PNS::VIA*>( aItem );
181 int shapeLayer = -1;
182 int largestDiameter = 0;
183
184 for( int layer : via->UniqueShapeLayers() )
185 {
186 if( via->Diameter( layer ) > largestDiameter )
187 {
188 largestDiameter = via->Diameter( layer );
189 shapeLayer = layer;
190 }
191 }
192
193 if( aItem->Shape( shapeLayer ) )
194 m_shape = aItem->Shape( shapeLayer )->Clone();
195
196 delete m_hole;
197 m_hole = nullptr;
198
199 if( aItem->HasHole() )
200 m_hole = aItem->Hole()->Shape( -1 )->Clone();
201
202 break;
203 }
204
207 break;
208
209 default:
210 break;
211 }
212
213 if( aItem->Marker() & PNS::MK_VIOLATION )
215
216 if( m_flags & PNS_COLLISION )
217 m_color = COLOR4D( 0, 1, 0, 1 );
218
219 if( m_flags & PNS_HOVER_ITEM )
220 m_color = m_color.WithAlpha( 1.0 );
221
223}
224
225
227{
228 // Halos go behind copper and collision markers go on top
229 if( m_mode == DM_SHADOW )
231
232 if( m_flags & PNS_COLLISION )
234
236}
237
238
240{
241 BOX2I bbox;
242
243 switch( m_type )
244 {
245 case PR_SHAPE:
246 if( m_shape )
247 {
248 bbox = m_shape->BBox();
249 bbox.Inflate( m_width / 2 );
250
251 if( m_mode == DM_SHADOW && m_clearance > 0 )
252 bbox.Inflate( m_clearance );
253 }
254
255 if( m_hole )
256 bbox.Merge( m_hole->BBox() );
257
258 return bbox;
259
260 case PR_POINT:
261 bbox = BOX2I ( m_pos - VECTOR2I( 100000, 100000 ), VECTOR2I( 200000, 200000 ) );
262 return bbox;
263
264 default:
265 break;
266 }
267
268 return bbox;
269}
270
271
273{
274 wxCHECK( aL, /* void */ );
275
276 gal->SetIsFill( false );
277
278 for( int s = 0; s < (int) aL->GetSegmentCount(); s++ )
279 {
280 SEG seg = aL->GetSegment( s );
281
282 if( seg.A == seg.B )
283 {
284 gal->SetIsFill( true );
285 gal->SetIsStroke( false );
286 gal->DrawCircle( seg.A, gal->GetLineWidth() / 2 );
287 gal->SetIsFill( false );
288 gal->SetIsStroke( true );
289 }
290 else
291 {
292 gal->DrawLine( seg.A, seg.B );
293 }
294 }
295
296 const SHAPE_LINE_CHAIN* lineChain = dynamic_cast<const SHAPE_LINE_CHAIN*>( aL );
297
298 for( size_t s = 0; lineChain && s < lineChain->ArcCount(); s++ )
299 {
300 const SHAPE_ARC& arc = lineChain->CArcs()[s];
301 EDA_ANGLE start_angle = arc.GetStartAngle();
302 EDA_ANGLE angle = arc.GetCentralAngle();
303
304 gal->DrawArc( arc.GetCenter(), arc.GetRadius(), start_angle, angle);
305 }
306
307 if( aL->IsClosed() )
308 gal->DrawLine( aL->GetSegment( -1 ).B, aL->GetSegment( 0 ).A );
309}
310
311
313{
314 if( m_clearance <= 0 )
315 return;
316
317 switch( aShape->Type() )
318 {
320 case SH_LINE_CHAIN:
321 {
322 const SHAPE_LINE_CHAIN_BASE* l = static_cast<const SHAPE_LINE_CHAIN_BASE*>( aShape );
323
324 gal->SetLineWidth( m_width + 2 * m_clearance );
325 drawLineChain( l, gal );
326 break;
327 }
328
329 case SH_SEGMENT:
330 {
331 const SHAPE_SEGMENT* s = static_cast<const SHAPE_SEGMENT*>( aShape );
332
333 gal->SetIsStroke( false );
334 gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() + 2 * m_clearance );
335 break;
336 }
337
338 case SH_CIRCLE:
339 {
340 const SHAPE_CIRCLE* c = static_cast<const SHAPE_CIRCLE*>( aShape );
341
342 gal->SetIsStroke( false );
343 gal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance );
344 break;
345 }
346
347 case SH_RECT:
348 {
349 gal->SetIsStroke( true );
350 gal->SetLineWidth( 2 * m_clearance );
351 gal->DrawPolyline( static_cast<const SHAPE_RECT*>( aShape )->Outline() );
352 break;
353 }
354
355 case SH_SIMPLE:
356 {
357 gal->SetIsStroke( true );
358 gal->SetLineWidth( 2 * m_clearance );
359 gal->DrawPolyline( static_cast<const SHAPE_SIMPLE*>( aShape )->Vertices() );
360 break;
361 }
362
363 case SH_ARC:
364 {
365 const SHAPE_ARC* arc = static_cast<const SHAPE_ARC*>( aShape );
366
367 gal->SetIsFill( false );
368 gal->SetIsStroke( true );
369 gal->SetLineWidth( arc->GetWidth() + 2 * m_clearance );
370 gal->DrawArc( arc->GetCenter(), arc->GetRadius(), arc->GetStartAngle(),
371 arc->GetCentralAngle() );
372 break;
373 }
374
375 case SH_ELLIPSE:
376 {
377 const SHAPE_ELLIPSE* ellipse = static_cast<const SHAPE_ELLIPSE*>( aShape );
378
379 gal->SetIsFill( false );
380 gal->SetIsStroke( true );
381 gal->SetLineWidth( std::max( 1, ellipse->GetWidth() ) + 2 * m_clearance );
382
383 if( ellipse->IsArc() )
384 {
385 gal->DrawEllipseArc( ellipse->GetCenter(), ellipse->GetMajorRadius(), ellipse->GetMinorRadius(),
386 ellipse->GetRotation(), ellipse->GetStartAngle(), ellipse->GetEndAngle() );
387 }
388 else
389 {
390 gal->DrawEllipse( ellipse->GetCenter(), ellipse->GetMajorRadius(), ellipse->GetMinorRadius(),
391 ellipse->GetRotation() );
392 }
393
394 break;
395 }
396
397 default:
398 break;
399 }
400}
401
402
403void ROUTER_PREVIEW_ITEM::drawShape( const SHAPE* aShape, KIGFX::GAL* gal ) const
404{
405 bool holeDrawn = false;
406
407 switch( aShape->Type() )
408 {
410 case SH_LINE_CHAIN:
411 {
412 const SHAPE_LINE_CHAIN_BASE* l = static_cast<const SHAPE_LINE_CHAIN_BASE*>( aShape );
413
414 gal->SetLayerDepth( m_depth );
415 gal->SetLineWidth( m_width );
416 gal->SetStrokeColor( m_color );
417 gal->SetFillColor( m_color );
418 drawLineChain( l, gal );
419 break;
420 }
421
422 case SH_SEGMENT:
423 {
424 const SHAPE_SEGMENT* s = static_cast<const SHAPE_SEGMENT*>( aShape );
425
426 gal->SetIsStroke( false );
427 gal->SetLayerDepth( m_depth );
428 gal->SetLineWidth( s->GetWidth() );
429 gal->SetFillColor( m_color );
430 gal->DrawSegment( s->GetSeg().A, s->GetSeg().B, s->GetWidth() );
431 break;
432 }
433
434 case SH_CIRCLE:
435 {
436 const SHAPE_CIRCLE* c = static_cast<const SHAPE_CIRCLE*>( aShape );
437
438 gal->SetStrokeColor( m_color );
439 gal->SetLayerDepth( m_depth );
440
441 if( m_hole && dynamic_cast<SHAPE_CIRCLE*>( m_hole ) )
442 {
443 const SHAPE_CIRCLE* h = static_cast<const SHAPE_CIRCLE*>( m_hole );
444 int halfWidth = m_width / 2;
445
446 gal->SetIsStroke( true );
447 gal->SetIsFill( false );
448 gal->SetLineWidth( halfWidth + c->GetRadius() - h->GetRadius() );
449 gal->DrawCircle( c->GetCenter(), ( halfWidth + c->GetRadius() + h->GetRadius() ) / 2 );
450
451 holeDrawn = true;
452 }
453 else
454 {
455 gal->SetIsStroke( m_width ? true : false );
456 gal->SetLineWidth( m_width );
457 gal->SetFillColor( m_color );
458 gal->DrawCircle( c->GetCenter(), c->GetRadius() );
459 }
460
461 break;
462 }
463
464 case SH_RECT:
465 {
466 const SHAPE_RECT* r = static_cast<const SHAPE_RECT*>( aShape );
467
468 gal->SetFillColor( m_color );
469 gal->SetLayerDepth( m_depth );
470 gal->SetIsStroke( m_width ? true : false );
471 gal->SetLineWidth( m_width );
472 gal->SetStrokeColor( m_color );
473 gal->DrawRectangle( r->GetPosition(), r->GetPosition() + r->GetSize() );
474 break;
475 }
476
477 case SH_SIMPLE:
478 {
479 gal->SetFillColor( m_color );
480 gal->SetLayerDepth( m_depth );
481 gal->SetIsStroke( m_width ? true : false );
482 gal->SetLineWidth( m_width );
483 gal->SetStrokeColor( m_color );
484 gal->DrawPolygon( static_cast<const SHAPE_SIMPLE*>( aShape )->Vertices() );
485 break;
486 }
487
488 case SH_ARC:
489 {
490 const SHAPE_ARC* arc = static_cast<const SHAPE_ARC*>( aShape );
491
492 gal->SetIsFill( false );
493 gal->SetIsStroke( true );
494 gal->SetLayerDepth( m_depth );
495 gal->SetStrokeColor( m_color );
496 gal->SetFillColor( m_color );
497 gal->SetLineWidth( arc->GetWidth() );
498 gal->DrawArc( arc->GetCenter(), arc->GetRadius(), arc->GetStartAngle(),
499 arc->GetCentralAngle() );
500 break;
501 }
502
503 case SH_ELLIPSE:
504 {
505 const SHAPE_ELLIPSE* ellipse = static_cast<const SHAPE_ELLIPSE*>( aShape );
506 const VECTOR2I center = ellipse->GetCenter();
507 const int major = ellipse->GetMajorRadius();
508 const int minor = ellipse->GetMinorRadius();
509 const EDA_ANGLE rotation = ellipse->GetRotation();
510 const bool isArc = ellipse->IsArc();
511 const int w = std::max( 1, ellipse->GetWidth() );
512
513 gal->SetIsFill( false );
514 gal->SetIsStroke( true );
515 gal->SetLayerDepth( m_depth );
516 gal->SetStrokeColor( m_color );
517 gal->SetFillColor( m_color );
518 gal->SetLineWidth( w );
519
520 if( isArc )
521 gal->DrawEllipseArc( center, major, minor, rotation, ellipse->GetStartAngle(), ellipse->GetEndAngle() );
522 else
523 gal->DrawEllipse( center, major, minor, rotation );
524
525 break;
526 }
527
528 case SH_COMPOUND:
529 wxFAIL_MSG( wxT( "Router preview item: nested compound shapes not supported" ) );
530 break;
531
532 case SH_POLY_SET:
533 wxFAIL_MSG( wxT( "Router preview item: SHAPE_POLY_SET not supported" ) );
534 break;
535
536 case SH_NULL:
537 break;
538 }
539
540 if( m_hole && !holeDrawn )
541 {
542 gal->SetLayerDepth( m_depth );
543 gal->SetIsStroke( true );
544 gal->SetIsFill( false );
545 gal->SetStrokeColor( m_color );
546 gal->SetLineWidth( 1 );
547
548 SHAPE_CIRCLE* circle = dynamic_cast<SHAPE_CIRCLE*>( m_hole );
549 SHAPE_SEGMENT* slot = dynamic_cast<SHAPE_SEGMENT*>( m_hole );
550
551 if( circle )
552 gal->DrawCircle( circle->GetCenter(), circle->GetRadius() );
553 else if( slot )
554 gal->DrawSegment( slot->GetSeg().A, slot->GetSeg().B, slot->GetWidth() );
555 }
556}
557
558
559void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
560{
561 GAL* gal = aView->GetGAL();
562
563 if( m_type != PR_SHAPE || !m_shape )
564 return;
565
566 std::vector<const SHAPE*> shapes;
567
568 if( m_shape->HasIndexableSubshapes() )
569 m_shape->GetIndexableSubshapes( shapes );
570 else
571 shapes.push_back( m_shape );
572
573 if( m_mode == DM_SHADOW )
574 {
575 //TODO(snh) Add configuration option for the color/alpha here
576 gal->SetStrokeColor( COLOR4D( DARKDARKGRAY ).WithAlpha( 0.9 ) );
577 gal->SetFillColor( COLOR4D( DARKDARKGRAY ).WithAlpha( 0.7 ) );
578 gal->SetIsStroke( m_width ? true : false );
579 gal->SetIsFill( true );
580
581 for( const SHAPE* shape : shapes )
582 drawClearanceHalo( shape, gal );
583
584 return;
585 }
586
587 gal->SetLayerDepth( m_depth );
588 gal->SetStrokeColor( m_color );
589 gal->SetFillColor( m_color );
590 gal->SetIsStroke( m_width ? true : false );
591 gal->SetIsFill( true );
592
593 // Semi-solids (ie: rule areas) which are not in collision are sketched (ie: outline only)
594 if( ( m_flags & PNS_SEMI_SOLID ) > 0 && ( m_flags & PNS_COLLISION ) == 0 )
595 gal->SetIsFill( false );
596
597 for( const SHAPE* shape : shapes )
598 drawShape( shape, gal );
599}
600
601
602const COLOR4D ROUTER_PREVIEW_ITEM::getLayerColor( int aLayer, const PNS::ITEM* aItem ) const
603{
604 auto settings = static_cast<PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
605
606 COLOR4D color = settings->GetLayerColor( aLayer );
607
608 if( aItem && aItem->Net() && settings->GetNetColorMode() == NET_COLOR_MODE::ALL && IsCopperLayer( aLayer ) )
609 {
610 NETINFO_ITEM* ni = static_cast<NETINFO_ITEM*>( aItem->Net() );
611
612 auto ii = settings->GetNetColorMap().find( ni->GetNetCode() );
613
614 if( ii != settings->GetNetColorMap().end() && ii->second != COLOR4D::UNSPECIFIED )
615 {
616 color = ii->second;
617 }
618 else
619 {
620 NETCLASS* nc = ni->GetNetClass();
621
622 if( nc && nc->HasPcbColor() )
623 color = nc->GetPcbColor();
624 }
625 }
626
627 if( m_flags & PNS_HEAD_TRACE )
628 return color.Saturate( 1.0 );
629 else if( m_flags & PNS_HOVER_ITEM )
630 return color.Brightened( 0.7 );
631
632 return color;
633}
@ ALL
Net/netclass colors are shown on all net copper.
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:85
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition board_item.h:418
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:553
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:594
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition color4d.h:265
COLOR4D & Saturate(double aFactor)
Saturates the color to a given factor (in HSV model)
Definition color4d.cpp:515
Abstract interface for drawing on a 2D-surface.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawEllipseArc(const VECTOR2D &aCenterPoint, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle)
Draw an elliptical arc in world coordinates.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle)
Draw an arc.
virtual void DrawEllipse(const VECTOR2D &aCenterPoint, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation)
Draw a closed ellipse.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
float GetLineWidth() const
Get the line width.
PCB specific render settings.
Definition pcb_painter.h:94
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
int GetLayerOrder(int aLayer) const
Return rendering order of a particular layer.
Definition view.cpp:1040
GAL * GetGAL() const
Return the GAL this view is using to draw graphical primitives.
Definition view.h:224
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:44
COLOR4D GetPcbColor(bool aIsForSave=false) const
Definition netclass.h:214
bool HasPcbColor() const
Definition netclass.h:213
Handle the data for a net.
Definition netinfo.h:50
NETCLASS * GetNetClass()
Definition netinfo.h:101
int GetNetCode() const
Definition netinfo.h:104
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
Definition pns_hole.h:69
Base class for PNS router board items.
Definition pns_item.h:98
virtual const SHAPE * Shape(int aLayer) const
Return the geometrical shape of the item.
Definition pns_item.h:246
const PNS_LAYER_RANGE & Layers() const
Definition pns_item.h:212
virtual NET_HANDLE Net() const
Definition pns_item.h:210
PnsKind Kind() const
Return the type (kind) of the item.
Definition pns_item.h:173
virtual HOLE * Hole() const
Definition pns_item.h:308
virtual bool HasHole() const
Definition pns_item.h:307
virtual BOARD_ITEM * BoardItem() const
Definition pns_item.h:207
virtual int Marker() const
Definition pns_item.h:267
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:62
int Start() const
DISPLAY_MODE
An element with a visible clearance is drawn as two items on separate view layers,...
@ DM_SHAPE
Shape body only, in the normal or collision color.
@ DM_SHADOW
Clearance halo only, drawn behind board items.
ROUTER_PREVIEW_ITEM(const SHAPE &aShape, PNS::ROUTER_IFACE *aIface, KIGFX::VIEW *aView)
static constexpr double LayerDepthFactor
We draw this item on a single layer, but we stack up all the layers from the various components that ...
void Update(const PNS::ITEM *aItem)
virtual void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
const KIGFX::COLOR4D getLayerColor(int aLayer, const PNS::ITEM *aItem=nullptr) const
void drawLineChain(const SHAPE_LINE_CHAIN_BASE *aL, KIGFX::GAL *aGal) const
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void drawShape(const SHAPE *aShape, KIGFX::GAL *aGal) const
PNS::ROUTER_IFACE * m_iface
void drawClearanceHalo(const SHAPE *aShape, KIGFX::GAL *aGal) const
Definition seg.h:38
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
EDA_ANGLE GetCentralAngle() const
Get the "central angle" of the arc - this is the angle at the point of the "pie slice".
int GetWidth() const override
Definition shape_arc.h:215
double GetRadius() const
EDA_ANGLE GetStartAngle() const
const VECTOR2I & GetCenter() const
SHAPE_TYPE Type() const
Return the type of the shape.
Definition shape.h:96
int GetRadius() const
const VECTOR2I GetCenter() const
int GetMajorRadius() const
const VECTOR2I & GetCenter() const
const EDA_ANGLE & GetStartAngle() const
const EDA_ANGLE & GetEndAngle() const
const EDA_ANGLE & GetRotation() const
bool IsArc() const
int GetMinorRadius() const
virtual size_t GetSegmentCount() const =0
virtual bool IsClosed() const =0
virtual const SEG GetSegment(int aIndex) const =0
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const std::vector< SHAPE_ARC > & CArcs() const
size_t ArcCount() const
const VECTOR2I & GetPosition() const
Definition shape_rect.h:164
const VECTOR2I GetSize() const
Definition shape_rect.h:172
const SEG & GetSeg() const
int GetWidth() const override
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
An abstract shape on 2D plane.
Definition shape.h:124
virtual int GetWidth() const
Definition shape.h:299
virtual SHAPE * Clone() const
Return a dynamically allocated copy of the shape.
Definition shape.h:146
@ DARKDARKGRAY
Definition color4d.h:41
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:741
@ LAYER_ROUTER_PREVIEW_COLLISION
Router preview collision marker, drawn above all board items.
Definition layer_ids.h:348
@ LAYER_ROUTER_PREVIEW_SHADOW
Router preview clearance shadow, drawn behind board copper.
Definition layer_ids.h:345
@ LAYER_SELECT_OVERLAY
Selected items overlay.
Definition layer_ids.h:276
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition layer_ids.h:228
@ Edge_Cuts
Definition layer_ids.h:108
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
@ MK_VIOLATION
Definition pns_item.h:44
#define PNS_HEAD_TRACE
#define PNS_SEMI_SOLID
#define PNS_HOVER_ITEM
#define PNS_COLLISION
@ SH_POLY_SET
set of polygons (with holes, etc.)
Definition shape.h:48
@ SH_RECT
axis-aligned rectangle
Definition shape.h:43
@ SH_CIRCLE
circle
Definition shape.h:46
@ SH_SIMPLE
simple polygon
Definition shape.h:47
@ SH_ELLIPSE
ellipse or elliptical arc
Definition shape.h:53
@ SH_NULL
empty shape (no shape...),
Definition shape.h:51
@ SH_SEGMENT
line segment
Definition shape.h:44
@ SH_ARC
circular arc
Definition shape.h:50
@ SH_POLY_SET_TRIANGLE
a single triangle belonging to a POLY_SET triangulation
Definition shape.h:52
@ SH_LINE_CHAIN
line chain (polyline)
Definition shape.h:45
@ SH_COMPOUND
compound shape, consisting of multiple simple shapes
Definition shape.h:49
VECTOR2I center
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
@ NOT_USED
the 3d code uses this value
Definition typeinfo.h:71
Casted dyn_cast(From aObject)
A lightweight dynamic downcast.
Definition typeinfo.h:55
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708