router: multiple fixes - fixed crash when trying to drag a locked via - prompt when the user attempts to drag a locked via/segment - removed remains of PICKED_ITEMS_LIST from the PNS_ROUTER class

This commit is contained in:
Tomasz Wlostowski 2016-08-15 17:16:50 +02:00 committed by Maciej Suminski
parent 2f3950e991
commit 456c02c800
6 changed files with 65 additions and 52 deletions

View File

@ -229,10 +229,6 @@ void LENGTH_TUNER_TOOL::performTuning()
}
m_router->StopRouting();
// Save the recent changes in the undo buffer
m_frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED );
m_router->ClearUndoBuffer();
m_frame->OnModify();
highlightNet( false );
@ -280,9 +276,13 @@ int LENGTH_TUNER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->IsCancel() || evt->IsActivate() )
{
break; // Finish
}
else if( evt->IsMotion() )
{
updateStartItem( *evt );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_StartTuning ) )
{
updateStartItem( *evt );

View File

@ -110,6 +110,8 @@ bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
m_draggedItems.Clear();
m_currentMode = Settings().Mode();
aStartItem->Unmark( MK_LOCKED );
TRACE( 2, "StartDragging: item %p [kind %d]", aStartItem % aStartItem->Kind() );
switch( aStartItem->Kind() )
@ -269,6 +271,7 @@ bool PNS_DRAGGER::dragShove( const VECTOR2I& aP )
if( ok )
{
if( newVia )
m_draggedVia = newVia;
m_draggedItems.Clear();
}

View File

@ -300,9 +300,9 @@ public:
m_marker = aMarker;
}
virtual void Unmark ()
virtual void Unmark (int aMarker = -1)
{
m_marker = 0;
m_marker &= ~aMarker;
}
virtual int Marker() const
@ -330,6 +330,11 @@ public:
return 0;
}
bool IsLocked() const
{
return Marker() & MK_LOCKED;
}
private:
bool collideSimple( const PNS_ITEM* aOther, int aClearance, bool aNeedMTV,
VECTOR2I& aMTV, bool aDifferentNetsOnly ) const;

View File

