KiCad PCB EDA Suite
PNS::MEANDER_SKEW_PLACER Class Reference

Class MEANDER_SKEW_PLACER. More...

#include <pns_meander_skew_placer.h>

Inheritance diagram for PNS::MEANDER_SKEW_PLACER:
PNS::MEANDER_PLACER PNS::MEANDER_PLACER_BASE PNS::PLACEMENT_ALGO PNS::ALGO_BASE

Public Types

enum  TUNING_STATUS { TOO_SHORT = 0, TOO_LONG, TUNED }
 

Result of the length tuning operation

More...
 

Public Member Functions

 MEANDER_SKEW_PLACER (ROUTER *aRouter)
 
 ~MEANDER_SKEW_PLACER ()
 
bool Start (const VECTOR2I &aP, ITEM *aStartItem) override
 Function Start() More...
 
bool Move (const VECTOR2I &aP, ITEM *aEndItem) override
 Function Move() More...
 
const wxString TuningInfo () const override
 Function TuningInfo() More...
 
virtual bool FixRoute (const VECTOR2I &aP, ITEM *aEndItem) override
 Function FixRoute() More...
 
NODECurrentNode (bool aLoopsRemoved=false) const override
 Function CurrentNode() More...
 
const ITEM_SET Traces () override
 Function Traces() More...
 
const VECTOR2ICurrentEnd () const override
 Function CurrentEnd() More...
 
const std::vector< int > CurrentNets () const override
 Function CurrentNets() More...
 
int CurrentLayer () const override
 Function CurrentLayer() More...
 
virtual TUNING_STATUS TuningStatus () const override
 Function TuningStatus() More...
 
bool CheckFit (MEANDER_SHAPE *aShape) override
 Function CheckFit() More...
 
virtual void AmplitudeStep (int aSign)
 Function AmplitudeStep() More...
 
virtual void SpacingStep (int aSign)
 Function SpacingStep() More...
 
virtual const MEANDER_SETTINGSMeanderSettings () const
 Function MeanderSettings() More...
 
virtual void UpdateSettings (const MEANDER_SETTINGS &aSettings)
 
virtual bool ToggleVia (bool aEnabled)
 Function ToggleVia() More...
 
virtual bool IsPlacingVia () const
 Function IsPlacingVia() More...
 
virtual bool SetLayer (int aLayer)
 Function SetLayer() More...
 
virtual void FlipPosture ()
 Function FlipPosture() More...
 
virtual void UpdateSizes (const SIZES_SETTINGS &aSizes)
 Function UpdateSizes() More...
 
virtual void SetOrthoMode (bool aOrthoMode)
 Function SetOrthoMode() More...
 
virtual void GetModifiedNets (std::vector< int > &aNets) const
 Function GetModifiedNets. More...
 
ROUTERRouter () const
 

Returns the instance of our router

More...
 
ROUTING_SETTINGSSettings () const
 

Returns current router settings

More...
 
virtual LOGGERLogger ()
 

Returns the logger object, allowing to dump geometry to a file.

More...
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Function SetDebugDecorator. More...
 
DEBUG_DECORATORDbg () const
 

Protected Member Functions

bool doMove (const VECTOR2I &aP, ITEM *aEndItem, int aTargetLength)
 
void setWorld (NODE *aWorld)
 
void cutTunedLine (const SHAPE_LINE_CHAIN &aOrigin, const VECTOR2I &aTuneStart, const VECTOR2I &aCursorPos, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aTuned, SHAPE_LINE_CHAIN &aPost)
 Function cutTunedLine() More...
 
void tuneLineLength (MEANDERED_LINE &aTuned, int aElongation)
 Function tuneLineLength() More...
 
int compareWithTolerance (int aValue, int aExpected, int aTolerance=0) const
 Function compareWithTolerance() More...
 

Protected Attributes

NODEm_world
 

pointer to world to search colliding items

More...
 
VECTOR2I m_currentStart
 

current routing start point (end of tail, beginning of head)

More...
 
NODEm_currentNode
 

Current world state

More...
 
LINE m_originLine
 
LINE m_currentTrace
 
SHAPE_LINE_CHAIN m_finalShape
 
MEANDERED_LINE m_result
 
SEGMENTm_initialSegment
 
int m_lastLength
 
TUNING_STATUS m_lastStatus
 
int m_currentWidth
 

width of the meandered trace(s)

More...
 
MEANDER_SETTINGS m_settings
 

meandering settings

More...
 
VECTOR2I m_currentEnd
 

current end point

More...
 

Private Member Functions

int currentSkew () const
 
int itemsetLength (const ITEM_SET &aSet) const
 
int origPathLength () const override
 

Private Attributes

DIFF_PAIR m_originPair
 
ITEM_SET m_tunedPath
 
ITEM_SET m_tunedPathP
 
ITEM_SET m_tunedPathN
 
int m_coupledLength
 

Detailed Description

Class MEANDER_SKEW_PLACER.

Differential pair skew adjustment algorithm.

Definition at line 39 of file pns_meander_skew_placer.h.

Member Enumeration Documentation

Result of the length tuning operation

