KiCad PCB EDA Suite
pns_dragger.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 (C) 2016 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 along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef __PNS_DRAGGER_H
23 #define __PNS_DRAGGER_H
24 
25 #include <memory>
26 #include <math/vector2d.h>
27 
28 #include "pns_node.h"
29 #include "pns_via.h"
30 #include "pns_line.h"
31 #include "pns_drag_algo.h"
32 #include "pns_itemset.h"
33 #include "pns_layerset.h"
34 #include "pns_mouse_trail_tracer.h"
35 
36 namespace PNS {
37 
38 class ROUTER;
39 class SHOVE;
40 class OPTIMIZER;
41 
47 class DRAGGER : public DRAG_ALGO
48 {
49 public:
50  DRAGGER( ROUTER* aRouter );
51  ~DRAGGER();
52 
59  virtual bool Start( const VECTOR2I& aP, ITEM_SET& aPrimitives ) override;
60 
67  bool Drag( const VECTOR2I& aP ) override;
68 
76  bool FixRoute() override;
77 
84  NODE* CurrentNode() const override;
85 
91  const std::vector<int> CurrentNets() const override
92  {
93  return std::vector<int>( 1, m_draggedLine.Net() );
94  }
95 
101  int CurrentLayer() const override
102  {
103  return m_draggedLine.Layer();
104  }
105 
111  const ITEM_SET Traces() override;
112 
113  void SetMode( int aDragMode ) override;
114 
115 private:
116  const ITEM_SET findViaFanoutByHandle ( NODE *aNode, const VIA_HANDLE& handle );
117 
118  bool dragMarkObstacles( const VECTOR2I& aP );
119  bool dragShove(const VECTOR2I& aP );
120  bool dragWalkaround(const VECTOR2I& aP );
121  bool startDragSegment( const VECTOR2D& aP, SEGMENT* aSeg );
122  bool startDragArc( const VECTOR2D& aP, ARC* aArc );
123  bool startDragVia( VIA* aVia );
124  bool dragViaMarkObstacles( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP );
125  bool dragViaWalkaround( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP );
126  void optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, const VECTOR2I& aP );
127  bool propagateViaForces( NODE* node, std::set<VIA*>& vias );
128  bool tryWalkaround( NODE* aNode, LINE& aOrig, LINE& aWalk );
129  VVIA* checkVirtualVia( const VECTOR2D& aP, SEGMENT* aSeg );
130 
131 
134 
136  int m_mode;
139  std::unique_ptr<SHOVE> m_shove;
145 
148 
152 };
153 
154 }
155 
156 #endif
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:147
bool Drag(const VECTOR2I &aP) override
Function Drag()
int CurrentLayer() const override
Function CurrentLayer()
Definition: pns_dragger.h:101
bool tryWalkaround(NODE *aNode, LINE &aOrig, LINE &aWalk)
virtual int Layer() const
Definition: pns_item.h:158
Keep the router "world" - i.e.
Definition: pns_node.h:146
bool propagateViaForces(NODE *node, std::set< VIA * > &vias)
Definition: pns_dragger.cpp:52
PNS_MODE
< Routing modes
DRAGGER(ROUTER *aRouter)
Definition: pns_dragger.cpp:32
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:139
DRAG_ALGO.
Definition: pns_drag_algo.h:42
bool m_dragStatus
Definition: pns_dragger.h:141
void optimizeAndUpdateDraggedLine(LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
bool startDragSegment(const VECTOR2D &aP, SEGMENT *aSeg)
VIA_HANDLE m_draggedVia
Definition: pns_dragger.h:133
virtual bool Start(const VECTOR2I &aP, ITEM_SET &aPrimitives) override
Function Start()
LINE m_draggedLine
Definition: pns_dragger.h:137
const ITEM_SET Traces() override
Function Traces()
NODE * CurrentNode() const override
Function CurrentNode()
bool startDragArc(const VECTOR2D &aP, ARC *aArc)
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:60
bool startDragVia(VIA *aVia)
LINE m_lastDragSolution
Definition: pns_dragger.h:138
const std::vector< int > CurrentNets() const override
Function CurrentNets()
Definition: pns_dragger.h:91
bool dragViaMarkObstacles(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
int Net() const
Definition: pns_item.h:152
int m_draggedSegmentIndex
Definition: pns_dragger.h:140
DRAGGER.
Definition: pns_dragger.h:47
ITEM_SET m_origViaConnections
Definition: pns_dragger.h:143
bool dragViaWalkaround(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
MOUSE_TRAIL_TRACER m_mouseTrailTracer
Definition: pns_dragger.h:151
NODE * m_lastNode
Definition: pns_dragger.h:135
bool FixRoute() override
Function FixRoute()
const ITEM_SET findViaFanoutByHandle(NODE *aNode, const VIA_HANDLE &handle)
bool dragWalkaround(const VECTOR2I &aP)
bool dragShove(const VECTOR2I &aP)
PNS_MODE m_currentMode
Definition: pns_dragger.h:142
VIA_HANDLE m_initialVia
Definition: pns_dragger.h:132
bool dragMarkObstacles(const VECTOR2I &aP)
bool m_freeAngleMode
Definition: pns_dragger.h:150
Push and Shove diff pair dimensions (gap) settings dialog.
VECTOR2D m_lastValidPoint
Contains the list of items that are currently modified by the dragger.
Definition: pns_dragger.h:144
VVIA * checkVirtualVia(const VECTOR2D &aP, SEGMENT *aSeg)
Definition: pns_dragger.cpp:71
void SetMode(int aDragMode) override