ToolsPanelizePrefGroupUI.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import FCDoubleSpinner, FCSpinner, RadioSet, FCCheckBox
  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 ToolsPanelizePrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  19. super(ToolsPanelizePrefGroupUI, self).__init__(self, parent=parent)
  20. self.setTitle(str(_("Panelize Tool Options")))
  21. self.decimals = decimals
  22. # ## Board cuttout
  23. self.panelize_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
  24. self.panelize_label.setToolTip(
  25. _("Create an object that contains an array of (x, y) elements,\n"
  26. "each element is a copy of the source object spaced\n"
  27. "at a X distance, Y distance of each other.")
  28. )
  29. self.layout.addWidget(self.panelize_label)
  30. grid0 = QtWidgets.QGridLayout()
  31. self.layout.addLayout(grid0)
  32. grid0.setColumnStretch(0, 0)
  33. grid0.setColumnStretch(1, 1)
  34. # ## Spacing Columns
  35. self.pspacing_columns = FCDoubleSpinner()
  36. self.pspacing_columns.set_range(0.000001, 9999.9999)
  37. self.pspacing_columns.set_precision(self.decimals)
  38. self.pspacing_columns.setSingleStep(0.1)
  39. self.spacing_columns_label = QtWidgets.QLabel('%s:' % _("Spacing cols"))
  40. self.spacing_columns_label.setToolTip(
  41. _("Spacing between columns of the desired panel.\n"
  42. "In current units.")
  43. )
  44. grid0.addWidget(self.spacing_columns_label, 0, 0)
  45. grid0.addWidget(self.pspacing_columns, 0, 1)
  46. # ## Spacing Rows
  47. self.pspacing_rows = FCDoubleSpinner()
  48. self.pspacing_rows.set_range(0.000001, 9999.9999)
  49. self.pspacing_rows.set_precision(self.decimals)
  50. self.pspacing_rows.setSingleStep(0.1)
  51. self.spacing_rows_label = QtWidgets.QLabel('%s:' % _("Spacing rows"))
  52. self.spacing_rows_label.setToolTip(
  53. _("Spacing between rows of the desired panel.\n"
  54. "In current units.")
  55. )
  56. grid0.addWidget(self.spacing_rows_label, 1, 0)
  57. grid0.addWidget(self.pspacing_rows, 1, 1)
  58. # ## Columns
  59. self.pcolumns = FCSpinner()
  60. self.pcolumns.set_range(1, 1000)
  61. self.pcolumns.set_step(1)
  62. self.columns_label = QtWidgets.QLabel('%s:' % _("Columns"))
  63. self.columns_label.setToolTip(
  64. _("Number of columns of the desired panel")
  65. )
  66. grid0.addWidget(self.columns_label, 2, 0)
  67. grid0.addWidget(self.pcolumns, 2, 1)
  68. # ## Rows
  69. self.prows = FCSpinner()
  70. self.prows.set_range(1, 1000)
  71. self.prows.set_step(1)
  72. self.rows_label = QtWidgets.QLabel('%s:' % _("Rows"))
  73. self.rows_label.setToolTip(
  74. _("Number of rows of the desired panel")
  75. )
  76. grid0.addWidget(self.rows_label, 3, 0)
  77. grid0.addWidget(self.prows, 3, 1)
  78. # ## Type of resulting Panel object
  79. self.panel_type_radio = RadioSet([{'label': _('Gerber'), 'value': 'gerber'},
  80. {'label': _('Geo'), 'value': 'geometry'}])
  81. self.panel_type_label = QtWidgets.QLabel('%s:' % _("Panel Type"))
  82. self.panel_type_label.setToolTip(
  83. _("Choose the type of object for the panel object:\n"
  84. "- Gerber\n"
  85. "- Geometry")
  86. )
  87. grid0.addWidget(self.panel_type_label, 4, 0)
  88. grid0.addWidget(self.panel_type_radio, 4, 1)
  89. # ## Constrains
  90. self.pconstrain_cb = FCCheckBox('%s:' % _("Constrain within"))
  91. self.pconstrain_cb.setToolTip(
  92. _("Area define by DX and DY within to constrain the panel.\n"
  93. "DX and DY values are in current units.\n"
  94. "Regardless of how many columns and rows are desired,\n"
  95. "the final panel will have as many columns and rows as\n"
  96. "they fit completely within selected area.")
  97. )
  98. grid0.addWidget(self.pconstrain_cb, 5, 0, 1, 2)
  99. self.px_width_entry = FCDoubleSpinner()
  100. self.px_width_entry.set_range(0.000001, 9999.9999)
  101. self.px_width_entry.set_precision(self.decimals)
  102. self.px_width_entry.setSingleStep(0.1)
  103. self.x_width_lbl = QtWidgets.QLabel('%s:' % _("Width (DX)"))
  104. self.x_width_lbl.setToolTip(
  105. _("The width (DX) within which the panel must fit.\n"
  106. "In current units.")
  107. )
  108. grid0.addWidget(self.x_width_lbl, 6, 0)
  109. grid0.addWidget(self.px_width_entry, 6, 1)
  110. self.py_height_entry = FCDoubleSpinner()
  111. self.py_height_entry.set_range(0.000001, 9999.9999)
  112. self.py_height_entry.set_precision(self.decimals)
  113. self.py_height_entry.setSingleStep(0.1)
  114. self.y_height_lbl = QtWidgets.QLabel('%s:' % _("Height (DY)"))
  115. self.y_height_lbl.setToolTip(
  116. _("The height (DY)within which the panel must fit.\n"
  117. "In current units.")
  118. )
  119. grid0.addWidget(self.y_height_lbl, 7, 0)
  120. grid0.addWidget(self.py_height_entry, 7, 1)
  121. self.layout.addStretch()