Eeschema: Moving SchematicCleanup to SCH_EDIT_FRAME
SchematicCleanup function moved from SCH_SCREEN to SCH_EDIT_FRAME to allow access to the undo stack as we are changing the schematic.
This commit is contained in:
parent
c6632bdded
commit
bf32cc2555
|
@ -330,7 +330,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
|
|||
screen->Append( s_wires );
|
||||
|
||||
// Correct and remove segments that need to be merged.
|
||||
screen->SchematicCleanUp();
|
||||
SchematicCleanUp();
|
||||
|
||||
// A junction could be needed to connect the end point of the last created segment.
|
||||
if( screen->IsJunctionNeeded( endpoint ) )
|
||||
|
@ -417,6 +417,55 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::SchematicCleanUp()
|
||||
{
|
||||
bool modified = false;
|
||||
|
||||
for( SCH_ITEM* item = GetScreen()->GetDrawItems() ; item; item = item->Next() )
|
||||
{
|
||||
if( ( item->Type() != SCH_LINE_T ) && ( item->Type() != SCH_JUNCTION_T ) )
|
||||
continue;
|
||||
|
||||
bool restart;
|
||||
|
||||
for( SCH_ITEM* testItem = item->Next(); testItem; testItem = restart ? GetScreen()->GetDrawItems() : testItem->Next() )
|
||||
{
|
||||
restart = false;
|
||||
|
||||
if( ( item->Type() == SCH_LINE_T ) && ( testItem->Type() == SCH_LINE_T ) )
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
|
||||
if( line->MergeOverlap( (SCH_LINE*) testItem ) )
|
||||
{
|
||||
// Keep the current flags, because the deleted segment can be flagged.
|
||||
item->SetFlags( testItem->GetFlags() );
|
||||
DeleteItem( testItem );
|
||||
restart = true;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
else if ( ( ( item->Type() == SCH_JUNCTION_T )
|
||||
&& ( testItem->Type() == SCH_JUNCTION_T ) ) && ( testItem != item ) )
|
||||
{
|
||||
if ( testItem->HitTest( item->GetPosition() ) )
|
||||
{
|
||||
// Keep the current flags, because the deleted segment can be flagged.
|
||||
item->SetFlags( testItem->GetFlags() );
|
||||
DeleteItem( testItem );
|
||||
restart = true;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetScreen()->TestDanglingEnds();
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( wxDC* aDC, const wxPoint& aPosition,
|
||||
bool aPutInUndoList )
|
||||
{
|
||||
|
@ -445,7 +494,7 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( wxDC* aDC, const wxPoint& aPositio
|
|||
|
||||
SetRepeatItem( no_connect );
|
||||
GetScreen()->Append( no_connect );
|
||||
GetScreen()->SchematicCleanUp();
|
||||
SchematicCleanUp();
|
||||
OnModify();
|
||||
m_canvas->Refresh();
|
||||
SaveCopyInUndoList( no_connect, UR_NEW );
|
||||
|
|
|
@ -261,17 +261,8 @@ public:
|
|||
|
||||
bool CheckIfOnDrawList( SCH_ITEM* st );
|
||||
|
||||
/**
|
||||
* Perform routine schematic cleaning including breaking wire and buses and
|
||||
* deleting identical objects superimposed on top of each other.
|
||||
*
|
||||
* @return True if any schematic clean up was performed.
|
||||
*/
|
||||
bool SchematicCleanUp();
|
||||
|
||||
/**
|
||||
* Test all of the connectable objects in the schematic for unused connection points.
|
||||
*
|
||||
* @return True if any connection state changes were made.
|
||||
*/
|
||||
bool TestDanglingEnds();
|
||||
|
@ -541,11 +532,6 @@ public:
|
|||
*/
|
||||
void ClearAnnotation();
|
||||
|
||||
/**
|
||||
* Merge and break wire segments in the entire schematic hierarchy.
|
||||
*/
|
||||
void SchematicCleanUp();
|
||||
|
||||
/**
|
||||
* Test all sheet and component objects in the schematic for duplicate time stamps
|
||||
* and replaces them as necessary.
|
||||
|
|
|
@ -299,7 +299,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
|||
screen->m_FirstRedraw = false;
|
||||
SetCrossHairPosition( GetScrollCenterPosition() );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->SchematicCleanUp();
|
||||
SchematicCleanUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -556,7 +556,7 @@ bool SCH_EDIT_FRAME::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
|
|||
viewer->ReCreateListLib();
|
||||
|
||||
// Clean up wire ends
|
||||
GetScreen()->SchematicCleanUp();
|
||||
SchematicCleanUp();
|
||||
m_canvas->Refresh( true );
|
||||
OnModify();
|
||||
|
||||
|
|
|
@ -435,55 +435,6 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SCREEN::SchematicCleanUp()
|
||||
{
|
||||
bool modified = false;
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin() ; item; item = item->Next() )
|
||||
{
|
||||
if( ( item->Type() != SCH_LINE_T ) && ( item->Type() != SCH_JUNCTION_T ) )
|
||||
continue;
|
||||
|
||||
bool restart;
|
||||
|
||||
for( SCH_ITEM* testItem = item->Next(); testItem; testItem = restart ? m_drawList.begin() : testItem->Next() )
|
||||
{
|
||||
restart = false;
|
||||
|
||||
if( ( item->Type() == SCH_LINE_T ) && ( testItem->Type() == SCH_LINE_T ) )
|
||||
{
|
||||
SCH_LINE* line = (SCH_LINE*) item;
|
||||
|
||||
if( line->MergeOverlap( (SCH_LINE*) testItem ) )
|
||||
{
|
||||
// Keep the current flags, because the deleted segment can be flagged.
|
||||
item->SetFlags( testItem->GetFlags() );
|
||||
DeleteItem( testItem );
|
||||
restart = true;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
else if ( ( ( item->Type() == SCH_JUNCTION_T )
|
||||
&& ( testItem->Type() == SCH_JUNCTION_T ) ) && ( testItem != item ) )
|
||||
{
|
||||
if ( testItem->HitTest( item->GetPosition() ) )
|
||||
{
|
||||
// Keep the current flags, because the deleted segment can be flagged.
|
||||
item->SetFlags( testItem->GetFlags() );
|
||||
DeleteItem( testItem );
|
||||
restart = true;
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TestDanglingEnds();
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREEN::UpdateSymbolLinks( bool aForce )
|
||||
{
|
||||
// Initialize or reinitialize the pointer to the LIB_PART for each component
|
||||
|
@ -1375,19 +1326,6 @@ void SCH_SCREENS::ClearAnnotation()
|
|||
m_screens[i]->ClearAnnotation( NULL );
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREENS::SchematicCleanUp()
|
||||
{
|
||||
for( size_t i = 0; i < m_screens.size(); i++ )
|
||||
{
|
||||
// if wire list has changed, delete the undo/redo list to avoid
|
||||
// pointer problems with deleted data.
|
||||
if( m_screens[i]->SchematicCleanUp() )
|
||||
m_screens[i]->ClearUndoRedoList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int SCH_SCREENS::ReplaceDuplicateTimeStamps()
|
||||
{
|
||||
EDA_ITEMS items;
|
||||
|
|
|
@ -1249,7 +1249,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
|||
libeditFrame->LoadComponentAndSelectLib( id );
|
||||
}
|
||||
|
||||
GetScreen()->SchematicCleanUp();
|
||||
SchematicCleanUp();
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -908,6 +908,15 @@ private:
|
|||
*/
|
||||
SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false );
|
||||
|
||||
/**
|
||||
* Function SchematicCleanUp
|
||||
* performs routine schematic cleaning including breaking wire and buses and
|
||||
* deleting identical objects superimposed on top of each other.
|
||||
*
|
||||
* @return True if any schematic clean up was performed.
|
||||
*/
|
||||
bool SchematicCleanUp();
|
||||
|
||||
/**
|
||||
* Start moving \a aItem using the mouse.
|
||||
*
|
||||
|
@ -1072,6 +1081,7 @@ public:
|
|||
* Remove \a aItem from the current screen and saves it in the undo list.
|
||||
*
|
||||
* @param aItem The item to remove from the current screen.
|
||||
* @param aAppend True if we are updating a previous Undo state
|
||||
*/
|
||||
void DeleteItem( SCH_ITEM* aItem, bool aAppend = false );
|
||||
|
||||
|
|
Loading…
Reference in New Issue