Просмотр исходного кода

- modified the GUI in Objects Selected Tab to accommodate 2 different modes: basic and Advanced. In Basic mode, some of the functionality's are hidden from the user.

Marius Stanciu 7 лет назад
Родитель
Сommit
88a0be7cf1
5 измененных файлов с 178 добавлено и 37 удалено
  1. 26 13
      FlatCAMApp.py
  2. 30 4
      FlatCAMGUI.py
  3. 62 0
      FlatCAMObj.py
  4. 59 20
      ObjectUI.py
  5. 1 0
      README.md

+ 26 - 13
FlatCAMApp.py

@@ -311,6 +311,7 @@ class App(QtCore.QObject):
             "global_send_stats": self.general_defaults_form.general_app_group.send_stats_cb,
             "global_project_at_startup": self.general_defaults_form.general_app_group.project_startup_cb,
             "global_project_autohide": self.general_defaults_form.general_app_group.project_autohide_cb,
+            "global_advanced": self.general_defaults_form.general_app_group.advanced_cb,
 
             "global_gridx": self.general_defaults_form.general_gui_group.gridx_entry,
             "global_gridy": self.general_defaults_form.general_gui_group.gridy_entry,
@@ -486,6 +487,7 @@ class App(QtCore.QObject):
             "global_send_stats": True,
             "global_project_at_startup": False,
             "global_project_autohide": True,
+            "global_advanced": False,
 
             "global_gridx": 1.0,
             "global_gridy": 1.0,
@@ -3597,21 +3599,32 @@ class App(QtCore.QObject):
         # work only if the notebook tab on focus is the Selected_Tab and only if the object is Geometry
         if notebook_widget_name == 'selected_tab':
             if str(type(self.collection.get_active())) == "<class 'FlatCAMObj.FlatCAMGeometry'>":
-                tool_add_popup = FCInputDialog(title="New Tool ...",
-                                               text='Enter a Tool Diameter:',
-                                               min=0.0000, max=99.9999, decimals=4)
-                tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png'))
-
-                val, ok = tool_add_popup.get_value()
-                if ok:
-                    if float(val) == 0:
+                # Tool add works for Geometry only if Advanced is True in Preferences
+                if self.defaults["global_advanced"] is True:
+                    tool_add_popup = FCInputDialog(title="New Tool ...",
+                                                   text='Enter a Tool Diameter:',
+                                                   min=0.0000, max=99.9999, decimals=4)
+                    tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png'))
+
+                    val, ok = tool_add_popup.get_value()
+                    if ok:
+                        if float(val) == 0:
+                            self.inform.emit(
+                                "[WARNING_NOTCL] Please enter a tool diameter with non-zero value, in Float format.")
+                            return
+                        self.collection.get_active().on_tool_add(dia=float(val))
+                    else:
                         self.inform.emit(
-                            "[WARNING_NOTCL] Please enter a tool diameter with non-zero value, in Float format.")
-                        return
-                    self.collection.get_active().on_tool_add(dia=float(val))
+                            "[WARNING_NOTCL] Adding Tool cancelled ...")
                 else:
-                    self.inform.emit(
-                        "[WARNING_NOTCL] Adding Tool cancelled ...")
+                    msgbox = QtWidgets.QMessageBox()
+                    msgbox.setText("Adding Tool works only when Advanced is checked.\n"
+                                   "Go to Preferences -> General - Show Advanced Options.")
+                    msgbox.setWindowTitle("Tool adding ...")
+                    msgbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
+                    msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
+                    msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok)
+                    msgbox.exec_()
 
         # work only if the notebook tab on focus is the Tools_Tab
         if notebook_widget_name == 'tool_tab':

+ 30 - 4
FlatCAMGUI.py

@@ -1165,6 +1165,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
 			<td height="20">&nbsp;</td>
 			<td>&nbsp;</td>
 		</tr>
+        <tr height="20">
+			<td height="20"><strong>ALT+R</strong></td>
+			<td>&nbsp;Editor Transformation Tool</td>
+		</tr>
         <tr height="20">
 			<td height="20"><strong>ALT+X</strong></td>
 			<td>&nbsp;Offset shape on X axis</td>
@@ -3104,6 +3108,25 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         # to the main layout of this TAB
         self.layout.addLayout(self.form_box)
 
+        hlay = QtWidgets.QHBoxLayout()
+        self.layout.addLayout(hlay)
+
+        # Advanced CB
+        self.advanced_cb = FCCheckBox('Show Advanced Options')
+        self.advanced_cb.setToolTip(
+            "When checked, Advanced Options will be\n"
+            "displayed in the Selected Tab for all\n"
+            "kind of objects."
+        )
+        # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
+        hlay.addWidget(self.advanced_cb)
+        hlay.addStretch()
+
+        self.form_box_2 = QtWidgets.QFormLayout()
+        self.layout.addLayout(self.form_box_2)
+
+        self.layout.addStretch()
+
 
 class GerberGenPrefGroupUI(OptionsGroupUI):
     def __init__(self, parent=None):
@@ -3519,8 +3542,11 @@ class ExcellonGenPrefGroupUI(OptionsGroupUI):
             self.optimization_time_label.setDisabled(True)
             self.optimization_time_entry.setDisabled(True)
 
-        ## Create CNC Job
-        self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job</b>')
+        ######################
+        ## ADVANCED OPTIONS ##
+        ######################
+
+        self.cncjob_label = QtWidgets.QLabel('<b>Advanced Options:</b>')
         self.cncjob_label.setToolTip(
             "Parameters used to create a CNC Job object\n"
             "for this drill object that are not changed very often."
@@ -3965,9 +3991,9 @@ class GeometryGenPrefGroupUI(OptionsGroupUI):
 
 
         # ------------------------------
-        ## Create CNC Job
+        ## Advanced Options
         # ------------------------------
-        self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job:</b>')
+        self.cncjob_label = QtWidgets.QLabel('<b>Advanced Options:</b>')
         self.cncjob_label.setToolTip(
             "Parameters to create a CNC Job object\n"
             "tracing the contours of a Geometry object."

+ 62 - 0
FlatCAMObj.py

@@ -478,6 +478,19 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
         self.ui.generate_noncopper_button.clicked.connect(self.on_generatenoncopper_button_click)
         self.ui.aperture_table_visibility_cb.stateChanged.connect(self.on_aperture_table_visibility_change)
 
+        # Show/Hide Advanced Options
+        if self.app.defaults["global_advanced"] is False:
+            self.ui.level.setText('<span style="color:green;"><b>BASIC Mode</b></span>')
+            self.ui.apertures_table_label.hide()
+            self.ui.aperture_table_visibility_cb.hide()
+            self.ui.milling_type_label.hide()
+            self.ui.milling_type_radio.hide()
+            self.ui.generate_ext_iso_button.hide()
+            self.ui.generate_int_iso_button.hide()
+
+        else:
+            self.ui.level.setText('<span style="color:red;"><b>ADVANCED Mode</b></span>')
+
         self.build_ui()
 
     def build_ui(self):
@@ -1528,6 +1541,24 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
                     dia = float('%.3f' % float(value['C']))
                 self.tool_offset[dia] = t_default_offset
 
+        # Show/Hide Advanced Options
+        if self.app.defaults["global_advanced"] is False:
+            self.ui.level.setText('<span style="color:green;"><b>BASIC Mode</b></span>')
+
+            self.ui.tools_table.setColumnHidden(4, True)
+            self.ui.estartz_label.hide()
+            self.ui.estartz_entry.hide()
+            self.ui.eendz_label.hide()
+            self.ui.eendz_entry.hide()
+            self.ui.feedrate_rapid_label.hide()
+            self.ui.feedrate_rapid_entry.hide()
+            self.ui.pdepth_label.hide()
+            self.ui.pdepth_entry.hide()
+            self.ui.feedrate_probe_label.hide()
+            self.ui.feedrate_probe_entry.hide()
+        else:
+            self.ui.level.setText('<span style="color:red;"><b>ADVANCED Mode</b></span>')
+
         assert isinstance(self.ui, ExcellonObjectUI), \
             "Expected a ExcellonObjectUI, got %s" % type(self.ui)
         self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click)
@@ -2744,6 +2775,30 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         self.ui.geo_tools_table.addContextMenu(
             "Delete", lambda: self.on_tool_delete(all=None), icon=QtGui.QIcon("share/delete32.png"))
 
+        # Show/Hide Advanced Options
+        if self.app.defaults["global_advanced"] is False:
+            self.ui.level.setText('<span style="color:green;"><b>BASIC Mode</b></span>')
+
+            self.ui.geo_tools_table.setColumnHidden(2, True)
+            self.ui.geo_tools_table.setColumnHidden(3, True)
+            self.ui.geo_tools_table.setColumnHidden(4, True)
+            self.ui.addtool_entry_lbl.hide()
+            self.ui.addtool_entry.hide()
+            self.ui.addtool_btn.hide()
+            self.ui.copytool_btn.hide()
+            self.ui.deltool_btn.hide()
+            self.ui.endzlabel.hide()
+            self.ui.gendz_entry.hide()
+            self.ui.fr_rapidlabel.hide()
+            self.ui.cncfeedrate_rapid_entry.hide()
+            self.ui.extracut_cb.hide()
+            self.ui.pdepth_label.hide()
+            self.ui.pdepth_entry.hide()
+            self.ui.feedrate_probe_label.hide()
+            self.ui.feedrate_probe_entry.hide()
+        else:
+            self.ui.level.setText('<span style="color:red;"><b>ADVANCED Mode</b></span>')
+
         self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click)
         self.ui.generate_cnc_button.clicked.connect(self.on_generatecnc_button_click)
         self.ui.paint_tool_button.clicked.connect(self.app.paint_tool.run)
