Fix undo handling of SchematicCleanUp
This commit is contained in:
parent
7b9f186464
commit
3c714f1d8c
|
@ -434,7 +434,7 @@ void SCH_EDIT_FRAME::EndSegment()
|
|||
for( auto i : new_ends )
|
||||
{
|
||||
if( screen->IsJunctionNeeded( i, true ) )
|
||||
AddJunction( i, true );
|
||||
AddJunction( i, true, false );
|
||||
}
|
||||
|
||||
if( IsBusUnfoldInProgress() )
|
||||
|
@ -633,6 +633,7 @@ bool SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool
|
|||
|
||||
SaveCopyInUndoList( (SCH_ITEM*)line, UR_DELETED, aAppend );
|
||||
RemoveFromScreen( (SCH_ITEM*)line );
|
||||
|
||||
aAppend = true;
|
||||
retval = true;
|
||||
}
|
||||
|
@ -641,7 +642,7 @@ bool SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool
|
|||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend, SCH_SCREEN* aScreen )
|
||||
bool SCH_EDIT_FRAME::SchematicCleanUp( bool aUndo, SCH_SCREEN* aScreen )
|
||||
{
|
||||
SCH_ITEM* item = NULL;
|
||||
SCH_ITEM* secondItem = NULL;
|
||||
|
@ -740,6 +741,9 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend, SCH_SCREEN* aScreen )
|
|||
RemoveFromScreen( item, aScreen );
|
||||
}
|
||||
|
||||
if( itemList.GetCount() && aUndo )
|
||||
SaveCopyInUndoList( itemList, UR_DELETED, true );
|
||||
|
||||
return itemList.GetCount() > 0;
|
||||
}
|
||||
|
||||
|
@ -760,6 +764,9 @@ bool SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const wxPoint& aPoint,
|
|||
newSegment->SetStartPoint( aPoint );
|
||||
AddToScreen( newSegment, aScreen );
|
||||
|
||||
if( aAppend )
|
||||
SaveCopyInUndoList( newSegment, UR_NEW, true );
|
||||
|
||||
RefreshItem( aSegment );
|
||||
aSegment->SetEndPoint( aPoint );
|
||||
|
||||
|
@ -888,21 +895,26 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
|
|||
}
|
||||
|
||||
|
||||
SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( const wxPoint& aPosition, bool aAppend )
|
||||
SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( const wxPoint& aPosition,
|
||||
bool aAppend, bool aFinal )
|
||||
{
|
||||
SCH_JUNCTION* junction = new SCH_JUNCTION( aPosition );
|
||||
bool broken_segments = false;
|
||||
|
||||
AddToScreen( junction );
|
||||
broken_segments = BreakSegments( aPosition, aAppend );
|
||||
TestDanglingEnds();
|
||||
OnModify();
|
||||
SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend );
|
||||
|
||||
auto view = GetCanvas()->GetView();
|
||||
view->ClearPreview();
|
||||
view->ShowPreview( false );
|
||||
view->ClearHiddenFlags();
|
||||
if( aFinal )
|
||||
{
|
||||
TestDanglingEnds();
|
||||
OnModify();
|
||||
|
||||
auto view = GetCanvas()->GetView();
|
||||
view->ClearPreview();
|
||||
view->ShowPreview( false );
|
||||
view->ClearHiddenFlags();
|
||||
}
|
||||
|
||||
return junction;
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
|
||||
// Ensure the schematic is fully segmented on first display
|
||||
BreakSegmentsOnJunctions();
|
||||
SchematicCleanUp( true );
|
||||
SchematicCleanUp();
|
||||
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
|
||||
GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
|
||||
|
||||
|
@ -850,7 +850,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
|||
|
||||
// Ensure the schematic is fully segmented on first display
|
||||
BreakSegmentsOnJunctions();
|
||||
SchematicCleanUp( true );
|
||||
SchematicCleanUp();
|
||||
GetScreen()->m_Initialized = true;
|
||||
|
||||
SCH_TYPE_COLLECTOR components;
|
||||
|
|
|
@ -293,7 +293,7 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
|
|||
if( item->GetFlags() == 0 )
|
||||
{
|
||||
addCurrentItemToScreen();
|
||||
SchematicCleanUp( true );
|
||||
SchematicCleanUp();
|
||||
}
|
||||
|
||||
TestDanglingEnds();
|
||||
|
|
|
@ -1519,7 +1519,7 @@ void SCH_EDIT_FRAME::RecalculateConnections()
|
|||
|
||||
// Ensure schematic graph is accurate
|
||||
for( const auto& sheet : list )
|
||||
SchematicCleanUp( true, sheet.LastScreen() );
|
||||
SchematicCleanUp( false, sheet.LastScreen() );
|
||||
|
||||
g_ConnectionGraph->Recalculate( list );
|
||||
}
|
||||
|
|
|
@ -997,7 +997,9 @@ private:
|
|||
/**
|
||||
* Add a new junction at \a aPosition.
|
||||
*/
|
||||
SCH_JUNCTION* AddJunction( const wxPoint& aPosition, bool aPutInUndoList = false );
|
||||
SCH_JUNCTION* AddJunction( const wxPoint& aPosition,
|
||||
bool aAppendToUndo = false,
|
||||
bool aFinal = true );
|
||||
|
||||
/**
|
||||
* Save a copy of the current wire image in the undo list.
|
||||
|
|
Loading…
Reference in New Issue