1 /* 2 * LibrePCB - Professional EDA for everyone! 3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors. 4 * https://librepcb.org/ 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef LIBREPCB_PROJECT_EDITOR_BOARDNETSEGMENTSPLITTER_H 21 #define LIBREPCB_PROJECT_EDITOR_BOARDNETSEGMENTSPLITTER_H 22 23 /******************************************************************************* 24 * Includes 25 ******************************************************************************/ 26 #include <librepcb/common/geometry/junction.h> 27 #include <librepcb/common/geometry/trace.h> 28 #include <librepcb/common/geometry/via.h> 29 30 #include <QtCore> 31 #include <QtWidgets> 32 33 /******************************************************************************* 34 * Namespace / Forward Declarations 35 ******************************************************************************/ 36 namespace librepcb { 37 38 class GraphicsLayer; 39 40 namespace project { 41 namespace editor { 42 43 /******************************************************************************* 44 * Class BoardNetSegmentSplitter 45 ******************************************************************************/ 46 47 /** 48 * @brief The BoardNetSegmentSplitter class 49 */ 50 class BoardNetSegmentSplitter final { 51 public: 52 // Types 53 struct Segment { 54 JunctionList junctions; 55 ViaList vias; 56 TraceList traces; 57 }; 58 59 // Constructors / Destructor 60 BoardNetSegmentSplitter() noexcept; 61 BoardNetSegmentSplitter(const BoardNetSegmentSplitter& other) = delete; 62 ~BoardNetSegmentSplitter() noexcept; 63 64 // General Methods 65 void replaceFootprintPadByJunctions(const TraceAnchor& anchor, 66 const Point& pos) noexcept; 67 void addJunction(const Junction& junction) noexcept; 68 void addVia(const Via& via, bool replaceByJunctions) noexcept; 69 void addTrace(const Trace& trace) noexcept; 70 QList<Segment> split() noexcept; 71 72 // Operator Overloadings 73 BoardNetSegmentSplitter& operator=(const BoardNetSegmentSplitter& rhs) = 74 delete; 75 76 private: // Methods 77 TraceAnchor replaceAnchor(const TraceAnchor& anchor, 78 const GraphicsLayerName& layer) noexcept; 79 void findConnectedLinesAndPoints(const TraceAnchor& anchor, 80 ViaList& availableVias, 81 TraceList& availableTraces, Segment& segment) 82 83 noexcept; 84 85 private: // Data 86 JunctionList mJunctions; 87 ViaList mVias; 88 TraceList mTraces; 89 90 QHash<TraceAnchor, Point> mAnchorsToReplace; 91 QHash<QPair<TraceAnchor, GraphicsLayerName>, TraceAnchor> mReplacedAnchors; 92 }; 93 94 /******************************************************************************* 95 * End of File 96 ******************************************************************************/ 97 98 } // namespace editor 99 } // namespace project 100 } // namespace librepcb 101 102 #endif 103