2014-05-14 13:53:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 CERN
|
2016-08-29 14:38:11 +00:00
|
|
|
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-05-14 13:53:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-03-22 12:35:07 +00:00
|
|
|
#include <geometry/direction45.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/parameters.h>
|
2017-03-22 12:35:07 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
#include "pns_routing_settings.h"
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
const int pnsSchemaVersion = 0;
|
|
|
|
|
|
|
|
|
|
|
|
ROUTING_SETTINGS::ROUTING_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
|
|
|
NESTED_SETTINGS( "pns", pnsSchemaVersion, aParent, aPath )
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
m_routingMode = RM_Walkaround;
|
2015-02-18 00:29:54 +00:00
|
|
|
m_optimizerEffort = OE_MEDIUM;
|
2014-05-14 13:53:54 +00:00
|
|
|
m_removeLoops = true;
|
|
|
|
m_smartPads = true;
|
|
|
|
m_shoveVias = true;
|
|
|
|
m_suggestFinish = false;
|
|
|
|
m_followMouse = true;
|
|
|
|
m_startDiagonal = false;
|
|
|
|
m_shoveIterationLimit = 250;
|
|
|
|
m_shoveTimeLimit = 1000;
|
|
|
|
m_walkaroundIterationLimit = 40;
|
|
|
|
m_jumpOverObstacles = false;
|
|
|
|
m_smoothDraggedSegments = true;
|
2021-04-10 09:31:42 +00:00
|
|
|
m_allowDRCViolations = false;
|
2015-07-02 14:09:51 +00:00
|
|
|
m_freeAngleMode = false;
|
2015-07-02 14:10:07 +00:00
|
|
|
m_inlineDragEnabled = false;
|
2017-08-03 15:53:07 +00:00
|
|
|
m_snapToTracks = false;
|
|
|
|
m_snapToPads = false;
|
2021-04-10 19:17:29 +00:00
|
|
|
m_optimizeEntireDraggedTrack = false;
|
2020-12-30 05:06:49 +00:00
|
|
|
m_cornerMode = CORNER_MODE::MITERED_45;
|
2021-05-27 22:08:31 +00:00
|
|
|
m_walkaroundHugLengthThreshold = 1.5;
|
2020-12-23 22:02:29 +00:00
|
|
|
m_autoPosture = true;
|
2020-12-24 02:55:43 +00:00
|
|
|
m_fixAllSegments = true;
|
2015-07-02 14:11:15 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "mode", reinterpret_cast<int*>( &m_routingMode ),
|
|
|
|
static_cast<int>( RM_Walkaround ) ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<int>( "effort", reinterpret_cast<int*>( &m_optimizerEffort ),
|
|
|
|
static_cast<int>( OE_MEDIUM ) ) );
|
|
|
|
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "remove_loops", &m_removeLoops, true ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "smart_pads", &m_smartPads, true ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "shove_vias", &m_shoveVias, true ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "suggest_finish", &m_suggestFinish, false ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "follow_mouse", &m_followMouse, true ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "start_diagonal", &m_startDiagonal, false ) );
|
|
|
|
m_params.emplace_back( new PARAM<int>( "shove_iteration_limit", &m_shoveIterationLimit, 250 ) );
|
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
m_params.emplace_back( new PARAM_LAMBDA<int>( "shove_time_limit",
|
|
|
|
[this] () -> int
|
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
return m_shoveTimeLimit.Get();
|
2020-05-08 18:10:47 +00:00
|
|
|
},
|
|
|
|
[this] ( int aVal )
|
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
m_shoveTimeLimit.Set( aVal );
|
2020-05-08 18:10:47 +00:00
|
|
|
},
|
|
|
|
1000 ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
m_params.emplace_back( new PARAM<int>( "walkaround_iteration_limit", &m_walkaroundIterationLimit, 40 ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "jump_over_obstacles", &m_jumpOverObstacles, false ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-05-08 18:10:47 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "smooth_dragged_segments", &m_smoothDraggedSegments, true ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-04-10 09:31:42 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "can_violate_drc", &m_allowDRCViolations, false ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "free_angle_mode", &m_freeAngleMode, false ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "inline_drag", &m_inlineDragEnabled, false ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "snap_to_tracks", &m_snapToTracks, false ) );
|
|
|
|
m_params.emplace_back( new PARAM<bool>( "snap_to_pads", &m_snapToPads, false ) );
|
2021-04-10 19:17:29 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "optimize_dragged_track",
|
|
|
|
&m_optimizeEntireDraggedTrack, false ) );
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2020-12-23 22:02:29 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "auto_posture", &m_autoPosture, true ) );
|
2020-12-24 02:55:43 +00:00
|
|
|
m_params.emplace_back( new PARAM<bool>( "fix_all_segments", &m_fixAllSegments, true ) );
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2020-12-30 05:06:49 +00:00
|
|
|
m_params.emplace_back( new PARAM_ENUM<CORNER_MODE>( "corner_mode", &m_cornerMode,
|
|
|
|
CORNER_MODE::MITERED_45, CORNER_MODE::ROUNDED_90,
|
|
|
|
CORNER_MODE::MITERED_45 ) );
|
|
|
|
|
2021-05-27 22:08:31 +00:00
|
|
|
m_params.emplace_back( new PARAM<double>( "walkaround_hug_length_threshold", &m_walkaroundHugLengthThreshold, 1.5 ) );
|
|
|
|
|
2020-02-26 00:36:36 +00:00
|
|
|
LoadFromFile();
|
2015-07-02 14:09:51 +00:00
|
|
|
}
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2015-07-02 14:11:15 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const DIRECTION_45 ROUTING_SETTINGS::InitialDirection() const
|
2014-07-09 13:02:56 +00:00
|
|
|
{
|
|
|
|
if( m_startDiagonal )
|
|
|
|
return DIRECTION_45( DIRECTION_45::NE );
|
|
|
|
else
|
|
|
|
return DIRECTION_45( DIRECTION_45::N );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
TIME_LIMIT ROUTING_SETTINGS::ShoveTimeLimit() const
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
return TIME_LIMIT ( m_shoveTimeLimit );
|
|
|
|
}
|
|
|
|
|
2014-05-16 11:37:31 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
int ROUTING_SETTINGS::ShoveIterationLimit() const
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
|
|
|
return m_shoveIterationLimit;
|
|
|
|
}
|
2016-08-29 14:38:11 +00:00
|
|
|
|
|
|
|
}
|