Schematic: disallow center rotation, allow both endpoint rotations

Center rotation will often misalign lines to the grid, which is bad
until fix off grid items on the schematic.

We can rotate a connection end into a new connection or to become
collinear with an existing line, so we need to check for this at the end
of rotation.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10565
(cherry picked from commit 7d4cb91f39)
This commit is contained in:
Mike Williams 2022-02-25 16:27:55 +00:00 committed by Seth Hillbrand
parent f241617478
commit 5503afc09a
3 changed files with 28 additions and 10 deletions

View File

@ -417,10 +417,13 @@ void SCH_LINE::MirrorHorizontally( int aCenter )
void SCH_LINE::Rotate( const VECTOR2I& aCenter )
{
// When we allow off grid items, the
// else if should become a plain if to allow
// rotation around the center of the line
if( m_flags & STARTPOINT )
RotatePoint( m_start, aCenter, ANGLE_90 );
if( m_flags & ENDPOINT )
else if( m_flags & ENDPOINT )
RotatePoint( m_end, aCenter, ANGLE_90 );
}

View File

@ -825,10 +825,6 @@ void EE_SELECTION_TOOL::narrowSelection( EE_COLLECTOR& collector, const VECTOR2I
else
line->SetFlags( STARTPOINT | ENDPOINT );
}
else if( collector[i]->Type() == SCH_LINE_T )
{
static_cast<SCH_LINE*>( collector[i] )->SetFlags( STARTPOINT | ENDPOINT );
}
}
// Apply some ugly heuristics to avoid disambiguation menus whenever possible

View File

@ -463,7 +463,6 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
int principalItemCount = 0; // User-selected items (as opposed to connected wires)
VECTOR2I rotPoint;
bool moving = false;
bool connections = false;
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
{
@ -532,6 +531,28 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
}
case SCH_LINE_T:
{
SCH_LINE* line = static_cast<SCH_LINE*>( head );
// Equal checks for both and neither. We need this because on undo
// the item will have both flags cleared, but will be selected, so it is possible
// for the user to get a selected line with neither endpoint selected. We
// set flags to make sure Rotate() works when we call it.
if( line->HasFlag( STARTPOINT ) == line->HasFlag( ENDPOINT ) )
{
line->SetFlags( STARTPOINT | ENDPOINT );
// When we allow off grid items, the rotPoint should be set to the midpoint
// of the line to allow rotation around the center, and the next if
// should become an else-if
}
if( line->HasFlag( STARTPOINT ) )
rotPoint = line->GetEndPoint();
else if( line->HasFlag( ENDPOINT ) )
rotPoint = line->GetStartPoint();
}
KI_FALLTHROUGH;
case SCH_BUS_BUS_ENTRY_T:
case SCH_BUS_WIRE_ENTRY_T:
for( int i = 0; clockwise ? i < 3 : i < 1; ++i )
@ -585,7 +606,6 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
UNIMPLEMENTED_FOR( head->GetClass() );
}
connections = head->IsConnectable();
m_frame->UpdateItem( head, false, true );
}
else
@ -664,7 +684,6 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
}
}
connections |= item->IsConnectable();
m_frame->UpdateItem( item, false, true );
updateItem( item, true );
}
@ -680,8 +699,8 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
if( selection.IsHover() )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
if( connections )
m_frame->TestDanglingEnds();
m_frame->RecalculateConnections( LOCAL_CLEANUP );
m_frame->TestDanglingEnds();
m_frame->OnModify();
}