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
13 class CloneEnv;
14 class Pin;
15 class Connection;
16
17 class Component : public Object
18{
19 public:
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
48 Pin *removeAndDisconnectPin(Pin&);
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
75 private:
76 Point_2 mRefPoint;
77 std::map<std::string, Pin *> mPinMap;
78 Color mColorLine;
79 Color mColorFill;
80};
81
82 inline 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
CloneEnv
Definition Clone.hpp:17
Color
Definition Color.hpp:9
Component::setLocation
void setLocation(const Point_2 &refPoint, int layer=0)
Component::addPin
Pin * addPin(const std::string &name)
Component::addOccludedObject
void addOccludedObject(Object &) override
Component::connectivity
static uint connectivity(std::vector< std::pair< Pin *, Pin * > > &, const Component &, const Component &)
Component::removeAndDisconnectPin
Pin * removeAndDisconnectPin(Pin &)
Component::gatherConnections
void gatherConnections(std::set< Connection * > &) const
Connection
Definition Connection.hpp:17
Pin
Definition Pin.hpp:18