PNS: Snap back to last valid point when committing a drag
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6651
This commit is contained in:
parent
e5b7e7d2b2
commit
be294dabce
|
@ -151,6 +151,7 @@ bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
|
||||||
m_draggedItems.Clear();
|
m_draggedItems.Clear();
|
||||||
m_currentMode = Settings().Mode();
|
m_currentMode = Settings().Mode();
|
||||||
m_freeAngleMode = (m_mode & DM_FREE_ANGLE);
|
m_freeAngleMode = (m_mode & DM_FREE_ANGLE);
|
||||||
|
m_lastValidPoint = aP;
|
||||||
|
|
||||||
if( m_currentMode == RM_Shove && !m_freeAngleMode )
|
if( m_currentMode == RM_Shove && !m_freeAngleMode )
|
||||||
{
|
{
|
||||||
|
@ -535,19 +536,16 @@ bool DRAGGER::FixRoute()
|
||||||
// invalid). In other modes, we can only commit if "Allow DRC violations" is enabled.
|
// invalid). In other modes, we can only commit if "Allow DRC violations" is enabled.
|
||||||
if( !m_dragStatus )
|
if( !m_dragStatus )
|
||||||
{
|
{
|
||||||
switch( m_currentMode )
|
Drag( m_lastValidPoint );
|
||||||
{
|
node = CurrentNode();
|
||||||
case RM_Shove:
|
|
||||||
case RM_Smart:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RM_Walkaround:
|
if( !node )
|
||||||
default:
|
return false;
|
||||||
if( !Settings().CanViolateDRC() )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !m_dragStatus && !Settings().CanViolateDRC() )
|
||||||
|
return false;
|
||||||
|
|
||||||
Router()->CommitRouting( node );
|
Router()->CommitRouting( node );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -558,24 +556,38 @@ bool DRAGGER::FixRoute()
|
||||||
|
|
||||||
bool DRAGGER::Drag( const VECTOR2I& aP )
|
bool DRAGGER::Drag( const VECTOR2I& aP )
|
||||||
{
|
{
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
if( m_freeAngleMode )
|
if( m_freeAngleMode )
|
||||||
return dragMarkObstacles( aP );
|
|
||||||
|
|
||||||
switch( m_currentMode )
|
|
||||||
{
|
{
|
||||||
case RM_MarkObstacles:
|
ret = dragMarkObstacles( aP );
|
||||||
return dragMarkObstacles( aP );
|
|
||||||
|
|
||||||
case RM_Shove:
|
|
||||||
case RM_Smart:
|
|
||||||
return dragShove( aP );
|
|
||||||
|
|
||||||
case RM_Walkaround:
|
|
||||||
return dragWalkaround( aP );
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch( m_currentMode )
|
||||||
|
{
|
||||||
|
case RM_MarkObstacles:
|
||||||
|
ret = dragMarkObstacles( aP );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RM_Shove:
|
||||||
|
case RM_Smart:
|
||||||
|
ret = dragShove( aP );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RM_Walkaround:
|
||||||
|
ret = dragWalkaround( aP );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ret )
|
||||||
|
m_lastValidPoint = aP;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,7 @@ private:
|
||||||
int m_draggedSegmentIndex;
|
int m_draggedSegmentIndex;
|
||||||
bool m_dragStatus;
|
bool m_dragStatus;
|
||||||
PNS_MODE m_currentMode;
|
PNS_MODE m_currentMode;
|
||||||
|
VECTOR2D m_lastValidPoint;
|
||||||
|
|
||||||
///< Contains the list of items that are currently modified by the dragger
|
///< Contains the list of items that are currently modified by the dragger
|
||||||
ITEM_SET m_draggedItems;
|
ITEM_SET m_draggedItems;
|
||||||
|
|
Loading…
Reference in New Issue