@ -27,7 +27,6 @@
#include <boost/unordered_set.hpp>
#include <geometry/shape_line_chain.h>
#include <class_undoredo_container.h>
#include "pns_routing_settings.h"
#include "pns_sizes_settings.h"
@ -177,23 +176,6 @@ public:
void CommitRouting( PNS_NODE* aNode );
/**
* Returns the last changes introduced by the router (since the last time ClearLastChanges()
* was called or a new track has been started).
*/
const PICKED_ITEMS_LIST& GetUndoBuffer() const
{
return m_undoBuffer;
}
/**
* Clears the list of recent changes, saved to be stored in the undo buffer.
*/
void ClearUndoBuffer()
{
m_undoBuffer.ClearItemsList();
}
/**
* Applies stored settings.
* @see Settings()
@ -289,7 +271,6 @@ private:
PNS_ROUTING_SETTINGS m_settings;
///> Stores list of modified items in the current operation
PICKED_ITEMS_LIST m_undoBuffer;
PNS_SIZES_SETTINGS m_sizes;
PNS_ROUTER_MODE m_mode;

View File

@ -591,6 +591,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc
return SH_INCOMPLETE;
}
if ( aVia->IsLocked() )
return SH_TRY_WALK;
if( jt->IsLocked() )
return SH_INCOMPLETE;
@ -1285,18 +1288,25 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveDraggingVia( PNS_VIA* aVia, const VECTOR
if( st == SH_OK || st == SH_HEAD_MODIFIED )
{
if( aNewVia )
{
printf("setNewV %p", m_draggedVia);
*aNewVia = m_draggedVia;
}
pushSpringback( m_currentNode, m_draggedViaHeadSet, PNS_COST_ESTIMATOR(), m_affectedAreaSum );
}
else
{
if( aNewVia )
{
*aNewVia = nullptr;
}
delete m_currentNode;
m_currentNode = parent;
}
if( aNewVia )
{
*aNewVia = m_draggedVia;
}
return st;
}

View File

@ -487,6 +487,7 @@ bool ROUTER_TOOL::prepareInteractive()
{
int routingLayer = getStartLayer( m_startItem );
m_frame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
m_frame->UndoRedoBlock ( true );
// fixme: switch on invisible layer
@ -523,6 +524,8 @@ bool ROUTER_TOOL::prepareInteractive()
m_endItem = NULL;
m_endSnapPoint = m_startSnapPoint;
m_frame->UndoRedoBlock ( false );
return true;
}
@ -531,13 +534,7 @@ bool ROUTER_TOOL::finishInteractive()
{
m_router->StopRouting();
// Save the recent changes in the undo buffer
if( m_router->GetUndoBuffer().GetCount() > 0 )
{
m_frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED );
m_router->ClearUndoBuffer();
m_frame->OnModify();
}
m_ctls->SetAutoPan( false );
m_ctls->ForceCursorPosition( false );
@ -677,7 +674,6 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
m_ctls->SetSnapping( true );
m_ctls->ShowCursor( true );
frame->UndoRedoBlock( true );
m_startSnapPoint = getViewControls()->GetCursorPosition();
@ -688,9 +684,17 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->IsCancel() || evt->IsActivate() )
{
break; // Finish
}
else if( evt->Action() == TA_UNDO_REDO )
{
m_router->SyncWorld();
}
else if( evt->IsMotion() )
{
updateStartItem( *evt );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) )
{
updateStartItem( *evt );
@ -711,7 +715,8 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
} else if (evt->IsAction ( &COMMON_ACTIONS::remove ) )
{
deleteTraces( m_startItem, true );
} else if (evt->IsAction ( &COMMON_ACTIONS::removeAlt ) )
}
else if (evt->IsAction ( &COMMON_ACTIONS::removeAlt ) )
{
deleteTraces( m_startItem, false );
}
@ -720,7 +725,6 @@ int ROUTER_TOOL::mainLoop( PNS_ROUTER_MODE aMode )
}
frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
frame->UndoRedoBlock( false );
// Store routing settings till the next invocation
m_savedSettings = m_router->Settings();
@ -738,6 +742,12 @@ void ROUTER_TOOL::performDragging()
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
VIEW_CONTROLS* ctls = getViewControls();
if ( m_startItem && m_startItem->IsLocked() )
{
if ( !IsOK( m_frame, _( "The item is locked. Do you want to continue?" ) ) )
return;
}
bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem );
if( !dragStarted )
@ -748,6 +758,8 @@ void ROUTER_TOOL::performDragging()
ctls->SetAutoPan( true );
bool modified = false;
while( OPT_TOOL_EVENT evt = Wait() )
{
ctls->ForceCursorPosition( false );
@ -762,8 +774,11 @@ void ROUTER_TOOL::performDragging()
else if( evt->IsClick( BUT_LEFT ) )
{
if( m_router->FixRoute( m_endSnapPoint, m_endItem ) )
{
modified = true;
break;
}
}
handleCommonEvents( *evt );
}
@ -771,9 +786,7 @@ void ROUTER_TOOL::performDragging()
if( m_router->RoutingInProgress() )
m_router->StopRouting();
// Save the recent changes in the undo buffer
frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED );
m_router->ClearUndoBuffer();
if( modified )
frame->OnModify();
m_startItem = NULL;
@ -798,6 +811,12 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
m_startItem = m_router->GetWorld()->FindItemByParent( item );
if ( m_startItem && m_startItem->IsLocked() )
{
if ( !IsOK( m_frame, _( "The item is locked. Do you want to continue?" ) ) )
return false;
}
VECTOR2I p0 = ctls->GetCursorPosition();
bool dragStarted = m_router->StartDragging( p0, m_startItem );
@ -809,7 +828,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
ctls->SetAutoPan( true );
frame->UndoRedoBlock( true );
bool saveUndoBuffer = true;
bool modified = false;
while( OPT_TOOL_EVENT evt = Wait() )
{
@ -817,7 +836,6 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
if( evt->IsCancel() )
{
saveUndoBuffer = false;
break;
}
else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
@ -826,7 +844,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
}
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
{
saveUndoBuffer = m_router->FixRoute( p0, NULL );
modified = m_router->FixRoute( p0, NULL );
break;
}
}
@ -834,12 +852,8 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
if( m_router->RoutingInProgress() )
m_router->StopRouting();
if( saveUndoBuffer )
{
frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED );
m_router->ClearUndoBuffer();
if( modified )
frame->OnModify();
}
ctls->SetAutoPan( false );
ctls->ShowCursor( false );