Horizon
pns_dragger.h
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 <tomasz.wlostowski@cern.ch>
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 
132  VIA_HANDLE m_initialVia;
133  VIA_HANDLE m_draggedVia;
134 
135  NODE* m_lastNode;
136  int m_mode;
137  LINE m_draggedLine;
138  LINE m_lastDragSolution;
139  std::unique_ptr<SHOVE> m_shove;
140  int m_draggedSegmentIndex;
141  bool m_dragStatus;
142  PNS_MODE m_currentMode;
143  ITEM_SET m_origViaConnections;
144  VECTOR2D m_lastValidPoint;
145 
147  ITEM_SET m_draggedItems;
148 
150  bool m_freeAngleMode;
151  MOUSE_TRAIL_TRACER m_mouseTrailTracer;
152 };
153 
154 }
155 
156 #endif
Definition: pns_arc.h:37
DRAGGER.
Definition: pns_dragger.h:48
const std::vector< int > CurrentNets() const override
Function CurrentNets()
Definition: pns_dragger.h:91
virtual bool Start(const VECTOR2I &aP, ITEM_SET &aPrimitives) override
Function Start()
Definition: pns_dragger.cpp:207
NODE * CurrentNode() const override
Function CurrentNode()
Definition: pns_dragger.cpp:745
bool Drag(const VECTOR2I &aP) override
Function Drag()
Definition: pns_dragger.cpp:717
int CurrentLayer() const override
Function CurrentLayer()
Definition: pns_dragger.h:101
bool FixRoute() override
Function FixRoute()
Definition: pns_dragger.cpp:688
const ITEM_SET Traces() override
Function Traces()
Definition: pns_dragger.cpp:751
DRAG_ALGO.
Definition: pns_drag_algo.h:43
Definition: pns_itemset.h:37
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:61
Definition: pns_mouse_trail_tracer.h:32
Keep the router "world" - i.e.
Definition: pns_node.h:148
Definition: pns_router.h:116
Definition: pns_segment.h:39
Definition: pns_via.h:49
Definition: pns_via.h:170
Definition: pns_via.h:41