Push m_forceMarkObstaclesMode down into the DRAGGER.

The existing flag was never read anyway, and it's only the DRAGGER
that knows that the starting state is already colliding and that we
need to force mark-obstacles mode.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8641
This commit is contained in:
Jeff Young 2023-10-28 17:49:42 +01:00
parent 708b42ea69
commit a2f19ea6bb
4 changed files with 27 additions and 14 deletions

View File

@ -41,6 +41,7 @@ DRAGGER::DRAGGER( ROUTER* aRouter ) :
m_dragStatus = false; m_dragStatus = false;
m_currentMode = RM_MarkObstacles; m_currentMode = RM_MarkObstacles;
m_freeAngleMode = false; m_freeAngleMode = false;
m_forceMarkObstaclesMode = false;
} }
@ -112,11 +113,16 @@ bool DRAGGER::startDragSegment( const VECTOR2D& aP, SEGMENT* aSeg )
m_draggedLine = m_world->AssembleLine( aSeg, &m_draggedSegmentIndex ); m_draggedLine = m_world->AssembleLine( aSeg, &m_draggedSegmentIndex );
m_lastDragSolution = m_draggedLine; m_lastDragSolution = m_draggedLine;
if( m_shove ) if ( m_world->CheckColliding( &m_draggedLine ) )
{ {
m_shove->SetInitialLine( m_draggedLine ); // If we're already in a state that violates DRC then there's not much we can do but
// switch to mark obstacles mode (and ignore other DRC violation).
m_forceMarkObstaclesMode = true;
} }
if( m_shove )
m_shove->SetInitialLine( m_draggedLine );
auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm(); auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm(); auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
@ -153,6 +159,13 @@ bool DRAGGER::startDragArc( const VECTOR2D& aP, ARC* aArc )
m_shove->SetInitialLine( m_draggedLine ); m_shove->SetInitialLine( m_draggedLine );
m_mode = DM_ARC; m_mode = DM_ARC;
if ( m_world->CheckColliding( &m_draggedLine ) )
{
// If we're already in a state that violates DRC then there's not much we can do but
// switch to mark obstacles mode (and ignore other DRC violation).
m_forceMarkObstaclesMode = true;
}
return true; return true;
} }
@ -164,6 +177,13 @@ bool DRAGGER::startDragVia( VIA* aVia )
m_mode = DM_VIA; m_mode = DM_VIA;
if ( m_world->CheckColliding( aVia ) )
{
// If we're already in a state that violates DRC then there's not much we can do but
// switch to mark obstacles mode (and ignore other DRC violation).
m_forceMarkObstaclesMode = true;
}
return true; return true;
} }
@ -209,6 +229,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_forceMarkObstaclesMode = false;
m_lastValidPoint = aP; m_lastValidPoint = aP;
m_mouseTrailTracer.Clear(); m_mouseTrailTracer.Clear();
@ -320,7 +341,7 @@ bool DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
} }
} }
if( Settings().AllowDRCViolations() ) if( m_forceMarkObstaclesMode || Settings().AllowDRCViolations() )
m_dragStatus = true; m_dragStatus = true;
else else
m_dragStatus = !m_lastNode->CheckColliding( m_draggedItems ); m_dragStatus = !m_lastNode->CheckColliding( m_draggedItems );
@ -718,7 +739,7 @@ bool DRAGGER::FixRoute()
return false; return false;
} }
if( !m_dragStatus && !Settings().AllowDRCViolations() ) if( !m_dragStatus && !Settings().AllowDRCViolations() && !m_forceMarkObstaclesMode )
return false; return false;
Router()->CommitRouting( node ); Router()->CommitRouting( node );
@ -735,7 +756,7 @@ bool DRAGGER::Drag( const VECTOR2I& aP )
bool ret = false; bool ret = false;
if( m_freeAngleMode ) if( m_freeAngleMode || m_forceMarkObstaclesMode )
{ {
ret = dragMarkObstacles( aP ); ret = dragMarkObstacles( aP );
} }

View File

@ -157,6 +157,7 @@ private:
///< If true, moves the connection lines without maintaining 45 degrees corners ///< If true, moves the connection lines without maintaining 45 degrees corners
bool m_freeAngleMode; bool m_freeAngleMode;
bool m_forceMarkObstaclesMode;
MOUSE_TRAIL_TRACER m_mouseTrailTracer; MOUSE_TRAIL_TRACER m_mouseTrailTracer;
}; };

View File

@ -189,16 +189,10 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM
if( aStartItems.Count( ITEM::SOLID_T ) == aStartItems.Size() ) if( aStartItems.Count( ITEM::SOLID_T ) == aStartItems.Size() )
{ {
m_dragger = std::make_unique<COMPONENT_DRAGGER>( this ); m_dragger = std::make_unique<COMPONENT_DRAGGER>( this );
m_forceMarkObstaclesMode = true;
m_state = DRAG_COMPONENT; m_state = DRAG_COMPONENT;
} }
else else
{ {
if( aDragMode & DM_FREE_ANGLE )
m_forceMarkObstaclesMode = true;
else
m_forceMarkObstaclesMode = false;
m_dragger = std::make_unique<DRAGGER>( this ); m_dragger = std::make_unique<DRAGGER>( this );
m_state = DRAG_SEGMENT; m_state = DRAG_SEGMENT;
} }
@ -420,8 +414,6 @@ bool ROUTER::StartRouting( const VECTOR2I& aP, ITEM* aStartItem, int aLayer )
if( !isStartingPointRoutable( aP, aStartItem, aLayer ) ) if( !isStartingPointRoutable( aP, aStartItem, aLayer ) )
return false; return false;
m_forceMarkObstaclesMode = false;
switch( m_mode ) switch( m_mode )
{ {
case PNS_MODE_ROUTE_SINGLE: case PNS_MODE_ROUTE_SINGLE:

View File

@ -248,7 +248,6 @@ private:
ROUTER_IFACE* m_iface; ROUTER_IFACE* m_iface;
int m_iterLimit; int m_iterLimit;
bool m_forceMarkObstaclesMode = false;
ROUTING_SETTINGS* m_settings; ROUTING_SETTINGS* m_settings;
SIZES_SETTINGS m_sizes; SIZES_SETTINGS m_sizes;