KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_placement_algo.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2014 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef __PNS_PLACEMENT_ALGO_H
23#define __PNS_PLACEMENT_ALGO_H
24
25#include <math/vector2d.h>
26
27#include "pns_algo_base.h"
28#include "pns_sizes_settings.h"
29#include "pns_itemset.h"
30
31namespace PNS {
32
33class ROUTER;
34class ITEM;
35class NODE;
36
42
44{
45public:
46 PLACEMENT_ALGO( ROUTER* aRouter ) :
47 ALGO_BASE( aRouter ) {};
48
49 virtual ~PLACEMENT_ALGO () {};
50
55 virtual bool Start( const VECTOR2I& aP, ITEM* aStartItem ) = 0;
56
62 virtual bool Move( const VECTOR2I& aP, ITEM* aEndItem ) = 0;
63
71 virtual bool FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish = false ) = 0;
72
73 virtual std::optional<VECTOR2I> UnfixRoute() { return std::nullopt; };
74
75 virtual bool CommitPlacement() { return false; };
76
77 virtual bool AbortPlacement() { return false; };
78
79 virtual bool HasPlacedAnything() const { return false; }
80
84 virtual bool ToggleVia( bool aEnabled )
85 {
86 return false;
87 }
88
92 virtual bool IsPlacingVia() const
93 {
94 return false;
95 }
96
100 virtual bool SetLayer( int aLayer )
101 {
102 return false;
103 }
104
108 virtual const ITEM_SET Traces() = 0;
109
113 virtual const VECTOR2I& CurrentStart() const = 0;
114
119 virtual const VECTOR2I& CurrentEnd() const = 0;
120
124 virtual const std::vector<NET_HANDLE> CurrentNets() const = 0;
125
129 virtual int CurrentLayer() const = 0;
130
134 virtual NODE* CurrentNode( bool aLoopsRemoved = false ) const = 0;
135
139 virtual void FlipPosture()
140 {
141 }
142
148 virtual void UpdateSizes( const SIZES_SETTINGS& aSizes )
149 {
150 }
151
157 virtual void SetOrthoMode ( bool aOrthoMode )
158 {
159 }
160
164 virtual void GetModifiedNets( std::vector<NET_HANDLE> &aNets ) const
165 {
166 }
167
168protected:
169 virtual bool removeLoops( NODE* aNode, LINE& aLatest );
170
176 virtual bool simplifyNewLine( NODE* aNode, LINKED_ITEM* aLatest );
177
178};
179
180}
181
182#endif
ALGO_BASE(ROUTER *aRouter)
Base class for PNS router board items.
Definition pns_item.h:98
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:62
Keep the router "world" - i.e.
Definition pns_node.h:244
virtual NODE * CurrentNode(bool aLoopsRemoved=false) const =0
Return the most recent board state.
virtual bool removeLoops(NODE *aNode, LINE &aLatest)
virtual bool IsPlacingVia() const
Return true if the placer is placing a via (or more vias).
virtual bool CommitPlacement()
virtual void FlipPosture()
Toggle the current posture (straight/diagonal) of the trace head.
virtual const VECTOR2I & CurrentEnd() const =0
Return the current end of the line(s) being placed/tuned.
virtual const ITEM_SET Traces()=0
Return all routed/tuned traces.
virtual bool Start(const VECTOR2I &aP, ITEM *aStartItem)=0
Start placement/drag operation at point aP, taking item aStartItem as anchor (unless NULL).
virtual bool HasPlacedAnything() const
PLACEMENT_ALGO(ROUTER *aRouter)
virtual bool simplifyNewLine(NODE *aNode, LINKED_ITEM *aLatest)
Assemble a line starting from segment or arc aLatest, removes collinear segments and redundant vertic...
virtual bool AbortPlacement()
virtual bool Move(const VECTOR2I &aP, ITEM *aEndItem)=0
Move the end of the currently routed primtive(s) to the point aP, taking aEndItem as the anchor (if n...
virtual const VECTOR2I & CurrentStart() const =0
Return the current start of the line(s) being placed/tuned.
virtual int CurrentLayer() const =0
Return the layer of currently routed track.
virtual void SetOrthoMode(bool aOrthoMode)
Force the router to place a straight 90/45 degree trace (with the end as near to the cursor as possib...
virtual void GetModifiedNets(std::vector< NET_HANDLE > &aNets) const
Return the nets of all currently routed trace(s)
virtual const std::vector< NET_HANDLE > CurrentNets() const =0
Returns the net(s) of currently routed track(s).
virtual bool ToggleVia(bool aEnabled)
Enable/disable a via at the end of currently routed trace.
virtual std::optional< VECTOR2I > UnfixRoute()
virtual bool SetLayer(int aLayer)
Set the current routing layer.
virtual void UpdateSizes(const SIZES_SETTINGS &aSizes)
Perform on-the-fly update of the width, via diameter & drill size from a settings class.
virtual bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish=false)=0
Commit the currently routed items to the parent node, taking aP as the final end point and aEndItem a...
Push and Shove diff pair dimensions (gap) settings dialog.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708