@@ -4762,6 +4817,13 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         # set the kind of geometries are plotted by default with plot2() from camlib.CNCJob
         self.ui.cncplot_method_combo.set_value(self.app.defaults["cncjob_plot_kind"])
 
+        # Show/Hide Advanced Options
+        if self.app.defaults["global_advanced"] is False:
+            self.ui.level.setText('<span style="color:green;"><b>BASIC Mode</b></span>')
+
+        else:
+            self.ui.level.setText('<span style="color:red;"><b>ADVANCED Mode</b></span>')
+
         self.ui.updateplot_button.clicked.connect(self.on_updateplot_button_click)
         self.ui.export_gcode_button.clicked.connect(self.on_exportgcode_button_click)
         self.ui.modify_gcode_button.clicked.connect(self.on_modifygcode_button_click)

+ 59 - 20
ObjectUI.py

@@ -108,6 +108,16 @@ class GerberObjectUI(ObjectUI):
     def __init__(self, parent=None):
         ObjectUI.__init__(self, title='Gerber Object', parent=parent)
 
+        self.level = QtWidgets.QLabel("")
+        self.level.setToolTip(
+            "In the BASIC mode certain functionality's\n"
+            "are hidden from the user.\n"
+            "To enable them, go to:\n"
+            "Edit -> Preferences -> General and check:\n"
+            "'Show Advanced Options' checkbox."
+        )
+        self.custom_box.addWidget(self.level)
+
         # Plot options
         grid0 = QtWidgets.QGridLayout()
         grid0.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
@@ -237,13 +247,13 @@ class GerberObjectUI(ObjectUI):
         grid1.addWidget(self.iso_overlap_entry, 2, 1)
 
         # Milling Type Radio Button
