KiCad PCB EDA Suite
PNS::MEANDER_PLACER_BASE Class Referenceabstract

Class MEANDER_PLACER_BASE. More...

#include <pns_meander_placer_base.h>

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

Public Types

enum  TUNING_STATUS { TOO_SHORT = 0, TOO_LONG, TUNED }
 

Result of the length tuning operation

More...
 

Public Member Functions

 MEANDER_PLACER_BASE (ROUTER *aRouter)
 
virtual ~MEANDER_PLACER_BASE ()
 
virtual const wxString TuningInfo () const =0
 Function TuningInfo() More...
 
virtual TUNING_STATUS TuningStatus () const =0
 Function TuningStatus() 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 CheckFit (MEANDER_SHAPE *aShape)
 Function CheckFit() More...
 
virtual bool Start (const VECTOR2I &aP, ITEM *aStartItem)=0
 Function Start() More...
 
virtual bool Move (const VECTOR2I &aP, ITEM *aEndItem)=0
 Function Move() More...
 
virtual bool FixRoute (const VECTOR2I &aP, ITEM *aEndItem)=0
 Function FixRoute() More...
 
virtual bool ToggleVia (bool aEnabled)
 Function ToggleVia() More...
 
virtual bool IsPlacingVia () const
 Function IsPlacingVia() More...
 
virtual bool SetLayer (int aLayer)
 Function SetLayer() More...
 
virtual const ITEM_SET Traces ()=0
 Function Traces() More...
 
virtual const VECTOR2ICurrentEnd () const =0
 Function CurrentEnd() More...
 
virtual const std::vector< int > CurrentNets () const =0
 Function CurrentNets() More...
 
virtual int CurrentLayer () const =0
 Function CurrentLayer() More...
 
virtual NODECurrentNode (bool aLoopsRemoved=false) const =0
 Function CurrentNode() 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

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

int m_currentWidth
 

width of the meandered trace(s)

More...
 
MEANDER_SETTINGS m_settings
 

meandering settings

More...
 
VECTOR2I m_currentEnd
 

current end point

More...
 

Detailed Description

Class MEANDER_PLACER_BASE.

Base class for Single trace & Differenial pair meandering tools, as both of them share a lot of code.

Definition at line 48 of file pns_meander_placer_base.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_PLACER_BASE::MEANDER_PLACER_BASE ( ROUTER aRouter)

Definition at line 28 of file pns_meander_placer_base.cpp.

References m_currentWidth.

28  :
29  PLACEMENT_ALGO( aRouter )
30 {
31  m_currentWidth = 0;
32 }
int m_currentWidth
width of the meandered trace(s)
PLACEMENT_ALGO(ROUTER *aRouter)
PNS::MEANDER_PLACER_BASE::~MEANDER_PLACER_BASE ( )
virtual

Definition at line 35 of file pns_meander_placer_base.cpp.

36 {
37 }

Member Function Documentation

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

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, 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
virtual bool PNS::MEANDER_PLACER_BASE::CheckFit ( MEANDER_SHAPE aShape)
inlinevirtual

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 in PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

Definition at line 118 of file pns_meander_placer_base.h.

Referenced by PNS::MEANDER_SHAPE::Fit().

119  {
120  return false;
121  }
int PNS::MEANDER_PLACER_BASE::compareWithTolerance ( int  aValue,
int  aExpected,
int  aTolerance = 0 
) const
protected

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 }
virtual const VECTOR2I& PNS::PLACEMENT_ALGO::CurrentEnd ( ) const
pure virtualinherited

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.

Implemented in PNS::LINE_PLACER, PNS::DIFF_PAIR_PLACER, PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

virtual int PNS::PLACEMENT_ALGO::CurrentLayer ( ) const
pure virtualinherited

Function CurrentLayer()

Returns the layer of currently routed track.

Implemented in PNS::LINE_PLACER, PNS::DIFF_PAIR_PLACER, PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

virtual const std::vector<int> PNS::PLACEMENT_ALGO::CurrentNets ( ) const
pure virtualinherited

Function CurrentNets()

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

Implemented in PNS::LINE_PLACER, PNS::DIFF_PAIR_PLACER, PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

virtual NODE* PNS::PLACEMENT_ALGO::CurrentNode ( bool  aLoopsRemoved = false) const
pure virtualinherited

Function CurrentNode()

Returns the most recent board state.

Implemented in PNS::LINE_PLACER, PNS::DIFF_PAIR_PLACER, PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

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 
)
protected

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 }
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()
int FindSegment(const VECTOR2I &aP) const
Function FindSegment()
Definition: seg.h:37
Class SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48
virtual bool PNS::PLACEMENT_ALGO::FixRoute ( const VECTOR2I aP,
ITEM aEndItem 
)
pure virtualinherited

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.

Implemented in PNS::DIFF_PAIR_PLACER, PNS::LINE_PLACER, PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

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  }
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
virtual

Function MeanderSettings()

Returns the current meandering configuration.

Returns
the settings

Definition at line 176 of file pns_meander_placer_base.cpp.

References 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
virtual bool PNS::PLACEMENT_ALGO::Move ( const VECTOR2I aP,
ITEM aEndItem 
)
pure virtualinherited

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).

Implemented in PNS::DIFF_PAIR_PLACER, PNS::LINE_PLACER, PNS::DP_MEANDER_PLACER, PNS::MEANDER_PLACER, and PNS::MEANDER_SKEW_PLACER.

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_BASE::SpacingStep ( int  aSign)
virtual

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 m_currentWidth, 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
virtual bool PNS::PLACEMENT_ALGO::Start ( const VECTOR2I aP,
ITEM aStartItem 
)
pure virtualinherited

Function Start()

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

Implemented in PNS::DIFF_PAIR_PLACER, PNS::LINE_PLACER, PNS::DP_MEANDER_PLACER, PNS::MEANDER_PLACER, and PNS::MEANDER_SKEW_PLACER.

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  }
virtual const ITEM_SET PNS::PLACEMENT_ALGO::Traces ( )
pure virtualinherited

Function Traces()

Returns all routed/tuned traces.

Implemented in PNS::LINE_PLACER, PNS::DIFF_PAIR_PLACER, PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

void PNS::MEANDER_PLACER_BASE::tuneLineLength ( MEANDERED_LINE aTuned,
int  aElongation 
)
protected

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, 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
virtual const wxString PNS::MEANDER_PLACER_BASE::TuningInfo ( ) const
pure virtual

Function TuningInfo()

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

Implemented in PNS::DP_MEANDER_PLACER, PNS::MEANDER_PLACER, and PNS::MEANDER_SKEW_PLACER.

Referenced by PNS_TUNE_STATUS_POPUP::UpdateStatus().

virtual TUNING_STATUS PNS::MEANDER_PLACER_BASE::TuningStatus ( ) const
pure virtual

Function TuningStatus()

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

Implemented in PNS::DP_MEANDER_PLACER, and PNS::MEANDER_PLACER.

Referenced by PNS_TUNE_STATUS_POPUP::UpdateStatus().

void PNS::MEANDER_PLACER_BASE::UpdateSettings ( const MEANDER_SETTINGS aSettings)
virtual

Definition at line 58 of file pns_meander_placer_base.cpp.

References 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

VECTOR2I PNS::MEANDER_PLACER_BASE::m_currentEnd
protected
int PNS::MEANDER_PLACER_BASE::m_currentWidth
protected

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