KiCad PCB EDA Suite
PNS::ITEM Class Referenceabstract

Class ITEM. More...

#include <pns_item.h>

Inheritance diagram for PNS::ITEM:
PNS::DIFF_PAIR PNS::JOINT PNS::LINE PNS::SEGMENT PNS::SOLID PNS::VIA

Public Types

enum  PnsKind {
  SOLID_T = 1, LINE_T = 2, JOINT_T = 4, SEGMENT_T = 8,
  VIA_T = 16, DIFF_PAIR_T = 32, ANY_T = 0xff
}
 

Supported item types

More...
 

Public Member Functions

 ITEM (PnsKind aKind)
 
 ITEM (const ITEM &aOther)
 
virtual ~ITEM ()
 
virtual ITEMClone () const =0
 Function Clone() More...
 
virtual const SHAPE_LINE_CHAIN Hull (int aClearance=0, int aWalkaroundThickness=0) const
 
PnsKind Kind () const
 Function Kind() More...
 
bool OfKind (int aKindMask) const
 Function OfKind() More...
 
const std::string KindStr () const
 Function KindStr() More...
 
void SetParent (BOARD_CONNECTED_ITEM *aParent)
 Function SetParent() More...
 
BOARD_CONNECTED_ITEMParent () const
 Function Parent() More...
 
void SetNet (int aNet)
 Function SetNet() More...
 
int Net () const
 Function Net() More...
 
void SetLayers (const LAYER_RANGE &aLayers)
 Function SetLayers() More...
 
void SetLayer (int aLayer)
 Function SetLayer() More...
 
const LAYER_RANGELayers () const
 Function Layers() More...
 
virtual int Layer () const
 Function Layer() More...
 
bool LayersOverlap (const ITEM *aOther) const
 Function LayersOverlap() More...
 
void SetOwner (NODE *aOwner)
 Functon SetOwner() More...
 
bool BelongsTo (NODE *aNode) const
 Function BelongsTo() More...
 
NODEOwner () const
 Function Owner() More...
 
virtual bool Collide (const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly=true) const
 Function Collide() More...
 
bool Collide (const ITEM *aOther, int aClearance, bool aDifferentNetsOnly=true) const
 Function Collide() More...
 
virtual const SHAPEShape () const
 Function Shape() More...
 
virtual void Mark (int aMarker)
 
virtual void Unmark (int aMarker=-1)
 
virtual int Marker () const
 
virtual void SetRank (int aRank)
 
virtual int Rank () const
 
virtual VECTOR2I Anchor (int n) const
 
virtual int AnchorCount () const
 
bool IsLocked () const
 
void SetRoutable (bool aRoutable)
 
bool IsRoutable () const
 

Static Public Attributes

static const int UnusedNet = INT_MAX
 

Protected Attributes

PnsKind m_kind
 
BOARD_CONNECTED_ITEMm_parent
 
NODEm_owner
 
LAYER_RANGE m_layers
 
bool m_movable
 
int m_net
 
int m_marker
 
int m_rank
 
bool m_routable
 

Private Member Functions

bool collideSimple (const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly) const
 

Detailed Description

Class ITEM.

Base class for PNS router board items. Implements the shared properties of all PCB items - net, spanned layers, geometric shape & refererence to owning model.

Definition at line 53 of file pns_item.h.

Member Enumeration Documentation

Supported item types

Enumerator
SOLID_T 
LINE_T 
JOINT_T 
SEGMENT_T 
VIA_T 
DIFF_PAIR_T 
ANY_T 

Definition at line 59 of file pns_item.h.

60  {
61  SOLID_T = 1,
62  LINE_T = 2,
63  JOINT_T = 4,
64  SEGMENT_T = 8,
65  VIA_T = 16,
66  DIFF_PAIR_T = 32,
67  ANY_T = 0xff
68  };

Constructor & Destructor Documentation

PNS::ITEM::ITEM ( PnsKind  aKind)
inline

Definition at line 70 of file pns_item.h.

References m_kind, m_marker, m_movable, m_net, m_owner, m_parent, m_rank, m_routable, and UnusedNet.

71  {
72  m_net = UnusedNet;
73  m_movable = true;
74  m_kind = aKind;
75  m_parent = NULL;
76  m_owner = NULL;
77  m_marker = 0;
78  m_rank = -1;
79  m_routable = true;
80  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:360
NODE * m_owner
Definition: pns_item.h:361
int m_rank
Definition: pns_item.h:367
bool m_movable
Definition: pns_item.h:364
bool m_routable
Definition: pns_item.h:368
static const int UnusedNet
Definition: pns_item.h:56
int m_marker
Definition: pns_item.h:366
int m_net
Definition: pns_item.h:365
PnsKind m_kind
Definition: pns_item.h:358
PNS::ITEM::ITEM ( const ITEM aOther)
inline

Definition at line 82 of file pns_item.h.

References Clone(), m_kind, m_layers, m_marker, m_movable, m_net, m_owner, m_parent, m_rank, m_routable, and ~ITEM().

83  {
84  m_layers = aOther.m_layers;
85  m_net = aOther.m_net;
86  m_movable = aOther.m_movable;
87  m_kind = aOther.m_kind;
88  m_parent = aOther.m_parent;
89  m_owner = NULL;
90  m_marker = aOther.m_marker;
91  m_rank = aOther.m_rank;
92  m_routable = aOther.m_routable;
93  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:360
NODE * m_owner
Definition: pns_item.h:361
LAYER_RANGE m_layers
Definition: pns_item.h:362
int m_rank
Definition: pns_item.h:367
bool m_movable
Definition: pns_item.h:364
bool m_routable
Definition: pns_item.h:368
int m_marker
Definition: pns_item.h:366
int m_net
Definition: pns_item.h:365
PnsKind m_kind
Definition: pns_item.h:358
PNS::ITEM::~ITEM ( )
virtual

Definition at line 88 of file pns_item.cpp.

Referenced by ITEM().

89 {
90 }

Member Function Documentation

virtual VECTOR2I PNS::ITEM::Anchor ( int  n) const
inlinevirtual

Reimplemented in PNS::VIA, PNS::SEGMENT, and PNS::SOLID.

Definition at line 328 of file pns_item.h.

Referenced by PNS::DP_PRIMITIVE_PAIR::CursorOrientation(), PNS::DP_PRIMITIVE_PAIR::DP_PRIMITIVE_PAIR(), and PNS::DIFF_PAIR_PLACER::getDanglingAnchor().

329  {
330  return VECTOR2I();
331  }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
virtual int PNS::ITEM::AnchorCount ( ) const
inlinevirtual

Reimplemented in PNS::VIA, PNS::SEGMENT, and PNS::SOLID.

Definition at line 333 of file pns_item.h.

334  {
335  return 0;
336  }
bool PNS::ITEM::BelongsTo ( NODE aNode) const
inline

Function BelongsTo()

Returns
true if the item is owned by the node aNode.

Definition at line 251 of file pns_item.h.

References m_owner.

Referenced by PNS::NODE::doRemove().

252  {
253  return m_owner == aNode;
254  }
NODE * m_owner
Definition: pns_item.h:361
virtual ITEM* PNS::ITEM::Clone ( ) const
pure virtual
bool PNS::ITEM::Collide ( const ITEM aOther,
int  aClearance,
bool  aNeedMTV,
VECTOR2I aMTV,
bool  aDifferentNetsOnly = true 
) const
virtual

Function Collide()

Checks for a collision (clearance violation) with between us and item aOther. Collision checking takes all PCB stuff into accound (layers, nets, DRC rules). Optionally returns a minimum translation vector for force propagation algorithm.

Parameters
aOtheritem to check collision against
aClearancedesired clearance
aNeedMTVwhen true, the minimum translation vector is calculated
aMTVthe minimum translation vector
Returns
true, if a collision was found.

Definition at line 44 of file pns_item.cpp.

References collideSimple(), PNS::LINE::EndsWithVia(), LINE_T, m_kind, PNS::LINE::Via(), and PNS::LINE::Width().

Referenced by PNS::NODE::CheckColliding(), Collide(), PNS::OPTIMIZER::CACHE_VISITOR::operator()(), PNS::NODE::DEFAULT_OBSTACLE_VISITOR::operator()(), and Owner().

46 {
47  if( collideSimple( aOther, aClearance, aNeedMTV, aMTV, aDifferentNetsOnly ) )
48  return true;
49 
50  // special case for "head" line with a via attached at the end.
51  if( aOther->m_kind == LINE_T )
52  {
53  const LINE* line = static_cast<const LINE*>( aOther );
54 
55  if( line->EndsWithVia() )
56  return collideSimple( &line->Via(), aClearance - line->Width() / 2, aNeedMTV, aMTV, aDifferentNetsOnly );
57  }
58 
59  return false;
60 }
bool collideSimple(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly) const
Definition: pns_item.cpp:27
bool PNS::ITEM::Collide ( const ITEM aOther,
int  aClearance,
bool  aDifferentNetsOnly = true 
) const
inline

Function Collide()

A shortcut for ITEM::Colllide() without MTV stuff.

Definition at line 285 of file pns_item.h.

References Collide(), and dummy().

286  {
287  VECTOR2I dummy;
288 
289  return Collide( aOther, aClearance, false, dummy, aDifferentNetsOnly );
290  }
virtual bool Collide(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly=true) const
Function Collide()
Definition: pns_item.cpp:44
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
bool PNS::ITEM::collideSimple ( const ITEM aOther,
int  aClearance,
bool  aNeedMTV,
VECTOR2I aMTV,
bool  aDifferentNetsOnly 
) const
private

Definition at line 27 of file pns_item.cpp.

References SHAPE::Collide(), m_layers, m_net, LAYER_RANGE::Overlaps(), and Shape().

Referenced by Collide(), and IsRoutable().

29 {
30  // same nets? no collision!
31  if( aDifferentNetsOnly && m_net == aOther->m_net && m_net >= 0 && aOther->m_net >= 0 )
32  return false;
33 
34  // check if we are not on completely different layers first
35  if( !m_layers.Overlaps( aOther->m_layers ) )
36  return false;
37 
38  return Shape()->Collide( aOther->Shape(), aClearance );
39 
40  // fixme: MTV
41 }
LAYER_RANGE m_layers
Definition: pns_item.h:362
virtual const SHAPE * Shape() const
Function Shape()
Definition: pns_item.h:298
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
int m_net
Definition: pns_item.h:365
virtual bool Collide(const VECTOR2I &aP, int aClearance=0) const
Function Collide()
Definition: shape.h:107
virtual const SHAPE_LINE_CHAIN PNS::ITEM::Hull ( int  aClearance = 0,
int  aWalkaroundThickness = 0 
) const
inlinevirtual

Reimplemented in PNS::VIA, PNS::SEGMENT, and PNS::SOLID.

Definition at line 112 of file pns_item.h.

113  {
114  return SHAPE_LINE_CHAIN();
115  }
Class SHAPE_LINE_CHAIN.
bool PNS::ITEM::IsLocked ( ) const
inline

Definition at line 338 of file pns_item.h.

References Marker(), and PNS::MK_LOCKED.

Referenced by ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::performDragging(), and PNS::SHOVE::pushVia().

339  {
340  return Marker() & MK_LOCKED;
341  }
virtual int Marker() const
Definition: pns_item.h:313
bool PNS::ITEM::IsRoutable ( ) const
inline

Definition at line 348 of file pns_item.h.

References collideSimple(), and m_routable.

349  {
350  return m_routable;
351  }
bool m_routable
Definition: pns_item.h:368
const std::string PNS::ITEM::KindStr ( ) const

Function KindStr()

Returns the kind of the item, as string

Definition at line 63 of file pns_item.cpp.

References JOINT_T, LINE_T, m_kind, SEGMENT_T, SOLID_T, and VIA_T.

Referenced by OfKind(), PNS::TOOL_BASE::pickSingleItem(), and PNS::TOOL_BASE::updateEndItem().

64 {
65  switch( m_kind )
66  {
67  case LINE_T:
68  return "line";
69 
70  case SEGMENT_T:
71  return "segment";
72 
73  case VIA_T:
74  return "via";
75 
76  case JOINT_T:
77  return "joint";
78 
79  case SOLID_T:
80  return "solid";
81 
82  default:
83  return "unknown";
84  }
85 }
PnsKind m_kind
Definition: pns_item.h:358
virtual int PNS::ITEM::Layer ( ) const
inlinevirtual

Function Layer()

Returns the item's layer, for single-layered items only.

Reimplemented in PNS::SEGMENT.

Definition at line 219 of file pns_item.h.

References Layers(), and LAYER_RANGE::Start().

Referenced by PNS::OPTIMIZER::fanoutCleanup(), and PNS::OPTIMIZER::runSmartPads().

220  {
221  return Layers().Start();
222  }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:209
int Start() const
Definition: pns_layerset.h:83
bool PNS::ITEM::LayersOverlap ( const ITEM aOther) const
inline

Function LayersOverlap()

Returns true if the set of layers spanned by aOther overlaps our layers.

Definition at line 230 of file pns_item.h.

References Layers(), and LAYER_RANGE::Overlaps().

Referenced by PNS::SHOVE::onCollidingSegment(), PNS::SHOVE::ProcessSingleLine(), and PNS::NODE::removeViaIndex().

231  {
232  return Layers().Overlaps( aOther->Layers() );
233  }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:209
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
virtual void PNS::ITEM::Mark ( int  aMarker)
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 303 of file pns_item.h.

References m_marker.

Referenced by PNS::SHOVE::ShoveDraggingVia().

304  {
305  m_marker = aMarker;
306  }
int m_marker
Definition: pns_item.h:366
virtual int PNS::ITEM::Marker ( ) const
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 313 of file pns_item.h.

References m_marker.

Referenced by IsLocked(), PNS::LOGGER::Log(), PNS::SHOVE::pushVia(), and ROUTER_PREVIEW_ITEM::Update().

314  {
315  return m_marker;
316  }
int m_marker
Definition: pns_item.h:366
NODE* PNS::ITEM::Owner ( ) const
inline

Function Owner()

Returns the owner of this item, or NULL if there's none.

Definition at line 261 of file pns_item.h.

References Collide(), and m_owner.

Referenced by PNS::SIZES_SETTINGS::inheritTrackWidth(), and PNS::LINE_PLACER::Move().

261 { return m_owner; }
NODE * m_owner
Definition: pns_item.h:361
BOARD_CONNECTED_ITEM* PNS::ITEM::Parent ( ) const
inline

Function Parent()

Returns the corresponding parent object in the host application's model.

Definition at line 159 of file pns_item.h.

References m_parent.

Referenced by PNS_PCBNEW_RULE_RESOLVER::DpNetPair(), PNS_KICAD_IFACE::HideItem(), PNS_PCBNEW_RULE_RESOLVER::localPadClearance(), ROUTER_TOOL::prepareInteractive(), and PNS_KICAD_IFACE::RemoveItem().

160  {
161  return m_parent;
162  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:360
virtual int PNS::ITEM::Rank ( ) const
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 323 of file pns_item.h.

References m_rank.

Referenced by PNS::LOGGER::Log(), PNS::SHOVE::onCollidingVia(), and PNS::SHOVE::shoveIteration().

324  {
325  return m_rank;
326  }
int m_rank
Definition: pns_item.h:367
void PNS::ITEM::SetLayer ( int  aLayer)
inline

Function SetLayer()

Sets the layers spanned by the item to a single layer aLayer.

Definition at line 199 of file pns_item.h.

References m_layers.

Referenced by PNS::LINE_PLACER::initPlacement(), PNS::DIFF_PAIR_PLACER::propagateDpHeadForces(), PNS::DIFF_PAIR_PLACER::routeHead(), and PNS::DIFF_PAIR::updateLine().

200  {
201  m_layers = LAYER_RANGE( aLayer, aLayer );
202  }
LAYER_RANGE m_layers
Definition: pns_item.h:362
Class LAYER_RANGE.
Definition: pns_layerset.h:32
void PNS::ITEM::SetLayers ( const LAYER_RANGE aLayers)
inline

Function SetLayers()

Sets the layers spanned by the item to aLayers.

Definition at line 189 of file pns_item.h.

References m_layers.

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), PNS::NODE::AssembleLine(), PNS::VIA::Clone(), PNS::SEGMENT::SetLayer(), and PNS::VIA::VIA().

190  {
191  m_layers = aLayers;
192  }
LAYER_RANGE m_layers
Definition: pns_item.h:362
void PNS::ITEM::SetNet ( int  aNet)
inline
void PNS::ITEM::SetOwner ( NODE aOwner)
inline

Functon SetOwner()

Sets the node that owns this item. An item can belong to a single NODE or stay unowned.

Definition at line 241 of file pns_item.h.

References m_owner.

Referenced by PNS::NODE::AssembleLine(), PNS::NODE::doRemove(), and PNS::NODE::Remove().

242  {
243  m_owner = aOwner;
244  }
NODE * m_owner
Definition: pns_item.h:361
void PNS::ITEM::SetParent ( BOARD_CONNECTED_ITEM aParent)
inline

Function SetParent()

Sets the corresponding parent object in the host application's model.

Definition at line 149 of file pns_item.h.

References m_parent.

Referenced by PNS_KICAD_IFACE::AddItem().

150  {
151  m_parent = aParent;
152  }
BOARD_CONNECTED_ITEM * m_parent
Definition: pns_item.h:360
virtual void PNS::ITEM::SetRank ( int  aRank)
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 318 of file pns_item.h.

References m_rank.

319  {
320  m_rank = aRank;
321  }
int m_rank
Definition: pns_item.h:367
void PNS::ITEM::SetRoutable ( bool  aRoutable)
inline

Definition at line 343 of file pns_item.h.

References m_routable.

344  {
345  m_routable = aRoutable;
346  }
bool m_routable
Definition: pns_item.h:368
virtual const SHAPE* PNS::ITEM::Shape ( ) const
inlinevirtual

Function Shape()

Returns the geometrical shape of the item. Used for collision detection & spatial indexing.

Reimplemented in PNS::VIA, PNS::LINE, PNS::SEGMENT, and PNS::SOLID.

Definition at line 298 of file pns_item.h.

Referenced by PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::OPTIMIZER::checkColliding(), collideSimple(), PNS::OPTIMIZER::computeBreakouts(), PNS::OPTIMIZER::customBreakouts(), PNS::LOGGER::Log(), PNS::SHOVE::onCollidingVia(), PNS::HIT_VISITOR::operator()(), PNS::INDEX::Query(), and ROUTER_PREVIEW_ITEM::Update().

299  {
300  return NULL;
301  }
virtual void PNS::ITEM::Unmark ( int  aMarker = -1)
inlinevirtual

Reimplemented in PNS::LINE.

Definition at line 308 of file pns_item.h.

References m_marker.

Referenced by PNS::DRAGGER::Start().

309  {
310  m_marker &= ~aMarker;
311  }
int m_marker
Definition: pns_item.h:366

Member Data Documentation

PnsKind PNS::ITEM::m_kind
protected

Definition at line 358 of file pns_item.h.

Referenced by Collide(), ITEM(), Kind(), KindStr(), and OfKind().

bool PNS::ITEM::m_movable
protected

Definition at line 364 of file pns_item.h.

Referenced by ITEM(), PNS::LINE::LINE(), PNS::LINE::operator=(), and PNS::SOLID::SOLID().

NODE* PNS::ITEM::m_owner
protected

Definition at line 361 of file pns_item.h.

Referenced by BelongsTo(), ITEM(), Owner(), and SetOwner().

BOARD_CONNECTED_ITEM* PNS::ITEM::m_parent
protected

Definition at line 360 of file pns_item.h.

Referenced by ITEM(), Parent(), and SetParent().

bool PNS::ITEM::m_routable
protected

Definition at line 368 of file pns_item.h.

Referenced by IsRoutable(), ITEM(), and SetRoutable().

const int PNS::ITEM::UnusedNet = INT_MAX
static

Definition at line 56 of file pns_item.h.

Referenced by ITEM().


The documentation for this class was generated from the following files: