-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
4372 lines (3982 loc) · 234 KB
/
main.py
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import argparse
from PyQt5.QtWidgets import (
QApplication, QWidget, QPushButton, QVBoxLayout, QHBoxLayout, QCheckBox, QLabel, QLineEdit, QFileDialog, QMessageBox, QComboBox, QGridLayout, QToolTip, QDialog, QSizePolicy, QProgressBar
)
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import Qt, QEvent
from gdswriter import GDSDesign # Import the GDSDesign class
from gdswriter import TEXT_SPACING_FACTOR as GDS_TEXT_SPACING_FACTOR
from copy import deepcopy
import math
import numpy as np
import random
import os
import uuid
import logging
from datetime import datetime
from shapely.geometry import Polygon, Point, box
from matplotlib.figure import Figure
from matplotlib.colors import rgb2hex
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
import matplotlib.patches as patches
import matplotlib
matplotlib.use('Qt5Agg')
AXIS_BUFFER = 5
TEXT_SPACING_FACTOR = 0.55
TEXT_HEIGHT_FACTOR = 0.7
TEMP_CELL_NAME = "SIZE CHECK TEMP"
TILDE_KEY = 96
COLOR_SEQUENCE = [
"#FFCCCC", # Light red
"#CCFFCC", # Light green
"#CCCCFF", # Light blue
"#FFFFCC", # Light yellow
"#FFCCFF", # Light pink
"#FFD1B3", # Light orange
"#E6CCFF", # Light purple
"#CCFFFF", # Light cyan
"#FFCCF2", # Light magenta
"#D9FFB3", # Light lime
"#CCFFFF", # Light teal
"#E6D8CC", # Light brown
"#FFDAB3", # Light coral
"#CCCCE6", # Light navy
"#E6E6CC", # Light olive
"#FFB3B3", # Light maroon
"#CCFFFF", # Light aqua
"#FFF5CC", # Light gold
"#FFD1CC", # Light salmon
"#E6CCFF" # Light violet
]
BASE_COLORS = {
"#FFCCCC": "#FF6666", # Light red -> Red
"#CCFFCC": "#66FF66", # Light green -> Green
"#CCCCFF": "#6666FF", # Light blue -> Blue
"#FFFFCC": "#FFFF66", # Light yellow -> Yellow
"#FFCCFF": "#FF66FF", # Light pink -> Pink
"#FFD1B3": "#FF9966", # Light orange -> Orange
"#E6CCFF": "#B266FF", # Light purple -> Purple
"#CCFFFF": "#66FFFF", # Light cyan -> Cyan
"#FFCCF2": "#FF66D9", # Light magenta -> Magenta
"#D9FFB3": "#99FF66", # Light lime -> Lime
"#CCFFFF": "#66FFFF", # Light teal -> Teal
"#E6D8CC": "#C9A57A", # Light brown -> Brown
"#FFDAB3": "#FF9966", # Light coral -> Coral
"#CCCCE6": "#6666B2", # Light navy -> Navy
"#E6E6CC": "#CCCC66", # Light olive -> Olive
"#FFB3B3": "#FF6666", # Light maroon -> Maroon
"#CCFFFF": "#66FFFF", # Light aqua -> Aqua
"#FFF5CC": "#FFEB99", # Light gold -> Gold
"#FFD1CC": "#FF9980", # Light salmon -> Salmon
"#E6CCFF": "#B266FF" # Light violet -> Violet
}
def setup_logging():
# Create a logs directory if it doesn't exist
if not os.path.exists('logs'):
os.makedirs('logs')
# Generate a timestamp for the log file
timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
log_filename = f'logs/log_{timestamp}.log'
# Configure logging
logging.basicConfig(
filename=log_filename,
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
# Optionally, also log to the console
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
console_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
logging.getLogger().addHandler(console_handler)
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
class CycleLineEdit(QLineEdit):
def __init__(self, comboBox, addButton, *args, **kwargs):
super().__init__(*args, **kwargs)
self.comboBox = comboBox
self.addButton = addButton
self.installEventFilter(self)
def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Tab:
self.editingFinished.emit()
currentIndex = self.comboBox.currentIndex()
nextIndex = (currentIndex + 1) % self.comboBox.count()
self.comboBox.setCurrentIndex(nextIndex)
return True # Event handled
elif event.type() == QEvent.KeyPress and event.key() == TILDE_KEY:
self.editingFinished.emit()
currentIndex = self.comboBox.currentIndex()
nextIndex = (currentIndex - 1) % self.comboBox.count()
self.comboBox.setCurrentIndex(nextIndex)
return True # Event handled
elif event.type() == QEvent.KeyPress and event.key() == Qt.Key_A and event.modifiers() == (Qt.ShiftModifier | Qt.AltModifier):
self.editingFinished.emit()
self.addButton.clicked.emit()
return True
return super().eventFilter(obj, event)
class EnterLineEdit(QLineEdit):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.installEventFilter(self)
def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress and (event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return):
self.editingFinished.emit()
return True # Event handled
return super().eventFilter(obj, event)
class PushButtonEdit(QLineEdit):
def __init__(self, addButton, *args, **kwargs):
super().__init__(*args, **kwargs)
self.addButton = addButton
self.installEventFilter(self)
def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_A and event.modifiers() == (Qt.ShiftModifier | Qt.AltModifier):
self.editingFinished.emit()
self.addButton.clicked.emit()
return True
elif event.type() == QEvent.KeyPress and (event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return):
self.editingFinished.emit()
return True # Event handled
return super().eventFilter(obj, event)
class TooltipComboBox(QComboBox):
def __init__(self, tooltips=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.tooltips = tooltips or {}
self.tooltip_widget = QLabel("", self)
self.tooltip_widget.setWindowFlags(Qt.ToolTip)
self.tooltip_widget.setStyleSheet("background-color: yellow; border: 1px solid black;")
self.view().viewport().installEventFilter(self)
self.setMouseTracking(True)
def setItemTooltips(self, tooltips):
self.tooltips = tooltips
def showCustomTooltip(self, text, pos):
self.tooltip_widget.setText(text)
self.tooltip_widget.adjustSize()
self.tooltip_widget.move(pos)
self.tooltip_widget.show()
def hideCustomTooltip(self):
self.tooltip_widget.hide()
def eventFilter(self, source, event):
if event.type() == QEvent.MouseMove and source is self.view().viewport():
index = self.view().indexAt(event.pos()).row()
if index >= 0 and index < len(self.tooltips):
global_pos = self.mapToGlobal(event.pos())
self.showCustomTooltip(self.tooltips[index], global_pos)
else:
self.hideCustomTooltip()
return False
elif event.type() == QEvent.Leave and source is self.view().viewport():
self.hideCustomTooltip()
return False
return super().eventFilter(source, event)
class MyApp(QWidget):
def __init__(self, verbose=False):
super().__init__()
self.verbose = verbose
self.show_animation = False
self.inputFileName = ""
self.outputFileName = ""
self.customTestCellName = ""
self.logFileName = ""
self.customFileName = ""
self.substrateLayer = None
self.excludedLayers = []
self.availableSpace = None
self.allOtherPolygons = None
self.layerData = [] # To store layer numbers and names
self.testStructureNames = [
"MLA Alignment Mark", "Resistance Test", "Trace Test",
"Interlayer Via Test", "Electronics Via Test", "Short Test",
"Rectangle", "Circle", "Text", "Polygon", "Path", "Escape Routing", "Register Ports", "Connect Rows", "Custom Test Structure"
]
self.parameters = {
"MLA Alignment Mark": ["Layer", "Center", "Outer Rect Width", "Outer Rect Height", "Interior Width", "Interior X Extent", "Interior Y Extent", "Automatic Placement"],
"Resistance Test": ["Layer", "Center", "Probe Pad Width", "Probe Pad Height", "Probe Pad Spacing", "Plug Width", "Plug Height", "Trace Width", "Trace Spacing", "Switchbacks", "X Extent", "Text Height", "Text", "Add Interlayer Short", "Layer Name Short", "Short Text", "Automatic Placement"],
"Trace Test": ["Layer", "Center", "Text", "Line Width", "Line Height", "Num Lines", "Line Spacing", "Text Height", "Automatic Placement"],
"Interlayer Via Test": ["Layer Number 1", "Layer Number 2", "Via Layer", "Center", "Text", "Layer 1 Rectangle Spacing", "Layer 1 Rectangle Width", "Layer 1 Rectangle Height", "Layer 2 Rectangle Width", "Layer 2 Rectangle Height", "Via Width", "Via Height", "Text Height", "Automatic Placement"],
"Electronics Via Test": ["Layer Number 1", "Layer Number 2", "Via Layer", "Center", "Text", "Layer 1 Rect Width", "Layer 1 Rect Height", "Layer 2 Rect Width", "Layer 2 Rect Height", "Layer 2 Rect Spacing", "Via Width", "Via Height", "Via Spacing", "Text Height", "Automatic Placement"],
"Short Test": ["Layer", "Center", "Text", "Rect Width", "Trace Width", "Trace Space", "Num Lines", "Group Spacing", "Num Groups", "Num Lines Vert", "Text Height", "Automatic Placement"],
"Rectangle": ["Layer", "Center", "Width", "Height", "Lower Left", "Upper Right", "Rotation"],
"Circle": ["Layer", "Center", "Diameter"],
"Text": ["Layer", "Center", "Text", "Height", "Rotation"],
"Polygon": ["Layer"],
"Path": ["Layer", "Width"],
"Escape Routing": ["Layer", "Center", "Copies X", "Copies Y", "Pitch X", "Pitch Y", "Trace Width", "Trace Space", "Pad Diameter", "Orientation", "Escape Extent", "Cable Tie Routing Angle", "Autorouting Angle"],
"Register Ports": ["Layer", "Orientation", "Center", "Num Ports", "Trace Width", "Trace Space"],
"Connect Rows": ["Layer", "Row 1 Start", "Row 1 End", "Row 1 Spacing", "Row 1 Constant", "Row 2 Start", "Row 2 End", "Row 2 Spacing", "Row 2 Constant", "Orientation", "Trace Width", "Escape Extent"],
"Custom Test Structure": ["Center", "Magnification", "Rotation", "X Reflection", "Array", "Copies X", "Copies Y", "Pitch X", "Pitch Y", "Automatic Placement"]
}
self.paramTooltips = {
"MLA Alignment Mark": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the alignment mark.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the alignment mark in um.",
"Outer Rect Width": "type:(number) Enter the width of the outer rectangle in um.",
"Outer Rect Height": "type:(number) Enter the height of the outer rectangle in um.",
"Interior Width": "type:(number) Enter the width of the interior lines in um.",
"Interior X Extent": "type:(number) Enter the extent of the interior lines in the x direction in um.",
"Interior Y Extent": "type:(number) Enter the extent of the interior lines in the y direction in um.",
"Automatic Placement": "type:(case-ignored string 'True' or 'False') Check to automatically place the alignment mark."
},
"Resistance Test": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the resistance test structure.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the resistance test structure in um.",
"Probe Pad Width": "type:(number) Enter the width of the probe pad in um.",
"Probe Pad Height": "type:(number) Enter the height of the probe pad in um.",
"Probe Pad Spacing": "type:(number) Enter the spacing between probe pads in um.",
"Plug Width": "type:(number) Enter the width of the plug in um.",
"Plug Height": "type:(number) Enter the height of the plug in um.",
"Trace Width": "type:(number) Enter the width of the traces in um.",
"Trace Spacing": "type:(number) Enter the spacing between traces in um.",
"Switchbacks": "type:(integer) Enter the number of switchbacks.",
"X Extent": "type:(number) Enter the extent of the structure in the x direction in um.",
"Text Height": "type:(number) Enter the height of the text in um.",
"Text": "type:(string) Enter the text to display on the structure.",
"Add Interlayer Short": "type:(case-ignored string 'True' or 'False') Check to add an interlayer short.",
"Layer Name Short": "type:(layer number integer or layer name string) Enter the name of the short layer.",
"Short Text": "type:(string) Enter the text to display for the short.",
"Automatic Placement": "type:(case-ignored string 'True' or 'False') Check to automatically place the resistance test structure."
},
"Trace Test": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the trace test structure.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the trace test structure in um.",
"Text": "type:(string) Enter the text to display on the structure.",
"Line Width": "type:(number) Enter the width of the lines in um.",
"Line Height": "type:(number) Enter the height of the lines in um.",
"Num Lines": "type:(integer) Enter the number of lines.",
"Line Spacing": "type:(number) Enter the spacing between lines in um.",
"Text Height": "type:(number) Enter the height of the text in um.",
"Automatic Placement": "type:(case-ignored string 'True' or 'False') Check to automatically place the trace test structure."
},
"Interlayer Via Test": {
"Layer Number 1": "type:(layer number integer or layer name string) Enter the first layer for the interlayer via test structure.",
"Layer Number 2": "type:(layer number integer or layer name string) Enter the second layer for the interlayer via test structure.",
"Via Layer": "type:(layer number integer or layer name string) Enter the via layer for the interlayer via test structure.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the interlayer via test structure in um.",
"Text": "type(string) Enter the text to display on the structure.",
"Layer 1 Rectangle Spacing": "type:(number) Enter the spacing between rectangles on layer 1 in um.",
"Layer 1 Rectangle Width": "type:(number) Enter the width of the rectangles on layer 1 in um.",
"Layer 1 Rectangle Height": "type:(number) Enter the height of the rectangles on layer 1 in um.",
"Layer 2 Rectangle Width": "type:(number) Enter the width of the rectangles on layer 2 in um.",
"Layer 2 Rectangle Height": "type:(number) Enter the height of the rectangles on layer 2 in um.",
"Via Width": "type:(number) Enter the width of the vias in um.",
"Via Height": "type:(number) Enter the height of the vias in um.",
"Text Height": "type:(number) Enter the height of the text in um.",
"Automatic Placement": "type:(case-ignored string 'True' or 'False') Check to automatically place the interlayer via test structure."
},
"Electronics Via Test": {
"Layer Number 1": "type:(layer number integer or layer name string) Enter the first layer for the electronics via test structure.",
"Layer Number 2": "type:(layer number integer or layer name string) Enter the second layer for the electronics via test structure.",
"Via Layer": "type:(layer number integer or layer name string) Enter the via layer for the electronics via test structure.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the electronics via test structure in um.",
"Text": "type:(string) Enter the text to display on the structure.",
"Layer 1 Rect Width": "type:(number) Enter the width of the rectangles on layer 1 in um.",
"Layer 1 Rect Height": "type:(number) Enter the height of the rectangles on layer 1 in um.",
"Layer 2 Rect Width": "type:(number) Enter the width of the rectangles on layer 2 in um.",
"Layer 2 Rect Height": "type:(number) Enter the height of the rectangles on layer 2 in um.",
"Layer 2 Rect Spacing": "type:(number) Enter the spacing between rectangles on layer 2 in um.",
"Via Width": "type:(number) Enter the width of the vias in um.",
"Via Height": "type:(number) Enter the height of the vias in um.",
"Via Spacing": "type:(number) Enter the spacing between vias and edge of rectangles in layer 2 in um.",
"Text Height": "type:(number) Enter the height of the text in um.",
"Automatic Placement": "type:(case-ignored string 'True' or 'False') Check to automatically place the electronics via test structure."
},
"Short Test": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the short test structure.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the short test structure in um.",
"Text": "type:(string) Enter the text to display on the structure.",
"Rect Width": "type:(number) Enter the width of the rectangles in um.",
"Trace Width": "type:(number) Enter the width of the traces in um.",
"Trace Space": "type:(number) Enter the spacing between traces in um.",
"Num Lines": "type:(integer) Enter the number of lines.",
"Group Spacing": "type:(number) Enter the spacing between groups in um.",
"Num Groups": "type:(integer) Enter the number of groups.",
"Num Lines Vert": "type:(integer) Enter the number of lines in the vertical direction.",
"Text Height": "type:(number) Enter the height of the text in um.",
"Automatic Placement": "type:(case-ignored string 'True' or 'False') Check to automatically place the short test structure."
},
"Rectangle": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the rectangle.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the rectangle in um.",
"Width": "type:(number) Enter the width of the rectangle in um.",
"Height": "type:(number) Enter the height of the rectangle in um.",
"Lower Left": "type:(comma-separated tuple x,y) Enter the lower left (x, y) coordinate of the rectangle in um.",
"Upper Right": "type:(comma-separated tuple x,y) Enter the upper right (x, y) coordinate of the rectangle in um.",
"Rotation": "type:(number) Enter the rotation angle of the rectangle in degrees."
},
"Circle": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the circle.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the circle in um.",
"Diameter": "type:(number) Enter the diameter of the circle in um."
},
"Text": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the text.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the text in um.",
"Text": "type:(string) Enter the text to display.",
"Height": "type:(number) Enter the height of the text in um.",
"Rotation": "type:(number) Enter the rotation angle of the text in degrees."
},
"Polygon": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the polygon."
},
"Path": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the path.",
"Width": "type(number) Enter the width of the path in um."
},
"Escape Routing": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the escape routing.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the escape routing in um.",
"Copies X": "type:(integer) Enter the number of copies in the x direction.",
"Copies Y": "type:(integer) Enter the number of copies in the y direction.",
"Pitch X": "type:(number) Enter the center-to-center pitch between copies in the x direction in um.",
"Pitch Y": "type:(number) Enter the center-to-center pitch between copies in the y direction in um.",
"Trace Width": "type:(number) Enter the width of the traces in um.",
"Trace Space": "type:(number) Enter the spacing between traces in um.",
"Pad Diameter": "type:(number) Enter the diameter of the pads in um.",
"Orientation": "type:(comma-separated tuple #sides,direction. Examples of valid orientations include '1,-y', '2,x', '3,+x', and '4'.) Enter the orientation of the escape routing.",
"Escape Extent": "type:(number) Enter the extent of the escape routing in um.",
"Cable Tie Routing Angle": "type:(either 45 or 90) Enter the angle of the cable tie routing in degrees",
"Autorouting Angle": "type:(either 45 or 90) Enter the angle for autorouting in degrees ."
},
"Register Ports": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the ports.",
"Orientation": "type:(integer 0, 90, 180, or 270) Enter the orientation of the ports.",
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the ports in um.",
"Num Ports": "type:(integer) Enter the number of ports.",
"Trace Width": "type:(number) Enter the width of the traces in um.",
"Trace Space": "type:(number) Enter the spacing between traces in um."
},
"Connect Rows": {
"Layer": "type:(layer number integer or layer name string) Enter the layer for the connect rows.",
"Row 1 Start": "type:(number) Enter the start position of the first row in um.",
"Row 1 End": "type:(number) Enter the end position of the first row in um.",
"Row 1 Spacing": "type:(number) Enter the spacing between elements in the first row in um.",
"Row 1 Constant": "type:(number) Enter the constant value for the first row in um.",
"Row 2 Start": "type:(number) Enter the start position of the second row in um.",
"Row 2 End": "type:(number) Enter the end position of the second row in um.",
"Row 2 Spacing": "type:(number) Enter the spacing between elements in the second row in um.",
"Row 2 Constant": "type:(number) Enter the constant value for the second row in um.",
"Orientation": "type:(direction string '+x', '-x', '+y', or '-y') Enter the orientation of the connect rows.",
"Trace Width": "type:(number) Enter the width of the traces in um.",
"Escape Extent": "type:(number) Enter the extent of the escape segment in um.",
},
"Custom Test Structure": {
"Center": "type:(comma-separated tuple x,y) Enter the center (x, y) coordinate of the custom test structure in um.",
"Magnification": "type:(number) Enter the magnification factor of the custom test structure.",
"Rotation": "type:(number) Enter the rotation angle of the custom test structure in degrees.",
"X Reflection": "type:(case-ignored string 'True' or 'False') Check to reflect the structure in the x direction.",
"Array": "type:(case-ignored string 'True' or 'False') Check to create an array of the structure.",
"Copies X": "type:(integer) Enter the number of copies in the x direction.",
"Copies Y": "type:(integer) Enter the number of copies in the y direction.",
"Pitch X": "type:(number) Enter the center-to-center pitch between copies in the x direction in um.",
"Pitch Y": "type:(number) Enter the center-to-center pitch between copies in the y direction in um.",
"Automatic Placement": "type:(case-ignored string 'True' or 'False') Check to automatically place the custom test structure."
}
}
self.defaultParams = {
"MLA Alignment Mark": {
"Layer": '',
"Center": '',
"Outer Rect Width": 500,
"Outer Rect Height": 20,
"Interior Width": 5,
"Interior X Extent": 50,
"Interior Y Extent": 50,
"Automatic Placement": False
},
"Resistance Test": {
"Layer": '',
"Center": '',
"Probe Pad Width": 1000,
"Probe Pad Height": 1000,
"Probe Pad Spacing": 3000,
"Plug Width": 200,
"Plug Height": 200,
"Trace Width": 5,
"Trace Spacing": 50,
"Switchbacks": 18,
"X Extent": 100,
"Text Height": 100,
"Text": '',
"Add Interlayer Short": False,
"Layer Name Short": '',
"Short Text": '',
"Automatic Placement": False
},
"Trace Test": {
"Layer": '',
"Center": '',
"Text": '',
"Line Width": 800,
"Line Height": 80,
"Num Lines": 4,
"Line Spacing": 80,
"Text Height": 100,
"Automatic Placement": False
},
"Interlayer Via Test": {
"Layer Number 1": '',
"Layer Number 2": '',
"Via Layer": '',
"Center": '',
"Text": '',
"Layer 1 Rectangle Spacing": 150,
"Layer 1 Rectangle Width": 700,
"Layer 1 Rectangle Height": 250,
"Layer 2 Rectangle Width": 600,
"Layer 2 Rectangle Height": 550,
"Via Width": 7,
"Via Height": 7,
"Text Height": 100,
"Automatic Placement": False
},
"Electronics Via Test": {
"Layer Number 1": '',
"Layer Number 2": '',
"Via Layer": '',
"Center": '',
"Text": '',
"Layer 1 Rect Width": 1550,
"Layer 1 Rect Height": 700,
"Layer 2 Rect Width": 600,
"Layer 2 Rect Height": 600,
"Layer 2 Rect Spacing": 250,
"Via Width": 7,
"Via Height": 7,
"Via Spacing": 10,
"Text Height": 100,
"Automatic Placement": False
},
"Short Test": {
"Layer": '',
"Center": '',
"Text": '',
"Rect Width": 1300,
"Trace Width": 5,
"Trace Space": 5,
"Num Lines": 5,
"Group Spacing": 130,
"Num Groups": 6,
"Num Lines Vert": 100,
"Text Height": 100,
"Automatic Placement": False
},
"Rectangle": {
"Layer": '',
"Center": '',
"Width": '',
"Height": '',
"Lower Left": '',
"Upper Right": '',
"Rotation": 0
},
"Circle": {
"Layer": '',
"Center": '',
"Diameter": ''
},
"Text": {
"Layer": '',
"Center": '',
"Text": '',
"Height": 100,
"Rotation": 0
},
"Polygon": {
"Layer": ''
},
"Path": {
"Layer": '',
"Width": ''
},
"Escape Routing": {
"Layer": '',
"Center": '',
"Copies X": '',
"Copies Y": '',
"Pitch X": '',
"Pitch Y": '',
"Trace Width": '',
"Trace Space": '',
"Pad Diameter": '',
"Orientation": '',
"Escape Extent": 100,
"Cable Tie Routing Angle": 45,
"Autorouting Angle": 45
},
"Register Ports": {
"Layer": '',
"Orientation": '',
"Center": '',
"Num Ports": '',
"Trace Width": '',
"Trace Space": ''
},
"Connect Rows": {
"Layer": '',
"Row 1 Start": '',
"Row 1 End": '',
"Row 1 Spacing": '',
"Row 1 Constant": '',
"Row 2 Start": '',
"Row 2 End": '',
"Row 2 Spacing": '',
"Row 2 Constant": '',
"Orientation": '',
"Trace Width": '',
"Escape Extent": 100,
},
"Custom Test Structure": {
"Center": '',
"Magnification": 1,
"Rotation": 0,
"X Reflection": False,
"Array": False,
"Copies X": 1,
"Copies Y": 1,
"Pitch X": 0,
"Pitch Y": 0,
"Automatic Placement": False
}
}
self.testStructures = [] # Initialize testStructures here
self.gds_design = None # To store the GDSDesign instance
self.custom_design = None # To store the custom design instance
self.polygon_points = [] # To store polygon points
self.path_points = [] # To store path points
self.undoStack = [] # Initialize undo stack
self.redoStack = [] # Initialize redo stack
self.escapeDicts = {} # To store escape routing dictionaries
self.routing = []
self.routingMode = False
self.flareMode = False
self.pitch_x = None
self.pitch_y = None
self.copies_x = None
self.copies_y = None
self.center_escape = None
self.initUI()
def initUI(self):
# Set a global stylesheet for the entire application
font_size = 28 # Adjust the font size as needed
self.setStyleSheet(f"""
QToolTip {{
background-color: yellow;
color: black;
border: 1px solid black;
}}
QWidget {{
font-size: {font_size}px;
}}
QLineEdit {{
font-size: {font_size}px;
}}
QPushButton {{
font-size: {font_size}px;
}}
QLabel {{
font-size: {font_size}px;
}}
QComboBox {{
font-size: {font_size}px;
}}
QCheckBox {{
font-size: {font_size}px;
}}
QToolTip {{
font-size: {font_size}px;
}}
""")
# Main Layout
mainLayout = QHBoxLayout() # Changed to QHBoxLayout
# Left Layout (contains all the menus)
leftLayout = QVBoxLayout()
# Write to GDS button
self.writeButton = QPushButton('Write to GDS')
self.writeButton.clicked.connect(self.writeToGDS)
self.writeButton.setToolTip('Click to write the current design to a GDS file.')
self.writeButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
# File selection layout
fileLayout = QHBoxLayout()
fileMenuLabel = QLabel('File Menu')
leftLayout.addWidget(fileMenuLabel)
self.initFileButton = QPushButton('Select Input File')
self.initFileButton.clicked.connect(self.selectInputFile)
self.initFileButton.setToolTip('Click to select the input GDS file.')
self.initFileButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.blankFileButton = QPushButton('Create Blank Design')
self.blankFileButton.clicked.connect(self.createBlankDesign)
self.blankFileButton.setToolTip('Click to create a blank design.')
self.blankFileButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.outFileField = PushButtonEdit(self.writeButton)
self.outFileField.setPlaceholderText('Output File')
self.outFileField.editingFinished.connect(self.validateOutputFileName)
self.outFileField.setToolTip("type:(filename or path ending with '.gds') Enter the name of the output GDS file.")
self.outFileField.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
fileLayout.addWidget(self.initFileButton)
fileLayout.addWidget(self.blankFileButton)
fileLayout.addWidget(self.outFileField)
leftLayout.addLayout(fileLayout)
# Undo and Redo buttons
undoRedoLayout = QHBoxLayout()
self.undoButton = QPushButton('Undo')
self.undoButton.clicked.connect(self.undo)
self.undoButton.setToolTip('Undo the last action.')
self.undoButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.redoButton = QPushButton('Redo')
self.redoButton.clicked.connect(self.redo)
self.redoButton.setToolTip('Redo the previously undone action.')
self.redoButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
undoRedoLayout.addWidget(self.undoButton)
undoRedoLayout.addWidget(self.redoButton)
leftLayout.addLayout(undoRedoLayout)
# Add cell dropdown and Matplotlib Button
plotLayout = QHBoxLayout()
plotMenuLabel = QLabel('Interactive Plotting Menu')
leftLayout.addWidget(plotMenuLabel)
self.cellComboBox = QComboBox()
self.cellComboBox.setToolTip('Select a cell from the loaded GDS file.')
self.cellComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
plotLayout.addWidget(self.cellComboBox)
self.plotLayersComboBox = QComboBox()
self.plotLayersComboBox.setToolTip('Select a layer from the list to plot for the cell.')
self.plotLayersComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
plotLayout.addWidget(self.plotLayersComboBox)
self.matplotlibButton = QPushButton('Routing Tool')
self.matplotlibButton.clicked.connect(self.showMatplotlibWindow)
self.matplotlibButton.setToolTip('Click to show an interactive plot of the selected cell for routing.')
self.matplotlibButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
plotLayout.addWidget(self.matplotlibButton)
leftLayout.addLayout(plotLayout)
# Die Placement Utility Button
self.diePlacementButton = QPushButton('Open Die Placement Menu')
self.diePlacementButton.clicked.connect(self.showDiePlacementUtility)
self.diePlacementButton.setToolTip('Click to open the Die Placement menu.')
self.diePlacementButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
leftLayout.addWidget(self.diePlacementButton)
# Test Structures layout
testLayout = QVBoxLayout()
testLabel = QLabel('Add Components (NOTE: all spatial units are in microns)')
testLayout.addWidget(testLabel)
gridLayout = QGridLayout()
row = 0
for name in self.testStructureNames:
testCheckBox = QCheckBox(name)
testCheckBox.stateChanged.connect(self.createCheckStateHandler)
testCheckBox.setToolTip(f'Check to include {name} in the design.')
testCheckBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
cellBoxLabel = QLabel('Cell Name')
cellBoxLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
testCellComboBox = QComboBox()
testCellComboBox.setPlaceholderText(f'Select Cell to Place {name}')
testCellComboBox.setToolTip(f'Select the cell on which to place {name}.')
testCellComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
paramLabel = QLabel('Parameters')
paramLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
paramComboBox = TooltipComboBox()
paramComboBox.addItems(self.parameters[name])
paramComboBox.setItemTooltips([self.paramTooltips[name].get(param, '') for param in self.parameters[name]])
paramComboBox.currentTextChanged.connect(self.createParamChangeHandler)
paramComboBox.setToolTip(f'Select parameters for {name}.')
paramComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
addButton = QPushButton("Add to Design")
addButton.clicked.connect(self.createAddToDesignHandler)
addButton.setToolTip(f'Click to add {name} to the design.')
addButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
paramValueEdit = CycleLineEdit(paramComboBox, addButton) # Use CycleLineEdit instead of QLineEdit
paramName = paramComboBox.currentText()
if paramName in self.defaultParams[name]:
paramValueEdit.setText(str(self.defaultParams[name][paramName]))
paramValueEdit.editingFinished.connect(self.createParamStoreHandler)
paramValueEdit.setToolTip(f'Enter value for the selected parameter of {name}.')
paramValueEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
gridLayout.addWidget(testCheckBox, row, 0)
gridLayout.addWidget(cellBoxLabel, row, 1)
gridLayout.addWidget(testCellComboBox, row, 2)
gridLayout.addWidget(paramLabel, row, 3)
gridLayout.addWidget(paramComboBox, row, 4)
gridLayout.addWidget(paramValueEdit, row, 5)
gridLayout.addWidget(addButton, row, 6)
if name == "Polygon":
self.polygonButton = QPushButton('Select Polygon Points File')
self.polygonButton.clicked.connect(self.selectPolygonPointsFile)
self.polygonButton.setToolTip('Click to select a file containing polygon points.')
self.polygonButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
gridLayout.addWidget(self.polygonButton, row, 7)
if name == "Path":
self.pathButton = QPushButton('Select Path Points File')
self.pathButton.clicked.connect(self.selectPathPointsFile)
self.pathButton.setToolTip('Click to select a file containing path points.')
self.pathButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
gridLayout.addWidget(self.pathButton, row, 7)
if name == "Escape Routing":
self.escapeButton = QPushButton('Select Escape Routing File')
self.escapeButton.clicked.connect(self.selectEscapeRoutingFile)
self.escapeButton.setToolTip('Click to select a file containing pad coordinates for escape routing.')
self.escapeButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
gridLayout.addWidget(self.escapeButton, row, 7)
if name == "Custom Test Structure":
self.customTestCellComboBox = QComboBox()
self.customTestCellComboBox.setPlaceholderText("Select Custom Test Structure Cell")
self.customTestCellComboBox.activated.connect(self.handleCustomTestCellName)
self.customTestCellComboBox.setToolTip('Select a custom test structure cell.')
self.customTestCellComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
gridLayout.addWidget(self.customTestCellComboBox, row, 7)
# New button to select other .gds file
self.selectOtherGDSButton = QPushButton('Select Other .gds File')
self.selectOtherGDSButton.clicked.connect(self.selectOtherGDSFile)
self.selectOtherGDSButton.setToolTip('Click to select another .gds file.')
self.selectOtherGDSButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
gridLayout.addWidget(self.selectOtherGDSButton, row, 8)
# Reset file button
self.resetOtherGDSButton = QPushButton('Reset Other .gds File')
self.resetOtherGDSButton.clicked.connect(self.resetOtherGDSFile)
self.resetOtherGDSButton.setToolTip('Click to reset the other .gds file.')
self.resetOtherGDSButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
gridLayout.addWidget(self.resetOtherGDSButton, row, 9)
self.resetOtherGDSButton.hide()
row += 1
defaultParams = deepcopy(self.defaultParams[name])
self.testStructures.append((testCheckBox, testCellComboBox, paramComboBox, paramValueEdit, defaultParams, addButton))
testLayout.addLayout(gridLayout)
leftLayout.addLayout(testLayout)
# Layers layout
layersHBoxLayout = QHBoxLayout() # Change from QVBoxLayout to QHBoxLayout
layerAndCellMenuLabel = QLabel('Layers and Cells Menu')
leftLayout.addWidget(layerAndCellMenuLabel)
layersLabel = QLabel('Layers:')
layersLabel.setToolTip('Layers available in the design.')
layersLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layersHBoxLayout.addWidget(layersLabel)
self.layersComboBox = QComboBox()
self.layersComboBox.setToolTip('Select a layer from the list.')
self.layersComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layersHBoxLayout.addWidget(self.layersComboBox)
self.selectSubstrateLayerButton = QPushButton('Select Substrate Layer')
self.selectSubstrateLayerButton.clicked.connect(self.selectSubstrateLayer)
self.selectSubstrateLayerButton.setToolTip('Click to select the substrate layer from the dropdown menu.')
self.selectSubstrateLayerButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layersHBoxLayout.addWidget(self.selectSubstrateLayerButton)
# New Excluded Layers input field
self.excludedLayersEdit = QLineEdit()
self.excludedLayersEdit.setPlaceholderText('Excluded Layers')
self.excludedLayersEdit.editingFinished.connect(self.updateExcludedLayers)
self.excludedLayersEdit.setToolTip('type:(comma-separated list of layer number integers or layer name strings) Enter comma-separated list of layer numbers or names to exclude from automatic placement search.')
self.excludedLayersEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layersHBoxLayout.addWidget(self.excludedLayersEdit)
# New Calculate Layer Area button and Layer Area text box
self.calculateLayerAreaButton = QPushButton('Calculate Layer Area')
self.calculateLayerAreaButton.clicked.connect(self.calculateLayerArea)
self.calculateLayerAreaButton.setToolTip('Click to calculate the area for the selected layer.')
self.calculateLayerAreaButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layersHBoxLayout.addWidget(self.calculateLayerAreaButton)
self.layerCellComboBox = QComboBox()
self.layerCellComboBox.setPlaceholderText("Select cell on which to calculate area")
self.layerCellComboBox.setToolTip("Select cell on which to calculate area (optional, will default to the first top cell in design if not provided)")
self.layerCellComboBox.currentTextChanged.connect(self.calculateLayerArea)
self.layerCellComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layersHBoxLayout.addWidget(self.layerCellComboBox)
self.layerAreaEdit = QLineEdit()
self.layerAreaEdit.setPlaceholderText('Layer Area (mm^2)')
self.layerAreaEdit.setReadOnly(True)
self.layerAreaEdit.setToolTip('Displays the calculated area of the selected layer in mm^2.')
self.layerAreaEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
layersHBoxLayout.addWidget(self.layerAreaEdit)
# Invert Layer Layout
invertLayerHBoxLayout = QHBoxLayout()
invertLayerButton = QPushButton('Invert Layer')
invertLayerButton.clicked.connect(self.invertLayer)
invertLayerButton.setToolTip('Click to invert the selected layer.')
invertLayerButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
invertLayerComboBoxLabel = QLabel('Select Layer to Invert:')
self.invertLayerComboBox = QComboBox()
self.invertLayerComboBox.setToolTip('Select a layer to invert.')
self.invertLayerComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
invertLayerCellComboBoxLabel = QLabel('Select Cell to Invert:')
self.invertLayerCellComboBox = QComboBox()
self.invertLayerCellComboBox.setToolTip('Select a cell to invert.')
self.invertLayerCellComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
inverLayerOutputComboBoxLabel = QLabel('Select Output Layer:')
self.invertLayerOutputComboBox = QComboBox()
self.invertLayerOutputComboBox.setToolTip('Select the output layer for the inverted layer.')
self.invertLayerOutputComboBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
invertLayerHBoxLayout.addWidget(invertLayerComboBoxLabel)
invertLayerHBoxLayout.addWidget(self.invertLayerComboBox)
invertLayerHBoxLayout.addWidget(invertLayerCellComboBoxLabel)
invertLayerHBoxLayout.addWidget(self.invertLayerCellComboBox)
invertLayerHBoxLayout.addWidget(inverLayerOutputComboBoxLabel)
invertLayerHBoxLayout.addWidget(self.invertLayerOutputComboBox)
invertLayerHBoxLayout.addWidget(invertLayerButton)
# Define Layer layout
defineLayerHBoxLayout = QHBoxLayout()
defineLayerButton = QPushButton('Define New Layer')
defineLayerButton.clicked.connect(self.defineNewLayer)
defineLayerButton.setToolTip('Click to define a new layer.')
defineLayerButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.newLayerNumberEdit = PushButtonEdit(defineLayerButton)
self.newLayerNumberEdit.setPlaceholderText('Layer Number')
self.newLayerNumberEdit.setToolTip('type:(integer) Enter the number of the new layer.')
self.newLayerNumberEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.newLayerNameEdit = PushButtonEdit(defineLayerButton)
self.newLayerNameEdit.setPlaceholderText('Layer Name')
self.newLayerNameEdit.setToolTip('type:(string) Enter the name of the new layer.')
self.newLayerNameEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
defineLayerHBoxLayout.addWidget(self.newLayerNumberEdit)
defineLayerHBoxLayout.addWidget(self.newLayerNameEdit)
defineLayerHBoxLayout.addWidget(defineLayerButton)
# Layers and Define Layer layout
layersVBoxLayout = QVBoxLayout()
layersVBoxLayout.addLayout(layersHBoxLayout)
layersVBoxLayout.addLayout(invertLayerHBoxLayout)
layersVBoxLayout.addLayout(defineLayerHBoxLayout)
leftLayout.addLayout(layersVBoxLayout)
mainLayout.addLayout(leftLayout) # Add the left layout to the main layout
# Plot Area Layout
plotAreaLayout = QVBoxLayout()
self.fig = Figure(figsize=(20, 12)) # Adjust the figsize to make the plot bigger
self.canvas = FigureCanvas(self.fig)
self.ax = self.fig.add_subplot(111)
self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
# Connect the click event to the handler
self.canvas.mpl_connect('button_press_event', self.on_click)
plotAreaLayout.addWidget(self.canvas)
# Add the navigation toolbar to the layout
self.toolbar = NavigationToolbar(self.canvas, self)
plotAreaLayout.addWidget(self.toolbar)
# Add Routing Mode and Flare Mode buttons
modeButtonLayout = QHBoxLayout()
self.routingModeButton = QPushButton('Routing Mode')
self.routingModeButton.clicked.connect(self.setRoutingMode)
self.routingModeButton.setToolTip('Click to enter routing mode.')
self.routingModeButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.flareModeButton = QPushButton('Flare Mode')
self.flareModeButton.clicked.connect(self.setFlareMode)
self.flareModeButton.setToolTip('Click to enter flare (fan out) mode.')
self.flareModeButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
modeButtonLayout.addWidget(self.routingModeButton)
modeButtonLayout.addWidget(self.flareModeButton)
plotAreaLayout.addLayout(modeButtonLayout)
routingModeLayout = QHBoxLayout()
self.showAnimationCheckBox = QCheckBox('Show Animation?')
self.showAnimationCheckBox.setToolTip('Check to show animation of the routing process.')
self.showAnimationCheckBox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.showAnimationCheckBox.stateChanged.connect(self.showAnimationChecked)
self.showAnimationCheckBox.hide()
self.gridSizeEdit = QLineEdit()
self.gridSizeEdit.setPlaceholderText('Grid Size: Default')
self.gridSizeEdit.setToolTip('type:(number) Enter the grid size in um.')
self.gridSizeEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.gridSizeEdit.hide()
routingModeLayout.addWidget(self.showAnimationCheckBox)
routingModeLayout.addWidget(self.gridSizeEdit)
plotAreaLayout.addLayout(routingModeLayout)
# Add text fields for Flare Mode
flareModeLayout = QHBoxLayout()
self.endingTraceWidthEdit = QLineEdit()
self.endingTraceWidthEdit.setPlaceholderText('Ending Trace Width')
self.endingTraceWidthEdit.setToolTip('type:(number) Enter the ending trace width of the fan out in um.')
self.endingTraceWidthEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.endingTraceSpaceEdit = QLineEdit()
self.endingTraceSpaceEdit.setPlaceholderText('Ending Trace Space')
self.endingTraceSpaceEdit.setToolTip('type:(number) Enter the ending trace space of the fan out in um.')
self.endingTraceSpaceEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.flareRoutingAngleEdit = QLineEdit()
self.flareRoutingAngleEdit.setText('90')
self.flareRoutingAngleEdit.setToolTip('type:(45 or 90) Enter the flare routing angle in degrees: 90 degrees is handled with smooth turns.')
self.flareRoutingAngleEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.flareEscapeExtentEdit = QLineEdit()
self.flareEscapeExtentEdit.setText('100')
self.flareEscapeExtentEdit.setToolTip('type:(number) Enter the extent of the escape in um: increasing this can help avoid collisions.')
self.flareEscapeExtentEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.flareFinalLengthEdit = QLineEdit()
self.flareFinalLengthEdit.setText('100')
self.flareFinalLengthEdit.setToolTip('type:(number) Enter the final length of the traces in the flare in um.')
self.flareFinalLengthEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.flareAutoroutingAngleEdit = QLineEdit()
self.flareAutoroutingAngleEdit.setText('45')
self.flareAutoroutingAngleEdit.setToolTip('type:(45 or 90) Enter the angle for autorouting in degrees.')
self.flareAutoroutingAngleEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
flareModeLayout.addWidget(self.endingTraceWidthEdit)
flareModeLayout.addWidget(self.endingTraceSpaceEdit)
flareModeLayout.addWidget(self.flareRoutingAngleEdit)
flareModeLayout.addWidget(self.flareEscapeExtentEdit)
flareModeLayout.addWidget(self.flareFinalLengthEdit)
flareModeLayout.addWidget(self.flareAutoroutingAngleEdit)
plotAreaLayout.addLayout(flareModeLayout)
self.endingTraceWidthEdit.hide()
self.endingTraceSpaceEdit.hide()
self.flareRoutingAngleEdit.hide()
self.flareEscapeExtentEdit.hide()
self.flareFinalLengthEdit.hide()
self.flareAutoroutingAngleEdit.hide()
mainLayout.addLayout(plotAreaLayout) # Add the plot area layout to the main layout
# Define Cell layout
defineCellHBoxLayout = QHBoxLayout()
defineCellButton = QPushButton('Define New Cell')
defineCellButton.clicked.connect(self.defineNewCell)
defineCellButton.setToolTip('Click to define a new cell.')
defineCellButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.newCellNameEdit = PushButtonEdit(defineCellButton)
self.newCellNameEdit.setPlaceholderText('Cell Name')
self.newCellNameEdit.setToolTip('type:(string) Enter the name of the new cell.')
self.newCellNameEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
defineCellHBoxLayout.addWidget(self.newCellNameEdit)
defineCellHBoxLayout.addWidget(defineCellButton)
leftLayout.addLayout(defineCellHBoxLayout)
leftLayout.addWidget(self.writeButton) # Add the write button to the left layout