浏览代码

- added plot kind for CNC Job in the App Preferences

Marius Stanciu 7 年之前
父节点
当前提交
9dfbae7515
共有 6 个文件被更改,包括 52 次插入18 次删除
  1. 3 1
      FlatCAM.py
  2. 6 1
      FlatCAMApp.py
  3. 34 13
      FlatCAMGUI.py
  4. 1 1
      FlatCAMObj.py
  5. 7 2
      ObjectUI.py
  6. 1 0
      README.md

+ 3 - 1
FlatCAM.py

@@ -5,7 +5,7 @@ from PyQt5 import QtGui, QtCore, QtWidgets
 from FlatCAMApp import App
 from multiprocessing import freeze_support
 import VisPyPatches
-
+import qtmodern.styles, qtmodern.windows
 
 if sys.platform == "win32":
     # cx_freeze 'module win32' workaround
@@ -34,5 +34,7 @@ if __name__ == '__main__':
 
     app = QtWidgets.QApplication(sys.argv)
     fc = App()
+
+    # qtmodern.styles.dark(app)
     sys.exit(app.exec_())
 

+ 6 - 1
FlatCAMApp.py

@@ -394,6 +394,7 @@ class App(QtCore.QObject):
             "geometry_extracut": self.geometry_defaults_form.geometry_opt_group.extracut_cb,
 
             "cncjob_plot": self.cncjob_defaults_form.cncjob_gen_group.plot_cb,
+            "cncjob_plot_kind": self.cncjob_defaults_form.cncjob_gen_group.cncplot_method_radio,
             "cncjob_tooldia": self.cncjob_defaults_form.cncjob_gen_group.tooldia_entry,
             "cncjob_coords_decimals": self.cncjob_defaults_form.cncjob_gen_group.coords_dec_entry,
             "cncjob_fr_decimals": self.cncjob_defaults_form.cncjob_gen_group.fr_dec_entry,
@@ -580,6 +581,7 @@ class App(QtCore.QObject):
             "geometry_circle_steps": 64,
 
             "cncjob_plot": True,
+            "cncjob_plot_kind": 'all',
             "cncjob_tooldia": 0.0393701,
             "cncjob_coords_decimals": 4,
             "cncjob_fr_decimals": 2,
@@ -2288,7 +2290,10 @@ class App(QtCore.QObject):
 
         def worker_task(obj):
             with self.proc_container.new("Plotting"):
-                obj.plot()
+                if isinstance(obj, FlatCAMCNCjob):
+                    obj.plot(kind=self.defaults["cncjob_plot_kind"])
+                else:
+                    obj.plot()
                 t1 = time.time()  # DEBUG
                 self.log.debug("%f seconds adding object and plotting." % (t1 - t0))
                 self.object_plotted.emit(obj)

+ 34 - 13
FlatCAMGUI.py

@@ -1968,7 +1968,7 @@ class CNCJobPreferencesUI(QtWidgets.QWidget):
         self.setLayout(self.layout)
 
         self.cncjob_gen_group = CNCJobGenPrefGroupUI()
-        self.cncjob_gen_group.setFixedWidth(260)
+        self.cncjob_gen_group.setFixedWidth(270)
         self.cncjob_opt_group = CNCJobOptPrefGroupUI()
         self.cncjob_opt_group.setFixedWidth(260)
 
@@ -3333,24 +3333,45 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
 
         grid0 = QtWidgets.QGridLayout()
         self.layout.addLayout(grid0)
+        grid0.setColumnStretch(1, 1)
+        grid0.setColumnStretch(2, 1)
 
         # Plot CB
         # self.plot_cb = QtWidgets.QCheckBox('Plot')
-        self.plot_cb = FCCheckBox('Plot')
+        self.plot_cb = FCCheckBox('Plot Object')
         self.plot_cb.setToolTip(
             "Plot (show) this object."
         )
         grid0.addWidget(self.plot_cb, 0, 0)
 
+        # Plot Kind
+        self.cncplot_method_label = QtWidgets.QLabel("Plot kind:")
+        self.cncplot_method_label.setToolTip(
+            "This selects the kind of geometries on the canvas to plot.\n"
+            "Those can be either of type 'Travel' which means the moves\n"
+            "above the work piece or it can be of type 'Cut',\n"
+            "which means the moves that cut into the material."
+        )
+
+        self.cncplot_method_radio = RadioSet([
+            {"label": "All", "value": "all"},
+            {"label": "Travel", "value": "travel"},
+            {"label": "Cut", "value": "cut"}
+        ], stretch=False)
+
+        grid0.addWidget(self.cncplot_method_label, 1, 0)
+        grid0.addWidget(self.cncplot_method_radio, 1, 1)
+        grid0.addWidget(QtWidgets.QLabel(''), 1, 2)
+
         # Number of circle steps for circular aperture linear approximation
         self.steps_per_circle_label = QtWidgets.QLabel("Circle Steps:")
         self.steps_per_circle_label.setToolTip(
             "The number of circle steps for <b>GCode</b> \n"
             "circle and arc shapes linear approximation."
         )
