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 )
|
for( auto i : new_ends )
|
||||||
{
|
{
|
||||||
if( screen->IsJunctionNeeded( i, true ) )
|
if( screen->IsJunctionNeeded( i, true ) )
|
||||||
AddJunction( i, true );
|
AddJunction( i, true, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( IsBusUnfoldInProgress() )
|
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 );
|
SaveCopyInUndoList( (SCH_ITEM*)line, UR_DELETED, aAppend );
|
||||||
RemoveFromScreen( (SCH_ITEM*)line );
|
RemoveFromScreen( (SCH_ITEM*)line );
|
||||||
|
|
||||||
aAppend = true;
|
aAppend = true;
|
||||||
retval = 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* item = NULL;
|
||||||
SCH_ITEM* secondItem = NULL;
|
SCH_ITEM* secondItem = NULL;
|
||||||
|
@ -740,6 +741,9 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend, SCH_SCREEN* aScreen )
|
||||||
RemoveFromScreen( item, aScreen );
|
RemoveFromScreen( item, aScreen );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( itemList.GetCount() && aUndo )
|
||||||
|
SaveCopyInUndoList( itemList, UR_DELETED, true );
|
||||||
|
|
||||||
return itemList.GetCount() > 0;
|
return itemList.GetCount() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,6 +764,9 @@ bool SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const wxPoint& aPoint,
|
||||||
newSegment->SetStartPoint( aPoint );
|
newSegment->SetStartPoint( aPoint );
|
||||||
AddToScreen( newSegment, aScreen );
|
AddToScreen( newSegment, aScreen );
|
||||||
|
|
||||||
|
if( aAppend )
|
||||||
|
SaveCopyInUndoList( newSegment, UR_NEW, true );
|
||||||
|
|
||||||
RefreshItem( aSegment );
|
RefreshItem( aSegment );
|
||||||
aSegment->SetEndPoint( aPoint );
|
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 );
|
SCH_JUNCTION* junction = new SCH_JUNCTION( aPosition );
|
||||||
bool broken_segments = false;
|
bool broken_segments = false;
|
||||||
|
|
||||||
AddToScreen( junction );
|
AddToScreen( junction );
|
||||||
broken_segments = BreakSegments( aPosition, aAppend );
|
broken_segments = BreakSegments( aPosition, aAppend );
|
||||||
TestDanglingEnds();
|
|
||||||
OnModify();
|
|
||||||
SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend );
|
SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend );
|
||||||
|
|
||||||
auto view = GetCanvas()->GetView();
|
if( aFinal )
|
||||||
view->ClearPreview();
|
{
|
||||||
view->ShowPreview( false );
|
TestDanglingEnds();
|
||||||
view->ClearHiddenFlags();
|
OnModify();
|
||||||
|
|
||||||
|
auto view = GetCanvas()->GetView();
|
||||||
|
view->ClearPreview();
|
||||||
|
view->ShowPreview( false );
|
||||||
|
view->ClearHiddenFlags();
|
||||||
|
}
|
||||||
|
|
||||||
return junction;
|
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
|
// Ensure the schematic is fully segmented on first display
|
||||||
BreakSegmentsOnJunctions();
|
BreakSegmentsOnJunctions();
|
||||||
SchematicCleanUp( true );
|
SchematicCleanUp();
|
||||||
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
|
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
|
||||||
GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
|
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
|
// Ensure the schematic is fully segmented on first display
|
||||||
BreakSegmentsOnJunctions();
|
BreakSegmentsOnJunctions();
|
||||||
SchematicCleanUp( true );
|
SchematicCleanUp();
|
||||||
GetScreen()->m_Initialized = true;
|
GetScreen()->m_Initialized = true;
|
||||||
|
|
||||||
SCH_TYPE_COLLECTOR components;
|
SCH_TYPE_COLLECTOR components;
|
||||||
|
|
|
@ -293,7 +293,7 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
|
||||||
if( item->GetFlags() == 0 )
|
if( item->GetFlags() == 0 )
|
||||||
{
|
{
|
||||||
addCurrentItemToScreen();
|
addCurrentItemToScreen();
|
||||||
SchematicCleanUp( true );
|
SchematicCleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestDanglingEnds();
|
TestDanglingEnds();
|
||||||
|
|
|
@ -1519,7 +1519,7 @@ void SCH_EDIT_FRAME::RecalculateConnections()
|
||||||
|
|
||||||
// Ensure schematic graph is accurate
|
// Ensure schematic graph is accurate
|
||||||
for( const auto& sheet : list )
|
for( const auto& sheet : list )
|
||||||
SchematicCleanUp( true, sheet.LastScreen() );
|
SchematicCleanUp( false, sheet.LastScreen() );
|
||||||
|
|
||||||
g_ConnectionGraph->Recalculate( list );
|
g_ConnectionGraph->Recalculate( list );
|
||||||
}
|
}
|
||||||
|
|
|
@ -997,7 +997,9 @@ private:
|
||||||
/**
|
/**
|
||||||
* Add a new junction at \a aPosition.
|
* 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.
|
* Save a copy of the current wire image in the undo list.
|
||||||
|
|
Loading…
Reference in New Issue