2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 CERN
|
2023-08-22 12:06:33 +00:00
|
|
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-18 00:29: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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PNS_PLACEMENT_ALGO_H
|
|
|
|
#define __PNS_PLACEMENT_ALGO_H
|
|
|
|
|
|
|
|
#include <math/vector2d.h>
|
|
|
|
|
|
|
|
#include "pns_algo_base.h"
|
|
|
|
#include "pns_sizes_settings.h"
|
|
|
|
#include "pns_itemset.h"
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class ROUTER;
|
|
|
|
class ITEM;
|
|
|
|
class NODE;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* PLACEMENT_ALGO
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
2015-02-18 16:53:46 +00:00
|
|
|
* Abstract class for a P&S placement/dragging algorithm.
|
2015-02-18 00:29:54 +00:00
|
|
|
* All subtools (drag, single/diff pair routing and meandering)
|
|
|
|
* are derived from it.
|
|
|
|
*/
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
class PLACEMENT_ALGO : public ALGO_BASE
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-08-29 17:31:13 +00:00
|
|
|
PLACEMENT_ALGO( ROUTER* aRouter ) :
|
|
|
|
ALGO_BASE( aRouter ) {};
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual ~PLACEMENT_ALGO () {};
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Start()
|
|
|
|
*
|
|
|
|
* Starts placement/drag operation at point aP, taking item aStartItem as anchor
|
|
|
|
* (unless NULL).
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual bool Start( const VECTOR2I& aP, ITEM* aStartItem ) = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Move()
|
|
|
|
*
|
|
|
|
* Moves the end of the currently routed primtive(s) to the point aP, taking
|
|
|
|
* aEndItem as the anchor (if not NULL).
|
|
|
|
* (unless NULL).
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual bool Move( const VECTOR2I& aP, ITEM* aEndItem ) = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function FixRoute()
|
|
|
|
*
|
|
|
|
* Commits the currently routed items to the parent node, taking
|
|
|
|
* aP as the final end point and aEndItem as the final anchor (if provided).
|
2021-06-09 19:32:58 +00:00
|
|
|
* @return true, if route has been committed. May return false if the routing
|
2015-02-18 00:29:54 +00:00
|
|
|
* result is violating design rules - in such case, the track is only committed
|
|
|
|
* if Settings.CanViolateDRC() is on.
|
|
|
|
*/
|
2018-06-19 17:29:36 +00:00
|
|
|
virtual bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish = false ) = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2023-06-19 16:09:03 +00:00
|
|
|
virtual std::optional<VECTOR2I> UnfixRoute() { return std::nullopt; };
|
2020-02-07 19:57:24 +00:00
|
|
|
|
|
|
|
virtual bool CommitPlacement() { return false; };
|
|
|
|
|
|
|
|
virtual bool AbortPlacement() { return false; };
|
|
|
|
|
|
|
|
virtual bool HasPlacedAnything() const { return false; }
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
|
|
|
* Function ToggleVia()
|
|
|
|
*
|
|
|
|
* Enables/disables a via at the end of currently routed trace.
|
|
|
|
*/
|
|
|
|
virtual bool ToggleVia( bool aEnabled )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsPlacingVia()
|
|
|
|
*
|
|
|
|
* Returns true if the placer is placing a via (or more vias).
|
|
|
|
*/
|
2015-02-18 16:53:46 +00:00
|
|
|
virtual bool IsPlacingVia() const
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetLayer()
|
|
|
|
*
|
|
|
|
* Sets the current routing layer.
|
|
|
|
*/
|
|
|
|
virtual bool SetLayer( int aLayer )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Traces()
|
|
|
|
*
|
|
|
|
* Returns all routed/tuned traces.
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual const ITEM_SET Traces() = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2022-09-12 19:43:36 +00:00
|
|
|
/**
|
|
|
|
* Function CurrentStart()
|
|
|
|
*
|
|
|
|
* Returns the current start of the line(s) being placed/tuned.
|
|
|
|
*/
|
|
|
|
virtual const VECTOR2I& CurrentStart() const = 0;
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
|
|
|
* Function CurrentEnd()
|
|
|
|
*
|
2015-08-21 14:35:34 +00:00
|
|
|
* Returns the current end of the line(s) being placed/tuned. It may not be equal
|
2015-02-18 00:29:54 +00:00
|
|
|
* to the cursor position due to collisions.
|
|
|
|
*/
|
|
|
|
virtual const VECTOR2I& CurrentEnd() const = 0;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
2015-08-21 14:35:34 +00:00
|
|
|
* Function CurrentNets()
|
2015-02-18 00:29:54 +00:00
|
|
|
*
|
2023-08-22 12:06:33 +00:00
|
|
|
* Returns the net(s) of currently routed track(s).
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2023-08-22 12:06:33 +00:00
|
|
|
virtual const std::vector<NET_HANDLE> CurrentNets() const = 0;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
/**
|
|
|
|
* Function CurrentLayer()
|
|
|
|
*
|
|
|
|
* Returns the layer of currently routed track.
|
|
|
|
*/
|
|
|
|
virtual int CurrentLayer() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CurrentNode()
|
|
|
|
*
|
|
|
|
* Returns the most recent board state.
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual NODE* CurrentNode( bool aLoopsRemoved = false ) const = 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function FlipPosture()
|
|
|
|
*
|
|
|
|
* Toggles the current posture (straight/diagonal) of the trace head.
|
|
|
|
*/
|
2015-02-18 16:53:46 +00:00
|
|
|
virtual void FlipPosture()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function UpdateSizes()
|
|
|
|
*
|
|
|
|
* Performs on-the-fly update of the width, via diameter & drill size from
|
|
|
|
* a settings class. Used to dynamically change these parameters as
|
|
|
|
* the track is routed.
|
|
|
|
*/
|
2016-08-29 17:31:13 +00:00
|
|
|
virtual void UpdateSizes( const SIZES_SETTINGS& aSizes )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetOrthoMode()
|
2015-02-18 16:53:46 +00:00
|
|
|
*
|
2015-02-18 00:29:54 +00:00
|
|
|
* Forces the router to place a straight 90/45 degree trace (with the end
|
|
|
|
* as near to the cursor as possible) instead of a standard 135 degree
|
|
|
|
* two-segment bend.
|
|
|
|
*/
|
|
|
|
virtual void SetOrthoMode ( bool aOrthoMode )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetModifiedNets
|
|
|
|
*
|
2023-08-22 12:06:33 +00:00
|
|
|
* Returns the nets of all currently routed trace(s)
|
2015-02-18 00:29:54 +00:00
|
|
|
*/
|
2023-08-22 12:06:33 +00:00
|
|
|
virtual void GetModifiedNets( std::vector<NET_HANDLE> &aNets ) const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
#endif
|