KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_multi_dragger.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 * Author: Tomasz Wlostowski <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __PNS_MULTI_DRAGGER_H
22#define __PNS_MULTI_DRAGGER_H
23
24#include <memory>
25#include <math/vector2d.h>
26
27#include "pns_node.h"
28#include "pns_via.h"
29#include "pns_line.h"
30#include "pns_drag_algo.h"
31#include "pns_itemset.h"
32#include "pns_layerset.h"
34
35namespace PNS {
36
37class ROUTER;
38class SHOVE;
39class OPTIMIZER;
40
47{
48public:
49 MULTI_DRAGGER( ROUTER* aRouter );
51
58 virtual bool Start( const VECTOR2I& aP, ITEM_SET& aPrimitives ) override;
59
66 bool Drag( const VECTOR2I& aP ) override;
67
75 bool FixRoute( bool aForceCommit ) override;
76
83 NODE* CurrentNode() const override;
84
90 const std::vector<NET_HANDLE> CurrentNets() const override;
91
97 int CurrentLayer() const override;
98
104 const ITEM_SET Traces() override;
105
106 void SetMode( PNS::DRAG_MODE aDragMode ) override;
107
108 PNS::DRAG_MODE Mode() const override;
109
110// Use case: we are dragging multiple tracks. The router erases a few of them, adds a few new ones. For the ease of use, it would be good for the tracks the be still selected when
111// the drag operation is completed. This method returns a set of the 'leader' (segments/arcs that have been selected for multi-fragging)
112 virtual std::vector<PNS::ITEM*> GetLastCommittedLeaderSegments() override { return m_leaderSegments; };
113
114 virtual bool GetForceMarkObstaclesMode( bool* aDragStatus ) const override
115 {
116 *aDragStatus = m_dragStatus;
117 return false;
118 }
119
120
121
122private:
123
124
125
126
128 {
129
130 ITEM* leaderItem = nullptr;
131 std::vector<PNS::ITEM*> originalLeaders;
132
133
134 bool isStrict = false;
135 bool isMidSeg = false;
136 bool isCorner = false;
137 bool isDraggable = false;
138
140 bool cornerIsLast = false;
141
142 PNS::LINE originalLine; // complete line (in a bundle) to drag
143 PNS::LINE preDragLine; // complete line (in a bundle) to drag
144 PNS::LINE draggedLine; // result of the drag calculation
145 PNS::LINE preShoveLine; // result of the drag calculation
146 bool dragOK = false;
147 bool isPrimaryLine = false; // when true, it's the "leader"/"primary one" - the one the cursor is attached to
148 bool clipDone = false;
149 int offset; // distance between this line and the primary one (only applicable if the respective end segments are parallel)
151// VECTOR2I dragAnchor;
154 };
155
156 bool multidragMarkObstacles ( std::vector<MDRAG_LINE>& aCompletedLines );
157 bool multidragShove ( std::vector<MDRAG_LINE>& aCompletedLines );
158 bool multidragWalkaround ( std::vector<MDRAG_LINE>& aCompletedLines );
159 void restoreLeaderSegments( std::vector<MDRAG_LINE>& aCompletedLines );
160 int findNewLeaderSegment( const MDRAG_LINE& aLine ) const;
161 bool tryWalkaround( NODE* aNode, LINE& aOrig, LINE& aWalk );
162
163
168 std::vector<MDRAG_LINE> m_mdragLines;
169 std::vector<PNS::ITEM*> m_leaderSegments;
176 std::unique_ptr<SHOVE> m_shove;
177
178};
179
180}
181
182#endif
DRAG_ALGO.
Definition: pns_drag_algo.h:44
Base class for PNS router board items.
Definition: pns_item.h:97
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:62
bool multidragShove(std::vector< MDRAG_LINE > &aCompletedLines)
bool multidragMarkObstacles(std::vector< MDRAG_LINE > &aCompletedLines)
virtual bool GetForceMarkObstaclesMode(bool *aDragStatus) const override
std::vector< PNS::ITEM * > m_leaderSegments
virtual bool Start(const VECTOR2I &aP, ITEM_SET &aPrimitives) override
Function Start()
bool FixRoute(bool aForceCommit) override
Function FixRoute()
bool Drag(const VECTOR2I &aP) override
Function Drag()
int CurrentLayer() const override
Function CurrentLayer()
NODE * CurrentNode() const override
Function CurrentNode()
std::vector< MDRAG_LINE > m_mdragLines
bool tryWalkaround(NODE *aNode, LINE &aOrig, LINE &aWalk)
void SetMode(PNS::DRAG_MODE aDragMode) override
int findNewLeaderSegment(const MDRAG_LINE &aLine) const
void restoreLeaderSegments(std::vector< MDRAG_LINE > &aCompletedLines)
virtual std::vector< PNS::ITEM * > GetLastCommittedLeaderSegments() override
bool multidragWalkaround(std::vector< MDRAG_LINE > &aCompletedLines)
const ITEM_SET Traces() override
Function Traces()
const std::vector< NET_HANDLE > CurrentNets() const override
Function CurrentNets()
PNS::DRAG_MODE Mode() const override
std::unique_ptr< SHOVE > m_shove
Keep the router "world" - i.e.
Definition: pns_node.h:231
Definition: seg.h:42
Push and Shove diff pair dimensions (gap) settings dialog.
PNS_MODE
< Routing modes
DRAG_MODE
Definition: pns_router.h:71
std::vector< PNS::ITEM * > originalLeaders