KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_block_dragger.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef __PNS_BLOCK_DRAGGER_H
21#define __PNS_BLOCK_DRAGGER_H
22
23#include <set>
24#include <unordered_set>
25#include <vector>
26
27#include <math/vector2d.h>
28
29#include "pns_drag_algo.h"
30
31namespace PNS
32{
33class ROUTER;
34
52{
53public:
54 BLOCK_DRAGGER( ROUTER* aRouter );
56
64 bool Start( const VECTOR2I& aP, ITEM_SET& aPrimitives ) override;
65
71 bool Drag( const VECTOR2I& aP ) override;
72
78 bool FixRoute( bool aForceCommit ) override;
79
81 NODE* CurrentNode() const override;
82
84 const std::vector<NET_HANDLE> CurrentNets() const override { return std::vector<NET_HANDLE>(); }
85
87 virtual int CurrentLayer() const override { return UNDEFINED_LAYER; }
88
90 const ITEM_SET Traces() override;
91
93 const std::vector<LINE>& AnchoredLines() const { return m_anchoredLines; }
94
95 void SetMode( PNS::DRAG_MODE aDragMode ) override { m_mode = aDragMode; }
96
97 virtual PNS::DRAG_MODE Mode() const override { return m_mode; }
98
99 bool GetForceMarkObstaclesMode( bool* aDragStatus ) const override
100 {
101 *aDragStatus = m_dragStatus;
102 return true;
103 }
104
105private:
112
114 bool isFixedByLock( ITEM* aItem ) const;
115
117 bool isPinned( const JOINT* aJoint, const LINE& aOwnLine ) const;
118
120 bool isHeldByBlock( const JOINT* aJoint ) const;
121
124 bool coveredBySolid( const JOINT* aJoint, bool aSelected ) const;
125
127 bool isBlockBoundary( const JOINT* aJoint ) const;
128
130 static LINE wrapLink( LINKED_ITEM* aLink );
131
133 void classifySelectedLink( LINKED_ITEM* aLink );
134
136 void clipToBlock( LINE& aLine, const VECTOR2I& aEntry, LINKED_ITEM* aLink ) const;
137
139 void classifyNeighbour( const JOINT* aJoint, LINKED_ITEM* aLink );
140
142 void scanJoint( const JOINT* aJoint );
143
145 void scanRigidItem( ITEM* aItem );
146
148 void displaceItem( ITEM* aItem, const VECTOR2I& aDelta );
149
150 std::set<ITEM*> m_rigidItems;
151 std::set<ITEM*> m_bridgeItems;
152 std::vector<DRAGGED_CONNECTION> m_conns;
153 std::vector<LINE> m_anchoredLines;
154
155 // Working state of Start()
156 std::unordered_set<ITEM*> m_selectedLinks;
157 std::unordered_set<LINKED_ITEM*> m_seenLinks;
158 std::set<const JOINT*> m_carriedJoints;
159
165};
166
167}; // namespace PNS
168
169#endif
void clipToBlock(LINE &aLine, const VECTOR2I &aEntry, LINKED_ITEM *aLink) const
Cut an assembled line back to the stretch between aEntry and the first block joint.
BLOCK_DRAGGER(ROUTER *aRouter)
std::set< const JOINT * > m_carriedJoints
Ends of selected copper that travel.
void SetMode(PNS::DRAG_MODE aDragMode) override
bool GetForceMarkObstaclesMode(bool *aDragStatus) const override
bool Start(const VECTOR2I &aP, ITEM_SET &aPrimitives) override
Sort the selection and the unselected copper touching it.
bool isBlockBoundary(const JOINT *aJoint) const
Copper at this joint is already sorted, so a walk stops here.
void scanRigidItem(ITEM *aItem)
Sort the copper touching a selected pad or via.
bool isHeldByBlock(const JOINT *aJoint) const
A selected pad or via sits on this joint.
virtual int CurrentLayer() const override
Unused for block dragging.
bool isPinned(const JOINT *aJoint, const LINE &aOwnLine) const
Held in place by something outside the block. Links of aOwnLine do not count.
const std::vector< LINE > & AnchoredLines() const
Selected arcs held at both ends, which cannot move.
std::vector< DRAGGED_CONNECTION > m_conns
Copper rerouted to follow the block.
std::unordered_set< ITEM * > m_selectedLinks
Selected segments and arcs.
std::vector< LINE > m_anchoredLines
Selected arcs that cannot move.
static LINE wrapLink(LINKED_ITEM *aLink)
A one link line, so no unselected copper is assembled into a selected segment.
void classifyNeighbour(const JOINT *aJoint, LINKED_ITEM *aLink)
Sort unselected copper that touches the block at aJoint.
std::set< ITEM * > m_bridgeItems
Copper displaced whole with the block.
bool isFixedByLock(ITEM *aItem) const
Unselected and locked, so it neither moves nor is rerouted.
bool Drag(const VECTOR2I &aP) override
Rebuild the block at aP: displace rigid and bridge items, reroute connections.
void displaceItem(ITEM *aItem, const VECTOR2I &aDelta)
Replace aItem in the current branch with a copy moved by aDelta.
NODE * CurrentNode() const override
The current branch, or the world before the first Drag().
std::set< ITEM * > m_rigidItems
Selected pads and vias.
void classifySelectedLink(LINKED_ITEM *aLink)
Sort a selected segment or arc by what holds its ends.
const ITEM_SET Traces() override
Everything displaced or rerouted by the last Drag().
virtual PNS::DRAG_MODE Mode() const override
const std::vector< NET_HANDLE > CurrentNets() const override
Unused for block dragging.
void scanJoint(const JOINT *aJoint)
Sort every unselected segment and arc on a joint.
std::unordered_set< LINKED_ITEM * > m_seenLinks
Already sorted.
bool FixRoute(bool aForceCommit) override
Commit the current branch if it is collision free or aForceCommit is set.
bool coveredBySolid(const JOINT *aJoint, bool aSelected) const
A pad covers more than its anchor, so ask what really sits on the joint.
DRAG_ALGO(ROUTER *aRouter)
Base class for PNS router board items.
Definition pns_item.h:98
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
Definition pns_joint.h:43
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
@ UNDEFINED_LAYER
Definition layer_ids.h:57
Push and Shove diff pair dimensions (gap) settings dialog.
DRAG_MODE
Definition pns_router.h:77
VECTOR2I p_orig
The corner that follows the block, or a body point.
bool dragBody
Both ends held, the body moves and the ends reroute.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708