diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 5c2500bebb..346157c10f 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -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 ); } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 0fa009f069..d50f7d548c 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -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( collector[i] )->SetFlags( STARTPOINT | ENDPOINT ); - } } // Apply some ugly heuristics to avoid disambiguation menus whenever possible diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 51eea12539..6e9260415d 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -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( 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(); }