mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Add wallclock timeout to PNS walkaround
WALKAROUND::singlestep is used by both shove and walkaround modes and can bog down when applied to clusters with many objects. In these cases, we are unlikely to find a viable solution and it is beter to allow the user to find a different ending position (cherry picked from commit d9cfb942812a57238d5ed6bbaa2c1d22a8676071)
This commit is contained in:
parent
5f48e2cbf3
commit
1066595a2c
@ -128,6 +128,7 @@ static const wxChar ExcludeFromSimulationLineWidth[] = wxT( "ExcludeFromSimulati
|
||||
static const wxChar GitIconRefreshInterval[] = wxT( "GitIconRefreshInterval" );
|
||||
static const wxChar ConfigurableToolbars[] = wxT( "ConfigurableToolbars" );
|
||||
static const wxChar MaxPastedTextLength[] = wxT( "MaxPastedTextLength" );
|
||||
static const wxChar PNSProcessClusterTimeout[] = wxT( "PNSProcessClusterTimeout" );
|
||||
|
||||
} // namespace KEYS
|
||||
|
||||
@ -312,6 +313,8 @@ ADVANCED_CFG::ADVANCED_CFG()
|
||||
|
||||
m_MaxPastedTextLength = 100;
|
||||
|
||||
m_PNSProcessClusterTimeout = 100; // Default: 100 ms
|
||||
|
||||
loadFromConfigFile();
|
||||
}
|
||||
|
||||
@ -602,6 +605,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
|
||||
&m_MaxPastedTextLength,
|
||||
m_MaxPastedTextLength, 0, 100000 ) );
|
||||
|
||||
configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::PNSProcessClusterTimeout,
|
||||
&m_PNSProcessClusterTimeout, 100, 10, 10000 ) );
|
||||
|
||||
// Special case for trace mask setting...we just grab them and set them immediately
|
||||
// Because we even use wxLogTrace inside of advanced config
|
||||
wxString traceMasks;
|
||||
|
@ -757,6 +757,15 @@ public:
|
||||
*/
|
||||
int m_MaxPastedTextLength;
|
||||
|
||||
/**
|
||||
* Timeout for the PNS router's processCluster wallclock timeout, in milliseconds.
|
||||
*
|
||||
* Setting name: "PNSProcessClusterTimeoutMs"
|
||||
* Valid values: 10 to 10000
|
||||
* Default value: 100
|
||||
*/
|
||||
int m_PNSProcessClusterTimeout;
|
||||
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
@ -19,6 +19,8 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <advanced_config.h>
|
||||
#include <optional>
|
||||
|
||||
#include <geometry/shape_line_chain.h>
|
||||
@ -138,10 +140,29 @@ bool WALKAROUND::singleStep()
|
||||
|
||||
auto processCluster = [ & ] ( TOPOLOGY::CLUSTER& aCluster, LINE& aLine, bool aCw ) -> bool
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto start_time = steady_clock::now();
|
||||
|
||||
int timeout_ms = ADVANCED_CFG::GetCfg().m_PNSProcessClusterTimeout;
|
||||
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "cluster-details [cw %d]", aCw?1:0 ), 1 );
|
||||
|
||||
for( auto& clItem : aCluster.m_items )
|
||||
{
|
||||
// Check for wallclock timeout
|
||||
// Emprically, 100ms seems to be about where you're not going to find a valid path
|
||||
// if you haven't found it by then. This allows the user to adjust their mouse position
|
||||
// to get a better path without waiting too long.
|
||||
auto now = steady_clock::now();
|
||||
auto elapsed = duration_cast<milliseconds>( now - start_time ).count();
|
||||
|
||||
if( elapsed > timeout_ms )
|
||||
{
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( "processCluster timeout after %d ms", timeout_ms ) );
|
||||
PNS_DBGN( Dbg(), EndGroup );
|
||||
return false;
|
||||
}
|
||||
|
||||
int clearance = m_world->GetClearance( clItem, &aLine, false );
|
||||
SHAPE_LINE_CHAIN hull = clItem->Hull( clearance + 1000, aLine.Width(), aLine.Layer() );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user