void SwitchNode::clearNodes() { while (nodes->size() > 0) { removeNode( nodes->size() - 1 ); } setDefaultNode( NULL ); clearAnchors(); clearPorts(); }
VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, BOARD_ITEM* aDraggedItem ) { double worldScale = m_frame->GetGalCanvas()->GetGAL()->GetWorldScale(); int snapRange = (int) ( 100.0 / worldScale ); BOX2I bb( VECTOR2I( aOrigin.x - snapRange / 2, aOrigin.y - snapRange / 2 ), VECTOR2I( snapRange, snapRange ) ); clearAnchors(); BOOST_FOREACH( BOARD_ITEM* item, queryVisible( bb ) ) { computeAnchors( item, aOrigin ); }
VECTOR2I GRID_HELPER::BestDragOrigin( const VECTOR2I &aMousePos, BOARD_ITEM* aItem ) { clearAnchors(); computeAnchors( aItem, aMousePos ); double worldScale = m_frame->GetGalCanvas()->GetGAL()->GetWorldScale(); double lineSnapMinCornerDistance = 50.0 / worldScale; ANCHOR* nearestOutline = nearestAnchor( aMousePos, OUTLINE, LSET::AllLayersMask() ); ANCHOR* nearestCorner = nearestAnchor( aMousePos, CORNER, LSET::AllLayersMask() ); ANCHOR* nearestOrigin = nearestAnchor( aMousePos, ORIGIN, LSET::AllLayersMask() ); ANCHOR* best = NULL; double minDist = std::numeric_limits<double>::max(); if( nearestOrigin ) { minDist = nearestOrigin->Distance( aMousePos ); best = nearestOrigin; } if( nearestCorner ) { double dist = nearestCorner->Distance( aMousePos ); if( dist < minDist ) { minDist = dist; best = nearestCorner; } } if( nearestOutline ) { double dist = nearestOutline->Distance( aMousePos ); if( minDist > lineSnapMinCornerDistance && dist < minDist ) best = nearestOutline; } return best ? best->pos : aMousePos; }