PCB Environment 2
Loading...
Searching...
No Matches
Component.hpp
1
2#ifndef GYM_PCB_COMPONENT_H
3#define GYM_PCB_COMPONENT_H
4
5#include "Py.hpp"
6#include "Object.hpp"
7#include "Color.hpp"
8#include <map>
9#include <set>
10#include <string>
11#include <vector>
12
13class CloneEnv;
14class Pin;
15class Connection;
16
17class Component : public Object
18{
19public:
20 Component(const std::string &name);
21 ~Component();
22 Object *clone(CloneEnv&) const override;
23
27 void setLocation(const Point_2 &refPoint, int layer = 0);
28
29 bool isPlaced() const { return mLayerRange[0] >= 0; }
30 const Point_2& getRefPoint() const { return mRefPoint; }
31
32 const std::vector<Object *>& getPins() const { return getChildren(); }
33 uint numPins() const { return numChildren(); }
34 Pin *getPin(const std::string &name) const;
35 Pin& getPin(uint i) const { return *mChildren.at(i)->as<Pin>(); }
36
42 Pin *addPin(const std::string &name);
43
49
53 void gatherConnections(std::set<Connection *>&) const;
54
58 static uint connectivity(std::vector<std::pair<Pin *, Pin *>>&, const Component&, const Component&);
59
64 void addOccludedObject(Object&) override;
65
66 std::string str() const override;
67 PyObject *getPy(uint depth) const override;
68
69 // UI
70 void setColors(const Color &line, const Color &fill) { mColorLine = line; mColorFill = fill; }
71
72 const Color& getLineColor() const { return mColorLine; }
73 const Color& getFillColor() const { return mColorFill; }
74
75private:
76 Point_2 mRefPoint;
77 std::map<std::string, Pin *> mPinMap;
78 Color mColorLine;
79 Color mColorFill;
80};
81
82inline Pin *Component::getPin(const std::string &name) const
83{
84 auto I = mPinMap.find(name);
85 if (I == mPinMap.end())
86 return 0;
87 return I->second;
88}
89
90#endif // GYM_PCB_COMPONENT_H
Definition Clone.hpp:17
Definition Color.hpp:9
void setLocation(const Point_2 &refPoint, int layer=0)
Pin * addPin(const std::string &name)
void addOccludedObject(Object &) override
static uint connectivity(std::vector< std::pair< Pin *, Pin * > > &, const Component &, const Component &)
Pin * removeAndDisconnectPin(Pin &)
void gatherConnections(std::set< Connection * > &) const
Definition Connection.hpp:17
Definition Pin.hpp:18