Commit 9245b903 authored by Maciej Suminski's avatar Maciej Suminski

Code formatting.

parent 7721d02a
......@@ -29,9 +29,9 @@ using boost::optional;
bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const
{
// fixme: ugly!
SEG s(aP, aP);
return this->Collide(s, aClearance);
// fixme: ugly!
SEG s( aP, aP );
return this->Collide( s, aClearance );
}
......@@ -161,9 +161,9 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP )
if( dist < min_dist && seg.A != aP && seg.B != aP )
{
min_dist = dist;
if(found_index < 0)
if( found_index < 0 )
ii = s;
else if(s < found_index)
else if( s < found_index )
ii = s;
}
}
......@@ -521,25 +521,27 @@ const std::string SHAPE_LINE_CHAIN::Format() const
bool SHAPE_LINE_CHAIN::CompareGeometry ( const SHAPE_LINE_CHAIN & aOther ) const
{
SHAPE_LINE_CHAIN a(*this), b(aOther);
SHAPE_LINE_CHAIN a(*this), b( aOther );
a.Simplify();
b.Simplify();
if(a.m_points.size() != b.m_points.size())
if( a.m_points.size() != b.m_points.size() )
return false;
for(int i = 0; i < a.PointCount(); i++)
if(a.CPoint(i) != b.CPoint(i))
for( int i = 0; i < a.PointCount(); i++)
if( a.CPoint( i ) != b.CPoint( i ) )
return false;
return true;
}
bool SHAPE_LINE_CHAIN::Intersects( const SHAPE_LINE_CHAIN& aChain ) const
{
INTERSECTIONS dummy;
return Intersect(aChain, dummy) != 0;
return Intersect( aChain, dummy ) != 0;
}
SHAPE* SHAPE_LINE_CHAIN::Clone() const
{
return new SHAPE_LINE_CHAIN( *this );
......
......@@ -52,7 +52,7 @@ public:
/** Default constructor
* Creates an empty (0, 0) segment, locally-referenced
*/
SEG()
SEG()
{
m_index = -1;
}
......@@ -61,8 +61,8 @@ public:
* Constructor
* Creates a segment between (aX1, aY1) and (aX2, aY2), locally referenced
*/
SEG( int aX1, int aY1, int aX2, int aY2 ) :
A ( VECTOR2I( aX1, aY1 ) ),
SEG( int aX1, int aY1, int aX2, int aY2 ) :
A ( VECTOR2I( aX1, aY1 ) ),
B ( VECTOR2I( aX2, aY2 ) )
{
m_index = -1;
......@@ -84,7 +84,7 @@ public:
* @param aB reference to the end point in the parent shape
* @param aIndex index of the segment within the parent shape
*/
SEG ( const VECTOR2I& aA, const VECTOR2I& aB, int aIndex ) : A( aA ), B( aB )
SEG( const VECTOR2I& aA, const VECTOR2I& aB, int aIndex ) : A( aA ), B( aB )
{
m_index = aIndex;
}
......@@ -92,7 +92,7 @@ public:
/**
* Copy constructor
*/
SEG ( const SEG& aSeg ) : A( aSeg.A ), B( aSeg.B ), m_index ( aSeg.m_index )
SEG( const SEG& aSeg ) : A( aSeg.A ), B( aSeg.B ), m_index( aSeg.m_index )
{
}
......@@ -101,7 +101,7 @@ public:
A = aSeg.A;
B = aSeg.B;
m_index = aSeg.m_index;
return *this;
}
......@@ -225,23 +225,24 @@ public:
return ( d1 <= 1 && d2 <= 1 );
}
bool Overlaps ( const SEG& aSeg ) const
bool Overlaps( const SEG& aSeg ) const
{
if( aSeg.A == aSeg.B ) // single point corner case
{
if(A == aSeg.A || B == aSeg.A)
if( A == aSeg.A || B == aSeg.A )
return false;
return Contains(aSeg.A);
return Contains( aSeg.A );
}
if( !Collinear (aSeg ))
if( !Collinear( aSeg ) )
return false;
if ( Contains (aSeg.A) || Contains(aSeg.B) )
if( Contains( aSeg.A ) || Contains( aSeg.B ) )
return true;
if ( aSeg.Contains (A) || aSeg.Contains(B) )
if( aSeg.Contains( A ) || aSeg.Contains( B ) )
return true;
return false;
}
......
......@@ -41,7 +41,7 @@ enum SHAPE_TYPE
SH_SEGMENT, ///> line segment
SH_LINE_CHAIN, ///> line chain (polyline)
SH_CIRCLE, ///> circle
SH_CONVEX, ///> convex polygon
SH_CONVEX, ///> convex polygon
SH_POLYGON, ///> any polygon (with holes, etc.)
SH_COMPOUND ///> compound shape, consisting of multiple simple shapes
};
......@@ -63,7 +63,7 @@ public:
* Creates an empty shape of type aType
*/
SHAPE ( SHAPE_TYPE aType ) : m_type( aType )
SHAPE( SHAPE_TYPE aType ) : m_type( aType )
{}
// Destructor
......@@ -152,7 +152,7 @@ public:
virtual void Move ( const VECTOR2I& aVector ) = 0;
virtual bool IsSolid() const = 0;
protected:
///> type of our shape
SHAPE_TYPE m_type;
......
......@@ -38,7 +38,7 @@ public:
SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter )
{}
SHAPE_CIRCLE ( const SHAPE_CIRCLE& aOther ) :
SHAPE_CIRCLE( const SHAPE_CIRCLE& aOther ) :
SHAPE( SH_CIRCLE ),
m_radius( aOther.m_radius ),
m_center( aOther.m_center )
......@@ -86,7 +86,7 @@ public:
return m_center;
}
void Move ( const VECTOR2I& aVector )
void Move( const VECTOR2I& aVector )
{
m_center += aVector;
}
......
......@@ -114,7 +114,7 @@ public:
}
SHAPE_LINE_CHAIN(const VECTOR2I* aV, int aCount ) :
SHAPE_LINE_CHAIN( const VECTOR2I* aV, int aCount ) :
SHAPE( SH_LINE_CHAIN ),
m_closed( false )
{
......@@ -564,9 +564,9 @@ public:
bool CompareGeometry( const SHAPE_LINE_CHAIN & aOther ) const;
void Move ( const VECTOR2I& aVector )
void Move( const VECTOR2I& aVector )
{
for(std::vector<VECTOR2I>::iterator i = m_points.begin(); i != m_points.end(); ++i)
for( std::vector<VECTOR2I>::iterator i = m_points.begin(); i != m_points.end(); ++i )
(*i) += aVector;
}
......
......@@ -57,7 +57,7 @@ public:
SHAPE( SH_RECT ), m_p0( aP0 ), m_w( aW ), m_h( aH )
{}
SHAPE_RECT ( const SHAPE_RECT& aOther ) :
SHAPE_RECT( const SHAPE_RECT& aOther ) :
SHAPE( SH_RECT ),
m_p0( aOther.m_p0 ),
m_w( aOther.m_w ),
......@@ -159,7 +159,7 @@ public:
return m_h;
}
void Move ( const VECTOR2I& aVector )
void Move( const VECTOR2I& aVector )
{
m_p0 += aVector;
}
......@@ -168,7 +168,7 @@ public:
{
return true;
}
private:
///> Top-left corner
VECTOR2I m_p0;
......
......@@ -31,71 +31,71 @@
class SHAPE_SEGMENT : public SHAPE {
public:
SHAPE_SEGMENT():
SHAPE( SH_SEGMENT ), m_width( 0 ) {};
SHAPE_SEGMENT( const VECTOR2I& aA, const VECTOR2I& aB, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aA, aB ), m_width( aWidth ) {};
SHAPE_SEGMENT():
SHAPE( SH_SEGMENT ), m_width( 0 ) {};
SHAPE_SEGMENT( const SEG& aSeg, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aSeg ), m_width( aWidth ) {};
SHAPE_SEGMENT( const VECTOR2I& aA, const VECTOR2I& aB, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aA, aB ), m_width( aWidth ) {};
~SHAPE_SEGMENT() {};
SHAPE_SEGMENT( const SEG& aSeg, int aWidth = 0 ):
SHAPE( SH_SEGMENT ), m_seg( aSeg ), m_width( aWidth ) {};
~SHAPE_SEGMENT() {};
SHAPE* Clone() const
{
return new SHAPE_SEGMENT( m_seg, m_width );
}
const BOX2I BBox( int aClearance = 0 ) const
{
return BOX2I( m_seg.A, m_seg.B - m_seg.A ).Inflate( aClearance + m_width / 2 );
}
bool Collide( const SEG& aSeg, int aClearance = 0 ) const
{
return m_seg.Distance( aSeg ) <= m_width / 2 + aClearance;
}
bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const
{
return m_seg.Distance( aP ) <= m_width / 2 + aClearance;
}
void SetSeg ( const SEG& aSeg )
{
m_seg = aSeg;
}
const SEG& GetSeg () const
{
return m_seg;
}
void SetWidth ( int aWidth )
{
m_width = aWidth;
}
int GetWidth() const
{
return m_width;
}
bool IsSolid() const
{
return true;
}
void Move ( const VECTOR2I& aVector )
{
m_seg.A += aVector;
m_seg.B += aVector;
}
const BOX2I BBox( int aClearance = 0 ) const
{
return BOX2I( m_seg.A, m_seg.B - m_seg.A ).Inflate( aClearance + m_width / 2 );
}
bool Collide( const SEG& aSeg, int aClearance = 0 ) const
{
return m_seg.Distance( aSeg ) <= m_width / 2 + aClearance;
}
bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const
{
return m_seg.Distance( aP ) <= m_width / 2 + aClearance;
}
void SetSeg( const SEG& aSeg )
{
m_seg = aSeg;
}
const SEG& GetSeg() const
{
return m_seg;
}
void SetWidth( int aWidth )
{
m_width = aWidth;
}
int GetWidth() const
{
return m_width;
}
bool IsSolid() const
{
return true;
}
void Move( const VECTOR2I& aVector )
{
m_seg.A += aVector;
m_seg.B += aVector;
}
private:
SEG m_seg;
int m_width;
SEG m_seg;
int m_width;
};
#endif
......@@ -387,7 +387,7 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
else
{
double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0;
m_gal->SetLineWidth( width );
m_gal->SetIsFill( true );
m_gal->SetIsStroke( false );
......
......@@ -25,7 +25,7 @@
#include "pns_router.h"
PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) :
PNS_ALGO_BASE ( aRouter )
PNS_ALGO_BASE( aRouter )
{
m_world = NULL;
m_shove = NULL;
......@@ -39,7 +39,7 @@ PNS_DRAGGER::~PNS_DRAGGER()
}
void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld )
void PNS_DRAGGER::SetWorld( PNS_NODE* aWorld )
{
m_world = aWorld;
}
......@@ -49,7 +49,7 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg )
{
int w2 = aSeg->Width() / 2;
m_draggedLine = m_world->AssembleLine ( aSeg, &m_draggedSegmentIndex );
m_draggedLine = m_world->AssembleLine( aSeg, &m_draggedSegmentIndex );
m_shove->SetInitialLine( m_draggedLine );
m_lastValidDraggedLine = *m_draggedLine;
m_lastValidDraggedLine.ClearSegmentLinks();
......@@ -58,9 +58,9 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg )
m_mode = CORNER;
else if( ( aP - aSeg->Seg().B ).EuclideanNorm() <= w2 )
{
m_draggedSegmentIndex ++;
m_draggedSegmentIndex++;
m_mode = CORNER;
} else
} else
m_mode = SEGMENT;
return true;
......@@ -74,14 +74,14 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia )
m_mode = VIA;
VECTOR2I p0( aVia->Pos() );
PNS_JOINT *jt = m_world->FindJoint( p0, aVia->Layers().Start(), aVia->Net() );
PNS_JOINT* jt = m_world->FindJoint( p0, aVia->Layers().Start(), aVia->Net() );
BOOST_FOREACH(PNS_ITEM *item, jt->LinkList() )
BOOST_FOREACH( PNS_ITEM* item, jt->LinkList() )
{
if( item->OfKind( PNS_ITEM::SEGMENT ) )
{
int segIndex;
PNS_SEGMENT* seg = (PNS_SEGMENT*) item;
PNS_SEGMENT* seg = ( PNS_SEGMENT*) item;
std::auto_ptr<PNS_LINE> l( m_world->AssembleLine( seg, &segIndex ) );
if( segIndex != 0 )
......@@ -97,29 +97,29 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia )
bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
m_shove = new PNS_SHOVE( m_world, Router() );
m_shove = new PNS_SHOVE( m_world, Router() );
m_lastNode = NULL;
m_draggedItems.Clear();
m_currentMode = Settings().Mode();
TRACE( 2, "StartDragging: item %p [kind %d]", aStartItem % aStartItem->Kind() );
switch( aStartItem->Kind() )
{
case PNS_ITEM::SEGMENT:
return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) );
switch( aStartItem->Kind() )
{
case PNS_ITEM::SEGMENT:
return startDragSegment( aP, static_cast<PNS_SEGMENT*>( aStartItem ) );
case PNS_ITEM::VIA:
return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) );
case PNS_ITEM::VIA:
return startDragVia( aP, static_cast<PNS_VIA*>( aStartItem ) );
default:
return false;
}
default:
return false;
}
}
bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
{
{
if( m_lastNode )
{
delete m_lastNode;
......@@ -133,20 +133,20 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
{
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0;
PNS_LINE tmp( *m_draggedLine );
if( m_mode == SEGMENT )
tmp.DragSegment ( aP, m_draggedSegmentIndex, thresh );
tmp.DragSegment( aP, m_draggedSegmentIndex, thresh );
else
tmp.DragCorner ( aP, m_draggedSegmentIndex, thresh );
tmp.DragCorner( aP, m_draggedSegmentIndex, thresh );
m_lastNode = m_shove->CurrentNode()->Branch();
m_lastValidDraggedLine = tmp;
m_lastValidDraggedLine.ClearSegmentLinks();
m_lastValidDraggedLine.Unmark();
m_lastNode->Add ( &m_lastValidDraggedLine );
m_draggedItems = PNS_ITEMSET ( &m_lastValidDraggedLine );
m_lastNode->Add( &m_lastValidDraggedLine );
m_draggedItems = PNS_ITEMSET( &m_lastValidDraggedLine );
break;
}
......@@ -154,7 +154,7 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
case VIA: // fixme...
{
m_lastNode = m_shove->CurrentNode()->Branch();
dumbDragVia ( m_initialVia, m_lastNode, aP );
dumbDragVia( m_initialVia, m_lastNode, aP );
break;
}
......@@ -164,7 +164,7 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
m_dragStatus = true;
else
m_dragStatus = !m_world->CheckColliding( m_draggedItems );
return true;
}
......@@ -176,20 +176,20 @@ void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& a
m_draggedVia->SetPos( aP );
m_draggedItems.Clear();
m_draggedItems.Add( m_draggedVia );
m_lastNode->Remove( aVia );
m_lastNode->Add( m_draggedVia );
BOOST_FOREACH( PNS_LINE &l, m_origViaConnections )
{
PNS_LINE origLine (l);
PNS_LINE origLine( l );
PNS_LINE* draggedLine = l.Clone();
draggedLine->DragCorner( aP, 0 );
draggedLine->ClearSegmentLinks();
m_draggedItems.Add( draggedLine ); // FIXME: mem leak
m_lastNode->Remove( &origLine );
m_lastNode->Add( draggedLine );
}
......@@ -208,43 +208,43 @@ bool PNS_DRAGGER::dragShove( const VECTOR2I& aP )
switch( m_mode )
{
case SEGMENT:
case CORNER:
{
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0;
PNS_LINE tmp( *m_draggedLine );
if( m_mode == SEGMENT )
tmp.DragSegment( aP, m_draggedSegmentIndex, thresh );
else
tmp.DragCorner( aP, m_draggedSegmentIndex, thresh );
case SEGMENT:
case CORNER:
{
int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0;
PNS_LINE tmp( *m_draggedLine );
if( m_mode == SEGMENT )
tmp.DragSegment( aP, m_draggedSegmentIndex, thresh );
else
tmp.DragCorner( aP, m_draggedSegmentIndex, thresh );
PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( tmp );
if( st == PNS_SHOVE::SH_OK )
ok = true;
ok = true;
else if( st == PNS_SHOVE::SH_HEAD_MODIFIED )
{
tmp = m_shove->NewHead();
ok = true;
}
}
m_lastNode = m_shove->CurrentNode()->Branch();
if( ok )
m_lastValidDraggedLine = tmp;
m_lastValidDraggedLine.ClearSegmentLinks();
m_lastValidDraggedLine.Unmark();
m_lastNode->Add( &m_lastValidDraggedLine );
m_draggedItems = PNS_ITEMSET( &m_lastValidDraggedLine );
break;
}
}
case VIA:
{
PNS_VIA *newVia;
{
PNS_VIA* newVia;
PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, &newVia );
if( st == PNS_SHOVE::SH_OK || st == PNS_SHOVE::SH_HEAD_MODIFIED )
......@@ -261,7 +261,7 @@ bool PNS_DRAGGER::dragShove( const VECTOR2I& aP )
break;
}
}
m_dragStatus = ok;
return ok;
......@@ -274,7 +274,7 @@ bool PNS_DRAGGER::FixRoute()
{
Router()->CommitRouting( CurrentNode() );
return true;
}
}
return false;
}
......@@ -282,23 +282,23 @@ bool PNS_DRAGGER::FixRoute()
bool PNS_DRAGGER::Drag( const VECTOR2I& aP )
{
switch( m_currentMode )
{
case RM_MarkObstacles:
return dragMarkObstacles( aP );
case RM_Shove:
case RM_Walkaround:
case RM_Smart:
return dragShove( aP );
default:
return false;
}
switch( m_currentMode )
{
case RM_MarkObstacles:
return dragMarkObstacles( aP );
case RM_Shove:
case RM_Walkaround:
case RM_Smart:
return dragShove( aP );
default:
return false;
}
}
PNS_NODE *PNS_DRAGGER::CurrentNode() const
PNS_NODE* PNS_DRAGGER::CurrentNode() const
{
return m_lastNode;
}
......
......@@ -24,8 +24,8 @@
PNS_ITEMSET::PNS_ITEMSET( PNS_ITEM* aInitialItem )
{
if(aInitialItem)
m_items.push_back(aInitialItem);
if( aInitialItem )
m_items.push_back( aInitialItem );
}
PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd, bool aInvert )
......@@ -55,7 +55,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask, bool aInvert )
BOOST_FOREACH( PNS_ITEM* item, m_items )
{
if( item->OfKind ( aKindMask ) ^ aInvert )
if( item->OfKind( aKindMask ) ^ aInvert )
newItems.push_back( item );
}
......@@ -71,7 +71,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet, bool aInvert )
BOOST_FOREACH( PNS_ITEM* item, m_items )
{
if( (item->Net() == aNet) ^ aInvert )
if( ( item->Net() == aNet ) ^ aInvert )
newItems.push_back( item );
}
......@@ -80,7 +80,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet, bool aInvert )
return *this;
}
PNS_ITEMSET& PNS_ITEMSET::ExcludeItem ( const PNS_ITEM *aItem )
PNS_ITEMSET& PNS_ITEMSET::ExcludeItem( const PNS_ITEM* aItem )
{
ITEMS newItems;
......
......@@ -44,17 +44,17 @@ public:
{
m_items = aOther.m_items;
}
const PNS_ITEMSET& operator=( const PNS_ITEMSET& aOther )
{
m_items = aOther.m_items;
return *this;
}
int Count(int aKindMask = -1) const
int Count( int aKindMask = -1 ) const
{
int n = 0;
BOOST_FOREACH ( PNS_ITEM *item, m_items )
BOOST_FOREACH( PNS_ITEM* item, m_items )
{
if( item->Kind() & aKindMask )
n++;
......@@ -76,32 +76,32 @@ public:
PNS_ITEMSET& ExcludeKinds( int aKindMask )
{
return FilterKinds ( aKindMask, true );
return FilterKinds( aKindMask, true );
}
PNS_ITEMSET& ExcludeNet( int aNet )
{
return FilterNet ( aNet, true );
return FilterNet( aNet, true );
}
PNS_ITEMSET& ExcludeItem ( const PNS_ITEM *aItem );
PNS_ITEMSET& ExcludeItem( const PNS_ITEM* aItem );
int Size() const
{
return m_items.size();
int Size() const
{
return m_items.size();
}
void Add( PNS_ITEM* aItem )
{
m_items.push_back ( aItem );
m_items.push_back( aItem );
}
PNS_ITEM* Get( int index ) const
{
return m_items[index];
PNS_ITEM* Get( int index ) const
{
return m_items[index];
}
PNS_ITEM* operator[] (int index ) const
PNS_ITEM* operator[] ( int index ) const
{
return m_items[index];
}
......@@ -111,19 +111,19 @@ public:
m_items.clear();
}
bool Contains ( const PNS_ITEM *aItem ) const
bool Contains( const PNS_ITEM* aItem ) const
{
return std::find ( m_items.begin(), m_items.end(), aItem ) != m_items.end();
return std::find( m_items.begin(), m_items.end(), aItem ) != m_items.end();
}
void Erase ( const PNS_ITEM *aItem )
void Erase( const PNS_ITEM* aItem )
{
ITEMS::iterator f = std::find (m_items.begin(), m_items.end(), aItem );
ITEMS::iterator f = std::find( m_items.begin(), m_items.end(), aItem );
if( f != m_items.end() )
m_items.erase ( f );
m_items.erase( f );
}
private:
ITEMS m_items;
};
......
......@@ -72,7 +72,7 @@ public:
m_layers = aB.m_layers;
}
PNS_ITEM* Clone ( ) const
PNS_ITEM* Clone( ) const
{
assert( false );
return NULL;
......@@ -98,17 +98,17 @@ public:
///> Links the joint to a given board item (when it's added to the PNS_NODE)
void Link( PNS_ITEM* aItem )
{
if (m_linkedItems.Contains( aItem ))
if( m_linkedItems.Contains( aItem ) )
return;
m_linkedItems.Add ( aItem );
m_linkedItems.Add( aItem );
}
///> Unlinks a given board item from the joint (upon its removal from a PNS_NODE)
///> Returns true if the joint became dangling after unlinking.
bool Unlink( PNS_ITEM* aItem )
{
m_linkedItems.Erase ( aItem );
m_linkedItems.Erase( aItem );
return m_linkedItems.Size() == 0;
}
......@@ -124,24 +124,24 @@ public:
/// trivial accessors
const HASH_TAG& Tag() const
{
return m_tag;
const HASH_TAG& Tag() const
{
return m_tag;
}
const VECTOR2I& Pos() const
{
return m_tag.pos;
const VECTOR2I& Pos() const
{
return m_tag.pos;
}
int Net() const
{
return m_tag.net;
int Net() const
{
return m_tag.net;
}
const LINKED_ITEMS& LinkList() const
{
return m_linkedItems.CItems();
{
return m_linkedItems.CItems();
}
const PNS_ITEMSET& CLinks() const
......@@ -159,7 +159,6 @@ public:
return m_linkedItems.Count( aMask );
}
void Dump() const;
bool operator==( const PNS_JOINT& rhs ) const
......@@ -174,9 +173,9 @@ public:
m_layers.Merge( aJoint.m_layers );
BOOST_FOREACH ( PNS_ITEM *item, aJoint.LinkList() )
BOOST_FOREACH( PNS_ITEM* item, aJoint.LinkList() )
{
m_linkedItems.Add (item);
m_linkedItems.Add( item );
}
}
......
......@@ -123,7 +123,7 @@ int PNS_LINE::Marker()const
}
void PNS_LINE::copyLinks( const PNS_LINE *aParent )
void PNS_LINE::copyLinks( const PNS_LINE* aParent )
{
if( aParent->m_segmentRefs == NULL )
{
......@@ -413,7 +413,7 @@ void PNS_LINE::DragCorner ( const VECTOR2I& aP, int aIndex, int aSnappingThresho
if( aIndex == 0 )
path = dragCornerInternal( m_line.Reverse(), snapped ).Reverse();
else if ( aIndex == m_line.SegmentCount() )
else if( aIndex == m_line.SegmentCount() )
path = dragCornerInternal( m_line, snapped );
else
{
......
......@@ -386,12 +386,12 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
walkaround.SetSolidsOnly( false );
walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
PNS_WALKAROUND::WALKAROUND_STATUS wf = walkaround.Route( initTrack, walkFull, false );
switch( Settings().OptimizerEffort() )
{
case OE_LOW:
case OE_LOW:
effort = 0;
break;
......@@ -423,7 +423,7 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
m_head = walkFull;
aNewHead = walkFull;
return rv;
}
......@@ -431,14 +431,14 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead )
bool PNS_LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead )
{
m_head.SetShape( m_direction.BuildInitialTrace( m_p_start, aP ) );
if( m_placingVia )
{
m_head.AppendVia( makeVia ( m_head.CPoint( -1 ) ) );
}
aNewHead = m_head;
return m_currentNode->CheckColliding( &m_head );
}
......@@ -482,16 +482,16 @@ bool PNS_LINE_PLACER::rhShoveOnly ( const VECTOR2I& aP, PNS_LINE& aNewHead )
l2.AppendVia( v2 );
}
l.Line().Simplify();
l.Line().Simplify();
// in certain, uncommon cases there may be loops in the head+tail, In such case, we don't shove to avoid
// screwing up the database.
if( l.HasLoops() )
{
aNewHead = m_head;
return false;
return false;
}
PNS_SHOVE::SHOVE_STATUS status = m_shove->ShoveLines( l );
m_currentNode = m_shove->CurrentNode();
......@@ -536,7 +536,7 @@ bool PNS_LINE_PLACER::routeHead( const VECTOR2I& aP, PNS_LINE& aNewHead )
default:
break;
}
return false;
}
......@@ -550,14 +550,14 @@ bool PNS_LINE_PLACER::optimizeTailHeadTransition()
if( tmp.SegmentCount() < 1 )
return false;
m_head = tmp;
m_head = tmp;
m_p_start = tmp.CLine().CPoint( 0 );
m_direction = DIRECTION_45( tmp.CSegment( 0 ) );
m_tail.Line().Clear();
return true;
}
SHAPE_LINE_CHAIN& head = m_head.Line();
SHAPE_LINE_CHAIN& tail = m_tail.Line();
......@@ -676,9 +676,9 @@ const PNS_LINE PNS_LINE_PLACER::Trace() const
}
const PNS_ITEMSET PNS_LINE_PLACER::Traces()
const PNS_ITEMSET PNS_LINE_PLACER::Traces()
{
m_currentTrace = Trace();
m_currentTrace = Trace();
return PNS_ITEMSET( &m_currentTrace );
}
......@@ -703,13 +703,13 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co
{
if( aSeg && aSeg->OfKind( PNS_ITEM::SEGMENT ) )
{
PNS_JOINT *jt = aNode->FindJoint( aP, aSeg );
PNS_JOINT* jt = aNode->FindJoint( aP, aSeg );
if( jt && jt->LinkCount() >= 1 )
return;
PNS_SEGMENT* s_old = static_cast<PNS_SEGMENT*>( aSeg );
PNS_SEGMENT* s_new[2];
s_new[0] = s_old->Clone();
......@@ -727,13 +727,13 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co
bool PNS_LINE_PLACER::SetLayer( int aLayer )
{
if(m_idle)
if( m_idle )
{
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 );
......@@ -755,7 +755,7 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
if( Router()->SnappingEnabled() )
p = Router()->SnapToItem( aStartItem, aP, splitSeg );
if( !aStartItem || aStartItem->Net() < 0 )
net = unknowNetIdx--;
else
......@@ -770,8 +770,8 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
m_splitSeg = splitSeg;
setInitialDirection( Settings().InitialDirection() );
initPlacement( m_splitSeg );
initPlacement( m_splitSeg );
}
void PNS_LINE_PLACER::initPlacement( bool aSplitSeg )
......@@ -786,12 +786,12 @@ void PNS_LINE_PLACER::initPlacement( bool aSplitSeg )
m_tail.SetLayer( m_currentLayer );
m_head.SetWidth( m_sizes.TrackWidth() );
m_tail.SetWidth( m_sizes.TrackWidth() );
m_p_start = m_currentStart;
m_direction = m_initial_direction;
PNS_NODE *world = Router()->GetWorld();
PNS_NODE* world = Router()->GetWorld();
world->KillChildren();
PNS_NODE* rootNode = world->Branch();
......@@ -799,23 +799,23 @@ void PNS_LINE_PLACER::initPlacement( bool aSplitSeg )
splitAdjacentSegments( rootNode, m_startItem, m_currentStart );
setWorld( rootNode );
TRACE( 1, "world %p, intitial-direction %s layer %d\n",
m_world % m_direction.Format().c_str() % aLayer );
m_lastNode = NULL;
m_lastNode = NULL;
m_currentNode = m_world;
m_currentMode = Settings().Mode();
if( m_shove )
delete m_shove;
m_shove = NULL;
if( m_currentMode == RM_Shove || m_currentMode == RM_Smart )
{
m_shove = new PNS_SHOVE( m_world->Branch(), Router() );
}
}
}
......@@ -824,20 +824,20 @@ void PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
PNS_LINE current;
VECTOR2I p = aP;
int eiDepth = -1;
if( aEndItem && aEndItem->Owner() )
eiDepth = aEndItem->Owner()->Depth();
if( m_lastNode )
{
delete m_lastNode;
m_lastNode = NULL;
}
route( p );
current = Trace();
if( !current.PointCount() )
m_currentEnd = m_p_start;
else
......@@ -845,14 +845,14 @@ void PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
PNS_NODE* latestNode = m_currentNode;
m_lastNode = latestNode->Branch();
if( eiDepth >= 0 && aEndItem && latestNode->Depth() > eiDepth &&
current.SegmentCount() && current.CPoint( -1 ) == aP )
{
splitAdjacentSegments( m_lastNode, aEndItem, current.CPoint( -1 ) );
if( Settings().RemoveLoops() )
removeLoops( m_lastNode, &current );
removeLoops( m_lastNode, &current );
}
updateLeadingRatLine();
......@@ -863,7 +863,7 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
bool realEnd = false;
int lastV;
PNS_LINE pl = Trace();
if( m_currentMode == RM_MarkObstacles &&
......@@ -908,9 +908,9 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
if( realEnd )
simplifyNewLine( m_lastNode, lastSeg );
Router()->CommitRouting( m_lastNode );
m_lastNode = NULL;
if( !realEnd )
......@@ -921,7 +921,7 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
m_placingVia = false;
m_chainedPlacement = !pl.EndsWithVia();
m_splitSeg = false;
initPlacement( );
initPlacement( );
} else {
m_idle = true;
}
......@@ -936,10 +936,10 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest )
return;
aNode->Add( aLatest, true );
for( int s = 0; s < aLatest->SegmentCount(); s++ )
{
PNS_SEGMENT *seg = ( *aLatest->LinkedSegments() )[s];
PNS_SEGMENT* seg = ( *aLatest->LinkedSegments() )[s];
PNS_LINE* ourLine = aNode->AssembleLine( seg );
PNS_JOINT a, b;
std::vector<PNS_LINE*> lines;
......@@ -950,7 +950,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest )
{
aNode->FindLineEnds( aLatest, a, b);
}
aNode->FindLinesBetweenJoints( a, b, lines );
int removedCount = 0;
......@@ -976,7 +976,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest )
delete ourLine;
}
aNode->Remove( aLatest );
}
......@@ -991,8 +991,8 @@ void PNS_LINE_PLACER::simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest )
if( simplified.PointCount() != l->PointCount() )
{
std::auto_ptr<PNS_LINE> lnew ( l->Clone() );
aNode -> Remove(l);
lnew->SetShape(simplified);
aNode -> Remove( l );
lnew->SetShape( simplified );
aNode -> Add( lnew.get() );
}
}
......@@ -1012,21 +1012,21 @@ void PNS_LINE_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes )
void PNS_LINE_PLACER::updateLeadingRatLine()
{
PNS_LINE current = Trace();
if( !current.PointCount() )
return;
std::auto_ptr<PNS_NODE> tmpNode ( m_lastNode->Branch() );
tmpNode->Add( &current );
PNS_JOINT *jt = tmpNode->FindJoint( current.CPoint( -1 ),
PNS_JOINT* jt = tmpNode->FindJoint( current.CPoint( -1 ),
current.Layers().Start(), current.Net() );
if( !jt )
return;
int anchor;
PNS_ITEM *it = tmpNode->NearestUnconnectedItem( jt, &anchor );
PNS_ITEM* it = tmpNode->NearestUnconnectedItem( jt, &anchor );
if( it )
{
......
......@@ -43,7 +43,7 @@ class PNS_SIZES_SETTINGS;
/**
* Class PNS_LINE_PLACER
*
* Single track placement algorithm. Interactively routes a track.
* Single track placement algorithm. Interactively routes a track.
* Applies shove and walkaround algorithms when needed.
*/
......@@ -55,7 +55,7 @@ public:
/**
* Function Start()
*
*
* Starts routing a single track at point aP, taking item aStartItem as anchor
* (unless NULL).
*/
......@@ -63,8 +63,8 @@ public:
/**
* Function Move()
*
* Moves the end of the currently routed trace to the point aP, taking
*
* Moves the end of the currently routed trace to the point aP, taking
* aEndItem as anchor (if not NULL).
* (unless NULL).
*/
......@@ -72,7 +72,7 @@ public:
/**
* Function FixRoute()
*
*
* Commits the currently routed track to the parent node, taking
* aP as the final end point and aEndItem as the final anchor (if provided).
* @return true, if route has been commited. May return false if the routing
......@@ -80,10 +80,10 @@ public:
* if Settings.CanViolateDRC() is on.
*/
bool FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem );
/**
* Function ToggleVia()
*
*
* Enables/disables a via at the end of currently routed trace.
*/
void ToggleVia( bool aEnabled );
......@@ -103,7 +103,7 @@ public:
* that has not "settled" yet.
*/
const PNS_LINE& Head() const { return m_head; }
/**
* Function Tail()
*
......@@ -131,7 +131,7 @@ public:
*
* Returns the current end of the line being placed. It may not be equal
* to the cursor position due to collisions.
*/
*/
const VECTOR2I& CurrentEnd() const
{
return m_currentEnd;
......@@ -141,8 +141,8 @@ public:
* Function CurrentNet()
*
* Returns the net code of currently routed track.
*/
int CurrentNet() const
*/
int CurrentNet() const
{
return m_currentNet;
}
......@@ -151,8 +151,8 @@ public:
* Function CurrentLayer()
*
* Returns the layer of currently routed track.
*/
int CurrentLayer() const
*/
int CurrentLayer() const
{
return m_currentLayer;
}
......@@ -163,14 +163,14 @@ public:
* Returns the most recent world state.
*/
PNS_NODE* CurrentNode( bool aLoopsRemoved = false ) const;
/**
* Function FlipPosture()
*
* Toggles the current posture (straight/diagonal) of the trace head.
*/
void FlipPosture();
/**
* Function UpdateSizes()
*
......@@ -198,18 +198,18 @@ private:
* Function updateLeadingRatLine()
*
* Draws the "leading" ratsnest line, which connects the end of currently
* routed track and the nearest yet unrouted item. If the routing for
* routed track and the nearest yet unrouted item. If the routing for
* current net is complete, draws nothing.
*/
void updateLeadingRatLine();
/**
* Function setWorld()
*
* Sets the board to route.
*/
void setWorld( PNS_NODE* aWorld );
/**
* Function startPlacement()
*
......@@ -245,10 +245,10 @@ private:
* Function simplifyNewLine()
*
* Assembles a line starting from segment aLatest, removes collinear segments
* and redundant vertexes. If a simplification bhas been found, replaces the
* and redundant vertexes. If a simplification bhas been found, replaces the
* old line with the simplified one in aNode.
*/
void simplifyNewLine( PNS_NODE *aNode, PNS_SEGMENT *aLatest );
void simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest );
/**
* Function handleViaPlacement()
......@@ -385,7 +385,7 @@ private:
///> current via drill
int m_viaDrill;
///> current track width
int m_currentWidth;
......@@ -393,12 +393,12 @@ private:
int m_currentLayer;
bool m_startsOnVia;
VECTOR2I m_currentEnd, m_currentStart;
PNS_LINE m_currentTrace;
PNS_MODE m_currentMode;
PNS_ITEM *m_startItem;
PNS_ITEM* m_startItem;
bool m_idle;
bool m_chainedPlacement;
......
......@@ -456,7 +456,7 @@ bool PNS_ROUTER::StartDragging( const VECTOR2I& aP, PNS_ITEM* aStartItem )
bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLayer )
{
m_placer = new PNS_LINE_PLACER( this );
m_placer->UpdateSizes ( m_sizes );
m_placer->SetLayer( aLayer );
m_placer->Start( aP, aStartItem );
......@@ -504,7 +504,7 @@ void PNS_ROUTER::DisplayItem( const PNS_ITEM* aItem, int aColor, int aClearance
void PNS_ROUTER::DisplayItems( const PNS_ITEMSET& aItems )
{
BOOST_FOREACH( const PNS_ITEM *item, aItems.CItems() )
BOOST_FOREACH( const PNS_ITEM* item, aItems.CItems() )
DisplayItem( item );
}
......@@ -604,7 +604,7 @@ void PNS_ROUTER::updateView( PNS_NODE* aNode, PNS_ITEMSET& aCurrent )
return;
if( Settings().Mode() == RM_MarkObstacles )
markViolations(aNode, aCurrent, removed);
markViolations( aNode, aCurrent, removed );
aNode->GetUpdatedItems( removed, added );
......@@ -760,7 +760,7 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
void PNS_ROUTER::StopRouting()
{
// Update the ratsnest with new changes
if(m_placer)
if( m_placer )
{
int n = m_placer->CurrentNet();
......@@ -827,7 +827,7 @@ void PNS_ROUTER::ToggleViaPlacement()
int PNS_ROUTER::GetCurrentNet() const
{
if(m_placer)
if( m_placer )
return m_placer->CurrentNet();
return -1;
}
......@@ -841,7 +841,6 @@ int PNS_ROUTER::GetCurrentLayer() const
}
void PNS_ROUTER::DumpLog()
{
PNS_LOGGER* logger = NULL;
......
......@@ -217,7 +217,7 @@ private:
void highlightCurrent( bool enabled );
void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved );
void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved );
VECTOR2I m_currentEnd;
RouterState m_state;
......
......@@ -26,7 +26,7 @@
#include "time_limit.h"
class DIRECTION_45;
///> Routing modes
enum PNS_MODE
{
......@@ -37,9 +37,9 @@ enum PNS_MODE
};
///> Optimization effort
enum PNS_OPTIMIZATION_EFFORT
enum PNS_OPTIMIZATION_EFFORT
{
OE_LOW = 0,
OE_LOW = 0,
OE_MEDIUM = 1,
OE_FULL = 2
};
......@@ -60,44 +60,44 @@ public:
///> Sets the routing mode.
void SetMode( PNS_MODE aMode ) { m_routingMode = aMode; }
///> Returns the optimizer effort. Bigger means cleaner traces, but slower routing.
PNS_OPTIMIZATION_EFFORT OptimizerEffort() const { return m_optimizerEffort; }
///> Sets the optimizer effort. Bigger means cleaner traces, but slower routing.
void SetOptimizerEffort( PNS_OPTIMIZATION_EFFORT aEffort ) { m_optimizerEffort = aEffort; }
///> Returns true if shoving vias is enbled.
bool ShoveVias() const { return m_shoveVias; }
///> Enables/disables shoving vias.
void SetShoveVias( bool aShoveVias ) { m_shoveVias = aShoveVias; }
///> Returns true if loop (redundant track) removal is on.
bool RemoveLoops() const { return m_removeLoops; }
///> Enables/disables loop (redundant track) removal.
void SetRemoveLoops( bool aRemoveLoops ) { m_removeLoops = aRemoveLoops; }
///> Returns true if suggesting the finish of currently placed track is on.
bool SuggestFinish() { return m_suggestFinish; }
///> Enables displaying suggestions for finishing the currently placed track.
void SetSuggestFinish( bool aSuggestFinish ) { m_suggestFinish = aSuggestFinish; }
///> Returns true if Smart Pads (automatic neckdown) is enabled.
bool SmartPads () const { return m_smartPads; }
///> Enables/disables Smart Pads (automatic neckdown).
void SetSmartPads( bool aSmartPads ) { m_smartPads = aSmartPads; }
///> Returns true if follow mouse mode is active (permanently on for the moment).
bool FollowMouse() const
{
bool FollowMouse() const
{
return m_followMouse && !( Mode() == RM_MarkObstacles );
}
///> Returns true if smoothing segments durign dragging is enabled.
///> Returns true if smoothing segments durign dragging is enabled.
bool SmoothDraggedSegments() const { return m_smoothDraggedSegments; }
///> Enables/disabled smoothing segments during dragging.
......@@ -106,11 +106,11 @@ public:
///> Returns true if jumping over unmovable obstacles is on.
bool JumpOverObstacles() const { return m_jumpOverObstacles; }
///> Enables/disables jumping over unmovable obstacles.
///> Enables/disables jumping over unmovable obstacles.
void SetJumpOverObstacles( bool aJumpOverObstacles ) { m_jumpOverObstacles = aJumpOverObstacles; }
void SetStartDiagonal(bool aStartDiagonal) { m_startDiagonal = aStartDiagonal; }
void SetStartDiagonal( bool aStartDiagonal ) { m_startDiagonal = aStartDiagonal; }
bool CanViolateDRC() const { return m_canViolateDRC; }
void SetCanViolateDRC( bool aViolate ) { m_canViolateDRC = aViolate; }
......@@ -136,7 +136,7 @@ private:
PNS_MODE m_routingMode;
PNS_OPTIMIZATION_EFFORT m_optimizerEffort;
int m_walkaroundIterationLimit;
int m_shoveIterationLimit;
......
......@@ -41,7 +41,7 @@
#include <profile.h>
static void sanityCheck( PNS_LINE *aOld, PNS_LINE *aNew )
static void sanityCheck( PNS_LINE* aOld, PNS_LINE* aNew )
{
assert( aOld->CPoint( 0 ) == aNew->CPoint( 0 ) );
assert( aOld->CPoint( -1 ) == aNew->CPoint( -1 ) );
......@@ -58,26 +58,26 @@ PNS_SHOVE::PNS_SHOVE( PNS_NODE* aWorld, PNS_ROUTER* aRouter ) :
PNS_SHOVE::~PNS_SHOVE()
{
// free all the stuff we've created during routing/dragging operation.
BOOST_FOREACH( PNS_ITEM *item, m_gcItems )
BOOST_FOREACH( PNS_ITEM* item, m_gcItems )
delete item;
}
// garbage-collected line assembling
PNS_LINE* PNS_SHOVE::assembleLine( const PNS_SEGMENT *aSeg, int *aIndex )
PNS_LINE* PNS_SHOVE::assembleLine( const PNS_SEGMENT* aSeg, int* aIndex )
{
PNS_LINE* l = m_currentNode->AssembleLine( const_cast<PNS_SEGMENT*>( aSeg ), aIndex );
m_gcItems.push_back(l);
m_gcItems.push_back( l );
return l;
}
// garbage-collected line cloning
PNS_LINE *PNS_SHOVE::cloneLine ( const PNS_LINE *aLine )
PNS_LINE* PNS_SHOVE::cloneLine ( const PNS_LINE* aLine )
{
PNS_LINE *l = aLine->Clone();
PNS_LINE* l = aLine->Clone();
m_gcItems.push_back( l );
return l;
......@@ -88,7 +88,7 @@ PNS_LINE *PNS_SHOVE::cloneLine ( const PNS_LINE *aLine )
// 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:
// if the shoved line wraps around the start of the "pusher", it's likely shoved in wrong direction.
bool PNS_SHOVE::checkBumpDirection( PNS_LINE *aCurrent, PNS_LINE *aShoved ) const
bool PNS_SHOVE::checkBumpDirection( PNS_LINE* aCurrent, PNS_LINE* aShoved ) const
{
const SEG ss = aCurrent->CSegment( 0 );
......@@ -98,7 +98,7 @@ bool PNS_SHOVE::checkBumpDirection( PNS_LINE *aCurrent, PNS_LINE *aShoved ) cons
dist += aShoved->Width() / 2;
const VECTOR2I ps = ss.A - ( ss.B - ss.A ).Resize( dist );
return !aShoved->CLine().PointOnEdge( ps );
}
......@@ -157,7 +157,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE* aCurrent, PNS_LINE*
path.Simplify();
l.SetShape( path );
}
for( int i = 0; i < std::min ( path.PointCount(), obs.PointCount() ); i++ )
{
if( path.CPoint( i ) != obs.CPoint( i ) )
......@@ -203,28 +203,28 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE* aCurrent, PNS_LINE*
TRACE( 100, "attempt %d fail self-intersect", attempt );
continue;
}
bool colliding = m_currentNode->CheckColliding( &l, aCurrent );
if( ( aCurrent->Marker() & MK_HEAD ) && !colliding )
{
PNS_JOINT* jtStart = m_currentNode->FindJoint( aCurrent->CPoint( 0 ), aCurrent );
BOOST_FOREACH( PNS_ITEM* item, jtStart->LinkList() )
{
if( m_currentNode->CheckColliding( item, &l ) )
colliding = true;
}
}
if( colliding )
{
TRACE( 100, "attempt %d fail coll-check", attempt );
continue;
}
aShoved->SetShape( l.CLine() );
aShoved->SetShape( l.CLine() );
return SH_OK;
}
......@@ -254,7 +254,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processSingleLine( PNS_LINE* aCurrent, PNS_LI
bool viaOnEnd = aCurrent->EndsWithVia();
if( viaOnEnd && ( !aCurrent->LayersOverlap( aObstacle ) || aCurrent->SegmentCount() == 0 ) )
if( viaOnEnd && ( !aCurrent->LayersOverlap( aObstacle ) || aCurrent->SegmentCount() == 0 ) )
{
rv = walkaroundLoneVia( aCurrent, aObstacle, aShoved );
}
......@@ -279,7 +279,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processSingleLine( PNS_LINE* aCurrent, PNS_LI
rv = processHullSet ( aCurrent, aObstacle, aShoved, hulls );
}
if( obstacleIsHead )
aShoved->Mark( aShoved->Marker() | MK_HEAD );
......@@ -292,16 +292,16 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S
int segIndex;
PNS_LINE* obstacleLine = assembleLine( aObstacleSeg, &segIndex );
PNS_LINE* shovedLine = cloneLine( obstacleLine );
SHOVE_STATUS rv = processSingleLine( aCurrent, obstacleLine, shovedLine );
assert ( obstacleLine->LayersOverlap( shovedLine ) );
if( rv == SH_OK )
{
if ( shovedLine->Marker() & MK_HEAD )
if( shovedLine->Marker() & MK_HEAD )
m_newHead = *shovedLine;
sanityCheck( obstacleLine, shovedLine );
m_currentNode->Replace( obstacleLine, shovedLine );
sanityCheck( obstacleLine, shovedLine );
......@@ -324,7 +324,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S
}
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE *aCurrent, PNS_LINE *aObstacle )
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE* aCurrent, PNS_LINE* aObstacle )
{
PNS_LINE* shovedLine = cloneLine( aObstacle );
......@@ -332,13 +332,13 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE *aCurrent, PNS_LINE
if( rv == SH_OK )
{
if ( shovedLine->Marker() & MK_HEAD )
if( shovedLine->Marker() & MK_HEAD )
m_newHead = *shovedLine;
sanityCheck( aObstacle, shovedLine );
m_currentNode->Replace( aObstacle, shovedLine );
sanityCheck( aObstacle, shovedLine );
int rank = aObstacle->Rank();
shovedLine->SetRank ( rank );
......@@ -360,10 +360,10 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
{
PNS_WALKAROUND walkaround( m_currentNode, Router() );
PNS_LINE* walkaroundLine = cloneLine( aCurrent );
if( aCurrent->EndsWithVia() )
{
PNS_VIA vh = aCurrent->Via();
PNS_VIA vh = aCurrent->Via();
PNS_VIA* via = NULL;
PNS_JOINT* jtStart = m_currentNode->FindJoint ( vh.Pos(), aCurrent );
......@@ -378,14 +378,14 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
break;
}
}
if( via && m_currentNode->CheckColliding( via, aObstacleSolid ) )
return onCollidingVia( aObstacleSolid, via );
}
walkaround.SetSolidsOnly( true );
walkaround.SetIterationLimit ( 8 ); // fixme: make configurable
int currentRank = aCurrent->Rank();
int nextRank;
......@@ -399,7 +399,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
nextRank = currentRank - 1;
walkaround.SetSingleDirection( true );
}
if( walkaround.Route( *aCurrent, *walkaroundLine, false ) != PNS_WALKAROUND::DONE )
return SH_INCOMPLETE;
......@@ -415,10 +415,10 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL
walkaroundLine->Mark( MK_HEAD );
m_newHead = *walkaroundLine;
}
m_currentNode->Replace( aCurrent, walkaroundLine );
walkaroundLine->SetRank ( nextRank );
#ifdef DEBUG
m_logger.NewGroup( "on-colliding-solid", m_iter );
m_logger.Log( aObstacleSolid, 0, "obstacle-solid" );
......@@ -444,7 +444,7 @@ bool PNS_SHOVE::reduceSpringback( const PNS_ITEMSET& aHeadSet )
if( !spTag.m_node->CheckColliding( aHeadSet ) )
{
rv = true;
delete spTag.m_node;
m_nodeStack.pop_back();
}
......@@ -498,9 +498,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
PNS_SEGMENT* seg = (PNS_SEGMENT*) item;
LINE_PAIR lp;
int segIndex;
lp.first = assembleLine( seg, &segIndex );
assert( segIndex == 0 || ( segIndex == ( lp.first->SegmentCount() - 1 ) ) );
if( segIndex == 0 )
......@@ -526,7 +526,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
m_logger.Log ( aVia, 0, "obstacle-via");
m_logger.Log ( pushedVia, 1, "pushed-via");
#endif
BOOST_FOREACH( LINE_PAIR lp, draggedLines )
{
if( lp.first->Marker() & MK_HEAD )
......@@ -535,13 +535,13 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
m_newHead = *lp.second;
}
unwindStack(lp.first);
unwindStack( lp.first );
if( lp.second->SegmentCount() )
{
m_currentNode->Replace( lp.first, lp.second );
lp.second->SetRank( aCurrentRank - 1 );
pushLine( lp.second );
pushLine( lp.second );
}
else
m_currentNode->Remove( lp.first );
......@@ -556,12 +556,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
}
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA* aObstacleVia )
PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia( PNS_ITEM* aCurrent, PNS_VIA* aObstacleVia )
{
int clearance = m_currentNode->GetClearance( aCurrent, aObstacleVia ) ;
LINE_PAIR_VEC draggedLines;
bool colLine = false, colVia = false;
PNS_LINE *currentLine = NULL;
PNS_LINE* currentLine = NULL;
VECTOR2I mtvLine, mtvVia, mtv, mtvSolid;
int rank = -1;
......@@ -573,12 +573,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA*
#endif
currentLine = (PNS_LINE*) aCurrent;
colLine = CollideShapes( aObstacleVia->Shape(), currentLine->Shape(),
clearance + currentLine->Width() / 2 + PNS_HULL_MARGIN,
colLine = CollideShapes( aObstacleVia->Shape(), currentLine->Shape(),
clearance + currentLine->Width() / 2 + PNS_HULL_MARGIN,
true, mtvLine );
if( currentLine->EndsWithVia() )
colVia = CollideShapes( currentLine->Via().Shape(), aObstacleVia->Shape(),
colVia = CollideShapes( currentLine->Via().Shape(), aObstacleVia->Shape(),
clearance + PNS_HULL_MARGIN, true, mtvVia );
if( !colLine && !colVia )
......@@ -590,18 +590,18 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA*
mtv = mtvLine;
else
mtv = mtvVia;
rank = currentLine->Rank();
}
else if (aCurrent->OfKind(PNS_ITEM::SOLID))
else if( aCurrent->OfKind( PNS_ITEM::SOLID ) )
{
CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(),
CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(),
clearance + PNS_HULL_MARGIN, true, mtvSolid );
mtv = -mtvSolid;
rank = aCurrent->Rank() + 10000;
}
return pushVia( aObstacleVia, mtv, rank );
return pushVia( aObstacleVia, mtv, rank );
}
......@@ -617,19 +617,19 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
shoved->ClearSegmentLinks();
cur->RemoveVia();
unwindStack(aCurrent);
unwindStack( aCurrent );
BOOST_FOREACH( PNS_ITEM* item, jt->LinkList() )
{
if( item->OfKind( PNS_ITEM::SEGMENT ) && item->LayersOverlap( aCurrent ) )
if( item->OfKind( PNS_ITEM::SEGMENT ) && item->LayersOverlap( aCurrent ) )
{
PNS_SEGMENT* seg = (PNS_SEGMENT*) item;
PNS_LINE* head = assembleLine( seg );
head->AppendVia( *aObstacleVia );
SHOVE_STATUS st = processSingleLine ( head, cur, shoved );
if( st != SH_OK )
{
#ifdef DEBUG
......@@ -641,7 +641,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
return st;
}
cur->SetShape( shoved->CLine() );
n++;
}
......@@ -654,7 +654,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
m_logger.Log( aObstacleVia, 0, "the-via" );
m_logger.Log( aCurrent, 1, "current-line" );
#endif
PNS_LINE head( *aCurrent );
head.Line().Clear();
head.AppendVia( *aObstacleVia );
......@@ -683,7 +683,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
pushLine( shoved );
shoved->SetRank( currentRank );
return SH_OK;
return SH_OK;
}
......@@ -703,7 +703,7 @@ void PNS_SHOVE::unwindStack( PNS_SEGMENT *aSeg )
i = m_optimizerQueue.erase( i );
else
i++;
}
}
}
......@@ -715,20 +715,20 @@ void PNS_SHOVE::unwindStack( PNS_ITEM* aItem )
{
PNS_LINE* l = static_cast<PNS_LINE*>( aItem );
if ( !l->LinkedSegments() )
if( !l->LinkedSegments() )
return;
BOOST_FOREACH( PNS_SEGMENT* seg, *l->LinkedSegments() )
unwindStack( seg );
}
}
void PNS_SHOVE::pushLine( PNS_LINE* aL )
{
if( aL->LinkCount() >= 0 && ( aL->LinkCount() != aL->SegmentCount() ) )
assert( false );
m_lineStack.push_back( aL );
m_optimizerQueue.push_back( aL );
}
......@@ -757,17 +757,17 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
PNS_LINE* currentLine = m_lineStack.back();
PNS_NODE::OPT_OBSTACLE nearest;
SHOVE_STATUS st;
PNS_ITEM::PnsKind search_order[] = { PNS_ITEM::SOLID, PNS_ITEM::VIA, PNS_ITEM::SEGMENT };
for( int i = 0; i < 3; i++ )
{
nearest = m_currentNode->NearestObstacle( currentLine, search_order[i] );
if( nearest )
break;
}
}
if( !nearest )
{
m_lineStack.pop_back();
......@@ -786,7 +786,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
{
PNS_VIA* revVia = (PNS_VIA*) ni;
TRACE( 2, "iter %d: reverse-collide-via", aIter );
if( currentLine->EndsWithVia() && m_currentNode->CheckColliding( &currentLine->Via(), revVia ) )
{
st = SH_INCOMPLETE;
......@@ -798,7 +798,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
break;
}
case PNS_ITEM::SEGMENT:
{
PNS_SEGMENT* seg = (PNS_SEGMENT*) ni;
......@@ -825,15 +825,15 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
break;
case PNS_ITEM::VIA:
TRACE( 2, "iter %d: shove-via ", aIter );
TRACE( 2, "iter %d: shove-via ", aIter );
st = onCollidingVia( currentLine, (PNS_VIA*) ni );
break;
case PNS_ITEM::SOLID:
TRACE( 2, "iter %d: walk-solid ", aIter );
TRACE( 2, "iter %d: walk-solid ", aIter );
st = onCollidingSolid( currentLine, (PNS_SOLID*) ni );
break;
default:
break;
}
......@@ -863,7 +863,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveMainLoop()
m_iter++;
if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit )
if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit )
{
st = SH_INCOMPLETE;
break;
......@@ -884,7 +884,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
PNS_LINE* head = cloneLine( &aCurrentHead );
head->ClearSegmentLinks();
m_lineStack.clear();
m_optimizerQueue.clear();
m_newHead = OPT_LINE();
......@@ -899,7 +899,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
m_currentNode = parent->Branch();
m_currentNode->ClearRanks();
m_currentNode->Add( head );
head->Mark( MK_HEAD );
head->SetRank( 100000 );
......@@ -921,11 +921,11 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
st = shoveMainLoop();
runOptimizer( m_currentNode, head );
if( m_newHead && st == SH_OK )
if( m_newHead && st == SH_OK )
{
st = SH_HEAD_MODIFIED;
//Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 );
}
}
m_currentNode->RemoveByMarker( MK_HEAD );
......@@ -939,9 +939,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
else
{
delete m_currentNode;
m_currentNode = parent;
m_newHead = OPT_LINE();
m_newHead = OPT_LINE();
}
return st;
......@@ -952,7 +952,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveDraggingVia( PNS_VIA* aVia, const VECTOR
PNS_VIA** aNewVia )
{
SHOVE_STATUS st = SH_OK;
m_lineStack.clear();
m_optimizerQueue.clear();
m_newHead = OPT_LINE();
......@@ -1031,7 +1031,7 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead )
i != m_optimizerQueue.end(); ++i)
{
PNS_LINE* line = *i;
if( !( line -> Marker() & MK_HEAD ) )
{
if( effort == OE_MEDIUM || effort == OE_LOW )
......@@ -1062,7 +1062,7 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead )
}
const RANGE<int> PNS_SHOVE::findShovedVertexRange( PNS_LINE *aL )
const RANGE<int> PNS_SHOVE::findShovedVertexRange( PNS_LINE* aL )
{
RANGE<int> r;
......@@ -1116,6 +1116,7 @@ const PNS_LINE PNS_SHOVE::NewHead() const
return *m_newHead;
}
void PNS_SHOVE::SetInitialLine( PNS_LINE* aInitial )
{
m_root = m_root->Branch();
......
......@@ -37,7 +37,7 @@ class PNS_ROUTER;
/**
* Class PNS_SHOVE
*
* The actual Push and Shove algorithm.
* The actual Push and Shove algorithm.
*/
class PNS_SHOVE : public PNS_ALGO_BASE
......@@ -88,11 +88,11 @@ private:
SHOVE_STATUS processSingleLine( PNS_LINE* aCurrent, PNS_LINE* aObstacle, PNS_LINE* aShoved );
SHOVE_STATUS processHullSet( PNS_LINE* aCurrent, PNS_LINE* aObstacle,
PNS_LINE* aShoved, const HULL_SET& hulls );
bool reduceSpringback( const PNS_ITEMSET& aHeadItems );
bool pushSpringback( PNS_NODE* aNode, const PNS_ITEMSET &aHeadItems,
const PNS_COST_ESTIMATOR& aCost );
SHOVE_STATUS walkaroundLoneVia( PNS_LINE* aCurrent, PNS_LINE* aObstacle, PNS_LINE* aShoved );
bool checkBumpDirection( PNS_LINE* aCurrent, PNS_LINE* aShoved ) const;
......@@ -104,20 +104,20 @@ private:
SHOVE_STATUS pushVia( PNS_VIA* aVia, const VECTOR2I& aForce, int aCurrentRank );
void unwindStack( PNS_SEGMENT* aSeg );
void unwindStack( PNS_ITEM *aItem );
void unwindStack( PNS_ITEM* aItem );
void runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead );
void pushLine( PNS_LINE *aL );
void popLine();
void pushLine( PNS_LINE* aL );
void popLine();
const RANGE<int> findShovedVertexRange( PNS_LINE *aL );
const RANGE<int> findShovedVertexRange( PNS_LINE* aL );
PNS_LINE* assembleLine( const PNS_SEGMENT* aSeg, int* aIndex = NULL );
PNS_LINE* cloneLine( const PNS_LINE* aLine );
SHOVE_STATUS shoveIteration( int aIter );
SHOVE_STATUS shoveMainLoop();
SHOVE_STATUS shoveMainLoop();
std::vector<SPRINGBACK_TAG> m_nodeStack;
std::vector<PNS_LINE*> m_lineStack;
......@@ -126,7 +126,7 @@ private:
PNS_NODE* m_root;
PNS_NODE* m_currentNode;
OPT_LINE m_newHead;
PNS_LOGGER m_logger;
......
......@@ -79,7 +79,7 @@ public:
private:
int inheritTrackWidth( PNS_ITEM *aItem );
int inheritTrackWidth( PNS_ITEM* aItem );
int m_trackWidth;
int m_diffPairWidth;
......
......@@ -48,7 +48,7 @@ public:
m_drill = aDrill;
m_shape = SHAPE_CIRCLE( aPos, aDiameter / 2 );
m_viaType = aViaType;
//If we're a through-board via, use all layers regardless of the set passed
if( aViaType == VIA_THROUGH )
{
......
......@@ -83,10 +83,10 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath,
m_logger.Log( &current_obs->m_hull, 2, "hull" );
m_logger.Log( current_obs->m_item, 3, "item" );
#endif
int len_pre = path_walk[0].Length();
int len_alt = path_walk[1].Length();
PNS_LINE walk_path( aPath, path_walk[1] );
bool alt_collides = m_world->CheckColliding( &walk_path, m_itemMask );
......@@ -158,7 +158,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
{
int len_cw = path_cw.CLine().Length();
int len_ccw = path_ccw.CLine().Length();
if( m_forceLongerPath )
aWalkPath = (len_cw > len_ccw ? path_cw : path_ccw);
else
......@@ -179,7 +179,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
m_iteration++;
}
if( m_iteration == m_iterationLimit )
{
int len_cw = path_cw.CLine().Length();
......@@ -235,7 +235,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia
if( aWalkPath.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
return STUCK;
WALKAROUND_STATUS st = s_ccw == DONE || s_cw == DONE ? DONE : STUCK;
if( aOptimize && st == DONE )
......
......@@ -34,7 +34,7 @@ class PNS_WALKAROUND : public PNS_ALGO_BASE
public:
PNS_WALKAROUND( PNS_NODE* aWorld, PNS_ROUTER* aRouter ) :
PNS_ALGO_BASE ( aRouter ),
m_world( aWorld ),
m_world( aWorld ),
m_iterationLimit( DefaultIterationLimit )
{
m_forceSingleDirection = false;
......
......@@ -38,7 +38,7 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem, VIEW_GROUP* aPa
EDA_ITEM( NOT_USED )
{
m_parent = aParent;
m_shape = NULL;
m_clearance = -1;
m_originLayer = m_layer = ITEM_GAL_LAYER( GP_OVERLAY );
......@@ -64,7 +64,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem )
m_color.a = 0.8;
m_depth = BaseOverlayDepth - aItem->Layers().Start();
m_shape = aItem->Shape()->Clone();
switch( aItem->Kind() )
{
case PNS_ITEM::LINE:
......@@ -99,7 +99,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem )
if( aItem->Marker() & MK_VIOLATION )
m_color = COLOR4D( 0, 1, 0, 1 );
if( aItem->Marker() & MK_HEAD )
m_color.Brighten( 0.7 );
......@@ -178,7 +178,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal->SetLineWidth( m_width + 2 * m_clearance );
aGal->DrawLine( s->GetSeg().A, s->GetSeg().B );
}
break;
}
......@@ -194,7 +194,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal->SetIsStroke( false );
aGal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance );
}
break;
}
......@@ -225,7 +225,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
void ROUTER_PREVIEW_ITEM::Line( const SHAPE_LINE_CHAIN& aLine, int aWidth, int aStyle )
{
m_originLayer = m_layer = 0;
m_originLayer = m_layer = 0;
m_width = aWidth;
m_color = assignColor( aStyle );
m_type = PR_SHAPE;
......
......@@ -304,7 +304,7 @@ PNS_ITEM* ROUTER_TOOL::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLa
PNS_ITEM* prioritized[4];
for(int i = 0; i < 4; i++)
for( int i = 0; i < 4; i++ )
prioritized[i] = 0;
PNS_ITEMSET candidates = m_router->QueryHoverItems( aWhere );
......@@ -379,7 +379,7 @@ void ROUTER_TOOL::highlightNet( bool aEnabled, int aNetcode )
void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
{
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME> ();
BOARD *board = getModel<BOARD> ();
BOARD* board = getModel<BOARD> ();
#ifdef DEBUG
if( aEvent.IsKeyPressed() )
......@@ -401,7 +401,7 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
if( settingsDlg.ShowModal() )
{
// FIXME: do we need an explicit update?
}
}
}
else if( aEvent.IsAction( &ACT_CustomTrackWidth ) )
......@@ -409,7 +409,7 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
DIALOG_TRACK_VIA_SIZE sizeDlg( frame, bds );
if ( sizeDlg.ShowModal() )
if( sizeDlg.ShowModal() )
{
bds.UseCustomTrackViaSize( true );
m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged );
......@@ -437,7 +437,7 @@ void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent )
{
VECTOR2I p = aEvent.Position();
startItem = pickSingleItem( p );
bool snapEnabled = !aEvent.Modifier(MD_SHIFT);
bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
m_router->EnableSnapping ( snapEnabled );
if( !snapEnabled && startItem && !startItem->Layers().Overlaps( tl ) )
......@@ -520,20 +520,20 @@ 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 ROUTER_TOOL::getStartLayer( const PNS_ITEM* aItem )
{
int tl = getView()->GetTopLayer();
if (m_startItem)
if( m_startItem )
{
const PNS_LAYERSET& ls = m_startItem->Layers();
if(ls.Overlaps( tl ))
if( ls.Overlaps( tl ) )
return tl;
else
return ls.Start();
}
return tl;
}
void ROUTER_TOOL::switchLayerOnViaPlacement()
......@@ -542,7 +542,7 @@ void ROUTER_TOOL::switchLayerOnViaPlacement()
int al = frame->GetActiveLayer();
int cl = m_router->GetCurrentLayer();
if( cl != al )
{
m_router->SwitchLayer( al );
......@@ -559,7 +559,7 @@ void ROUTER_TOOL::switchLayerOnViaPlacement()
bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType )
{
BOARD *board = getModel<BOARD> ();
BOARD* board = getModel<BOARD> ();
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
......@@ -572,32 +572,32 @@ bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType )
sizes.AddLayerPair( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
if (!m_router->IsPlacingVia())
if( !m_router->IsPlacingVia() )
{
// Cannot place microvias or blind vias if not allowed (obvious)
if( ( aType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
return false;
if( ( aType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
return false;
//Can only place through vias on 2-layer boards
if( ( aType != VIA_THROUGH ) && ( layerCount <= 2 ) )
return false;
//Can only place microvias if we're on an outer layer, or directly adjacent to one
if( ( aType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount-2 ) )
return false;
//Cannot place blind vias with front/back as the layer pair, this doesn't make sense
if( ( aType == VIA_BLIND_BURIED ) && ( sizes.GetLayerTop() == F_Cu ) && ( sizes.GetLayerBottom() == B_Cu ) )
return false;
}
sizes.SetViaType ( aType );
m_router->ToggleViaPlacement( );
m_router->UpdateSizes( sizes );
m_router->Move( m_endSnapPoint, m_endItem ); // refresh
return false;
......@@ -612,7 +612,7 @@ void ROUTER_TOOL::performRouting()
int routingLayer = getStartLayer ( m_startItem );
frame->SetActiveLayer( ToLAYER_ID ( routingLayer ) );
// fixme: switch on invisible layer
// fixme: switch on invisible layer
if( m_startItem && m_startItem->Net() >= 0 )
{
......@@ -631,7 +631,7 @@ void ROUTER_TOOL::performRouting()
sizes.AddLayerPair ( frame->GetScreen()->m_Route_Layer_TOP,
frame->GetScreen()->m_Route_Layer_BOTTOM );
m_router->UpdateSizes( sizes );
m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer );
m_endItem = NULL;
......@@ -659,7 +659,7 @@ void ROUTER_TOOL::performRouting()
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
break;
if(needLayerSwitch)
if( needLayerSwitch )
{
switchLayerOnViaPlacement();
}
......@@ -764,7 +764,7 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
else
performRouting();
}
else if ( evt->IsAction( &ACT_Drag ) )
else if( evt->IsAction( &ACT_Drag ) )
performDragging();
handleCommonEvents( *evt );
......
......@@ -47,10 +47,10 @@ private:
PNS_ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1 );
int getDefaultWidth( int aNetCode );
void performRouting();
void performDragging();
void highlightNet( bool aEnabled, int aNetcode = -1 );
void updateStartItem( TOOL_EVENT& aEvent );
......@@ -59,7 +59,7 @@ private:
void getNetclassDimensions( int aNetCode, int& aWidth, int& aViaDiameter, int& aViaDrill );
void handleCommonEvents( TOOL_EVENT& evt );
int getStartLayer( const PNS_ITEM *aItem );
int getStartLayer( const PNS_ITEM* aItem );
void switchLayerOnViaPlacement();
bool onViaCommand( VIATYPE_T aType );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment