- modified the pull request to include along the flipX, flipY commands
also the Rotate, SkewX and SkewY commands. Fix for issue #235 All perform the same in regard of multiple object selection.
This commit is contained in:
126
FlatCAMApp.py
126
FlatCAMApp.py
@@ -35,6 +35,7 @@ from FlatCAMCommon import LoudDict
|
||||
from FlatCAMShell import FCShell
|
||||
from FlatCAMDraw import FlatCAMDraw
|
||||
from FlatCAMProcess import *
|
||||
from GUIElements import FCInputDialog
|
||||
from MeasurementTool import Measurement
|
||||
from DblSidedTool import DblSidedTool
|
||||
import tclCommands
|
||||
@@ -538,6 +539,9 @@ class App(QtCore.QObject):
|
||||
self.ui.menuoptions_transfer_p2o.triggered.connect(self.on_options_project2object)
|
||||
self.ui.menuoptions_transform_flipx.triggered.connect(self.on_flipx)
|
||||
self.ui.menuoptions_transform_flipy.triggered.connect(self.on_flipy)
|
||||
self.ui.menuoptions_transform_skewx.triggered.connect(self.on_skewx)
|
||||
self.ui.menuoptions_transform_skewy.triggered.connect(self.on_skewy)
|
||||
self.ui.menuoptions_transform_rotate.triggered.connect(self.on_rotate)
|
||||
self.ui.menuviewdisableall.triggered.connect(self.disable_plots)
|
||||
self.ui.menuviewdisableother.triggered.connect(lambda: self.disable_plots(except_current=True))
|
||||
self.ui.menuviewenable.triggered.connect(self.enable_all_plots)
|
||||
@@ -1501,7 +1505,7 @@ class App(QtCore.QObject):
|
||||
warningbox.setText(msg)
|
||||
warningbox.setWindowTitle("Warning ...")
|
||||
warningbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
|
||||
warningbox.setStandardButtons(QtGUi.QMessageBox.Ok)
|
||||
warningbox.setStandardButtons(QtGui.QMessageBox.Ok)
|
||||
warningbox.setDefaultButton(QtGui.QMessageBox.Ok)
|
||||
warningbox.exec_()
|
||||
else:
|
||||
@@ -1569,6 +1573,126 @@ class App(QtCore.QObject):
|
||||
obj.plot()
|
||||
self.inform.emit('Flipped on the Y axis ...')
|
||||
|
||||
def on_rotate(self, preset=None):
|
||||
obj_list = self.collection.get_selected()
|
||||
xminlist = []
|
||||
yminlist = []
|
||||
xmaxlist = []
|
||||
ymaxlist = []
|
||||
|
||||
if not obj_list:
|
||||
self.inform.emit("WARNING: No object selected.")
|
||||
msg = "Please Select an object to rotate!"
|
||||
warningbox = QtGui.QMessageBox()
|
||||
warningbox.setText(msg)
|
||||
warningbox.setWindowTitle("Warning ...")
|
||||
warningbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
|
||||
warningbox.setStandardButtons(QtGui.QMessageBox.Ok)
|
||||
warningbox.setDefaultButton(QtGui.QMessageBox.Ok)
|
||||
warningbox.exec_()
|
||||
else:
|
||||
if preset is not None:
|
||||
rotatebox = FCInputDialog()
|
||||
num, ok = rotatebox.get_value(title='Transform', message='Enter the Angle value',
|
||||
min=-360, max=360, decimals=3)
|
||||
else:
|
||||
num = preset
|
||||
ok = True
|
||||
|
||||
if ok:
|
||||
for sel_obj in obj_list:
|
||||
# first get a bounding box to fit all
|
||||
for obj in obj_list:
|
||||
xmin, ymin, xmax, ymax = obj.bounds()
|
||||
xminlist.append(xmin)
|
||||
yminlist.append(ymin)
|
||||
xmaxlist.append(xmax)
|
||||
ymaxlist.append(ymax)
|
||||
|
||||
# get the minimum x,y and maximum x,y for all objects selected
|
||||
xminimal = min(xminlist)
|
||||
yminimal = min(yminlist)
|
||||
xmaximal = max(xmaxlist)
|
||||
ymaximal = max(ymaxlist)
|
||||
|
||||
px = 0.5 * (xminimal + xmaximal)
|
||||
py = 0.5 * (yminimal + ymaximal)
|
||||
|
||||
sel_obj.rotate(-num, point=(px, py))
|
||||
sel_obj.plot()
|
||||
self.inform.emit('Object was rotated ...')
|
||||
|
||||
def on_skewx(self):
|
||||
obj_list = self.collection.get_selected()
|
||||
xminlist = []
|
||||
yminlist = []
|
||||
|
||||
if not obj_list:
|
||||
self.inform.emit("WARNING: No object selected.")
|
||||
msg = "Please Select an object to skew/shear!"
|
||||
warningbox = QtGui.QMessageBox()
|
||||
warningbox.setText(msg)
|
||||
warningbox.setWindowTitle("Warning ...")
|
||||
warningbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
|
||||
warningbox.setStandardButtons(QtGui.QMessageBox.Ok)
|
||||
warningbox.setDefaultButton(QtGui.QMessageBox.Ok)
|
||||
warningbox.exec_()
|
||||
else:
|
||||
skewxbox = FCInputDialog()
|
||||
num, ok = skewxbox.get_value(title='Transform', message='Enter the Angle value',
|
||||
min=-360, max=360, decimals=3)
|
||||
if ok:
|
||||
# first get a bounding box to fit all
|
||||
for obj in obj_list:
|
||||
xmin, ymin, xmax, ymax = obj.bounds()
|
||||
xminlist.append(xmin)
|
||||
yminlist.append(ymin)
|
||||
|
||||
# get the minimum x,y and maximum x,y for all objects selected
|
||||
xminimal = min(xminlist)
|
||||
yminimal = min(yminlist)
|
||||
|
||||
for obj in obj_list:
|
||||
obj.skew(num, 0, point=(xminimal, yminimal))
|
||||
obj.plot()
|
||||
self.inform.emit('Object was skewed on X axis ...')
|
||||
|
||||
def on_skewy(self):
|
||||
obj_list = self.collection.get_selected()
|
||||
xminlist = []
|
||||
yminlist = []
|
||||
|
||||
|
||||
if not obj_list:
|
||||
self.inform.emit("WARNING: No object selected.")
|
||||
msg = "Please Select an object to skew/shear!"
|
||||
warningbox = QtGui.QMessageBox()
|
||||
warningbox.setText(msg)
|
||||
warningbox.setWindowTitle("Warning ...")
|
||||
warningbox.setWindowIcon(QtGui.QIcon('share/warning.png'))
|
||||
warningbox.setStandardButtons(QtGui.QMessageBox.Ok)
|
||||
warningbox.setDefaultButton(QtGui.QMessageBox.Ok)
|
||||
warningbox.exec_()
|
||||
else:
|
||||
skewybox = FCInputDialog()
|
||||
num, ok = skewybox.get_value(title='Transform', message='Enter the Angle value',
|
||||
min=-360, max=360, decimals=3)
|
||||
if ok:
|
||||
# first get a bounding box to fit all
|
||||
for obj in obj_list:
|
||||
xmin, ymin, xmax, ymax = obj.bounds()
|
||||
xminlist.append(xmin)
|
||||
yminlist.append(ymin)
|
||||
|
||||
# get the minimum x,y and maximum x,y for all objects selected
|
||||
xminimal = min(xminlist)
|
||||
yminimal = min(yminlist)
|
||||
|
||||
for obj in obj_list:
|
||||
obj.skew(0, num, point=(xminimal, yminimal))
|
||||
obj.plot()
|
||||
self.inform.emit('Object was skewed on Y axis ...')
|
||||
|
||||
def on_delete(self):
|
||||
"""
|
||||
Delete the currently selected FlatCAMObjs.
|
||||
|
||||
Reference in New Issue
Block a user