Convertion to Qt. Major refactoring.
This commit is contained in:
577
ObjectUI.py
577
ObjectUI.py
@@ -1,114 +1,103 @@
|
||||
############################################################
|
||||
# FlatCAM: 2D Post-processing for Manufacturing #
|
||||
# http://caram.cl/software/flatcam #
|
||||
# Author: Juan Pablo Caram (c) #
|
||||
# Date: 2/5/2014 #
|
||||
# MIT Licence #
|
||||
############################################################
|
||||
|
||||
from gi.repository import Gtk
|
||||
import sys
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from GUIElements import *
|
||||
|
||||
|
||||
class ObjectUI(Gtk.VBox):
|
||||
class ObjectUI(QtGui.QWidget):
|
||||
"""
|
||||
Base class for the UI of FlatCAM objects.
|
||||
Base class for the UI of FlatCAM objects. Deriving classes should
|
||||
put UI elements in ObjectUI.custom_box (QtGui.QLayout).
|
||||
"""
|
||||
|
||||
def __init__(self, icon_file='share/flatcam_icon32.png', title='FlatCAM Object'):
|
||||
Gtk.VBox.__init__(self, spacing=3, margin=5, vexpand=False)
|
||||
def __init__(self, icon_file='share/flatcam_icon32.png', title='FlatCAM Object', parent=None):
|
||||
QtGui.QWidget.__init__(self, parent=parent)
|
||||
|
||||
layout = QtGui.QVBoxLayout()
|
||||
self.setLayout(layout)
|
||||
|
||||
## Page Title box (spacing between children)
|
||||
self.title_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 2)
|
||||
self.pack_start(self.title_box, expand=False, fill=False, padding=2)
|
||||
self.title_box = QtGui.QHBoxLayout()
|
||||
layout.addLayout(self.title_box)
|
||||
|
||||
## Page Title icon
|
||||
self.icon = Gtk.Image.new_from_file(icon_file)
|
||||
self.title_box.pack_start(self.icon, expand=False, fill=False, padding=2)
|
||||
pixmap = QtGui.QPixmap(icon_file)
|
||||
self.icon = QtGui.QLabel()
|
||||
self.icon.setPixmap(pixmap)
|
||||
self.title_box.addWidget(self.icon, stretch=0)
|
||||
|
||||
## Title label
|
||||
self.title_label = Gtk.Label()
|
||||
self.title_label.set_markup("<b>" + title + "</b>")
|
||||
self.title_label.set_justify(Gtk.Justification.CENTER)
|
||||
self.title_box.pack_start(self.title_label, expand=False, fill=False, padding=2)
|
||||
self.title_label = QtGui.QLabel("<font size=5><b>" + title + "</b></font>")
|
||||
self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
self.title_box.addWidget(self.title_label, stretch=1)
|
||||
|
||||
## Object name
|
||||
self.name_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 2)
|
||||
self.pack_start(self.name_box, expand=False, fill=False, padding=2)
|
||||
name_label = Gtk.Label('Name:')
|
||||
name_label.set_justify(Gtk.Justification.RIGHT)
|
||||
self.name_box.pack_start(name_label,
|
||||
expand=False, fill=False, padding=2)
|
||||
self.name_box = QtGui.QHBoxLayout()
|
||||
layout.addLayout(self.name_box)
|
||||
name_label = QtGui.QLabel("Name:")
|
||||
self.name_box.addWidget(name_label)
|
||||
self.name_entry = FCEntry()
|
||||
self.name_box.pack_start(self.name_entry, expand=True, fill=False, padding=2)
|
||||
self.name_box.addWidget(self.name_entry)
|
||||
|
||||
## Box box for custom widgets
|
||||
self.custom_box = Gtk.VBox(spacing=3, margin=0, vexpand=False)
|
||||
self.pack_start(self.custom_box, expand=False, fill=False, padding=0)
|
||||
self.custom_box = QtGui.QVBoxLayout()
|
||||
layout.addLayout(self.custom_box)
|
||||
|
||||
## Common to all objects
|
||||
## Scale
|
||||
self.scale_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.scale_label.set_markup('<b>Scale:</b>')
|
||||
self.scale_label.set_tooltip_markup(
|
||||
self.scale_label = QtGui.QLabel('<b>Scale:</b>')
|
||||
self.scale_label.setToolTip(
|
||||
"Change the size of the object."
|
||||
)
|
||||
self.pack_start(self.scale_label, expand=False, fill=False, padding=2)
|
||||
layout.addWidget(self.scale_label)
|
||||
|
||||
grid5 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.pack_start(grid5, expand=False, fill=False, padding=2)
|
||||
grid1 = QtGui.QGridLayout()
|
||||
layout.addLayout(grid1)
|
||||
|
||||
# Factor
|
||||
l10 = Gtk.Label('Factor:', xalign=1)
|
||||
l10.set_tooltip_markup(
|
||||
faclabel = QtGui.QLabel('Factor:')
|
||||
faclabel.setToolTip(
|
||||
"Factor by which to multiply\n"
|
||||
"geometric features of this object."
|
||||
)
|
||||
grid5.attach(l10, 0, 0, 1, 1)
|
||||
grid1.addWidget(faclabel, 0, 0)
|
||||
self.scale_entry = FloatEntry()
|
||||
self.scale_entry.set_text("1.0")
|
||||
grid5.attach(self.scale_entry, 1, 0, 1, 1)
|
||||
self.scale_entry.set_value(1.0)
|
||||
grid1.addWidget(self.scale_entry, 0, 1)
|
||||
|
||||
# GO Button
|
||||
self.scale_button = Gtk.Button(label='Scale')
|
||||
self.scale_button.set_tooltip_markup(
|
||||
self.scale_button = QtGui.QPushButton('Scale')
|
||||
self.scale_button.setToolTip(
|
||||
"Perform scaling operation."
|
||||
)
|
||||
self.pack_start(self.scale_button, expand=False, fill=False, padding=2)
|
||||
layout.addWidget(self.scale_button)
|
||||
|
||||
## Offset
|
||||
self.offset_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.offset_label.set_markup('<b>Offset:</b>')
|
||||
self.offset_label.set_tooltip_markup(
|
||||
self.offset_label = QtGui.QLabel('<b>Offset:</b>')
|
||||
self.offset_label.setToolTip(
|
||||
"Change the position of this object."
|
||||
)
|
||||
self.pack_start(self.offset_label, expand=False, fill=False, padding=2)
|
||||
layout.addWidget(self.offset_label)
|
||||
|
||||
grid6 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.pack_start(grid6, expand=False, fill=False, padding=2)
|
||||
grid2 = QtGui.QGridLayout()
|
||||
layout.addLayout(grid2)
|
||||
|
||||
# Vector
|
||||
l11 = Gtk.Label('Offset Vector:', xalign=1)
|
||||
l11.set_tooltip_markup(
|
||||
self.offset_label = QtGui.QLabel('Vector:')
|
||||
self.offset_label.setToolTip(
|
||||
"Amount by which to move the object\n"
|
||||
"in the x and y axes in (x, y) format."
|
||||
)
|
||||
grid6.attach(l11, 0, 0, 1, 1)
|
||||
grid2.addWidget(self.offset_label, 0, 0)
|
||||
self.offsetvector_entry = EvalEntry()
|
||||
self.offsetvector_entry.set_text("(0.0, 0.0)")
|
||||
grid6.attach(self.offsetvector_entry, 1, 0, 1, 1)
|
||||
self.offsetvector_entry.setText("(0.0, 0.0)")
|
||||
grid2.addWidget(self.offsetvector_entry, 0, 1)
|
||||
|
||||
self.offset_button = Gtk.Button(label='Scale')
|
||||
self.offset_button.set_tooltip_markup(
|
||||
self.offset_button = QtGui.QPushButton('Offset')
|
||||
self.offset_button.setToolTip(
|
||||
"Perform the offset operation."
|
||||
)
|
||||
self.pack_start(self.offset_button, expand=False, fill=False, padding=2)
|
||||
layout.addWidget(self.offset_button)
|
||||
|
||||
def set_field(self, name, value):
|
||||
getattr(self, name).set_value(value)
|
||||
|
||||
def get_field(self, name):
|
||||
return getattr(self, name).get_value()
|
||||
layout.addStretch()
|
||||
|
||||
|
||||
class CNCObjectUI(ObjectUI):
|
||||
@@ -116,57 +105,68 @@ class CNCObjectUI(ObjectUI):
|
||||
User interface for CNCJob objects.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
ObjectUI.__init__(self, title='CNC Job Object', icon_file='share/cnc32.png')
|
||||
def __init__(self, parent=None):
|
||||
ObjectUI.__init__(self, title='CNC Job Object', icon_file='share/cnc32.png', parent=parent)
|
||||
|
||||
## Plot options
|
||||
self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.plot_options_label.set_markup("<b>Plot Options:</b>")
|
||||
self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
|
||||
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
|
||||
self.custom_box.addWidget(self.plot_options_label)
|
||||
|
||||
grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid0, expand=False, fill=False, padding=2)
|
||||
grid0 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid0)
|
||||
|
||||
# Plot CB
|
||||
self.plot_cb = FCCheckBox(label='Plot')
|
||||
self.plot_cb.set_tooltip_markup(
|
||||
# self.plot_cb = QtGui.QCheckBox('Plot')
|
||||
self.plot_cb = FCCheckBox('Plot')
|
||||
self.plot_cb.setToolTip(
|
||||
"Plot (show) this object."
|
||||
)
|
||||
grid0.attach(self.plot_cb, 0, 0, 2, 1)
|
||||
grid0.addWidget(self.plot_cb, 0, 0)
|
||||
|
||||
# Tool dia for plot
|
||||
l1 = Gtk.Label('Tool dia:', xalign=1)
|
||||
l1.set_tooltip_markup(
|
||||
tdlabel = QtGui.QLabel('Tool dia:')
|
||||
tdlabel.setToolTip(
|
||||
"Diameter of the tool to be\n"
|
||||
"rendered in the plot."
|
||||
)
|
||||
grid0.attach(l1, 0, 1, 1, 1)
|
||||
grid0.addWidget(tdlabel, 1, 0)
|
||||
self.tooldia_entry = LengthEntry()
|
||||
grid0.attach(self.tooldia_entry, 1, 1, 1, 1)
|
||||
grid0.addWidget(self.tooldia_entry, 1, 1)
|
||||
|
||||
# Update plot button
|
||||
self.updateplot_button = Gtk.Button(label='Update Plot')
|
||||
self.updateplot_button.set_tooltip_markup(
|
||||
self.updateplot_button = QtGui.QPushButton('Update Plot')
|
||||
self.updateplot_button.setToolTip(
|
||||
"Update the plot."
|
||||
)
|
||||
self.custom_box.pack_start(self.updateplot_button, expand=False, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.updateplot_button)
|
||||
|
||||
## Export G-Code
|
||||
self.export_gcode_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.export_gcode_label.set_markup("<b>Export G-Code:</b>")
|
||||
self.export_gcode_label.set_tooltip_markup(
|
||||
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.custom_box.pack_start(self.export_gcode_label, expand=False, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.export_gcode_label)
|
||||
|
||||
# Append text to Gerber
|
||||
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.custom_box.addWidget(appendlabel)
|
||||
|
||||
self.append_text = FCTextArea()
|
||||
self.custom_box.addWidget(self.append_text)
|
||||
|
||||
# GO Button
|
||||
self.export_gcode_button = Gtk.Button(label='Export G-Code')
|
||||
self.export_gcode_button.set_tooltip_markup(
|
||||
self.export_gcode_button = QtGui.QPushButton('Export G-Code')
|
||||
self.export_gcode_button.setToolTip(
|
||||
"Opens dialog to save G-Code\n"
|
||||
"file."
|
||||
)
|
||||
self.custom_box.pack_start(self.export_gcode_button, expand=False, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.export_gcode_button)
|
||||
|
||||
|
||||
class GeometryObjectUI(ObjectUI):
|
||||
@@ -174,135 +174,131 @@ class GeometryObjectUI(ObjectUI):
|
||||
User interface for Geometry objects.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
ObjectUI.__init__(self, title='Geometry Object', icon_file='share/geometry32.png')
|
||||
def __init__(self, parent=None):
|
||||
super(GeometryObjectUI, self).__init__(title='Geometry Object', icon_file='share/geometry32.png', parent=parent)
|
||||
|
||||
## Plot options
|
||||
self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.plot_options_label.set_markup("<b>Plot Options:</b>")
|
||||
self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
|
||||
|
||||
grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid0, expand=True, fill=False, padding=2)
|
||||
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
|
||||
self.custom_box.addWidget(self.plot_options_label)
|
||||
|
||||
# Plot CB
|
||||
self.plot_cb = FCCheckBox(label='Plot')
|
||||
self.plot_cb.set_tooltip_markup(
|
||||
self.plot_cb.setToolTip(
|
||||
"Plot (show) this object."
|
||||
)
|
||||
grid0.attach(self.plot_cb, 0, 0, 1, 1)
|
||||
self.custom_box.addWidget(self.plot_cb)
|
||||
|
||||
## Create CNC Job
|
||||
self.cncjob_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.cncjob_label.set_markup('<b>Create CNC Job:</b>')
|
||||
self.cncjob_label.set_tooltip_markup(
|
||||
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.custom_box.pack_start(self.cncjob_label, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.cncjob_label)
|
||||
|
||||
grid1 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid1, expand=True, fill=False, padding=2)
|
||||
grid1 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid1)
|
||||
|
||||
# Cut Z
|
||||
l1 = Gtk.Label('Cut Z:', xalign=1)
|
||||
l1.set_tooltip_markup(
|
||||
cutzlabel = QtGui.QLabel('Cut Z:')
|
||||
cutzlabel.setToolTip(
|
||||
"Cutting depth (negative)\n"
|
||||
"below the copper surface."
|
||||
)
|
||||
grid1.attach(l1, 0, 0, 1, 1)
|
||||
grid1.addWidget(cutzlabel, 0, 0)
|
||||
self.cutz_entry = LengthEntry()
|
||||
grid1.attach(self.cutz_entry, 1, 0, 1, 1)
|
||||
grid1.addWidget(self.cutz_entry, 0, 1)
|
||||
|
||||
# Travel Z
|
||||
l2 = Gtk.Label('Travel Z:', xalign=1)
|
||||
l2.set_tooltip_markup(
|
||||
travelzlabel = QtGui.QLabel('Travel Z:')
|
||||
travelzlabel.setToolTip(
|
||||
"Height of the tool when\n"
|
||||
"moving without cutting."
|
||||
)
|
||||
grid1.attach(l2, 0, 1, 1, 1)
|
||||
grid1.addWidget(travelzlabel, 1, 0)
|
||||
self.travelz_entry = LengthEntry()
|
||||
grid1.attach(self.travelz_entry, 1, 1, 1, 1)
|
||||
grid1.addWidget(self.travelz_entry, 1, 1)
|
||||
|
||||
l3 = Gtk.Label('Feed rate:', xalign=1)
|
||||
l3.set_tooltip_markup(
|
||||
# Feedrate
|
||||
frlabel = QtGui.QLabel('Feed Rate:')
|
||||
frlabel.setToolTip(
|
||||
"Cutting speed in the XY\n"
|
||||
"plane in units per minute"
|
||||
)
|
||||
grid1.attach(l3, 0, 2, 1, 1)
|
||||
grid1.addWidget(frlabel, 2, 0)
|
||||
self.cncfeedrate_entry = LengthEntry()
|
||||
grid1.attach(self.cncfeedrate_entry, 1, 2, 1, 1)
|
||||
grid1.addWidget(self.cncfeedrate_entry, 2, 1)
|
||||
|
||||
l4 = Gtk.Label('Tool dia:', xalign=1)
|
||||
l4.set_tooltip_markup(
|
||||
# Tooldia
|
||||
tdlabel = QtGui.QLabel('Tool dia:')
|
||||
tdlabel.setToolTip(
|
||||
"The diameter of the cutting\n"
|
||||
"tool (just for display)."
|
||||
)
|
||||
grid1.attach(l4, 0, 3, 1, 1)
|
||||
grid1.addWidget(tdlabel, 3, 0)
|
||||
self.cnctooldia_entry = LengthEntry()
|
||||
grid1.attach(self.cnctooldia_entry, 1, 3, 1, 1)
|
||||
grid1.addWidget(self.cnctooldia_entry, 3, 1)
|
||||
|
||||
self.generate_cnc_button = Gtk.Button(label='Generate')
|
||||
self.generate_cnc_button.set_tooltip_markup(
|
||||
self.generate_cnc_button = QtGui.QPushButton('Generate')
|
||||
self.generate_cnc_button.setToolTip(
|
||||
"Generate the CNC Job object."
|
||||
)
|
||||
self.custom_box.pack_start(self.generate_cnc_button, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.generate_cnc_button)
|
||||
|
||||
## Paint Area
|
||||
self.paint_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.paint_label.set_markup('<b>Paint Area:</b>')
|
||||
self.paint_label.set_tooltip_markup(
|
||||
## 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.custom_box.pack_start(self.paint_label, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.paint_label)
|
||||
|
||||
grid2 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid2, expand=True, fill=False, padding=2)
|
||||
grid2 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid2)
|
||||
|
||||
# Tool dia
|
||||
l5 = Gtk.Label('Tool dia:', xalign=1)
|
||||
l5.set_tooltip_markup(
|
||||
ptdlabel = QtGui.QLabel('Tool dia:')
|
||||
ptdlabel.setToolTip(
|
||||
"Diameter of the tool to\n"
|
||||
"be used in the operation."
|
||||
)
|
||||
grid2.attach(l5, 0, 0, 1, 1)
|
||||
grid2.addWidget(ptdlabel, 0, 0)
|
||||
|
||||
self.painttooldia_entry = LengthEntry()
|
||||
grid2.attach(self.painttooldia_entry, 1, 0, 1, 1)
|
||||
grid2.addWidget(self.painttooldia_entry, 0, 1)
|
||||
|
||||
# Overlap
|
||||
l6 = Gtk.Label('Overlap:', xalign=1)
|
||||
l6.set_tooltip_markup(
|
||||
ovlabel = QtGui.QLabel('Overlap:')
|
||||
ovlabel.setToolTip(
|
||||
"How much (fraction) of the tool\n"
|
||||
"width to overlap each tool pass."
|
||||
)
|
||||
grid2.attach(l6, 0, 1, 1, 1)
|
||||
grid2.addWidget(ovlabel, 1, 0)
|
||||
self.paintoverlap_entry = LengthEntry()
|
||||
grid2.attach(self.paintoverlap_entry, 1, 1, 1, 1)
|
||||
grid2.addWidget(self.paintoverlap_entry, 1, 1)
|
||||
|
||||
# Margin
|
||||
l7 = Gtk.Label('Margin:', xalign=1)
|
||||
l7.set_tooltip_markup(
|
||||
marginlabel = QtGui.QLabel('Margin:')
|
||||
marginlabel.setToolTip(
|
||||
"Distance by which to avoid\n"
|
||||
"the edges of the polygon to\n"
|
||||
"be painted."
|
||||
)
|
||||
grid2.attach(l7, 0, 2, 1, 1)
|
||||
grid2.addWidget(marginlabel, 2, 0)
|
||||
self.paintmargin_entry = LengthEntry()
|
||||
grid2.attach(self.paintmargin_entry, 1, 2, 1, 1)
|
||||
grid2.addWidget(self.paintmargin_entry)
|
||||
|
||||
# GO Button
|
||||
self.generate_paint_button = Gtk.Button(label='Generate')
|
||||
self.generate_paint_button.set_tooltip_markup(
|
||||
self.generate_paint_button = QtGui.QPushButton('Generate')
|
||||
self.generate_paint_button.setToolTip(
|
||||
"After clicking here, click inside\n"
|
||||
"the polygon you wish to be painted.\n"
|
||||
"A new Geometry object with the tool\n"
|
||||
"paths will be created."
|
||||
)
|
||||
self.custom_box.pack_start(self.generate_paint_button, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.generate_paint_button)
|
||||
|
||||
|
||||
class ExcellonObjectUI(ObjectUI):
|
||||
@@ -310,90 +306,85 @@ class ExcellonObjectUI(ObjectUI):
|
||||
User interface for Excellon objects.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
ObjectUI.__init__(self, title='Excellon Object', icon_file='share/drill32.png')
|
||||
def __init__(self, parent=None):
|
||||
ObjectUI.__init__(self, title='Excellon Object', icon_file='share/drill32.png', parent=parent)
|
||||
|
||||
## Plot options
|
||||
self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.plot_options_label.set_markup("<b>Plot Options:</b>")
|
||||
self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
|
||||
|
||||
grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid0, expand=True, fill=False, padding=2)
|
||||
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
|
||||
self.custom_box.addWidget(self.plot_options_label)
|
||||
|
||||
grid0 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid0)
|
||||
self.plot_cb = FCCheckBox(label='Plot')
|
||||
self.plot_cb.set_tooltip_markup(
|
||||
self.plot_cb.setToolTip(
|
||||
"Plot (show) this object."
|
||||
)
|
||||
grid0.attach(self.plot_cb, 0, 0, 1, 1)
|
||||
|
||||
grid0.addWidget(self.plot_cb, 0, 0)
|
||||
self.solid_cb = FCCheckBox(label='Solid')
|
||||
self.solid_cb.set_tooltip_markup(
|
||||
self.solid_cb.setToolTip(
|
||||
"Solid circles."
|
||||
)
|
||||
grid0.attach(self.solid_cb, 1, 0, 1, 1)
|
||||
grid0.addWidget(self.solid_cb, 0, 1)
|
||||
|
||||
## Tools
|
||||
self.tools_table_label = QtGui.QLabel('<b>Tools</b>')
|
||||
self.tools_table_label.setToolTip(
|
||||
"Tools in this Excellon object."
|
||||
)
|
||||
self.custom_box.addWidget(self.tools_table_label)
|
||||
self.tools_table = QtGui.QTableWidget()
|
||||
self.tools_table.setFixedHeight(100)
|
||||
self.custom_box.addWidget(self.tools_table)
|
||||
|
||||
## Create CNC Job
|
||||
self.cncjob_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.cncjob_label.set_markup('<b>Create CNC Job</b>')
|
||||
self.cncjob_label.set_tooltip_markup(
|
||||
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.custom_box.pack_start(self.cncjob_label, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.cncjob_label)
|
||||
|
||||
grid1 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid1, expand=True, fill=False, padding=2)
|
||||
grid1 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid1)
|
||||
|
||||
l1 = Gtk.Label('Cut Z:', xalign=1)
|
||||
l1.set_tooltip_markup(
|
||||
cutzlabel = QtGui.QLabel('Cut Z:')
|
||||
cutzlabel.setToolTip(
|
||||
"Drill depth (negative)\n"
|
||||
"below the copper surface."
|
||||
)
|
||||
grid1.attach(l1, 0, 0, 1, 1)
|
||||
grid1.addWidget(cutzlabel, 0, 0)
|
||||
self.cutz_entry = LengthEntry()
|
||||
grid1.attach(self.cutz_entry, 1, 0, 1, 1)
|
||||
grid1.addWidget(self.cutz_entry, 0, 1)
|
||||
|
||||
l2 = Gtk.Label('Travel Z:', xalign=1)
|
||||
l2.set_tooltip_markup(
|
||||
travelzlabel = QtGui.QLabel('Travel Z:')
|
||||
travelzlabel.setToolTip(
|
||||
"Tool height when travelling\n"
|
||||
"across the XY plane."
|
||||
)
|
||||
grid1.attach(l2, 0, 1, 1, 1)
|
||||
grid1.addWidget(travelzlabel, 1, 0)
|
||||
self.travelz_entry = LengthEntry()
|
||||
grid1.attach(self.travelz_entry, 1, 1, 1, 1)
|
||||
grid1.addWidget(self.travelz_entry, 1, 1)
|
||||
|
||||
l3 = Gtk.Label('Feed rate:', xalign=1)
|
||||
l3.set_tooltip_markup(
|
||||
frlabel = QtGui.QLabel('Feed rate:')
|
||||
frlabel.setToolTip(
|
||||
"Tool speed while drilling\n"
|
||||
"(in units per minute)."
|
||||
)
|
||||
grid1.attach(l3, 0, 2, 1, 1)
|
||||
grid1.addWidget(frlabel, 2, 0)
|
||||
self.feedrate_entry = LengthEntry()
|
||||
grid1.attach(self.feedrate_entry, 1, 2, 1, 1)
|
||||
grid1.addWidget(self.feedrate_entry, 2, 1)
|
||||
|
||||
l4 = Gtk.Label('Tools:', xalign=1)
|
||||
l4.set_tooltip_markup(
|
||||
"Which tools to include\n"
|
||||
"in the CNC Job."
|
||||
choose_tools_label = QtGui.QLabel(
|
||||
"Select from the tools section above\n"
|
||||
"the tools you want to include."
|
||||
)
|
||||
grid1.attach(l4, 0, 3, 1, 1)
|
||||
boxt = Gtk.Box()
|
||||
grid1.attach(boxt, 1, 3, 1, 1)
|
||||
self.tools_entry = FCEntry()
|
||||
boxt.pack_start(self.tools_entry, expand=True, fill=False, padding=2)
|
||||
self.choose_tools_button = Gtk.Button(label='Choose...')
|
||||
self.choose_tools_button.set_tooltip_markup(
|
||||
"Choose the tools\n"
|
||||
"from a list."
|
||||
)
|
||||
boxt.pack_start(self.choose_tools_button, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(choose_tools_label)
|
||||
|
||||
self.generate_cnc_button = Gtk.Button(label='Generate')
|
||||
self.generate_cnc_button.set_tooltip_markup(
|
||||
self.generate_cnc_button = QtGui.QPushButton('Generate')
|
||||
self.generate_cnc_button.setToolTip(
|
||||
"Generate the CNC Job."
|
||||
)
|
||||
self.custom_box.pack_start(self.generate_cnc_button, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.generate_cnc_button)
|
||||
|
||||
|
||||
class GerberObjectUI(ObjectUI):
|
||||
@@ -401,214 +392,210 @@ class GerberObjectUI(ObjectUI):
|
||||
User interface for Gerber objects.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
ObjectUI.__init__(self, title='Gerber Object')
|
||||
def __init__(self, parent=None):
|
||||
ObjectUI.__init__(self, title='Gerber Object', parent=parent)
|
||||
|
||||
## Plot options
|
||||
self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.plot_options_label.set_markup("<b>Plot Options:</b>")
|
||||
self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
|
||||
|
||||
grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid0, expand=True, fill=False, padding=2)
|
||||
self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
|
||||
self.custom_box.addWidget(self.plot_options_label)
|
||||
|
||||
grid0 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid0)
|
||||
# Plot CB
|
||||
self.plot_cb = FCCheckBox(label='Plot')
|
||||
self.plot_cb.set_tooltip_markup(
|
||||
self.plot_options_label.setToolTip(
|
||||
"Plot (show) this object."
|
||||
)
|
||||
grid0.attach(self.plot_cb, 0, 0, 1, 1)
|
||||
grid0.addWidget(self.plot_cb, 0, 0)
|
||||
|
||||
# Solid CB
|
||||
self.solid_cb = FCCheckBox(label='Solid')
|
||||
self.solid_cb.set_tooltip_markup(
|
||||
self.solid_cb.setToolTip(
|
||||
"Solid color polygons."
|
||||
)
|
||||
grid0.attach(self.solid_cb, 1, 0, 1, 1)
|
||||
grid0.addWidget(self.solid_cb, 0, 1)
|
||||
|
||||
# Multicolored CB
|
||||
self.multicolored_cb = FCCheckBox(label='Multicolored')
|
||||
self.multicolored_cb.set_tooltip_markup(
|
||||
self.multicolored_cb.setToolTip(
|
||||
"Draw polygons in different colors."
|
||||
)
|
||||
grid0.attach(self.multicolored_cb, 2, 0, 1, 1)
|
||||
grid0.addWidget(self.multicolored_cb, 0, 2)
|
||||
|
||||
## Isolation Routing
|
||||
self.isolation_routing_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.isolation_routing_label.set_markup("<b>Isolation Routing:</b>")
|
||||
self.isolation_routing_label.set_tooltip_markup(
|
||||
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.custom_box.pack_start(self.isolation_routing_label, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.isolation_routing_label)
|
||||
|
||||
grid = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid, expand=True, fill=False, padding=2)
|
||||
|
||||
l1 = Gtk.Label('Tool diam:', xalign=1)
|
||||
l1.set_tooltip_markup(
|
||||
grid1 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid1)
|
||||
tdlabel = QtGui.QLabel('Tool dia:')
|
||||
tdlabel.setToolTip(
|
||||
"Diameter of the cutting tool."
|
||||
)
|
||||
grid.attach(l1, 0, 0, 1, 1)
|
||||
grid1.addWidget(tdlabel, 0, 0)
|
||||
self.iso_tool_dia_entry = LengthEntry()
|
||||
grid.attach(self.iso_tool_dia_entry, 1, 0, 1, 1)
|
||||
grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
|
||||
|
||||
l2 = Gtk.Label('Width (# passes):', xalign=1)
|
||||
l2.set_tooltip_markup(
|
||||
passlabel = QtGui.QLabel('Width (# passes):')
|
||||
passlabel.setToolTip(
|
||||
"Width of the isolation gap in\n"
|
||||
"number (integer) of tool widths."
|
||||
)
|
||||
grid.attach(l2, 0, 1, 1, 1)
|
||||
grid1.addWidget(passlabel, 1, 0)
|
||||
self.iso_width_entry = IntEntry()
|
||||
grid.attach(self.iso_width_entry, 1, 1, 1, 1)
|
||||
grid1.addWidget(self.iso_width_entry, 1, 1)
|
||||
|
||||
l3 = Gtk.Label('Pass overlap:', xalign=1)
|
||||
l3.set_tooltip_markup(
|
||||
overlabel = QtGui.QLabel('Pass overlap:')
|
||||
overlabel.setToolTip(
|
||||
"How much (fraction of tool width)\n"
|
||||
"to overlap each pass."
|
||||
)
|
||||
grid.attach(l3, 0, 2, 1, 1)
|
||||
grid1.addWidget(overlabel, 2, 0)
|
||||
self.iso_overlap_entry = FloatEntry()
|
||||
grid.attach(self.iso_overlap_entry, 1, 2, 1, 1)
|
||||
grid1.addWidget(self.iso_overlap_entry, 2, 1)
|
||||
|
||||
self.generate_iso_button = Gtk.Button(label='Generate Geometry')
|
||||
self.generate_iso_button.set_tooltip_markup(
|
||||
self.generate_iso_button = QtGui.QPushButton('Generate Geometry')
|
||||
self.generate_iso_button.setToolTip(
|
||||
"Create the Geometry Object\n"
|
||||
"for isolation routing."
|
||||
)
|
||||
self.custom_box.pack_start(self.generate_iso_button, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.generate_iso_button)
|
||||
|
||||
## Board cuttout
|
||||
self.board_cutout_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.board_cutout_label.set_markup("<b>Board cutout:</b>")
|
||||
self.board_cutout_label.set_tooltip_markup(
|
||||
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.custom_box.pack_start(self.board_cutout_label, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.board_cutout_label)
|
||||
|
||||
grid2 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid2, expand=True, fill=False, padding=2)
|
||||
|
||||
l4 = Gtk.Label('Tool dia:', xalign=1)
|
||||
l4.set_tooltip_markup(
|
||||
grid2 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid2)
|
||||
tdclabel = QtGui.QLabel('Tool dia:')
|
||||
tdclabel.setToolTip(
|
||||
"Diameter of the cutting tool."
|
||||
)
|
||||
grid2.attach(l4, 0, 0, 1, 1)
|
||||
grid2.addWidget(tdclabel, 0, 0)
|
||||
self.cutout_tooldia_entry = LengthEntry()
|
||||
grid2.attach(self.cutout_tooldia_entry, 1, 0, 1, 1)
|
||||
grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
|
||||
|
||||
l5 = Gtk.Label('Margin:', xalign=1)
|
||||
l5.set_tooltip_markup(
|
||||
marginlabel = QtGui.QLabel('Margin:')
|
||||
marginlabel.setToolTip(
|
||||
"Distance from objects at which\n"
|
||||
"to draw the cutout."
|
||||
)
|
||||
grid2.attach(l5, 0, 1, 1, 1)
|
||||
grid2.addWidget(marginlabel, 1, 0)
|
||||
self.cutout_margin_entry = LengthEntry()
|
||||
grid2.attach(self.cutout_margin_entry, 1, 1, 1, 1)
|
||||
grid2.addWidget(self.cutout_margin_entry, 1, 1)
|
||||
|
||||
l6 = Gtk.Label('Gap size:', xalign=1)
|
||||
l6.set_tooltip_markup(
|
||||
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.attach(l6, 0, 2, 1, 1)
|
||||
grid2.addWidget(gaplabel, 2, 0)
|
||||
self.cutout_gap_entry = LengthEntry()
|
||||
grid2.attach(self.cutout_gap_entry, 1, 2, 1, 1)
|
||||
grid2.addWidget(self.cutout_gap_entry, 2, 1)
|
||||
|
||||
l7 = Gtk.Label('Gaps:', xalign=1)
|
||||
l7.set_tooltip_markup(
|
||||
gapslabel = QtGui.QLabel('Gaps:')
|
||||
gapslabel.setToolTip(
|
||||
"Where to place the gaps, Top/Bottom\n"
|
||||
"Left/Rigt, or on all 4 sides."
|
||||
)
|
||||
grid2.attach(l7, 0, 3, 1, 1)
|
||||
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.attach(self.gaps_radio, 1, 3, 1, 1)
|
||||
grid2.addWidget(self.gaps_radio, 3, 1)
|
||||
|
||||
self.generate_cutout_button = Gtk.Button(label='Generate Geometry')
|
||||
self.generate_cutout_button.set_tooltip_markup(
|
||||
self.generate_cutout_button = QtGui.QPushButton('Generate Geometry')
|
||||
self.generate_cutout_button.setToolTip(
|
||||
"Generate the geometry for\n"
|
||||
"the board cutout."
|
||||
)
|
||||
self.custom_box.pack_start(self.generate_cutout_button, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.generate_cutout_button)
|
||||
|
||||
## Non-copper regions
|
||||
self.noncopper_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.noncopper_label.set_markup("<b>Non-copper regions:</b>")
|
||||
self.noncopper_label.set_tooltip_markup(
|
||||
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.custom_box.pack_start(self.noncopper_label, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.noncopper_label)
|
||||
|
||||
grid3 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid3, expand=True, fill=False, padding=2)
|
||||
grid3 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid3)
|
||||
|
||||
l8 = Gtk.Label('Boundary margin:', xalign=1)
|
||||
l8.set_tooltip_markup(
|
||||
# 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.attach(l8, 0, 0, 1, 1)
|
||||
grid3.addWidget(bmlabel, 0, 0)
|
||||
self.noncopper_margin_entry = LengthEntry()
|
||||
grid3.attach(self.noncopper_margin_entry, 1, 0, 1, 1)
|
||||
grid3.addWidget(self.noncopper_margin_entry, 0, 1)
|
||||
|
||||
# Rounded corners
|
||||
self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
|
||||
self.noncopper_rounded_cb.set_tooltip_markup(
|
||||
"If the boundary of the board\n"
|
||||
"is to have rounded corners\n"
|
||||
"their radius is equal to the margin."
|
||||
)
|
||||
grid3.attach(self.noncopper_rounded_cb, 0, 1, 2, 1)
|
||||
|
||||
self.generate_noncopper_button = Gtk.Button(label='Generate Geometry')
|
||||
self.generate_noncopper_button.set_tooltip_markup(
|
||||
self.noncopper_rounded_cb.setToolTip(
|
||||
"Creates a Geometry objects with polygons\n"
|
||||
"covering the copper-free areas of the PCB."
|
||||
)
|
||||
self.custom_box.pack_start(self.generate_noncopper_button, expand=True, fill=False, padding=2)
|
||||
grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
|
||||
|
||||
self.generate_noncopper_button = QtGui.QPushButton('Generate Geometry')
|
||||
self.custom_box.addWidget(self.generate_noncopper_button)
|
||||
|
||||
## Bounding box
|
||||
self.boundingbox_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
|
||||
self.boundingbox_label.set_markup('<b>Bounding Box:</b>')
|
||||
self.boundingbox_label.set_tooltip_markup(
|
||||
"Create a Geometry object with a rectangle\n"
|
||||
"enclosing all polygons at a given distance."
|
||||
)
|
||||
self.custom_box.pack_start(self.boundingbox_label, expand=True, fill=False, padding=2)
|
||||
self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
|
||||
self.custom_box.addWidget(self.boundingbox_label)
|
||||
|
||||
grid4 = Gtk.Grid(column_spacing=3, row_spacing=2)
|
||||
self.custom_box.pack_start(grid4, expand=True, fill=False, padding=2)
|
||||
grid4 = QtGui.QGridLayout()
|
||||
self.custom_box.addLayout(grid4)
|
||||
|
||||
l9 = Gtk.Label('Boundary Margin:', xalign=1)
|
||||
l9.set_tooltip_markup(
|
||||
bbmargin = QtGui.QLabel('Boundary Margin:')
|
||||
bbmargin.setToolTip(
|
||||
"Distance of the edges of the box\n"
|
||||
"to the nearest polygon."
|
||||
)
|
||||
grid4.attach(l9, 0, 0, 1, 1)
|
||||
grid4.addWidget(bbmargin, 0, 0)
|
||||
self.bbmargin_entry = LengthEntry()
|
||||
grid4.attach(self.bbmargin_entry, 1, 0, 1, 1)
|
||||
grid4.addWidget(self.bbmargin_entry, 0, 1)
|
||||
|
||||
self.bbrounded_cb = FCCheckBox(label="Rounded corners")
|
||||
self.bbrounded_cb.set_tooltip_markup(
|
||||
self.bbrounded_cb.setToolTip(
|
||||
"If the bounding box is \n"
|
||||
"to have rounded corners\n"
|
||||
"their radius is equal to\n"
|
||||
"the margin."
|
||||
)
|
||||
grid4.attach(self.bbrounded_cb, 0, 1, 2, 1)
|
||||
grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
|
||||
|
||||
self.generate_bb_button = Gtk.Button(label='Generate Geometry')
|
||||
self.generate_bb_button.set_tooltip_markup(
|
||||
self.generate_bb_button = QtGui.QPushButton('Generate Geometry')
|
||||
self.generate_bb_button.setToolTip(
|
||||
"Genrate the Geometry object."
|
||||
)
|
||||
self.custom_box.pack_start(self.generate_bb_button, expand=True, fill=False, padding=2)
|
||||
self.custom_box.addWidget(self.generate_bb_button)
|
||||
|
||||
|
||||
# def main():
|
||||
#
|
||||
# app = QtGui.QApplication(sys.argv)
|
||||
# fc = GerberObjectUI()
|
||||
# sys.exit(app.exec_())
|
||||
#
|
||||
#
|
||||
# if __name__ == '__main__':
|
||||
# main()
|
||||
Reference in New Issue
Block a user