Handle GAL view refresh for breaking wires.
This commit is contained in:
parent
38f38b16c0
commit
cb8e6c0df5
|
@ -1420,7 +1420,8 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
|
|||
case ID_VIEWER_ZOOM_REDRAW:
|
||||
case ID_POPUP_ZOOM_REDRAW:
|
||||
case ID_ZOOM_REDRAW:
|
||||
m_canvas->Refresh();
|
||||
// This usually means something went wrong. Do a hard refresh.
|
||||
SetScreen( GetScreen() );
|
||||
break;
|
||||
|
||||
case ID_POPUP_ZOOM_CENTER:
|
||||
|
|
|
@ -1726,7 +1726,8 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
|
|||
case ID_VIEWER_ZOOM_REDRAW:
|
||||
case ID_POPUP_ZOOM_REDRAW:
|
||||
case ID_ZOOM_REDRAW:
|
||||
m_canvas->Refresh();
|
||||
// This usually means something went wrong. Do a hard refresh.
|
||||
SetScreen( GetScreen() );
|
||||
break;
|
||||
|
||||
case ID_POPUP_ZOOM_CENTER:
|
||||
|
|
|
@ -475,25 +475,32 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
|
|||
|
||||
void SCH_EDIT_FRAME::SaveWireImage()
|
||||
{
|
||||
DLIST< SCH_ITEM > oldWires;
|
||||
PICKED_ITEMS_LIST oldItems;
|
||||
oldItems.m_Status = UR_WIRE_IMAGE;
|
||||
|
||||
oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
|
||||
GetScreen()->ExtractWires( oldWires, true );
|
||||
SCH_ITEM* item;
|
||||
SCH_ITEM* next_item;
|
||||
|
||||
if( oldWires.GetCount() != 0 )
|
||||
for( item = GetScreen()->GetDrawItems(); item; item = next_item )
|
||||
{
|
||||
PICKED_ITEMS_LIST oldItems;
|
||||
next_item = item->Next();
|
||||
|
||||
oldItems.m_Status = UR_WIRE_IMAGE;
|
||||
|
||||
while( oldWires.GetCount() != 0 )
|
||||
if( item->Type() == SCH_JUNCTION_T || item->Type() == SCH_LINE_T )
|
||||
{
|
||||
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
|
||||
oldItems.PushItem( picker );
|
||||
}
|
||||
GetScreen()->Remove( item );
|
||||
GetCanvas()->GetView()->Remove( item );
|
||||
|
||||
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
|
||||
oldItems.PushItem( ITEM_PICKER( item, UR_WIRE_IMAGE ) );
|
||||
|
||||
SCH_ITEM* item_copy = static_cast<SCH_ITEM*>( item->Clone() );
|
||||
|
||||
GetScreen()->GetDrawList().Insert( item_copy, next_item );
|
||||
GetCanvas()->GetView()->Add( item_copy );
|
||||
}
|
||||
}
|
||||
|
||||
if( oldItems.GetCount() != 0 )
|
||||
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -254,34 +254,6 @@ SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T
|
|||
}
|
||||
|
||||
|
||||
void SCH_SCREEN::ExtractWires( DLIST< SCH_ITEM >& aList, bool aCreateCopy )
|
||||
{
|
||||
SCH_ITEM* item;
|
||||
SCH_ITEM* next_item;
|
||||
|
||||
for( item = m_drawList.begin(); item; item = next_item )
|
||||
{
|
||||
next_item = item->Next();
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_JUNCTION_T:
|
||||
case SCH_LINE_T:
|
||||
m_drawList.Remove( item );
|
||||
aList.Append( item );
|
||||
|
||||
if( aCreateCopy )
|
||||
m_drawList.Insert( (SCH_ITEM*) item->Clone(), next_item );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREEN::ReplaceWires( DLIST< SCH_ITEM >& aWireList )
|
||||
{
|
||||
SCH_ITEM* item;
|
||||
|
|
|
@ -293,19 +293,6 @@ public:
|
|||
*/
|
||||
bool TestDanglingEnds();
|
||||
|
||||
/**
|
||||
* Extracts the old wires, junctions and buses.
|
||||
*
|
||||
* If \a aCreateCopy is true, replace extracted items with a copy of the original. Old
|
||||
* items are to be put in undo list and the new ones can be modified by clean up safely.
|
||||
* If an abort draw segment command is made, the old wires must be put back into #m_drawList,
|
||||
* and the copies must be deleted. This is because previously stored undo commands can
|
||||
* handle pointers on wires or buses, and we do not delete wires or buses, we must put them
|
||||
* in undo list. Because cleanup deletes and/or modify bus and wires, it is easier is to put
|
||||
* all the existing wires in undo list and use a new copy of wires for cleanup.
|
||||
*/
|
||||
void ExtractWires( DLIST< SCH_ITEM >& aList, bool aCreateCopy );
|
||||
|
||||
/**
|
||||
* Replace all of the wires, buses, and junctions in the screen with \a aWireList.
|
||||
*
|
||||
|
|
|
@ -272,27 +272,38 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
// Exchange the current wires, buses, and junctions with the copy save by the last edit.
|
||||
if( aList->m_Status == UR_WIRE_IMAGE )
|
||||
{
|
||||
DLIST< SCH_ITEM > oldWires;
|
||||
PICKED_ITEMS_LIST oldItems;
|
||||
oldItems.m_Status = UR_WIRE_IMAGE;
|
||||
|
||||
// Prevent items from being deleted when the DLIST goes out of scope.
|
||||
oldWires.SetOwnership( false );
|
||||
SCH_ITEM* item;
|
||||
SCH_ITEM* next_item;
|
||||
|
||||
// Remove all of the wires, buses, and junctions from the current screen.
|
||||
GetScreen()->ExtractWires( oldWires, false );
|
||||
for( item = GetScreen()->GetDrawItems(); item; item = next_item )
|
||||
{
|
||||
next_item = item->Next();
|
||||
|
||||
if( item->Type() == SCH_JUNCTION_T || item->Type() == SCH_LINE_T )
|
||||
{
|
||||
GetScreen()->Remove( item );
|
||||
GetCanvas()->GetView()->Remove( item );
|
||||
|
||||
oldItems.PushItem( ITEM_PICKER( item, UR_WIRE_IMAGE ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the saved wires, buses, and junctions to the current screen.
|
||||
for( unsigned int i = 0; i < aList->GetCount(); i++ )
|
||||
AddToScreen( (SCH_ITEM*) aList->GetPickedItem( i ) );
|
||||
{
|
||||
auto item = static_cast<SCH_ITEM*>( aList->GetPickedItem( i ) );
|
||||
|
||||
aList->ClearItemsList();
|
||||
AddToScreen( item );
|
||||
GetCanvas()->GetView()->Add( item );
|
||||
}
|
||||
|
||||
// Copy the previous wires, buses, and junctions to the picked item list for the
|
||||
// redo operation.
|
||||
while( oldWires.GetCount() != 0 )
|
||||
{
|
||||
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
|
||||
aList->PushItem( picker );
|
||||
}
|
||||
*aList = oldItems;
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue