Code formatting.

This commit is contained in:
Maciej Suminski 2015-02-18 17:53:46 +01:00
parent 112adccbcb
commit 4fb9bce354
100 changed files with 3005 additions and 4238 deletions

View File

@ -29,35 +29,37 @@
#include <wx_status_popup.h>
#include <wxPcbStruct.h>
WX_STATUS_POPUP::WX_STATUS_POPUP ( PCB_EDIT_FRAME *parent ) :
wxPopupWindow ( parent )
WX_STATUS_POPUP::WX_STATUS_POPUP( PCB_EDIT_FRAME* aParent ) :
wxPopupWindow( aParent )
{
m_panel = new wxPanel( this, wxID_ANY );
m_panel->SetBackgroundColour( *wxLIGHT_GREY );
m_topSizer = new wxBoxSizer( wxVERTICAL );
m_panel->SetSizer( m_topSizer );
}
void WX_STATUS_POPUP::updateSize()
{
m_topSizer->Fit( m_panel );
SetClientSize( m_panel->GetSize() );
}
WX_STATUS_POPUP::~WX_STATUS_POPUP()
{
}
void WX_STATUS_POPUP::Popup(wxWindow *focus)
void WX_STATUS_POPUP::Popup( wxWindow* )
{
Show( true );
Raise();
}
void WX_STATUS_POPUP::Move( const wxPoint& aWhere )
{
SetPosition ( aWhere );
}

View File

@ -50,6 +50,7 @@ WX_UNIT_BINDER::~WX_UNIT_BINDER()
{
}
void WX_UNIT_BINDER::SetValue( int aValue )
{
wxString s = StringFromValue( m_units, aValue, false );
@ -59,6 +60,7 @@ void WX_UNIT_BINDER::SetValue( int aValue )
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units ) );
}
int WX_UNIT_BINDER::GetValue() const
{
wxString s = m_textCtrl->GetValue();
@ -66,6 +68,7 @@ int WX_UNIT_BINDER::GetValue() const
return ValueFromString( m_units, s );
}
void WX_UNIT_BINDER::Enable( bool aEnable )
{
m_textCtrl->Enable( aEnable );

View File

@ -257,7 +257,6 @@ public:
return cnt;
}
/**
* Function Collect
* scans an EDA_ITEM using this class's Inspector method, which does

View File

@ -50,7 +50,7 @@ public:
/**
* Function GetSize()
* Returns information about number of vertices stored.
* @param Number of vertices.
* @return Number of vertices.
*/
inline unsigned int GetSize() const
{

View File

@ -320,7 +320,6 @@ private:
int m_index;
};
inline VECTOR2I SEG::LineProject( const VECTOR2I& aP ) const
{
VECTOR2I d = B - A;
@ -337,7 +336,6 @@ inline VECTOR2I SEG::LineProject( const VECTOR2I& aP ) const
return A + VECTOR2I( xp, yp );
}
inline int SEG::LineDistance( const VECTOR2I& aP, bool aDetermineSide ) const
{
ecoord p = A.y - B.y;
@ -376,7 +374,6 @@ inline const VECTOR2I SEG::NearestPoint( const VECTOR2I& aP ) const
return A + VECTOR2I( xp, yp );
}
inline std::ostream& operator<<( std::ostream& aStream, const SEG& aSeg )
{
aStream << "[ " << aSeg.A << " - " << aSeg.B << " ]";

View File

@ -85,7 +85,6 @@ public:
HIDDEN = 0x02 /// Item is temporarily hidden (e.g. being used by a tool). Overrides VISIBLE flag.
};
VIEW_ITEM() : m_view( NULL ), m_flags( VISIBLE ), m_requiredUpdate( ALL ),
m_groups( NULL ), m_groupsSize( 0 ) {}
@ -148,6 +147,7 @@ public:
m_flags |= VISIBLE;
else
m_flags &= ~VISIBLE;
ViewUpdate( APPEARANCE | COLOR );
}
}

View File

@ -41,10 +41,10 @@ class PCB_EDIT_FRAME;
class WX_STATUS_POPUP: public wxPopupWindow
{
public:
WX_STATUS_POPUP ( PCB_EDIT_FRAME *parent );
WX_STATUS_POPUP( PCB_EDIT_FRAME* aParent );
virtual ~WX_STATUS_POPUP();
virtual void Popup(wxWindow *focus = NULL);
virtual void Popup(wxWindow* aFocus = NULL);
virtual void Move( const wxPoint &aWhere );
protected:

View File

@ -815,12 +815,14 @@ void MODULE::RunOnChildren( boost::function<void (BOARD_ITEM*)> aFunction )
}
}
const BOX2I MODULE::ViewBBox() const
{
return BOX2I( VECTOR2I( GetFootprintRect().GetOrigin() ),
VECTOR2I( GetFootprintRect().GetSize() ) );
}
void MODULE::ViewUpdate( int aUpdateFlags )
{
if( !m_view )
@ -1115,6 +1117,7 @@ void MODULE::SetOrientation( double newangle )
CalculateBoundingBox();
}
double MODULE::PadCoverageRatio() const
{
double padArea = 0.0;

View File

@ -263,6 +263,7 @@ public:
}
bool PadsLocked() const { return ( m_ModuleStatus & MODULE_PADS_LOCKED ); }
void SetPadsLocked( bool aPadsLocked )
{
if( aPadsLocked )

View File

@ -31,7 +31,6 @@ DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( wxWindow* aPar
m_traceGap( this, m_traceGapText, m_traceGapUnit ),
m_viaGap( this, m_viaGapText, m_viaGapUnit ),
m_sizes( aSizes )
{
m_traceWidth.SetValue( aSizes.DiffPairWidth() );
m_traceGap.SetValue( aSizes.DiffPairGap() );
@ -41,9 +40,9 @@ DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( wxWindow* aPar
updateCheckbox();
}
void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::updateCheckbox()
{
printf("Checked: %d", m_viaTraceGapEqual->GetValue());
if( m_viaTraceGapEqual->GetValue() )
{
m_sizes.SetDiffPairViaGapSameAsTraceGap( true );
@ -58,6 +57,7 @@ void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::updateCheckbox()
}
}
void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::OnClose( wxCloseEvent& aEvent )
{
// Do nothing, it is result of ESC pressing
@ -83,6 +83,7 @@ void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::OnCancelClick( wxCommandEvent& aEvent )
EndModal( 0 );
}
void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::OnViaTraceGapEqualCheck( wxCommandEvent& event )
{
event.Skip();

View File

@ -41,7 +41,6 @@ class DIALOG_PNS_DIFF_PAIR_DIMENSIONS : public DIALOG_PNS_DIFF_PAIR_DIMENSIONS_B
virtual void OnCancelClick( wxCommandEvent& aEvent );
virtual void OnViaTraceGapEqualCheck( wxCommandEvent& event );
private:
void updateCheckbox();

View File

@ -34,7 +34,6 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( wxWindow*
m_settings( aSettings ),
m_mode( aMode )
{
m_miterStyle->Enable( false );
m_radiusText->Enable( aMode != PNS_MODE_TUNE_DIFF_PAIR );
//m_minAmpl.Enable ( aMode != PNS_MODE_TUNE_DIFF_PAIR_SKEW );
@ -45,7 +44,6 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( wxWindow*
m_spacing.SetValue( m_settings.m_spacing );
m_radiusText->SetValue( wxString::Format( wxT( "%i" ), m_settings.m_cornerRadiusPercentage ) );
m_miterStyle->SetSelection( m_settings.m_cornerType == PNS_MEANDER_SETTINGS::ROUND ? 1 : 0 );
switch( aMode )
@ -54,14 +52,12 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( wxWindow*
SetTitle( _( "Single track length tuning" ) );
m_legend->SetBitmap( KiBitmap( tune_single_track_length_legend_xpm ) );
m_targetLength.SetValue( m_settings.m_targetLength );
break;
case PNS_MODE_TUNE_DIFF_PAIR:
SetTitle( _( "Differential pair length tuning" ) );
m_legend->SetBitmap( KiBitmap( tune_diff_pair_length_legend_xpm ) );
m_targetLength.SetValue( m_settings.m_targetLength );
break;
case PNS_MODE_TUNE_DIFF_PAIR_SKEW:
@ -90,7 +86,6 @@ void DIALOG_PNS_LENGTH_TUNING_SETTINGS::OnClose( wxCloseEvent& aEvent )
void DIALOG_PNS_LENGTH_TUNING_SETTINGS::OnOkClick( wxCommandEvent& aEvent )
{
// fixme: use validators and TransferDataFromWindow
m_settings.m_minAmplitude = m_minAmpl.GetValue();
m_settings.m_maxAmplitude = m_maxAmpl.GetValue();
@ -106,11 +101,8 @@ void DIALOG_PNS_LENGTH_TUNING_SETTINGS::OnOkClick( wxCommandEvent& aEvent )
if( m_settings.m_maxAmplitude < m_settings.m_minAmplitude )
m_settings.m_maxAmplitude = m_settings.m_maxAmplitude;
m_settings.m_cornerType = m_miterStyle->GetSelection() ? PNS_MEANDER_SETTINGS::CHAMFER : PNS_MEANDER_SETTINGS::ROUND;
EndModal( 1 );
}

View File

@ -43,7 +43,6 @@ class DIALOG_PNS_LENGTH_TUNING_SETTINGS : public DIALOG_PNS_LENGTH_TUNING_SETTIN
virtual void OnCancelClick( wxCommandEvent& aEvent );
private:
WX_UNIT_BINDER m_minAmpl;
WX_UNIT_BINDER m_maxAmpl;
WX_UNIT_BINDER m_spacing;

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,6 @@ class DIALOG_TRACK_VIA_SIZE : public DIALOG_TRACK_VIA_SIZE_BASE
DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings );
protected:
WX_UNIT_BINDER m_trackWidth;
WX_UNIT_BINDER m_viaDiameter;
WX_UNIT_BINDER m_viaDrill;

View File

@ -515,7 +515,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Configure Interactive Routing." ),
KiBitmap( add_tracks_xpm ) ); // fixme: icon
//--- dimensions submenu ------------------------------------------------------
wxMenu* dimensionsMenu = new wxMenu;

View File

@ -70,7 +70,6 @@
#include <tool/tool_dispatcher.h>
#include <tools/common_actions.h>
#include <scripting/python_console_frame.h>
#if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)

View File

@ -49,7 +49,6 @@ enum pcbnew_ids
ID_MENU_DIFF_PAIR_DIMENSIONS,
ID_MENU_INTERACTIVE_ROUTER_SETTINGS,
ID_PCB_MASK_CLEARANCE,
ID_PCB_LAYERS_SETUP,

View File

@ -1,7 +1,7 @@
/*
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2013-2014 CERN
* Copyright (C) 2013-2015 CERN
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
@ -320,7 +320,8 @@ private:
* Function construct()
* Calculates the direction from a vector. If the vector's angle is not a multiple of 45
* degrees, the direction is rounded to the nearest octant.
* @param aVec our vector */
* @param aVec our vector
*/
void construct_( const VECTOR2I& aVec )
{
m_dir = UNDEFINED;
@ -347,32 +348,6 @@ private:
m_dir = (Directions) dir;
return;
if( aVec.y < 0 )
{
if( aVec.x > 0 )
m_dir = NE;
else if( aVec.x < 0 )
m_dir = NW;
else
m_dir = N;
}
else if( aVec.y == 0 )
{
if( aVec.x > 0 )
m_dir = E;
else
m_dir = W;
}
else // aVec.y>0
{
if( aVec.x > 0 )
m_dir = SE;
else if( aVec.x < 0 )
m_dir = SW;
else
m_dir = S;
}
}
///> our actual direction

View File

@ -106,6 +106,7 @@ LENGTH_TUNER_TOOL::~LENGTH_TUNER_TOOL()
delete m_router;
}
void LENGTH_TUNER_TOOL::Reset( RESET_REASON aReason )
{
PNS_TOOL_BASE::Reset( aReason );
@ -147,6 +148,7 @@ void LENGTH_TUNER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent )
}
}
void LENGTH_TUNER_TOOL::performTuning()
{
bool saveUndoBuffer = true;
@ -177,7 +179,6 @@ void LENGTH_TUNER_TOOL::performTuning()
placer->UpdateSettings( m_savedMeanderSettings );
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->IsCancel() || evt->IsActivate() )
@ -209,16 +210,24 @@ void LENGTH_TUNER_TOOL::performTuning()
{
if( m_router->FixRoute( end, NULL ) )
break;
} else if (evt->IsAction ( &ACT_AmplDecrease ) ) {
}
else if( evt->IsAction( &ACT_AmplDecrease ) )
{
placer->AmplitudeStep( -1 );
m_router->Move( end, NULL );
} else if (evt->IsAction ( &ACT_AmplIncrease ) ) {
}
else if( evt->IsAction( &ACT_AmplIncrease ) )
{
placer->AmplitudeStep( 1 );
m_router->Move( end, NULL );
} else if (evt->IsAction ( &ACT_SpacingDecrease ) ) {
}
else if(evt->IsAction( &ACT_SpacingDecrease ) )
{
placer->SpacingStep( -1 );
m_router->Move( end, NULL );
} else if (evt->IsAction ( &ACT_SpacingIncrease ) ) {
}
else if( evt->IsAction( &ACT_SpacingIncrease ) )
{
placer->SpacingStep( 1 );
m_router->Move( end, NULL );
}
@ -244,21 +253,23 @@ void LENGTH_TUNER_TOOL::performTuning()
m_ctls->SetAutoPan( false );
m_ctls->ForceCursorPosition( false );
highlightNet( false );
}
int LENGTH_TUNER_TOOL::TuneSingleTrace( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Trace Length" ) );
return mainLoop( PNS_MODE_TUNE_SINGLE );
}
int LENGTH_TUNER_TOOL::TuneDiffPair( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Diff Pair Length" ) );
return mainLoop( PNS_MODE_TUNE_DIFF_PAIR );
}
int LENGTH_TUNER_TOOL::TuneDiffPairSkew( const TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Diff Pair Skew" ) );

View File

@ -41,10 +41,9 @@ public:
int ClearMeanders( const TOOL_EVENT& aEvent );
private:
void performTuning( );
int mainLoop( PNS_ROUTER_MODE aMode );
void handleCommonEvents( const TOOL_EVENT& evt );
void handleCommonEvents( const TOOL_EVENT& aEvent );
PNS_MEANDER_SETTINGS m_savedMeanderSettings;
};

View File

@ -33,8 +33,7 @@ class PNS_LOGGER;
*
* Base class for all P&S algorithms (shoving, walkaround, line placement, dragging, etc.)
* Holds a bunch of objects commonly used by all algorithms (P&S settings, parent router instance, logging)
**/
*/
class PNS_ALGO_BASE
{
public:
@ -56,7 +55,6 @@ public:
///> Returns the logger object, allowing to dump geometry to a file.
virtual PNS_LOGGER* Logger();
private:
PNS_ROUTER* m_router;
};

View File

@ -48,12 +48,14 @@ PNS_DP_PRIMITIVE_PAIR::PNS_DP_PRIMITIVE_PAIR ( PNS_ITEM *aPrimP, PNS_ITEM *aPrim
m_anchorN = m_primN->Anchor( 0 );
}
void PNS_DP_PRIMITIVE_PAIR::SetAnchors( const VECTOR2I& aAnchorP, const VECTOR2I& aAnchorN )
{
m_anchorP = aAnchorP;
m_anchorN = aAnchorN;
}
PNS_DP_PRIMITIVE_PAIR::PNS_DP_PRIMITIVE_PAIR( const VECTOR2I& aAnchorP, const VECTOR2I& aAnchorN )
{
m_anchorP = aAnchorP;
@ -61,6 +63,7 @@ PNS_DP_PRIMITIVE_PAIR::PNS_DP_PRIMITIVE_PAIR ( const VECTOR2I& aAnchorP, const V
m_primP = m_primN = NULL;
}
PNS_DP_PRIMITIVE_PAIR::PNS_DP_PRIMITIVE_PAIR( const PNS_DP_PRIMITIVE_PAIR& aOther )
{
if( aOther.m_primP )
@ -72,6 +75,7 @@ PNS_DP_PRIMITIVE_PAIR::PNS_DP_PRIMITIVE_PAIR ( const PNS_DP_PRIMITIVE_PAIR& aOth
m_anchorN = aOther.m_anchorN;
}
PNS_DP_PRIMITIVE_PAIR& PNS_DP_PRIMITIVE_PAIR::operator=( const PNS_DP_PRIMITIVE_PAIR& aOther )
{
if( aOther.m_primP )
@ -92,6 +96,7 @@ PNS_DP_PRIMITIVE_PAIR::~PNS_DP_PRIMITIVE_PAIR()
delete m_primN;
}
bool PNS_DP_PRIMITIVE_PAIR::Directional() const
{
if( !m_primP )
@ -100,6 +105,7 @@ bool PNS_DP_PRIMITIVE_PAIR::Directional() const
return m_primP->OfKind( PNS_ITEM::SEGMENT );
}
DIRECTION_45 PNS_DP_PRIMITIVE_PAIR::anchorDirection( PNS_ITEM* aItem, const VECTOR2I& aP ) const
{
if( !aItem->OfKind ( PNS_ITEM::SEGMENT ) )
@ -113,16 +119,19 @@ DIRECTION_45 PNS_DP_PRIMITIVE_PAIR::anchorDirection ( PNS_ITEM *aItem, const VEC
return DIRECTION_45( s->Seg().B - s->Seg().A );
}
DIRECTION_45 PNS_DP_PRIMITIVE_PAIR::DirP() const
{
return anchorDirection( m_primP, m_anchorP );
}
DIRECTION_45 PNS_DP_PRIMITIVE_PAIR::DirN() const
{
return anchorDirection( m_primN, m_anchorN );
}
static void drawGw( VECTOR2I p, int color )
{
SHAPE_LINE_CHAIN l;
@ -138,8 +147,6 @@ static void drawGw ( VECTOR2I p, int color )
l.Append( p + VECTOR2I( 50000, -50000 ) );
// PNS_ROUTER::GetInstance()->DisplayDebugLine ( l, color, 10000 );
}
@ -149,29 +156,35 @@ static DIRECTION_45::AngleType angle ( const VECTOR2I &a, const VECTOR2I &b )
DIRECTION_45 dir_b( b );
return dir_a.Angle( dir_b );
}
static bool checkGap( const SHAPE_LINE_CHAIN &p, const SHAPE_LINE_CHAIN &n, int gap )
{
int i, j;
for( i = 0; i < p.SegmentCount(); i++ )
{
for( j = 0; j < n.SegmentCount() ; j++ )
{
int dist = p.CSegment( i ).Distance( n.CSegment( j ) );
if( dist < gap - 100 )
return false;
}
}
return true;
}
void PNS_DP_GATEWAY::Reverse()
{
m_entryN = m_entryN.Reverse();
m_entryP = m_entryP.Reverse();
}
bool PNS_DIFF_PAIR::BuildInitial( PNS_DP_GATEWAY& aEntry, PNS_DP_GATEWAY &aTarget, bool aPrefDiagonal )
{
SHAPE_LINE_CHAIN p = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorP(), aTarget.AnchorP(), aPrefDiagonal );
@ -196,11 +209,14 @@ bool PNS_DIFF_PAIR::BuildInitial ( PNS_DP_GATEWAY& aEntry, PNS_DP_GATEWAY &aTarg
{
if( !aEntry.Entry().CheckConnectionAngle( *this, mask ) )
return false;
sum_p = aEntry.Entry().CP();
sum_n = aEntry.Entry().CN();
sum_p.Append( p );
sum_n.Append( n );
} else {
}
else
{
sum_p = p;
sum_n = n;
}
@ -220,7 +236,6 @@ bool PNS_DIFF_PAIR::BuildInitial ( PNS_DP_GATEWAY& aEntry, PNS_DP_GATEWAY &aTarg
sum_p.Append( t.Entry().CP() );
sum_n.Append( t.Entry().CN() );
}
m_p = sum_p;
@ -229,39 +244,43 @@ bool PNS_DIFF_PAIR::BuildInitial ( PNS_DP_GATEWAY& aEntry, PNS_DP_GATEWAY &aTarg
return true;
}
bool PNS_DIFF_PAIR::CheckConnectionAngle ( const PNS_DIFF_PAIR &aOther, int allowedAngles ) const
bool PNS_DIFF_PAIR::CheckConnectionAngle( const PNS_DIFF_PAIR& aOther, int aAllowedAngles ) const
{
bool checkP, checkN;
if( m_p.SegmentCount() == 0 || aOther.m_p.SegmentCount() == 0 )
checkP = true;
else {
else
{
DIRECTION_45 p0( m_p.CSegment( -1 ) );
DIRECTION_45 p1( aOther.m_p.CSegment( 0 ) );
checkP = (p0.Angle(p1) & allowedAngles) != 0;
checkP = ( p0.Angle( p1 ) & aAllowedAngles ) != 0;
}
if( m_n.SegmentCount() == 0 || aOther.m_n.SegmentCount() == 0 )
checkN = true;
else {
else
{
DIRECTION_45 n0( m_n.CSegment( -1 ) );
DIRECTION_45 n1( aOther.m_n.CSegment( 0 ) );
checkN = (n0.Angle(n1) & allowedAngles) != 0;
checkN = ( n0.Angle( n1 ) & aAllowedAngles ) != 0;
}
return checkP && checkN;
}
const PNS_DIFF_PAIR PNS_DP_GATEWAY::Entry() const
{
return PNS_DIFF_PAIR( m_entryP, m_entryN, 0 );
}
void PNS_DP_GATEWAYS::BuildOrthoProjections ( PNS_DP_GATEWAYS& aEntries, const VECTOR2I& aCursorPos, int aOrthoScore )
void PNS_DP_GATEWAYS::BuildOrthoProjections( PNS_DP_GATEWAYS& aEntries,
const VECTOR2I& aCursorPos, int aOrthoScore )
{
BOOST_FOREACH( PNS_DP_GATEWAY g, aEntries.Gateways() )
{
@ -270,7 +289,6 @@ void PNS_DP_GATEWAYS::BuildOrthoProjections ( PNS_DP_GATEWAYS& aEntries, const V
SEG guide( midpoint, midpoint + dir );
VECTOR2I proj = guide.LineProject( aCursorPos );
PNS_DP_GATEWAYS targets( m_gap );
targets.m_viaGap = m_viaGap;
@ -288,7 +306,8 @@ void PNS_DP_GATEWAYS::BuildOrthoProjections ( PNS_DP_GATEWAYS& aEntries, const V
}
bool PNS_DP_GATEWAYS::FitGateways ( PNS_DP_GATEWAYS& aEntry, PNS_DP_GATEWAYS& aTarget, bool aPrefDiagonal, PNS_DIFF_PAIR& aDp )
bool PNS_DP_GATEWAYS::FitGateways( PNS_DP_GATEWAYS& aEntry, PNS_DP_GATEWAYS& aTarget,
bool aPrefDiagonal, PNS_DIFF_PAIR& aDp )
{
std::vector<DP_CANDIDATE> candidates;
@ -306,7 +325,6 @@ bool PNS_DP_GATEWAYS::FitGateways ( PNS_DP_GATEWAYS& aEntry, PNS_DP_GATEWAYS& a
score +=g_entry.Priority();
score +=g_target.Priority();
DP_CANDIDATE c;
c.score = score;
c.p = l.CP();
@ -341,6 +359,7 @@ bool PNS_DP_GATEWAYS::FitGateways ( PNS_DP_GATEWAYS& aEntry, PNS_DP_GATEWAYS& a
return false;
}
bool PNS_DP_GATEWAYS::checkDiagonalAlignment( const VECTOR2I& a, const VECTOR2I& b ) const
{
VECTOR2I dir ( std::abs (a.x - b.x), std::abs ( a.y - b.y ));
@ -372,7 +391,9 @@ void PNS_DP_GATEWAYS::BuildFromPrimitivePair( PNS_DP_PRIMITIVE_PAIR aPair, bool
shP = aPair.PrimP()->Shape();
} else if ( aPair.PrimP()->OfKind ( PNS_ITEM::SEGMENT ) && aPair.PrimN()->OfKind ( PNS_ITEM::SEGMENT ) ) {
}
else if( aPair.PrimP()->OfKind( PNS_ITEM::SEGMENT ) && aPair.PrimN()->OfKind( PNS_ITEM::SEGMENT ) )
{
buildDpContinuation( aPair, aPreferDiagonal );
return;
@ -420,13 +441,14 @@ void PNS_DP_GATEWAYS::BuildFromPrimitivePair( PNS_DP_PRIMITIVE_PAIR aPair, bool
if( k == 0 )
{
dir = majorDirection.Resize( orthoFanDistance );
int d = ( padDist - m_gap ) / 2;
dp = dir.Resize( d );
dv = ( p0_n - p0_p ).Resize( d );
} else {
}
else
{
dir = majorDirection.Resize( diagFanDistance );
int d = ( padDist - m_gap ) / 2;
dp = dir.Resize( d );
@ -466,13 +488,13 @@ void PNS_DP_GATEWAYS::BuildForCursor( const VECTOR2I& aCursorPos )
{
VECTOR2I dir;
if( !attempt )
{
dir = VECTOR2I( gap, gap ).Resize( gap / 2 );
if( i % 2 == 0 )
dir.x = -dir.x;
if( i / 2 == 0 )
dir.y = -dir.y;
}
@ -487,7 +509,8 @@ void PNS_DP_GATEWAYS::BuildForCursor( const VECTOR2I& aCursorPos )
if( m_fitVias )
BuildGeneric( aCursorPos + dir, aCursorPos - dir, true, true );
else
m_gateways.push_back( PNS_DP_GATEWAY( aCursorPos + dir, aCursorPos - dir, attempt ? true : false ) );
m_gateways.push_back( PNS_DP_GATEWAY( aCursorPos + dir,
aCursorPos - dir, attempt ? true : false ) );
drawGw ( aCursorPos + dir, 2 );
drawGw ( aCursorPos - dir, 3 );
@ -542,7 +565,6 @@ void PNS_DP_GATEWAYS::buildDpContinuation ( PNS_DP_PRIMITIVE_PAIR aPair, bool aI
t2 = aPair.AnchorN() + dP.Left().ToVector().Resize( gap );
}
PNS_DP_GATEWAY gwL( t2, aPair.AnchorN(), !aIsDiagonal );
SHAPE_LINE_CHAIN ep = dP.BuildInitialTrace( aPair.AnchorP(), t2, !aIsDiagonal );
@ -602,8 +624,8 @@ void PNS_DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n,
}
}
for( int i = 0; i < 2; i++ )
{
for( int j = 0; j < 2; j++ )
{
OPT_VECTOR2I ips[2], m;
@ -654,7 +676,7 @@ void PNS_DP_GATEWAYS::BuildGeneric( const VECTOR2I& p0_p, const VECTOR2I& p0_n,
if( angle( g_p, g_n ) != DIRECTION_45::ANG_ACUTE )
m_gateways.push_back( PNS_DP_GATEWAY( *m + g_p, *m + g_n, true ) );
}
}
}
}
@ -678,10 +700,12 @@ PNS_DP_PRIMITIVE_PAIR PNS_DIFF_PAIR::EndingPrimitives()
PNS_DP_PRIMITIVE_PAIR dpair( &sP, &sN );
dpair.SetAnchors( sP.Seg().B, sN.Seg().B );
return dpair;
}
}
bool commonParallelProjection( SEG n, SEG p, SEG &pClip, SEG& nClip )
{
SEG n_proj_p( p.LineProject( n.A ), p.LineProject( n.B ) );
@ -698,14 +722,12 @@ bool commonParallelProjection ( SEG n, SEG p, SEG &pClip, SEG& nClip )
if( tproj_b < tproj_a )
std::swap( tproj_b, tproj_a );
if( t_b <= tproj_a )
return false;
if( t_a >= tproj_b )
return false;
int64_t t[4] = { 0, p.TCoef( p.B ), p.TCoef( n_proj_p.A ), p.TCoef( n_proj_p.B ) };
std::vector<int64_t> tv( t, t + 4 );
std::sort( tv.begin(), tv.end() ); // fixme: awful and disgusting way of finding 2 midpoints
@ -723,14 +745,15 @@ bool commonParallelProjection ( SEG n, SEG p, SEG &pClip, SEG& nClip )
nClip.B = n.LineProject( pClip.B );
return true;
}
double PNS_DIFF_PAIR::Skew() const
{
return m_p.Length() - m_n.Length();
}
void PNS_DIFF_PAIR::CoupledSegmentPairs( COUPLED_SEGMENTS_VEC& aPairs ) const
{
SHAPE_LINE_CHAIN p( m_p );
@ -759,6 +782,7 @@ void PNS_DIFF_PAIR::CoupledSegmentPairs ( COUPLED_SEGMENTS_VEC& aPairs ) const
}
}
int64_t PNS_DIFF_PAIR::CoupledLength( const SHAPE_LINE_CHAIN& aP, const SHAPE_LINE_CHAIN& aN ) const
{
int64_t total = 0;
@ -774,15 +798,16 @@ int64_t PNS_DIFF_PAIR::CoupledLength ( const SHAPE_LINE_CHAIN& aP, const SHAPE_L
int64_t dist = std::abs( sp.Distance(sn) - m_width );
if( sp.ApproxParallel(sn) && m_gapConstraint.Matches ( dist ) && commonParallelProjection ( sp, sn, p_clip, n_clip ))
if( sp.ApproxParallel( sn ) && m_gapConstraint.Matches( dist ) &&
commonParallelProjection( sp, sn, p_clip, n_clip ) )
total += p_clip.Length();
}
}
return total;
}
double PNS_DIFF_PAIR::CoupledLength() const
{
COUPLED_SEGMENTS_VEC pairs;
@ -796,14 +821,18 @@ double PNS_DIFF_PAIR::CoupledLength() const
return l;
}
double PNS_DIFF_PAIR::CoupledLengthFactor() const
{
double t = TotalLength();
if( t == 0.0 )
return 0.0;
return CoupledLength() / t;
}
double PNS_DIFF_PAIR::TotalLength() const
{
double lenP = m_p.Length();
@ -812,14 +841,15 @@ double PNS_DIFF_PAIR::TotalLength() const
return (lenN + lenP ) / 2.0;
}
int PNS_DIFF_PAIR::CoupledLength ( const SEG& aP, const SEG& aN ) const
{
SEG p_clip, n_clip;
int64_t dist = std::abs( aP.Distance( aN ) - m_width );
if( aP.ApproxParallel(aN) && m_gapConstraint.Matches ( dist ) && commonParallelProjection ( aP, aN, p_clip, n_clip ))
if( aP.ApproxParallel( aN ) && m_gapConstraint.Matches( dist ) &&
commonParallelProjection ( aP, aN, p_clip, n_clip ) )
return p_clip.Length();
return 0;
}

View File

@ -59,7 +59,6 @@ public:
~PNS_DP_GATEWAY()
{
}
/**
@ -67,13 +66,13 @@ public:
*
* @return true, if the gateway anchors lie on a diagonal line
*/
bool IsDiagonal() const
{
return m_isDiagonal;
}
const VECTOR2I& AnchorP() const { return m_anchorP; }
const VECTOR2I& AnchorN() const { return m_anchorN; }
/**
@ -118,7 +117,6 @@ public:
}
private:
SHAPE_LINE_CHAIN m_entryP, m_entryN;
bool m_hasEntryLines;
VECTOR2I m_anchorP, m_anchorN;
@ -134,7 +132,6 @@ private:
**/
class PNS_DP_PRIMITIVE_PAIR
{
public:
PNS_DP_PRIMITIVE_PAIR():
m_primP( NULL ), m_primN( NULL ) {};
@ -161,10 +158,10 @@ public:
DIRECTION_45 DirN() const;
private:
DIRECTION_45 anchorDirection( PNS_ITEM* aItem, const VECTOR2I& aP ) const;
PNS_ITEM *m_primP, *m_primN;
PNS_ITEM* m_primP;
PNS_ITEM* m_primN;
VECTOR2I m_anchorP, m_anchorN;
};

View File

@ -62,31 +62,38 @@ void PNS_DIFF_PAIR_PLACER::setWorld ( PNS_NODE* aWorld )
m_world = aWorld;
}
const PNS_VIA PNS_DIFF_PAIR_PLACER::makeVia( const VECTOR2I& aP, int aNet )
{
const PNS_LAYERSET layers( m_sizes.GetLayerTop(), m_sizes.GetLayerBottom() );
PNS_VIA v( aP, layers, m_sizes.ViaDiameter(), m_sizes.ViaDrill(), -1, m_sizes.ViaType() );
v.SetNet( aNet );
return v;
}
void PNS_DIFF_PAIR_PLACER::SetOrthoMode ( bool aOrthoMode )
{
m_orthoMode = aOrthoMode;
if( !m_idle )
Move( m_currentEnd, NULL );
}
bool PNS_DIFF_PAIR_PLACER::ToggleVia( bool aEnabled )
{
m_placingVia = aEnabled;
if( !m_idle )
Move( m_currentEnd, NULL );
return true;
}
bool PNS_DIFF_PAIR_PLACER::rhMarkObstacles( const VECTOR2I& aP )
{
if( !routeHead( aP ) )
@ -99,6 +106,7 @@ bool PNS_DIFF_PAIR_PLACER::rhMarkObstacles( const VECTOR2I& aP )
return m_fitOk;
}
bool PNS_DIFF_PAIR_PLACER::propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I& aNewP )
{
PNS_VIA virtHead = makeVia( aP, -1 );
@ -115,12 +123,12 @@ bool PNS_DIFF_PAIR_PLACER::propagateDpHeadForces ( const VECTOR2I& aP, VECTOR2I&
VECTOR2I force;
bool solidsOnly = true;
if( m_currentMode == RM_MarkObstacles )
{
aNewP = aP;
return true;
} else if (m_currentMode == RM_Walkaround )
}
else if( m_currentMode == RM_Walkaround )
{
solidsOnly = false;
}
@ -162,14 +170,14 @@ bool PNS_DIFF_PAIR_PLACER::attemptWalk ( PNS_NODE *aNode, PNS_DIFF_PAIR *aCurren
//Router()->DisplayDebugLine( aCurrent->CP(), 4, 10000 );
//Router()->DisplayDebugLine( aCurrent->CN(), 5, 10000 );
do {
do
{
PNS_LINE preWalk = ( currentIsP ? cur.PLine() : cur.NLine() );
PNS_LINE preShove = ( currentIsP ? cur.NLine() : cur.PLine() );
PNS_LINE postWalk;
if( !aNode->CheckColliding ( &preWalk, mask ) )
{
currentIsP = !currentIsP;
if( !aNode->CheckColliding( &preShove, mask ) )
@ -197,7 +205,6 @@ bool PNS_DIFF_PAIR_PLACER::attemptWalk ( PNS_NODE *aNode, PNS_DIFF_PAIR *aCurren
postWalk.Line().Simplify();
postShove.Line().Simplify();
cur.SetShape( postWalk.CLine(), postShove.CLine(), !currentIsP );
currentIsP = !currentIsP;
@ -205,21 +212,20 @@ bool PNS_DIFF_PAIR_PLACER::attemptWalk ( PNS_NODE *aNode, PNS_DIFF_PAIR *aCurren
if( !aNode->CheckColliding( &postShove, mask ) )
break;
iter++;
} while (iter < 3);
}
while( iter < 3 );
if( iter == 3 )
return false;
aWalk.SetShape( cur.CP(), cur.CN() );
Router()->GetClearanceFunc()->OverrideClearance( false );
return true;
}
bool PNS_DIFF_PAIR_PLACER::tryWalkDp( PNS_NODE* aNode, PNS_DIFF_PAIR &aPair, bool aSolidsOnly )
{
PNS_DIFF_PAIR best;
@ -256,14 +262,15 @@ bool PNS_DIFF_PAIR_PLACER::tryWalkDp ( PNS_NODE* aNode, PNS_DIFF_PAIR &aPair, bo
PNS_OPTIMIZER optimizer( m_currentNode );
aPair.SetShape( best );
optimizer.Optimize( &aPair );
return true;
}
return false;
}
bool PNS_DIFF_PAIR_PLACER::rhWalkOnly( const VECTOR2I& aP )
{
if( !routeHead ( aP ) )
@ -292,6 +299,7 @@ bool PNS_DIFF_PAIR_PLACER::route ( const VECTOR2I& aP )
return false;
}
bool PNS_DIFF_PAIR_PLACER::rhShoveOnly( const VECTOR2I& aP )
{
m_currentNode = m_shove->CurrentNode();
@ -332,7 +340,6 @@ bool PNS_DIFF_PAIR_PLACER::rhShoveOnly ( const VECTOR2I& aP )
}
const PNS_ITEMSET PNS_DIFF_PAIR_PLACER::Traces()
{
PNS_ITEMSET t;
@ -372,7 +379,9 @@ bool PNS_DIFF_PAIR_PLACER::SetLayer( int aLayer )
return false;
else if( !m_prevPair )
return false;
else if( m_prevPair->PrimP() || ( m_prevPair->PrimP()->OfKind( PNS_ITEM::VIA ) && m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) ) {
else if( m_prevPair->PrimP() || ( m_prevPair->PrimP()->OfKind( PNS_ITEM::VIA ) &&
m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
{
m_currentLayer = aLayer;
m_start = *m_prevPair;
initPlacement( false );
@ -383,34 +392,41 @@ bool PNS_DIFF_PAIR_PLACER::SetLayer( int aLayer )
return false;
}
int PNS_DIFF_PAIR_PLACER::matchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName )
{
int rv = 0;
if( aNetName.EndsWith( "+" ) )
{
aComplementNet = "-";
rv = 1;
} else if (aNetName.EndsWith("_P"))
}
else if( aNetName.EndsWith( "_P" ) )
{
aComplementNet = "_N";
rv = 1;
} else if (aNetName.EndsWith("-"))
}
else if( aNetName.EndsWith( "-" ) )
{
aComplementNet = "+";
rv = -1;
} else if (aNetName.EndsWith("_N"))
}
else if( aNetName.EndsWith( "_N" ) )
{
aComplementNet = "_P";
rv = -1;
}
if (rv != 0) {
if( rv != 0 )
{
aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );
}
return rv;
}
OPT_VECTOR2I PNS_DIFF_PAIR_PLACER::getDanglingAnchor( PNS_NODE* aNode, PNS_ITEM* aItem )
{
switch( aItem->Kind() )
@ -433,22 +449,22 @@ OPT_VECTOR2I PNS_DIFF_PAIR_PLACER::getDanglingAnchor ( PNS_NODE *aNode, PNS_ITEM
else
return OPT_VECTOR2I();
}
default:
return OPT_VECTOR2I();
break;
}
}
bool PNS_DIFF_PAIR_PLACER::findDpPrimitivePair( const VECTOR2I& aP, PNS_ITEM* aItem, PNS_DP_PRIMITIVE_PAIR& aPair )
{
if( !aItem || !aItem->Parent() || !aItem->Parent()->GetNet() )
return false;
wxString netNameP = aItem->Parent()->GetNet()->GetNetname();
wxString netNameN, netNameBase;
BOARD* brd = Router()->GetBoard();
PNS_ITEM *primRef = NULL, *primP = NULL, *primN = NULL;
@ -465,7 +481,9 @@ bool PNS_DIFF_PAIR_PLACER::findDpPrimitivePair ( const VECTOR2I& aP, PNS_ITEM *a
{
primRef = primP = static_cast<PNS_SOLID*>( aItem );
netNameN = netNameBase + suffix;
} else {
}
else
{
primRef = primN = static_cast<PNS_SOLID*>( aItem );
netNameN = netNameP;
netNameP = netNameBase + suffix;
@ -511,7 +529,9 @@ bool PNS_DIFF_PAIR_PLACER::findDpPrimitivePair ( const VECTOR2I& aP, PNS_ITEM *a
{
aPair = PNS_DP_PRIMITIVE_PAIR ( item, primRef );
aPair.SetAnchors( *anchor, *refAnchor );
} else {
}
else
{
aPair = PNS_DP_PRIMITIVE_PAIR( primRef, item );
aPair.SetAnchors( *refAnchor, *anchor );
}
@ -528,11 +548,13 @@ int PNS_DIFF_PAIR_PLACER::viaGap() const
return m_sizes.DiffPairViaGap();
}
int PNS_DIFF_PAIR_PLACER::gap() const
{
return m_sizes.DiffPairGap() + m_sizes.DiffPairWidth();
}
bool PNS_DIFF_PAIR_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
VECTOR2I p( aP );
@ -573,6 +595,7 @@ bool PNS_DIFF_PAIR_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
return true;
}
void PNS_DIFF_PAIR_PLACER::initPlacement( bool aSplitSeg )
{
m_idle = false;
@ -612,7 +635,6 @@ bool PNS_DIFF_PAIR_PLACER::routeHead( const VECTOR2I& aP )
PNS_DP_GATEWAYS gwsEntry( gap() );
PNS_DP_GATEWAYS gwsTarget( gap() );
if( !m_prevPair )
m_prevPair = m_start;
@ -640,7 +662,6 @@ bool PNS_DIFF_PAIR_PLACER::routeHead( const VECTOR2I& aP )
m_currentTrace.SetGap( gap() );
m_currentTrace.SetLayer( m_currentLayer );
if ( gwsEntry.FitGateways( gwsEntry, gwsTarget, m_startDiagonal, m_currentTrace ) )
{
m_currentTrace.SetNets( m_netP, m_netN );
@ -652,13 +673,14 @@ bool PNS_DIFF_PAIR_PLACER::routeHead( const VECTOR2I& aP )
m_currentTrace.AppendVias ( makeVia ( m_currentTrace.CP().CPoint(-1), m_netP ),
makeVia ( m_currentTrace.CN().CPoint(-1), m_netN ) );
}
return true;
}
return false;
}
bool PNS_DIFF_PAIR_PLACER::Move( const VECTOR2I& aP , PNS_ITEM* aEndItem )
{
m_currentEndItem = aEndItem;
@ -681,9 +703,11 @@ bool PNS_DIFF_PAIR_PLACER::Move(const VECTOR2I& aP , PNS_ITEM* aEndItem )
return true;
}
void PNS_DIFF_PAIR_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes )
{
m_sizes = aSizes;
if( !m_idle )
{
initPlacement();
@ -691,6 +715,7 @@ void PNS_DIFF_PAIR_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes )
}
}
bool PNS_DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
if( !m_fitOk )
@ -747,7 +772,9 @@ bool PNS_DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
m_idle = true;
return true;
} else {
}
else
{
initPlacement();
return false;
}
@ -760,6 +787,7 @@ void PNS_DIFF_PAIR_PLACER::GetModifiedNets( std::vector<int> &aNets ) const
aNets.push_back( m_netN );
}
void PNS_DIFF_PAIR_PLACER::updateLeadingRatLine()
{
SHAPE_LINE_CHAIN ratLineN, ratLineP;
@ -774,5 +802,4 @@ void PNS_DIFF_PAIR_PLACER::updateLeadingRatLine()
{
Router()->DisplayDebugLine( ratLineN, 3, 10000 );
}
}

View File

@ -164,8 +164,8 @@ public:
void SetOrthoMode( bool aOrthoMode );
void GetModifiedNets( std::vector<int>& aNets ) const;
private:
private:
int viaGap() const;
int gap() const;
@ -251,7 +251,6 @@ private:
PNS_DP_PRIMITIVE_PAIR m_start;
boost::optional<PNS_DP_PRIMITIVE_PAIR> m_prevPair;
///> current algorithm iteration
int m_iteration;

View File

@ -34,11 +34,8 @@
#include "pns_router.h"
#include "pns_utils.h"
using boost::optional;
PNS_DP_MEANDER_PLACER::PNS_DP_MEANDER_PLACER( PNS_ROUTER* aRouter ) :
PNS_MEANDER_PLACER_BASE( aRouter )
{
@ -49,24 +46,28 @@ PNS_DP_MEANDER_PLACER::PNS_DP_MEANDER_PLACER( PNS_ROUTER* aRouter ) :
PNS_DP_MEANDER_PLACER::~PNS_DP_MEANDER_PLACER()
{
}
const PNS_LINE PNS_DP_MEANDER_PLACER::Trace() const
{
return m_currentTraceP;
}
PNS_NODE* PNS_DP_MEANDER_PLACER::CurrentNode( bool aLoopsRemoved ) const
{
if( !m_currentNode )
return m_world;
return m_currentNode;
}
bool PNS_DP_MEANDER_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
VECTOR2I p;
if( !aStartItem || !aStartItem->OfKind( PNS_ITEM::SEGMENT ) )
{
Router()->SetFailureReason( _( "Please select a track whose length you want to tune." ) );
@ -92,7 +93,6 @@ bool PNS_DP_MEANDER_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
return false;
}
m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
if( !m_originPair.PLine().SegmentCount() ||
@ -123,6 +123,7 @@ void PNS_DP_MEANDER_PLACER::release()
#endif
}
int PNS_DP_MEANDER_PLACER::origPathLength() const
{
int totalP = 0;
@ -134,16 +135,17 @@ int PNS_DP_MEANDER_PLACER::origPathLength () const
totalP += l->CLine().Length();
}
BOOST_FOREACH( const PNS_ITEM* item, m_tunedPathN.CItems() )
{
if( const PNS_LINE* l = dyn_cast<const PNS_LINE*>( item ) )
totalN += l->CLine().Length();
}
return std::max( totalP, totalN );
}
const SEG PNS_DP_MEANDER_PLACER::baselineSegment( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& aCoupledSegs )
{
const VECTOR2I a( ( aCoupledSegs.coupledP.A + aCoupledSegs.coupledN.A ) / 2 );
@ -228,7 +230,6 @@ PNS_MEANDER_PLACER_BASE::TUNING_STATUS PNS_DP_MEANDER_PLACER::tuneLineLength ( P
#endif
bool pairOrientation( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& aPair )
{
VECTOR2I midp = ( aPair.coupledP.A + aPair.coupledN.A ) / 2;
@ -238,11 +239,9 @@ bool pairOrientation( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& aPair )
return aPair.coupledP.Side( midp ) > 0;
}
bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
// return false;
if( m_currentNode )
@ -281,15 +280,12 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
if( !pairOrientation( m_coupledSegments[0] ) )
offset *= -1;
m_result.SetBaselineOffset( offset );
BOOST_FOREACH( const PNS_ITEM* item, m_tunedPathP.CItems() )
{
if( const PNS_LINE* l = dyn_cast<const PNS_LINE*>( item ) )
Router()->DisplayDebugLine( l->CLine(), 5, 10000 );
}
BOOST_FOREACH( const PNS_ITEM* item, m_tunedPathN.CItems() )
@ -298,7 +294,6 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
Router()->DisplayDebugLine( l->CLine(), 5, 10000 );
}
BOOST_FOREACH( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& sp, m_coupledSegments )
{
SEG base = baselineSegment( sp );
@ -314,12 +309,13 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
m_lastStatus = TUNED;
if (dpLen - m_settings.m_targetLength > m_settings.m_lengthTollerance)
if( dpLen - m_settings.m_targetLength > m_settings.m_lengthTolerance )
{
m_lastStatus = TOO_LONG;
m_lastLength = dpLen;
} else {
}
else
{
m_lastLength = dpLen - std::max( tunedP.Length(), tunedN.Length() );
tuneLineLength( m_result, m_settings.m_targetLength - dpLen );
}
@ -340,7 +336,7 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
m_lastLength += std::max( tunedP.Length(), tunedN.Length() );
int comp = compareWithTollerance( m_lastLength - m_settings.m_targetLength, 0, m_settings.m_lengthTollerance );
int comp = compareWithTolerance( m_lastLength - m_settings.m_targetLength, 0, m_settings.m_lengthTolerance );
if( comp > 0 )
m_lastStatus = TOO_LONG;
@ -348,7 +344,6 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
m_lastStatus = TOO_SHORT;
else
m_lastStatus = TUNED;
}
m_finalShapeP.Clear();
@ -380,6 +375,7 @@ bool PNS_DP_MEANDER_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
return true;
}
bool PNS_DP_MEANDER_PLACER::CheckFit( PNS_MEANDER_SHAPE* aShape )
{
PNS_LINE l1( m_originPair.PLine(), aShape->CLine( 0 ) );
@ -400,7 +396,6 @@ bool PNS_DP_MEANDER_PLACER::CheckFit ( PNS_MEANDER_SHAPE *aShape )
const PNS_ITEMSET PNS_DP_MEANDER_PLACER::Traces()
{
m_currentTraceP = PNS_LINE( m_originPair.PLine(), m_finalShapeP );
m_currentTraceN = PNS_LINE( m_originPair.NLine(), m_finalShapeN );
@ -412,21 +407,25 @@ const PNS_ITEMSET PNS_DP_MEANDER_PLACER::Traces()
return traces;
}
const VECTOR2I& PNS_DP_MEANDER_PLACER::CurrentEnd() const
{
return m_currentEnd;
}
int PNS_DP_MEANDER_PLACER::CurrentNet() const
{
return m_initialSegment->Net();
}
int PNS_DP_MEANDER_PLACER::CurrentLayer() const
{
return m_initialSegment->Layers().Start();
}
const wxString PNS_DP_MEANDER_PLACER::TuningInfo() const
{
wxString status;
@ -453,6 +452,7 @@ const wxString PNS_DP_MEANDER_PLACER::TuningInfo() const
return status;
}
PNS_DP_MEANDER_PLACER::TUNING_STATUS PNS_DP_MEANDER_PLACER::TuningStatus() const
{
return m_lastStatus;

View File

@ -48,7 +48,6 @@ class PNS_ROUTER_BASE;
class PNS_DP_MEANDER_PLACER : public PNS_MEANDER_PLACER_BASE
{
public:
PNS_DP_MEANDER_PLACER( PNS_ROUTER* aRouter );
~PNS_DP_MEANDER_PLACER();
@ -96,7 +95,6 @@ public:
int CurrentNet() const;
int CurrentLayer() const;
int totalLength();
const wxString TuningInfo() const;
@ -110,8 +108,6 @@ private:
void meanderSegment ( const SEG& aBase );
// void addMeander ( PNS_MEANDER *aM );
// void addCorner ( const VECTOR2I& aP );

View File

@ -160,7 +160,6 @@ PNS_INDEX::PNS_INDEX()
memset( m_subIndices, 0, sizeof( m_subIndices ) );
}
PNS_INDEX::ITEM_SHAPE_INDEX* PNS_INDEX::getSubindex( const PNS_ITEM* aItem )
{
int idx_n = -1;
@ -201,7 +200,6 @@ PNS_INDEX::ITEM_SHAPE_INDEX* PNS_INDEX::getSubindex( const PNS_ITEM* aItem )
return m_subIndices[idx_n];
}
void PNS_INDEX::Add( PNS_ITEM* aItem )
{
ITEM_SHAPE_INDEX* idx = getSubindex( aItem );
@ -216,7 +214,6 @@ void PNS_INDEX::Add( PNS_ITEM* aItem )
}
}
void PNS_INDEX::Remove( PNS_ITEM* aItem )
{
ITEM_SHAPE_INDEX* idx = getSubindex( aItem );
@ -230,14 +227,12 @@ void PNS_INDEX::Remove( PNS_ITEM* aItem )
m_netMap[net].remove( aItem );
}
void PNS_INDEX::Replace( PNS_ITEM* aOldItem, PNS_ITEM* aNewItem )
{
Remove( aOldItem );
Add( aNewItem );
}
template<class Visitor>
int PNS_INDEX::querySingle( int index, const SHAPE* aShape, int aMinDistance, Visitor& aVisitor )
{
@ -247,7 +242,6 @@ int PNS_INDEX::querySingle( int index, const SHAPE* aShape, int aMinDistance, Vi
return m_subIndices[index]->Query( aShape, aMinDistance, aVisitor, false );
}
template<class Visitor>
int PNS_INDEX::Query( const PNS_ITEM* aItem, int aMinDistance, Visitor& aVisitor )
{
@ -281,7 +275,6 @@ int PNS_INDEX::Query( const PNS_ITEM* aItem, int aMinDistance, Visitor& aVisitor
return total;
}
template<class Visitor>
int PNS_INDEX::Query( const SHAPE* aShape, int aMinDistance, Visitor& aVisitor )
{
@ -293,7 +286,6 @@ int PNS_INDEX::Query( const SHAPE* aShape, int aMinDistance, Visitor& aVisitor )
return total;
}
void PNS_INDEX::Clear()
{
for( int i = 0; i < MaxSubIndices; ++i )
@ -307,13 +299,11 @@ void PNS_INDEX::Clear()
}
}
PNS_INDEX::~PNS_INDEX()
{
Clear();
}
PNS_INDEX::NET_ITEMS_LIST* PNS_INDEX::GetItemsForNet( int aNet )
{
if( m_netMap.find( aNet ) == m_netMap.end() )

View File

@ -29,6 +29,7 @@ PNS_ITEMSET::PNS_ITEMSET( PNS_ITEM* aInitialItem ) :
m_items.push_back( aInitialItem );
}
PNS_ITEMSET::~PNS_ITEMSET()
{
if( m_owner )
@ -38,6 +39,7 @@ PNS_ITEMSET::~PNS_ITEMSET()
}
}
PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd, bool aInvert )
{
ITEMS newItems;
@ -74,6 +76,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask, bool aInvert )
return *this;
}
PNS_ITEMSET& PNS_ITEMSET::FilterMarker( int aMarker, bool aInvert )
{
ITEMS newItems;
@ -105,6 +108,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet, bool aInvert )
return *this;
}
PNS_ITEMSET& PNS_ITEMSET::ExcludeItem( const PNS_ITEM* aItem )
{
ITEMS newItems;

View File

@ -209,15 +209,11 @@ private:
PNS_ITEMSET m_linkedItems;
};
// hash function & comparison operator for boost::unordered_map<>
inline bool operator==( PNS_JOINT::HASH_TAG const& aP1,
PNS_JOINT::HASH_TAG const& aP2 )
inline bool operator==( PNS_JOINT::HASH_TAG const& aP1, PNS_JOINT::HASH_TAG const& aP2 )
{
return aP1.pos == aP2.pos && aP1.net == aP2.net;
}
inline std::size_t hash_value( PNS_JOINT::HASH_TAG const& aP )
{
std::size_t seed = 0;

View File

@ -348,7 +348,6 @@ SHAPE_LINE_CHAIN dragCornerInternal( const SHAPE_LINE_CHAIN& aOrigin, const VECT
{
optional<SHAPE_LINE_CHAIN> picked;
int i;
int d = 2;
if( aOrigin.CSegment( -1 ).Length() > 100000 * 30 ) // fixme: constant/parameter?
@ -785,6 +784,7 @@ void PNS_LINE::ClearSegmentLinks()
m_segmentRefs = NULL;
}
static void extendBox( BOX2I& aBox, bool& aDefined, const VECTOR2I& aP )
{
if( aDefined )
@ -795,12 +795,12 @@ static void extendBox( BOX2I& aBox, bool &aDefined, const VECTOR2I& aP )
}
}
OPT_BOX2I PNS_LINE::ChangedArea( const PNS_LINE* aOther ) const
{
BOX2I area;
bool areaDefined = false;
int i_start = -1;
int i_end_self = -1, i_end_other = -1;
@ -818,11 +818,13 @@ OPT_BOX2I PNS_LINE::ChangedArea ( const PNS_LINE *aOther ) const
{
const VECTOR2I p1 = self.CPoint( i );
const VECTOR2I p2 = other.CPoint( i );
if( p1 != p2 )
{
if( i != n - 1 )
{
SEG s = self.CSegment( i );
if( !s.Contains( p2 ) )
{
i_start = i;
@ -832,15 +834,14 @@ OPT_BOX2I PNS_LINE::ChangedArea ( const PNS_LINE *aOther ) const
i_start = i;
break;
}
}
}
for( int i = 0; i < n; i++ )
{
const VECTOR2I p1 = self.CPoint( np_self - 1 - i );
const VECTOR2I p2 = other.CPoint( np_other - 1 - i );
if( p1 != p2 )
{
i_end_self = np_self - 1 - i;

View File

@ -732,9 +732,12 @@ bool PNS_LINE_PLACER::SetLayer( int aLayer )
{
m_currentLayer = aLayer;
return true;
} else if( m_chainedPlacement ) {
}
else if( m_chainedPlacement )
{
return false;
} else if( !m_startItem || ( m_startItem->OfKind( PNS_ITEM::VIA ) && m_startItem->Layers().Overlaps( aLayer ) ) ) {
}
else if( !m_startItem || ( m_startItem->OfKind( PNS_ITEM::VIA ) && m_startItem->Layers().Overlaps( aLayer ) ) ) {
m_currentLayer = aLayer;
m_splitSeg = false;
initPlacement ( m_splitSeg );
@ -745,6 +748,7 @@ bool PNS_LINE_PLACER::SetLayer( int aLayer )
return false;
}
bool PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
VECTOR2I p( aP );
@ -1017,9 +1021,11 @@ void PNS_LINE_PLACER::updateLeadingRatLine()
Router()->DisplayDebugLine( ratLine, 5, 10000 );
}
void PNS_LINE_PLACER::SetOrthoMode( bool aOrthoMode )
{
m_orthoMode = aOrthoMode;
if( !m_idle )
Move( m_currentEnd, NULL );
}
@ -1042,6 +1048,7 @@ const SHAPE_LINE_CHAIN PNS_LINE_PLACER::buildInitialLine ( const VECTOR2I& aP )
return l;
}
void PNS_LINE_PLACER::GetModifiedNets( std::vector<int>& aNets ) const
{
aNets.push_back( m_currentNet );

View File

@ -40,7 +40,6 @@ class PNS_VIA;
class PNS_SIZES_SETTINGS;
/**
* Class PNS_LINE_PLACER
*
@ -96,7 +95,6 @@ public:
*/
bool SetLayer( int aLayer );
/**
* Function Head()
*
@ -348,6 +346,7 @@ private:
bool rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead );
const PNS_VIA makeVia ( const VECTOR2I& aP );
const SHAPE_LINE_CHAIN buildInitialLine( const VECTOR2I& aP );
///> current routing direction

View File

@ -178,6 +178,7 @@ void PNS_LOGGER::dumpShape( const SHAPE* aSh )
}
}
void PNS_LOGGER::Save( const std::string& aFilename )
{
EndGroup();

View File

@ -75,7 +75,6 @@ void PNS_MEANDERED_LINE::MeanderSegment( const SEG &aBase, int aBaseIndex )
if( remaining > 3.0 * thr )
{
if( !turning )
{
for( int i = 0; i < 2; i++ )
@ -106,7 +105,6 @@ void PNS_MEANDERED_LINE::MeanderSegment( const SEG &aBase, int aBaseIndex )
}
}
}
} else {
bool rv = m->Fit( MT_CHECK_FINISH, aBase, m_last, side );
@ -124,7 +122,6 @@ void PNS_MEANDERED_LINE::MeanderSegment( const SEG &aBase, int aBaseIndex )
side = !side;
}
} else if( started )
{
bool rv = m->Fit( MT_FINISH, aBase, m_last, side );
@ -142,7 +139,6 @@ void PNS_MEANDERED_LINE::MeanderSegment( const SEG &aBase, int aBaseIndex )
if( remaining < Settings( ).m_step )
break;
if( fail )
{
PNS_MEANDER_SHAPE tmp( m_placer, m_width, m_dual );
@ -174,6 +170,7 @@ int PNS_MEANDER_SHAPE::cornerRadius( ) const
return cr;
}
int PNS_MEANDER_SHAPE::spacing( ) const
{
if ( !m_dual )
@ -186,7 +183,7 @@ int PNS_MEANDER_SHAPE::spacing( ) const
}
SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::circleQuad( VECTOR2D aP, VECTOR2D aDir, bool side )
SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::circleQuad( VECTOR2D aP, VECTOR2D aDir, bool aSide )
{
SHAPE_LINE_CHAIN lc;
@ -205,12 +202,14 @@ SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::circleQuad( VECTOR2D aP, VECTOR2D aDir, bool
{
VECTOR2D p;
double alpha = (double) i / (double) ( ArcSegments - 1 ) * M_PI / 2.0;
p = aP + dir_u * cos( alpha ) + dir_v * ( side ? -1.0 : 1.0 ) * ( 1.0 - sin( alpha ) );
p = aP + dir_u * cos( alpha ) + dir_v * ( aSide ? -1.0 : 1.0 ) * ( 1.0 - sin( alpha ) );
lc.Append( ( int ) p.x, ( int ) p.y );
}
return lc;
}
VECTOR2I PNS_MEANDER_SHAPE::reflect( VECTOR2I p, const SEG& line )
{
typedef int64_t ecoord;
@ -229,6 +228,7 @@ VECTOR2I PNS_MEANDER_SHAPE::reflect( VECTOR2I p, const SEG& line )
return 2 * c - p;
}
void PNS_MEANDER_SHAPE::start( SHAPE_LINE_CHAIN* aTarget, const VECTOR2D& aWhere, const VECTOR2D& aDir )
{
m_currentTarget = aTarget;
@ -238,17 +238,20 @@ void PNS_MEANDER_SHAPE::start( SHAPE_LINE_CHAIN* aTarget, const VECTOR2D& aWhere
m_currentPos = aWhere;
}
void PNS_MEANDER_SHAPE::forward( int aLength )
{
m_currentPos += m_currentDir.Resize( aLength );
m_currentTarget->Append( m_currentPos );
}
void PNS_MEANDER_SHAPE::turn( int aAngle )
{
m_currentDir = m_currentDir.Rotate( (double) aAngle * M_PI / 180.0 );
}
void PNS_MEANDER_SHAPE::arc( int aRadius, bool aSide )
{
if( aRadius <= 0 )
@ -265,6 +268,7 @@ void PNS_MEANDER_SHAPE::arc( int aRadius, bool aSide )
m_currentTarget->Append ( arc );
}
void PNS_MEANDER_SHAPE::uShape( int aSides, int aCorner, int aTop )
{
forward( aSides );
@ -274,7 +278,9 @@ void PNS_MEANDER_SHAPE::uShape ( int aSides, int aCorner, int aTop )
forward( aSides );
}
SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::genMeanderShape ( VECTOR2D aP, VECTOR2D aDir, bool aSide, PNS_MEANDER_TYPE aType, int aAmpl, int aBaselineOffset )
SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::genMeanderShape( VECTOR2D aP, VECTOR2D aDir,
bool aSide, PNS_MEANDER_TYPE aType, int aAmpl, int aBaselineOffset )
{
const PNS_MEANDER_SETTINGS& st = Settings();
int cr = cornerRadius();
@ -297,7 +303,6 @@ SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::genMeanderShape ( VECTOR2D aP, VECTOR2D aDir
cr = spc / 2;
}
SHAPE_LINE_CHAIN lc;
start( &lc, aP + dir_v_b, aDir );
@ -332,13 +337,11 @@ SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::genMeanderShape ( VECTOR2D aP, VECTOR2D aDir
case MT_TURN:
{
start( &lc, aP - dir_u_b, aDir );
turn( 90 );
forward( std::abs( offset ) );
uShape ( aAmpl - cr, cr + offset, spc - 2 * cr );
forward( std::abs( offset ) );
break;
}
@ -358,6 +361,7 @@ SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::genMeanderShape ( VECTOR2D aP, VECTOR2D aDir
if( aSide )
{
SEG axis ( aP, aP + aDir );
for( int i = 0; i < lc.PointCount(); i++ )
lc.Point( i ) = reflect( lc.CPoint( i ), axis );
}
@ -365,6 +369,7 @@ SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::genMeanderShape ( VECTOR2D aP, VECTOR2D aDir
return lc;
}
bool PNS_MEANDERED_LINE::CheckSelfIntersections( PNS_MEANDER_SHAPE* aShape, int aClearance )
{
for( int i = m_meanders.size() - 1; i >= 0; i-- )
@ -390,6 +395,7 @@ bool PNS_MEANDERED_LINE::CheckSelfIntersections ( PNS_MEANDER_SHAPE *aShape, int
return true;
}
bool PNS_MEANDER_SHAPE::Fit( PNS_MEANDER_TYPE aType, const SEG& aSeg, const VECTOR2I& aP, bool aSide )
{
const PNS_MEANDER_SETTINGS& st = Settings();
@ -402,7 +408,9 @@ bool PNS_MEANDER_SHAPE::Fit ( PNS_MEANDER_TYPE aType, const SEG& aSeg, const VEC
prim1 = MT_START;
prim2 = MT_TURN;
checkMode = true;
} else if (aType == MT_CHECK_FINISH ) {
}
else if( aType == MT_CHECK_FINISH )
{
prim1 = MT_TURN;
prim2 = MT_FINISH;
checkMode = true;
@ -439,7 +447,6 @@ bool PNS_MEANDER_SHAPE::Fit ( PNS_MEANDER_TYPE aType, const SEG& aSeg, const VEC
return true;
} else
return false;
}
int minAmpl = st.m_minAmplitude;
@ -457,7 +464,9 @@ bool PNS_MEANDER_SHAPE::Fit ( PNS_MEANDER_TYPE aType, const SEG& aSeg, const VEC
{
m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, ampl, m_baselineOffset );
m_shapes[1] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, ampl, -m_baselineOffset );
} else {
}
else
{
m_shapes[0] = genMeanderShape( aP, aSeg.B - aSeg.A, aSide, aType, ampl, 0 );
}
@ -476,18 +485,18 @@ bool PNS_MEANDER_SHAPE::Fit ( PNS_MEANDER_TYPE aType, const SEG& aSeg, const VEC
return false;
}
void PNS_MEANDER_SHAPE::Recalculate()
{
m_shapes[0] = genMeanderShape( m_p0, m_baseSeg.B - m_baseSeg.A, m_side, m_type, m_amplitude, m_dual ? m_baselineOffset : 0 );
if( m_dual )
m_shapes[1] = genMeanderShape( m_p0, m_baseSeg.B - m_baseSeg.A, m_side, m_type, m_amplitude, -m_baselineOffset );
updateBaseSegment();
}
void PNS_MEANDER_SHAPE::Resize( int aAmpl )
{
if( aAmpl < 0 )
@ -498,6 +507,7 @@ void PNS_MEANDER_SHAPE::Resize ( int aAmpl )
Recalculate();
}
void PNS_MEANDER_SHAPE::MakeEmpty()
{
updateBaseSegment();
@ -510,8 +520,6 @@ void PNS_MEANDER_SHAPE::MakeEmpty()
if( m_dual )
m_shapes[1] = genMeanderShape( m_p0, dir, m_side, m_type, 0, -m_baselineOffset );
}
@ -525,6 +533,7 @@ void PNS_MEANDERED_LINE::AddCorner ( const VECTOR2I& aA, const VECTOR2I& aB )
m_meanders.push_back( m );
}
void PNS_MEANDER_SHAPE::MakeCorner( VECTOR2I aP1, VECTOR2I aP2 )
{
SetType( MT_CORNER );
@ -534,9 +543,9 @@ void PNS_MEANDER_SHAPE::MakeCorner ( VECTOR2I aP1, VECTOR2I aP2 )
m_shapes[1].Append( aP2 );
m_clippedBaseSeg.A = aP1;
m_clippedBaseSeg.B = aP1;
}
void PNS_MEANDERED_LINE::AddMeander( PNS_MEANDER_SHAPE* aShape )
{
m_last = aShape->BaseSegment().B;
@ -554,16 +563,19 @@ void PNS_MEANDERED_LINE::Clear( )
m_meanders.clear( );
}
int PNS_MEANDER_SHAPE::BaselineLength() const
{
return m_clippedBaseSeg.Length();
}
int PNS_MEANDER_SHAPE::MaxTunableLength() const
{
return CLine( 0 ).Length();
}
void PNS_MEANDER_SHAPE::updateBaseSegment( )
{
if( m_dual )
@ -573,7 +585,9 @@ void PNS_MEANDER_SHAPE::updateBaseSegment( )
m_clippedBaseSeg.A = m_baseSeg.LineProject( midpA );
m_clippedBaseSeg.B = m_baseSeg.LineProject( midpB );
} else {
}
else
{
m_clippedBaseSeg.A = m_baseSeg.LineProject( CLine( 0 ).CPoint( 0 ) );
m_clippedBaseSeg.B = m_baseSeg.LineProject( CLine( 0 ).CPoint( -1 ) );
}

View File

@ -65,7 +65,7 @@ public:
m_targetSkew = 0;
m_cornerType = ROUND;
m_cornerRadiusPercentage = 100;
m_lengthTollerance = 100000;
m_lengthTolerance = 100000;
m_cornerArcSegments = 8;
}
@ -84,7 +84,7 @@ public:
///> rounding percentage (0 - 100)
int m_cornerRadiusPercentage;
///> allowable tuning error
int m_lengthTollerance;
int m_lengthTolerance;
///> number of line segments for arc approximation
int m_cornerArcSegments;
///> target skew value for diff pair de-skewing
@ -101,7 +101,6 @@ class PNS_MEANDERED_LINE;
class PNS_MEANDER_SHAPE
{
public:
/**
* Constructor
*
@ -116,7 +115,6 @@ class PNS_MEANDER_SHAPE
m_width( aWidth ),
m_baselineOffset( 0 )
{
}
/**
@ -271,7 +269,7 @@ class PNS_MEANDER_SHAPE
* Function BaselineLength()
*
* @return length of the base segment for the meander (i.e.
* the minimim tuned length.
* the minimum tuned length.
*/
int BaselineLength() const;
@ -326,10 +324,10 @@ class PNS_MEANDER_SHAPE
void uShape( int aSides, int aCorner, int aTop );
///> generates a 90-degree circular arc
SHAPE_LINE_CHAIN circleQuad ( VECTOR2D aP, VECTOR2D aDir, bool side );
SHAPE_LINE_CHAIN circleQuad( VECTOR2D aP, VECTOR2D aDir, bool aSide );
///> reflects a point onto other side of a given segment
VECTOR2I reflect ( VECTOR2I p, const SEG& line );
VECTOR2I reflect( VECTOR2I aP, const SEG& aLine );
///> produces a meander shape of given type
SHAPE_LINE_CHAIN genMeanderShape( VECTOR2D aP, VECTOR2D aDir, bool aSide, PNS_MEANDER_TYPE aType, int aAmpl, int aBaselineOffset = 0 );
@ -387,7 +385,6 @@ class PNS_MEANDERED_LINE
public:
PNS_MEANDERED_LINE()
{
}
/**
@ -400,7 +397,6 @@ class PNS_MEANDERED_LINE
m_placer( aPlacer ),
m_dual( aIsDual )
{
}
/**
@ -464,7 +460,6 @@ class PNS_MEANDERED_LINE
return m_meanders;
}
/**
* Function CheckSelfIntersections()
*
@ -484,7 +479,6 @@ class PNS_MEANDERED_LINE
const PNS_MEANDER_SETTINGS& Settings() const;
private:
VECTOR2I m_last;
PNS_MEANDER_PLACER_BASE* m_placer;

View File

@ -43,9 +43,9 @@ PNS_MEANDER_PLACER::PNS_MEANDER_PLACER( PNS_ROUTER* aRouter ) :
PNS_MEANDER_PLACER::~PNS_MEANDER_PLACER()
{
}
PNS_NODE* PNS_MEANDER_PLACER::CurrentNode( bool aLoopsRemoved ) const
{
if( !m_currentNode )
@ -54,6 +54,7 @@ PNS_NODE* PNS_MEANDER_PLACER::CurrentNode( bool aLoopsRemoved ) const
return m_currentNode;
}
bool PNS_MEANDER_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
VECTOR2I p;
@ -101,11 +102,13 @@ int PNS_MEANDER_PLACER::origPathLength( ) const
return total;
}
bool PNS_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
return doMove( aP, aEndItem, m_settings.m_targetLength );
}
bool PNS_MEANDER_PLACER::doMove( const VECTOR2I& aP, PNS_ITEM* aEndItem, int aTargetLength )
{
SHAPE_LINE_CHAIN pre, tuned, post;
@ -134,7 +137,7 @@ bool PNS_MEANDER_PLACER::doMove( const VECTOR2I& aP, PNS_ITEM* aEndItem, int aTa
m_lastLength = lineLen;
m_lastStatus = TUNED;
if( compareWithTollerance ( lineLen, aTargetLength, m_settings.m_lengthTollerance ) > 0 )
if( compareWithTolerance( lineLen, aTargetLength, m_settings.m_lengthTolerance ) > 0 )
{
m_lastStatus = TOO_LONG;
} else {
@ -164,7 +167,7 @@ bool PNS_MEANDER_PLACER::doMove( const VECTOR2I& aP, PNS_ITEM* aEndItem, int aTa
m_lastLength += tuned.Length();
int comp = compareWithTollerance( m_lastLength - aTargetLength, 0, m_settings.m_lengthTollerance );
int comp = compareWithTolerance( m_lastLength - aTargetLength, 0, m_settings.m_lengthTolerance );
if( comp > 0 )
m_lastStatus = TOO_LONG;
@ -172,7 +175,6 @@ bool PNS_MEANDER_PLACER::doMove( const VECTOR2I& aP, PNS_ITEM* aEndItem, int aTa
m_lastStatus = TOO_SHORT;
else
m_lastStatus = TUNED;
}
m_finalShape.Clear();
@ -194,6 +196,7 @@ bool PNS_MEANDER_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
return true;
}
bool PNS_MEANDER_PLACER::CheckFit( PNS_MEANDER_SHAPE* aShape )
{
PNS_LINE l( *m_originLine, aShape->CLine( 0 ) );
@ -214,16 +217,19 @@ const PNS_ITEMSET PNS_MEANDER_PLACER::Traces()
return PNS_ITEMSET( &m_currentTrace );
}
const VECTOR2I& PNS_MEANDER_PLACER::CurrentEnd() const
{
return m_currentEnd;
}
int PNS_MEANDER_PLACER::CurrentNet() const
{
return m_initialSegment->Net();
}
int PNS_MEANDER_PLACER::CurrentLayer() const
{
return m_initialSegment->Layers().Start();
@ -256,6 +262,7 @@ const wxString PNS_MEANDER_PLACER::TuningInfo( ) const
return status;
}
PNS_MEANDER_PLACER::TUNING_STATUS PNS_MEANDER_PLACER::TuningStatus() const
{
return m_lastStatus;

View File

@ -25,13 +25,13 @@
PNS_MEANDER_PLACER_BASE::PNS_MEANDER_PLACER_BASE( PNS_ROUTER* aRouter ) :
PNS_PLACEMENT_ALGO( aRouter )
{
}
};
PNS_MEANDER_PLACER_BASE::~PNS_MEANDER_PLACER_BASE()
{
}
};
void PNS_MEANDER_PLACER_BASE::AmplitudeStep( int aSign )
{
@ -41,6 +41,7 @@ void PNS_MEANDER_PLACER_BASE::AmplitudeStep( int aSign )
m_settings.m_maxAmplitude = a;
}
void PNS_MEANDER_PLACER_BASE::SpacingStep( int aSign )
{
int s = m_settings.m_spacing + aSign * m_settings.m_step;
@ -49,11 +50,13 @@ void PNS_MEANDER_PLACER_BASE::SpacingStep( int aSign )
m_settings.m_spacing = s;
}
void PNS_MEANDER_PLACER_BASE::UpdateSettings( const PNS_MEANDER_SETTINGS& aSettings )
{
m_settings = aSettings;
}
void PNS_MEANDER_PLACER_BASE::cutTunedLine( const SHAPE_LINE_CHAIN& aOrigin,
const VECTOR2I& aTuneStart,
const VECTOR2I& aCursorPos,
@ -84,6 +87,7 @@ void PNS_MEANDER_PLACER_BASE::cutTunedLine( const SHAPE_LINE_CHAIN& aOrigin,
aTuned.Simplify();
}
void PNS_MEANDER_PLACER_BASE::tuneLineLength( PNS_MEANDERED_LINE& aTuned, int aElongation )
{
int remaining = aElongation;
@ -147,20 +151,21 @@ void PNS_MEANDER_PLACER_BASE::tuneLineLength( PNS_MEANDERED_LINE& aTuned, int aE
m->Resize( std::max( m->Amplitude() - balance / 2, m_settings.m_minAmplitude ) );
}
}
}
}
}
}
const PNS_MEANDER_SETTINGS& PNS_MEANDER_PLACER_BASE::MeanderSettings() const
{
return m_settings;
}
int PNS_MEANDER_PLACER_BASE::compareWithTollerance ( int aValue, int aExpected, int aTollerance ) const
int PNS_MEANDER_PLACER_BASE::compareWithTolerance( int aValue, int aExpected, int aTolerance ) const
{
if( aValue < aExpected - aTollerance )
if( aValue < aExpected - aTolerance )
return -1;
else if( aValue > aExpected + aTollerance )
else if( aValue > aExpected + aTolerance )
return 1;
else
return 0;

View File

@ -118,8 +118,6 @@ public:
return false;
}
protected:
/**
@ -150,11 +148,11 @@ protected:
void tuneLineLength( PNS_MEANDERED_LINE& aTuned, int aElongation );
/**
* Function compareWithTollerance()
* Function compareWithTolerance()
*
* Compares aValue against aExpected with given tollerance.
* Compares aValue against aExpected with given tolerance.
*/
int compareWithTollerance ( int aValue, int aExpected, int aTollerance = 0 ) const;
int compareWithTolerance ( int aValue, int aExpected, int aTolerance = 0 ) const;
///> width of the meandered trace(s)
int m_currentWidth;

View File

@ -38,11 +38,12 @@ PNS_MEANDER_SKEW_PLACER::PNS_MEANDER_SKEW_PLACER ( PNS_ROUTER* aRouter ) :
{
}
PNS_MEANDER_SKEW_PLACER::~PNS_MEANDER_SKEW_PLACER( )
{
}
bool PNS_MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
VECTOR2I p;
@ -75,7 +76,6 @@ bool PNS_MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
return false;
}
m_originPair.SetGap ( Router()->Sizes().DiffPairGap() );
if( !m_originPair.PLine().SegmentCount() ||
@ -104,6 +104,7 @@ int PNS_MEANDER_SKEW_PLACER::origPathLength( ) const
return itemsetLength ( m_tunedPath );
}
int PNS_MEANDER_SKEW_PLACER::itemsetLength( const PNS_ITEMSET& aSet ) const
{
int total = 0;
@ -118,11 +119,13 @@ int PNS_MEANDER_SKEW_PLACER::itemsetLength( const PNS_ITEMSET& aSet ) const
return total;
}
int PNS_MEANDER_SKEW_PLACER::currentSkew() const
{
return m_lastLength - m_coupledLength;
}
bool PNS_MEANDER_SKEW_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
return doMove( aP, aEndItem, m_coupledLength + m_settings.m_targetSkew );

View File

@ -37,7 +37,6 @@ class PNS_ROUTER_BASE;
class PNS_MEANDER_SKEW_PLACER : public PNS_MEANDER_PLACER
{
public:
PNS_MEANDER_SKEW_PLACER( PNS_ROUTER* aRouter );
~PNS_MEANDER_SKEW_PLACER();

View File

@ -723,6 +723,7 @@ void PNS_NODE::Remove( PNS_ITEM* aItem )
}
}
void PNS_NODE::Remove( PNS_LINE& aLine )
{
removeLine( &aLine );
@ -865,8 +866,6 @@ void PNS_NODE::MapConnectivity ( PNS_JOINT* aStart, std::vector<PNS_JOINT*>& aFo
#endif
int PNS_NODE::FindLinesBetweenJoints( PNS_JOINT& aA, PNS_JOINT& aB, std::vector<PNS_LINE*>& aLines )
{
BOOST_FOREACH( PNS_ITEM* item, aA.LinkList() )

View File

@ -55,7 +55,6 @@ public:
virtual ~PNS_CLEARANCE_FUNC() {}
virtual int operator()( const PNS_ITEM* aA, const PNS_ITEM* aB ) = 0;
virtual void OverrideClearance (bool aEnable, int aNetA = 0, int aNetB = 0, int aClearance = 0) = 0;
};
class PNS_PCBNEW_CLEARANCE_FUNC : public PNS_CLEARANCE_FUNC

View File

@ -101,14 +101,14 @@ void PNS_COST_ESTIMATOR::Replace( PNS_LINE& aOldLine, PNS_LINE& aNewLine )
bool PNS_COST_ESTIMATOR::IsBetter( PNS_COST_ESTIMATOR& aOther,
double aLengthTollerance,
double aCornerTollerance ) const
double aLengthTolerance,
double aCornerTolerance ) const
{
if( aOther.m_cornerCost < m_cornerCost && aOther.m_lengthCost < m_lengthCost )
return true;
else if( aOther.m_cornerCost < m_cornerCost * aCornerTollerance &&
aOther.m_lengthCost < m_lengthCost * aLengthTollerance )
else if( aOther.m_cornerCost < m_cornerCost * aCornerTolerance &&
aOther.m_lengthCost < m_lengthCost * aLengthTolerance )
return true;
return false;
@ -224,6 +224,7 @@ void PNS_OPTIMIZER::ClearCache( bool aStaticOnly )
}
}
class LINE_RESTRICTIONS
{
public:
@ -234,7 +235,6 @@ class LINE_RESTRICTIONS
bool Check ( int aVertex1, int aVertex2, const SHAPE_LINE_CHAIN& aReplacement );
void Dump();
private:
int allowedAngles( PNS_NODE* aWorld, const PNS_LINE* aLine, const VECTOR2I& aP, bool aFirst );
@ -244,7 +244,6 @@ class LINE_RESTRICTIONS
restricted( aRestricted ),
allowedAngles( aAllowedAngles )
{
}
bool restricted;
@ -254,6 +253,7 @@ class LINE_RESTRICTIONS
std::vector<RVERTEX> m_rs;
};
// fixme: use later
int LINE_RESTRICTIONS::allowedAngles( PNS_NODE* aWorld, const PNS_LINE* aLine, const VECTOR2I& aP, bool aFirst )
{
@ -262,7 +262,6 @@ int LINE_RESTRICTIONS::allowedAngles ( PNS_NODE *aWorld, const PNS_LINE *aLine,
if( !jt )
return 0xff;
DIRECTION_45 dirs [8];
int n_dirs = 0;
@ -282,14 +281,13 @@ int LINE_RESTRICTIONS::allowedAngles ( PNS_NODE *aWorld, const PNS_LINE *aLine,
}
}
const int angleMask = DIRECTION_45::ANG_OBTUSE | DIRECTION_45::ANG_HALF_FULL | DIRECTION_45::ANG_STRAIGHT;
int outputMask = 0xff;
for( int d = 0; d < 8; d++ )
{
DIRECTION_45 refDir( ( DIRECTION_45::Directions ) d );
for( int i = 0; i < n_dirs; i++ )
{
if( !(refDir.Angle( dirs[i] ) & angleMask ) )
@ -330,23 +328,30 @@ void LINE_RESTRICTIONS::Build( PNS_NODE *aWorld, PNS_LINE *aOriginLine, const SH
{
const SEG& sp = l.CSegment( i );
r.allowedAngles = DIRECTION_45( sp ).Mask();
} else if (exiting) {
}
else if( exiting )
{
const SEG& sp = l.CSegment( i - 1 );
r.allowedAngles = DIRECTION_45( sp ).Mask();
} else {
}
else
{
r.allowedAngles = ( !aRestrictedArea.Contains( v ) ) ? 0 : 0xff;
r.restricted = r.allowedAngles ? false : true;
}
}
v_prev = v;
m_rs.push_back( r );
}
}
void LINE_RESTRICTIONS::Dump()
{
}
bool LINE_RESTRICTIONS::Check( int aVertex1, int aVertex2, const SHAPE_LINE_CHAIN& aReplacement )
{
if( m_rs.empty( ) )
@ -361,18 +366,17 @@ bool LINE_RESTRICTIONS::Check ( int aVertex1, int aVertex2, const SHAPE_LINE_CHA
int m1 = DIRECTION_45( aReplacement.CSegment( 0 ) ).Mask();
int m2;
if( aReplacement.SegmentCount() == 1 )
m2 = m1;
else
m2 = DIRECTION_45( aReplacement.CSegment( 1 ) ).Mask();
return ( ( v1.allowedAngles & m1 ) != 0 ) &&
( ( v2.allowedAngles & m2 ) != 0 );
}
bool PNS_OPTIMIZER::checkColliding( PNS_ITEM* aItem, bool aUpdateCache )
{
CACHE_VISITOR v( aItem, m_world, m_collisionKindMask );
@ -464,7 +468,6 @@ bool PNS_OPTIMIZER::mergeObtuse( PNS_LINE* aLine )
s2opt = SEG( ip, s2.B );
}
if( DIRECTION_45( s1opt ).IsObtuse( DIRECTION_45( s2opt ) ) )
{
SHAPE_LINE_CHAIN opt_path;
@ -928,7 +931,9 @@ bool PNS_OPTIMIZER::fanoutCleanup( PNS_LINE* aLine )
if(endPad)
{
endMatch = endPad->OfKind( PNS_ITEM::VIA | PNS_ITEM::SOLID );
} else {
}
else
{
endMatch = aLine->EndsWithVia();
}
@ -951,6 +956,7 @@ bool PNS_OPTIMIZER::fanoutCleanup( PNS_LINE* aLine )
return false;
}
int findCoupledVertices( const VECTOR2I& aVertex, const SEG& aOrigSeg, const SHAPE_LINE_CHAIN& aCoupled, PNS_DIFF_PAIR* aPair, int* aIndices )
{
int count = 0;
@ -959,7 +965,6 @@ int findCoupledVertices ( const VECTOR2I& aVertex, const SEG& aOrigSeg, const SH
SEG s = aCoupled.CSegment( i );
VECTOR2I projOverCoupled = s.LineProject ( aVertex );
if( s.ApproxParallel ( aOrigSeg ) )
{
int64_t dist = ( projOverCoupled - aVertex ).EuclideanNorm() - aPair->Width();
@ -975,6 +980,7 @@ int findCoupledVertices ( const VECTOR2I& aVertex, const SEG& aOrigSeg, const SH
return count;
}
bool verifyDpBypass( PNS_NODE* aNode, PNS_DIFF_PAIR* aPair, bool aRefIsP, const SHAPE_LINE_CHAIN& aNewRef, const SHAPE_LINE_CHAIN& aNewCoupled )
{
PNS_LINE refLine ( aRefIsP ? aPair->PLine() : aPair->NLine(), aNewRef );
@ -992,6 +998,7 @@ bool verifyDpBypass ( PNS_NODE *aNode, PNS_DIFF_PAIR *aPair, bool aRefIsP, const
return true;
}
bool coupledBypass( PNS_NODE* aNode, PNS_DIFF_PAIR* aPair, bool aRefIsP, const SHAPE_LINE_CHAIN& aRef, const SHAPE_LINE_CHAIN& aRefBypass, const SHAPE_LINE_CHAIN& aCoupled, SHAPE_LINE_CHAIN& aNewCoupled )
{
int vStartIdx[1024]; // fixme: possible overflow
@ -1005,9 +1012,11 @@ bool coupledBypass ( PNS_NODE *aNode, PNS_DIFF_PAIR *aPair, bool aRefIsP, const
int si, ei;
for( int i=0; i< nStarts; i++ )
{
for( int j = 1; j < aCoupled.PointCount() - 1; j++ )
{
int delta = std::abs ( vStartIdx[i] - j );
if( delta > 1 )
{
const VECTOR2I& vs = aCoupled.CPoint( vStartIdx[i] );
@ -1033,6 +1042,7 @@ bool coupledBypass ( PNS_NODE *aNode, PNS_DIFF_PAIR *aPair, bool aRefIsP, const
}
}
}
}
if( found )
@ -1041,6 +1051,7 @@ bool coupledBypass ( PNS_NODE *aNode, PNS_DIFF_PAIR *aPair, bool aRefIsP, const
return found;
}
bool checkDpColliding( PNS_NODE* aNode, PNS_DIFF_PAIR* aPair, bool aIsP, const SHAPE_LINE_CHAIN& aPath )
{
PNS_LINE tmp ( aIsP ? aPair->PLine() : aPair->NLine(), aPath );
@ -1076,7 +1087,6 @@ bool PNS_OPTIMIZER::mergeDpStep( PNS_DIFF_PAIR *aPair, bool aTryP, int step )
SHAPE_LINE_CHAIN newCoup;
int64_t deltaCoupled = -1, deltaUni = -1;
newRef = currentPath;
newRef.Replace( s1.Index(), s2.Index(), bypass );
@ -1111,6 +1121,7 @@ bool PNS_OPTIMIZER::mergeDpStep( PNS_DIFF_PAIR *aPair, bool aTryP, int step )
return false;
}
bool PNS_OPTIMIZER::mergeDpSegments( PNS_DIFF_PAIR* aPair )
{
int step_p = aPair->CP().SegmentCount() - 2;
@ -1151,9 +1162,8 @@ bool PNS_OPTIMIZER::mergeDpSegments( PNS_DIFF_PAIR *aPair )
return true;
}
bool PNS_OPTIMIZER::Optimize( PNS_DIFF_PAIR* aPair )
{
return mergeDpSegments( aPair );
}

View File

@ -62,7 +62,7 @@ public:
void Remove( PNS_LINE& aLine );
void Replace( PNS_LINE& aOldLine, PNS_LINE& aNewLine );
bool IsBetter( PNS_COST_ESTIMATOR& aOther, double aLengthTollerance,
bool IsBetter( PNS_COST_ESTIMATOR& aOther, double aLengthTolerance,
double aCornerTollerace ) const;
double GetLengthCost() const { return m_lengthCost; }

View File

@ -148,7 +148,6 @@ public:
*/
virtual void FlipPosture()
{
}
/**
@ -160,7 +159,6 @@ public:
*/
virtual void UpdateSizes( const PNS_SIZES_SETTINGS& aSizes )
{
}
/**
@ -172,7 +170,6 @@ public:
*/
virtual void SetOrthoMode ( bool aOrthoMode )
{
}
/**
@ -182,7 +179,6 @@ public:
*/
virtual void GetModifiedNets( std::vector<int> &aNets ) const
{
}
};

View File

@ -49,8 +49,6 @@
#include "pns_meander_skew_placer.h"
#include "pns_dp_meander_placer.h"
#include <router/router_preview_item.h>
#include <class_board.h>
@ -87,11 +85,12 @@ PNS_PCBNEW_CLEARANCE_FUNC::PNS_PCBNEW_CLEARANCE_FUNC( BOARD* aBoard )
m_defaultClearance = 254000; // aBoard->m_NetClasses.Find ("Default clearance")->GetClearance();
}
PNS_PCBNEW_CLEARANCE_FUNC::~PNS_PCBNEW_CLEARANCE_FUNC()
{
}
int PNS_PCBNEW_CLEARANCE_FUNC::localPadClearance( const PNS_ITEM* aItem ) const
{
if( !aItem->Parent() || aItem->Parent()->Type() != PCB_PAD_T )
@ -101,6 +100,7 @@ int PNS_PCBNEW_CLEARANCE_FUNC::localPadClearance( const PNS_ITEM* aItem ) const
return pad->GetLocalClearance();
}
int PNS_PCBNEW_CLEARANCE_FUNC::operator()( const PNS_ITEM* aA, const PNS_ITEM* aB )
{
int net_a = aA->Net();
@ -123,7 +123,8 @@ int PNS_PCBNEW_CLEARANCE_FUNC::operator()( const PNS_ITEM* aA, const PNS_ITEM* a
cl_b = std::max( cl_b, pad_b );
return std::max( cl_a, cl_b );
};
}
// fixme: ugly hack to make the optimizer respect gap width for currently routed differential pair.
void PNS_PCBNEW_CLEARANCE_FUNC::OverrideClearance( bool aEnable, int aNetA, int aNetB , int aClearance )
@ -249,6 +250,7 @@ PNS_ITEM* PNS_ROUTER::syncTrack( TRACK* aTrack )
if( aTrack->GetFlags( ) & DP_COUPLED )
s->Mark ( MK_DP_COUPLED );
s->SetWidth( aTrack->GetWidth() );
s->SetLayers( PNS_LAYERSET( aTrack->GetLayer() ) );
s->SetParent( aTrack );
@ -280,6 +282,7 @@ void PNS_ROUTER::SetBoard( BOARD* aBoard )
TRACE( 1, "m_board = %p\n", m_board );
}
void PNS_ROUTER::SyncWorld()
{
if( !m_board )
@ -524,11 +527,13 @@ bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLa
return rv;
}
BOARD* PNS_ROUTER::GetBoard()
{
return m_board;
}
void PNS_ROUTER::eraseView()
{
BOOST_FOREACH( BOARD_ITEM* item, m_hiddenItems )
@ -710,7 +715,6 @@ void PNS_ROUTER::movePlacing( const VECTOR2I& aP, PNS_ITEM* aEndItem )
m_placer->Move( aP, aEndItem );
PNS_ITEMSET current = m_placer->Traces();
BOOST_FOREACH( const PNS_ITEM* item, current.CItems() )
{
if( !item->OfKind( PNS_ITEM::LINE ) )
@ -723,7 +727,6 @@ void PNS_ROUTER::movePlacing( const VECTOR2I& aP, PNS_ITEM* aEndItem )
DisplayItem( &l->Via() );
}
//PNS_ITEMSET tmp( &current );
updateView( m_placer->CurrentNode( true ), current );
@ -844,7 +847,6 @@ void PNS_ROUTER::StopRouting()
}
}
if( !RoutingInProgress() )
return;
@ -932,13 +934,16 @@ void PNS_ROUTER::DumpLog()
logger->Save( "/tmp/shove.log" );
}
bool PNS_ROUTER::IsPlacingVia() const
{
if( !m_placer )
return NULL;
return m_placer->IsPlacingVia();
}
void PNS_ROUTER::SetOrthoMode( bool aEnable )
{
if( !m_placer )
@ -947,9 +952,8 @@ void PNS_ROUTER::SetOrthoMode( bool aEnable )
m_placer->SetOrthoMode( aEnable );
}
void PNS_ROUTER::SetMode( PNS_ROUTER_MODE aMode )
{
m_mode = aMode;
}

View File

@ -277,7 +277,6 @@ private:
wxString m_toolStatusbarName;
wxString m_failureReason;
};
#endif

View File

@ -137,7 +137,6 @@ private:
PNS_MODE m_routingMode;
PNS_OPTIMIZATION_EFFORT m_optimizerEffort;
int m_walkaroundIterationLimit;
int m_shoveIterationLimit;
TIME_LIMIT m_shoveTimeLimit;

View File

@ -46,7 +46,6 @@ void PNS_SHOVE::replaceItems ( PNS_ITEM *aOld, PNS_ITEM *aNew )
{
OPT_BOX2I changed_area = ChangedArea( aOld, aNew );
if( changed_area )
{
assert( !changed_area->Contains( VECTOR2I( 0, 0 ) ) );
@ -66,6 +65,7 @@ int PNS_SHOVE::getClearance( PNS_ITEM *aA, PNS_ITEM *aB ) const
return m_currentNode->GetClearance( aA, aB );
}
static void sanityCheck( PNS_LINE* aOld, PNS_LINE* aNew )
{
assert( aOld->CPoint( 0 ) == aNew->CPoint( 0 ) );
@ -99,6 +99,7 @@ PNS_LINE* PNS_SHOVE::assembleLine( const PNS_SEGMENT* aSeg, int* aIndex )
return l;
}
// A dumb function that checks if the shoved line is shoved the right way, e.g.
// visually "outwards" of the line/via applying pressure on it. Unfortunately there's no
// mathematical concept of orientation of an open curve, so we use some primitive heuristics:
@ -351,8 +352,6 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE* aCurrent, PNS_LINE
SHOVE_STATUS rv = ProcessSingleLine( aCurrent, aObstacle, shovedLine );
if( rv == SH_OK )
{
if( shovedLine->Marker() & MK_HEAD )
@ -499,7 +498,6 @@ bool PNS_SHOVE::pushSpringback( PNS_NODE* aNode, const PNS_ITEMSET& aHeadItems,
if( !m_nodeStack.empty() )
prev_area = m_nodeStack.back().m_affectedArea;
st.m_node = aNode;
st.m_cost = aCost;
st.m_headItems = aHeadItems;
@ -574,7 +572,6 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
if( aVia->Marker() & MK_HEAD )
m_draggedViaHeadSet.Add( clone ( lp.second ) );
}
}
@ -955,6 +952,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveMainLoop()
return st;
}
OPT_BOX2I PNS_SHOVE::totalAffectedArea() const
{
OPT_BOX2I area;
@ -1047,7 +1045,6 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
}
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveMultiLines( const PNS_ITEMSET& aHeadSet )
{
SHOVE_STATUS st = SH_OK;
@ -1067,7 +1064,6 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveMultiLines( const PNS_ITEMSET& aHeadSet
headSet.Add( clone( headOrig ) );
}
m_lineStack.clear();
m_optimizerQueue.clear();
m_logger.Clear();
@ -1128,12 +1124,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveMultiLines( const PNS_ITEMSET& aHeadSet
return st;
}
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveDraggingVia( PNS_VIA* aVia, const VECTOR2I& aWhere,
PNS_VIA** aNewVia )
{
SHOVE_STATUS st = SH_OK;
m_lineStack.clear();
m_optimizerQueue.clear();
m_newHead = OPT_LINE();
@ -1223,7 +1219,6 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead )
break;
}
if( Settings().SmartPads() )
optFlags |= PNS_OPTIMIZER::SMART_PADS ;
@ -1254,6 +1249,7 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead )
}
}
PNS_NODE* PNS_SHOVE::CurrentNode()
{
return m_nodeStack.empty() ? m_root : m_nodeStack.back().m_node;

View File

@ -117,7 +117,6 @@ private:
OPT_BOX2I totalAffectedArea() const;
void unwindStack( PNS_SEGMENT* aSeg );
void unwindStack( PNS_ITEM* aItem );
@ -140,7 +139,6 @@ private:
OPT_BOX2I m_affectedAreaSum;
SHOVE_STATUS shoveIteration( int aIter );
SHOVE_STATUS shoveMainLoop();

View File

@ -66,6 +66,7 @@ int PNS_SIZES_SETTINGS::inheritTrackWidth( PNS_ITEM* aItem )
return ( mval == INT_MAX ? 0 : mval );
}
void PNS_SIZES_SETTINGS::Init( BOARD* aBoard, PNS_ITEM* aStartItem, int aNet )
{
BOARD_DESIGN_SETTINGS &bds = aBoard->GetDesignSettings();
@ -121,11 +122,13 @@ void PNS_SIZES_SETTINGS::Init( BOARD* aBoard, PNS_ITEM* aStartItem, int aNet )
m_layerPairs.clear();
}
void PNS_SIZES_SETTINGS::ClearLayerPairs()
{
m_layerPairs.clear();
}
void PNS_SIZES_SETTINGS::AddLayerPair( int aL1, int aL2 )
{
int top = std::min( aL1, aL2 );
@ -135,6 +138,7 @@ void PNS_SIZES_SETTINGS::AddLayerPair( int aL1, int aL2 )
m_layerPairs[top] = bottom;
}
void PNS_SIZES_SETTINGS::ImportCurrent( BOARD_DESIGN_SETTINGS& aSettings )
{
m_trackWidth = aSettings.GetCurrentTrackWidth();
@ -142,6 +146,7 @@ void PNS_SIZES_SETTINGS::ImportCurrent( BOARD_DESIGN_SETTINGS& aSettings )
m_viaDrill = aSettings.GetCurrentViaDrill();
}
int PNS_SIZES_SETTINGS::GetLayerTop() const
{
if( m_layerPairs.empty() )
@ -150,6 +155,7 @@ int PNS_SIZES_SETTINGS::GetLayerTop() const
return m_layerPairs.begin()->first;
}
int PNS_SIZES_SETTINGS::GetLayerBottom() const
{
if( m_layerPairs.empty() )

View File

@ -95,6 +95,7 @@ void PNS_TOOL_BASE::Reset( RESET_REASON aReason )
m_router->SetView( getView() );
}
PNS_ITEM* PNS_TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer )
{
int tl = getView()->GetTopLayer();
@ -178,6 +179,7 @@ void PNS_TOOL_BASE::highlightNet( bool aEnabled, int aNetcode )
getView()->UpdateAllLayersColor();
}
void PNS_TOOL_BASE::updateStartItem( TOOL_EVENT& aEvent )
{
int tl = getView()->GetTopLayer();
@ -227,6 +229,7 @@ void PNS_TOOL_BASE::updateStartItem( TOOL_EVENT& aEvent )
}
}
void PNS_TOOL_BASE::updateEndItem( TOOL_EVENT& aEvent )
{
VECTOR2I mp = m_ctls->GetMousePosition();

View File

@ -32,7 +32,6 @@
bool PNS_TOPOLOGY::SimplifyLine( PNS_LINE* aLine )
{
if( !aLine->LinkedSegments() || !aLine->SegmentCount() )
return false;
@ -54,6 +53,7 @@ bool PNS_TOPOLOGY::SimplifyLine ( PNS_LINE *aLine )
return false;
}
const PNS_TOPOLOGY::JOINT_SET PNS_TOPOLOGY::ConnectedJoints( PNS_JOINT* aStart )
{
std::deque<PNS_JOINT*> searchQueue;
@ -108,7 +108,9 @@ bool PNS_TOPOLOGY::LeadingRatLine( const PNS_LINE *aTrack, SHAPE_LINE_CHAIN& aRa
if( ( !track.EndsWithVia() && jt->LinkCount() >= 2 ) || ( track.EndsWithVia() && jt->LinkCount() >= 3 ) ) // we got something connected
{
end = jt->Pos();
} else {
}
else
{
int anchor;
PNS_TOPOLOGY topo( tmpNode.get() );
@ -208,16 +210,20 @@ bool PNS_TOPOLOGY::followTrivialPath ( PNS_LINE *aLine, bool aLeft, PNS_ITEMSET&
{
aSet.Prepend( via );
aSet.Prepend( l );
} else {
}
else
{
aSet.Add( via );
aSet.Add( l );
}
return followTrivialPath( l, aLeft, aSet, aVisited );
}
return false;
}
const PNS_ITEMSET PNS_TOPOLOGY::AssembleTrivialPath( PNS_SEGMENT* aStart )
{
PNS_ITEMSET path;
@ -233,38 +239,46 @@ const PNS_ITEMSET PNS_TOPOLOGY::AssembleTrivialPath ( PNS_SEGMENT *aStart )
return path;
}
const PNS_ITEMSET PNS_TOPOLOGY::ConnectedItems( PNS_JOINT* aStart, int aKindMask )
{
return PNS_ITEMSET();
}
const PNS_ITEMSET PNS_TOPOLOGY::ConnectedItems( PNS_ITEM* aStart, int aKindMask )
{
return PNS_ITEMSET();
}
int PNS_TOPOLOGY::MatchDpSuffix( wxString aNetName, wxString& aComplementNet, wxString& aBaseDpName )
{
int rv = 0;
if( aNetName.EndsWith( "+" ) )
{
aComplementNet = "-";
rv = 1;
} else if (aNetName.EndsWith("_P"))
}
else if( aNetName.EndsWith( "_P" ) )
{
aComplementNet = "_N";
rv = 1;
} else if (aNetName.EndsWith("-"))
}
else if( aNetName.EndsWith( "-" ) )
{
aComplementNet = "+";
rv = -1;
} else if (aNetName.EndsWith("_N"))
}
else if( aNetName.EndsWith( "_N" ) )
{
aComplementNet = "_P";
rv = -1;
}
if (rv != 0) {
if( rv != 0 )
{
aBaseDpName = aNetName.Left( aNetName.Length() - aComplementNet.Length() );
aComplementNet = aBaseDpName + aComplementNet;
}
@ -356,5 +370,6 @@ bool PNS_TOPOLOGY::AssembleDiffPair ( PNS_ITEM *aStart, PNS_DIFF_PAIR& aPair )
aPair = PNS_DIFF_PAIR( *lp, *ln );
aPair.SetWidth( lp->Width() );
aPair.SetLayers( lp->Layers() );
return true;
}

View File

@ -52,8 +52,6 @@ class PNS_TOPOLOGY
const PNS_ITEMSET ConnectedItems( PNS_ITEM* aStart, int aKindMask = PNS_ITEM::ANY );
int64_t ShortestConnectionLength( PNS_ITEM* aFrom, PNS_ITEM* aTo );
const PNS_ITEMSET AssembleTrivialPath( PNS_SEGMENT* aStart );
const PNS_DIFF_PAIR AssembleDiffPair( PNS_SEGMENT* aStart );
@ -63,10 +61,7 @@ class PNS_TOPOLOGY
const PNS_LINE DpCoupledLine( PNS_LINE* aLine );
bool AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair );
private:
bool followTrivialPath( PNS_LINE* aLine, bool aLeft, PNS_ITEMSET& aSet, std::set<PNS_ITEM*>& aVisited );
PNS_NODE *m_world;

View File

@ -22,22 +22,22 @@
#include "pns_router.h"
#include "pns_meander_placer.h"
PNS_TUNE_STATUS_POPUP::PNS_TUNE_STATUS_POPUP ( PCB_EDIT_FRAME *parent ) :
WX_STATUS_POPUP ( parent )
PNS_TUNE_STATUS_POPUP::PNS_TUNE_STATUS_POPUP( PCB_EDIT_FRAME* aParent ) :
WX_STATUS_POPUP( aParent )
{
m_panel->SetBackgroundColour( wxColour( 64, 64, 64 ) );
m_statusLine = new wxStaticText( m_panel, wxID_ANY,
wxT("Status text 1\n") ) ;
m_statusLine = new wxStaticText( m_panel, wxID_ANY, wxT( "Status text 1\n" ) ) ;
m_topSizer->Add( m_statusLine, 1, wxALL | wxEXPAND, 5 );
updateSize();
}
PNS_TUNE_STATUS_POPUP::~PNS_TUNE_STATUS_POPUP()
{
}
void PNS_TUNE_STATUS_POPUP::Update( PNS_ROUTER* aRouter )
{
PNS_MEANDER_PLACER_BASE* placer = dynamic_cast<PNS_MEANDER_PLACER_BASE*>( aRouter->Placer() );

View File

@ -32,10 +32,9 @@ class PNS_ROUTER;
class PNS_TUNE_STATUS_POPUP : public WX_STATUS_POPUP
{
public:
PNS_TUNE_STATUS_POPUP ( PCB_EDIT_FRAME *parent );
PNS_TUNE_STATUS_POPUP( PCB_EDIT_FRAME* aParent );
~PNS_TUNE_STATUS_POPUP();
void Update( PNS_ROUTER* aRouter );
private:

View File

@ -93,29 +93,31 @@ SHAPE_RECT ApproximateSegmentAsRect( const SHAPE_SEGMENT& aSeg )
std::abs( p1.x - p0.x ), std::abs( p1.y - p0.y ) );
}
void DrawDebugPoint ( VECTOR2I p, int color )
void DrawDebugPoint( VECTOR2I aP, int aColor )
{
SHAPE_LINE_CHAIN l;
l.Append ( p - VECTOR2I(-50000, -50000) );
l.Append ( p + VECTOR2I(-50000, -50000) );
l.Append( aP - VECTOR2I( -50000, -50000 ) );
l.Append( aP + VECTOR2I( -50000, -50000 ) );
//printf("router @ %p\n", PNS_ROUTER::GetInstance());
PNS_ROUTER::GetInstance()->DisplayDebugLine ( l, color, 10000 );
PNS_ROUTER::GetInstance()->DisplayDebugLine ( l, aColor, 10000 );
l.Clear();
l.Append ( p - VECTOR2I(50000, -50000) );
l.Append ( p + VECTOR2I(50000, -50000) );
l.Append( aP - VECTOR2I( 50000, -50000 ) );
l.Append( aP + VECTOR2I( 50000, -50000 ) );
PNS_ROUTER::GetInstance()->DisplayDebugLine ( l, color, 10000 );
PNS_ROUTER::GetInstance()->DisplayDebugLine( l, aColor, 10000 );
}
void DrawDebugBox ( BOX2I b, int color )
void DrawDebugBox( BOX2I aB, int aColor )
{
SHAPE_LINE_CHAIN l;
VECTOR2I o = b.GetOrigin();
VECTOR2I s = b.GetSize();
VECTOR2I o = aB.GetOrigin();
VECTOR2I s = aB.GetSize();
l.Append( o );
l.Append( o.x + s.x, o.y );
@ -124,33 +126,33 @@ void DrawDebugBox ( BOX2I b, int color )
l.Append( o );
//printf("router @ %p\n", PNS_ROUTER::GetInstance());
PNS_ROUTER::GetInstance()->DisplayDebugLine ( l, color, 10000 );
PNS_ROUTER::GetInstance()->DisplayDebugLine( l, aColor, 10000 );
}
void DrawDebugSeg ( SEG s, int color )
void DrawDebugSeg( SEG aS, int aColor )
{
SHAPE_LINE_CHAIN l;
l.Append ( s.A );
l.Append ( s.B );
l.Append( aS.A );
l.Append( aS.B );
PNS_ROUTER::GetInstance()->DisplayDebugLine ( l, color, 10000 );
PNS_ROUTER::GetInstance()->DisplayDebugLine( l, aColor, 10000 );
}
void DrawDebugDirs ( VECTOR2D p, int mask, int color )
{
BOX2I b ( p - VECTOR2I ( 10000, 10000 ), VECTOR2I ( 20000, 20000 ) );
DrawDebugBox ( b, color );
void DrawDebugDirs( VECTOR2D aP, int aMask, int aColor )
{
BOX2I b( aP - VECTOR2I( 10000, 10000 ), VECTOR2I( 20000, 20000 ) );
DrawDebugBox( b, aColor );
for( int i = 0; i < 8; i++ )
{
if ( (1<<i) & mask )
if( ( 1 << i ) & aMask )
{
VECTOR2I v = DIRECTION_45( ( DIRECTION_45::Directions ) i ).ToVector() * 100000;
DrawDebugSeg ( SEG (p, p+v), color );
DrawDebugSeg( SEG( aP, aP + v ), aColor );
}
}
}
@ -163,12 +165,14 @@ OPT_BOX2I ChangedArea ( const PNS_ITEM *aItemA, const PNS_ITEM *aItemB )
const PNS_VIA* vb = static_cast<const PNS_VIA*>( aItemB );
return va->ChangedArea( vb );
} else if ( aItemA->OfKind ( PNS_ITEM::LINE ) && aItemB->OfKind ( PNS_ITEM::LINE ) )
}
else if( aItemA->OfKind( PNS_ITEM::LINE ) && aItemB->OfKind( PNS_ITEM::LINE ) )
{
const PNS_LINE* la = static_cast<const PNS_LINE*> ( aItemA );
const PNS_LINE* lb = static_cast<const PNS_LINE*> ( aItemB );
return la->ChangedArea( lb );
}
return OPT_BOX2I();
}

View File

@ -41,10 +41,10 @@ const SHAPE_LINE_CHAIN SegmentHull ( const SHAPE_SEGMENT& aSeg, int aClearance,
SHAPE_RECT ApproximateSegmentAsRect( const SHAPE_SEGMENT& aSeg );
void DrawDebugPoint ( VECTOR2I p, int color );
void DrawDebugBox ( BOX2I b, int color );
void DrawDebugSeg ( SEG s, int color );
void DrawDebugDirs ( VECTOR2D p, int mask, int color );
void DrawDebugPoint( VECTOR2I aP, int aColor );
void DrawDebugBox( BOX2I aB, int aColor );
void DrawDebugSeg( SEG aS, int aColor );
void DrawDebugDirs( VECTOR2D aP, int aMask, int aColor );
OPT_BOX2I ChangedArea( const PNS_ITEM* aItemA, const PNS_ITEM* aItemB );

View File

@ -96,6 +96,7 @@ PNS_VIA* PNS_VIA::Clone ( ) const
return v;
}
OPT_BOX2I PNS_VIA::ChangedArea ( const PNS_VIA* aOther ) const
{
if ( aOther->Pos() != Pos() )

View File

@ -151,9 +151,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
s_cw = m_forceCw ? IN_PROGRESS : STUCK;
s_ccw = m_forceCw ? STUCK : IN_PROGRESS;
m_forceSingleDirection = true;
} else {
m_forceSingleDirection = false;
}
@ -253,7 +251,5 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
PNS_OPTIMIZER::Optimize( &aWalkPath, PNS_OPTIMIZER::MERGE_OBTUSE, m_world );
}
return st;
}

View File

@ -23,10 +23,10 @@
template <class T> class RANGED_NUM {
public:
RANGED_NUM ( T aValue = 0, T aTollerancePlus = 0, T aTolleranceMinus = 0) :
RANGED_NUM( T aValue = 0, T aTolerancePlus = 0, T aToleranceMinus = 0 ) :
m_value( aValue ),
m_tollerancePlus ( aTollerancePlus ),
m_tolleranceMinus ( aTolleranceMinus )
m_tolerancePlus( aTolerancePlus ),
m_toleranceMinus( aToleranceMinus )
{}
operator T()
@ -42,12 +42,11 @@ template <class T> class RANGED_NUM {
bool Matches( const T& aOther ) const
{
return ( aOther >= m_value - m_tolleranceMinus && aOther <= m_value + m_tollerancePlus );
return ( aOther >= m_value - m_toleranceMinus && aOther <= m_value + m_tolerancePlus );
}
private:
T m_value, m_tollerancePlus, m_tolleranceMinus;
T m_value, m_tolerancePlus, m_toleranceMinus;
};
#endif

View File

@ -274,7 +274,7 @@ ROUTER_TOOL::~ROUTER_TOOL()
void ROUTER_TOOL::Reset( RESET_REASON aReason )
{
printf("RESET\n");
//printf("RESET\n");
if( m_router )
delete m_router;
@ -299,6 +299,7 @@ void ROUTER_TOOL::Reset( RESET_REASON aReason )
Go( &ROUTER_TOOL::TuneSingleTrace, COMMON_ACTIONS::routerActivateTuneSingleTrace.MakeEvent() );
}
int ROUTER_TOOL::getDefaultWidth( int aNetCode )
{
int w, d1, d2;
@ -479,7 +480,6 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
else if( aEvent.IsAction( &COMMON_ACTIONS::trackViaSizeChanged ) )
{
PNS_SIZES_SETTINGS sizes( m_savedSizes );
sizes.ImportCurrent( m_board->GetDesignSettings() );
m_router->UpdateSizes( sizes );
@ -581,6 +581,7 @@ void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent )
TRACE( 0, "%s, layer : %d", m_endItem->KindStr().c_str() % m_endItem->Layers().Start() );
}
int ROUTER_TOOL::getStartLayer( const PNS_ITEM* aItem )
{
int tl = getView()->GetTopLayer();
@ -597,6 +598,8 @@ int ROUTER_TOOL::getStartLayer( const PNS_ITEM* aItem )
return tl;
}
void ROUTER_TOOL::switchLayerOnViaPlacement()
{
int al = m_frame->GetActiveLayer();
@ -616,6 +619,7 @@ void ROUTER_TOOL::switchLayerOnViaPlacement()
}
}
bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType )
{
BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
@ -651,7 +655,6 @@ bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType )
return false;
}
sizes.SetViaType ( aType );
m_router->ToggleViaPlacement( );
m_router->UpdateSizes( sizes );
@ -697,7 +700,6 @@ void ROUTER_TOOL::performRouting()
return;
}
m_tuneStatusPopup = new PNS_TUNE_STATUS_POPUP( m_frame );
m_tuneStatusPopup->Popup();
@ -715,14 +717,12 @@ void ROUTER_TOOL::performRouting()
}
else if( evt->IsMotion() )
{
wxPoint p = wxGetMousePosition();
p.x += 20;
p.y += 20;
m_tuneStatusPopup->Update( m_router );
m_tuneStatusPopup->Move( p );
updateEndItem( *evt );
m_router->SetOrthoMode( evt->Modifier ( MD_CTRL ) );
m_router->Move( m_endSnapPoint, m_endItem );
@ -796,24 +796,28 @@ void ROUTER_TOOL::performRouting()
highlightNet( false );
}
int ROUTER_TOOL::RouteSingleTrace( TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Route Track" ) );
return mainLoop( PNS_MODE_ROUTE_SINGLE );
}
int ROUTER_TOOL::RouteDiffPair( TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Router Differential Pair" ) );
return mainLoop( PNS_MODE_ROUTE_DIFF_PAIR );
}
int ROUTER_TOOL::TuneSingleTrace( TOOL_EVENT& aEvent )
{
m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Tune Track Length" ) );
return mainLoop( PNS_MODE_TUNE_SINGLE );
}
int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
{
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
@ -875,6 +879,7 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
return 0;
}
int ROUTER_TOOL::InlineDrag( TOOL_EVENT& aEvent )
{
return 0;
@ -919,6 +924,7 @@ int ROUTER_TOOL::InlineDrag ( TOOL_EVENT& aEvent )
}
void ROUTER_TOOL::performDragging()
{
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();

View File

@ -57,7 +57,6 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem )
{
m_originLayer = aItem->Layers().Start();
if( aItem->OfKind ( PNS_ITEM::LINE ) )
{
const PNS_LINE* l=static_cast<const PNS_LINE*>( aItem );

View File

@ -99,7 +99,7 @@ bool EDIT_TOOL::invokeInlineRouter()
if( track || via )
{
printf("Calling interactive drag\n");
//printf("Calling interactive drag\n");
m_toolMgr->RunAction( COMMON_ACTIONS::routerInlineDrag, true );
return true;
}
@ -187,11 +187,8 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
m_cursor = grid.Align( evt->Position() );
isDragAndDrop = evt->IsDrag( BUT_LEFT );
if( m_dragging )
{
m_cursor = grid.BestSnapAnchor( evt->Position(), selection.Item<BOARD_ITEM>( 0 ) );
getViewControls()->ForceCursorPosition ( true, m_cursor );
@ -225,7 +222,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
VECTOR2I origin;
if( evt->IsDrag( BUT_LEFT ) )
mousePos = evt->DragOrigin();
@ -249,9 +245,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
m_offset = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) )->GetPosition() -
wxPoint( origin.x, origin.y );
getViewControls()->ForceCursorPosition( true, origin );
}
controls->SetAutoPan( true );
@ -543,7 +537,6 @@ void EDIT_TOOL::remove( BOARD_ITEM* aItem )
if( m_editModules )
{
MODULE* module = static_cast<MODULE*>( aItem->GetParent() );
module->SetLastEditTime();
board->m_Status_Pcb = 0; // it is done in the legacy view
@ -569,6 +562,7 @@ void EDIT_TOOL::remove( BOARD_ITEM* aItem )
DisplayError( getEditFrame<PCB_BASE_FRAME>(), _( "Cannot delete the only remaining pad of the module (modules on PCB must have at least one pad)." ) );
return;
}
getView()->Remove( aItem );
board->Remove( aItem );
}
@ -707,6 +701,7 @@ void EDIT_TOOL::processChanges( const PICKED_ITEMS_LIST* aList )
}
}
int EDIT_TOOL::editFootprintInFpEditor( const TOOL_EVENT& aEvent )
{
MODULE *mod = uniqueSelected<MODULE>();

View File

@ -43,23 +43,25 @@
GRID_HELPER::GRID_HELPER( PCB_BASE_FRAME* aFrame ) :
m_frame( aFrame )
{
}
GRID_HELPER::~GRID_HELPER()
{
}
void GRID_HELPER::SetGrid( int aSize )
{
assert( false );
}
void GRID_HELPER::SetOrigin( const VECTOR2I& aOrigin )
{
}
VECTOR2I GRID_HELPER::GetGrid()
{
PCB_SCREEN* screen = m_frame->GetScreen();
@ -69,11 +71,13 @@ VECTOR2I GRID_HELPER::GetGrid ()
return VECTOR2I ( KiROUND( size.x ), KiROUND( size.y ) );
}
VECTOR2I GRID_HELPER::GetOrigin()
{
return VECTOR2I( 0, 0 );
}
void GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I aOrigin, bool aEnableDiagonal )
{
if( aEnable )
@ -84,6 +88,7 @@ void GRID_HELPER::SetAuxAxes ( bool aEnable, const VECTOR2I aOrigin, bool aEnabl
m_diagonalAuxAxesEnable = aEnable;
}
VECTOR2I GRID_HELPER::Align( const VECTOR2I& aPoint )
{
const VECTOR2D gridOffset( GetOrigin () );
@ -104,6 +109,7 @@ VECTOR2I GRID_HELPER::Align ( const VECTOR2I& aPoint )
return nearest;
}
VECTOR2I GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, BOARD_ITEM* aItem )
{
clearAnchors();
@ -144,6 +150,7 @@ VECTOR2I GRID_HELPER::BestDragOrigin ( const VECTOR2I &aMousePos, BOARD_ITEM *aI
return best ? best->pos : aMousePos;
}
std::set<BOARD_ITEM*> GRID_HELPER::queryVisible( const BOX2I& aArea )
{
std::set<BOARD_ITEM*> items;
@ -163,6 +170,7 @@ std::set<BOARD_ITEM *> GRID_HELPER::queryVisible ( const BOX2I& aArea )
return items;
}
VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I &aOrigin, BOARD_ITEM* aDraggedItem )
{
double worldScale = m_frame->GetGalCanvas()->GetGAL()->GetWorldScale();
@ -193,11 +201,11 @@ VECTOR2I GRID_HELPER::BestSnapAnchor ( const VECTOR2I &aOrigin, BOARD_ITEM *aDra
return nearestGrid;
}
void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos )
{
VECTOR2I origin;
switch( aItem->Type() )
{
case PCB_MODULE_T:
@ -219,7 +227,6 @@ void GRID_HELPER::computeAnchors ( BOARD_ITEM *aItem, const VECTOR2I& aRefPos )
VECTOR2I end = dseg->GetEnd();
//LAYER_ID layer = dseg->GetLayer();
switch( dseg->GetShape() )
{
case S_CIRCLE:
@ -301,12 +308,11 @@ void GRID_HELPER::computeAnchors ( BOARD_ITEM *aItem, const VECTOR2I& aRefPos )
addAnchor( aItem->GetPosition(), ORIGIN, aItem );
default:
break;
}
}
GRID_HELPER::ANCHOR* GRID_HELPER::nearestAnchor( VECTOR2I aPos, int aFlags, LSET aMatchLayers )
{
double minDist = std::numeric_limits<double>::max();
@ -330,5 +336,4 @@ GRID_HELPER::ANCHOR* GRID_HELPER::nearestAnchor ( VECTOR2I aPos, int aFlags, LSE
}
return best;
}

View File

@ -54,7 +54,6 @@ public:
VECTOR2I BestSnapAnchor ( const VECTOR2I &aOrigin, BOARD_ITEM* aDraggedItem );
private:
enum ANCHOR_FLAGS {
CORNER = 0x1,
OUTLINE = 0x2,

View File

@ -36,7 +36,6 @@
#include <class_pcb_text.h>
#include <class_drawsegment.h>
#include <wxPcbStruct.h>
#include <collectors.h>
#include <confirm.h>
@ -295,7 +294,6 @@ bool SELECTION_TOOL::selectCursor( const VECTOR2I& aWhere, bool aOnDrag )
return true;
default:
// Apply some ugly heuristics to avoid disambiguation menus whenever possible
guessSelectionCandidates( collector );
@ -414,6 +412,7 @@ void SELECTION_TOOL::setTransitions()
Go( &SELECTION_TOOL::findMove, COMMON_ACTIONS::findMove.MakeEvent() );
}
SELECTION_LOCK_FLAGS SELECTION_TOOL::CheckLock()
{
if( !m_locked || m_editModules )
@ -521,6 +520,7 @@ void SELECTION_TOOL::findCallback( BOARD_ITEM* aItem )
{
clearSelection();
select( aItem );
getView()->SetCenter( VECTOR2D( aItem->GetPosition() ) );
// Inform other potentially interested tools
m_toolMgr->ProcessEvent( SelectedEvent );
@ -742,6 +742,7 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
case PCB_MODULE_TEXT_T:
if( m_multiple && !m_editModules )
return false;
return aItem->ViewIsVisible() && board->IsLayerVisible( aItem->GetLayer() );
// These are not selectable
@ -897,6 +898,7 @@ void SELECTION_TOOL::highlightNet( const VECTOR2I& aPoint )
}
}
static double calcArea( BOARD_ITEM* aItem )
{
switch( aItem -> Type() )
@ -915,6 +917,7 @@ static double calcArea ( BOARD_ITEM *aItem )
}
}
static double calcMinArea( GENERAL_COLLECTOR& aCollector, KICAD_T aType )
{
double best = std::numeric_limits<double>::max();
@ -933,6 +936,7 @@ static double calcMinArea ( GENERAL_COLLECTOR& aCollector, KICAD_T aType )
return best;
}
static double calcMaxArea( GENERAL_COLLECTOR& aCollector, KICAD_T aType )
{
double best = 0.0;
@ -948,6 +952,7 @@ static double calcMaxArea ( GENERAL_COLLECTOR& aCollector, KICAD_T aType )
return best;
}
double calcRatio( double a, double b )
{
if ( a == 0.0 && b == 0.0 )
@ -958,6 +963,7 @@ double calcRatio ( double a, double b )
return a / b;
}
// todo: explain the selection heuristics
void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) const
{
@ -1012,10 +1018,11 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
if( item->Type() == PCB_MODULE_T && areaRatio < textToFootprintMinRatio )
{
printf("rejectModuleN\n");
//printf("rejectModuleN\n");
rejected.insert( item );
}
switch( item->Type() )
{
case PCB_TRACE_T:
@ -1025,7 +1032,7 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
case PCB_MODULE_T:
if( areaRatio > textToFeatureMinRatio )
{
printf("t after moduleRejected\n");
//printf("t after moduleRejected\n");
rejected.insert( txt );
}
break;
@ -1041,7 +1048,6 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
double minArea = calcMinArea( aCollector, PCB_MODULE_T );
double maxArea = calcMaxArea( aCollector, PCB_MODULE_T );
if( calcRatio( minArea, maxArea ) <= footprintAreaRatio )
{
for( int i = 0; i < aCollector.GetCount(); ++i )
@ -1051,7 +1057,7 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
if( normalizedArea > footprintAreaRatio )
{
printf("rejectModule1\n");
//printf("rejectModule1\n");
rejected.insert( mod );
}
@ -1062,6 +1068,7 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
if( aCollector.CountType ( PCB_PAD_T ) > 0 )
{
for( int i = 0; i < aCollector.GetCount(); ++i )
{
if ( D_PAD* pad = dyn_cast<D_PAD*>( aCollector[i] ) )
{
double ratio = pad->GetParent()->PadCoverageRatio();
@ -1070,10 +1077,12 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
rejected.insert( pad->GetParent() );
}
}
}
if( aCollector.CountType( PCB_VIA_T ) > 0 )
{
for( int i = 0; i < aCollector.GetCount(); ++i )
{
if( VIA* via = dyn_cast<VIA*>( aCollector[i] ) )
{
double viaArea = calcArea( via );
@ -1102,6 +1111,7 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
}
}
}
}
int nTracks = aCollector.CountType ( PCB_TRACE_T );
@ -1124,14 +1134,18 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
}
if( maxLength > 0.0 && minLength/maxLength < trackTrackLengthRatio && nTracks > 1 )
{
for( int i = 0; i < aCollector.GetCount(); ++i )
{
if( TRACK* track = dyn_cast<TRACK*>( aCollector[i] ) )
{
double ratio = std::max( (double) track->GetWidth(), track->GetLength()) / maxLength;
if( ratio > trackTrackLengthRatio )
rejected.insert( track) ;
}
}
}
for( int j = 0; j < aCollector.GetCount(); ++j )
{
@ -1141,28 +1155,28 @@ void SELECTION_TOOL::guessSelectionCandidates( GENERAL_COLLECTOR& aCollector ) c
if( ratio < modulePadMinCoverRatio )
{
printf("rejectModule\n");
//printf("rejectModule\n");
rejected.insert( mod );
}
}
}
}
BOOST_FOREACH( BOARD_ITEM* item, rejected )
{
aCollector.Remove( item );
}
printf("Post-selection: %d\n", aCollector.GetCount() );
//printf("Post-selection: %d\n", aCollector.GetCount() );
}
bool SELECTION_TOOL::SanitizeSelection()
{
std::set<BOARD_ITEM*> rejected;
if( !m_editModules )
{
for( unsigned int i = 0; i < m_selection.items.GetCount(); ++i )
{
BOARD_ITEM* item = m_selection.Item<BOARD_ITEM>( i );
@ -1185,8 +1199,8 @@ bool SELECTION_TOOL::SanitizeSelection()
while( !rejected.empty () )
{
BOARD_ITEM* item = *rejected.begin();
int itemIdx = m_selection.items.FindItem( item );
if( itemIdx >= 0 )
m_selection.items.RemovePicker( itemIdx );
@ -1196,6 +1210,7 @@ bool SELECTION_TOOL::SanitizeSelection()
return true;
}
void SELECTION_TOOL::generateMenu()
{
// Create a copy of the master context menu
@ -1225,7 +1240,6 @@ void SELECTION::clear()
}
const TOOL_EVENT SELECTION_TOOL::SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" );
const TOOL_EVENT SELECTION_TOOL::UnselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.unselected" );
const TOOL_EVENT SELECTION_TOOL::ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" );

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2015 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <io_mgr.h>
#include <tool/tool_manager.h>

View File

@ -486,7 +486,6 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
m_toolManager->RunAction( COMMON_ACTIONS::selectionClear, true );
GetGalCanvas()->ForceRefresh();
}
}
else