KiCad PCB EDA Suite
ratsnest_data.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KICAD, a free EDA CAD application.
3  *
4  * Copyright (C) 2013-2015 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef RATSNEST_DATA_H
31 #define RATSNEST_DATA_H
32 
33 #include <core/typeinfo.h>
34 #include <math/box2.h>
35 
36 #include <deque>
37 #include <unordered_set>
38 #include <unordered_map>
39 
40 #include <ttl/halfedge/hetriang.h>
41 #include <ttl/halfedge/hetraits.h>
42 
43 #include <connectivity_algo.h>
44 
45 class BOARD;
46 class BOARD_ITEM;
48 class CN_CLUSTER;
50 
51 struct RN_NODE_OR_FILTER;
52 struct RN_NODE_AND_FILTER;
53 
54 
59 class RN_NET
60 {
61 public:
63  RN_NET();
64 
71  void SetVisible( bool aEnabled );
72 
77  void MarkDirty()
78  {
79  m_dirty = true;
80  }
81 
88  bool IsDirty() const
89  {
90  return m_dirty;
91  }
92 
98  const std::vector<CN_EDGE> GetUnconnected() const
99  {
100  return m_rnEdges;
101  }
102 
107  void Update();
108  void Clear();
109 
110  void AddCluster( std::shared_ptr<CN_CLUSTER> aCluster );
111 
112  unsigned int GetNodeCount() const
113  {
114  return m_nodes.size();
115  }
116 
123  std::list<CN_ANCHOR_PTR> GetNodes( const BOARD_CONNECTED_ITEM* aItem ) const;
124 
125  const std::vector<CN_EDGE>& GetEdges() const
126  {
127  return m_rnEdges;
128  }
129 
136  void GetAllItems( std::list<BOARD_CONNECTED_ITEM*>& aOutput, const KICAD_T aTypes[] ) const;
137 
143  const CN_ANCHOR_PTR GetClosestNode( const CN_ANCHOR_PTR& aNode ) const;
144 
145  bool NearestBicoloredPair( const RN_NET& aOtherNet, CN_ANCHOR_PTR& aNode1, CN_ANCHOR_PTR& aNode2 ) const;
146 
147 protected:
149  void compute();
150 
152  std::vector<CN_ANCHOR_PTR> m_nodes;
153 
155  std::vector<CN_EDGE> m_boardEdges;
156 
158  std::vector<CN_EDGE> m_rnEdges;
159 
161  bool m_dirty;
162 
164 
165  std::shared_ptr<TRIANGULATOR_STATE> m_triangulator;
166 };
167 
168 #endif /* RATSNEST_DATA_H */
const std::vector< CN_EDGE > & GetEdges() const
void Update()
Function Update() Recomputes ratsnest for a net.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
bool m_dirty
Flag indicating necessity of recalculation of ratsnest for a net.
std::vector< CN_EDGE > m_rnEdges
Vector of edges that makes ratsnest for a given net.
void compute()
Recomputes ratsnest from scratch.
void MarkDirty()
Function MarkDirty() Marks ratsnest for given net as 'dirty', i.e.
Definition: ratsnest_data.h:77
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
std::list< CN_ANCHOR_PTR > GetNodes(const BOARD_CONNECTED_ITEM *aItem) const
Function GetNodes() Returns list of nodes that are associated with a given item.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
std::vector< CN_ANCHOR_PTR > m_nodes
Vector of nodes
RN_NET()
Default constructor.
void Clear()
const CN_ANCHOR_PTR GetClosestNode(const CN_ANCHOR_PTR &aNode) const
Function GetClosestNode() Returns a single node that lies in the shortest distance from a specific no...
void SetVisible(bool aEnabled)
Function SetVisible() Sets state of the visibility flag.
const std::vector< CN_EDGE > GetUnconnected() const
Function GetUnconnected() Returns pointer to a vector of edges that makes ratsnest for a given net...
Definition: ratsnest_data.h:98
void AddCluster(std::shared_ptr< CN_CLUSTER > aCluster)
std::shared_ptr< TRIANGULATOR_STATE > m_triangulator
std::vector< CN_EDGE > m_boardEdges
Vector of edges that make pre-defined connections
bool NearestBicoloredPair(const RN_NET &aOtherNet, CN_ANCHOR_PTR &aNode1, CN_ANCHOR_PTR &aNode2) const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
bool IsDirty() const
Function IsDirty() Returns state of the 'dirty' flag, indicating that ratsnest for a given net is inv...
Definition: ratsnest_data.h:88
Class RN_NET Describes ratsnest for a single net.
Definition: ratsnest_data.h:59
std::shared_ptr< CN_ANCHOR > CN_ANCHOR_PTR
void GetAllItems(std::list< BOARD_CONNECTED_ITEM * > &aOutput, const KICAD_T aTypes[]) const
Function GetAllItems() Adds all stored items to a list.
unsigned int GetNodeCount() const