-        milling_type_label = QtWidgets.QLabel('Milling Type:')
-        milling_type_label.setToolTip(
+        self.milling_type_label = QtWidgets.QLabel('Milling Type:')
+        self.milling_type_label.setToolTip(
             "Milling type:\n"
             "- climb / best for precision milling and to reduce tool usage\n"
             "- conventional / useful when there is no backlash compensation"
         )
-        grid1.addWidget(milling_type_label, 3, 0)
+        grid1.addWidget(self.milling_type_label, 3, 0)
         self.milling_type_radio = RadioSet([{'label': 'Climb', 'value': 'cl'},
                                     {'label': 'Conv.', 'value': 'cv'}])
         grid1.addWidget(self.milling_type_radio, 3, 1)
@@ -430,6 +440,16 @@ class ExcellonObjectUI(ObjectUI):
                           icon_file='share/drill32.png',
                           parent=parent)
 
+        self.level = QtWidgets.QLabel("")
+        self.level.setToolTip(
+            "In the BASIC mode certain functionality's\n"
+            "are hidden from the user.\n"
+            "To enable them, go to:\n"
+            "Edit -> Preferences -> General and check:\n"
+            "'Show Advanced Options' checkbox."
+        )
+        self.custom_box.addWidget(self.level)
+
         #### Plot options ####
         hlay_plot = QtWidgets.QHBoxLayout()
         self.custom_box.addLayout(hlay_plot)
@@ -485,7 +505,7 @@ class ExcellonObjectUI(ObjectUI):
         self.tools_box.addWidget(self.tools_table)
 
         self.tools_table.setColumnCount(6)
