-
Notifications
You must be signed in to change notification settings - Fork 0
/
FlatCAMGUI.py
979 lines (813 loc) · 35.5 KB
/
FlatCAMGUI.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
############################################################
# FlatCAM: 2D Post-processing for Manufacturing #
# http://flatcam.org #
# Author: Juan Pablo Caram (c) #
# Date: 2/5/2014 #
# MIT Licence #
############################################################
from PyQt4 import QtGui, QtCore, Qt
from GUIElements import *
class FlatCAMGUI(QtGui.QMainWindow):
# Emitted when persistent window geometry needs to be retained
geom_update = QtCore.pyqtSignal(int, int, int, int, name='geomUpdate')
def __init__(self, version, name=None):
super(FlatCAMGUI, self).__init__()
# Divine icon pack by Ipapun @ finicons.com
############
### Menu ###
############
self.menu = self.menuBar()
### File ###
self.menufile = self.menu.addMenu('&File')
# New
self.menufilenew = QtGui.QAction(QtGui.QIcon('share/file16.png'), '&New project', self)
self.menufile.addAction(self.menufilenew)
# Recent
self.recent = self.menufile.addMenu(QtGui.QIcon('share/folder16.png'), "Open recent ...")
# Separator
self.menufile.addSeparator()
# Open gerber ...
self.menufileopengerber = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Gerber ...', self)
self.menufile.addAction(self.menufileopengerber)
# Open Excellon ...
self.menufileopenexcellon = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Excellon ...', self)
self.menufile.addAction(self.menufileopenexcellon)
# Open G-Code ...
self.menufileopengcode = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open G-&Code ...', self)
self.menufile.addAction(self.menufileopengcode)
# Open Project ...
self.menufileopenproject = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Project ...', self)
self.menufile.addAction(self.menufileopenproject)
# Separator
self.menufile.addSeparator()
# Import SVG ...
self.menufileimportsvg = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Import &SVG ...', self)
self.menufile.addAction(self.menufileimportsvg)
# Export SVG ...
self.menufileexportsvg = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Export &SVG ...', self)
self.menufile.addAction(self.menufileexportsvg)
# Separator
self.menufile.addSeparator()
# Save Project
self.menufilesaveproject = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), '&Save Project', self)
self.menufile.addAction(self.menufilesaveproject)
# Save Project As ...
self.menufilesaveprojectas = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project &As ...', self)
self.menufile.addAction(self.menufilesaveprojectas)
# Save Project Copy ...
self.menufilesaveprojectcopy = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project C&opy ...', self)
self.menufile.addAction(self.menufilesaveprojectcopy)
# Save Defaults
self.menufilesavedefaults = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save &Defaults', self)
self.menufile.addAction(self.menufilesavedefaults)
# Separator
self.menufile.addSeparator()
# Quit
self.exit_action = QtGui.QAction(QtGui.QIcon('share/power16.png'), '&Exit', self)
self.menufile.addAction(self.exit_action)
# exitAction.setShortcut('Ctrl+Q')
# exitAction.setStatusTip('Exit application')
#self.exit_action.triggered.connect(QtGui.qApp.quit)
### Edit ###
self.menuedit = self.menu.addMenu('&Edit')
self.menueditnew = self.menuedit.addAction(QtGui.QIcon('share/new_geo16.png'), 'New Geometry')
self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), 'Edit Geometry')
self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), 'Update Geometry')
# Separator
self.menuedit.addSeparator()
self.menueditjoin = self.menuedit.addAction(QtGui.QIcon('share/join16.png'), 'Join Geometry')
self.menueditdelete = self.menuedit.addAction(QtGui.QIcon('share/trash16.png'), 'Delete')
self.menuedit.addSeparator()
### Options ###
self.menuoptions = self.menu.addMenu('&Options')
self.menuoptions_transfer = self.menuoptions.addMenu(QtGui.QIcon('share/transfer.png'), 'Transfer options')
self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction("Application to Project")
self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction("Project to Application")
self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction("Project to Object")
self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction("Object to Project")
self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction("Application to Object")
self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction("Object to Application")
### View ###
self.menuview = self.menu.addMenu('&View')
self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'), 'Disable all plots')
self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
'Disable all plots but this one')
self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), 'Enable all plots')
### Tool ###
self.menutool = QtGui.QMenu('&Tool')
self.menutoolaction = self.menu.addMenu(self.menutool)
self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), '&Command Line')
### Help ###
self.menuhelp = self.menu.addMenu('&Help')
self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/tv16.png'), 'About FlatCAM')
self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), 'Home')
self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), 'Manual')
###############
### Toolbar ###
###############
self.toolbarfile = QtGui.QToolBar('File Toolbar')
self.addToolBar(self.toolbarfile)
self.open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'), "Open &Gerber")
self.open_exc_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open &Excellon")
self.open_gcode_btn = self.toolbarfile.addAction(QtGui.QIcon('share/cnc32.png'), "Open Gco&de")
self.save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), 'Save Project &As ...')
self.toolbarview= QtGui.QToolBar('View Toolbar')
self.addToolBar(self.toolbarview)
self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "&Zoom Fit")
self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "&Zoom Out")
self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "&Zoom In")
# Separator
self.toolbarview.addSeparator()
self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear Plot")
self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
self.toolbareditobj = QtGui.QToolBar('Obj.Editor Toolbar')
self.addToolBar(self.toolbareditobj)
self.newgeo_btn = self.toolbareditobj.addAction(QtGui.QIcon('share/new_geo32.png'), "New Blank Geometry")
self.editgeo_btn = self.toolbareditobj.addAction(QtGui.QIcon('share/edit32.png'), "Edit Geometry")
self.updategeo_btn = self.toolbareditobj.addAction(QtGui.QIcon('share/edit_ok32.png'), "Update Geometry")
self.updategeo_btn.setEnabled(False)
self.toolbaredit = QtGui.QToolBar('Edit Toolbar')
self.addToolBar(self.toolbaredit)
self.delete_btn = self.toolbaredit.addAction(QtGui.QIcon('share/delete32.png'), "&Delete")
self.toolbartools = QtGui.QToolBar('Tools Toolbar')
self.addToolBar(self.toolbartools)
self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
self.measure_btn = self.toolbartools.addAction(QtGui.QIcon('share/measure32.png'), "&Measurement Tool")
################
### Splitter ###
################
self.splitter = QtGui.QSplitter()
self.setCentralWidget(self.splitter)
################
### Notebook ###
################
self.notebook = QtGui.QTabWidget()
# self.notebook.setMinimumWidth(250)
### Project ###
project_tab = QtGui.QWidget()
project_tab.setMinimumWidth(250) # Hack
self.project_tab_layout = QtGui.QVBoxLayout(project_tab)
self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
self.notebook.addTab(project_tab, "Project")
### Selected ###
self.selected_tab = QtGui.QWidget()
self.selected_tab_layout = QtGui.QVBoxLayout(self.selected_tab)
self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
self.selected_scroll_area = VerticalScrollArea()
self.selected_tab_layout.addWidget(self.selected_scroll_area)
self.notebook.addTab(self.selected_tab, "Selected")
### Options ###
self.options_tab = QtGui.QWidget()
self.options_tab.setContentsMargins(0, 0, 0, 0)
self.options_tab_layout = QtGui.QVBoxLayout(self.options_tab)
self.options_tab_layout.setContentsMargins(2, 2, 2, 2)
hlay1 = QtGui.QHBoxLayout()
self.options_tab_layout.addLayout(hlay1)
self.icon = QtGui.QLabel()
self.icon.setPixmap(QtGui.QPixmap('share/gear48.png'))
hlay1.addWidget(self.icon)
self.options_combo = QtGui.QComboBox()
self.options_combo.addItem("APPLICATION DEFAULTS")
self.options_combo.addItem("PROJECT OPTIONS")
hlay1.addWidget(self.options_combo)
hlay1.addStretch()
self.options_scroll_area = VerticalScrollArea()
self.options_tab_layout.addWidget(self.options_scroll_area)
self.notebook.addTab(self.options_tab, "Options")
### Tool ###
self.tool_tab = QtGui.QWidget()
self.tool_tab_layout = QtGui.QVBoxLayout(self.tool_tab)
self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
self.notebook.addTab(self.tool_tab, "Tool")
self.tool_scroll_area = VerticalScrollArea()
self.tool_tab_layout.addWidget(self.tool_scroll_area)
self.splitter.addWidget(self.notebook)
######################
### Plot and other ###
######################
right_widget = QtGui.QWidget()
# right_widget.setContentsMargins(0, 0, 0, 0)
self.splitter.addWidget(right_widget)
self.right_layout = QtGui.QVBoxLayout()
self.right_layout.setMargin(0)
# self.right_layout.setContentsMargins(0, 0, 0, 0)
right_widget.setLayout(self.right_layout)
################
### Info bar ###
################
infobar = self.statusBar()
#self.info_label = QtGui.QLabel("Welcome to FlatCAM.")
#self.info_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
#infobar.addWidget(self.info_label, stretch=1)
self.fcinfo = FlatCAMInfoBar()
infobar.addWidget(self.fcinfo, stretch=1)
self.position_label = QtGui.QLabel("")
#self.position_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
self.position_label.setMinimumWidth(110)
infobar.addWidget(self.position_label)
self.units_label = QtGui.QLabel("[in]")
# self.units_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
self.units_label.setMargin(2)
infobar.addWidget(self.units_label)
self.progress_bar = QtGui.QProgressBar()
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(100)
#infobar.addWidget(self.progress_bar)
self.activity_view = FlatCAMActivityView()
infobar.addWidget(self.activity_view)
#############
### Icons ###
#############
self.app_icon = QtGui.QIcon()
self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
self.setWindowIcon(self.app_icon)
self.setGeometry(100, 100, 1024, 650)
title = 'FlatCAM {}'.format(version)
if name is not None:
title += ' - {}'.format(name)
self.setWindowTitle(title)
self.show()
def closeEvent(self, event):
grect = self.geometry()
self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height())
QtGui.qApp.quit()
class FlatCAMActivityView(QtGui.QWidget):
def __init__(self, parent=None):
super(FlatCAMActivityView, self).__init__(parent=parent)
self.setMinimumWidth(200)
self.icon = QtGui.QLabel(self)
self.icon.setGeometry(0, 0, 12, 12)
self.movie = QtGui.QMovie("share/active.gif")
self.icon.setMovie(self.movie)
#self.movie.start()
layout = QtGui.QHBoxLayout()
layout.setContentsMargins(5, 0, 5, 0)
layout.setAlignment(QtCore.Qt.AlignLeft)
self.setLayout(layout)
layout.addWidget(self.icon)
self.text = QtGui.QLabel(self)
self.text.setText("Idle.")
layout.addWidget(self.text)
def set_idle(self):
self.movie.stop()
self.text.setText("Idle.")
def set_busy(self, msg):
self.movie.start()
self.text.setText(msg)
class FlatCAMInfoBar(QtGui.QWidget):
def __init__(self, parent=None):
super(FlatCAMInfoBar, self).__init__(parent=parent)
self.icon = QtGui.QLabel(self)
self.icon.setGeometry(0, 0, 12, 12)
self.pmap = QtGui.QPixmap('share/graylight12.png')
self.icon.setPixmap(self.pmap)
layout = QtGui.QHBoxLayout()
layout.setContentsMargins(5, 0, 5, 0)
self.setLayout(layout)
layout.addWidget(self.icon)
self.text = QtGui.QLabel(self)
self.text.setText("Hello!")
self.text.setToolTip("Hello!")
layout.addWidget(self.text)
layout.addStretch()
def set_text_(self, text):
self.text.setText(text)
self.text.setToolTip(text)
def set_status(self, text, level="info"):
level = str(level)
self.pmap.fill()
if level == "error":
self.pmap = QtGui.QPixmap('share/redlight12.png')
elif level == "success":
self.pmap = QtGui.QPixmap('share/greenlight12.png')
elif level == "warning":
self.pmap = QtGui.QPixmap('share/yellowlight12.png')
else:
self.pmap = QtGui.QPixmap('share/graylight12.png')
self.icon.setPixmap(self.pmap)
self.set_text_(text)
class OptionsGroupUI(QtGui.QGroupBox):
def __init__(self, title, parent=None):
QtGui.QGroupBox.__init__(self, title, parent=parent)
self.setStyleSheet("""
QGroupBox
{
font-size: 16px;
font-weight: bold;
}
""")
self.layout = QtGui.QVBoxLayout()
self.setLayout(self.layout)
class GerberOptionsGroupUI(OptionsGroupUI):
def __init__(self, parent=None):
OptionsGroupUI.__init__(self, "Gerber Options", parent=parent)
## Plot options
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
self.layout.addWidget(self.plot_options_label)
grid0 = QtGui.QGridLayout()
self.layout.addLayout(grid0)
# Plot CB
self.plot_cb = FCCheckBox(label='Plot')
self.plot_options_label.setToolTip(
"Plot (show) this object."
)
grid0.addWidget(self.plot_cb, 0, 0)
# Solid CB
self.solid_cb = FCCheckBox(label='Solid')
self.solid_cb.setToolTip(
"Solid color polygons."
)
grid0.addWidget(self.solid_cb, 0, 1)
# Multicolored CB
self.multicolored_cb = FCCheckBox(label='Multicolored')
self.multicolored_cb.setToolTip(
"Draw polygons in different colors."
)
grid0.addWidget(self.multicolored_cb, 0, 2)
## Isolation Routing
self.isolation_routing_label = QtGui.QLabel("<b>Isolation Routing:</b>")
self.isolation_routing_label.setToolTip(
"Create a Geometry object with\n"
"toolpaths to cut outside polygons."
)
self.layout.addWidget(self.isolation_routing_label)
grid1 = QtGui.QGridLayout()
self.layout.addLayout(grid1)
tdlabel = QtGui.QLabel('Tool dia:')
tdlabel.setToolTip(
"Diameter of the cutting tool."
)
grid1.addWidget(tdlabel, 0, 0)
self.iso_tool_dia_entry = LengthEntry()
grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
passlabel = QtGui.QLabel('Width (# passes):')
passlabel.setToolTip(
"Width of the isolation gap in\n"
"number (integer) of tool widths."
)
grid1.addWidget(passlabel, 1, 0)
self.iso_width_entry = IntEntry()
grid1.addWidget(self.iso_width_entry, 1, 1)
overlabel = QtGui.QLabel('Pass overlap:')
overlabel.setToolTip(
"How much (fraction of tool width)\n"
"to overlap each pass."
)
grid1.addWidget(overlabel, 2, 0)
self.iso_overlap_entry = FloatEntry()
grid1.addWidget(self.iso_overlap_entry, 2, 1)
self.combine_passes_cb = FCCheckBox(label='Combine Passes')
self.combine_passes_cb.setToolTip(
"Combine all passes into one object"
)
grid1.addWidget(self.combine_passes_cb, 3, 0)
## Board cuttout
self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
self.board_cutout_label.setToolTip(
"Create toolpaths to cut around\n"
"the PCB and separate it from\n"
"the original board."
)
self.layout.addWidget(self.board_cutout_label)
grid2 = QtGui.QGridLayout()
self.layout.addLayout(grid2)
tdclabel = QtGui.QLabel('Tool dia:')
tdclabel.setToolTip(
"Diameter of the cutting tool."
)
grid2.addWidget(tdclabel, 0, 0)
self.cutout_tooldia_entry = LengthEntry()
grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
marginlabel = QtGui.QLabel('Margin:')
marginlabel.setToolTip(
"Distance from objects at which\n"
"to draw the cutout."
)
grid2.addWidget(marginlabel, 1, 0)
self.cutout_margin_entry = LengthEntry()
grid2.addWidget(self.cutout_margin_entry, 1, 1)
gaplabel = QtGui.QLabel('Gap size:')
gaplabel.setToolTip(
"Size of the gaps in the toolpath\n"
"that will remain to hold the\n"
"board in place."
)
grid2.addWidget(gaplabel, 2, 0)
self.cutout_gap_entry = LengthEntry()
grid2.addWidget(self.cutout_gap_entry, 2, 1)
gapslabel = QtGui.QLabel('Gaps:')
gapslabel.setToolTip(
"Where to place the gaps, Top/Bottom\n"
"Left/Rigt, or on all 4 sides."
)
grid2.addWidget(gapslabel, 3, 0)
self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
{'label': '2 (L/R)', 'value': 'lr'},
{'label': '4', 'value': '4'}])
grid2.addWidget(self.gaps_radio, 3, 1)
## Non-copper regions
self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
self.noncopper_label.setToolTip(
"Create polygons covering the\n"
"areas without copper on the PCB.\n"
"Equivalent to the inverse of this\n"
"object. Can be used to remove all\n"
"copper from a specified region."
)
self.layout.addWidget(self.noncopper_label)
grid3 = QtGui.QGridLayout()
self.layout.addLayout(grid3)
# Margin
bmlabel = QtGui.QLabel('Boundary Margin:')
bmlabel.setToolTip(
"Specify the edge of the PCB\n"
"by drawing a box around all\n"
"objects with this minimum\n"
"distance."
)
grid3.addWidget(bmlabel, 0, 0)
self.noncopper_margin_entry = LengthEntry()
grid3.addWidget(self.noncopper_margin_entry, 0, 1)
# Rounded corners
self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
self.noncopper_rounded_cb.setToolTip(
"Creates a Geometry objects with polygons\n"
"covering the copper-free areas of the PCB."
)
grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
## Bounding box
self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
self.layout.addWidget(self.boundingbox_label)
grid4 = QtGui.QGridLayout()
self.layout.addLayout(grid4)
bbmargin = QtGui.QLabel('Boundary Margin:')
bbmargin.setToolTip(
"Distance of the edges of the box\n"
"to the nearest polygon."
)
grid4.addWidget(bbmargin, 0, 0)
self.bbmargin_entry = LengthEntry()
grid4.addWidget(self.bbmargin_entry, 0, 1)
self.bbrounded_cb = FCCheckBox(label="Rounded corners")
self.bbrounded_cb.setToolTip(
"If the bounding box is \n"
"to have rounded corners\n"
"their radius is equal to\n"
"the margin."
)
grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
class ExcellonOptionsGroupUI(OptionsGroupUI):
def __init__(self, parent=None):
OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
## Plot options
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
self.layout.addWidget(self.plot_options_label)
grid0 = QtGui.QGridLayout()
self.layout.addLayout(grid0)
self.plot_cb = FCCheckBox(label='Plot')
self.plot_cb.setToolTip(
"Plot (show) this object."
)
grid0.addWidget(self.plot_cb, 0, 0)
self.solid_cb = FCCheckBox(label='Solid')
self.solid_cb.setToolTip(
"Solid circles."
)
grid0.addWidget(self.solid_cb, 0, 1)
## Create CNC Job
self.cncjob_label = QtGui.QLabel('<b>Create CNC Job</b>')
self.cncjob_label.setToolTip(
"Create a CNC Job object\n"
"for this drill object."
)
self.layout.addWidget(self.cncjob_label)
grid1 = QtGui.QGridLayout()
self.layout.addLayout(grid1)
cutzlabel = QtGui.QLabel('Cut Z:')
cutzlabel.setToolTip(
"Drill depth (negative)\n"
"below the copper surface."
)
grid1.addWidget(cutzlabel, 0, 0)
self.cutz_entry = LengthEntry()
grid1.addWidget(self.cutz_entry, 0, 1)
travelzlabel = QtGui.QLabel('Travel Z:')
travelzlabel.setToolTip(
"Tool height when travelling\n"
"across the XY plane."
)
grid1.addWidget(travelzlabel, 1, 0)
self.travelz_entry = LengthEntry()
grid1.addWidget(self.travelz_entry, 1, 1)
frlabel = QtGui.QLabel('Feed rate:')
frlabel.setToolTip(
"Tool speed while drilling\n"
"(in units per minute)."
)
grid1.addWidget(frlabel, 2, 0)
self.feedrate_entry = LengthEntry()
grid1.addWidget(self.feedrate_entry, 2, 1)
toolchangezlabel = QtGui.QLabel('Toolchange Z:')
toolchangezlabel.setToolTip(
"Tool Z where user can change drill bit\n"
)
grid1.addWidget(toolchangezlabel, 3, 0)
self.toolchangez_entry = LengthEntry()
grid1.addWidget(self.toolchangez_entry, 3, 1)
spdlabel = QtGui.QLabel('Spindle speed:')
spdlabel.setToolTip(
"Speed of the spindle\n"
"in RPM (optional)"
)
grid1.addWidget(spdlabel, 4, 0)
self.spindlespeed_entry = IntEntry(allow_empty=True)
grid1.addWidget(self.spindlespeed_entry, 4, 1)
#### Milling Holes ####
self.mill_hole_label = QtGui.QLabel('<b>Mill Holes</b>')
self.mill_hole_label.setToolTip(
"Create Geometry for milling holes."
)
self.layout.addWidget(self.mill_hole_label)
grid1 = QtGui.QGridLayout()
self.layout.addLayout(grid1)
tdlabel = QtGui.QLabel('Tool dia:')
tdlabel.setToolTip(
"Diameter of the cutting tool."
)
grid1.addWidget(tdlabel, 0, 0)
self.tooldia_entry = LengthEntry()
grid1.addWidget(self.tooldia_entry, 0, 1)
class GeometryOptionsGroupUI(OptionsGroupUI):
def __init__(self, parent=None):
OptionsGroupUI.__init__(self, "Geometry Options", parent=parent)
## Plot options
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
self.layout.addWidget(self.plot_options_label)
# Plot CB
self.plot_cb = FCCheckBox(label='Plot')
self.plot_cb.setToolTip(
"Plot (show) this object."
)
self.layout.addWidget(self.plot_cb)
# ------------------------------
## Create CNC Job
# ------------------------------
self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
self.cncjob_label.setToolTip(
"Create a CNC Job object\n"
"tracing the contours of this\n"
"Geometry object."
)
self.layout.addWidget(self.cncjob_label)
grid1 = QtGui.QGridLayout()
self.layout.addLayout(grid1)
cutzlabel = QtGui.QLabel('Cut Z:')
cutzlabel.setToolTip(
"Cutting depth (negative)\n"
"below the copper surface."
)
grid1.addWidget(cutzlabel, 0, 0)
self.cutz_entry = LengthEntry()
grid1.addWidget(self.cutz_entry, 0, 1)
# Travel Z
travelzlabel = QtGui.QLabel('Travel Z:')
travelzlabel.setToolTip(
"Height of the tool when\n"
"moving without cutting."
)
grid1.addWidget(travelzlabel, 1, 0)
self.travelz_entry = LengthEntry()
grid1.addWidget(self.travelz_entry, 1, 1)
# Feedrate
frlabel = QtGui.QLabel('Feed Rate:')
frlabel.setToolTip(
"Cutting speed in the XY\n"
"plane in units per minute"
)
grid1.addWidget(frlabel, 2, 0)
self.cncfeedrate_entry = LengthEntry()
grid1.addWidget(self.cncfeedrate_entry, 2, 1)
# Tooldia
tdlabel = QtGui.QLabel('Tool dia:')
tdlabel.setToolTip(
"The diameter of the cutting\n"
"tool (just for display)."
)
grid1.addWidget(tdlabel, 3, 0)
self.cnctooldia_entry = LengthEntry()
grid1.addWidget(self.cnctooldia_entry, 3, 1)
spdlabel = QtGui.QLabel('Spindle speed:')
spdlabel.setToolTip(
"Speed of the spindle\n"
"in RPM (optional)"
)
grid1.addWidget(spdlabel, 4, 0)
self.cncspindlespeed_entry = IntEntry(allow_empty=True)
grid1.addWidget(self.cncspindlespeed_entry, 4, 1)
# ------------------------------
## Paint area
# ------------------------------
self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
self.paint_label.setToolTip(
"Creates tool paths to cover the\n"
"whole area of a polygon (remove\n"
"all copper). You will be asked\n"
"to click on the desired polygon."
)
self.layout.addWidget(self.paint_label)
grid2 = QtGui.QGridLayout()
self.layout.addLayout(grid2)
# Tool dia
ptdlabel = QtGui.QLabel('Tool dia:')
ptdlabel.setToolTip(
"Diameter of the tool to\n"
"be used in the operation."
)
grid2.addWidget(ptdlabel, 0, 0)
self.painttooldia_entry = LengthEntry()
grid2.addWidget(self.painttooldia_entry, 0, 1)
# Overlap
ovlabel = QtGui.QLabel('Overlap:')
ovlabel.setToolTip(
"How much (fraction) of the tool\n"
"width to overlap each tool pass."
)
grid2.addWidget(ovlabel, 1, 0)
self.paintoverlap_entry = LengthEntry()
grid2.addWidget(self.paintoverlap_entry, 1, 1)
# Margin
marginlabel = QtGui.QLabel('Margin:')
marginlabel.setToolTip(
"Distance by which to avoid\n"
"the edges of the polygon to\n"
"be painted."
)
grid2.addWidget(marginlabel, 2, 0)
self.paintmargin_entry = LengthEntry()
grid2.addWidget(self.paintmargin_entry, 2, 1)
# Method
methodlabel = QtGui.QLabel('Method:')
methodlabel.setToolTip(
"Algorithm to paint the polygon:<BR>"
"<B>Standard</B>: Fixed step inwards.<BR>"
"<B>Seed-based</B>: Outwards from seed."
)
grid2.addWidget(methodlabel, 3, 0)
self.paintmethod_combo = RadioSet([
{"label": "Standard", "value": "standard"},
{"label": "Seed-based", "value": "seed"},
{"label": "Straight lines", "value": "lines"}
], orientation='vertical')
grid2.addWidget(self.paintmethod_combo, 3, 1)
# Connect lines
pathconnectlabel = QtGui.QLabel("Connect:")
pathconnectlabel.setToolTip(
"Draw lines between resulting\n"
"segments to minimize tool lifts."
)
grid2.addWidget(pathconnectlabel, 4, 0)
self.pathconnect_cb = FCCheckBox()
grid2.addWidget(self.pathconnect_cb, 4, 1)
# Paint contour
contourlabel = QtGui.QLabel("Contour:")
contourlabel.setToolTip(
"Cut around the perimeter of the polygon\n"
"to trim rough edges."
)
grid2.addWidget(contourlabel, 5, 0)
self.contour_cb = FCCheckBox()
grid2.addWidget(self.contour_cb, 5, 1)
# Polygon selection
selectlabel = QtGui.QLabel('Selection:')
selectlabel.setToolTip(
"How to select the polygons to paint."
)
grid2.addWidget(selectlabel, 6, 0)
# grid3 = QtGui.QGridLayout()
self.selectmethod_combo = RadioSet([
{"label": "Single", "value": "single"},
{"label": "All", "value": "all"},
# {"label": "Rectangle", "value": "rectangle"}
])
grid2.addWidget(self.selectmethod_combo, 6, 1)
class CNCJobOptionsGroupUI(OptionsGroupUI):
def __init__(self, parent=None):
OptionsGroupUI.__init__(self, "CNC Job Options", parent=None)
## Plot options
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
self.layout.addWidget(self.plot_options_label)
grid0 = QtGui.QGridLayout()
self.layout.addLayout(grid0)
# Plot CB
# self.plot_cb = QtGui.QCheckBox('Plot')
self.plot_cb = FCCheckBox('Plot')
self.plot_cb.setToolTip(
"Plot (show) this object."
)
grid0.addWidget(self.plot_cb, 0, 0)
# Tool dia for plot
tdlabel = QtGui.QLabel('Tool dia:')
tdlabel.setToolTip(
"Diameter of the tool to be\n"
"rendered in the plot."
)
grid0.addWidget(tdlabel, 1, 0)
self.tooldia_entry = LengthEntry()
grid0.addWidget(self.tooldia_entry, 1, 1)
## Export G-Code
self.export_gcode_label = QtGui.QLabel("<b>Export G-Code:</b>")
self.export_gcode_label.setToolTip(
"Export and save G-Code to\n"
"make this object to a file."
)
self.layout.addWidget(self.export_gcode_label)
# Prepend to G-Code
prependlabel = QtGui.QLabel('Prepend to G-Code:')
prependlabel.setToolTip(
"Type here any G-Code commands you would\n"
"like to add at the beginning of the G-Code file."
)
self.layout.addWidget(prependlabel)
self.prepend_text = FCTextArea()
self.layout.addWidget(self.prepend_text)
# Append text to G-Code
appendlabel = QtGui.QLabel('Append to G-Code:')
appendlabel.setToolTip(
"Type here any G-Code commands you would\n"
"like to append to the generated file.\n"
"I.e.: M2 (End of program)"
)
self.layout.addWidget(appendlabel)
self.append_text = FCTextArea()
self.layout.addWidget(self.append_text)
# Dwell
grid1 = QtGui.QGridLayout()
self.layout.addLayout(grid1)
dwelllabel = QtGui.QLabel('Dwell:')
dwelllabel.setToolTip(
"Pause to allow the spindle to reach its\n"
"speed before cutting."
)
dwelltime = QtGui.QLabel('Duration [sec.]:')
dwelltime.setToolTip(
"Number of second to dwell."
)
self.dwell_cb = FCCheckBox()
self.dwelltime_cb = FCEntry()
grid1.addWidget(dwelllabel, 0, 0)
grid1.addWidget(self.dwell_cb, 0, 1)
grid1.addWidget(dwelltime, 1, 0)
grid1.addWidget(self.dwelltime_cb, 1, 1)
class GlobalOptionsUI(QtGui.QWidget):
"""
This is the app and project options editor.
"""
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent=parent)
layout = QtGui.QVBoxLayout()
self.setLayout(layout)
hlay1 = QtGui.QHBoxLayout()
layout.addLayout(hlay1)
unitslabel = QtGui.QLabel('Units:')
hlay1.addWidget(unitslabel)
self.units_radio = RadioSet([{'label': 'inch', 'value': 'IN'},
{'label': 'mm', 'value': 'MM'}])
hlay1.addWidget(self.units_radio)
####### Gerber #######
# gerberlabel = QtGui.QLabel('<b>Gerber Options</b>')
# layout.addWidget(gerberlabel)
self.gerber_group = GerberOptionsGroupUI()
# self.gerber_group.setFrameStyle(QtGui.QFrame.StyledPanel)
layout.addWidget(self.gerber_group)
####### Excellon #######
# excellonlabel = QtGui.QLabel('<b>Excellon Options</b>')
# layout.addWidget(excellonlabel)
self.excellon_group = ExcellonOptionsGroupUI()
# self.excellon_group.setFrameStyle(QtGui.QFrame.StyledPanel)
layout.addWidget(self.excellon_group)
####### Geometry #######
# geometrylabel = QtGui.QLabel('<b>Geometry Options</b>')
# layout.addWidget(geometrylabel)
self.geometry_group = GeometryOptionsGroupUI()
# self.geometry_group.setStyle(QtGui.QFrame.StyledPanel)
layout.addWidget(self.geometry_group)
####### CNC #######
# cnclabel = QtGui.QLabel('<b>CNC Job Options</b>')
# layout.addWidget(cnclabel)
self.cncjob_group = CNCJobOptionsGroupUI()
# self.cncjob_group.setStyle(QtGui.QFrame.StyledPanel)
layout.addWidget(self.cncjob_group)
# def main():
#
# app = QtGui.QApplication(sys.argv)
# fc = FlatCAMGUI()
# sys.exit(app.exec_())
#
#
# if __name__ == '__main__':
# main()