From fb0045a898456271b8932b12bfe1256212c64a7e Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 7 Jul 2014 10:48:47 +0200 Subject: [PATCH] Bugfix: Bottom layer not correctly handled in (PNS) Interactive router. --- include/gal/graphics_abstraction_layer.h | 3 +++ include/layers_id_colors_and_visibility.h | 2 +- pcbnew/router/pns_layerset.h | 2 +- pcbnew/router/pns_line_placer.cpp | 8 ++++---- pcbnew/router/pns_router.cpp | 10 +++++----- pcbnew/router/router_preview_item.cpp | 7 +++---- pcbnew/router/router_preview_item.h | 4 ++-- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index d6dccd0d61..24f207f355 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -255,6 +255,9 @@ public: */ inline virtual void SetLayerDepth( double aLayerDepth ) { + assert( aLayerDepth <= depthRange.y ); + assert( aLayerDepth >= depthRange.x ); + layerDepth = aLayerDepth; } diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index d972f61784..c3dfd4b0ab 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -138,7 +138,7 @@ enum LAYER_ID #define LAST_COPPER_LAYER brain dead #define FIRST_LAYER brain dead #define NB_LAYERS use LAYER_ID_COUNT instead -#define NB_COPPER_LAYERS was always a max, not a number, use MAX_CU_COUNT now. +#define NB_COPPER_LAYERS was always a max, not a number, use MAX_CU_LAYERS now. */ diff --git a/pcbnew/router/pns_layerset.h b/pcbnew/router/pns_layerset.h index 7ba05d84ef..aed8761365 100644 --- a/pcbnew/router/pns_layerset.h +++ b/pcbnew/router/pns_layerset.h @@ -108,7 +108,7 @@ public: ///> Shortcut for comparisons/overlap tests static PNS_LAYERSET All() { - return PNS_LAYERSET( 0, 256 ); + return PNS_LAYERSET( 0, 64 ); } private: diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index e60729c90c..2c26df7c96 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -379,7 +379,7 @@ bool PNS_LINE_PLACER::handleViaPlacement( PNS_LINE& aHead ) if( !m_placingVia ) return true; - PNS_LAYERSET allLayers( 0, 15 ); + PNS_LAYERSET allLayers( 0, MAX_CU_LAYERS - 1 ); PNS_VIA v( aHead.CPoint( -1 ), allLayers, m_viaDiameter, m_viaDrill, aHead.Net() ); VECTOR2I force; @@ -439,7 +439,7 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead ) } else if( m_placingVia && viaOk ) { - PNS_LAYERSET allLayers( 0, 15 ); + PNS_LAYERSET allLayers( 0, MAX_CU_LAYERS - 1 ); PNS_VIA v1( walkFull.CPoint( -1 ), allLayers, m_viaDiameter, m_viaDrill ); walkFull.AppendVia( v1 ); } @@ -464,7 +464,7 @@ bool PNS_LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead ) if( m_placingVia ) { - PNS_LAYERSET allLayers( 0, 15 ); + PNS_LAYERSET allLayers( 0, MAX_CU_LAYERS - 1 ); PNS_VIA v1( m_head.CPoint( -1 ), allLayers, m_viaDiameter, m_viaDrill ); m_head.AppendVia( v1 ); } @@ -507,7 +507,7 @@ bool PNS_LINE_PLACER::rhShoveOnly ( const VECTOR2I& aP, PNS_LINE& aNewHead ) if( m_placingVia ) { - PNS_LAYERSET allLayers( 0, 15 ); + PNS_LAYERSET allLayers( 0, MAX_CU_LAYERS - 1 ); PNS_VIA v1( l.CPoint( -1 ), allLayers, m_viaDiameter, m_viaDrill ); PNS_VIA v2( l2.CPoint( -1 ), allLayers, m_viaDiameter, m_viaDrill ); diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 70e3c5d36a..8813a854f1 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -116,12 +116,12 @@ private: PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad ) { - PNS_LAYERSET layers( 0, 15 ); + PNS_LAYERSET layers( 0, MAX_CU_LAYERS - 1 ); switch( aPad->GetAttribute() ) { case PAD_STANDARD: - layers = PNS_LAYERSET( 0, 15 ); + layers = PNS_LAYERSET( 0, MAX_CU_LAYERS - 1 ); // TODO necessary? it is already initialized break; case PAD_SMD: @@ -191,7 +191,7 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad ) else delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 ); - SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta, + SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta, std::min( sz.x, sz.y ) ); solid->SetShape( shape ); } @@ -229,7 +229,7 @@ PNS_ITEM* PNS_ROUTER::syncVia( VIA* aVia ) { PNS_VIA* v = new PNS_VIA( aVia->GetPosition(), - PNS_LAYERSET( 0, 15 ), + PNS_LAYERSET( 0, MAX_CU_LAYERS - 1 ), aVia->GetWidth(), aVia->GetDrillValue(), aVia->GetNetCode() ); @@ -260,7 +260,7 @@ int PNS_ROUTER::NextCopperLayer( bool aUp ) l = 0; if( l < 0 ) - l = MAX_CU_LAYERS-1; + l = MAX_CU_LAYERS - 1; if( mask[l] ) return l; diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index 85a7062b5a..83e0a2f3a2 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -41,7 +41,7 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem, VIEW_GROUP* aPa m_shape = NULL; m_clearance = -1; - m_originLayer = m_layer = ITEM_GAL_LAYER ( GP_OVERLAY ); + m_originLayer = m_layer = ITEM_GAL_LAYER( GP_OVERLAY ); if( aItem ) Update( aItem ); @@ -59,7 +59,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem ) assert( m_originLayer >= 0 ); - m_layer = m_originLayer; + m_layer = m_originLayer; m_color = getLayerColor( m_originLayer ); m_color.a = 0.8; m_depth = BaseOverlayDepth - aItem->Layers().Start(); @@ -70,7 +70,6 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem ) case PNS_ITEM::LINE: m_type = PR_SHAPE; m_width = ( (PNS_LINE*) aItem )->Width(); - break; case PNS_ITEM::SEGMENT: @@ -174,7 +173,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const if( m_clearance > 0 ) { aGal->SetLayerDepth( ClearanceOverlayDepth ); - aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY )); + aGal->SetStrokeColor( COLOR4D( DARKDARKGRAY ) ); aGal->SetLineWidth( m_width + 2 * m_clearance ); aGal->DrawLine( s->GetSeg().A, s->GetSeg().B ); } diff --git a/pcbnew/router/router_preview_item.h b/pcbnew/router/router_preview_item.h index c22e21c5e6..aeb5492979 100644 --- a/pcbnew/router/router_preview_item.h +++ b/pcbnew/router/router_preview_item.h @@ -84,7 +84,7 @@ public: aCount = 1; } - void drawLineChain( const SHAPE_LINE_CHAIN& aL, KIGFX::GAL *aGal ) const; + void drawLineChain( const SHAPE_LINE_CHAIN& aL, KIGFX::GAL* aGal ) const; private: const KIGFX::COLOR4D assignColor( int aStyle ) const; @@ -105,7 +105,7 @@ private: // fixme: shouldn't this go to VIEW? static const int ClearanceOverlayDepth = -2000; - static const int BaseOverlayDepth = -2020; + static const int BaseOverlayDepth = -2010; static const int ViaOverlayDepth = -2046; double m_depth;