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
This commit is contained in:
parent
0f497d1b7a
commit
7d4cb91f39
|
@ -447,10 +447,12 @@ void SCH_LINE::MirrorHorizontally( int aCenter )
|
|||
|
||||
void SCH_LINE::Rotate( const wxPoint& 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, 900 );
|
||||
|
||||
if( m_flags & ENDPOINT )
|
||||
else if( m_flags & ENDPOINT )
|
||||
RotatePoint( &m_end, aCenter, 900 );
|
||||
}
|
||||
|
||||
|
|
|
@ -853,10 +853,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
|
||||
|
|
|
@ -445,7 +445,6 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
int principalItemCount = 0; // User-selected items (as opposed to connected wires)
|
||||
wxPoint rotPoint;
|
||||
bool moving = false;
|
||||
bool connections = false;
|
||||
|
||||
for( unsigned ii = 0; ii < selection.GetSize(); ii++ )
|
||||
{
|
||||
|
@ -511,6 +510,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 )
|
||||
|
@ -557,7 +578,6 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
break;
|
||||
}
|
||||
|
||||
connections = head->IsConnectable();
|
||||
m_frame->UpdateItem( head, false, true );
|
||||
}
|
||||
else
|
||||
|
@ -636,7 +656,6 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
connections |= item->IsConnectable();
|
||||
m_frame->UpdateItem( item, false, true );
|
||||
updateItem( item, true );
|
||||
}
|
||||
|
@ -652,8 +671,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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue