KiCad PCB EDA Suite
PNS::SEGMENT Class Reference

#include <pns_segment.h>

Inheritance diagram for PNS::SEGMENT:
PNS::ITEM

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

 SEGMENT ()
 
 SEGMENT (const SEG &aSeg, int aNet)
 
 SEGMENT (const LINE &aParentLine, const SEG &aSeg)
 
SEGMENTClone () const override
 Function Clone() More...
 
const SHAPEShape () const override
 Function Shape() More...
 
void SetLayer (int aLayer)
 
int Layer () const override
 Function Layer() More...
 
void SetWidth (int aWidth)
 
int Width () const
 
const SEGSeg () const
 
const SHAPE_LINE_CHAIN CLine () const
 
void SetEnds (const VECTOR2I &a, const VECTOR2I &b)
 
void SwapEnds ()
 
const SHAPE_LINE_CHAIN Hull (int aClearance, int aWalkaroundThickness) const override
 
virtual VECTOR2I Anchor (int n) const override
 
virtual int AnchorCount () const override
 
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...
 
const LAYER_RANGELayers () const
 Function Layers() 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 void Mark (int aMarker)
 
virtual void Unmark (int aMarker=-1)
 
virtual int Marker () const
 
virtual void SetRank (int aRank)
 
virtual int Rank () const
 
bool IsLocked () const
 
void SetRoutable (bool aRoutable)
 
bool IsRoutable () const
 

Static Public Member Functions

static bool ClassOf (const ITEM *aItem)
 

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 Attributes

SHAPE_SEGMENT m_seg
 

Detailed Description

Definition at line 38 of file pns_segment.h.

Member Enumeration Documentation

enum PNS::ITEM::PnsKind
inherited

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::SEGMENT::SEGMENT ( )
inline

Definition at line 41 of file pns_segment.h.

41  :
42  ITEM( SEGMENT_T )
43  {}
ITEM(PnsKind aKind)
Definition: pns_item.h:70
PNS::SEGMENT::SEGMENT ( const SEG aSeg,
int  aNet 
)
inline

Definition at line 45 of file pns_segment.h.

References PNS::ITEM::m_net.

