GeometryGenPrefGroupUI.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import FCCheckBox, FCSpinner, FCEntry, FCColorEntry
  4. from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
  5. import gettext
  6. import appTranslation as fcTranslate
  7. import builtins
  8. fcTranslate.apply_language('strings')
  9. if '_' not in builtins.__dict__:
  10. _ = gettext.gettext
  11. settings = QSettings("Open Source", "FlatCAM")
  12. if settings.contains("machinist"):
  13. machinist_setting = settings.value('machinist', type=int)
  14. else:
  15. machinist_setting = 0
  16. class GeometryGenPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Geometry General Preferences", parent=parent)
  19. super(GeometryGenPrefGroupUI, self).__init__(self, parent=parent)
  20. self.setTitle(str(_("Geometry General")))
  21. self.decimals = decimals
  22. # ## Plot options
  23. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  24. self.layout.addWidget(self.plot_options_label)
  25. plot_hlay = QtWidgets.QHBoxLayout()
  26. self.layout.addLayout(plot_hlay)
  27. # Plot CB
  28. self.plot_cb = FCCheckBox(label=_('Plot'))
  29. self.plot_cb.setToolTip(
  30. _("Plot (show) this object.")
  31. )
  32. plot_hlay.addWidget(self.plot_cb)
  33. # Multicolored CB
  34. self.multicolored_cb = FCCheckBox(label=_('M-Color'))
  35. self.multicolored_cb.setToolTip(
  36. _("Draw polygons in different colors.")
  37. )
  38. plot_hlay.addWidget(self.multicolored_cb)
  39. grid0 = QtWidgets.QGridLayout()
  40. self.layout.addLayout(grid0)
  41. grid0.setColumnStretch(0, 0)
  42. grid0.setColumnStretch(1, 1)
  43. # Number of circle steps for circular aperture linear approximation
  44. self.circle_steps_label = QtWidgets.QLabel('%s:' % _("Circle Steps"))
  45. self.circle_steps_label.setToolTip(
  46. _("The number of circle steps for <b>Geometry</b> \n"
  47. "circle and arc shapes linear approximation.")
  48. )
  49. self.circle_steps_entry = FCSpinner()
  50. self.circle_steps_entry.set_range(0, 999)
  51. grid0.addWidget(self.circle_steps_label, 1, 0)
  52. grid0.addWidget(self.circle_steps_entry, 1, 1)
  53. # Tools
  54. self.tools_label = QtWidgets.QLabel("<b>%s:</b>" % _("Tools"))
  55. grid0.addWidget(self.tools_label, 2, 0, 1, 2)
  56. # Tooldia
  57. tdlabel = QtWidgets.QLabel('<b><font color="green">%s:</font></b>' % _('Tools Dia'))
  58. tdlabel.setToolTip(
  59. _("Diameters of the tools, separated by comma.\n"
  60. "The value of the diameter has to use the dot decimals separator.\n"
  61. "Valid values: 0.3, 1.0")
  62. )
  63. self.cnctooldia_entry = FCEntry()
  64. grid0.addWidget(tdlabel, 3, 0)
  65. grid0.addWidget(self.cnctooldia_entry, 3, 1)
  66. separator_line = QtWidgets.QFrame()
  67. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  68. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  69. grid0.addWidget(separator_line, 9, 0, 1, 2)
  70. # Fuse Tools
  71. self.join_geo_label = QtWidgets.QLabel('<b>%s</b>:' % _('Join Option'))
  72. grid0.addWidget(self.join_geo_label, 10, 0, 1, 2)
  73. self.fuse_tools_cb = FCCheckBox(_("Fuse Tools"))
  74. self.fuse_tools_cb.setToolTip(
  75. _("When checked the joined (merged) object tools\n"
  76. "will be merged also but only if they share some of their attributes.")
  77. )
  78. grid0.addWidget(self.fuse_tools_cb, 11, 0, 1, 2)
  79. separator_line = QtWidgets.QFrame()
  80. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  81. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  82. grid0.addWidget(separator_line, 12, 0, 1, 2)
  83. # Geometry Object Color
  84. self.gerber_color_label = QtWidgets.QLabel('<b>%s</b>:' % _('Object Color'))
  85. grid0.addWidget(self.gerber_color_label, 13, 0, 1, 2)
  86. # Plot Line Color
  87. self.line_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
  88. self.line_color_label.setToolTip(
  89. _("Set the line color for plotted objects.")
  90. )
  91. self.line_color_entry = FCColorEntry()
  92. grid0.addWidget(self.line_color_label, 14, 0)
  93. grid0.addWidget(self.line_color_entry, 14, 1)
  94. self.layout.addStretch()
  95. # Setting plot colors signals
  96. self.line_color_entry.editingFinished.connect(self.on_line_color_entry)
  97. def on_line_color_entry(self):
  98. self.app.defaults['geometry_plot_line'] = self.line_color_entry.get_value()[:7] + 'FF'