Eeschema: Correcting missing cleanup calls
Adds cleanup (wires and junctions) to two commands: rotate/orient and drag without block. Fixes: lp:1739951 * https://bugs.launchpad.net/kicad/+bug/1739951
This commit is contained in:
parent
6073bf3ea7
commit
cfe20e22fb
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue