1 /* 2 * KiRouter - a push-and-(sometimes-)shove PCB router 3 * 4 * Copyright (C) 2013-2020 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_DRAG_ALGO_H 23 #define __PNS_DRAG_ALGO_H 24 25 #include <memory> 26 #include <math/vector2d.h> 27 28 #include "pns_algo_base.h" 29 #include "pns_itemset.h" 30 #include "pns_layerset.h" 31 32 33 namespace PNS { 34 35 class NODE; 36 37 /** 38 * DRAG_ALGO 39 * 40 * Base class for item dragging algorithms. 41 */ 42 class DRAG_ALGO : public ALGO_BASE 43 { 44 public: DRAG_ALGO(ROUTER * aRouter)45 DRAG_ALGO( ROUTER* aRouter ) : 46 ALGO_BASE( aRouter ), 47 m_world( nullptr ) 48 { 49 } 50 ~DRAG_ALGO()51 ~DRAG_ALGO() 52 { 53 } 54 55 /** 56 * Function SetWorld() 57 * 58 * Sets the board to work on. 59 */ SetWorld(NODE * aWorld)60 virtual void SetWorld( NODE* aWorld ) 61 { 62 m_world = aWorld; 63 } 64 65 /** 66 * Function Start() 67 * 68 * Starts routing a single track at point aP, taking item aStartItem as anchor (unless NULL). 69 * Returns true if a dragging operation has started. 70 */ 71 virtual bool Start( const VECTOR2I& aP, ITEM_SET& aPrimitives ) = 0; 72 73 /** 74 * Function Drag() 75 * 76 * Drags the current segment/corner/via to the point aP. 77 * @return true, if dragging finished with success. 78 */ 79 virtual bool Drag( const VECTOR2I& aP ) = 0; 80 81 /** 82 * Function FixRoute() 83 * 84 * Checks if the result of current dragging operation is correct 85 * and eventually commits it to the world. 86 * @return true, if dragging finished with success. 87 */ 88 virtual bool FixRoute() = 0; 89 90 /** 91 * Function CurrentNode() 92 * 93 * Returns the most recent world state, including all items changed by dragging operation. 94 */ 95 virtual NODE* CurrentNode() const = 0; 96 97 /** 98 * Function CurrentNets() 99 * 100 * Returns the net code(s) of currently dragged item(s). 101 */ 102 virtual const std::vector<int> CurrentNets() const = 0; 103 104 /** 105 * Function CurrentLayer() 106 * 107 * Returns the layer of currently dragged item(s). 108 */ 109 virtual int CurrentLayer() const = 0; 110 111 /** 112 * Function Traces() 113 * 114 * Returns the set of dragged items. 115 */ 116 virtual const ITEM_SET Traces() = 0; 117 SetMode(int aDragMode)118 virtual void SetMode( int aDragMode ) {}; 119 120 protected: 121 NODE* m_world; 122 123 }; 124 125 126 } // namespace PNS 127 128 #endif 129