mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Improve progress reporting for opening and importing schematics.
This commit is contained in:
parent
a5d8cadeb9
commit
e615fcfe90
@ -736,7 +736,8 @@ void CONNECTION_GRAPH::Reset()
|
||||
|
||||
|
||||
void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnconditional,
|
||||
std::function<void( SCH_ITEM* )>* aChangedItemHandler )
|
||||
std::function<void( SCH_ITEM* )>* aChangedItemHandler,
|
||||
PROGRESS_REPORTER* aProgressReporter )
|
||||
{
|
||||
PROF_TIMER recalc_time( "CONNECTION_GRAPH::Recalculate" );
|
||||
|
||||
@ -748,8 +749,17 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
|
||||
m_sheetList = aSheetList;
|
||||
std::set<SCH_ITEM*> dirty_items;
|
||||
|
||||
int count = aSheetList.size() * 2;
|
||||
int done = 0;
|
||||
|
||||
for( const SCH_SHEET_PATH& sheet : aSheetList )
|
||||
{
|
||||
if( aProgressReporter )
|
||||
{
|
||||
aProgressReporter->SetCurrentProgress( done++ / (double) count );
|
||||
aProgressReporter->KeepRefreshing();
|
||||
}
|
||||
|
||||
std::vector<SCH_ITEM*> items;
|
||||
|
||||
// Store current unit value, to replace it after calculations
|
||||
@ -826,6 +836,12 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco
|
||||
|
||||
updateItemConnectivity( sheet, items );
|
||||
|
||||
if( aProgressReporter )
|
||||
{
|
||||
aProgressReporter->SetCurrentProgress( done++ / count );
|
||||
aProgressReporter->KeepRefreshing();
|
||||
}
|
||||
|
||||
// UpdateDanglingState() also adds connected items for SCH_TEXT
|
||||
sheet.LastScreen()->TestDanglingEnds( &sheet, aChangedItemHandler );
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <sch_item.h>
|
||||
#include <wx/treectrl.h>
|
||||
#include <advanced_config.h>
|
||||
#include <progress_reporter.h>
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -391,7 +392,8 @@ public:
|
||||
* @param aChangedItemHandler an optional handler to receive any changed items
|
||||
*/
|
||||
void Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnconditional = false,
|
||||
std::function<void( SCH_ITEM* )>* aChangedItemHandler = nullptr );
|
||||
std::function<void( SCH_ITEM* )>* aChangedItemHandler = nullptr,
|
||||
PROGRESS_REPORTER* aProgressReporter = nullptr );
|
||||
|
||||
/**
|
||||
* Return a bus alias pointer for the given name if it exists (from cache)
|
||||
|
@ -539,7 +539,10 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||
|
||||
SCH_COMMIT dummy( this );
|
||||
|
||||
RecalculateConnections( &dummy, GLOBAL_CLEANUP );
|
||||
progressReporter.Report( _( "Updating connections..." ) );
|
||||
progressReporter.KeepRefreshing();
|
||||
|
||||
RecalculateConnections( &dummy, GLOBAL_CLEANUP, &progressReporter );
|
||||
|
||||
if( schematic.HasSymbolFieldNamesWithWhiteSpace() )
|
||||
{
|
||||
@ -1382,12 +1385,12 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType,
|
||||
GetScreen()->SetFileName( newfilename.GetFullPath() );
|
||||
GetScreen()->SetContentModified();
|
||||
|
||||
progressReporter.Report( _( "Cleaning up schematic..." ) );
|
||||
progressReporter.Report( _( "Updating connections..." ) );
|
||||
|
||||
if( !progressReporter.KeepRefreshing() )
|
||||
THROW_IO_ERROR( _( "File import canceled by user." ) );
|
||||
|
||||
RecalculateConnections( nullptr, GLOBAL_CLEANUP );
|
||||
RecalculateConnections( nullptr, GLOBAL_CLEANUP, &progressReporter );
|
||||
|
||||
// Only perform the dangling end test on root sheet.
|
||||
GetScreen()->TestDanglingEnds();
|
||||
|
@ -1777,7 +1777,8 @@ void SCH_EDIT_FRAME::initScreenZoom()
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags )
|
||||
void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags,
|
||||
PROGRESS_REPORTER* aProgressReporter )
|
||||
{
|
||||
wxString highlightedConn = GetHighlightedConnection();
|
||||
bool hasHighlightedConn = !highlightedConn.IsEmpty();
|
||||
@ -1846,7 +1847,7 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL
|
||||
SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, GetCanvas()->GetView() );
|
||||
|
||||
// Recalculate all connectivity
|
||||
Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
|
||||
Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler, aProgressReporter );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2052,7 +2053,7 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL
|
||||
for( const wxString& netName : affectedNets )
|
||||
netSettings->ClearCacheForNet( netName );
|
||||
|
||||
new_graph.Recalculate( list, false, &changeHandler );
|
||||
new_graph.Recalculate( list, false, &changeHandler, aProgressReporter );
|
||||
Schematic().ConnectionGraph()->Merge( new_graph );
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ class RESCUER;
|
||||
class HIERARCHY_PANE;
|
||||
class API_HANDLER_SCH;
|
||||
class DIALOG_SCHEMATIC_SETUP;
|
||||
class PROGRESS_REPORTER;
|
||||
|
||||
|
||||
/// Schematic search type used by the socket link with Pcbnew
|
||||
@ -797,7 +798,8 @@ public:
|
||||
/**
|
||||
* Generate the connection data for the entire schematic hierarchy.
|
||||
*/
|
||||
void RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags );
|
||||
void RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags,
|
||||
PROGRESS_REPORTER* aProgressReporter = nullptr );
|
||||
|
||||
/**
|
||||
* Called after the preferences dialog is run.
|
||||
|
@ -822,12 +822,12 @@ void SCH_IO_ALTIUM::CreateAliases()
|
||||
|
||||
void SCH_IO_ALTIUM::ParseAltiumSch( const wxString& aFileName )
|
||||
{
|
||||
if( m_rootFilepath.IsEmpty() )
|
||||
m_rootFilepath = aFileName;
|
||||
|
||||
// Load path may be different from the project path.
|
||||
wxFileName parentFileName( aFileName );
|
||||
|
||||
if( m_rootFilepath.IsEmpty() )
|
||||
m_rootFilepath = parentFileName.GetPath();
|
||||
|
||||
if( m_progressReporter )
|
||||
{
|
||||
wxFileName relative = parentFileName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user