GeometryGenPrefGroupUI.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. from PyQt5 import QtWidgets, QtCore, QtGui
  2. from flatcamGUI.GUIElements import FCCheckBox, FCSpinner, FCEntry
  3. from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
  4. class GeometryGenPrefGroupUI(OptionsGroupUI):
  5. def __init__(self, decimals=4, parent=None):
  6. # OptionsGroupUI.__init__(self, "Geometry General Preferences", parent=parent)
  7. super(GeometryGenPrefGroupUI, self).__init__(self)
  8. self.setTitle(str(_("Geometry General")))
  9. self.decimals = decimals
  10. # ## Plot options
  11. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  12. self.layout.addWidget(self.plot_options_label)
  13. # Plot CB
  14. self.plot_cb = FCCheckBox(label=_('Plot'))
  15. self.plot_cb.setToolTip(
  16. _("Plot (show) this object.")
  17. )
  18. self.layout.addWidget(self.plot_cb)
  19. grid0 = QtWidgets.QGridLayout()
  20. self.layout.addLayout(grid0)
  21. grid0.setColumnStretch(0, 0)
  22. grid0.setColumnStretch(1, 1)
  23. # Number of circle steps for circular aperture linear approximation
  24. self.circle_steps_label = QtWidgets.QLabel('%s:' % _("Circle Steps"))
  25. self.circle_steps_label.setToolTip(
  26. _("The number of circle steps for <b>Geometry</b> \n"
  27. "circle and arc shapes linear approximation.")
  28. )
  29. self.circle_steps_entry = FCSpinner()
  30. self.circle_steps_entry.set_range(0, 999)
  31. grid0.addWidget(self.circle_steps_label, 1, 0)
  32. grid0.addWidget(self.circle_steps_entry, 1, 1)
  33. # Tools
  34. self.tools_label = QtWidgets.QLabel("<b>%s:</b>" % _("Tools"))
  35. grid0.addWidget(self.tools_label, 2, 0, 1, 2)
  36. # Tooldia
  37. tdlabel = QtWidgets.QLabel('<b><font color="green">%s:</font></b>' % _('Tools Dia'))
  38. tdlabel.setToolTip(
  39. _("Diameters of the tools, separated by comma.\n"
  40. "The value of the diameter has to use the dot decimals separator.\n"
  41. "Valid values: 0.3, 1.0")
  42. )
  43. self.cnctooldia_entry = FCEntry()
  44. grid0.addWidget(tdlabel, 3, 0)
  45. grid0.addWidget(self.cnctooldia_entry, 3, 1)
  46. separator_line = QtWidgets.QFrame()
  47. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  48. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  49. grid0.addWidget(separator_line, 9, 0, 1, 2)
  50. # Geometry Object Color
  51. self.gerber_color_label = QtWidgets.QLabel('<b>%s</b>' % _('Geometry Object Color'))
  52. grid0.addWidget(self.gerber_color_label, 10, 0, 1, 2)
  53. # Plot Line Color
  54. self.line_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
  55. self.line_color_label.setToolTip(
  56. _("Set the line color for plotted objects.")
  57. )
  58. self.line_color_entry = FCEntry()
  59. self.line_color_button = QtWidgets.QPushButton()
  60. self.line_color_button.setFixedSize(15, 15)
  61. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  62. self.form_box_child_2.addWidget(self.line_color_entry)
  63. self.form_box_child_2.addWidget(self.line_color_button)
  64. self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  65. grid0.addWidget(self.line_color_label, 11, 0)
  66. grid0.addLayout(self.form_box_child_2, 11, 1)
  67. self.layout.addStretch()
  68. # Setting plot colors signals
  69. self.line_color_entry.editingFinished.connect(self.on_line_color_entry)
  70. self.line_color_button.clicked.connect(self.on_line_color_button)
  71. def on_line_color_entry(self):
  72. self.app.defaults['geometry_plot_line'] = self.line_color_entry.get_value()[:7] + 'FF'
  73. self.line_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['geometry_plot_line'])[:7])
  74. def on_line_color_button(self):
  75. current_color = QtGui.QColor(self.app.defaults['geometry_plot_line'][:7])
  76. # print(current_color)
  77. c_dialog = QtWidgets.QColorDialog()
  78. plot_line_color = c_dialog.getColor(initial=current_color)
  79. if plot_line_color.isValid() is False:
  80. return
  81. self.line_color_button.setStyleSheet("background-color:%s" % str(plot_line_color.name()))
  82. new_val_line = str(plot_line_color.name()) + str(self.app.defaults['geometry_plot_line'][7:9])
  83. self.line_color_entry.set_value(new_val_line)