- working on the Dual Point option in Align Objects Tool - angle has to be recalculated
This commit is contained in:
parent
9a3f3b600b
commit
a8bea7805e
|
@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
|
|||
|
||||
- in Extract Drill Tool added a new method of drills extraction. The methods are: fixed diameter, fixed annular ring and proportional
|
||||
- in Align Objects Tool finished the Single Point method of alignment
|
||||
- working on the Dual Point option in Align Objects Tool - angle has to be recalculated
|
||||
|
||||
13.01.2020
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@ from FlatCAMTool import FlatCAMTool
|
|||
|
||||
from flatcamGUI.GUIElements import FCComboBox, RadioSet
|
||||
|
||||
import math
|
||||
|
||||
from shapely.geometry import Point
|
||||
from shapely.affinity import translate, rotate
|
||||
from shapely.affinity import translate
|
||||
|
||||
import gettext
|
||||
import FlatCAMTranslation as fcTranslate
|
||||
|
@ -68,7 +70,7 @@ class AlignObjects(FlatCAMTool):
|
|||
self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type"))
|
||||
self.type_obj_combo_label.setToolTip(
|
||||
_("Specify the type of object to be aligned.\n"
|
||||
"It can be of type: Gerber, Excellon or Geometry.\n"
|
||||
"It can be of type: Gerber or Excellon.\n"
|
||||
"The selection here decide the type of objects that will be\n"
|
||||
"in the Object combobox.")
|
||||
)
|
||||
|
@ -111,7 +113,7 @@ class AlignObjects(FlatCAMTool):
|
|||
self.type_aligner_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type"))
|
||||
self.type_aligner_obj_combo_label.setToolTip(
|
||||
_("Specify the type of object to be aligned to.\n"
|
||||
"It can be of type: Gerber, Excellon or Geometry.\n"
|
||||
"It can be of type: Gerber or Excellon.\n"
|
||||
"The selection here decide the type of objects that will be\n"
|
||||
"in the Object combobox.")
|
||||
)
|
||||
|
@ -394,8 +396,8 @@ class AlignObjects(FlatCAMTool):
|
|||
self.set_color()
|
||||
|
||||
if len(self.clicked_points) == 2:
|
||||
self.align_translate()
|
||||
if self.align_type == 'sp':
|
||||
self.align_translate()
|
||||
self.app.inform.emit('[success] %s' % _("Done."))
|
||||
self.app.plot_all()
|
||||
|
||||
|
@ -416,6 +418,7 @@ class AlignObjects(FlatCAMTool):
|
|||
self.set_color()
|
||||
|
||||
if len(self.clicked_points) == 4:
|
||||
self.align_translate()
|
||||
self.align_rotate()
|
||||
self.app.inform.emit('[success] %s' % _("Done."))
|
||||
|
||||
|
@ -426,10 +429,6 @@ class AlignObjects(FlatCAMTool):
|
|||
dx = self.clicked_points[1][0] - self.clicked_points[0][0]
|
||||
dy = self.clicked_points[1][1] - self.clicked_points[0][1]
|
||||
|
||||
if self.align_type == 'dp':
|
||||
self.new_start = translate(Point(self.clicked_points[2]), xoff=dx, yoff=dy)
|
||||
self.new_dest = translate(Point(self.clicked_points[3]), xoff=dx, yoff=dy)
|
||||
|
||||
self.aligned_obj.offset((dx, dy))
|
||||
|
||||
# Update the object bounding box options
|
||||
|
@ -440,7 +439,24 @@ class AlignObjects(FlatCAMTool):
|
|||
self.aligned_obj.options['ymax'] = d
|
||||
|
||||
def align_rotate(self):
|
||||
print(self.new_start.x == self.new_dest.x)
|
||||
dx = self.clicked_points[1][0] - self.clicked_points[0][0]
|
||||
dy = self.clicked_points[1][1] - self.clicked_points[0][1]
|
||||
|
||||
new_start_pt = translate(Point(self.clicked_points[2]), xoff=dx, yoff=dy)
|
||||
self.new_start = (new_start_pt.x, new_start_pt.y)
|
||||
self.new_dest = self.clicked_points[3]
|
||||
|
||||
origin_pt = self.clicked_points[1]
|
||||
|
||||
sec_dx = self.new_dest[0] - self.new_start[0]
|
||||
sec_dy = self.new_dest[1] - self.new_start[1]
|
||||
|
||||
rotation_not_needed = (abs(self.new_start[0] - self.new_dest[0]) <= (10 ** -self.decimals)) or \
|
||||
(abs(self.new_start[1] - self.new_dest[1]) <= (10 ** -self.decimals))
|
||||
if rotation_not_needed is False:
|
||||
# calculate rotation angle
|
||||
angle = math.degrees(math.atan(sec_dy / sec_dx))
|
||||
self.aligned_obj.rotate(angle=angle, point=origin_pt)
|
||||
|
||||
def execute(self):
|
||||
aligned_name = self.object_combo.currentText()
|
||||
|
|
|
@ -641,7 +641,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
|||
}
|
||||
|
||||
# #############################################################################
|
||||
# ############################ SGINALS ########################################
|
||||
# ############################ SIGNALS ########################################
|
||||
# #############################################################################
|
||||
self.addtool_btn.clicked.connect(self.on_tool_add)
|
||||
self.addtool_entry.returnPressed.connect(self.on_tool_add)
|
||||
|
|
Loading…
Reference in New Issue