diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e823ffc..4dd8a446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,11 +17,13 @@ CHANGELOG for FlatCAM beta - finished the Romanian translation - created two new preprocessors (from 'default' and from 'grbl_11') that will have no toolchange commands regardless of the settings in the software - updated the Turkish translation (by Mehmet Kaya) -- the methods of the APP class that were the handlers for the File menu are now moved to their oen class +- the methods of the APP class that were the handlers for the File menu are now moved to their own class - fixed some of the Tcl Commands that depended on the methods refactored above - reverted the preprocessors with no toolchange commands to the original but removed the M6 toolchange command - fixed newly introduced issue when doing File -> Print(PDF) - fixed newly introduced issues with SysTray and Splash +- added ability for the app to detect the current DPI used on the screen; applied this information in the Film Tool when exporting PNG files +- found that Pillow v >= 7.2 breaks Reportlab 3.5.53 (latest version) and creates an error in Film Tool when exporting PNG files. Pillow 7.2 still works. 23.10.2020 diff --git a/FlatCAM.py b/FlatCAM.py index 934a0bb4..41868e03 100644 --- a/FlatCAM.py +++ b/FlatCAM.py @@ -90,6 +90,6 @@ if __name__ == '__main__': style = settings.value('style', type=str) app.setStyle(style) - fc = App() + fc = App(qapp=app) sys.exit(app.exec_()) # app.exec_() diff --git a/appTools/ToolFilm.py b/appTools/ToolFilm.py index 3b51bd8d..0cccacf4 100644 --- a/appTools/ToolFilm.py +++ b/appTools/ToolFilm.py @@ -63,6 +63,8 @@ class Film(AppTool): self.ui.file_type_radio.activated_custom.connect(self.ui.on_file_type) self.ui.reset_button.clicked.connect(self.set_tool_ui) + self.screen_dpi = 96 + def on_type_obj_index_changed(self, val): obj_type = 2 if val == 'geo' else 0 self.ui.tf_object_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) @@ -446,9 +448,10 @@ class Film(AppTool): scale_reference = 'center' - default_dpi = 96 + self.screen_dpi = self.app.qapp.screens()[0].logicalDotsPerInch() + new_png_dpi = self.ui.png_dpi_spinner.get_value() - dpi_rate = new_png_dpi / default_dpi + dpi_rate = new_png_dpi / self.screen_dpi # Determine bounding area for svg export bounds = box.bounds() tr_scale_reference = (bounds[0], bounds[1]) @@ -703,9 +706,10 @@ class Film(AppTool): scale_reference = 'center' - default_dpi = 96 + self.screen_dpi = self.app.qapp.screens()[0].logicalDotsPerInch() + new_png_dpi = self.ui.png_dpi_spinner.get_value() - dpi_rate = new_png_dpi / default_dpi + dpi_rate = new_png_dpi / self.screen_dpi # Determine bounding area for svg export bounds = box.bounds() tr_scale_reference = (bounds[0], bounds[1]) @@ -835,11 +839,6 @@ class Film(AppTool): doc_final = StringIO(doc_final) drawing = svg2rlg(doc_final) renderPM.drawToFile(drawing, filename, 'PNG') - - # if new_png_dpi == default_dpi: - # renderPM.drawToFile(drawing, filename, 'PNG') - # else: - # renderPM.drawToFile(drawing, filename, 'PNG', dpi=new_png_dpi) except Exception as e: log.debug("FilmTool.export_positive() --> PNG output --> %s" % str(e)) return 'fail' diff --git a/app_Main.py b/app_Main.py index bd68856c..2a92c157 100644 --- a/app_Main.py +++ b/app_Main.py @@ -267,7 +267,7 @@ class App(QtCore.QObject): # graphic residues behind cleanup = pyqtSignal() - def __init__(self, user_defaults=True): + def __init__(self, qapp, user_defaults=True): """ Starts the application. @@ -279,6 +279,8 @@ class App(QtCore.QObject): App.log.info("FlatCAM Starting...") + self.qapp = qapp + # ############################################################################################################ # ################# Setup the listening thread for another instance launching with args ###################### # ############################################################################################################