2013-09-18 17:55:16 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 CERN
|
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* 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.
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* 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.
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
2014-05-14 13:53:54 +00:00
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2013-09-18 17:55:16 +00:00
|
|
|
*/
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
#include <wx/numdlg.h>
|
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
#include <boost/optional.hpp>
|
2014-05-14 13:53:54 +00:00
|
|
|
#include <boost/bind.hpp>
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-04-04 09:56:04 +00:00
|
|
|
#include "class_draw_panel_gal.h"
|
2013-09-18 17:55:16 +00:00
|
|
|
#include "class_board.h"
|
|
|
|
|
|
|
|
#include <wxPcbStruct.h>
|
2014-02-19 12:51:32 +00:00
|
|
|
#include <id.h>
|
2014-05-14 13:53:54 +00:00
|
|
|
#include <macros.h>
|
2014-04-04 09:50:15 +00:00
|
|
|
#include <pcbnew_id.h>
|
2013-09-18 17:55:16 +00:00
|
|
|
#include <view/view_controls.h>
|
|
|
|
#include <pcbcommon.h>
|
|
|
|
#include <pcb_painter.h>
|
2014-05-14 13:53:54 +00:00
|
|
|
#include <dialogs/dialog_pns_settings.h>
|
|
|
|
#include <dialogs/dialog_track_via_size.h>
|
|
|
|
#include <base_units.h>
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
#include <tool/context_menu.h>
|
2014-02-17 17:21:00 +00:00
|
|
|
#include <tools/common_actions.h>
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-01-31 17:05:11 +00:00
|
|
|
#include <ratsnest_data.h>
|
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
#include "router_tool.h"
|
|
|
|
#include "pns_segment.h"
|
|
|
|
#include "pns_router.h"
|
|
|
|
#include "trace.h"
|
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
using namespace KIGFX;
|
2013-09-18 17:55:16 +00:00
|
|
|
using boost::optional;
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
static TOOL_ACTION ACT_NewTrack( "pcbnew.InteractiveRouter.NewTrack",
|
|
|
|
AS_CONTEXT, 'X',
|
|
|
|
"New Track", "Starts laying a new track.");
|
|
|
|
static TOOL_ACTION ACT_EndTrack( "pcbnew.InteractiveRouter.EndTrack",
|
|
|
|
AS_CONTEXT, WXK_END,
|
|
|
|
"End Track", "Stops laying the current track.");
|
|
|
|
static TOOL_ACTION ACT_AutoEndRoute( "pcbnew.InteractiveRouter.AutoEndRoute",
|
|
|
|
AS_CONTEXT, 'F',
|
|
|
|
"Auto-end Track", "Automagically finishes currently routed track." );
|
|
|
|
static TOOL_ACTION ACT_Drag( "pcbnew.InteractiveRouter.Drag",
|
|
|
|
AS_CONTEXT, 'G',
|
|
|
|
"Drag Track/Via", "Drags a track or a via." );
|
|
|
|
static TOOL_ACTION ACT_PlaceThroughVia( "pcbnew.InteractiveRouter.PlaceVia",
|
|
|
|
AS_CONTEXT, 'V',
|
|
|
|
"Place Through Via", "Adds a through-hole via at the end of currently routed track." );
|
|
|
|
static TOOL_ACTION ACT_CustomTrackWidth( "pcbnew.InteractiveRouter.CustomTrackWidth",
|
|
|
|
AS_CONTEXT, 'W',
|
|
|
|
"Custom Track Width", "Shows a dialog for changing the track width and via size.");
|
|
|
|
static TOOL_ACTION ACT_RouterOptions( "pcbnew.InteractiveRouter.RouterOptions",
|
|
|
|
AS_CONTEXT, 'E',
|
|
|
|
"Routing Options...", "Shows a dialog containing router options.");
|
|
|
|
static TOOL_ACTION ACT_SwitchPosture( "pcbnew.InteractiveRouter.SwitchPosture",
|
|
|
|
AS_CONTEXT, '/',
|
|
|
|
"Switch Track Posture", "Switches posture of the currenly routed track.");
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
ROUTER_TOOL::ROUTER_TOOL() :
|
2013-09-26 21:53:54 +00:00
|
|
|
TOOL_INTERACTIVE( "pcbnew.InteractiveRouter" )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
m_router = NULL;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
class CONTEXT_TRACK_WIDTH_MENU: public CONTEXT_MENU
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CONTEXT_TRACK_WIDTH_MENU()
|
|
|
|
{
|
2014-05-16 11:37:31 +00:00
|
|
|
setCustomEventHandler( boost::bind( &CONTEXT_TRACK_WIDTH_MENU::handleCustomEvent,
|
|
|
|
this, _1 ) );
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2013-10-11 12:26:09 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetBoard( BOARD* aBoard )
|
|
|
|
{
|
2014-05-16 11:37:31 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
m_board = aBoard;
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
Append( ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, _( "Custom size" ),
|
|
|
|
wxEmptyString, wxITEM_CHECK );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH, _( "Use the starting track width" ),
|
2014-05-16 11:37:31 +00:00
|
|
|
_( "Route using the width of the starting track." ), wxITEM_CHECK );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, _( "Use netclass values" ),
|
|
|
|
_( "Use track and via sizes from the net class" ), wxITEM_CHECK );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
for( unsigned i = 0; i < bds.m_TrackWidthList.size(); i++ )
|
|
|
|
{
|
2014-05-16 11:37:31 +00:00
|
|
|
msg = _( "Track ");
|
2014-05-14 13:53:54 +00:00
|
|
|
msg << StringFromValue( g_UserUnit, bds.m_TrackWidthList[i], true );
|
|
|
|
|
|
|
|
if( i == 0 )
|
|
|
|
msg << _( " (from netclass)" );
|
|
|
|
|
|
|
|
Append( ID_POPUP_PCB_SELECT_WIDTH1 + i, msg, wxEmptyString, wxITEM_CHECK );
|
|
|
|
}
|
|
|
|
|
|
|
|
AppendSeparator();
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < bds.m_ViasDimensionsList.size(); i++ )
|
|
|
|
{
|
2014-05-16 11:37:31 +00:00
|
|
|
msg = _("Via ");
|
|
|
|
msg << StringFromValue( g_UserUnit, bds.m_ViasDimensionsList[i].m_Diameter, true );
|
2014-05-14 13:53:54 +00:00
|
|
|
wxString drill = StringFromValue( g_UserUnit,
|
2014-05-16 11:37:31 +00:00
|
|
|
bds.m_ViasDimensionsList[i].m_Drill,
|
|
|
|
true );
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
if( bds.m_ViasDimensionsList[i].m_Drill <= 0 )
|
|
|
|
{
|
|
|
|
msg << _ (", drill: default");
|
2014-05-16 11:37:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
msg << _ (", drill: ") << drill;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( i == 0 )
|
|
|
|
msg << _( " (from netclass)" );
|
|
|
|
|
|
|
|
Append( ID_POPUP_PCB_SELECT_VIASIZE1 + i, msg, wxEmptyString, wxITEM_CHECK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
OPT_TOOL_EVENT handleCustomEvent( const wxEvent& aEvent )
|
|
|
|
{
|
|
|
|
#if ID_POPUP_PCB_SELECT_VIASIZE1 < ID_POPUP_PCB_SELECT_WIDTH1
|
2014-05-16 11:37:31 +00:00
|
|
|
#error You have changed event ids order, it breaks code. Check the source code for more details.
|
2014-05-14 13:53:54 +00:00
|
|
|
// Recognising type of event (track width/via size) is based on comparison if the event id is
|
|
|
|
// within a specific range. If ranges of event ids changes, then the following is not valid anymore.
|
|
|
|
#endif
|
|
|
|
BOARD_DESIGN_SETTINGS &bds = m_board->GetDesignSettings();
|
|
|
|
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
// Initial settings, to be modified below
|
2014-05-14 13:53:54 +00:00
|
|
|
bds.m_UseConnectedTrackWidth = false;
|
|
|
|
bds.UseCustomTrackViaSize( false );
|
|
|
|
|
|
|
|
if( id == ID_POPUP_PCB_SELECT_CUSTOM_WIDTH )
|
|
|
|
{
|
|
|
|
bds.UseCustomTrackViaSize( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( id == ID_POPUP_PCB_SELECT_AUTO_WIDTH )
|
|
|
|
{
|
|
|
|
bds.m_UseConnectedTrackWidth = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( id == ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES )
|
|
|
|
{
|
|
|
|
bds.SetViaSizeIndex( 0 );
|
|
|
|
bds.SetTrackWidthIndex( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
else if( id > ID_POPUP_PCB_SELECT_VIASIZE1 ) // via size has changed
|
|
|
|
{
|
|
|
|
assert( id < ID_POPUP_PCB_SELECT_WIDTH_END_RANGE );
|
|
|
|
|
|
|
|
bds.SetViaSizeIndex( id - ID_POPUP_PCB_SELECT_VIASIZE1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
else // track width has changed
|
|
|
|
{
|
|
|
|
assert( id >= ID_POPUP_PCB_SELECT_WIDTH1 );
|
|
|
|
assert( id < ID_POPUP_PCB_SELECT_VIASIZE );
|
|
|
|
|
|
|
|
bds.SetTrackWidthIndex( id - ID_POPUP_PCB_SELECT_WIDTH1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPT_TOOL_EVENT( COMMON_ACTIONS::trackViaSizeChanged.MakeEvent() );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOARD* m_board;
|
|
|
|
};
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
class ROUTER_TOOL_MENU: public CONTEXT_MENU
|
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
public:
|
2014-05-16 11:37:31 +00:00
|
|
|
ROUTER_TOOL_MENU( BOARD* aBoard )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
SetTitle( wxT( "Interactive Router" ) );
|
|
|
|
Add( ACT_NewTrack );
|
|
|
|
Add( ACT_EndTrack );
|
|
|
|
// Add( ACT_AutoEndRoute ); // fixme: not implemented yet. Sorry.
|
|
|
|
Add( ACT_Drag );
|
|
|
|
Add( ACT_PlaceThroughVia );
|
|
|
|
Add( ACT_SwitchPosture );
|
|
|
|
|
|
|
|
AppendSeparator ( );
|
|
|
|
|
|
|
|
CONTEXT_TRACK_WIDTH_MENU* trackMenu = new CONTEXT_TRACK_WIDTH_MENU;
|
|
|
|
trackMenu->SetBoard( aBoard );
|
|
|
|
AppendSubMenu( trackMenu, wxT( "Select Track Width" ) );
|
|
|
|
|
|
|
|
Add( ACT_CustomTrackWidth );
|
|
|
|
|
|
|
|
AppendSeparator ( );
|
|
|
|
Add( ACT_RouterOptions );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
ROUTER_TOOL::~ROUTER_TOOL()
|
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
delete m_router;
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-09 09:42:38 +00:00
|
|
|
void ROUTER_TOOL::Reset( RESET_REASON aReason )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
if( m_router )
|
2013-09-18 17:55:16 +00:00
|
|
|
delete m_router;
|
|
|
|
|
|
|
|
m_router = new PNS_ROUTER;
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
TRACEn( 0, "Reset" );
|
2013-09-18 17:55:16 +00:00
|
|
|
m_router->ClearWorld();
|
2013-09-26 21:53:54 +00:00
|
|
|
m_router->SetBoard( getModel<BOARD>( PCB_T ) );
|
2013-09-18 17:55:16 +00:00
|
|
|
m_router->SyncWorld();
|
2014-05-14 14:53:49 +00:00
|
|
|
m_router->LoadSettings( m_settings );
|
2014-01-31 15:08:20 +00:00
|
|
|
m_needsSync = false;
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
if( getView() )
|
2013-09-18 17:55:16 +00:00
|
|
|
m_router->SetView( getView() );
|
|
|
|
|
2014-02-17 17:21:00 +00:00
|
|
|
Go( &ROUTER_TOOL::Main, COMMON_ACTIONS::routerActivate.MakeEvent() );
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
int ROUTER_TOOL::getDefaultWidth( int aNetCode )
|
|
|
|
{
|
|
|
|
int w, d1, d2;
|
2013-09-26 21:53:54 +00:00
|
|
|
|
|
|
|
getNetclassDimensions( aNetCode, w, d1, d2 );
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2013-10-14 11:43:57 +00:00
|
|
|
void ROUTER_TOOL::getNetclassDimensions( int aNetCode, int& aWidth,
|
2014-05-31 14:04:25 +00:00
|
|
|
int& aViaDiameter, int& aViaDrill )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
BOARD* board = getModel<BOARD>( PCB_T );
|
2014-05-14 13:53:54 +00:00
|
|
|
BOARD_DESIGN_SETTINGS &bds = board->GetDesignSettings();
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-20 09:29:37 +00:00
|
|
|
NETCLASSPTR netClass;
|
2013-09-26 21:53:54 +00:00
|
|
|
NETINFO_ITEM* ni = board->FindNet( aNetCode );
|
|
|
|
|
|
|
|
if( ni )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
|
|
|
wxString netClassName = ni->GetClassName();
|
2014-05-14 13:53:54 +00:00
|
|
|
netClass = bds.m_NetClasses.Find( netClassName );
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !netClass )
|
2014-05-15 08:51:08 +00:00
|
|
|
netClass = bds.GetDefault();
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
aWidth = netClass->GetTrackWidth();
|
|
|
|
aViaDiameter = netClass->GetViaDiameter();
|
|
|
|
aViaDrill = netClass->GetViaDrill();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
PNS_ITEM* ROUTER_TOOL::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
|
|
|
int tl = getView()->GetTopLayer();
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
if( aLayer > 0 )
|
2013-09-18 17:55:16 +00:00
|
|
|
tl = aLayer;
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
PNS_ITEM* prioritized[4];
|
|
|
|
|
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
prioritized[i] = 0;
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
PNS_ITEMSET candidates = m_router->QueryHoverItems( aWhere );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
BOOST_FOREACH( PNS_ITEM* item, candidates.Items() )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
if( !IsCopperLayer( item->Layers().Start() ) )
|
2013-09-18 17:55:16 +00:00
|
|
|
continue;
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
// fixme: this causes flicker with live loop removal...
|
|
|
|
//if( item->Parent() && !item->Parent()->ViewIsVisible() )
|
|
|
|
// continue;
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
if( aNet < 0 || item->Net() == aNet )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
if( item->OfKind( PNS_ITEM::VIA | PNS_ITEM::SOLID ) )
|
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
if( !prioritized[2] )
|
|
|
|
prioritized[2] = item;
|
2014-05-16 11:37:31 +00:00
|
|
|
if( item->Layers().Overlaps( tl ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
prioritized[0] = item;
|
2013-09-26 21:53:54 +00:00
|
|
|
}
|
|
|
|
else
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2014-05-16 11:37:31 +00:00
|
|
|
if( !prioritized[3] )
|
2014-05-14 13:53:54 +00:00
|
|
|
prioritized[3] = item;
|
2014-05-16 11:37:31 +00:00
|
|
|
if( item->Layers().Overlaps( tl ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
prioritized[1] = item;
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
PNS_ITEM* rv = NULL;
|
|
|
|
for( int i = 0; i < 4; i++ )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2014-05-16 11:37:31 +00:00
|
|
|
PNS_ITEM* item = prioritized[i];
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
if( item && !item->Layers().Overlaps( tl ) )
|
|
|
|
item = NULL;
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
if( item )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
rv = item;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
if( rv && aLayer >= 0 && !rv->Layers().Overlaps( aLayer ) )
|
2013-09-18 17:55:16 +00:00
|
|
|
rv = NULL;
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
if( rv )
|
2014-05-16 11:37:31 +00:00
|
|
|
TRACE( 0, "%s, layer : %d, tl: %d", rv->KindStr().c_str() % rv->Layers().Start() % tl );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
void ROUTER_TOOL::highlightNet( bool aEnabled, int aNetcode )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
RENDER_SETTINGS* rs = getView()->GetPainter()->GetSettings();
|
|
|
|
|
|
|
|
if( aNetcode >= 0 && aEnabled )
|
|
|
|
rs->SetHighlight( true, aNetcode );
|
|
|
|
else
|
|
|
|
rs->SetHighlight( false );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
getView()->UpdateAllLayersColor();
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
|
|
|
void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2014-05-16 11:37:31 +00:00
|
|
|
if( aEvent.IsKeyPressed() )
|
|
|
|
{
|
|
|
|
switch( aEvent.KeyCode() )
|
|
|
|
{
|
|
|
|
case 'S':
|
|
|
|
TRACEn( 2, "saving drag/route log...\n" );
|
|
|
|
m_router->DumpLog();
|
|
|
|
break;
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
else
|
|
|
|
#endif
|
2014-05-16 11:37:31 +00:00
|
|
|
if( aEvent.IsAction( &ACT_RouterOptions ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
DIALOG_PNS_SETTINGS settingsDlg( m_toolMgr->GetEditFrame(), m_router->Settings() );
|
|
|
|
|
|
|
|
if( settingsDlg.ShowModal() )
|
|
|
|
m_router->ApplySettings();
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
else if( aEvent.IsAction( &ACT_CustomTrackWidth ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
DIALOG_TRACK_VIA_SIZE sizeDlg( m_toolMgr->GetEditFrame(), m_router->Settings() );
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>( PCB_T )->GetDesignSettings();
|
|
|
|
|
|
|
|
sizeDlg.ShowModal();
|
|
|
|
|
|
|
|
// TODO it should be changed, router settings won't keep track & via sizes in the future
|
|
|
|
bds.SetCustomTrackWidth( m_router->Settings().GetTrackWidth() );
|
|
|
|
bds.SetCustomViaSize( m_router->Settings().GetViaDiameter() );
|
|
|
|
bds.SetCustomViaDrill( m_router->Settings().GetViaDrill() );
|
|
|
|
bds.UseCustomTrackViaSize( true );
|
|
|
|
|
|
|
|
// TODO Should be done another way, but RunAction() won't work here. As the ROUTER_TOOL
|
|
|
|
// did not call Wait(), it does not wait for events and therefore the sent event
|
|
|
|
// won't arrive here
|
|
|
|
TOOL_EVENT event = COMMON_ACTIONS::trackViaSizeChanged.MakeEvent();
|
|
|
|
handleCommonEvents( event );
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
else if( aEvent.IsAction( &COMMON_ACTIONS::trackViaSizeChanged ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>( PCB_T )->GetDesignSettings();
|
|
|
|
|
|
|
|
m_router->Settings().SetTrackWidth( bds.GetCurrentTrackWidth() );
|
|
|
|
m_router->Settings().SetViaDiameter( bds.GetCurrentViaSize() );
|
|
|
|
m_router->Settings().SetViaDrill( bds.GetCurrentViaDrill() );
|
|
|
|
m_router->ApplySettings();
|
|
|
|
}
|
|
|
|
}
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent )
|
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
VIEW_CONTROLS* ctls = getViewControls();
|
2013-09-18 17:55:16 +00:00
|
|
|
int tl = getView()->GetTopLayer();
|
2014-05-14 13:53:54 +00:00
|
|
|
VECTOR2I cp = ctls->GetCursorPosition();
|
2013-09-26 21:53:54 +00:00
|
|
|
PNS_ITEM* startItem = NULL;
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
if( aEvent.IsMotion() || aEvent.IsClick() )
|
|
|
|
{
|
|
|
|
VECTOR2I p = aEvent.Position();
|
2013-09-26 21:53:54 +00:00
|
|
|
startItem = pickSingleItem( p );
|
2014-05-14 13:53:54 +00:00
|
|
|
bool snapEnabled = !aEvent.Modifier(MD_SHIFT);
|
|
|
|
m_router->EnableSnapping ( snapEnabled );
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
if( !snapEnabled && startItem && !startItem->Layers().Overlaps( tl ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
startItem = NULL;
|
|
|
|
|
|
|
|
if( startItem && startItem->Net() >= 0 )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
|
|
|
bool dummy;
|
2014-05-14 13:53:54 +00:00
|
|
|
VECTOR2I psnap = m_router->SnapToItem( startItem, p, dummy );
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
if( snapEnabled )
|
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
m_startSnapPoint = psnap;
|
|
|
|
ctls->ForceCursorPosition( true, psnap );
|
2014-05-16 11:37:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
m_startSnapPoint = cp;
|
|
|
|
ctls->ForceCursorPosition( false );
|
|
|
|
}
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
if( startItem->Layers().IsMultilayer() )
|
2013-09-18 17:55:16 +00:00
|
|
|
m_startLayer = tl;
|
|
|
|
else
|
2014-05-14 13:53:54 +00:00
|
|
|
m_startLayer = startItem->Layers().Start();
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
m_startItem = startItem;
|
2013-09-26 21:53:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-18 17:55:16 +00:00
|
|
|
m_startItem = NULL;
|
2014-05-14 13:53:54 +00:00
|
|
|
m_startSnapPoint = cp;
|
2013-09-18 17:55:16 +00:00
|
|
|
m_startLayer = tl;
|
2013-09-26 21:53:54 +00:00
|
|
|
ctls->ForceCursorPosition( false );
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent )
|
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
VIEW_CONTROLS* ctls = getViewControls();
|
2014-05-14 13:53:54 +00:00
|
|
|
VECTOR2I p = getView()->ToWorld( ctls->GetMousePosition() );
|
|
|
|
VECTOR2I cp = ctls->GetCursorPosition();
|
2013-09-18 17:55:16 +00:00
|
|
|
int layer;
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
bool snapEnabled = !aEvent.Modifier(MD_SHIFT);
|
|
|
|
|
|
|
|
m_router->EnableSnapping ( snapEnabled );
|
|
|
|
|
|
|
|
if( !snapEnabled || m_router->GetCurrentNet() < 0 || !m_startItem )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
|
|
|
m_endItem = NULL;
|
2014-05-14 13:53:54 +00:00
|
|
|
m_endSnapPoint = cp;
|
2013-09-18 17:55:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool dummy;
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
if( m_router->IsPlacingVia() )
|
2013-09-18 17:55:16 +00:00
|
|
|
layer = -1;
|
2013-09-26 21:53:54 +00:00
|
|
|
else
|
2013-09-18 17:55:16 +00:00
|
|
|
layer = m_router->GetCurrentLayer();
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
PNS_ITEM* endItem = pickSingleItem( p, m_startItem->Net(), layer );
|
2013-09-26 21:53:54 +00:00
|
|
|
|
|
|
|
if( endItem )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
VECTOR2I cursorPos = m_router->SnapToItem( endItem, p, dummy );
|
|
|
|
ctls->ForceCursorPosition( true, cursorPos );
|
2013-09-18 17:55:16 +00:00
|
|
|
m_endItem = endItem;
|
|
|
|
m_endSnapPoint = cursorPos;
|
2013-09-26 21:53:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-18 17:55:16 +00:00
|
|
|
m_endItem = NULL;
|
2014-05-14 13:53:54 +00:00
|
|
|
m_endSnapPoint = cp;
|
2013-09-26 21:53:54 +00:00
|
|
|
ctls->ForceCursorPosition( false );
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
2013-09-26 21:53:54 +00:00
|
|
|
|
|
|
|
if( m_endItem )
|
2014-05-16 11:37:31 +00:00
|
|
|
TRACE( 0, "%s, layer : %d", m_endItem->KindStr().c_str() % m_endItem->Layers().Start() );
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
void ROUTER_TOOL::performRouting()
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
|
2014-01-30 16:11:40 +00:00
|
|
|
bool saveUndoBuffer = true;
|
2013-09-26 21:53:54 +00:00
|
|
|
VIEW_CONTROLS* ctls = getViewControls();
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
if( getModel<BOARD>( PCB_T )->GetDesignSettings().m_UseConnectedTrackWidth )
|
|
|
|
{
|
|
|
|
int width = getDefaultWidth( m_startItem ? m_startItem->Net() : -1 );
|
|
|
|
|
|
|
|
if( m_startItem && m_startItem->OfKind( PNS_ITEM::SEGMENT ) )
|
|
|
|
width = static_cast<PNS_SEGMENT*>( m_startItem )->Width();
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
m_router->Settings().SetTrackWidth( width );
|
|
|
|
}
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
m_router->SwitchLayer( m_startLayer );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
frame->SetActiveLayer( m_startLayer );
|
|
|
|
frame->GetGalCanvas()->SetFocus();
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
if( m_startItem && m_startItem->Net() >= 0 )
|
|
|
|
highlightNet( true, m_startItem->Net() );
|
2013-09-26 21:53:54 +00:00
|
|
|
|
|
|
|
ctls->ForceCursorPosition( false );
|
|
|
|
ctls->SetAutoPan( true );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
m_router->StartRouting( m_startSnapPoint, m_startItem );
|
|
|
|
|
|
|
|
m_endItem = NULL;
|
|
|
|
m_endSnapPoint = m_startSnapPoint;
|
|
|
|
|
|
|
|
while( OPT_TOOL_EVENT evt = Wait() )
|
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
if( evt->IsCancel() )
|
|
|
|
break;
|
2014-01-30 16:11:40 +00:00
|
|
|
else if( evt->Action() == TA_UNDO_REDO )
|
|
|
|
{
|
|
|
|
saveUndoBuffer = false;
|
|
|
|
break;
|
|
|
|
}
|
2013-09-26 21:53:54 +00:00
|
|
|
else if( evt->IsMotion() )
|
|
|
|
{
|
2013-09-18 17:55:16 +00:00
|
|
|
updateEndItem( *evt );
|
2013-09-26 21:53:54 +00:00
|
|
|
m_router->Move( m_endSnapPoint, m_endItem );
|
|
|
|
}
|
2013-10-15 08:41:00 +00:00
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
2013-09-26 21:53:54 +00:00
|
|
|
{
|
2013-09-18 17:55:16 +00:00
|
|
|
updateEndItem( *evt );
|
2013-09-26 21:53:54 +00:00
|
|
|
|
|
|
|
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
|
2013-09-18 17:55:16 +00:00
|
|
|
break;
|
2013-09-26 21:53:54 +00:00
|
|
|
|
|
|
|
m_router->Move( m_endSnapPoint, m_endItem );
|
2014-05-16 11:37:31 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsAction( &ACT_PlaceThroughVia ) )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
m_router->ToggleViaPlacement();
|
|
|
|
frame->SetTopLayer( m_router->GetCurrentLayer() );
|
|
|
|
m_router->Move( m_endSnapPoint, m_endItem );
|
2013-09-26 21:53:54 +00:00
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
else if( evt->IsAction( &ACT_SwitchPosture ) )
|
2013-09-26 21:53:54 +00:00
|
|
|
{
|
2014-05-14 13:53:54 +00:00
|
|
|
m_router->FlipPosture();
|
|
|
|
m_router->Move( m_endSnapPoint, m_endItem );
|
|
|
|
}
|
|
|
|
else if( evt->IsAction( &COMMON_ACTIONS::layerNext ) )
|
|
|
|
{
|
|
|
|
m_router->SwitchLayer( m_router->NextCopperLayer( true ) );
|
|
|
|
updateEndItem( *evt );
|
|
|
|
frame->SetActiveLayer( m_router->GetCurrentLayer() );
|
|
|
|
m_router->Move( m_endSnapPoint, m_endItem );
|
|
|
|
}
|
|
|
|
else if( evt->IsAction( &COMMON_ACTIONS::layerPrev ) )
|
|
|
|
{
|
|
|
|
m_router->SwitchLayer( m_router->NextCopperLayer( false ) );
|
|
|
|
frame->SetActiveLayer( m_router->GetCurrentLayer() );
|
|
|
|
m_router->Move( m_endSnapPoint, m_endItem );
|
|
|
|
}
|
|
|
|
else if( evt->IsAction( &ACT_EndTrack ) )
|
|
|
|
{
|
|
|
|
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
|
2013-09-26 21:53:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
handleCommonEvents(*evt);
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
|
2014-01-07 13:22:37 +00:00
|
|
|
m_router->StopRouting();
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-01-30 16:11:40 +00:00
|
|
|
if( saveUndoBuffer )
|
|
|
|
{
|
|
|
|
// Save the recent changes in the undo buffer
|
2014-05-14 13:53:54 +00:00
|
|
|
frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED );
|
|
|
|
m_router->ClearUndoBuffer();
|
|
|
|
frame->OnModify();
|
2014-01-30 16:11:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// It was interrupted by TA_UNDO_REDO event, so we have to sync the world now
|
2014-01-31 15:08:20 +00:00
|
|
|
m_needsSync = true;
|
2014-01-30 16:11:40 +00:00
|
|
|
}
|
2014-01-30 10:32:08 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
ctls->SetAutoPan( false );
|
|
|
|
ctls->ForceCursorPosition( false );
|
|
|
|
highlightNet( false );
|
2013-09-18 17:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
|
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
VIEW_CONTROLS* ctls = getViewControls();
|
2014-05-14 13:53:54 +00:00
|
|
|
BOARD* board = getModel<BOARD>( PCB_T );
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-05-14 17:15:25 +00:00
|
|
|
// Deselect all items
|
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear );
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL,
|
|
|
|
_( "Interactive Router" ) );
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
ctls->SetSnapping( true );
|
2013-09-18 17:55:16 +00:00
|
|
|
ctls->ShowCursor( true );
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
// Set current track widths & via size
|
|
|
|
m_router->Settings().SetTrackWidth( bds.GetCurrentTrackWidth() );
|
|
|
|
m_router->Settings().SetViaDiameter( bds.GetCurrentViaSize() );
|
|
|
|
m_router->Settings().SetViaDrill( bds.GetCurrentViaDrill() );
|
|
|
|
|
|
|
|
ROUTER_TOOL_MENU *ctxMenu = new ROUTER_TOOL_MENU( board );
|
|
|
|
|
|
|
|
SetContextMenu ( ctxMenu );
|
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
// Main loop: keep receiving events
|
|
|
|
while( OPT_TOOL_EVENT evt = Wait() )
|
|
|
|
{
|
2014-01-31 15:08:20 +00:00
|
|
|
if( m_needsSync )
|
|
|
|
{
|
|
|
|
m_router->SyncWorld();
|
2014-06-01 16:44:38 +00:00
|
|
|
m_router->SetView( getView() );
|
2014-01-31 15:08:20 +00:00
|
|
|
m_needsSync = false;
|
|
|
|
}
|
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
if( evt->IsCancel() )
|
2013-09-26 21:53:54 +00:00
|
|
|
break; // Finish
|
2014-01-30 10:32:08 +00:00
|
|
|
else if( evt->Action() == TA_UNDO_REDO )
|
2014-01-31 15:08:20 +00:00
|
|
|
m_needsSync = true;
|
2013-09-26 21:53:54 +00:00
|
|
|
else if( evt->IsMotion() )
|
2013-09-18 17:55:16 +00:00
|
|
|
updateStartItem( *evt );
|
2014-05-14 13:53:54 +00:00
|
|
|
else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) )
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
|
|
|
updateStartItem( *evt );
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
if( evt->Modifier( MD_CTRL ) )
|
|
|
|
performDragging();
|
|
|
|
else
|
|
|
|
performRouting();
|
|
|
|
} else if ( evt->IsAction( &ACT_Drag ) )
|
|
|
|
performDragging();
|
|
|
|
|
|
|
|
handleCommonEvents(*evt);
|
|
|
|
}
|
2013-09-18 17:55:16 +00:00
|
|
|
|
|
|
|
// Restore the default settings
|
|
|
|
ctls->SetAutoPan( false );
|
|
|
|
ctls->ShowCursor( false );
|
2014-02-19 12:51:32 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
|
|
|
|
|
2014-05-14 16:45:59 +00:00
|
|
|
// Store routing settings till the next invocation
|
|
|
|
m_settings = m_router->Settings();
|
2014-05-14 13:53:54 +00:00
|
|
|
delete ctxMenu;
|
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ROUTER_TOOL::performDragging()
|
|
|
|
{
|
2014-05-14 16:45:59 +00:00
|
|
|
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
|
|
|
|
bool saveUndoBuffer = true;
|
2014-05-14 13:53:54 +00:00
|
|
|
VIEW_CONTROLS* ctls = getViewControls();
|
|
|
|
|
|
|
|
bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem );
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
if( !dragStarted )
|
2014-05-14 13:53:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( m_startItem && m_startItem->Net() >= 0 )
|
|
|
|
highlightNet( true, m_startItem->Net() );
|
|
|
|
|
|
|
|
ctls->ForceCursorPosition( false );
|
|
|
|
ctls->SetAutoPan( true );
|
|
|
|
|
|
|
|
while( OPT_TOOL_EVENT evt = Wait() )
|
|
|
|
{
|
|
|
|
if( evt->IsCancel() )
|
|
|
|
break;
|
2014-05-14 16:45:59 +00:00
|
|
|
else if( evt->Action() == TA_UNDO_REDO )
|
|
|
|
{
|
|
|
|
saveUndoBuffer = false;
|
|
|
|
break;
|
|
|
|
}
|
2014-05-14 13:53:54 +00:00
|
|
|
else if( evt->IsMotion() )
|
|
|
|
{
|
|
|
|
updateEndItem( *evt );
|
|
|
|
m_router->Move( m_endSnapPoint, m_endItem );
|
|
|
|
}
|
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
|
|
|
{
|
|
|
|
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
|
|
|
|
break;
|
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
|
|
|
|
handleCommonEvents( *evt );
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_router->RoutingInProgress() )
|
|
|
|
m_router->StopRouting();
|
|
|
|
|
2014-05-14 16:45:59 +00:00
|
|
|
if( saveUndoBuffer )
|
|
|
|
{
|
|
|
|
// Save the recent changes in the undo buffer
|
|
|
|
frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED );
|
|
|
|
m_router->ClearUndoBuffer();
|
|
|
|
frame->OnModify();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// It was interrupted by TA_UNDO_REDO event, so we have to sync the world now
|
|
|
|
m_needsSync = true;
|
|
|
|
}
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
ctls->SetAutoPan( false );
|
|
|
|
ctls->ForceCursorPosition( false );
|
|
|
|
highlightNet( false );
|
|
|
|
}
|