diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 7cba888907..f0915ca8a2 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -153,7 +153,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) break; } - CheckJunctionsInList( block->GetItems(), true ); + CheckListConnections( block->GetItems(), true ); block->ClearItemsList(); SchematicCleanUp( true ); OnModify(); @@ -217,7 +217,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC ) SetCrossHairPosition( rotationPoint ); SaveCopyInUndoList( block->GetItems(), UR_ROTATED, false, rotationPoint ); RotateListOfItems( block->GetItems(), rotationPoint ); - CheckJunctionsInList( block->GetItems(), true ); + CheckListConnections( block->GetItems(), true ); SchematicCleanUp( true ); OnModify(); } diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 9115e3343d..b094e2eaa1 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -437,15 +437,19 @@ void SCH_EDIT_FRAME::SaveWireImage() } -void SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool aAppend ) +bool SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool aAppend ) { SCH_LINE* line; + SCH_ITEM* next_item = NULL; + bool retval = false; if( aStart == aEnd ) - return; + return retval; - for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() ) + for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = next_item ) { + next_item = item->Next(); + if( item->GetFlags() & STRUCT_DELETED ) continue; @@ -472,7 +476,11 @@ void SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool SaveCopyInUndoList( (SCH_ITEM*)line, UR_DELETED, aAppend ); GetScreen()->Remove( (SCH_ITEM*)line ); + aAppend = true; + retval = true; } + + return retval; } diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index d591f8c25e..e6e6ffb21f 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -300,11 +300,8 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) m_canvas->MoveCursorToCrossHair(); - if( component->GetFlags() == 0 ) - { - SaveCopyInUndoList( item, UR_CHANGED ); - GetScreen()->SetCurItem( NULL ); - } + if( item->GetFlags() == 0 ) + SetUndoItem( item ); INSTALL_UNBUFFERED_DC( dc, m_canvas ); @@ -312,6 +309,12 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation ) m_canvas->CrossHairOn( &dc ); + if( item->GetFlags() == 0 ) + { + addCurrentItemToList(); + SchematicCleanUp( true ); + } + if( GetScreen()->TestDanglingEnds() ) m_canvas->Refresh(); diff --git a/eeschema/operations_on_items_lists.cpp b/eeschema/operations_on_items_lists.cpp index fcb6efa579..84915fb56c 100644 --- a/eeschema/operations_on_items_lists.cpp +++ b/eeschema/operations_on_items_lists.cpp @@ -115,7 +115,7 @@ void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMoveVector } -void SCH_EDIT_FRAME::CheckJunctionsInList( PICKED_ITEMS_LIST& aItemsList, bool aAppend ) +void SCH_EDIT_FRAME::CheckListConnections( PICKED_ITEMS_LIST& aItemsList, bool aAppend ) { std::vector< wxPoint > pts; std::vector< wxPoint > connections; @@ -124,7 +124,16 @@ void SCH_EDIT_FRAME::CheckJunctionsInList( PICKED_ITEMS_LIST& aItemsList, bool a for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); - item->GetConnectionPoints( pts ); + std::vector< wxPoint > new_pts; + + if( !item->IsConnectable() ) + continue; + + item->GetConnectionPoints( new_pts ); + pts.insert( pts.end(), new_pts.begin(), new_pts.end() ); + + // If the item is a line, we also add any connection points from the rest of the schematic + // that terminate on the line after it is moved. if( item->Type() == SCH_LINE_T ) { SCH_LINE* line = (SCH_LINE*) item; @@ -132,6 +141,17 @@ void SCH_EDIT_FRAME::CheckJunctionsInList( PICKED_ITEMS_LIST& aItemsList, bool a if( IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), i ) ) pts.push_back( i ); } + else + { + // Clean up any wires that short non-wire connections in the list + for( auto point = new_pts.begin(); point != new_pts.end(); point++ ) + { + for( auto second_point = point + 1; second_point != new_pts.end(); second_point++ ) + { + aAppend |= TrimWire( *point, *second_point, aAppend ); + } + } + } } // We always have some overlapping connection points. Drop duplicates here diff --git a/eeschema/schframe.h b/eeschema/schframe.h index 71e940368c..e727e6cee8 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -968,8 +968,9 @@ private: * @param aStart The starting point for trimmming * @param aEnd The ending point for trimming * @param aAppend Should the line changes be appended to a previous undo state + * @return True if any wires were changed by this operation */ - void TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool aAppend = true ); + bool TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool aAppend = true ); /** * Start moving \a aItem using the mouse. @@ -1155,7 +1156,7 @@ public: * @param aItemsList The list of items to check * @param aAppend True if we are updating a previous commit */ - void CheckJunctionsInList( PICKED_ITEMS_LIST& aItemsList, bool aAppend = false ); + void CheckListConnections( PICKED_ITEMS_LIST& aItemsList, bool aAppend = false ); int GetLabelIncrement() const { return m_repeatLabelDelta; }