2013-09-18 17:55:16 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
2014-05-14 13:53:54 +00:00
|
|
|
* Copyright (C) 2013-2014 CERN
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* 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.
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* 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.
|
2013-09-26 21:53:54 +00:00
|
|
|
*
|
2013-09-18 17:55:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
2014-05-14 13:53:54 +00:00
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2013-09-18 17:55:16 +00:00
|
|
|
*/
|
2013-09-26 21:53:54 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
#ifndef __PNS_ROUTING_SETTINGS
|
|
|
|
#define __PNS_ROUTING_SETTINGS
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-11-14 18:15:58 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/nested_settings.h>
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
#include "time_limit.h"
|
2014-07-09 13:02:56 +00:00
|
|
|
|
|
|
|
class DIRECTION_45;
|
2015-07-02 14:09:51 +00:00
|
|
|
class TOOL_SETTINGS;
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Routing modes
|
2013-09-26 21:53:54 +00:00
|
|
|
enum PNS_MODE
|
|
|
|
{
|
2021-01-27 22:15:38 +00:00
|
|
|
RM_MarkObstacles = 0, ///< Ignore collisions, mark obstacles
|
|
|
|
RM_Shove, ///< Only shove
|
|
|
|
RM_Walkaround, ///< Only walk around
|
|
|
|
RM_Smart ///< Guess what's better, try to make least mess on the PCB
|
2013-09-18 17:55:16 +00:00
|
|
|
};
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Optimization effort.
|
2014-11-14 19:19:00 +00:00
|
|
|
enum PNS_OPTIMIZATION_EFFORT
|
2014-05-14 13:53:54 +00:00
|
|
|
{
|
2014-11-14 19:19:00 +00:00
|
|
|
OE_LOW = 0,
|
2014-05-16 11:37:31 +00:00
|
|
|
OE_MEDIUM = 1,
|
|
|
|
OE_FULL = 2
|
2014-05-14 13:53:54 +00:00
|
|
|
};
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< What kind of corners to create in the line placers.
|
2020-12-30 05:06:49 +00:00
|
|
|
enum class CORNER_MODE
|
|
|
|
{
|
|
|
|
MITERED_90, ///< H/V only (90-degree corners) (not yet implemented)
|
|
|
|
MITERED_45, ///< H/V/45 with mitered corners (default)
|
2020-12-30 23:51:32 +00:00
|
|
|
ROUNDED_90, ///< H/V with filleted corners (not yet implemented)
|
|
|
|
ROUNDED_45 ///< H/V/45 with filleted corners
|
2020-12-30 05:06:49 +00:00
|
|
|
};
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Contain all persistent settings of the router, such as the mode, optimization effort, etc.
|
2014-05-14 13:53:54 +00:00
|
|
|
*/
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
class ROUTING_SETTINGS : public NESTED_SETTINGS
|
2013-09-18 17:55:16 +00:00
|
|
|
{
|
2013-09-26 21:53:54 +00:00
|
|
|
public:
|
2020-01-13 01:44:19 +00:00
|
|
|
ROUTING_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath );
|
2015-07-02 14:09:51 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return the routing mode.
|
2014-05-14 13:53:54 +00:00
|
|
|
PNS_MODE Mode() const { return m_routingMode; }
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Set the routing mode.
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetMode( PNS_MODE aMode ) { m_routingMode = aMode; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return the optimizer effort. Bigger means cleaner traces, but slower routing.
|
2014-05-14 13:53:54 +00:00
|
|
|
PNS_OPTIMIZATION_EFFORT OptimizerEffort() const { return m_optimizerEffort; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Set the optimizer effort. Bigger means cleaner traces, but slower routing.
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetOptimizerEffort( PNS_OPTIMIZATION_EFFORT aEffort ) { m_optimizerEffort = aEffort; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if shoving vias is enabled.
|
2014-05-14 13:53:54 +00:00
|
|
|
bool ShoveVias() const { return m_shoveVias; }
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Enable/disable shoving vias.
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetShoveVias( bool aShoveVias ) { m_shoveVias = aShoveVias; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if loop (redundant track) removal is on.
|
2014-05-14 13:53:54 +00:00
|
|
|
bool RemoveLoops() const { return m_removeLoops; }
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Enable/disable loop (redundant track) removal.
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetRemoveLoops( bool aRemoveLoops ) { m_removeLoops = aRemoveLoops; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if suggesting the finish of currently placed track is on.
|
2014-05-14 13:53:54 +00:00
|
|
|
bool SuggestFinish() { return m_suggestFinish; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Enable displaying suggestions for finishing the currently placed track.
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetSuggestFinish( bool aSuggestFinish ) { m_suggestFinish = aSuggestFinish; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if Smart Pads (optimized connections) is enabled.
|
2017-01-25 09:33:49 +00:00
|
|
|
bool SmartPads() const { return m_smartPads; }
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Enable/disable Smart Pads (optimized connections).
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetSmartPads( bool aSmartPads ) { m_smartPads = aSmartPads; }
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if follow mouse mode is active (permanently on for the moment).
|
2014-11-14 19:19:00 +00:00
|
|
|
bool FollowMouse() const
|
|
|
|
{
|
2014-05-16 11:37:31 +00:00
|
|
|
return m_followMouse && !( Mode() == RM_MarkObstacles );
|
2014-05-14 13:53:54 +00:00
|
|
|
}
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if smoothing segments during dragging is enabled.
|
2014-05-14 13:53:54 +00:00
|
|
|
bool SmoothDraggedSegments() const { return m_smoothDraggedSegments; }
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Enable/disable smoothing segments during dragging.
|
2014-05-14 13:53:54 +00:00
|
|
|
void SetSmoothDraggedSegments( bool aSmooth ) { m_smoothDraggedSegments = aSmooth; }
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Return true if jumping over unmovable obstacles is on.
|
2014-05-14 13:53:54 +00:00
|
|
|
bool JumpOverObstacles() const { return m_jumpOverObstacles; }
|
2021-04-10 09:31:42 +00:00
|
|
|
void SetJumpOverObstacles( bool aJump ) { m_jumpOverObstacles = aJump; }
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2021-04-10 09:31:42 +00:00
|
|
|
void SetStartDiagonal( bool aStartDiagonal ) { m_startDiagonal = aStartDiagonal; }
|
|
|
|
|
|
|
|
bool AllowDRCViolations() const
|
2021-01-27 22:15:38 +00:00
|
|
|
{
|
2021-04-10 09:31:42 +00:00
|
|
|
return m_routingMode == PNS_MODE::RM_MarkObstacles && m_allowDRCViolations;
|
2021-01-27 22:15:38 +00:00
|
|
|
}
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2021-04-10 09:31:42 +00:00
|
|
|
bool GetAllowDRCViolationsSetting() const { return m_allowDRCViolations; }
|
|
|
|
void SetAllowDRCViolations( bool aViolate ) { m_allowDRCViolations = aViolate; }
|
2014-05-14 13:53:54 +00:00
|
|
|
|
2015-07-02 14:09:51 +00:00
|
|
|
bool GetFreeAngleMode() const { return m_freeAngleMode; }
|
|
|
|
|
|
|
|
void SetFreeAngleMode( bool aEnable ) { m_freeAngleMode = aEnable; }
|
|
|
|
|
2014-07-09 13:02:56 +00:00
|
|
|
const DIRECTION_45 InitialDirection() const;
|
2014-05-14 13:53:54 +00:00
|
|
|
|
|
|
|
int ShoveIterationLimit() const;
|
|
|
|
TIME_LIMIT ShoveTimeLimit() const;
|
|
|
|
|
|
|
|
int WalkaroundIterationLimit() const { return m_walkaroundIterationLimit; };
|
|
|
|
TIME_LIMIT WalkaroundTimeLimit() const;
|
|
|
|
|
2015-07-02 14:10:07 +00:00
|
|
|
void SetInlineDragEnabled ( bool aEnable ) { m_inlineDragEnabled = aEnable; }
|
2017-01-25 09:33:49 +00:00
|
|
|
bool InlineDragEnabled() const { return m_inlineDragEnabled; }
|
2015-07-02 14:10:07 +00:00
|
|
|
|
2017-08-03 15:53:07 +00:00
|
|
|
void SetSnapToTracks( bool aSnap ) { m_snapToTracks = aSnap; }
|
|
|
|
void SetSnapToPads( bool aSnap ) { m_snapToPads = aSnap; }
|
|
|
|
|
|
|
|
bool GetSnapToTracks() const { return m_snapToTracks; }
|
|
|
|
bool GetSnapToPads() const { return m_snapToPads; }
|
|
|
|
|
2020-12-30 05:06:49 +00:00
|
|
|
CORNER_MODE GetCornerMode() const { return m_cornerMode; }
|
|
|
|
void SetCornerMode( CORNER_MODE aMode ) { m_cornerMode = aMode; }
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2021-04-10 19:17:29 +00:00
|
|
|
bool GetOptimizeEntireDraggedTrack() const { return m_optimizeEntireDraggedTrack; }
|
|
|
|
void SetOptimizeEntireDraggedTrack( bool aEnable ) { m_optimizeEntireDraggedTrack = aEnable; }
|
2020-02-27 21:02:45 +00:00
|
|
|
|
2020-12-23 22:02:29 +00:00
|
|
|
bool GetAutoPosture() const { return m_autoPosture; }
|
|
|
|
void SetAutoPosture( bool aEnable ) { m_autoPosture = aEnable; }
|
|
|
|
|
2020-12-24 02:55:43 +00:00
|
|
|
bool GetFixAllSegments() const { return m_fixAllSegments; }
|
|
|
|
void SetFixAllSegments( bool aEnable ) { m_fixAllSegments = aEnable; }
|
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
private:
|
|
|
|
bool m_shoveVias;
|
|
|
|
bool m_startDiagonal;
|
2013-09-26 21:53:54 +00:00
|
|
|
bool m_removeLoops;
|
|
|
|
bool m_smartPads;
|
2014-05-14 13:53:54 +00:00
|
|
|
bool m_suggestFinish;
|
2013-09-26 21:53:54 +00:00
|
|
|
bool m_followMouse;
|
2014-05-14 13:53:54 +00:00
|
|
|
bool m_jumpOverObstacles;
|
|
|
|
bool m_smoothDraggedSegments;
|
2021-04-10 09:31:42 +00:00
|
|
|
bool m_allowDRCViolations;
|
2015-07-02 14:09:51 +00:00
|
|
|
bool m_freeAngleMode;
|
2015-07-02 14:10:07 +00:00
|
|
|
bool m_inlineDragEnabled;
|
2017-08-03 15:53:07 +00:00
|
|
|
bool m_snapToTracks;
|
|
|
|
bool m_snapToPads;
|
2021-04-10 19:17:29 +00:00
|
|
|
bool m_optimizeEntireDraggedTrack;
|
2020-12-23 22:02:29 +00:00
|
|
|
bool m_autoPosture;
|
2020-12-24 02:55:43 +00:00
|
|
|
bool m_fixAllSegments;
|
2019-05-17 00:13:21 +00:00
|
|
|
|
2020-12-30 05:06:49 +00:00
|
|
|
CORNER_MODE m_cornerMode;
|
2013-09-18 17:55:16 +00:00
|
|
|
|
2014-05-14 13:53:54 +00:00
|
|
|
PNS_MODE m_routingMode;
|
|
|
|
PNS_OPTIMIZATION_EFFORT m_optimizerEffort;
|
2014-11-14 19:19:00 +00:00
|
|
|
|
2013-09-26 21:53:54 +00:00
|
|
|
int m_walkaroundIterationLimit;
|
|
|
|
int m_shoveIterationLimit;
|
2014-05-14 13:53:54 +00:00
|
|
|
TIME_LIMIT m_shoveTimeLimit;
|
|
|
|
TIME_LIMIT m_walkaroundTimeLimit;
|
2013-09-18 17:55:16 +00:00
|
|
|
};
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
}
|
|
|
|
|
2013-09-18 17:55:16 +00:00
|
|
|
#endif
|