-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponentLibrary.py
More file actions
143 lines (110 loc) · 4.92 KB
/
componentLibrary.py
File metadata and controls
143 lines (110 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
"""component library defining all the usable components"""
from ursina import *
# from helperFunctions import *
from settings import *
from footprints import *
from math import asin, acos
# only needed for test in this file
def click():
global currentEntity
if currentEntity != {}:
currentEntity.color = color.rgb(255, 255, 255)
currentEntity = mouse.hovered_entity
currentEntity.color = color.rgb(150, 255, 150)
# base class for components
class Component():
def __init__(self, current_footprint, available_footprints, designator, clickFunction):
self.available_footprints = available_footprints
if len(available_footprints) > int(current_footprint):
self.current_footprint = current_footprint
else:
print("selected footprint out of bounds")
self.current_footprint = 0
self.footprint = self.available_footprints[self.current_footprint](clickFunction, designator)
self.designator = designator
def getPinPos(self, pinNumber):
return self.footprint.getPinPos(pinNumber)
value = "None"
class AIRWIRE(Entity):
def __init__(self, start, end, clickFunction, netname, startPart, endPart):
self.net = netname
self.startPart = startPart
self.endPart = endPart
self.designator = "AIRWIRE_" + str(next(counter))
self.value = "AIRWIRE"
midpoint = (Vec3(start) + Vec3(end)) / 2
length = distance(start, end)
scale = (airwire_thickness, airwire_thickness, length)
super().__init__(model='cube', position=midpoint, scale=scale, collider='mesh', color=color.yellow, on_click=clickFunction)
self.original_color = self.color
class WIRE(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [WIRE10X10, WIRE20X10, WIRE20X50, WIRE50X20], designator, clickFunction)
self.value = "WIRE"
class BC847(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [TO92, SOT23_3], designator, clickFunction)
self.value = "BC847"
class LED5MM(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [LED5MM_A, LED5MM_B], designator, clickFunction)
self.value = "LED5MM"
class RES(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [RESTHT, RESTHT_SHORT, RES0603], designator, clickFunction)
self.value = "RES"
class CAP(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [CAPTHT, CAP0603], designator, clickFunction)
self.value = "CAP"
class PORT(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [PIN], designator, clickFunction)
self.value = "PORT"
class DIODE(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [DIODETHT], designator, clickFunction)
self.value = "DIODE"
class BC547(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [TO92, SOT23_3], designator, clickFunction)
self.value = "BC547"
class BC557(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [TO92, SOT23_3], designator, clickFunction)
self.value = "BC557"
class NE555(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [SOIC8, DIP8], designator, clickFunction)
self.value = "NE555"
class TL072(Component):
def __init__(self, clickFunction, footprint=0, designator = '?'):
super().__init__(footprint, [SOIC8, DIP8], designator, clickFunction)
self.value = "TL072"
if __name__ == '__main__':
app = Ursina()
window.borderless = False
window.exit_button.enabled = False
currentEntity = {}
originArrows()
# C = CAPTHT(click)
L = LED5MM(click)
# T = BC547(click)
# D = DIP8(click)
D = SOIC8(click)
# R = RESTHT(click)
# PORT(click)
AIRWIRE(start=L.getPinPos(1), end=D.getPinPos(7))
AIRWIRE(start=L.getPinPos(2), end=D.getPinPos(6))
AIRWIRE(start=D.getPinPos(3), end=D.getPinPos(5))
# AIRWIRE(start=D.getPinPos(4), end=D.getPinPos(8))
# AIRWIRE(start=C.getPinPos(2), end=T.getPinPos(2))
for i in range(-10, 10):
for j in range(-10, 10):
Entity(model="cube", position=[i*2, j*2, 0], scale=0.05)
Entity(model="cube", position=[i*2, 0, j*2], scale=0.05)
def input(key):
if key == key_exit:
app.userExit()
EditorCamera()
app.run()