You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
3.2 KiB

  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2013-2020 CERN
  5. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  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. #ifndef __PNS_COMPONENT_DRAGGER_H
  21. #define __PNS_COMPONENT_DRAGGER_H
  22. #include <math/vector2d.h>
  23. #include "pns_drag_algo.h"
  24. #include "pns_itemset.h"
  25. #include "pns_line.h"
  26. #include "pns_node.h"
  27. #include "pns_via.h"
  28. namespace PNS
  29. {
  30. class ROUTER;
  31. class OPTIMIZER;
  32. /**
  33. * COMPONENT_DRAGGER
  34. *
  35. * Implements component dragging algorithm.
  36. */
  37. class COMPONENT_DRAGGER : public DRAG_ALGO
  38. {
  39. public:
  40. COMPONENT_DRAGGER( ROUTER* aRouter );
  41. ~COMPONENT_DRAGGER();
  42. /**
  43. * Function Start()
  44. *
  45. * Starts routing a single track at point aP, taking item aStartItem as anchor
  46. * (unless NULL). Returns true if a dragging operation has started.
  47. */
  48. bool Start( const VECTOR2I& aP, ITEM_SET& aPrimitives ) override;
  49. /**
  50. * Function Drag()
  51. *
  52. * Drags the current segment/corner/via to the point aP.
  53. * @return true, if dragging finished with success.
  54. */
  55. bool Drag( const VECTOR2I& aP ) override;
  56. /**
  57. * Function FixRoute()
  58. *
  59. * Checks if the result of current dragging operation is correct
  60. * and eventually commits it to the world.
  61. * @return true, if dragging finished with success.
  62. */
  63. bool FixRoute() override;
  64. /**
  65. * Function CurrentNode()
  66. *
  67. * Returns the most recent world state, including all
  68. * items changed due to dragging operation.
  69. */
  70. NODE* CurrentNode() const override;
  71. /**
  72. * Function CurrentNets()
  73. *
  74. * Returns the net code(s) of currently dragged item(s).
  75. * Currently unused for component dragging.
  76. */
  77. const std::vector<int> CurrentNets() const override
  78. {
  79. return std::vector<int>();
  80. }
  81. /**
  82. * Function CurrentLayer()
  83. *
  84. * Returns the layer of currently dragged item(s).
  85. * Currently unused for component dragging.
  86. */
  87. virtual int CurrentLayer() const override
  88. {
  89. return UNDEFINED_LAYER;
  90. }
  91. /**
  92. * Function Traces()
  93. *
  94. * Returns the set of dragged items.
  95. */
  96. const ITEM_SET Traces() override;
  97. private:
  98. struct DRAGGED_CONNECTION
  99. {
  100. LINE origLine;
  101. SOLID* attachedPad;
  102. VECTOR2I p_orig, p_next;
  103. };
  104. std::set<SOLID*> m_solids;
  105. std::vector<DRAGGED_CONNECTION> m_conns;
  106. bool m_dragStatus;
  107. ITEM_SET m_draggedItems;
  108. ITEM_SET m_initialDraggedItems;
  109. NODE* m_currentNode;
  110. VECTOR2I m_p0;
  111. };
  112. }; // namespace PNS
  113. #endif