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.
|
||||
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.
|
||||
virtual void Revert() = 0;
|
||||
|
|
|
@ -1430,10 +1430,7 @@ private:
|
|||
MD5_HASH checksum() const;
|
||||
|
||||
private:
|
||||
typedef std::vector<POLYGON> POLYSET;
|
||||
|
||||
POLYSET m_polys;
|
||||
|
||||
std::vector<POLYGON> m_polys;
|
||||
std::vector<std::unique_ptr<TRIANGULATED_POLYGON>> m_triangulatedPolys;
|
||||
|
||||
bool m_triangulationValid = false;
|
||||
|
|
|
@ -2360,7 +2360,6 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition )
|
|||
|
||||
while( tmpSet.OutlineCount() > 0 )
|
||||
{
|
||||
|
||||
if( !m_triangulatedPolys.empty() && m_triangulatedPolys.back()->GetTriangleCount() == 0 )
|
||||
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:
|
||||
PICKED_ITEMS_LIST undoList;
|
||||
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||
BOARD* board = (BOARD*) m_toolMgr->GetModel();
|
||||
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
|
||||
auto connectivity = board->GetConnectivity();
|
||||
std::set<EDA_ITEM*> savedModules;
|
||||
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
|
||||
bool itemsDeselected = false;
|
||||
|
@ -352,10 +352,15 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
undoList.PushItem( itemWrapper );
|
||||
}
|
||||
|
||||
if( ent.m_copy )
|
||||
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
|
||||
if( aUpdateConnectivity )
|
||||
{
|
||||
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
|
||||
|
||||
connectivity->Update( boardItem );
|
||||
if( ent.m_copy )
|
||||
connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
|
||||
|
||||
connectivity->Update( boardItem );
|
||||
}
|
||||
|
||||
if( view )
|
||||
{
|
||||
|
@ -399,11 +404,16 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
|
|||
{
|
||||
size_t num_changes = m_changes.size();
|
||||
|
||||
if( m_resolveNetConflicts )
|
||||
connectivity->PropagateNets( this, PROPAGATE_MODE::RESOLVE_CONFLICTS );
|
||||
if( aUpdateConnectivity )
|
||||
{
|
||||
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
|
||||
|
||||
connectivity->RecalculateRatsnest( this );
|
||||
connectivity->ClearDynamicRatsnest();
|
||||
if( m_resolveNetConflicts )
|
||||
connectivity->PropagateNets( this, PROPAGATE_MODE::RESOLVE_CONFLICTS );
|
||||
|
||||
connectivity->RecalculateRatsnest( this );
|
||||
connectivity->ClearDynamicRatsnest();
|
||||
}
|
||||
|
||||
if( frame && solderMaskDirty )
|
||||
frame->HideSolderMask();
|
||||
|
|
|
@ -44,7 +44,8 @@ public:
|
|||
virtual ~BOARD_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;
|
||||
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 )
|
||||
{
|
||||
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 size = 0;
|
||||
|
||||
size += aBoard->Zones().size();
|
||||
size += aBoard->Zones().size() * zoneScaler;
|
||||
size += aBoard->Tracks().size();
|
||||
|
||||
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
||||
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 );
|
||||
|
||||
reportProgress( aReporter, 0, size, delta );
|
||||
if( aReporter )
|
||||
aReporter->KeepRefreshing( false );
|
||||
|
||||
for( ZONE* zone : aBoard->Zones() )
|
||||
{
|
||||
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() )
|
||||
{
|
||||
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() )
|
||||
|
@ -466,15 +470,27 @@ void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
|||
for( PAD* pad : footprint->Pads() )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
for( auto item : aItems )
|
||||
for( BOARD_ITEM* item : aItems )
|
||||
{
|
||||
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" ),
|
||||
skipConflicts );
|
||||
|
||||
for( const auto& cluster : m_connClusters )
|
||||
for( const std::shared_ptr<CN_CLUSTER>& cluster : m_connClusters )
|
||||
{
|
||||
if( skipConflicts && cluster->IsConflicting() )
|
||||
{
|
||||
|
|
|
@ -272,9 +272,9 @@ private:
|
|||
CN_LIST m_itemList;
|
||||
std::unordered_map<const BOARD_ITEM*, ITEM_MAP_ENTRY> m_itemMap;
|
||||
|
||||
CLUSTERS m_connClusters;
|
||||
CLUSTERS m_ratsnestClusters;
|
||||
std::vector<bool> m_dirtyNets;
|
||||
std::vector<std::shared_ptr<CN_CLUSTER>> m_connClusters;
|
||||
std::vector<std::shared_ptr<CN_CLUSTER>> m_ratsnestClusters;
|
||||
std::vector<bool> m_dirtyNets;
|
||||
|
||||
PROGRESS_REPORTER* m_progressReporter = nullptr;
|
||||
};
|
||||
|
|
|
@ -97,8 +97,10 @@ void CONNECTIVITY_DATA::Build( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
|||
m_netclassMap.clear();
|
||||
|
||||
for( NETINFO_ITEM* net : aBoard->GetNetInfo() )
|
||||
{
|
||||
if( net->GetNetClass()->GetName() != NETCLASS::Default )
|
||||
m_netclassMap[ net->GetNetCode() ] = net->GetNetClass()->GetName();
|
||||
}
|
||||
|
||||
if( aReporter )
|
||||
{
|
||||
|
|
|
@ -127,7 +127,7 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
|||
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
||||
{
|
||||
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 );
|
||||
|
||||
button->Bind( wxEVT_COMMAND_HYPERLINK,
|
||||
|
@ -150,25 +150,26 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
|
|||
}
|
||||
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() );
|
||||
}
|
||||
|
||||
if( filler.Fill( toFill ) )
|
||||
{
|
||||
if( filler.Fill( toFill ) )
|
||||
{
|
||||
board()->GetConnectivity()->Build( board(), reporter.get() );
|
||||
commit.Push( _( "Fill Zone(s)" ), true ); // Allow undoing zone fill
|
||||
frame->m_ZoneFillsDirty = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
commit.Revert();
|
||||
}
|
||||
reporter->AdvancePhase();
|
||||
reporter->Report( _( "Updating nets..." ) );
|
||||
board()->GetConnectivity()->Build( board(), reporter.get() );
|
||||
|
||||
if( filler.IsDebug() )
|
||||
frame->UpdateUserInterface();
|
||||
commit.Push( _( "Fill Zone(s)" ), true, true, false );
|
||||
frame->m_ZoneFillsDirty = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
commit.Revert();
|
||||
}
|
||||
|
||||
if( filler.IsDebug() )
|
||||
frame->UpdateUserInterface();
|
||||
|
||||
canvas()->Refresh();
|
||||
m_fillInProgress = false;
|
||||
|
@ -208,13 +209,16 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
|||
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
||||
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() );
|
||||
|
||||
if( filler.Fill( toFill ) )
|
||||
{
|
||||
board()->GetConnectivity()->Build( board() );
|
||||
commit.Push( _( "Fill Zone(s)" ), true ); // Allow undoing zone fill
|
||||
reporter->AdvancePhase();
|
||||
reporter->Report( _( "Updating nets..." ) );
|
||||
board()->GetConnectivity()->Build( board(), reporter.get() );
|
||||
|
||||
commit.Push( _( "Fill Zone(s)" ), true, true, false );
|
||||
}
|
||||
else
|
||||
commit.Revert();
|
||||
|
|
Loading…
Reference in New Issue