Loading pcbnew/router/direction.h +16 −18 Original line number Original line Diff line number Diff line Loading @@ -237,7 +237,7 @@ public: pl.Append( aP1 ); pl.Append( aP1 ); pl.Simplify(); pl.Simplify(); return pl; return pl; }; } bool operator==( const DIRECTION_45& aOther ) const bool operator==( const DIRECTION_45& aOther ) const { { Loading Loading @@ -286,8 +286,6 @@ public: return l; return l; } } /** /** * Function ToVector() * Function ToVector() * * Loading pcbnew/router/pns_algo_base.h +8 −7 Original line number Original line Diff line number Diff line Loading @@ -33,17 +33,18 @@ class PNS_LOGGER; * Holds a bunch of objects commonly used by all algorithms (P&S settings, parent router instance, logging) * Holds a bunch of objects commonly used by all algorithms (P&S settings, parent router instance, logging) **/ **/ class PNS_ALGO_BASE { class PNS_ALGO_BASE { public: public: PNS_ALGO_BASE( PNS_ROUTER *aRouter ) : PNS_ALGO_BASE( PNS_ROUTER *aRouter ) : m_router ( aRouter ) m_router ( aRouter ) {}; {} virtual ~PNS_ALGO_BASE() {} virtual ~PNS_ALGO_BASE() {} ///> Returns the instance of our router ///> Returns the instance of our router PNS_ROUTER *Router() const { PNS_ROUTER* Router() const { return m_router; return m_router; } } Loading pcbnew/router/pns_dragger.cpp +79 −61 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,8 @@ PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) : { { m_world = NULL; m_world = NULL; m_shove = NULL; m_shove = NULL; }; } PNS_DRAGGER::~PNS_DRAGGER() PNS_DRAGGER::~PNS_DRAGGER() { { Loading @@ -37,11 +38,13 @@ PNS_DRAGGER::~PNS_DRAGGER() delete m_shove; delete m_shove; } } void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld ) void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld ) { { m_world = aWorld; m_world = aWorld; } } bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) { { int w2 = aSeg->Width() / 2; int w2 = aSeg->Width() / 2; Loading @@ -59,9 +62,11 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT *aSeg ) m_mode = CORNER; m_mode = CORNER; } else } else m_mode = SEGMENT; m_mode = SEGMENT; return true; return true; } } bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) { { m_draggedVia = aVia; m_draggedVia = aVia; Loading @@ -83,14 +88,13 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA *aVia ) l->Reverse(); l->Reverse(); m_origViaConnections.push_back( *l ); m_origViaConnections.push_back( *l ); } } } } return true; return true; } } bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) 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() ); Loading @@ -104,13 +108,16 @@ bool PNS_DRAGGER::Start ( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { { case PNS_ITEM::SEGMENT: case PNS_ITEM::SEGMENT: return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) ); return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) ); case PNS_ITEM::VIA: case PNS_ITEM::VIA: return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) ); return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) ); default: default: return false; return false; } } } } bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) { { if( m_lastNode ) if( m_lastNode ) Loading Loading @@ -143,12 +150,12 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) break; break; } } case VIA: // fixme... case VIA: // fixme... { { m_lastNode = m_shove->CurrentNode()->Branch(); m_lastNode = m_shove->CurrentNode()->Branch(); dumbDragVia ( m_initialVia, m_lastNode, aP ); dumbDragVia ( m_initialVia, m_lastNode, aP ); break; break; } } } } Loading @@ -161,6 +168,7 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) return true; return true; } } void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& aP ) void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& aP ) { { // fixme: this is awful. // fixme: this is awful. Loading @@ -187,11 +195,11 @@ void PNS_DRAGGER::dumbDragVia ( PNS_VIA *aVia, PNS_NODE *aNode, const VECTOR2I& } } } } bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) { { bool ok = false; bool ok = false; if( m_lastNode ) if( m_lastNode ) { { delete m_lastNode; delete m_lastNode; Loading @@ -205,12 +213,13 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) { { int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; PNS_LINE tmp( *m_draggedLine ); PNS_LINE tmp( *m_draggedLine ); if( m_mode == SEGMENT ) if( m_mode == SEGMENT ) tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); else else tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); PNS_SHOVE::ShoveStatus st = m_shove->ShoveLines( tmp ); PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( tmp ); if( st == PNS_SHOVE::SH_OK ) if( st == PNS_SHOVE::SH_OK ) ok = true; ok = true; Loading @@ -232,10 +241,11 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; break; } } case VIA: case VIA: { { PNS_VIA *newVia; PNS_VIA *newVia; PNS_SHOVE::ShoveStatus st = m_shove -> ShoveDraggingVia ( m_draggedVia, aP, &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 ) if( st == PNS_SHOVE::SH_OK || st == PNS_SHOVE::SH_HEAD_MODIFIED ) ok = true; ok = true; Loading @@ -250,13 +260,14 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; break; } } } } m_dragStatus = ok; m_dragStatus = ok; return ok; return ok; } } bool PNS_DRAGGER::FixRoute() bool PNS_DRAGGER::FixRoute() { { if( m_dragStatus ) if( m_dragStatus ) Loading @@ -268,34 +279,41 @@ bool PNS_DRAGGER::FixRoute( ) return false; return false; } } bool PNS_DRAGGER::Drag( const VECTOR2I& aP ) bool PNS_DRAGGER::Drag( const VECTOR2I& aP ) { { switch( m_currentMode ) switch( m_currentMode ) { { case RM_MarkObstacles: case RM_MarkObstacles: return dragMarkObstacles( aP ); return dragMarkObstacles( aP ); case RM_Shove: case RM_Shove: case RM_Walkaround: case RM_Walkaround: case RM_Smart: case RM_Smart: return dragShove( aP ); return dragShove( aP ); default: default: return false; return false; } } } } PNS_NODE *PNS_DRAGGER::CurrentNode() const PNS_NODE *PNS_DRAGGER::CurrentNode() const { { return m_lastNode; return m_lastNode; } } const PNS_ITEMSET PNS_DRAGGER::Traces() const PNS_ITEMSET PNS_DRAGGER::Traces() { { return m_draggedItems; return m_draggedItems; } } PNS_LOGGER* PNS_DRAGGER::Logger() PNS_LOGGER* PNS_DRAGGER::Logger() { { if( m_shove ) if( m_shove ) return m_shove->Logger(); return m_shove->Logger(); return NULL; return NULL; } } pcbnew/router/pns_dragger.h +26 −31 Original line number Original line Diff line number Diff line Loading @@ -39,11 +39,9 @@ class PNS_ROUTER_BASE; * * * Via, segment and corner dragging algorithm. * Via, segment and corner dragging algorithm. */ */ class PNS_DRAGGER : public PNS_ALGO_BASE class PNS_DRAGGER : public PNS_ALGO_BASE { { public: public: PNS_DRAGGER( PNS_ROUTER* aRouter ); PNS_DRAGGER( PNS_ROUTER* aRouter ); ~PNS_DRAGGER(); ~PNS_DRAGGER(); Loading @@ -54,7 +52,6 @@ public: */ */ void SetWorld( PNS_NODE* aWorld ); void SetWorld( PNS_NODE* aWorld ); /** /** * Function Start() * Function Start() * * Loading Loading @@ -86,7 +83,6 @@ public: * Returns the most recent world state, including all * Returns the most recent world state, including all * items changed due to dragging operation. * items changed due to dragging operation. */ */ PNS_NODE* CurrentNode() const; PNS_NODE* CurrentNode() const; /** /** Loading @@ -100,7 +96,6 @@ public: virtual PNS_LOGGER* Logger(); virtual PNS_LOGGER* Logger(); private: private: typedef std::pair<PNS_LINE *, PNS_LINE *> LinePair; typedef std::pair<PNS_LINE *, PNS_LINE *> LinePair; typedef std::vector<LinePair> LinePairVec; typedef std::vector<LinePair> LinePairVec; Loading pcbnew/router/pns_index.h +19 −23 Original line number Original line Diff line number Diff line Loading @@ -39,13 +39,12 @@ * are assigned to separate R-Tree subindices depending on their type and spanned layers, reducing * are assigned to separate R-Tree subindices depending on their type and spanned layers, reducing * overlap and improving search time. * overlap and improving search time. **/ **/ class PNS_INDEX class PNS_INDEX { { public: public: typedef std::list<PNS_ITEM*> NetItemsList; typedef std::list<PNS_ITEM*> NET_ITEMS_LIST; typedef SHAPE_INDEX<PNS_ITEM*> ItemShapeIndex; typedef SHAPE_INDEX<PNS_ITEM*> ITEM_SHAPE_INDEX; typedef boost::unordered_set<PNS_ITEM*> ItemSet; typedef boost::unordered_set<PNS_ITEM*> ITEM_SET; PNS_INDEX(); PNS_INDEX(); ~PNS_INDEX(); ~PNS_INDEX(); Loading Loading @@ -115,7 +114,7 @@ public: * * * Returns list of all items in a given net. * Returns list of all items in a given net. */ */ NetItemsList* GetItemsForNet( int aNet ); NET_ITEMS_LIST* GetItemsForNet( int aNet ); /** /** * Function Contains() * Function Contains() Loading @@ -134,8 +133,8 @@ public: */ */ int Size() const { return m_allItems.size(); } int Size() const { return m_allItems.size(); } ItemSet::iterator begin() { return m_allItems.begin(); } ITEM_SET::iterator begin() { return m_allItems.begin(); } ItemSet::iterator end() { return m_allItems.end(); } ITEM_SET::iterator end() { return m_allItems.end(); } private: private: static const int MaxSubIndices = 64; static const int MaxSubIndices = 64; Loading @@ -149,21 +148,20 @@ private: template <class Visitor> template <class Visitor> int querySingle( int index, const SHAPE* aShape, int aMinDistance, Visitor& aVisitor ); int querySingle( int index, const SHAPE* aShape, int aMinDistance, Visitor& aVisitor ); ItemShapeIndex* getSubindex( const PNS_ITEM* aItem ); ITEM_SHAPE_INDEX* getSubindex( const PNS_ITEM* aItem ); ItemShapeIndex* m_subIndices[MaxSubIndices]; ITEM_SHAPE_INDEX* m_subIndices[MaxSubIndices]; std::map<int, NetItemsList> m_netMap; std::map<int, NET_ITEMS_LIST> m_netMap; ItemSet m_allItems; ITEM_SET m_allItems; }; }; PNS_INDEX::PNS_INDEX() PNS_INDEX::PNS_INDEX() { { memset( m_subIndices, 0, sizeof( m_subIndices ) ); memset( m_subIndices, 0, sizeof( m_subIndices ) ); } } PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) PNS_INDEX::ITEM_SHAPE_INDEX* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) { { int idx_n = -1; int idx_n = -1; Loading Loading @@ -199,7 +197,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) assert( idx_n >= 0 && idx_n < MaxSubIndices ); assert( idx_n >= 0 && idx_n < MaxSubIndices ); if( !m_subIndices[idx_n] ) if( !m_subIndices[idx_n] ) m_subIndices[idx_n] = new ItemShapeIndex; m_subIndices[idx_n] = new ITEM_SHAPE_INDEX; return m_subIndices[idx_n]; return m_subIndices[idx_n]; } } Loading @@ -207,9 +205,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) void PNS_INDEX::Add( PNS_ITEM* aItem ) void PNS_INDEX::Add( PNS_ITEM* aItem ) { { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Add( aItem ); idx->Add( aItem ); m_allItems.insert( aItem ); m_allItems.insert( aItem ); Loading @@ -224,7 +220,7 @@ void PNS_INDEX::Add( PNS_ITEM* aItem ) void PNS_INDEX::Remove( PNS_ITEM* aItem ) void PNS_INDEX::Remove( PNS_ITEM* aItem ) { { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Remove( aItem ); idx->Remove( aItem ); m_allItems.erase( aItem ); m_allItems.erase( aItem ); Loading Loading @@ -303,7 +299,7 @@ void PNS_INDEX::Clear() { { for( int i = 0; i < MaxSubIndices; ++i ) for( int i = 0; i < MaxSubIndices; ++i ) { { ItemShapeIndex* idx = m_subIndices[i]; ITEM_SHAPE_INDEX* idx = m_subIndices[i]; if( idx ) if( idx ) delete idx; delete idx; Loading @@ -319,7 +315,7 @@ PNS_INDEX::~PNS_INDEX() } } PNS_INDEX::NetItemsList* PNS_INDEX::GetItemsForNet( int aNet ) PNS_INDEX::NET_ITEMS_LIST* PNS_INDEX::GetItemsForNet( int aNet ) { { if( m_netMap.find( aNet ) == m_netMap.end() ) if( m_netMap.find( aNet ) == m_netMap.end() ) return NULL; return NULL; Loading Loading
pcbnew/router/direction.h +16 −18 Original line number Original line Diff line number Diff line Loading @@ -237,7 +237,7 @@ public: pl.Append( aP1 ); pl.Append( aP1 ); pl.Simplify(); pl.Simplify(); return pl; return pl; }; } bool operator==( const DIRECTION_45& aOther ) const bool operator==( const DIRECTION_45& aOther ) const { { Loading Loading @@ -286,8 +286,6 @@ public: return l; return l; } } /** /** * Function ToVector() * Function ToVector() * * Loading
pcbnew/router/pns_algo_base.h +8 −7 Original line number Original line Diff line number Diff line Loading @@ -33,17 +33,18 @@ class PNS_LOGGER; * Holds a bunch of objects commonly used by all algorithms (P&S settings, parent router instance, logging) * Holds a bunch of objects commonly used by all algorithms (P&S settings, parent router instance, logging) **/ **/ class PNS_ALGO_BASE { class PNS_ALGO_BASE { public: public: PNS_ALGO_BASE( PNS_ROUTER *aRouter ) : PNS_ALGO_BASE( PNS_ROUTER *aRouter ) : m_router ( aRouter ) m_router ( aRouter ) {}; {} virtual ~PNS_ALGO_BASE() {} virtual ~PNS_ALGO_BASE() {} ///> Returns the instance of our router ///> Returns the instance of our router PNS_ROUTER *Router() const { PNS_ROUTER* Router() const { return m_router; return m_router; } } Loading
pcbnew/router/pns_dragger.cpp +79 −61 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,8 @@ PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) : { { m_world = NULL; m_world = NULL; m_shove = NULL; m_shove = NULL; }; } PNS_DRAGGER::~PNS_DRAGGER() PNS_DRAGGER::~PNS_DRAGGER() { { Loading @@ -37,11 +38,13 @@ PNS_DRAGGER::~PNS_DRAGGER() delete m_shove; delete m_shove; } } void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld ) void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld ) { { m_world = aWorld; m_world = aWorld; } } bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) { { int w2 = aSeg->Width() / 2; int w2 = aSeg->Width() / 2; Loading @@ -59,9 +62,11 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT *aSeg ) m_mode = CORNER; m_mode = CORNER; } else } else m_mode = SEGMENT; m_mode = SEGMENT; return true; return true; } } bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) { { m_draggedVia = aVia; m_draggedVia = aVia; Loading @@ -83,14 +88,13 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA *aVia ) l->Reverse(); l->Reverse(); m_origViaConnections.push_back( *l ); m_origViaConnections.push_back( *l ); } } } } return true; return true; } } bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) 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() ); Loading @@ -104,13 +108,16 @@ bool PNS_DRAGGER::Start ( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { { case PNS_ITEM::SEGMENT: case PNS_ITEM::SEGMENT: return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) ); return startDragSegment ( aP, static_cast<PNS_SEGMENT *>( aStartItem ) ); case PNS_ITEM::VIA: case PNS_ITEM::VIA: return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) ); return startDragVia ( aP, static_cast<PNS_VIA *> (aStartItem) ); default: default: return false; return false; } } } } bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) { { if( m_lastNode ) if( m_lastNode ) Loading Loading @@ -143,12 +150,12 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) break; break; } } case VIA: // fixme... case VIA: // fixme... { { m_lastNode = m_shove->CurrentNode()->Branch(); m_lastNode = m_shove->CurrentNode()->Branch(); dumbDragVia ( m_initialVia, m_lastNode, aP ); dumbDragVia ( m_initialVia, m_lastNode, aP ); break; break; } } } } Loading @@ -161,6 +168,7 @@ bool PNS_DRAGGER::dragMarkObstacles(const VECTOR2I& aP) return true; return true; } } void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& aP ) void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& aP ) { { // fixme: this is awful. // fixme: this is awful. Loading @@ -187,11 +195,11 @@ void PNS_DRAGGER::dumbDragVia ( PNS_VIA *aVia, PNS_NODE *aNode, const VECTOR2I& } } } } bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) { { bool ok = false; bool ok = false; if( m_lastNode ) if( m_lastNode ) { { delete m_lastNode; delete m_lastNode; Loading @@ -205,12 +213,13 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) { { int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; PNS_LINE tmp( *m_draggedLine ); PNS_LINE tmp( *m_draggedLine ); if( m_mode == SEGMENT ) if( m_mode == SEGMENT ) tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); else else tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); PNS_SHOVE::ShoveStatus st = m_shove->ShoveLines( tmp ); PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( tmp ); if( st == PNS_SHOVE::SH_OK ) if( st == PNS_SHOVE::SH_OK ) ok = true; ok = true; Loading @@ -232,10 +241,11 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; break; } } case VIA: case VIA: { { PNS_VIA *newVia; PNS_VIA *newVia; PNS_SHOVE::ShoveStatus st = m_shove -> ShoveDraggingVia ( m_draggedVia, aP, &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 ) if( st == PNS_SHOVE::SH_OK || st == PNS_SHOVE::SH_HEAD_MODIFIED ) ok = true; ok = true; Loading @@ -250,13 +260,14 @@ bool PNS_DRAGGER::dragShove(const VECTOR2I& aP) break; break; } } } } m_dragStatus = ok; m_dragStatus = ok; return ok; return ok; } } bool PNS_DRAGGER::FixRoute() bool PNS_DRAGGER::FixRoute() { { if( m_dragStatus ) if( m_dragStatus ) Loading @@ -268,34 +279,41 @@ bool PNS_DRAGGER::FixRoute( ) return false; return false; } } bool PNS_DRAGGER::Drag( const VECTOR2I& aP ) bool PNS_DRAGGER::Drag( const VECTOR2I& aP ) { { switch( m_currentMode ) switch( m_currentMode ) { { case RM_MarkObstacles: case RM_MarkObstacles: return dragMarkObstacles( aP ); return dragMarkObstacles( aP ); case RM_Shove: case RM_Shove: case RM_Walkaround: case RM_Walkaround: case RM_Smart: case RM_Smart: return dragShove( aP ); return dragShove( aP ); default: default: return false; return false; } } } } PNS_NODE *PNS_DRAGGER::CurrentNode() const PNS_NODE *PNS_DRAGGER::CurrentNode() const { { return m_lastNode; return m_lastNode; } } const PNS_ITEMSET PNS_DRAGGER::Traces() const PNS_ITEMSET PNS_DRAGGER::Traces() { { return m_draggedItems; return m_draggedItems; } } PNS_LOGGER* PNS_DRAGGER::Logger() PNS_LOGGER* PNS_DRAGGER::Logger() { { if( m_shove ) if( m_shove ) return m_shove->Logger(); return m_shove->Logger(); return NULL; return NULL; } }
pcbnew/router/pns_dragger.h +26 −31 Original line number Original line Diff line number Diff line Loading @@ -39,11 +39,9 @@ class PNS_ROUTER_BASE; * * * Via, segment and corner dragging algorithm. * Via, segment and corner dragging algorithm. */ */ class PNS_DRAGGER : public PNS_ALGO_BASE class PNS_DRAGGER : public PNS_ALGO_BASE { { public: public: PNS_DRAGGER( PNS_ROUTER* aRouter ); PNS_DRAGGER( PNS_ROUTER* aRouter ); ~PNS_DRAGGER(); ~PNS_DRAGGER(); Loading @@ -54,7 +52,6 @@ public: */ */ void SetWorld( PNS_NODE* aWorld ); void SetWorld( PNS_NODE* aWorld ); /** /** * Function Start() * Function Start() * * Loading Loading @@ -86,7 +83,6 @@ public: * Returns the most recent world state, including all * Returns the most recent world state, including all * items changed due to dragging operation. * items changed due to dragging operation. */ */ PNS_NODE* CurrentNode() const; PNS_NODE* CurrentNode() const; /** /** Loading @@ -100,7 +96,6 @@ public: virtual PNS_LOGGER* Logger(); virtual PNS_LOGGER* Logger(); private: private: typedef std::pair<PNS_LINE *, PNS_LINE *> LinePair; typedef std::pair<PNS_LINE *, PNS_LINE *> LinePair; typedef std::vector<LinePair> LinePairVec; typedef std::vector<LinePair> LinePairVec; Loading
pcbnew/router/pns_index.h +19 −23 Original line number Original line Diff line number Diff line Loading @@ -39,13 +39,12 @@ * are assigned to separate R-Tree subindices depending on their type and spanned layers, reducing * are assigned to separate R-Tree subindices depending on their type and spanned layers, reducing * overlap and improving search time. * overlap and improving search time. **/ **/ class PNS_INDEX class PNS_INDEX { { public: public: typedef std::list<PNS_ITEM*> NetItemsList; typedef std::list<PNS_ITEM*> NET_ITEMS_LIST; typedef SHAPE_INDEX<PNS_ITEM*> ItemShapeIndex; typedef SHAPE_INDEX<PNS_ITEM*> ITEM_SHAPE_INDEX; typedef boost::unordered_set<PNS_ITEM*> ItemSet; typedef boost::unordered_set<PNS_ITEM*> ITEM_SET; PNS_INDEX(); PNS_INDEX(); ~PNS_INDEX(); ~PNS_INDEX(); Loading Loading @@ -115,7 +114,7 @@ public: * * * Returns list of all items in a given net. * Returns list of all items in a given net. */ */ NetItemsList* GetItemsForNet( int aNet ); NET_ITEMS_LIST* GetItemsForNet( int aNet ); /** /** * Function Contains() * Function Contains() Loading @@ -134,8 +133,8 @@ public: */ */ int Size() const { return m_allItems.size(); } int Size() const { return m_allItems.size(); } ItemSet::iterator begin() { return m_allItems.begin(); } ITEM_SET::iterator begin() { return m_allItems.begin(); } ItemSet::iterator end() { return m_allItems.end(); } ITEM_SET::iterator end() { return m_allItems.end(); } private: private: static const int MaxSubIndices = 64; static const int MaxSubIndices = 64; Loading @@ -149,21 +148,20 @@ private: template <class Visitor> template <class Visitor> int querySingle( int index, const SHAPE* aShape, int aMinDistance, Visitor& aVisitor ); int querySingle( int index, const SHAPE* aShape, int aMinDistance, Visitor& aVisitor ); ItemShapeIndex* getSubindex( const PNS_ITEM* aItem ); ITEM_SHAPE_INDEX* getSubindex( const PNS_ITEM* aItem ); ItemShapeIndex* m_subIndices[MaxSubIndices]; ITEM_SHAPE_INDEX* m_subIndices[MaxSubIndices]; std::map<int, NetItemsList> m_netMap; std::map<int, NET_ITEMS_LIST> m_netMap; ItemSet m_allItems; ITEM_SET m_allItems; }; }; PNS_INDEX::PNS_INDEX() PNS_INDEX::PNS_INDEX() { { memset( m_subIndices, 0, sizeof( m_subIndices ) ); memset( m_subIndices, 0, sizeof( m_subIndices ) ); } } PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) PNS_INDEX::ITEM_SHAPE_INDEX* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) { { int idx_n = -1; int idx_n = -1; Loading Loading @@ -199,7 +197,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) assert( idx_n >= 0 && idx_n < MaxSubIndices ); assert( idx_n >= 0 && idx_n < MaxSubIndices ); if( !m_subIndices[idx_n] ) if( !m_subIndices[idx_n] ) m_subIndices[idx_n] = new ItemShapeIndex; m_subIndices[idx_n] = new ITEM_SHAPE_INDEX; return m_subIndices[idx_n]; return m_subIndices[idx_n]; } } Loading @@ -207,9 +205,7 @@ PNS_INDEX::ItemShapeIndex* PNS_INDEX::getSubindex( const PNS_ITEM* aItem ) void PNS_INDEX::Add( PNS_ITEM* aItem ) void PNS_INDEX::Add( PNS_ITEM* aItem ) { { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Add( aItem ); idx->Add( aItem ); m_allItems.insert( aItem ); m_allItems.insert( aItem ); Loading @@ -224,7 +220,7 @@ void PNS_INDEX::Add( PNS_ITEM* aItem ) void PNS_INDEX::Remove( PNS_ITEM* aItem ) void PNS_INDEX::Remove( PNS_ITEM* aItem ) { { ItemShapeIndex* idx = getSubindex( aItem ); ITEM_SHAPE_INDEX* idx = getSubindex( aItem ); idx->Remove( aItem ); idx->Remove( aItem ); m_allItems.erase( aItem ); m_allItems.erase( aItem ); Loading Loading @@ -303,7 +299,7 @@ void PNS_INDEX::Clear() { { for( int i = 0; i < MaxSubIndices; ++i ) for( int i = 0; i < MaxSubIndices; ++i ) { { ItemShapeIndex* idx = m_subIndices[i]; ITEM_SHAPE_INDEX* idx = m_subIndices[i]; if( idx ) if( idx ) delete idx; delete idx; Loading @@ -319,7 +315,7 @@ PNS_INDEX::~PNS_INDEX() } } PNS_INDEX::NetItemsList* PNS_INDEX::GetItemsForNet( int aNet ) PNS_INDEX::NET_ITEMS_LIST* PNS_INDEX::GetItemsForNet( int aNet ) { { if( m_netMap.find( aNet ) == m_netMap.end() ) if( m_netMap.find( aNet ) == m_netMap.end() ) return NULL; return NULL; Loading