Enumerator
TOO_SHORT 
TOO_LONG 
TUNED 

Definition at line 52 of file pns_meander_placer_base.h.

Constructor & Destructor Documentation

PNS::MEANDER_SKEW_PLACER::MEANDER_SKEW_PLACER ( ROUTER aRouter)

Definition at line 34 of file pns_meander_skew_placer.cpp.

References m_coupledLength.

34  :
35  MEANDER_PLACER ( aRouter )
36 {
37  // Init temporary variables (do not leave uninitialized members)
38  m_coupledLength = 0;
39 }
MEANDER_PLACER(ROUTER *aRouter)
PNS::MEANDER_SKEW_PLACER::~MEANDER_SKEW_PLACER ( )

Definition at line 42 of file pns_meander_skew_placer.cpp.

43 {
44 }

Member Function Documentation

void PNS::MEANDER_PLACER_BASE::AmplitudeStep ( int  aSign)
virtualinherited

Function AmplitudeStep()

Increases/decreases the current meandering amplitude by one step.

Parameters
aSigndirection (negative = decrease, positive = increase).

Definition at line 40 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_SETTINGS::m_maxAmplitude, PNS::MEANDER_SETTINGS::m_minAmplitude, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_step, and max.

Referenced by LENGTH_TUNER_TOOL::performTuning().

41 {
42  int a = m_settings.m_maxAmplitude + aSign * m_settings.m_step;
44 
46 }
int m_minAmplitude
minimum meandering amplitude
Definition: pns_meander.h:76
int m_step
amplitude/spacing adjustment step
Definition: pns_meander.h:82
MEANDER_SETTINGS m_settings
meandering settings
#define max(a, b)
Definition: auxiliary.h:86
int m_maxAmplitude
maximum meandering amplitude
Definition: pns_meander.h:78
bool PNS::MEANDER_PLACER::CheckFit ( MEANDER_SHAPE aShape)
overridevirtualinherited

Function CheckFit()

Checks if it's ok to place the shape aShape (i.e. if it doesn't cause DRC violations or collide with other meanders).

Parameters
aShapethe shape to check
Returns
true if the shape fits

Reimplemented from PNS::MEANDER_PLACER_BASE.

Definition at line 204 of file pns_meander_placer.cpp.

References PNS::NODE::CheckColliding(), PNS::MEANDERED_LINE::CheckSelfIntersections(), PNS::MEANDER_SHAPE::CLine(), PNS::MEANDER_PLACER::m_currentNode, PNS::MEANDER_PLACER::m_originLine, PNS::MEANDER_PLACER::m_result, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_spacing, and PNS::MEANDER_SHAPE::Width().

205 {
206  LINE l( m_originLine, aShape->CLine( 0 ) );
207 
208  if( m_currentNode->CheckColliding( &l ) )
209  return false;
210 
211  int w = aShape->Width();
212  int clearance = w + m_settings.m_spacing;
213 
214  return m_result.CheckSelfIntersections( aShape, clearance );
215 }
const SHAPE_LINE_CHAIN & CLine() const
Const accessor to the underlying shape
Definition: pns_line.h:123
bool CheckSelfIntersections(MEANDER_SHAPE *aShape, int aClearance)
Function CheckSelfIntersections()
MEANDER_SETTINGS m_settings
meandering settings
NODE * m_currentNode
Current world state
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Function CheckColliding()
Definition: pns_node.cpp:427
int m_spacing
meandering period/spacing (see dialog picture for explanation)
Definition: pns_meander.h:80
int PNS::MEANDER_PLACER_BASE::compareWithTolerance ( int  aValue,
int  aExpected,
int  aTolerance = 0 
) const
protectedinherited

Function compareWithTolerance()

Compares aValue against aExpected with given tolerance.

Definition at line 182 of file pns_meander_placer_base.cpp.

Referenced by PNS::MEANDER_PLACER::doMove(), and PNS::DP_MEANDER_PLACER::Move().

183 {
184  if( aValue < aExpected - aTolerance )
185  return -1;
186  else if( aValue > aExpected + aTolerance )
187  return 1;
188  else
189  return 0;
190 }
const VECTOR2I & PNS::MEANDER_PLACER::CurrentEnd ( ) const
overridevirtualinherited

Function CurrentEnd()

Returns the current end of the line(s) being placed/tuned. It may not be equal to the cursor position due to collisions.

Implements PNS::PLACEMENT_ALGO.

Definition at line 225 of file pns_meander_placer.cpp.

References PNS::MEANDER_PLACER_BASE::m_currentEnd.

226 {
227  return m_currentEnd;
228 }
VECTOR2I m_currentEnd
current end point
int PNS::MEANDER_PLACER::CurrentLayer ( ) const
overridevirtualinherited

Function CurrentLayer()

Returns the layer of currently routed track.

Implements PNS::PLACEMENT_ALGO.

Definition at line 230 of file pns_meander_placer.cpp.

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

231 {
232  return m_initialSegment->Layers().Start();
233 }
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
int Start() const
Definition: pns_layerset.h:83
const std::vector<int> PNS::MEANDER_PLACER::CurrentNets ( ) const
inlineoverridevirtualinherited

Function CurrentNets()

Returns the net code(s) of currently routed track(s).

Implements PNS::PLACEMENT_ALGO.

Definition at line 74 of file pns_meander_placer.h.

References PNS::MEANDER_PLACER::m_originLine, and PNS::ITEM::Net().

75  {
76  return std::vector<int> (1, m_originLine.Net() );
77  }
int Net() const
Function Net()
Definition: pns_item.h:177
NODE * PNS::MEANDER_PLACER::CurrentNode ( bool  aLoopsRemoved = false) const
overridevirtualinherited

Function CurrentNode()

Returns the most recent board state.

Implements PNS::PLACEMENT_ALGO.

Definition at line 51 of file pns_meander_placer.cpp.

References PNS::MEANDER_PLACER::m_currentNode, and PNS::MEANDER_PLACER::m_world.

52 {
53  if( !m_currentNode )
54  return m_world;
55 
56  return m_currentNode;
57 }
NODE * m_world
pointer to world to search colliding items
NODE * m_currentNode
Current world state
int PNS::MEANDER_SKEW_PLACER::currentSkew ( ) const
private
void PNS::MEANDER_PLACER_BASE::cutTunedLine ( const SHAPE_LINE_CHAIN aOrigin,
const VECTOR2I aTuneStart,
const VECTOR2I aCursorPos,
SHAPE_LINE_CHAIN aPre,
SHAPE_LINE_CHAIN aTuned,
SHAPE_LINE_CHAIN aPost 
)
protectedinherited

Function cutTunedLine()

Extracts the part of a track to be meandered, depending on the starting point and the cursor position.

Parameters
aOriginthe original line
aTuneStartpoint where we start meandering (start click coorinates)
aCursorPoscurrent cursor position
aPrepart before the beginning of meanders
aTunedpart to be meandered
aPostpart after the end of meanders

Definition at line 64 of file pns_meander_placer_base.cpp.

References SEG::A, SEG::B, SHAPE_LINE_CHAIN::CSegment(), SHAPE_LINE_CHAIN::Find(), SHAPE_LINE_CHAIN::FindSegment(), SHAPE_LINE_CHAIN::NearestPoint(), SHAPE_LINE_CHAIN::Reverse(), SHAPE_LINE_CHAIN::Simplify(), SHAPE_LINE_CHAIN::Slice(), and SHAPE_LINE_CHAIN::Split().

Referenced by PNS::MEANDER_PLACER::doMove(), and PNS::DP_MEANDER_PLACER::Move().

70 {
71  VECTOR2I cp ( aCursorPos );
72 
73  if ( cp == aTuneStart ) // we don't like tuning segments with 0 length
74  {
75  int idx = aOrigin.FindSegment( cp );
76  if( idx >= 0 )
77  {
78  const SEG& s = aOrigin.CSegment( idx );
79  cp += (s.B - s.A).Resize(2);
80  } else
81  cp += VECTOR2I (2, 5); // some arbitrary value that is not 45 degrees oriented
82  }
83 
84  VECTOR2I n = aOrigin.NearestPoint( cp );
85  VECTOR2I m = aOrigin.NearestPoint( aTuneStart );
86 
87  SHAPE_LINE_CHAIN l( aOrigin );
88  l.Split( n );
89  l.Split( m );
90 
91  int i_start = l.Find( m );
92  int i_end = l.Find( n );
93 
94  if( i_start > i_end )
95  {
96  l = l.Reverse();
97  i_start = l.Find( m );
98  i_end = l.Find( n );
99  }
100 
101  aPre = l.Slice( 0, i_start );
102  aPost = l.Slice( i_end, -1 );
103  aTuned = l.Slice( i_start, i_end );
104 
105  aTuned.Simplify();
106 }
VECTOR2I & B
Definition: seg.h:52
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
const SEG CSegment(int aIndex) const
Function CSegment()
VECTOR2I & A
Definition: seg.h:51
int FindSegment(const VECTOR2I &aP) const
Function FindSegment()
Definition: seg.h:37
Class SHAPE_LINE_CHAIN.
bool PNS::MEANDER_PLACER::doMove ( const VECTOR2I aP,
ITEM aEndItem,
int  aTargetLength 
)
protectedinherited

Definition at line 113 of file pns_meander_placer.cpp.

References SEG::A, PNS::DEBUG_DECORATOR::AddLine(), SHAPE_LINE_CHAIN::Append(), SEG::B, PNS::NODE::Branch(), PNS::ITEM_SET::CItems(), SHAPE_LINE_CHAIN::Clear(), PNS::LINE::CLine(), PNS::MEANDER_PLACER_BASE::compareWithTolerance(), PNS::MEANDER_PLACER_BASE::cutTunedLine(), PNS::ALGO_BASE::Dbg(), PNS::MEANDER_PLACER::m_currentNode, PNS::MEANDER_PLACER::m_currentStart, PNS::MEANDER_PLACER::m_finalShape, PNS::MEANDER_PLACER::m_lastLength, PNS::MEANDER_PLACER::m_lastStatus, PNS::MEANDER_SETTINGS::m_lengthTolerance, PNS::MEANDER_PLACER::m_originLine, PNS::MEANDER_PLACER::m_result, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_PLACER::m_tunedPath, PNS::MEANDER_PLACER::m_world, PNS::MT_EMPTY, PNS::MEANDER_PLACER::origPathLength(), SHAPE_LINE_CHAIN::Simplify(), PNS::MEANDER_PLACER_BASE::TOO_LONG, PNS::MEANDER_PLACER_BASE::TOO_SHORT, PNS::MEANDER_PLACER_BASE::TUNED, PNS::MEANDER_PLACER_BASE::tuneLineLength(), and PNS::LINE::Width().

