From 9685b3812d33a3d7986b9082d379646e06473d3a Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 20 Feb 2016 09:59:42 -0500 Subject: [PATCH] Eeschema: decouple SCH_SCREEN::SchematicCleanUp() from wxDC and EDA_DRAW_FRAME. * Remove wxDC and EDA_DRAW_FRAME parameters from SCH_SCREEN::SchematicCleanUp() function call. * Update all code that calls SCH_SCREEN::SchematicCleanUp() with wxDC and/or EDA_DRAW_FRAME parameters. * Fix a display refresh bug when incrementally inserting bus entries created in my last commit. IsDanglingStateChanged() appears to be broke for bus entries. --- eeschema/bus-wire-junction.cpp | 10 +++++----- eeschema/class_sch_screen.h | 6 ++---- eeschema/dialogs/dialog_erc.cpp | 6 +++--- eeschema/hierarch.cpp | 6 +++--- eeschema/project_rescue.cpp | 5 ++--- eeschema/sch_screen.cpp | 9 +++------ eeschema/schframe.cpp | 4 ++-- 7 files changed, 20 insertions(+), 26 deletions(-) diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 599f638fad..6de5e9960f 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -314,7 +314,7 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) screen->Append( s_wires ); // Correct and remove segments that need to be merged. - screen->SchematicCleanUp( NULL, DC ); + screen->SchematicCleanUp(); // A junction could be needed to connect the end point of the last created segment. if( screen->IsJunctionNeeded( endpoint ) ) @@ -429,7 +429,7 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( wxDC* aDC, const wxPoint& aPositio SetRepeatItem( no_connect ); GetScreen()->Append( no_connect ); - GetScreen()->SchematicCleanUp( m_canvas, aDC ); + GetScreen()->SchematicCleanUp(); OnModify(); m_canvas->Refresh(); SaveCopyInUndoList( no_connect, UR_NEW ); @@ -497,8 +497,8 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) if( my_clone->IsConnectable() ) { - if( GetScreen()->TestDanglingEnds() ) - m_canvas->Refresh(); + GetScreen()->TestDanglingEnds(); + m_canvas->Refresh(); } else { diff --git a/eeschema/class_sch_screen.h b/eeschema/class_sch_screen.h index f2c19c66f7..2fb40438fc 100644 --- a/eeschema/class_sch_screen.h +++ b/eeschema/class_sch_screen.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -256,11 +256,9 @@ public: * performs routine schematic cleaning including breaking wire and buses and * deleting identical objects superimposed on top of each other. * - * @param aCanvas The window to draw on. - * @param aDC The device context used for drawing to \a aCanvas. * @return True if any schematic clean up was performed. */ - bool SchematicCleanUp( EDA_DRAW_PANEL* aCanvas = NULL, wxDC* aDC = NULL ); + bool SchematicCleanUp(); /** * Function TestDanglingEnds diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 87acb30d5f..3186bf5df3 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2012 Wayne Stambaugh - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2012-2016 Wayne Stambaugh + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -480,7 +480,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) /* Ff wire list has changed, delete Undo Redo list to avoid pointers on deleted * data problems. */ - if( screen->SchematicCleanUp( NULL ) ) + if( screen->SchematicCleanUp() ) screen->ClearUndoRedoList(); } diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 578274b173..9361c22b50 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2008-2016 Wayne Stambaugh + * Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -295,7 +295,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() screen->m_FirstRedraw = false; SetCrossHairPosition( GetScrollCenterPosition() ); m_canvas->MoveCursorToCrossHair(); - screen->SchematicCleanUp( GetCanvas(), NULL ); + screen->SchematicCleanUp(); } else { diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index f8db7d61fc..f1fdd4ec9d 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Chris Pavlina - * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015-2016 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -562,8 +562,7 @@ bool SCH_EDIT_FRAME::RescueProject( bool aRunningOnDemand ) Prj().SetElem( PROJECT::ELEM_SCH_PART_LIBS, NULL ); // Clean up wire ends - INSTALL_UNBUFFERED_DC( dc, m_canvas ); - GetScreen()->SchematicCleanUp( NULL, &dc ); + GetScreen()->SchematicCleanUp(); m_canvas->Refresh( true ); OnModify(); diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index fdb491478e..20a18b99a8 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -3,8 +3,8 @@ * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2008-2015 Wayne Stambaugh - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2008-2016 Wayne Stambaugh + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -424,7 +424,7 @@ bool SCH_SCREEN::IsTerminalPoint( const wxPoint& aPosition, int aLayer ) } -bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) +bool SCH_SCREEN::SchematicCleanUp() { SCH_ITEM* item, * testItem; bool modified = false; @@ -482,9 +482,6 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) TestDanglingEnds(); - if( aCanvas && modified ) - aCanvas->Refresh(); - return modified; } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index d545a37a44..9e4d213298 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1168,7 +1168,7 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event ) } } - GetScreen()->SchematicCleanUp( m_canvas, NULL ); + GetScreen()->SchematicCleanUp(); m_canvas->Refresh(); }