Tools2FiducialsPrefGroupUI.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from AppGUI.GUIElements import FCDoubleSpinner, RadioSet
  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 Tools2FiducialsPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. super(Tools2FiducialsPrefGroupUI, self).__init__(self, parent=parent)
  19. self.setTitle(str(_("Fiducials Tool Options")))
  20. self.decimals = decimals
  21. # ## Grid Layout
  22. grid_lay = QtWidgets.QGridLayout()
  23. self.layout.addLayout(grid_lay)
  24. grid_lay.setColumnStretch(0, 0)
  25. grid_lay.setColumnStretch(1, 1)
  26. self.param_label = QtWidgets.QLabel('<b>%s:</b>' % _('Parameters'))
  27. self.param_label.setToolTip(
  28. _("Parameters used for this tool.")
  29. )
  30. grid_lay.addWidget(self.param_label, 0, 0, 1, 2)
  31. # DIAMETER #
  32. self.dia_label = QtWidgets.QLabel('%s:' % _("Size"))
  33. self.dia_label.setToolTip(
  34. _("This set the fiducial diameter if fiducial type is circular,\n"
  35. "otherwise is the size of the fiducial.\n"
  36. "The soldermask opening is double than that.")
  37. )
  38. self.dia_entry = FCDoubleSpinner()
  39. self.dia_entry.set_range(1.0000, 3.0000)
  40. self.dia_entry.set_precision(self.decimals)
  41. self.dia_entry.setWrapping(True)
  42. self.dia_entry.setSingleStep(0.1)
  43. grid_lay.addWidget(self.dia_label, 1, 0)
  44. grid_lay.addWidget(self.dia_entry, 1, 1)
  45. # MARGIN #
  46. self.margin_label = QtWidgets.QLabel('%s:' % _("Margin"))
  47. self.margin_label.setToolTip(
  48. _("Bounding box margin.")
  49. )
  50. self.margin_entry = FCDoubleSpinner()
  51. self.margin_entry.set_range(-9999.9999, 9999.9999)
  52. self.margin_entry.set_precision(self.decimals)
  53. self.margin_entry.setSingleStep(0.1)
  54. grid_lay.addWidget(self.margin_label, 2, 0)
  55. grid_lay.addWidget(self.margin_entry, 2, 1)
  56. # Mode #
  57. self.mode_radio = RadioSet([
  58. {'label': _('Auto'), 'value': 'auto'},
  59. {"label": _("Manual"), "value": "manual"}
  60. ], stretch=False)
  61. self.mode_label = QtWidgets.QLabel(_("Mode:"))
  62. self.mode_label.setToolTip(
  63. _("- 'Auto' - automatic placement of fiducials in the corners of the bounding box.\n"
  64. "- 'Manual' - manual placement of fiducials.")
  65. )
  66. grid_lay.addWidget(self.mode_label, 3, 0)
  67. grid_lay.addWidget(self.mode_radio, 3, 1)
  68. # Position for second fiducial #
  69. self.pos_radio = RadioSet([
  70. {'label': _('Up'), 'value': 'up'},
  71. {"label": _("Down"), "value": "down"},
  72. {"label": _("None"), "value": "no"}
  73. ], stretch=False)
  74. self.pos_label = QtWidgets.QLabel('%s:' % _("Second fiducial"))
  75. self.pos_label.setToolTip(
  76. _("The position for the second fiducial.\n"
  77. "- 'Up' - the order is: bottom-left, top-left, top-right.\n"
  78. "- 'Down' - the order is: bottom-left, bottom-right, top-right.\n"
  79. "- 'None' - there is no second fiducial. The order is: bottom-left, top-right.")
  80. )
  81. grid_lay.addWidget(self.pos_label, 4, 0)
  82. grid_lay.addWidget(self.pos_radio, 4, 1)
  83. separator_line = QtWidgets.QFrame()
  84. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  85. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  86. grid_lay.addWidget(separator_line, 5, 0, 1, 2)
  87. # Fiducial type #
  88. self.fid_type_radio = RadioSet([
  89. {'label': _('Circular'), 'value': 'circular'},
  90. {"label": _("Cross"), "value": "cross"},
  91. {"label": _("Chess"), "value": "chess"}
  92. ], stretch=False)
  93. self.fid_type_label = QtWidgets.QLabel('%s:' % _("Fiducial Type"))
  94. self.fid_type_label.setToolTip(
  95. _("The type of fiducial.\n"
  96. "- 'Circular' - this is the regular fiducial.\n"
  97. "- 'Cross' - cross lines fiducial.\n"
  98. "- 'Chess' - chess pattern fiducial.")
  99. )
  100. grid_lay.addWidget(self.fid_type_label, 6, 0)
  101. grid_lay.addWidget(self.fid_type_radio, 6, 1)
  102. # Line Thickness #
  103. self.line_thickness_label = QtWidgets.QLabel('%s:' % _("Line thickness"))
  104. self.line_thickness_label.setToolTip(
  105. _("Bounding box margin.")
  106. )
  107. self.line_thickness_entry = FCDoubleSpinner()
  108. self.line_thickness_entry.set_range(0.00001, 9999.9999)
  109. self.line_thickness_entry.set_precision(self.decimals)
  110. self.line_thickness_entry.setSingleStep(0.1)
  111. grid_lay.addWidget(self.line_thickness_label, 7, 0)
  112. grid_lay.addWidget(self.line_thickness_entry, 7, 1)
  113. self.layout.addStretch()