Referenced by Move(), and PNS::MEANDER_PLACER::Move().

114 {
115  SHAPE_LINE_CHAIN pre, tuned, post;
116 
117  if( m_currentNode )
118  delete m_currentNode;
119 
121 
122  cutTunedLine( m_originLine.CLine(), m_currentStart, aP, pre, tuned, post );
123 
124  m_result = MEANDERED_LINE( this, false );
125  m_result.SetWidth( m_originLine.Width() );
126  m_result.SetBaselineOffset( 0 );
127 
128  for( int i = 0; i < tuned.SegmentCount(); i++ )
129  {
130  const SEG s = tuned.CSegment( i );
131  m_result.AddCorner( s.A );
132  m_result.MeanderSegment( s );
133  m_result.AddCorner( s.B );
134  }
135 
136  int lineLen = origPathLength();
137 
138  m_lastLength = lineLen;
140 
141  if( compareWithTolerance( lineLen, aTargetLength, m_settings.m_lengthTolerance ) > 0 )
142  {
144  } else {
145  m_lastLength = lineLen - tuned.Length();
146  tuneLineLength( m_result, aTargetLength - lineLen );
147  }
148 
149  for( const ITEM* item : m_tunedPath.CItems() )
150  {
151  if( const LINE* l = dyn_cast<const LINE*>( item ) )
152  {
153  Dbg()->AddLine( l->CLine(), 5, 30000 );
154  }
155  }
156 
157  if( m_lastStatus != TOO_LONG )
158  {
159  tuned.Clear();
160 
161  for( MEANDER_SHAPE* m : m_result.Meanders() )
162  {
163  if( m->Type() != MT_EMPTY )
164  {
165  tuned.Append ( m->CLine( 0 ) );
166  }
167  }
168 
169  m_lastLength += tuned.Length();
170 
171  int comp = compareWithTolerance( m_lastLength - aTargetLength, 0, m_settings.m_lengthTolerance );
172 
173  if( comp > 0 )
175  else if( comp < 0 )
177  else
179  }
180 
182  m_finalShape.Append( pre );
183  m_finalShape.Append( tuned );
184  m_finalShape.Append( post );
186 
187  return true;
188 }
const SHAPE_LINE_CHAIN & CLine() const
Const accessor to the underlying shape
Definition: pns_line.h:123
VECTOR2I & B
Definition: seg.h:52
const ENTRIES & CItems() const
Definition: pns_itemset.h:138
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:70
TUNING_STATUS m_lastStatus
virtual int origPathLength() const
int Width() const
Returns line width
Definition: pns_line.h:159
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:109
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
virtual void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType=0, int aWidth=0)
VECTOR2I & A
Definition: seg.h:51
void tuneLineLength(MEANDERED_LINE &aTuned, int aElongation)
Function tuneLineLength()
Definition: seg.h:37
int compareWithTolerance(int aValue, int aExpected, int aTolerance=0) const
Function compareWithTolerance()
VECTOR2I m_currentStart
current routing start point (end of tail, beginning of head)
NODE * m_world
pointer to world to search colliding items
MEANDER_SETTINGS m_settings
meandering settings
int m_lengthTolerance
allowable tuning error
Definition: pns_meander.h:90
NODE * m_currentNode
Current world state
Class SHAPE_LINE_CHAIN.
void Clear()
Function Clear() Removes all points from the line chain.
SHAPE_LINE_CHAIN m_finalShape
void cutTunedLine(const SHAPE_LINE_CHAIN &aOrigin, const VECTOR2I &aTuneStart, const VECTOR2I &aCursorPos, SHAPE_LINE_CHAIN &aPre, SHAPE_LINE_CHAIN &aTuned, SHAPE_LINE_CHAIN &aPost)
Function cutTunedLine()
bool PNS::MEANDER_PLACER::FixRoute ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtualinherited

Function FixRoute()

Commits the currently routed items to the parent node, taking aP as the final end point and aEndItem as the final anchor (if provided).

Returns
true, if route has been commited. May return false if the routing result is violating design rules - in such case, the track is only committed if Settings.CanViolateDRC() is on.

Implements PNS::PLACEMENT_ALGO.

Definition at line 191 of file pns_meander_placer.cpp.

References PNS::NODE::Add(), PNS::ROUTER::CommitRouting(), PNS::MEANDER_PLACER::m_currentNode, PNS::MEANDER_PLACER::m_currentTrace, PNS::MEANDER_PLACER::m_finalShape, PNS::MEANDER_PLACER::m_originLine, and PNS::ALGO_BASE::Router().

192 {
193  if( !m_currentNode )
194  return false;
195 
198 
200  return true;
201 }
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:324
NODE * m_currentNode
Current world state
SHAPE_LINE_CHAIN m_finalShape
void Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:596
virtual void PNS::PLACEMENT_ALGO::FlipPosture ( )
inlinevirtualinherited

Function FlipPosture()

Toggles the current posture (straight/diagonal) of the trace head.

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 152 of file pns_placement_algo.h.

153  {
154  }
virtual void PNS::PLACEMENT_ALGO::GetModifiedNets ( std::vector< int > &  aNets) const
inlinevirtualinherited

Function GetModifiedNets.

Returns the net codes of all currently routed trace(s)

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 183 of file pns_placement_algo.h.

184  {
185  }
virtual bool PNS::PLACEMENT_ALGO::IsPlacingVia ( ) const
inlinevirtualinherited

Function IsPlacingVia()

Returns true if the placer is placing a via (or more vias).

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 96 of file pns_placement_algo.h.

97  {
98  return false;
99  }
int PNS::MEANDER_SKEW_PLACER::itemsetLength ( const ITEM_SET aSet) const
private

Definition at line 108 of file pns_meander_skew_placer.cpp.

References PNS::ITEM_SET::CItems().

Referenced by origPathLength(), and Start().

109 {
110  int total = 0;
111  for( const ITEM* item : aSet.CItems() )
112  {
113  if( const LINE* l = dyn_cast<const LINE*>( item ) )
114  {
115  total += l->CLine().Length();
116  }
117  }
118 
119  return total;
120 }
LOGGER * PNS::ALGO_BASE::Logger ( )
virtualinherited

Returns the logger object, allowing to dump geometry to a file.

Reimplemented in PNS::LINE_PLACER, PNS::WALKAROUND, PNS::DRAGGER, and PNS::SHOVE.

Definition at line 34 of file pns_algo_base.cpp.

35 {
36  return NULL;
37 }
const MEANDER_SETTINGS & PNS::MEANDER_PLACER_BASE::MeanderSettings ( ) const
virtualinherited

Function MeanderSettings()

Returns the current meandering configuration.

Returns
the settings

Definition at line 176 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_PLACER_BASE::m_settings.

Referenced by PNS::MEANDER_SHAPE::makeMiterShape(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), PNS::MEANDER_SHAPE::Settings(), and PNS::MEANDERED_LINE::Settings().

177 {
178  return m_settings;
179 }
MEANDER_SETTINGS m_settings
meandering settings
bool PNS::MEANDER_SKEW_PLACER::Move ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtual

Function Move()

Moves the end of the currently routed primtive(s) to the point aP, taking aEndItem as the anchor (if not NULL). (unless NULL).

Reimplemented from PNS::MEANDER_PLACER.

Definition at line 129 of file pns_meander_skew_placer.cpp.

References PNS::DEBUG_DECORATOR::AddLine(), PNS::ITEM_SET::CItems(), PNS::ALGO_BASE::Dbg(), PNS::MEANDER_PLACER::doMove(), m_coupledLength, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_targetSkew, m_tunedPathN, and m_tunedPathP.

130 {
131  for( const ITEM* item : m_tunedPathP.CItems() )
132  {
133  if( const LINE* l = dyn_cast<const LINE*>( item ) )
134  Dbg()->AddLine( l->CLine(), 5, 10000 );
135  }
136 
137  for( const ITEM* item : m_tunedPathN.CItems() )
138  {
139  if( const LINE* l = dyn_cast<const LINE*>( item ) )
140  Dbg()->AddLine( l->CLine(), 4, 10000 );
141  }
142 
143  return doMove( aP, aEndItem, m_coupledLength + m_settings.m_targetSkew );
144 }
const ENTRIES & CItems() const
Definition: pns_itemset.h:138
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:70
int m_targetSkew
target skew value for diff pair de-skewing
Definition: pns_meander.h:94
virtual void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType=0, int aWidth=0)
bool doMove(const VECTOR2I &aP, ITEM *aEndItem, int aTargetLength)
MEANDER_SETTINGS m_settings
meandering settings
int PNS::MEANDER_SKEW_PLACER::origPathLength ( ) const
overrideprivatevirtual

Reimplemented from PNS::MEANDER_PLACER.

Definition at line 102 of file pns_meander_skew_placer.cpp.

References itemsetLength(), and m_tunedPath.

103 {
104  return itemsetLength ( m_tunedPath );
105 }
int itemsetLength(const ITEM_SET &aSet) const
void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

Function SetDebugDecorator.

Assign a debug decorator allowing this algo to draw extra graphics for visual debugging

Definition at line 65 of file pns_algo_base.h.

References PNS::ALGO_BASE::m_debugDecorator.

66  {
67  m_debugDecorator = aDecorator;
68  }
DEBUG_DECORATOR * m_debugDecorator
Definition: pns_algo_base.h:76
virtual bool PNS::PLACEMENT_ALGO::SetLayer ( int  aLayer)
inlinevirtualinherited

Function SetLayer()

Sets the current routing layer.

Reimplemented in PNS::DIFF_PAIR_PLACER, and PNS::LINE_PLACER.

Definition at line 106 of file pns_placement_algo.h.

107  {
108  return false;
109  }
virtual void PNS::PLACEMENT_ALGO::SetOrthoMode ( bool  aOrthoMode)
inlinevirtualinherited

Function SetOrthoMode()

Forces the router to place a straight 90/45 degree trace (with the end as near to the cursor as possible) instead of a standard 135 degree two-segment bend.

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 174 of file pns_placement_algo.h.

175  {
176  }
void PNS::MEANDER_PLACER::setWorld ( NODE aWorld)
protectedinherited
void PNS::MEANDER_PLACER_BASE::SpacingStep ( int  aSign)
virtualinherited

Function SpacingStep()

Increases/decreases the current meandering spcing by one step.

Parameters
aSigndirection (negative = decrease, positive = increase).

Definition at line 49 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_PLACER_BASE::m_currentWidth, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_spacing, PNS::MEANDER_SETTINGS::m_step, and max.

Referenced by LENGTH_TUNER_TOOL::performTuning().

50 {
51  int s = m_settings.m_spacing + aSign * m_settings.m_step;
52  s = std::max( s, 2 * m_currentWidth );
53 
55 }
int m_currentWidth
width of the meandered trace(s)
int m_step
amplitude/spacing adjustment step
Definition: pns_meander.h:82
MEANDER_SETTINGS m_settings
meandering settings
#define max(a, b)
Definition: auxiliary.h:86
int m_spacing
meandering period/spacing (see dialog picture for explanation)
Definition: pns_meander.h:80
bool PNS::MEANDER_SKEW_PLACER::Start ( const VECTOR2I aP,
ITEM aStartItem 
)
overridevirtual

Function Start()

Starts placement/drag operation at point aP, taking item aStartItem as anchor (unless NULL).

Reimplemented from PNS::MEANDER_PLACER.

Definition at line 47 of file pns_meander_skew_placer.cpp.