-        grid0.addWidget(self.steps_per_circle_label, 1, 0)
+        grid0.addWidget(self.steps_per_circle_label, 2, 0)
         self.steps_per_circle_entry = IntEntry()
-        grid0.addWidget(self.steps_per_circle_entry, 1, 1)
+        grid0.addWidget(self.steps_per_circle_entry, 2, 1)
 
         # Tool dia for plot
         tdlabel = QtWidgets.QLabel('Tool dia:')
@@ -3358,29 +3379,29 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
             "Diameter of the tool to be\n"
             "rendered in the plot."
         )
-        grid0.addWidget(tdlabel, 2, 0)
+        grid0.addWidget(tdlabel, 3, 0)
         self.tooldia_entry = LengthEntry()
-        grid0.addWidget(self.tooldia_entry, 2, 1)
+        grid0.addWidget(self.tooldia_entry, 3, 1)
 
         # Number of decimals to use in GCODE coordinates
-        cdeclabel = QtWidgets.QLabel('Coords decimals:')
+        cdeclabel = QtWidgets.QLabel('Coords dec.:')
         cdeclabel.setToolTip(
             "The number of decimals to be used for \n"
             "the X, Y, Z coordinates in CNC code (GCODE, etc.)"
         )
-        grid0.addWidget(cdeclabel, 3, 0)
+        grid0.addWidget(cdeclabel, 4, 0)
         self.coords_dec_entry = IntEntry()
-        grid0.addWidget(self.coords_dec_entry, 3, 1)
+        grid0.addWidget(self.coords_dec_entry, 4, 1)
 
         # Number of decimals to use in GCODE feedrate
-        frdeclabel = QtWidgets.QLabel('Feedrate decimals:')
+        frdeclabel = QtWidgets.QLabel('Feedrate dec.:')
         frdeclabel.setToolTip(
             "The number of decimals to be used for \n"
-            "the feedrate in CNC code (GCODE, etc.)"
+            "the Feedrate parameter in CNC code (GCODE, etc.)"
         )
-        grid0.addWidget(frdeclabel, 4, 0)
+        grid0.addWidget(frdeclabel, 5, 0)
         self.fr_dec_entry = IntEntry()
-        grid0.addWidget(self.fr_dec_entry, 4, 1)
+        grid0.addWidget(self.fr_dec_entry, 5, 1)
 
         self.layout.addStretch()
 

+ 1 - 1
FlatCAMObj.py

@@ -4235,7 +4235,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         self.to_form()
 
         # set the kind of geometries are plotted by default with plot2() from camlib.CNCJob
-        self.ui.cncplot_method_combo.set_value('all')
+        self.ui.cncplot_method_combo.set_value(self.app.defaults["cncjob_plot_kind"])
 
         self.ui.updateplot_button.clicked.connect(self.on_updateplot_button_click)
         self.ui.export_gcode_button.clicked.connect(self.on_exportgcode_button_click)

+ 7 - 2
ObjectUI.py

@@ -1129,9 +1129,14 @@ class CNCObjectUI(ObjectUI):
             {"label": "Cut", "value": "cut"}
         ], stretch=False)
 
-        f_lay = QtWidgets.QFormLayout()
+        f_lay = QtWidgets.QGridLayout()
+        f_lay.setColumnStretch(1, 1)
+        f_lay.setColumnStretch(2, 1)
+
         self.custom_box.addLayout(f_lay)
-        f_lay.addRow(self.cncplot_method_label, self.cncplot_method_combo)
+        f_lay.addWidget(self.cncplot_method_label, 0, 0)
+        f_lay.addWidget(self.cncplot_method_combo, 0, 1)
+        f_lay.addWidget(QtWidgets.QLabel(''), 0, 2)
 
         e1_lbl = QtWidgets.QLabel('')
         self.custom_box.addWidget(e1_lbl)

+ 1 - 0
README.md

@@ -21,6 +21,7 @@ CAD program, and create G-Code for Isolation routing.
 - changed the messages for Units Conversion
 - all key shortcuts work across the entire application; moved all the shortcuts definitions in FlatCAMGUI.keyPressEvent()
 - renamed the theme to layout because it is really a layout change
+- added plot kind for CNC Job in the App Preferences
 - combined the geocutout and cutout_any TCL commands - work in progress
 
 5.02.3019