Better progress reporting and a slight performance boost on commit.
This commit is contained in:
parent
d2de114d21
commit
98b9c6e2a1
|
@ -132,7 +132,8 @@ public:
|
||||||
|
|
||||||
///< Execute the changes.
|
///< Execute the changes.
|
||||||
virtual void Push( const wxString& aMessage = wxT( "A commit" ),
|
virtual void Push( const wxString& aMessage = wxT( "A commit" ),
|
||||||
bool aCreateUndoEntry = true, bool aSetDirtyBit = true ) = 0;
|
bool aCreateUndoEntry = true, bool aSetDirtyBit = true,
|
||||||
|
bool aUpdateConnectivity = true ) = 0;
|
||||||
|
|
||||||
///< Revert the commit by restoring the modified items state.
|
///< Revert the commit by restoring the modified items state.
|
||||||
virtual void Revert() = 0;
|
virtual void Revert() = 0;
|
||||||
|
|
|
@ -1430,10 +1430,7 @@ private:
|
||||||
MD5_HASH checksum() const;
|
MD5_HASH checksum() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<POLYGON> POLYSET;
|
std::vector<POLYGON> m_polys;
|
||||||
|
|
||||||
POLYSET m_polys;
|
|
||||||
|
|
||||||
std::vector<std::unique_ptr<TRIANGULATED_POLYGON>> m_triangulatedPolys;
|
std::vector<std::unique_ptr<TRIANGULATED_POLYGON>> m_triangulatedPolys;
|
||||||
|
|
||||||
bool m_triangulationValid = false;
|
bool m_triangulationValid = false;
|
||||||
|
|
|
@ -2360,7 +2360,6 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition )
|
||||||
|
|
||||||
while( tmpSet.OutlineCount() > 0 )
|
while( tmpSet.OutlineCount() > 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !m_triangulatedPolys.empty() && m_triangulatedPolys.back()->GetTriangleCount() == 0 )
|
if( !m_triangulatedPolys.empty() && m_triangulatedPolys.back()->GetTriangleCount() == 0 )
|
||||||
m_triangulatedPolys.erase( m_triangulatedPolys.end() - 1 );
|
m_triangulatedPolys.erase( m_triangulatedPolys.end() - 1 );
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,14 @@ COMMIT& BOARD_COMMIT::Stage( const PICKED_ITEMS_LIST& aItems, UNDO_REDO aModFlag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool aSetDirtyBit )
|
void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool aSetDirtyBit,
|
||||||
|
bool aUpdateConnectivity )
|
||||||
{
|
{
|
||||||
// Objects potentially interested in changes:
|
// Objects potentially interested in changes:
|
||||||
PICKED_ITEMS_LIST undoList;
|
PICKED_ITEMS_LIST undoList;
|
||||||
KIGFX::VIEW* view = m_toolMgr->GetView();
|
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||||
BOARD* board = (BOARD*) m_toolMgr->GetModel();
|
BOARD* board = (BOARD*) m_toolMgr->GetModel();
|
||||||
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
|
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
|
||||||
auto connectivity = board->GetConnectivity();
|
|
||||||
std::set<EDA_ITEM*> savedModules;
|
std::set<EDA_ITEM*> savedModules;
|
||||||
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
||||||
bool itemsDeselected = false;
|
bool itemsDeselected = false;
|
||||||
|
@ -352,10 +352,15 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
||||||
undoList.PushItem( itemWrapper );
|
undoList.PushItem( itemWrapper );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( aUpdateConnectivity )
|
||||||
|
{
|
||||||
|
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
|
||||||
|
|
||||||
if( ent.m_copy )
|
if( ent.m_copy )
|
||||||
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
|
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
|
||||||
|
|
||||||
connectivity->Update( boardItem );
|
connectivity->Update( boardItem );
|
||||||
|
}
|
||||||
|
|
||||||
if( view )
|
if( view )
|
||||||
{
|
{
|
||||||
|
@ -399,11 +404,16 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
||||||
{
|
{
|
||||||
size_t num_changes = m_changes.size();
|
size_t num_changes = m_changes.size();
|
||||||
|
|
||||||
|
if( aUpdateConnectivity )
|
||||||
|
{
|
||||||
|
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
|
||||||
|
|
||||||
if( m_resolveNetConflicts )
|
if( m_resolveNetConflicts )
|
||||||
connectivity->PropagateNets( this, PROPAGATE_MODE::RESOLVE_CONFLICTS );
|
connectivity->PropagateNets( this, PROPAGATE_MODE::RESOLVE_CONFLICTS );
|
||||||
|
|
||||||
connectivity->RecalculateRatsnest( this );
|
connectivity->RecalculateRatsnest( this );
|
||||||
connectivity->ClearDynamicRatsnest();
|
connectivity->ClearDynamicRatsnest();
|
||||||
|
}
|
||||||
|
|
||||||
if( frame && solderMaskDirty )
|
if( frame && solderMaskDirty )
|
||||||
frame->HideSolderMask();
|
frame->HideSolderMask();
|
||||||
|
|
|
@ -44,7 +44,8 @@ public:
|
||||||
virtual ~BOARD_COMMIT();
|
virtual ~BOARD_COMMIT();
|
||||||
|
|
||||||
virtual void Push( const wxString& aMessage = wxT( "A commit" ),
|
virtual void Push( const wxString& aMessage = wxT( "A commit" ),
|
||||||
bool aCreateUndoEntry = true, bool aSetDirtyBit = true ) override;
|
bool aCreateUndoEntry = true, bool aSetDirtyBit = true,
|
||||||
|
bool aUpdateConnectivity = true ) override;
|
||||||
|
|
||||||
virtual void Revert() override;
|
virtual void Revert() override;
|
||||||
COMMIT& Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType ) override;
|
COMMIT& Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType ) override;
|
||||||
|
|
|
@ -421,44 +421,48 @@ CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode, const KICAD_T a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void reportProgress( PROGRESS_REPORTER* aReporter, int aCount, int aSize, int aDelta )
|
|
||||||
{
|
|
||||||
if( aReporter && ( ( aCount % aDelta ) == 0 || aCount == aSize - 1 ) )
|
|
||||||
{
|
|
||||||
aReporter->SetCurrentProgress( (double) aCount / (double) aSize );
|
|
||||||
aReporter->KeepRefreshing( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
||||||
{
|
{
|
||||||
int delta = 200; // Number of additions between 2 calls to the progress bar
|
int delta = 100; // Number of additions between 2 calls to the progress bar
|
||||||
|
int zoneScaler = 50; // Zones are more expensive
|
||||||
int ii = 0;
|
int ii = 0;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
size += aBoard->Zones().size();
|
size += aBoard->Zones().size() * zoneScaler;
|
||||||
size += aBoard->Tracks().size();
|
size += aBoard->Tracks().size();
|
||||||
|
|
||||||
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
||||||
size += footprint->Pads().size();
|
size += footprint->Pads().size();
|
||||||
|
|
||||||
size *= 2; // Our caller gets the other half of the progress bar
|
size *= 1.5; // Our caller gets the other third of the progress bar
|
||||||
|
|
||||||
delta = std::max( delta, size / 10 );
|
delta = std::max( delta, size / 10 );
|
||||||
|
|
||||||
reportProgress( aReporter, 0, size, delta );
|
if( aReporter )
|
||||||
|
aReporter->KeepRefreshing( false );
|
||||||
|
|
||||||
for( ZONE* zone : aBoard->Zones() )
|
for( ZONE* zone : aBoard->Zones() )
|
||||||
{
|
{
|
||||||
Add( zone );
|
Add( zone );
|
||||||
reportProgress( aReporter, ii++, size, delta );
|
ii += zoneScaler;
|
||||||
|
|
||||||
|
if( aReporter )
|
||||||
|
{
|
||||||
|
aReporter->SetCurrentProgress( (double) ii / (double) size );
|
||||||
|
aReporter->KeepRefreshing( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( PCB_TRACK* tv : aBoard->Tracks() )
|
for( PCB_TRACK* tv : aBoard->Tracks() )
|
||||||
{
|
{
|
||||||
Add( tv );
|
Add( tv );
|
||||||
reportProgress( aReporter, ii++, size, delta );
|
ii++;
|
||||||
|
|
||||||
|
if( aReporter && ( ii % delta ) == 0 )
|
||||||
|
{
|
||||||
|
aReporter->SetCurrentProgress( (double) ii / (double) size );
|
||||||
|
aReporter->KeepRefreshing( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
||||||
|
@ -466,15 +470,27 @@ void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
||||||
for( PAD* pad : footprint->Pads() )
|
for( PAD* pad : footprint->Pads() )
|
||||||
{
|
{
|
||||||
Add( pad );
|
Add( pad );
|
||||||
reportProgress( aReporter, ii++, size, delta );
|
ii++;
|
||||||
|
|
||||||
|
if( aReporter && ( ii % delta ) == 0 )
|
||||||
|
{
|
||||||
|
aReporter->SetCurrentProgress( (double) ii / (double) size );
|
||||||
|
aReporter->KeepRefreshing( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aReporter )
|
||||||
|
{
|
||||||
|
aReporter->SetCurrentProgress( (double) ii / (double) size );
|
||||||
|
aReporter->KeepRefreshing( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CN_CONNECTIVITY_ALGO::Build( const std::vector<BOARD_ITEM*>& aItems )
|
void CN_CONNECTIVITY_ALGO::Build( const std::vector<BOARD_ITEM*>& aItems )
|
||||||
{
|
{
|
||||||
for( auto item : aItems )
|
for( BOARD_ITEM* item : aItems )
|
||||||
{
|
{
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
{
|
{
|
||||||
|
@ -505,7 +521,7 @@ void CN_CONNECTIVITY_ALGO::propagateConnections( BOARD_COMMIT* aCommit, PROPAGAT
|
||||||
wxLogTrace( wxT( "CN" ), wxT( "propagateConnections: propagate skip conflicts? %d" ),
|
wxLogTrace( wxT( "CN" ), wxT( "propagateConnections: propagate skip conflicts? %d" ),
|
||||||
skipConflicts );
|
skipConflicts );
|
||||||
|
|
||||||
for( const auto& cluster : m_connClusters )
|
for( const std::shared_ptr<CN_CLUSTER>& cluster : m_connClusters )
|
||||||
{
|
{
|
||||||
if( skipConflicts && cluster->IsConflicting() )
|
if( skipConflicts && cluster->IsConflicting() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -272,8 +272,8 @@ private:
|
||||||
CN_LIST m_itemList;
|
CN_LIST m_itemList;
|
||||||
std::unordered_map<const BOARD_ITEM*, ITEM_MAP_ENTRY> m_itemMap;
|
std::unordered_map<const BOARD_ITEM*, ITEM_MAP_ENTRY> m_itemMap;
|
||||||
|
|
||||||
CLUSTERS m_connClusters;
|
std::vector<std::shared_ptr<CN_CLUSTER>> m_connClusters;
|
||||||
CLUSTERS m_ratsnestClusters;
|
std::vector<std::shared_ptr<CN_CLUSTER>> m_ratsnestClusters;
|
||||||
std::vector<bool> m_dirtyNets;
|
std::vector<bool> m_dirtyNets;
|
||||||
|
|
||||||
PROGRESS_REPORTER* m_progressReporter = nullptr;
|
PROGRESS_REPORTER* m_progressReporter = nullptr;
|
||||||
|
|
|
@ -97,8 +97,10 @@ void CONNECTIVITY_DATA::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
||||||
m_netclassMap.clear();
|
m_netclassMap.clear();
|
||||||
|
|
||||||
for( NETINFO_ITEM* net : aBoard->GetNetInfo() )
|
for( NETINFO_ITEM* net : aBoard->GetNetInfo() )
|
||||||
|
{
|
||||||
if( net->GetNetClass()->GetName() != NETCLASS::Default )
|
if( net->GetNetClass()->GetName() != NETCLASS::Default )
|
||||||
m_netclassMap[ net->GetNetCode() ] = net->GetNetClass()->GetName();
|
m_netclassMap[ net->GetNetCode() ] = net->GetNetClass()->GetName();
|
||||||
|
}
|
||||||
|
|
||||||
if( aReporter )
|
if( aReporter )
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,7 +127,7 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
||||||
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
||||||
{
|
{
|
||||||
WX_INFOBAR* infobar = frame->GetInfoBar();
|
WX_INFOBAR* infobar = frame->GetInfoBar();
|
||||||
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _("Show DRC rules"),
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Show DRC rules" ),
|
||||||
wxEmptyString );
|
wxEmptyString );
|
||||||
|
|
||||||
button->Bind( wxEVT_COMMAND_HYPERLINK,
|
button->Bind( wxEVT_COMMAND_HYPERLINK,
|
||||||
|
@ -150,15 +150,17 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Fill All Zones" ), 3 );
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Fill All Zones" ), 5 );
|
||||||
filler.SetProgressReporter( reporter.get() );
|
filler.SetProgressReporter( reporter.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
if( filler.Fill( toFill ) )
|
if( filler.Fill( toFill ) )
|
||||||
{
|
{
|
||||||
|
reporter->AdvancePhase();
|
||||||
|
reporter->Report( _( "Updating nets..." ) );
|
||||||
board()->GetConnectivity()->Build( board(), reporter.get() );
|
board()->GetConnectivity()->Build( board(), reporter.get() );
|
||||||
commit.Push( _( "Fill Zone(s)" ), true ); // Allow undoing zone fill
|
|
||||||
|
commit.Push( _( "Fill Zone(s)" ), true, true, false );
|
||||||
frame->m_ZoneFillsDirty = false;
|
frame->m_ZoneFillsDirty = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -168,7 +170,6 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
||||||
|
|
||||||
if( filler.IsDebug() )
|
if( filler.IsDebug() )
|
||||||
frame->UpdateUserInterface();
|
frame->UpdateUserInterface();
|
||||||
}
|
|
||||||
|
|
||||||
canvas()->Refresh();
|
canvas()->Refresh();
|
||||||
m_fillInProgress = false;
|
m_fillInProgress = false;
|
||||||
|
@ -208,13 +209,16 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
||||||
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
||||||
ZONE_FILLER filler( board(), &commit );
|
ZONE_FILLER filler( board(), &commit );
|
||||||
|
|
||||||
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 4 );
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 5 );
|
||||||
filler.SetProgressReporter( reporter.get() );
|
filler.SetProgressReporter( reporter.get() );
|
||||||
|
|
||||||
if( filler.Fill( toFill ) )
|
if( filler.Fill( toFill ) )
|
||||||
{
|
{
|
||||||
board()->GetConnectivity()->Build( board() );
|
reporter->AdvancePhase();
|
||||||
commit.Push( _( "Fill Zone(s)" ), true ); // Allow undoing zone fill
|
reporter->Report( _( "Updating nets..." ) );
|
||||||
|
board()->GetConnectivity()->Build( board(), reporter.get() );
|
||||||
|
|
||||||
|
commit.Push( _( "Fill Zone(s)" ), true, true, false );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
commit.Revert();
|
commit.Revert();
|
||||||
|
|
Loading…
Reference in New Issue