2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 CERN
|
2016-08-29 14:38:11 +00:00
|
|
|
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-18 00:29:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <wx/numdlg.h>
|
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
#include <functional>
|
|
|
|
using namespace std::placeholders;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
#include "class_draw_panel_gal.h"
|
|
|
|
#include "class_board.h"
|
|
|
|
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2015-02-18 00:29:54 +00:00
|
|
|
#include <id.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <view/view_controls.h>
|
|
|
|
#include <pcb_painter.h>
|
|
|
|
#include <dialogs/dialog_pns_settings.h>
|
|
|
|
#include <dialogs/dialog_pns_diff_pair_dimensions.h>
|
|
|
|
#include <dialogs/dialog_pns_length_tuning_settings.h>
|
|
|
|
#include <dialogs/dialog_track_via_size.h>
|
|
|
|
#include <base_units.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2019-05-14 11:14:00 +00:00
|
|
|
#include <tool/action_menu.h>
|
2017-02-21 12:42:08 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2015-11-03 16:19:42 +00:00
|
|
|
#include <tools/grid_helper.h>
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
#include "pns_kicad_iface.h"
|
2015-02-18 00:29:54 +00:00
|
|
|
#include "pns_tool_base.h"
|
|
|
|
#include "pns_segment.h"
|
2016-08-15 15:16:51 +00:00
|
|
|
#include "pns_solid.h"
|
|
|
|
#include "pns_via.h"
|
2015-02-18 00:29:54 +00:00
|
|
|
#include "pns_router.h"
|
|
|
|
#include "pns_meander_placer.h" // fixme: move settings to separate header
|
|
|
|
#include "pns_tune_status_popup.h"
|
2016-08-15 15:16:47 +00:00
|
|
|
#include "pns_topology.h"
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
using namespace KIGFX;
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
TOOL_BASE::TOOL_BASE( const std::string& aToolName ) :
|
2019-05-12 11:49:58 +00:00
|
|
|
PCB_TOOL_BASE( aToolName )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-09-29 16:59:11 +00:00
|
|
|
m_gridHelper = nullptr;
|
|
|
|
m_iface = nullptr;
|
|
|
|
m_router = nullptr;
|
2016-08-17 13:09:48 +00:00
|
|
|
|
2016-09-29 16:59:11 +00:00
|
|
|
m_startItem = nullptr;
|
2015-03-10 14:38:27 +00:00
|
|
|
m_startLayer = 0;
|
2018-12-02 19:21:43 +00:00
|
|
|
m_startHighlight = false;
|
2015-03-10 14:38:27 +00:00
|
|
|
|
2016-09-29 16:59:11 +00:00
|
|
|
m_endItem = nullptr;
|
|
|
|
m_gridHelper = nullptr;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
TOOL_BASE::~TOOL_BASE()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-11-03 16:19:42 +00:00
|
|
|
delete m_gridHelper;
|
2016-08-17 13:09:48 +00:00
|
|
|
delete m_iface;
|
|
|
|
delete m_router;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-03 16:19:42 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void TOOL_BASE::Reset( RESET_REASON aReason )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-17 13:09:48 +00:00
|
|
|
delete m_gridHelper;
|
|
|
|
delete m_iface;
|
|
|
|
delete m_router;
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
m_iface = new PNS_KICAD_IFACE;
|
2017-08-03 15:53:07 +00:00
|
|
|
m_iface->SetBoard( board() );
|
2016-08-15 15:16:47 +00:00
|
|
|
m_iface->SetView( getView() );
|
2017-10-31 11:03:58 +00:00
|
|
|
m_iface->SetHostTool( this );
|
2019-11-07 14:23:09 +00:00
|
|
|
m_iface->SetDisplayOptions( &( frame()->GetDisplayOptions() ) );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
m_router = new ROUTER;
|
2017-08-03 15:53:07 +00:00
|
|
|
m_router->SetInterface( m_iface );
|
2015-02-18 00:29:54 +00:00
|
|
|
m_router->ClearWorld();
|
|
|
|
m_router->SyncWorld();
|
|
|
|
m_router->LoadSettings( m_savedSettings );
|
|
|
|
m_router->UpdateSizes( m_savedSizes );
|
2015-11-03 16:19:42 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
m_gridHelper = new GRID_HELPER( frame() );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2019-03-17 03:34:08 +00:00
|
|
|
ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, bool aIgnorePads,
|
|
|
|
const std::vector<ITEM*> aAvoidItems)
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
int tl = getView()->GetTopLayer();
|
|
|
|
|
|
|
|
if( aLayer > 0 )
|
|
|
|
tl = aLayer;
|
|
|
|
|
2018-04-08 20:20:51 +00:00
|
|
|
static const int candidateCount = 5;
|
|
|
|
ITEM* prioritized[candidateCount];
|
2018-05-03 16:31:00 +00:00
|
|
|
int dist[candidateCount];
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-04-08 20:20:51 +00:00
|
|
|
for( int i = 0; i < candidateCount; i++ )
|
2018-05-03 16:31:00 +00:00
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
prioritized[i] = 0;
|
2018-05-03 16:31:00 +00:00
|
|
|
dist[i] = std::numeric_limits<int>::max();
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( ITEM* item : candidates.Items() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2018-02-03 09:39:46 +00:00
|
|
|
if( !item->IsRoutable() )
|
|
|
|
continue;
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
if( !IsCopperLayer( item->Layers().Start() ) )
|
|
|
|
continue;
|
|
|
|
|
2019-08-15 07:21:48 +00:00
|
|
|
if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
|
|
|
|
continue;
|
|
|
|
|
2019-03-17 03:34:08 +00:00
|
|
|
if( std::find( aAvoidItems.begin(), aAvoidItems.end(), item ) != aAvoidItems.end() )
|
|
|
|
continue;
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
// fixme: this causes flicker with live loop removal...
|
|
|
|
//if( item->Parent() && !item->Parent()->ViewIsVisible() )
|
|
|
|
// continue;
|
|
|
|
|
2018-04-08 20:20:51 +00:00
|
|
|
if( aNet <= 0 || item->Net() == aNet )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2018-03-16 18:00:57 +00:00
|
|
|
if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
|
|
|
|
continue;
|
|
|
|
|
2018-05-03 16:31:00 +00:00
|
|
|
int itemDist = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
|
|
|
|
|
|
|
|
if( !prioritized[2] || itemDist < dist[2] )
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
prioritized[2] = item;
|
2018-05-03 16:31:00 +00:00
|
|
|
dist[2] = itemDist;
|
|
|
|
}
|
|
|
|
if( item->Layers().Overlaps( tl ) && itemDist < dist[0] )
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
prioritized[0] = item;
|
2018-05-03 16:31:00 +00:00
|
|
|
dist[0] = itemDist;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !prioritized[3] )
|
|
|
|
prioritized[3] = item;
|
|
|
|
if( item->Layers().Overlaps( tl ) )
|
|
|
|
prioritized[1] = item;
|
|
|
|
}
|
|
|
|
}
|
2018-04-08 20:20:51 +00:00
|
|
|
// Allow unconnected items as last resort in RM_MarkObstacles mode
|
|
|
|
else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
|
|
|
|
{
|
|
|
|
if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item->Layers().Overlaps( tl ) )
|
|
|
|
prioritized[4] = item;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM* rv = NULL;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-04-08 20:20:51 +00:00
|
|
|
for( int i = 0; i < candidateCount; i++ )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM* item = prioritized[i];
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2019-11-07 14:23:09 +00:00
|
|
|
if( displayOptions().m_ContrastModeDisplay )
|
2015-02-18 00:29:54 +00:00
|
|
|
if( item && !item->Layers().Overlaps( tl ) )
|
|
|
|
item = NULL;
|
|
|
|
|
2018-10-20 14:57:54 +00:00
|
|
|
if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
rv = item;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rv )
|
2016-08-17 14:00:21 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void TOOL_BASE::highlightNet( bool aEnabled, int aNetcode )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
RENDER_SETTINGS* rs = getView()->GetPainter()->GetSettings();
|
|
|
|
|
|
|
|
if( aNetcode >= 0 && aEnabled )
|
2018-12-02 19:21:43 +00:00
|
|
|
{
|
|
|
|
// If the user has previously set the current net to be highlighted,
|
|
|
|
// we assume they want to keep it highlighted after routing
|
|
|
|
m_startHighlight = ( rs->IsHighlightEnabled() && rs->GetHighlightNetCode() == aNetcode );
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
rs->SetHighlight( true, aNetcode );
|
2018-12-02 19:21:43 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
else
|
2018-12-02 19:21:43 +00:00
|
|
|
{
|
|
|
|
if( !m_startHighlight )
|
|
|
|
rs->SetHighlight( false );
|
|
|
|
|
|
|
|
m_startHighlight = false;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
getView()->UpdateAllLayersColor();
|
|
|
|
}
|
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
bool TOOL_BASE::checkSnap( ITEM *aItem )
|
|
|
|
{
|
2019-06-01 10:39:39 +00:00
|
|
|
// Sync PNS engine settings with the general PCB editor options.
|
2017-08-03 15:53:07 +00:00
|
|
|
auto& pnss = m_router->Settings();
|
|
|
|
|
2019-06-26 12:12:32 +00:00
|
|
|
pnss.SetSnapToPads( frame()->Settings().m_MagneticPads == CAPTURE_CURSOR_IN_TRACK_TOOL
|
|
|
|
|| frame()->Settings().m_MagneticPads == CAPTURE_ALWAYS );
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2019-06-26 12:12:32 +00:00
|
|
|
pnss.SetSnapToTracks( frame()->Settings().m_MagneticTracks == CAPTURE_CURSOR_IN_TRACK_TOOL
|
|
|
|
|| frame()->Settings().m_MagneticTracks == CAPTURE_ALWAYS );
|
2017-08-03 15:53:07 +00:00
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
2019-06-01 10:39:39 +00:00
|
|
|
if( aItem->OfKind( ITEM::VIA_T ) || aItem->OfKind( ITEM::SEGMENT_T ) )
|
|
|
|
return pnss.GetSnapToTracks();
|
|
|
|
else if( aItem->OfKind( ITEM::SOLID_T ) )
|
|
|
|
return pnss.GetSnapToPads();
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 10:39:39 +00:00
|
|
|
return false;
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2018-07-26 22:35:11 +00:00
|
|
|
void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
int tl = getView()->GetTopLayer();
|
2019-01-29 14:04:12 +00:00
|
|
|
VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
|
2015-08-04 09:37:16 +00:00
|
|
|
VECTOR2I p;
|
|
|
|
|
2017-08-16 12:11:07 +00:00
|
|
|
controls()->ForceCursorPosition( false );
|
2019-01-29 15:16:11 +00:00
|
|
|
m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
|
|
|
|
m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
|
2017-08-16 12:11:07 +00:00
|
|
|
|
2015-08-04 09:37:16 +00:00
|
|
|
bool snapEnabled = true;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
if( aEvent.IsMotion() || aEvent.IsClick() )
|
|
|
|
{
|
2015-08-04 09:37:16 +00:00
|
|
|
snapEnabled = !aEvent.Modifier( MD_SHIFT );
|
|
|
|
p = aEvent.Position();
|
2016-08-15 15:16:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-04 09:37:16 +00:00
|
|
|
p = cp;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-03-16 18:00:57 +00:00
|
|
|
m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-09-29 16:59:11 +00:00
|
|
|
if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
|
|
|
|
m_startItem = nullptr;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-09-29 16:59:11 +00:00
|
|
|
m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
|
2017-08-03 15:53:07 +00:00
|
|
|
|
2019-03-17 03:34:08 +00:00
|
|
|
if( checkSnap( m_startItem ) )
|
2017-08-16 12:11:07 +00:00
|
|
|
{
|
|
|
|
controls()->ForceCursorPosition( true, m_startSnapPoint );
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2017-01-18 08:04:11 +00:00
|
|
|
void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
int layer;
|
2015-07-02 14:10:07 +00:00
|
|
|
bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
|
2019-01-29 15:16:11 +00:00
|
|
|
m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
|
|
|
|
m_gridHelper->SetSnap( snapEnabled );
|
|
|
|
|
|
|
|
controls()->ForceCursorPosition( false );
|
|
|
|
VECTOR2I mousePos = controls()->GetMousePosition();
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-04-08 20:20:51 +00:00
|
|
|
if( m_router->Settings().Mode() != RM_MarkObstacles &&
|
|
|
|
( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2017-08-16 12:11:07 +00:00
|
|
|
m_endSnapPoint = snapToItem( snapEnabled, nullptr, mousePos );
|
2017-08-03 15:53:07 +00:00
|
|
|
controls()->ForceCursorPosition( true, m_endSnapPoint );
|
2016-09-29 16:59:11 +00:00
|
|
|
m_endItem = nullptr;
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_router->IsPlacingVia() )
|
|
|
|
layer = -1;
|
|
|
|
else
|
|
|
|
layer = m_router->GetCurrentLayer();
|
|
|
|
|
2016-09-29 16:59:11 +00:00
|
|
|
ITEM* endItem = nullptr;
|
2015-08-21 14:35:34 +00:00
|
|
|
|
|
|
|
std::vector<int> nets = m_router->GetCurrentNets();
|
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( int net : nets )
|
2015-08-21 14:35:34 +00:00
|
|
|
{
|
2019-03-17 03:34:08 +00:00
|
|
|
endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
|
2015-08-21 14:35:34 +00:00
|
|
|
|
|
|
|
if( endItem )
|
|
|
|
break;
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
if( checkSnap( endItem ) )
|
|
|
|
{
|
|
|
|
m_endItem = endItem;
|
2019-01-29 15:16:11 +00:00
|
|
|
m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
|
2017-08-03 15:53:07 +00:00
|
|
|
} else {
|
|
|
|
m_endItem = nullptr;
|
2019-01-29 15:16:11 +00:00
|
|
|
m_endSnapPoint = m_gridHelper->Align( mousePos );
|
2017-08-03 15:53:07 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2019-01-29 15:16:11 +00:00
|
|
|
controls()->ForceCursorPosition( true, m_endSnapPoint );
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
if( m_endItem )
|
2016-08-17 14:00:21 +00:00
|
|
|
{
|
|
|
|
wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void TOOL_BASE::deleteTraces( ITEM* aStartItem, bool aWholeTrack )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
NODE *node = m_router->GetWorld()->Branch();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
|
|
|
if( !aStartItem )
|
|
|
|
return;
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
if( !aWholeTrack )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
node->Remove( aStartItem );
|
2016-08-15 15:16:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
TOPOLOGY topo( node );
|
|
|
|
ITEM_SET path = topo.AssembleTrivialPath( aStartItem );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
for( auto ent : path.Items() )
|
2016-08-15 15:16:47 +00:00
|
|
|
node->Remove( ent.item );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_router->CommitRouting( node );
|
|
|
|
}
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
ROUTER *TOOL_BASE::Router() const
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
|
|
|
return m_router;
|
|
|
|
}
|
2016-08-15 15:16:51 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
|
2016-09-29 16:59:11 +00:00
|
|
|
const VECTOR2I TOOL_BASE::snapToItem( bool aEnabled, ITEM* aItem, VECTOR2I aP)
|
2016-08-15 15:16:51 +00:00
|
|
|
{
|
|
|
|
VECTOR2I anchor;
|
|
|
|
|
2019-10-10 13:33:21 +00:00
|
|
|
if( !aItem || !aEnabled || !m_iface->IsItemVisible( aItem ) )
|
2016-08-15 15:16:51 +00:00
|
|
|
{
|
2016-09-29 16:59:11 +00:00
|
|
|
return m_gridHelper->Align( aP );
|
2016-08-15 15:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch( aItem->Kind() )
|
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
case ITEM::SOLID_T:
|
|
|
|
anchor = static_cast<SOLID*>( aItem )->Pos();
|
2016-08-15 15:16:51 +00:00
|
|
|
break;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
case ITEM::VIA_T:
|
|
|
|
anchor = static_cast<VIA*>( aItem )->Pos();
|
2016-08-15 15:16:51 +00:00
|
|
|
break;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
case ITEM::SEGMENT_T:
|
2016-08-15 15:16:51 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
SEGMENT* seg = static_cast<SEGMENT*>( aItem );
|
2016-08-15 15:16:51 +00:00
|
|
|
const SEG& s = seg->Seg();
|
|
|
|
int w = seg->Width();
|
|
|
|
|
|
|
|
|
|
|
|
if( ( aP - s.A ).EuclideanNorm() < w / 2 )
|
|
|
|
anchor = s.A;
|
|
|
|
else if( ( aP - s.B ).EuclideanNorm() < w / 2 )
|
|
|
|
anchor = s.B;
|
|
|
|
else
|
2016-08-15 15:16:53 +00:00
|
|
|
anchor = m_gridHelper->AlignToSegment( aP, s );
|
2016-08-15 15:16:51 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return anchor;
|
|
|
|
}
|
2016-08-29 14:38:11 +00:00
|
|
|
|
|
|
|
}
|