References PNS::TOPOLOGY::AssembleDiffPair(), PNS::NODE::AssembleLine(), PNS::TOPOLOGY::AssembleTrivialPath(), PNS::NODE::Branch(), PNS::DIFF_PAIR::Gap(), PNS::LINE::GetLink(), PNS::ROUTER::GetWorld(), itemsetLength(), m_coupledLength, PNS::MEANDER_PLACER_BASE::m_currentEnd, PNS::MEANDER_PLACER::m_currentNode, PNS::MEANDER_PLACER::m_currentStart, PNS::MEANDER_PLACER_BASE::m_currentWidth, PNS::MEANDER_PLACER::m_initialSegment, PNS::MEANDER_PLACER::m_originLine, m_originPair, m_tunedPath, m_tunedPathN, m_tunedPathP, PNS::MEANDER_PLACER::m_world, SEG::NearestPoint(), PNS::ITEM::Net(), PNS::DIFF_PAIR::NLine(), PNS::ITEM::OfKind(), PNS::DIFF_PAIR::PLine(), PNS::NODE::Remove(), PNS::ALGO_BASE::Router(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::LINE::SegmentCount(), PNS::ROUTER::SetFailureReason(), PNS::DIFF_PAIR::SetGap(), and PNS::LINE::Width().

48 {
49  VECTOR2I p;
50 
51  if( !aStartItem || !aStartItem->OfKind( ITEM::SEGMENT_T ) )
52  {
53  Router()->SetFailureReason( _( "Please select a differential pair trace you want to tune." ) );
54  return false;
55  }
56 
57  m_initialSegment = static_cast<SEGMENT*>( aStartItem );
58 
59  p = m_initialSegment->Seg().NearestPoint( aP );
60 
61  m_currentNode = NULL;
62  m_currentStart = p;
63 
64  m_world = Router()->GetWorld( )->Branch();
66 
67  TOPOLOGY topo( m_world );
68  m_tunedPath = topo.AssembleTrivialPath( m_initialSegment );
69 
70  if( !topo.AssembleDiffPair ( m_initialSegment, m_originPair ) )
71  {
72  Router()->SetFailureReason( _( "Unable to find complementary differential pair "
73  "net for skew tuning. Make sure the names of the nets belonging "
74  "to a differential pair end with either _N/_P or +/-." ) );
75  return false;
76  }
77 
78  if( m_originPair.Gap() < 0 )
79  m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
80 
81  if( !m_originPair.PLine().SegmentCount() ||
83  return false;
84 
85  m_tunedPathP = topo.AssembleTrivialPath( m_originPair.PLine().GetLink( 0 ) );
86  m_tunedPathN = topo.AssembleTrivialPath( m_originPair.NLine().GetLink( 0 ) );
87 
89 
91  m_currentEnd = VECTOR2I( 0, 0 );
92 
93  if ( m_originPair.PLine().Net() == m_originLine.Net() )
95  else
97 
98  return true;
99 }
const LINE AssembleLine(SEGMENT *aSeg, int *aOriginSegmentIndex=NULL, bool aStopAtLockedJoints=false)
Function AssembleLine()
Definition: pns_node.cpp:834
VECTOR2I m_currentEnd
current end point
SEGMENT * GetLink(int aIndex) const
Definition: pns_line.h:203
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
int Width() const
Returns line width
Definition: pns_line.h:159
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:109
NODE * GetWorld() const
Definition: pns_router.h:134
int m_currentWidth
width of the meandered trace(s)
void SetGap(int aGap)
int SegmentCount() const
Returns the number of segments in the line
Definition: pns_line.h:129
int Gap() const
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:204
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
void Remove(SOLID *aSolid)
Function Remove()
Definition: pns_node.cpp:729
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
Definition: seg.h:397
VECTOR2I m_currentStart
current routing start point (end of tail, beginning of head)
NODE * m_world
pointer to world to search colliding items
NODE * m_currentNode
Current world state
int Net() const
Function Net()
Definition: pns_item.h:177
Struct SEGMENT is a simple container used when filling areas with segments.
Definition: class_zone.h:57
const SEG & Seg() const
Definition: pns_segment.h:93
int itemsetLength(const ITEM_SET &aSet) const
virtual bool PNS::PLACEMENT_ALGO::ToggleVia ( bool  aEnabled)
inlinevirtualinherited

Function ToggleVia()

Enables/disables a via at the end of currently routed trace.

Reimplemented in PNS::DIFF_PAIR_PLACER, and PNS::LINE_PLACER.

Definition at line 86 of file pns_placement_algo.h.

87  {
88  return false;
89  }
const ITEM_SET PNS::MEANDER_PLACER::Traces ( )
overridevirtualinherited

Function Traces()

Returns all routed/tuned traces.

Implements PNS::PLACEMENT_ALGO.

Definition at line 218 of file pns_meander_placer.cpp.

References PNS::MEANDER_PLACER::m_currentTrace, PNS::MEANDER_PLACER::m_finalShape, and PNS::MEANDER_PLACER::m_originLine.

219 {
221  return ITEM_SET( &m_currentTrace );
222 }
SHAPE_LINE_CHAIN m_finalShape
void PNS::MEANDER_PLACER_BASE::tuneLineLength ( MEANDERED_LINE aTuned,
int  aElongation 
)
protectedinherited

Function tuneLineLength()

Takes a set of meanders in aTuned and tunes their length to extend the original line length by aElongation.

Definition at line 109 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_SETTINGS::m_minAmplitude, PNS::MEANDER_PLACER_BASE::m_settings, max, PNS::MEANDERED_LINE::Meanders(), PNS::MT_CORNER, PNS::MT_EMPTY, PNS::MT_FINISH, PNS::MT_SINGLE, and PNS::MT_START.

Referenced by PNS::MEANDER_PLACER::doMove(), and PNS::DP_MEANDER_PLACER::Move().

110 {
111  int remaining = aElongation;
112  bool finished = false;
113 
114  for( MEANDER_SHAPE* m : aTuned.Meanders() )
115  {
116  if( m->Type() != MT_CORNER )
117  {
118  if( remaining >= 0 )
119  remaining -= m->MaxTunableLength() - m->BaselineLength();
120 
121  if( remaining < 0 )
122  {
123  if( !finished )
124  {
125  MEANDER_TYPE newType;
126 
127  if( m->Type() == MT_START || m->Type() == MT_SINGLE )
128  newType = MT_SINGLE;
129  else
130  newType = MT_FINISH;
131 
132  m->SetType( newType );
133  m->Recalculate();
134 
135  finished = true;
136  } else {
137  m->MakeEmpty();
138  }
139  }
140  }
141  }
142 
143  remaining = aElongation;
144  int meanderCount = 0;
145 
146  for(MEANDER_SHAPE* m : aTuned.Meanders())
147  {
148  if( m->Type() != MT_CORNER && m->Type() != MT_EMPTY )
149  {
150  if(remaining >= 0)
151  {
152  remaining -= m->MaxTunableLength() - m->BaselineLength();
153  meanderCount ++;
154  }
155  }
156  }
157 
158  int balance = 0;
159 
160  if( meanderCount )
161  balance = -remaining / meanderCount;
162 
163  if( balance >= 0 )
164  {
165  for( MEANDER_SHAPE* m : aTuned.Meanders() )
166  {
167  if( m->Type() != MT_CORNER && m->Type() != MT_EMPTY )
168  {
169  m->Resize( std::max( m->Amplitude() - balance / 2, m_settings.m_minAmplitude ) );
170  }
171  }
172  }
173 }
int m_minAmplitude
minimum meandering amplitude
Definition: pns_meander.h:76
MEANDER_TYPE
Shapes of available meanders.
Definition: pns_meander.h:35
MEANDER_SETTINGS m_settings
meandering settings
#define max(a, b)
Definition: auxiliary.h:86
const wxString PNS::MEANDER_SKEW_PLACER::TuningInfo ( ) const
overridevirtual

Function TuningInfo()

Returns a string describing the status and length of the tuned traces.

Reimplemented from PNS::MEANDER_PLACER.

Definition at line 147 of file pns_meander_skew_placer.cpp.

References LengthDoubleToString(), m_coupledLength, PNS::MEANDER_PLACER::m_lastLength, PNS::MEANDER_PLACER::m_lastStatus, PNS::MEANDER_PLACER_BASE::m_settings, PNS::MEANDER_SETTINGS::m_targetSkew, PNS::MEANDER_PLACER_BASE::TOO_LONG, PNS::MEANDER_PLACER_BASE::TOO_SHORT, and PNS::MEANDER_PLACER_BASE::TUNED.

148 {
149  wxString status;
150 
151  switch( m_lastStatus )
152  {
153  case TOO_LONG:
154  status = _( "Too long: skew " );
155  break;
156  case TOO_SHORT:
157  status = _( "Too short: skew " );
158  break;
159  case TUNED:
160  status = _( "Tuned: skew " );
161  break;
162  default:
163  return _( "?" );
164  }
165 
166  status += LengthDoubleToString( (double) m_lastLength - m_coupledLength, false );
167  status += "/";
168  status += LengthDoubleToString( (double) m_settings.m_targetSkew, false );
169 
170  return status;
171 }
TUNING_STATUS m_lastStatus
int m_targetSkew
target skew value for diff pair de-skewing
Definition: pns_meander.h:94
wxString LengthDoubleToString(double aValue, bool aConvertToMils)
Function LengthDoubleToString is a helper to convert the double length aValue to a string in inches...
Definition: base_units.cpp:122
MEANDER_SETTINGS m_settings
meandering settings
MEANDER_PLACER::TUNING_STATUS PNS::MEANDER_PLACER::TuningStatus ( ) const
overridevirtualinherited

Function TuningStatus()

Returns the tuning status (too short, too long, etc.) of the trace(s) being tuned.

Implements PNS::MEANDER_PLACER_BASE.

Definition at line 263 of file pns_meander_placer.cpp.

References PNS::MEANDER_PLACER::m_lastStatus.

264 {
265  return m_lastStatus;
266 }
TUNING_STATUS m_lastStatus
void PNS::MEANDER_PLACER_BASE::UpdateSettings ( const MEANDER_SETTINGS aSettings)
virtualinherited

Definition at line 58 of file pns_meander_placer_base.cpp.

References PNS::MEANDER_PLACER_BASE::m_settings.

Referenced by LENGTH_TUNER_TOOL::meanderSettingsDialog(), and LENGTH_TUNER_TOOL::performTuning().

59 {
60  m_settings = aSettings;
61 }
MEANDER_SETTINGS m_settings
meandering settings
virtual void PNS::PLACEMENT_ALGO::UpdateSizes ( const SIZES_SETTINGS aSizes)
inlinevirtualinherited

Function UpdateSizes()

Performs on-the-fly update of the width, via diameter & drill size from a settings class. Used to dynamically change these parameters as the track is routed.

Reimplemented in PNS::LINE_PLACER, and PNS::DIFF_PAIR_PLACER.

Definition at line 163 of file pns_placement_algo.h.

164  {
165  }

Member Data Documentation

int PNS::MEANDER_SKEW_PLACER::m_coupledLength
private

Definition at line 64 of file pns_meander_skew_placer.h.

Referenced by currentSkew(), MEANDER_SKEW_PLACER(), Move(), Start(), and TuningInfo().

VECTOR2I PNS::MEANDER_PLACER_BASE::m_currentEnd
protectedinherited
VECTOR2I PNS::MEANDER_PLACER::m_currentStart
protectedinherited

current routing start point (end of tail, beginning of head)

Definition at line 103 of file pns_meander_placer.h.

Referenced by PNS::MEANDER_PLACER::doMove(), Start(), and PNS::MEANDER_PLACER::Start().

LINE PNS::MEANDER_PLACER::m_currentTrace
protectedinherited
int PNS::MEANDER_PLACER_BASE::m_currentWidth
protectedinherited
SHAPE_LINE_CHAIN PNS::MEANDER_PLACER::m_finalShape
protectedinherited
SEGMENT* PNS::MEANDER_PLACER::m_initialSegment
protectedinherited
int PNS::MEANDER_PLACER::m_lastLength
protectedinherited
DIFF_PAIR PNS::MEANDER_SKEW_PLACER::m_originPair
private

Definition at line 61 of file pns_meander_skew_placer.h.

Referenced by Start().

MEANDERED_LINE PNS::MEANDER_PLACER::m_result
protectedinherited
ITEM_SET PNS::MEANDER_SKEW_PLACER::m_tunedPath
private

Definition at line 62 of file pns_meander_skew_placer.h.

Referenced by origPathLength(), and Start().

ITEM_SET PNS::MEANDER_SKEW_PLACER::m_tunedPathN
private

Definition at line 62 of file pns_meander_skew_placer.h.

Referenced by Move(), and Start().

ITEM_SET PNS::MEANDER_SKEW_PLACER::m_tunedPathP
private

Definition at line 62 of file pns_meander_skew_placer.h.

Referenced by Move(), and Start().

NODE* PNS::MEANDER_PLACER::m_world
protectedinherited

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