45  :
46  ITEM( SEGMENT_T ), m_seg( aSeg, 0 )
47  {
48  m_net = aNet;
49  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
ITEM(PnsKind aKind)
Definition: pns_item.h:70
int m_net
Definition: pns_item.h:365
PNS::SEGMENT::SEGMENT ( const LINE aParentLine,
const SEG aSeg 
)
inline

Definition at line 51 of file pns_segment.h.

References PNS::ITEM::Layers(), PNS::ITEM::m_layers, PNS::ITEM::m_marker, PNS::ITEM::m_net, PNS::ITEM::m_rank, PNS::LINE::Marker(), PNS::ITEM::Net(), and PNS::LINE::Rank().

51  :
52  ITEM( SEGMENT_T ),
53  m_seg( aSeg, aParentLine.Width() )
54  {
55  m_net = aParentLine.Net();
56  m_layers = aParentLine.Layers();
57  m_marker = aParentLine.Marker();
58  m_rank = aParentLine.Rank();
59  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
LAYER_RANGE m_layers
Definition: pns_item.h:362
int m_rank
Definition: pns_item.h:367
ITEM(PnsKind aKind)
Definition: pns_item.h:70
int m_marker
Definition: pns_item.h:366
int m_net
Definition: pns_item.h:365

Member Function Documentation

virtual VECTOR2I PNS::SEGMENT::Anchor ( int  n) const
inlineoverridevirtual

Reimplemented from PNS::ITEM.

Definition at line 116 of file pns_segment.h.

References SEG::A, SEG::B, SHAPE_SEGMENT::GetSeg(), and m_seg.

Referenced by PNS::TOPOLOGY::AssembleDiffPair().

117  {
118  if( n == 0 )
119  return m_seg.GetSeg().A;
120  else
121  return m_seg.GetSeg().B;
122  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
const SEG & GetSeg() const
Definition: shape_segment.h:70
VECTOR2I A
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:45
virtual int PNS::SEGMENT::AnchorCount ( ) const
inlineoverridevirtual

Reimplemented from PNS::ITEM.

Definition at line 124 of file pns_segment.h.

125  {
126  return 2;
127  }
bool PNS::ITEM::BelongsTo ( NODE aNode) const
inlineinherited

Function BelongsTo()

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

Definition at line 251 of file pns_item.h.

References PNS::ITEM::m_owner.

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

252  {
253  return m_owner == aNode;
254  }
NODE * m_owner
Definition: pns_item.h:361
static bool PNS::SEGMENT::ClassOf ( const ITEM aItem)
inlinestatic

Definition at line 61 of file pns_segment.h.

References Clone(), PNS::ITEM::Kind(), and PNS::ITEM::SEGMENT_T.

62  {
63  return aItem && SEGMENT_T == aItem->Kind();
64  }
const SHAPE_LINE_CHAIN PNS::SEGMENT::CLine ( ) const
inline

Definition at line 98 of file pns_segment.h.

References SEG::A, SEG::B, SHAPE_SEGMENT::GetSeg(), and m_seg.

99  {
100  return SHAPE_LINE_CHAIN( m_seg.GetSeg().A, m_seg.GetSeg().B );
101  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
const SEG & GetSeg() const
Definition: shape_segment.h:70
Class SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:45
SEGMENT * PNS::SEGMENT::Clone ( ) const
overridevirtual

Function Clone()

Returns a deep copy of the item

Implements PNS::ITEM.

Definition at line 122 of file pns_line.cpp.

References PNS::ITEM::m_layers, PNS::ITEM::m_marker, PNS::ITEM::m_net, PNS::ITEM::m_rank, and m_seg.

Referenced by ClassOf().

123 {
124  SEGMENT* s = new SEGMENT;
125 
126  s->m_seg = m_seg;
127  s->m_net = m_net;
128  s->m_layers = m_layers;
129  s->m_marker = m_marker;
130  s->m_rank = m_rank;
131 
132  return s;
133 }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
LAYER_RANGE m_layers
Definition: pns_item.h:362
int m_rank
Definition: pns_item.h:367
int m_marker
Definition: pns_item.h:366
int m_net
Definition: pns_item.h:365
bool PNS::ITEM::Collide ( const ITEM aOther,
int  aClearance,
bool  aNeedMTV,
VECTOR2I aMTV,
bool  aDifferentNetsOnly = true 
) const
virtualinherited

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 PNS::ITEM::collideSimple(), PNS::LINE::EndsWithVia(), PNS::ITEM::LINE_T, PNS::ITEM::m_kind, PNS::LINE::Via(), and PNS::LINE::Width().

Referenced by PNS::NODE::CheckColliding(), PNS::ITEM::Collide(), PNS::OPTIMIZER::CACHE_VISITOR::operator()(), PNS::NODE::DEFAULT_OBSTACLE_VISITOR::operator()(), and PNS::ITEM::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
inlineinherited

Function Collide()

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

Definition at line 285 of file pns_item.h.

References PNS::ITEM::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...
const SHAPE_LINE_CHAIN PNS::SEGMENT::Hull ( int  aClearance,
int  aWalkaroundThickness 
) const
overridevirtual

Reimplemented from PNS::ITEM.

Definition at line 270 of file pns_line.cpp.

References PNS::SegmentHull().

Referenced by SwapEnds().

271 {
272  return SegmentHull( m_seg, aClearance, aWalkaroundThickness );
273 }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
const SHAPE_LINE_CHAIN SegmentHull(const SHAPE_SEGMENT &aSeg, int aClearance, int aWalkaroundThickness)
Definition: pns_utils.cpp:53
bool PNS::ITEM::IsLocked ( ) const
inlineinherited

Definition at line 338 of file pns_item.h.

References PNS::ITEM::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
inlineinherited

Definition at line 348 of file pns_item.h.

References PNS::ITEM::collideSimple(), and PNS::ITEM::m_routable.

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

Function KindStr()

Returns the kind of the item, as string

Definition at line 63 of file pns_item.cpp.

References PNS::ITEM::JOINT_T, PNS::ITEM::LINE_T, PNS::ITEM::m_kind, PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

Referenced by PNS::ITEM::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
int PNS::SEGMENT::Layer ( ) const
inlineoverridevirtual

Function Layer()

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

Reimplemented from PNS::ITEM.

Definition at line 78 of file pns_segment.h.

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

79  {
80  return Layers().Start();
81  }
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
inlineinherited

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 PNS::ITEM::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)
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 303 of file pns_item.h.

References PNS::ITEM::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
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 313 of file pns_item.h.

References PNS::ITEM::m_marker.

Referenced by PNS::ITEM::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
inlineinherited

Function Owner()

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

Definition at line 261 of file pns_item.h.

References PNS::ITEM::Collide(), and PNS::ITEM::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
inlineinherited

Function Parent()

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

Definition at line 159 of file pns_item.h.

References PNS::ITEM::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
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 323 of file pns_item.h.

References PNS::ITEM::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::SEGMENT::SetEnds ( const VECTOR2I a,
const VECTOR2I b 
)
inline

Definition at line 103 of file pns_segment.h.

References m_seg, and SHAPE_SEGMENT::SetSeg().

104  {
105  m_seg.SetSeg( SEG ( a, b ) );
106  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
void SetSeg(const SEG &aSeg)
Definition: shape_segment.h:65
Definition: seg.h:36
void PNS::SEGMENT::SetLayer ( int  aLayer)
inline

Definition at line 73 of file pns_segment.h.

References PNS::ITEM::SetLayers().

74  {
75  SetLayers( LAYER_RANGE( aLayer ) );
76  }
void SetLayers(const LAYER_RANGE &aLayers)
Function SetLayers()
Definition: pns_item.h:189
Class LAYER_RANGE.
Definition: pns_layerset.h:32
void PNS::ITEM::SetLayers ( const LAYER_RANGE aLayers)
inlineinherited

Function SetLayers()

Sets the layers spanned by the item to aLayers.

Definition at line 189 of file pns_item.h.

References PNS::ITEM::m_layers.

Referenced by PNS::TOPOLOGY::AssembleDiffPair(), PNS::NODE::AssembleLine(), PNS::VIA::Clone(), 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)
inlineinherited
void PNS::ITEM::SetOwner ( NODE aOwner)
inlineinherited

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 PNS::ITEM::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)
inlineinherited

Function SetParent()

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

Definition at line 149 of file pns_item.h.

References PNS::ITEM::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)
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 318 of file pns_item.h.

References PNS::ITEM::m_rank.

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

Definition at line 343 of file pns_item.h.

References PNS::ITEM::m_routable.

344  {
345  m_routable = aRoutable;
346  }
bool m_routable
Definition: pns_item.h:368
void PNS::SEGMENT::SetWidth ( int  aWidth)
inline

Definition at line 83 of file pns_segment.h.

References m_seg, and SHAPE_SEGMENT::SetWidth().

84  {
85  m_seg.SetWidth(aWidth);
86  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
void SetWidth(int aWidth)
Definition: shape_segment.h:75
const SHAPE* PNS::SEGMENT::Shape ( ) const
inlineoverridevirtual

Function Shape()

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

Reimplemented from PNS::ITEM.

Definition at line 68 of file pns_segment.h.

References m_seg.

69  {
70  return static_cast<const SHAPE*>( &m_seg );
71  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
Class SHAPE.
Definition: shape.h:58
void PNS::SEGMENT::SwapEnds ( )
inline

Definition at line 108 of file pns_segment.h.

References SEG::A, SEG::B, SHAPE_SEGMENT::GetSeg(), Hull(), m_seg, and SHAPE_SEGMENT::SetSeg().

109  {
110  SEG tmp = m_seg.GetSeg();
111  m_seg.SetSeg( SEG (tmp.B , tmp.A ) );
112  }
SHAPE_SEGMENT m_seg
Definition: pns_segment.h:130
void SetSeg(const SEG &aSeg)
Definition: shape_segment.h:65
Definition: seg.h:36
const SEG & GetSeg() const
Definition: shape_segment.h:70
VECTOR2I A
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:45
virtual void PNS::ITEM::Unmark ( int  aMarker = -1)
inlinevirtualinherited

Reimplemented in PNS::LINE.

Definition at line 308 of file pns_item.h.

References PNS::ITEM::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
protectedinherited
bool PNS::ITEM::m_movable
protectedinherited
NODE* PNS::ITEM::m_owner
protectedinherited
BOARD_CONNECTED_ITEM* PNS::ITEM::m_parent
protectedinherited

Definition at line 360 of file pns_item.h.

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

bool PNS::ITEM::m_routable
protectedinherited

Definition at line 368 of file pns_item.h.

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

SHAPE_SEGMENT PNS::SEGMENT::m_seg
private

Definition at line 130 of file pns_segment.h.

Referenced by Anchor(), CLine(), Clone(), Seg(), SetEnds(), SetWidth(), Shape(), SwapEnds(), and Width().

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

Definition at line 56 of file pns_item.h.

Referenced by PNS::ITEM::ITEM().


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