-        self.tools_table.setHorizontalHeaderLabels(['#', 'Diameter', 'Drills', 'Slots', 'Offset', 'P'])
+        self.tools_table.setHorizontalHeaderLabels(['#', 'Diameter', 'Drills', 'Slots', 'Offset Z', 'P'])
         self.tools_table.setSortingEnabled(False)
 
         self.tools_table.horizontalHeaderItem(0).setToolTip(
@@ -562,22 +582,22 @@ class ExcellonObjectUI(ObjectUI):
         self.ois_tcz_e = OptionalInputSection(self.toolchange_cb, [self.toolchangez_entry])
 
         # Start move Z:
-        startzlabel = QtWidgets.QLabel("Start move Z:")
-        startzlabel.setToolTip(
+        self.estartz_label = QtWidgets.QLabel("Start move Z:")
+        self.estartz_label.setToolTip(
             "Tool height just before starting the work.\n"
             "Delete the value if you don't need this feature."
         )
-        grid1.addWidget(startzlabel, 4, 0)
+        grid1.addWidget(self.estartz_label, 4, 0)
         self.estartz_entry = FloatEntry()
         grid1.addWidget(self.estartz_entry, 4, 1)
 
         # End move Z:
-        endzlabel = QtWidgets.QLabel("End move Z:")
-        endzlabel.setToolTip(
+        self.eendz_label = QtWidgets.QLabel("End move Z:")
+        self.eendz_label.setToolTip(
             "Z-axis position (height) for\n"
             "the last move."
         )
-        grid1.addWidget(endzlabel, 5, 0)
+        grid1.addWidget(self.eendz_label, 5, 0)
         self.eendz_entry = LengthEntry()
         grid1.addWidget(self.eendz_entry, 5, 1)
 
@@ -593,13 +613,13 @@ class ExcellonObjectUI(ObjectUI):
         grid1.addWidget(self.feedrate_entry, 6, 1)
 
         # Excellon Rapid Feedrate
-        fr_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
-        fr_rapid_label.setToolTip(
+        self.feedrate_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
+        self.feedrate_rapid_label.setToolTip(
             "Tool speed while drilling\n"
             "(in units per minute).\n"
             "This is for the rapid move G00."
         )
-        grid1.addWidget(fr_rapid_label, 7, 0)
+        grid1.addWidget(self.feedrate_rapid_label, 7, 0)
         self.feedrate_rapid_entry = LengthEntry()
         grid1.addWidget(self.feedrate_rapid_entry, 7, 1)
 
@@ -753,6 +773,16 @@ class GeometryObjectUI(ObjectUI):
     def __init__(self, parent=None):
         super(GeometryObjectUI, self).__init__(title='Geometry Object', icon_file='share/geometry32.png', parent=parent)
 
+        self.level = QtWidgets.QLabel("")
+        self.level.setToolTip(
+            "In the BASIC mode certain functionality's\n"
+            "are hidden from the user.\n"
+            "To enable them, go to:\n"
+            "Edit -> Preferences -> General and check:\n"
+            "'Show Advanced Options' checkbox."
+        )
+        self.custom_box.addWidget(self.level)
+
         # Plot options
         self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
         self.custom_box.addWidget(self.plot_options_label)
@@ -976,7 +1006,6 @@ class GeometryObjectUI(ObjectUI):
         )
         self.grid3.addWidget(self.mpass_cb, 4, 0)
 
-
         self.maxdepth_entry = LengthEntry()
         self.maxdepth_entry.setToolTip(
             "Depth of each pass (positive)."
@@ -1026,12 +1055,12 @@ class GeometryObjectUI(ObjectUI):
         # self.grid3.addWidget(self.gstartz_entry, 8, 1)
 
         # The Z value for the end move
-        endzlabel = QtWidgets.QLabel('End move Z:')
-        endzlabel.setToolTip(
+        self.endzlabel = QtWidgets.QLabel('End move Z:')
+        self.endzlabel.setToolTip(
             "This is the height (Z) at which the CNC\n"
             "will go as the last move."
         )
-        self.grid3.addWidget(endzlabel, 9, 0)
+        self.grid3.addWidget(self.endzlabel, 9, 0)
         self.gendz_entry = LengthEntry()
         self.grid3.addWidget(self.gendz_entry, 9, 1)
 
@@ -1056,13 +1085,13 @@ class GeometryObjectUI(ObjectUI):
         self.grid3.addWidget(self.cncplunge_entry, 11, 1)
 
         # Feedrate rapids
-        fr_rapidlabel = QtWidgets.QLabel('Feed Rate Rapids:')
-        fr_rapidlabel.setToolTip(
+        self.fr_rapidlabel = QtWidgets.QLabel('Feed Rate Rapids:')
+        self.fr_rapidlabel.setToolTip(
             "Cutting speed in the XY\n"
             "plane in units per minute\n"
             "for the rapid movements"
         )
-        self.grid3.addWidget(fr_rapidlabel, 12, 0)
+        self.grid3.addWidget(self.fr_rapidlabel, 12, 0)
         self.cncfeedrate_rapid_entry = LengthEntry()
         self.grid3.addWidget(self.cncfeedrate_rapid_entry, 12, 1)
 
@@ -1182,6 +1211,16 @@ class CNCObjectUI(ObjectUI):
 
         ObjectUI.__init__(self, title='CNC Job Object', icon_file='share/cnc32.png', parent=parent)
 
+        self.level = QtWidgets.QLabel("")
+        self.level.setToolTip(
+            "In the BASIC mode certain functionality's\n"
+            "are hidden from the user.\n"
+            "To enable them, go to:\n"
+            "Edit -> Preferences -> General and check:\n"
+            "'Show Advanced Options' checkbox."
+        )
+        self.custom_box.addWidget(self.level)
+
         # Scale and offset ans skew are not available for CNCJob objects.
         # Hiding from the GUI.
         for i in range(0, self.scale_grid.count()):

+ 1 - 0
README.md

@@ -25,6 +25,7 @@ CAD program, and create G-Code for Isolation routing.
 - added a button to clear de GUI preferences in Preferences -> General -> Gui Settings -> Clear GUI Settings
 - added key shortcuts for the shape transformations within Geometry Editor: X, Y keys for Flip(mirror), SHIFT+X, SHIFT+Y combo keys for Skew and ALT+X, ALT+Y combo keys for Offset
 - adjusted the plotcanvas.zomm_fit() function so the objects are better fit into view (with a border around) 
+- modified the GUI in Objects Selected Tab to accommodate 2 different modes: basic and Advanced. In Basic mode, some of the functionality's are hidden from the user.
 
 17.02.2019