PCB Environment 2

Loading...
Searching...
No Matches
Pin.hpp
1#ifndef GYM_PCB_PIN_H
2#define GYM_PCB_PIN_H
3
4#include "Py.hpp"
5#include "Component.hpp"
6#include "Color.hpp"
7#include <vector>
8
9 class CloneEnv;
10 class Component;
11 class Connection;
12 class Net;
13 class Pin;
14
15 using PinCompound = std::vector<Pin *>;
16
17 class Pin : public Object
18{
19 public:
20 Pin(Component *, const std::string &name);
21 ~Pin();
22 Object *clone(CloneEnv&) const override;
23
24 Component *getParent() const;
25
26 bool hasNet() const { return !!mNet; }
27 Net *net() const { return mNet; }
28 bool sameNetAs(const Pin &T) const { return mNet == T.net(); }
29 void setNet(Net *net);
30
35 uint getStartLayerFor(const Connection&) const;
36
40 const PinCompound *compound() const { return mCompound; }
41 bool inCompound(const Pin&) const;
42 void setCompound(Pin *);
43
44 uint numConnections() const { return mConnections.size(); }
45 void addConnection(Connection *X) { mConnections.insert(X); }
46 bool removeConnection(Connection *X, bool retainNet);
47 const std::set<Connection *>& connections() const { return mConnections; }
48
49 Color colorLine() const;
50 Color colorFill() const;
51
52 std::string str() const override;
53 PyObject *getPy(uint depth) const override;
54
55 private:
56 Net *mNet{0};
57 std::set<Connection *> mConnections; // Owned by the net!
58 PinCompound *mCompound{0};
59};
60
61 inline bool Pin::inCompound(const Pin &P) const
62{
63 return mCompound && mCompound == P.mCompound;
64}
65
66 inline Color Pin::colorLine() const
67{
68 return Palette::PinLine[hasNet() ? 1 : 0][minLayer() ? 1 : 0];
69}
70 inline Color Pin::colorFill() const
71{
72 return Palette::PinFill[hasNet() ? 1 : 0][minLayer() ? 1 : 0];
73}
74
75 inline Component *Pin::getParent() const
76{
77 return dynamic_cast<Component *>(mParent);
78}
79
80#endif // GYM_PCB_PIN_H
CloneEnv
Definition Clone.hpp:17
Color
Definition Color.hpp:9
Component
Definition Component.hpp:18
Connection
Definition Connection.hpp:17
Net
Definition Net.hpp:19
Pin
Definition Pin.hpp:18
Pin::getStartLayerFor
uint getStartLayerFor(const Connection &) const
Pin::compound
const PinCompound * compound() const
Definition Pin.hpp:40