- fixed a bug in Tool Transform that made the user to not be able to capture the click coordinates with SHIFT + LMB click combo
- added the ability to choose an App QStyle out of the offered choices (different for each OS) to be applied at the next app start (Preferences -> General -> Gui Pref -> Style Combobox) - added support for FlatCAM usage with High DPI monitors (4k). It is applied on the next app startup after change in Preferences -> General -> Gui Pref -> HDPI Support Checkbox
This commit is contained in:
parent
13dc84809c
commit
bb8dcb37b9
27
FlatCAM.py
27
FlatCAM.py
|
@ -1,7 +1,8 @@
|
||||||
import sys
|
import sys, os
|
||||||
from PyQt5 import sip
|
from PyQt5 import sip
|
||||||
|
|
||||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||||
|
from PyQt5.QtCore import QSettings, Qt
|
||||||
from FlatCAMApp import App
|
from FlatCAMApp import App
|
||||||
from multiprocessing import freeze_support
|
from multiprocessing import freeze_support
|
||||||
import VisPyPatches
|
import VisPyPatches
|
||||||
|
@ -31,7 +32,31 @@ if __name__ == '__main__':
|
||||||
debug_trace()
|
debug_trace()
|
||||||
VisPyPatches.apply_patches()
|
VisPyPatches.apply_patches()
|
||||||
|
|
||||||
|
# apply High DPI support
|
||||||
|
settings = QSettings("Open Source", "FlatCAM")
|
||||||
|
if settings.contains("hdpi"):
|
||||||
|
hdpi_support = settings.value('hdpi', type=int)
|
||||||
|
else:
|
||||||
|
hdpi_support = 0
|
||||||
|
|
||||||
|
if hdpi_support == 2:
|
||||||
|
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
|
||||||
|
else:
|
||||||
|
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "0"
|
||||||
|
|
||||||
app = QtWidgets.QApplication(sys.argv)
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
|
||||||
|
# apply style
|
||||||
|
settings = QSettings("Open Source", "FlatCAM")
|
||||||
|
if settings.contains("style"):
|
||||||
|
style = settings.value('style', type=str)
|
||||||
|
app.setStyle(style)
|
||||||
|
|
||||||
|
if hdpi_support == 2:
|
||||||
|
app.setAttribute(Qt.AA_EnableHighDpiScaling, True)
|
||||||
|
else:
|
||||||
|
app.setAttribute(Qt.AA_EnableHighDpiScaling, False)
|
||||||
|
|
||||||
fc = App()
|
fc = App()
|
||||||
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
165
FlatCAMEditor.py
165
FlatCAMEditor.py
|
@ -1013,17 +1013,20 @@ class TransformEditorTool(FlatCAMTool):
|
||||||
|
|
||||||
self.app.ui.splitter.setSizes([0, 1])
|
self.app.ui.splitter.setSizes([0, 1])
|
||||||
|
|
||||||
def on_rotate(self):
|
def on_rotate(self, sig=None, val=None):
|
||||||
try:
|
if val:
|
||||||
value = float(self.rotate_entry.get_value())
|
value = val
|
||||||
except ValueError:
|
else:
|
||||||
# try to convert comma to decimal point. if it's still not working error message and return
|
|
||||||
try:
|
try:
|
||||||
value = float(self.rotate_entry.get_value().replace(',', '.'))
|
value = float(self.rotate_entry.get_value())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Rotate, "
|
# try to convert comma to decimal point. if it's still not working error message and return
|
||||||
"use a number.")
|
try:
|
||||||
return
|
value = float(self.rotate_entry.get_value().replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Rotate, "
|
||||||
|
"use a number.")
|
||||||
|
return
|
||||||
self.app.worker_task.emit({'fcn': self.on_rotate_action,
|
self.app.worker_task.emit({'fcn': self.on_rotate_action,
|
||||||
'params': [value]})
|
'params': [value]})
|
||||||
# self.on_rotate_action(value)
|
# self.on_rotate_action(value)
|
||||||
|
@ -1044,20 +1047,23 @@ class TransformEditorTool(FlatCAMTool):
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_flip_add_coords(self):
|
def on_flip_add_coords(self):
|
||||||
val = self.app.defaults["global_point_clipboard_format"] % (self.app.pos[0], self.app.pos[1])
|
val = self.app.clipboard.text()
|
||||||
self.flip_ref_entry.set_value(val)
|
self.flip_ref_entry.set_value(val)
|
||||||
|
|
||||||
def on_skewx(self):
|
def on_skewx(self, sig=None, val=None):
|
||||||
try:
|
if val:
|
||||||
value = float(self.skewx_entry.get_value())
|
value = val
|
||||||
except ValueError:
|
else:
|
||||||
# try to convert comma to decimal point. if it's still not working error message and return
|
|
||||||
try:
|
try:
|
||||||
value = float(self.skewx_entry.get_value().replace(',', '.'))
|
value = float(self.skewx_entry.get_value())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Skew X, "
|
# try to convert comma to decimal point. if it's still not working error message and return
|
||||||
"use a number.")
|
try:
|
||||||
return
|
value = float(self.skewx_entry.get_value().replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Skew X, "
|
||||||
|
"use a number.")
|
||||||
|
return
|
||||||
|
|
||||||
# self.on_skew("X", value)
|
# self.on_skew("X", value)
|
||||||
axis = 'X'
|
axis = 'X'
|
||||||
|
@ -1065,17 +1071,20 @@ class TransformEditorTool(FlatCAMTool):
|
||||||
'params': [axis, value]})
|
'params': [axis, value]})
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_skewy(self):
|
def on_skewy(self, sig=None, val=None):
|
||||||
try:
|
if val:
|
||||||
value = float(self.skewy_entry.get_value())
|
value = val
|
||||||
except ValueError:
|
else:
|
||||||
# try to convert comma to decimal point. if it's still not working error message and return
|
|
||||||
try:
|
try:
|
||||||
value = float(self.skewy_entry.get_value().replace(',', '.'))
|
value = float(self.skewy_entry.get_value())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Skew Y, "
|
# try to convert comma to decimal point. if it's still not working error message and return
|
||||||
"use a number.")
|
try:
|
||||||
return
|
value = float(self.skewy_entry.get_value().replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Skew Y, "
|
||||||
|
"use a number.")
|
||||||
|
return
|
||||||
|
|
||||||
# self.on_skew("Y", value)
|
# self.on_skew("Y", value)
|
||||||
axis = 'Y'
|
axis = 'Y'
|
||||||
|
@ -1083,17 +1092,20 @@ class TransformEditorTool(FlatCAMTool):
|
||||||
'params': [axis, value]})
|
'params': [axis, value]})
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_scalex(self):
|
def on_scalex(self, sig=None, val=None):
|
||||||
try:
|
if val:
|
||||||
xvalue = float(self.scalex_entry.get_value())
|
xvalue = val
|
||||||
except ValueError:
|
else:
|
||||||
# try to convert comma to decimal point. if it's still not working error message and return
|
|
||||||
try:
|
try:
|
||||||
xvalue = float(self.scalex_entry.get_value().replace(',', '.'))
|
xvalue = float(self.scalex_entry.get_value())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Scale X, "
|
# try to convert comma to decimal point. if it's still not working error message and return
|
||||||
"use a number.")
|
try:
|
||||||
return
|
xvalue = float(self.scalex_entry.get_value().replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Scale X, "
|
||||||
|
"use a number.")
|
||||||
|
return
|
||||||
|
|
||||||
# scaling to zero has no sense so we remove it, because scaling with 1 does nothing
|
# scaling to zero has no sense so we remove it, because scaling with 1 does nothing
|
||||||
if xvalue == 0:
|
if xvalue == 0:
|
||||||
|
@ -1116,18 +1128,21 @@ class TransformEditorTool(FlatCAMTool):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_scaley(self):
|
def on_scaley(self, sig=None, val=None):
|
||||||
xvalue = 1
|
xvalue = 1
|
||||||
try:
|
if val:
|
||||||
yvalue = float(self.scaley_entry.get_value())
|
yvalue = val
|
||||||
except ValueError:
|
else:
|
||||||
# try to convert comma to decimal point. if it's still not working error message and return
|
|
||||||
try:
|
try:
|
||||||
yvalue = float(self.scaley_entry.get_value().replace(',', '.'))
|
yvalue = float(self.scaley_entry.get_value())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Scale Y, "
|
# try to convert comma to decimal point. if it's still not working error message and return
|
||||||
"use a number.")
|
try:
|
||||||
return
|
yvalue = float(self.scaley_entry.get_value().replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Scale Y, "
|
||||||
|
"use a number.")
|
||||||
|
return
|
||||||
|
|
||||||
# scaling to zero has no sense so we remove it, because scaling with 1 does nothing
|
# scaling to zero has no sense so we remove it, because scaling with 1 does nothing
|
||||||
if yvalue == 0:
|
if yvalue == 0:
|
||||||
|
@ -1146,17 +1161,20 @@ class TransformEditorTool(FlatCAMTool):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_offx(self):
|
def on_offx(self, sig=None, val=None):
|
||||||
try:
|
if val:
|
||||||
value = float(self.offx_entry.get_value())
|
value = val
|
||||||
except ValueError:
|
else:
|
||||||
# try to convert comma to decimal point. if it's still not working error message and return
|
|
||||||
try:
|
try:
|
||||||
value = float(self.offx_entry.get_value().replace(',', '.'))
|
value = float(self.offx_entry.get_value())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Offset X, "
|
# try to convert comma to decimal point. if it's still not working error message and return
|
||||||
"use a number.")
|
try:
|
||||||
return
|
value = float(self.offx_entry.get_value().replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Offset X, "
|
||||||
|
"use a number.")
|
||||||
|
return
|
||||||
|
|
||||||
# self.on_offset("X", value)
|
# self.on_offset("X", value)
|
||||||
axis = 'X'
|
axis = 'X'
|
||||||
|
@ -1164,17 +1182,20 @@ class TransformEditorTool(FlatCAMTool):
|
||||||
'params': [axis, value]})
|
'params': [axis, value]})
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_offy(self):
|
def on_offy(self, sig=None, val=None):
|
||||||
try:
|
if val:
|
||||||
value = float(self.offy_entry.get_value())
|
value = val
|
||||||
except ValueError:
|
else:
|
||||||
# try to convert comma to decimal point. if it's still not working error message and return
|
|
||||||
try:
|
try:
|
||||||
value = float(self.offy_entry.get_value().replace(',', '.'))
|
value = float(self.offy_entry.get_value())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Offset Y, "
|
# try to convert comma to decimal point. if it's still not working error message and return
|
||||||
"use a number.")
|
try:
|
||||||
return
|
value = float(self.offy_entry.get_value().replace(',', '.'))
|
||||||
|
except ValueError:
|
||||||
|
self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered for Offset Y, "
|
||||||
|
"use a number.")
|
||||||
|
return
|
||||||
|
|
||||||
# self.on_offset("Y", value)
|
# self.on_offset("Y", value)
|
||||||
axis = 'Y'
|
axis = 'Y'
|
||||||
|
@ -2582,8 +2603,7 @@ class FCPaint(FCShapeTool):
|
||||||
|
|
||||||
self.start_msg = "Create Paint geometry ..."
|
self.start_msg = "Create Paint geometry ..."
|
||||||
self.origin = (0, 0)
|
self.origin = (0, 0)
|
||||||
self.paint_tool = PaintOptionsTool(self.app, self.draw_app)
|
self.draw_app.paint_tool.run()
|
||||||
self.paint_tool.run()
|
|
||||||
|
|
||||||
|
|
||||||
class FCTransform(FCShapeTool):
|
class FCTransform(FCShapeTool):
|
||||||
|
@ -2597,8 +2617,7 @@ class FCTransform(FCShapeTool):
|
||||||
|
|
||||||
self.start_msg = "Shape transformations ..."
|
self.start_msg = "Shape transformations ..."
|
||||||
self.origin = (0, 0)
|
self.origin = (0, 0)
|
||||||
self.transform_tool = TransformEditorTool(self.app, self.draw_app)
|
self.draw_app.transform_tool.run()
|
||||||
self.transform_tool.run()
|
|
||||||
|
|
||||||
|
|
||||||
class FCRotate(FCShapeTool):
|
class FCRotate(FCShapeTool):
|
||||||
|
@ -3341,6 +3360,9 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
||||||
# if using Paint store here the tool diameter used
|
# if using Paint store here the tool diameter used
|
||||||
self.paint_tooldia = None
|
self.paint_tooldia = None
|
||||||
|
|
||||||
|
self.paint_tool = PaintOptionsTool(self.app, self)
|
||||||
|
self.transform_tool = TransformEditorTool(self.app, self)
|
||||||
|
|
||||||
def pool_recreated(self, pool):
|
def pool_recreated(self, pool):
|
||||||
self.shapes.pool = pool
|
self.shapes.pool = pool
|
||||||
self.tool_shape.pool = pool
|
self.tool_shape.pool = pool
|
||||||
|
@ -3656,6 +3678,13 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
||||||
|
|
||||||
self.pos = (x, y)
|
self.pos = (x, y)
|
||||||
|
|
||||||
|
modifiers = QtWidgets.QApplication.keyboardModifiers()
|
||||||
|
# If the SHIFT key is pressed when LMB is clicked then the coordinates are copied to clipboard
|
||||||
|
if modifiers == QtCore.Qt.ShiftModifier:
|
||||||
|
self.app.clipboard.setText(
|
||||||
|
self.app.defaults["global_point_clipboard_format"] % (self.pos[0], self.pos[1]))
|
||||||
|
return
|
||||||
|
|
||||||
# Selection with left mouse button
|
# Selection with left mouse button
|
||||||
if self.active_tool is not None and event.button is 1:
|
if self.active_tool is not None and event.button is 1:
|
||||||
# Dispatch event to active_tool
|
# Dispatch event to active_tool
|
||||||
|
|
|
@ -2774,10 +2774,11 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||||
self.form_box_child_11.addWidget(self.sel_draw_color_button)
|
self.form_box_child_11.addWidget(self.sel_draw_color_button)
|
||||||
self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||||
|
|
||||||
# Theme selection
|
# Layout selection
|
||||||
self.layout_label = QtWidgets.QLabel('Layout:')
|
self.layout_label = QtWidgets.QLabel('Layout:')
|
||||||
self.alt_sf_color_label.setToolTip(
|
self.layout_label.setToolTip(
|
||||||
"Select an layout for FlatCAM."
|
"Select an layout for FlatCAM.\n"
|
||||||
|
"It is applied immediately."
|
||||||
)
|
)
|
||||||
self.layout_combo = FCComboBox()
|
self.layout_combo = FCComboBox()
|
||||||
self.layout_combo.addItem("Choose ...")
|
self.layout_combo.addItem("Choose ...")
|
||||||
|
@ -2785,11 +2786,37 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||||
self.layout_combo.addItem("Compact")
|
self.layout_combo.addItem("Compact")
|
||||||
self.layout_combo.setCurrentIndex(0)
|
self.layout_combo.setCurrentIndex(0)
|
||||||
|
|
||||||
|
# Style selection
|
||||||
|
self.style_label = QtWidgets.QLabel('Style:')
|
||||||
|
self.style_label.setToolTip(
|
||||||
|
"Select an style for FlatCAM.\n"
|
||||||
|
"It will be applied at the next app start."
|
||||||
|
)
|
||||||
|
self.style_combo = FCComboBox()
|
||||||
|
self.style_combo.addItems(QtWidgets.QStyleFactory.keys())
|
||||||
|
# find current style
|
||||||
|
index = self.style_combo.findText(QtWidgets.qApp.style().objectName(), QtCore.Qt.MatchFixedString)
|
||||||
|
self.style_combo.setCurrentIndex(index)
|
||||||
|
self.style_combo.activated[str].connect(self.handle_style)
|
||||||
|
|
||||||
|
# Enable High DPI Support
|
||||||
|
self.hdpi_label = QtWidgets.QLabel('HDPI Support:')
|
||||||
|
self.hdpi_label.setToolTip(
|
||||||
|
"Enable High DPI support for FlatCAM.\n"
|
||||||
|
"It will be applied at the next app start."
|
||||||
|
)
|
||||||
|
self.hdpi_cb = FCCheckBox()
|
||||||
|
settings = QSettings("Open Source", "FlatCAM")
|
||||||
|
if settings.contains("hdpi"):
|
||||||
|
self.hdpi_cb.set_value(settings.value('hdpi', type=int))
|
||||||
|
else:
|
||||||
|
self.hdpi_cb.set_value(False)
|
||||||
|
self.hdpi_cb.stateChanged.connect(self.handle_hdpi)
|
||||||
|
|
||||||
# Just to add empty rows
|
# Just to add empty rows
|
||||||
self.spacelabel = QtWidgets.QLabel('')
|
self.spacelabel = QtWidgets.QLabel('')
|
||||||
|
|
||||||
# Add (label - input field) pair to the QFormLayout
|
# Add (label - input field) pair to the QFormLayout
|
||||||
|
|
||||||
self.form_box.addRow(self.spacelabel, self.spacelabel)
|
self.form_box.addRow(self.spacelabel, self.spacelabel)
|
||||||
|
|
||||||
self.form_box.addRow(self.gridx_label, self.gridx_entry)
|
self.form_box.addRow(self.gridx_label, self.gridx_entry)
|
||||||
|
@ -2813,10 +2840,29 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||||
|
|
||||||
self.form_box.addRow(self.spacelabel, self.spacelabel)
|
self.form_box.addRow(self.spacelabel, self.spacelabel)
|
||||||
self.form_box.addRow(self.layout_label, self.layout_combo)
|
self.form_box.addRow(self.layout_label, self.layout_combo)
|
||||||
|
self.form_box.addRow(self.style_label, self.style_combo)
|
||||||
|
self.form_box.addRow(self.hdpi_label, self.hdpi_cb)
|
||||||
|
|
||||||
# Add the QFormLayout that holds the Application general defaults
|
# Add the QFormLayout that holds the Application general defaults
|
||||||
# to the main layout of this TAB
|
# to the main layout of this TAB
|
||||||
self.layout.addLayout(self.form_box)
|
self.layout.addLayout(self.form_box)
|
||||||
|
|
||||||
|
def handle_style(self, style):
|
||||||
|
# set current style
|
||||||
|
settings = QSettings("Open Source", "FlatCAM")
|
||||||
|
settings.setValue('style', style)
|
||||||
|
|
||||||
|
# This will write the setting to the platform specific storage.
|
||||||
|
del settings
|
||||||
|
|
||||||
|
def handle_hdpi(self, state):
|
||||||
|
# set current style
|
||||||
|
settings = QSettings("Open Source", "FlatCAM")
|
||||||
|
settings.setValue('hdpi', state)
|
||||||
|
|
||||||
|
# This will write the setting to the platform specific storage.
|
||||||
|
del settings
|
||||||
|
|
||||||
|
|
||||||
class GeneralAppPrefGroupUI(OptionsGroupUI):
|
class GeneralAppPrefGroupUI(OptionsGroupUI):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|
|
@ -18,6 +18,9 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
- added in Geometry Editor a new Tool: Transformation Tool. It still has some bugs, though ...
|
- added in Geometry Editor a new Tool: Transformation Tool. It still has some bugs, though ...
|
||||||
- in Geometry Editor by selecting a shape with a selection shape, that object was added multiple times (one per each selection) to the selected list, which is not intended. Bug fixed.
|
- in Geometry Editor by selecting a shape with a selection shape, that object was added multiple times (one per each selection) to the selected list, which is not intended. Bug fixed.
|
||||||
- finished adding Transform Tool in Geometry Editor - everything is working as intended
|
- finished adding Transform Tool in Geometry Editor - everything is working as intended
|
||||||
|
- fixed a bug in Tool Transform that made the user to not be able to capture the click coordinates with SHIFT + LMB click combo
|
||||||
|
- added the ability to choose an App QStyle out of the offered choices (different for each OS) to be applied at the next app start (Preferences -> General -> Gui Pref -> Style Combobox)
|
||||||
|
- added support for FlatCAM usage with High DPI monitors (4k). It is applied on the next app startup after change in Preferences -> General -> Gui Pref -> HDPI Support Checkbox
|
||||||
|
|
||||||
17.02.2019
|
17.02.2019
|
||||||
|
|
||||||
|
|
|
@ -419,7 +419,7 @@ class ToolTransform(FlatCAMTool):
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_flip_add_coords(self):
|
def on_flip_add_coords(self):
|
||||||
val = self.app.defaults["global_point_clipboard_format"] % (self.app.pos[0], self.app.pos[1])
|
val = self.app.clipboard.text()
|
||||||
self.flip_ref_entry.set_value(val)
|
self.flip_ref_entry.set_value(val)
|
||||||
|
|
||||||
def on_skewx(self):
|
def on_skewx(self):
|
||||||
|
|
Loading…
Reference in New Issue