- fixed the PDF import tool to work with files generated by the Microsoft PDF printer (chained subpaths)
- in PDF import tool added support for paths filled and at the same time stroked ('B' and 'B*'commands)
- added a shortcut key for PDF Import Tool (ALT+Q) and updated the Shortcut list (also with the 'T' and 'R' keys for Gerber Editor where they control the bend in Track and Region tool and the 'M' and 'D' keys for Add Arc tool in Geometry Editor)
This commit is contained in:
@@ -95,7 +95,7 @@ class App(QtCore.QObject):
|
|||||||
|
|
||||||
# Version
|
# Version
|
||||||
version = 8.914
|
version = 8.914
|
||||||
version_date = "2019/04/20"
|
version_date = "2019/04/22"
|
||||||
beta = True
|
beta = True
|
||||||
|
|
||||||
# current date now
|
# current date now
|
||||||
@@ -2003,15 +2003,16 @@ class App(QtCore.QObject):
|
|||||||
self.properties_tool = Properties(self)
|
self.properties_tool = Properties(self)
|
||||||
self.properties_tool.install(icon=QtGui.QIcon('share/properties32.png'), pos=self.ui.menuoptions)
|
self.properties_tool.install(icon=QtGui.QIcon('share/properties32.png'), pos=self.ui.menuoptions)
|
||||||
|
|
||||||
|
self.pdf_tool = ToolPDF(self)
|
||||||
|
self.pdf_tool.install(icon=QtGui.QIcon('share/pdf32.png'), pos=self.ui.menufileimport,
|
||||||
|
separator=True)
|
||||||
|
|
||||||
self.image_tool = ToolImage(self)
|
self.image_tool = ToolImage(self)
|
||||||
self.image_tool.install(icon=QtGui.QIcon('share/image32.png'), pos=self.ui.menufileimport,
|
self.image_tool.install(icon=QtGui.QIcon('share/image32.png'), pos=self.ui.menufileimport,
|
||||||
separator=True)
|
separator=True)
|
||||||
self.pcb_wizard_tool = PcbWizard(self)
|
self.pcb_wizard_tool = PcbWizard(self)
|
||||||
self.pcb_wizard_tool.install(icon=QtGui.QIcon('share/drill32.png'), pos=self.ui.menufileimport)
|
self.pcb_wizard_tool.install(icon=QtGui.QIcon('share/drill32.png'), pos=self.ui.menufileimport)
|
||||||
|
|
||||||
self.pdf_tool = ToolPDF(self)
|
|
||||||
self.pdf_tool.install(icon=QtGui.QIcon('share/pdf32.png'), pos=self.ui.menufileimport)
|
|
||||||
|
|
||||||
self.log.debug("Tools are installed.")
|
self.log.debug("Tools are installed.")
|
||||||
|
|
||||||
def remove_tools(self):
|
def remove_tools(self):
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
21.04.2019
|
||||||
|
|
||||||
|
- fixed the PDF import tool to work with files generated by the Microsoft PDF printer (chained subpaths)
|
||||||
|
- in PDF import tool added support for paths filled and at the same time stroked ('B' and 'B*'commands)
|
||||||
|
- added a shortcut key for PDF Import Tool (ALT+Q) and updated the Shortcut list (also with the 'T' and 'R' keys for Gerber Editor where they control the bend in Track and Region tool and the 'M' and 'D' keys for Add Arc tool in Geometry Editor)
|
||||||
|
|
||||||
20.04.2019
|
20.04.2019
|
||||||
|
|
||||||
- finished adding the PDF import tool although it does not support all kinds of outputs from PDF printers. Microsoft PDF printer is not supported.
|
- finished adding the PDF import tool although it does not support all kinds of outputs from PDF printers. Microsoft PDF printer is not supported.
|
||||||
|
|||||||
@@ -1146,6 +1146,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|||||||
<td height="20"><strong>ALT+P</strong></td>
|
<td height="20"><strong>ALT+P</strong></td>
|
||||||
<td> Paint Area Tool</td>
|
<td> Paint Area Tool</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr height="20">
|
||||||
|
<td height="20"><strong>ALT+Q</strong></td>
|
||||||
|
<td> PDF Import Tool</td>
|
||||||
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
<td height="20"><strong>ALT+R</strong></td>
|
<td height="20"><strong>ALT+R</strong></td>
|
||||||
<td> Transformations Tool</td>
|
<td> Transformations Tool</td>
|
||||||
@@ -1238,6 +1242,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|||||||
<td height="20"><strong>C</strong></td>
|
<td height="20"><strong>C</strong></td>
|
||||||
<td> Copy Geo Item</td>
|
<td> Copy Geo Item</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr height="20">
|
||||||
|
<td height="20"><strong>D</strong></td>
|
||||||
|
<td> Within Add Arc will toogle the ARC direction: CW or CCW</td>
|
||||||
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
<td height="20"><strong>E</strong></td>
|
<td height="20"><strong>E</strong></td>
|
||||||
<td> Polygon Intersection Tool</td>
|
<td> Polygon Intersection Tool</td>
|
||||||
@@ -1258,6 +1266,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|||||||
<td height="20"><strong>M</strong></td>
|
<td height="20"><strong>M</strong></td>
|
||||||
<td> Move Geo Item</td>
|
<td> Move Geo Item</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr height="20">
|
||||||
|
<td height="20"><strong>M</strong></td>
|
||||||
|
<td> Within Add Arc will cycle through the ARC modes</td>
|
||||||
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
<td height="20"><strong>N</strong></td>
|
<td height="20"><strong>N</strong></td>
|
||||||
<td> Draw a Polygon</td>
|
<td> Draw a Polygon</td>
|
||||||
@@ -1452,6 +1464,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|||||||
<td height="20"><strong>P</strong></td>
|
<td height="20"><strong>P</strong></td>
|
||||||
<td> Add Pad</td>
|
<td> Add Pad</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr height="20">
|
||||||
|
<td height="20"><strong>R</strong></td>
|
||||||
|
<td> Within Track & Region Tools will cycle in REVERSE the bend modes</td>
|
||||||
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
<td height="20"><strong>S</strong></td>
|
<td height="20"><strong>S</strong></td>
|
||||||
<td> Scale</td>
|
<td> Scale</td>
|
||||||
@@ -1460,6 +1476,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|||||||
<td height="20"><strong>T</strong></td>
|
<td height="20"><strong>T</strong></td>
|
||||||
<td> Add Track</td>
|
<td> Add Track</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr height="20">
|
||||||
|
<td height="20"><strong>R</strong></td>
|
||||||
|
<td> Within Track & Region Tools will cycle FORWARD the bend modes</td>
|
||||||
|
</tr>
|
||||||
<tr height="20">
|
<tr height="20">
|
||||||
<td height="20"> </td>
|
<td height="20"> </td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
@@ -2087,6 +2107,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|||||||
self.app.paint_tool.run(toggle=True)
|
self.app.paint_tool.run(toggle=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Paint Tool
|
||||||
|
if key == QtCore.Qt.Key_Q:
|
||||||
|
self.app.pdf_tool.run()
|
||||||
|
return
|
||||||
|
|
||||||
# Transformation Tool
|
# Transformation Tool
|
||||||
if key == QtCore.Qt.Key_R:
|
if key == QtCore.Qt.Key_R:
|
||||||
self.app.transform_tool.run(toggle=True)
|
self.app.transform_tool.run(toggle=True)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class ToolPDF(FlatCAMTool):
|
|||||||
# detect 'w' command
|
# detect 'w' command
|
||||||
self.strokewidth_re = re.compile(r'^(\d+\.?\d*)\s*w$')
|
self.strokewidth_re = re.compile(r'^(\d+\.?\d*)\s*w$')
|
||||||
# detect 'S' command
|
# detect 'S' command
|
||||||
self.stroke_path__re = re.compile(r'^S$')
|
self.stroke_path__re = re.compile(r'^S\s?[Q]?$')
|
||||||
# detect 's' command
|
# detect 's' command
|
||||||
self.close_stroke_path__re = re.compile(r'^s$')
|
self.close_stroke_path__re = re.compile(r'^s$')
|
||||||
# detect 'f' or 'f*' command
|
# detect 'f' or 'f*' command
|
||||||
@@ -152,7 +152,7 @@ class ToolPDF(FlatCAMTool):
|
|||||||
stream_nr = 0
|
stream_nr = 0
|
||||||
for s in re.findall(self.stream_re, pdf):
|
for s in re.findall(self.stream_re, pdf):
|
||||||
stream_nr += 1
|
stream_nr += 1
|
||||||
print("STREAM:", stream_nr, '\n', '\n')
|
log.debug(" PDF STREAM: %d\n" % stream_nr)
|
||||||
s = s.strip(b'\r\n')
|
s = s.strip(b'\r\n')
|
||||||
try:
|
try:
|
||||||
self.pdf_parsed += (zlib.decompress(s).decode('UTF-8') + '\r\n')
|
self.pdf_parsed += (zlib.decompress(s).decode('UTF-8') + '\r\n')
|
||||||
@@ -189,27 +189,41 @@ class ToolPDF(FlatCAMTool):
|
|||||||
|
|
||||||
def parse_pdf(self, pdf_content):
|
def parse_pdf(self, pdf_content):
|
||||||
path = dict()
|
path = dict()
|
||||||
path['lines'] = [] # it's a list of points
|
path['lines'] = [] # it's a list of lines subpaths
|
||||||
path['bezier'] = [] # it's a list of sublists each like this [start, c1, c2, stop]
|
path['bezier'] = [] # it's a list of bezier arcs subpaths
|
||||||
path['rectangle'] = [] # it's a list of sublists of points
|
path['rectangle'] = [] # it's a list of rectangle subpaths
|
||||||
|
|
||||||
|
subpath = dict()
|
||||||
|
subpath['lines'] = [] # it's a list of points
|
||||||
|
subpath['bezier'] = [] # it's a list of sublists each like this [start, c1, c2, stop]
|
||||||
|
subpath['rectangle'] = [] # it's a list of sublists of points
|
||||||
|
|
||||||
|
# store the start point (when 'm' command is encountered)
|
||||||
|
current_subpath = None
|
||||||
|
|
||||||
|
# set True when 'h' command is encountered (close path)
|
||||||
|
close_path = False
|
||||||
|
|
||||||
start_point = None
|
start_point = None
|
||||||
current_point = None
|
current_point = None
|
||||||
size = None
|
size = 0
|
||||||
|
|
||||||
# signal that we have encountered a close path command
|
|
||||||
flag_close_path = False
|
|
||||||
|
|
||||||
# initial values for the transformations, in case they are not encountered in the PDF file
|
# initial values for the transformations, in case they are not encountered in the PDF file
|
||||||
offset_geo = [0, 0]
|
offset_geo = [0, 0]
|
||||||
scale_geo = [1, 1]
|
scale_geo = [1, 1]
|
||||||
|
|
||||||
|
c_offset_f= [0, 0]
|
||||||
|
c_scale_f = [1, 1]
|
||||||
|
|
||||||
# initial aperture
|
# initial aperture
|
||||||
aperture = 10
|
aperture = 10
|
||||||
|
|
||||||
# store the apertures here
|
# store the apertures here
|
||||||
apertures_dict = {}
|
apertures_dict = {}
|
||||||
|
|
||||||
|
# it seems that first transform apply to the whole PDF; signal here if it's first
|
||||||
|
first_transform = True
|
||||||
|
|
||||||
line_nr = 0
|
line_nr = 0
|
||||||
lines = pdf_content.splitlines()
|
lines = pdf_content.splitlines()
|
||||||
|
|
||||||
@@ -219,56 +233,50 @@ class ToolPDF(FlatCAMTool):
|
|||||||
|
|
||||||
# TRANSFORMATIONS DETECTION #
|
# TRANSFORMATIONS DETECTION #
|
||||||
|
|
||||||
# Detect Scale transform
|
# # Detect Scale transform
|
||||||
match = self.scale_re.search(pline)
|
# match = self.scale_re.search(pline)
|
||||||
if match:
|
# if match:
|
||||||
log.debug(
|
# log.debug(
|
||||||
"ToolPDF.parse_pdf() --> SCALE transformation found on line: %s --> %s" % (line_nr, pline))
|
# "ToolPDF.parse_pdf() --> SCALE transformation found on line: %s --> %s" % (line_nr, pline))
|
||||||
scale_geo = [float(match.group(1)), float(match.group(2))]
|
# if first_transform:
|
||||||
continue
|
# first_transform = False
|
||||||
|
# c_scale_f = [float(match.group(1)), float(match.group(2))]
|
||||||
|
# else:
|
||||||
|
# scale_geo = [float(match.group(1)), float(match.group(2))]
|
||||||
|
# continue
|
||||||
|
|
||||||
# Detect Offset transform
|
# # Detect Offset transform
|
||||||
match = self.offset_re.search(pline)
|
# match = self.offset_re.search(pline)
|
||||||
if match:
|
# if match:
|
||||||
log.debug(
|
# log.debug(
|
||||||
"ToolPDF.parse_pdf() --> OFFSET transformation found on line: %s --> %s" % (line_nr, pline))
|
# "ToolPDF.parse_pdf() --> OFFSET transformation found on line: %s --> %s" % (line_nr, pline))
|
||||||
offset_geo = [float(match.group(1)), float(match.group(2))]
|
# offset_geo = [float(match.group(1)), float(match.group(2))]
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
# Detect combined transformation. Must be always the last from transformations to be checked.
|
# Detect combined transformation. Must be always the last from transformations to be checked.
|
||||||
# TODO: Perhaps it can replace the others transformation detections
|
|
||||||
match = self.combined_transform_re.search(pline)
|
match = self.combined_transform_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
# transformation = TRANSLATION (OFFSET)
|
# transformation = TRANSLATION (OFFSET)
|
||||||
if float(match.group(1)) == 1 and float(match.group(2)) == 0 and \
|
if (float(match.group(2)) == 0 and float(match.group(3)) == 0) and \
|
||||||
float(match.group(3)) == 0 and float(match.group(4)) == 1:
|
(float(match.group(5)) != 0 or float(match.group(6)) != 0):
|
||||||
pass
|
log.debug(
|
||||||
|
"ToolPDF.parse_pdf() --> OFFSET transformation found on line: %s --> %s" % (line_nr, pline))
|
||||||
|
if first_transform:
|
||||||
|
c_offset_f = [float(match.group(5)), float(match.group(6))]
|
||||||
|
else:
|
||||||
|
offset_geo = [float(match.group(5)), float(match.group(6))]
|
||||||
|
|
||||||
# transformation = SCALING
|
# transformation = SCALING
|
||||||
elif float(match.group(2)) == 0 and float(match.group(3)) == 0 and \
|
if float(match.group(1)) != 1 and float(match.group(4)) != 1:
|
||||||
float(match.group(5)) == 0 and float(match.group(6)) == 0:
|
log.debug(
|
||||||
pass
|
"ToolPDF.parse_pdf() --> SCALE transformation found on line: %s --> %s" % (line_nr, pline))
|
||||||
|
if first_transform:
|
||||||
|
c_scale_f = [float(match.group(1)), float(match.group(4))]
|
||||||
|
else:
|
||||||
|
scale_geo = [float(match.group(1)), float(match.group(4))]
|
||||||
|
|
||||||
# transformation = ROTATION
|
if first_transform:
|
||||||
elif float(match.group(1)) == float(match.group(4)) and \
|
first_transform = False
|
||||||
float(match.group(2)) == - float(match.group(3)) and \
|
|
||||||
float(match.group(5)) == 0 and float(match.group(6)) == 0:
|
|
||||||
# rot_angle = math.acos(float(match.group(1)))
|
|
||||||
pass
|
|
||||||
|
|
||||||
# transformation = SKEW
|
|
||||||
elif float(match.group(1)) == 1 and float(match.group(4)) == 1 and \
|
|
||||||
float(match.group(5)) == 0 and float(match.group(6)) == 0:
|
|
||||||
# skew_x = math.atan(float(match.group(2)))
|
|
||||||
# skew_y = math.atan(float(match.group(3)))
|
|
||||||
pass
|
|
||||||
|
|
||||||
# transformation combined
|
|
||||||
else:
|
|
||||||
log.debug("ToolPDF.parse_pdf() --> COMBINED transformation found on line: %s --> %s" %
|
|
||||||
(line_nr, pline))
|
|
||||||
scale_geo = [float(match.group(1)), float(match.group(4))]
|
|
||||||
offset_geo = [float(match.group(5)), float(match.group(6))]
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# PATH CONSTRUCTION #
|
# PATH CONSTRUCTION #
|
||||||
@@ -276,53 +284,77 @@ class ToolPDF(FlatCAMTool):
|
|||||||
# Start SUBPATH
|
# Start SUBPATH
|
||||||
match = self.start_subpath_re.search(pline)
|
match = self.start_subpath_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
|
# we just started a subpath so we mark it as not closed yet
|
||||||
|
close_path = False
|
||||||
|
|
||||||
|
# init subpaths
|
||||||
|
subpath['lines'] = []
|
||||||
|
subpath['bezier'] = []
|
||||||
|
subpath['rectangle'] = []
|
||||||
|
|
||||||
|
# detect start point to move to
|
||||||
x = float(match.group(1)) + offset_geo[0]
|
x = float(match.group(1)) + offset_geo[0]
|
||||||
y = float(match.group(2)) + offset_geo[1]
|
y = float(match.group(2)) + offset_geo[1]
|
||||||
pt = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
pt = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
start_point = pt
|
start_point = pt
|
||||||
current_point = pt
|
|
||||||
|
# add the start point to subpaths
|
||||||
|
subpath['lines'].append(start_point)
|
||||||
|
# subpath['bezier'].append(start_point)
|
||||||
|
subpath['rectangle'].append(start_point)
|
||||||
|
current_point = start_point
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Draw Line
|
# Draw Line
|
||||||
match = self.draw_line_re.search(pline)
|
match = self.draw_line_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
|
current_subpath = 'lines'
|
||||||
x = float(match.group(1)) + offset_geo[0]
|
x = float(match.group(1)) + offset_geo[0]
|
||||||
y = float(match.group(2)) + offset_geo[1]
|
y = float(match.group(2)) + offset_geo[1]
|
||||||
pt = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
pt = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
path['lines'].append(pt)
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
|
subpath['lines'].append(pt)
|
||||||
current_point = pt
|
current_point = pt
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Draw Bezier 'c'
|
# Draw Bezier 'c'
|
||||||
match = self.draw_arc_3pt_re.search(pline)
|
match = self.draw_arc_3pt_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
|
current_subpath = 'bezier'
|
||||||
start = current_point
|
start = current_point
|
||||||
x = float(match.group(1)) + offset_geo[0]
|
x = float(match.group(1)) + offset_geo[0]
|
||||||
y = float(match.group(2)) + offset_geo[1]
|
y = float(match.group(2)) + offset_geo[1]
|
||||||
c1 = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
c1 = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
x = float(match.group(3)) + offset_geo[0]
|
x = float(match.group(3)) + offset_geo[0]
|
||||||
y = float(match.group(4)) + offset_geo[1]
|
y = float(match.group(4)) + offset_geo[1]
|
||||||
c2 = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
c2 = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
x = float(match.group(5)) + offset_geo[0]
|
x = float(match.group(5)) + offset_geo[0]
|
||||||
y = float(match.group(6)) + offset_geo[1]
|
y = float(match.group(6)) + offset_geo[1]
|
||||||
stop = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
stop = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
|
|
||||||
path['bezier'].append([start, c1, c2, stop])
|
subpath['bezier'].append([start, c1, c2, stop])
|
||||||
current_point = stop
|
current_point = stop
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Draw Bezier 'v'
|
# Draw Bezier 'v'
|
||||||
match = self.draw_arc_2pt_c1start_re.search(pline)
|
match = self.draw_arc_2pt_c1start_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
|
current_subpath = 'bezier'
|
||||||
start = current_point
|
start = current_point
|
||||||
x = float(match.group(1)) + offset_geo[0]
|
x = float(match.group(1)) + offset_geo[0]
|
||||||
y = float(match.group(2)) + offset_geo[1]
|
y = float(match.group(2)) + offset_geo[1]
|
||||||
c2 = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
c2 = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
x = float(match.group(3)) + offset_geo[0]
|
x = float(match.group(3)) + offset_geo[0]
|
||||||
y = float(match.group(4)) + offset_geo[1]
|
y = float(match.group(4)) + offset_geo[1]
|
||||||
stop = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
stop = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
|
|
||||||
path['bezier'].append([start, start, c2, stop])
|
subpath['bezier'].append([start, start, c2, stop])
|
||||||
current_point = stop
|
current_point = stop
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -332,33 +364,34 @@ class ToolPDF(FlatCAMTool):
|
|||||||
start = current_point
|
start = current_point
|
||||||
x = float(match.group(1)) + offset_geo[0]
|
x = float(match.group(1)) + offset_geo[0]
|
||||||
y = float(match.group(2)) + offset_geo[1]
|
y = float(match.group(2)) + offset_geo[1]
|
||||||
c1 = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
c1 = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
x = float(match.group(3)) + offset_geo[0]
|
x = float(match.group(3)) + offset_geo[0]
|
||||||
y = float(match.group(4)) + offset_geo[1]
|
y = float(match.group(4)) + offset_geo[1]
|
||||||
stop = (x * self.point_to_unit_factor * scale_geo[0], y * self.point_to_unit_factor * scale_geo[1])
|
stop = (x * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0],
|
||||||
|
y * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1])
|
||||||
|
|
||||||
path['bezier'].append([start, c1, stop, stop])
|
subpath['bezier'].append([start, c1, stop, stop])
|
||||||
|
print(subpath['bezier'])
|
||||||
current_point = stop
|
current_point = stop
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Close SUBPATH
|
|
||||||
match = self.end_subpath_re.search(pline)
|
|
||||||
if match:
|
|
||||||
flag_close_path = True
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Draw RECTANGLE
|
# Draw RECTANGLE
|
||||||
match = self.rect_re.search(pline)
|
match = self.rect_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
x = (float(match.group(1)) + offset_geo[0]) * self.point_to_unit_factor * scale_geo[0]
|
current_subpath = 'rectangle'
|
||||||
y = (float(match.group(2)) + offset_geo[1]) * self.point_to_unit_factor * scale_geo[1]
|
x = (float(match.group(1)) + offset_geo[0]) * self.point_to_unit_factor * scale_geo[0] * c_scale_f[0]
|
||||||
width = (float(match.group(3)) + offset_geo[0]) * self.point_to_unit_factor * scale_geo[0]
|
y = (float(match.group(2)) + offset_geo[1]) * self.point_to_unit_factor * scale_geo[1] * c_scale_f[1]
|
||||||
height = (float(match.group(4)) + offset_geo[1]) * self.point_to_unit_factor * scale_geo[1]
|
width = (float(match.group(3)) + offset_geo[0]) * \
|
||||||
|
self.point_to_unit_factor * scale_geo[0] * c_scale_f[0]
|
||||||
|
height = (float(match.group(4)) + offset_geo[1]) * \
|
||||||
|
self.point_to_unit_factor * scale_geo[1] * c_scale_f[1]
|
||||||
pt1 = (x, y)
|
pt1 = (x, y)
|
||||||
pt2 = (x+width, y)
|
pt2 = (x+width, y)
|
||||||
pt3 = (x+width, y+height)
|
pt3 = (x+width, y+height)
|
||||||
pt4 = (x, y+height)
|
pt4 = (x, y+height)
|
||||||
path['rectangle'] += [pt1, pt2, pt3, pt4, pt1]
|
# TODO: I'm not sure if rectangles are a subpath in themselves that autoclose
|
||||||
|
subpath['rectangle'] += [pt1, pt2, pt3, pt4, pt1]
|
||||||
current_point = pt1
|
current_point = pt1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -366,9 +399,38 @@ class ToolPDF(FlatCAMTool):
|
|||||||
# ignore this and delete the current subpath
|
# ignore this and delete the current subpath
|
||||||
match = self.clip_path_re.search(pline)
|
match = self.clip_path_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
path['lines'] = []
|
subpath['lines'] = []
|
||||||
path['bezier'] = []
|
subpath['bezier'] = []
|
||||||
path['rectangle'] = []
|
subpath['rectangle'] = []
|
||||||
|
# it measns that we've already added the subpath to path and we need to delete it
|
||||||
|
# clipping path is usually either rectangle or lines
|
||||||
|
if close_path is True:
|
||||||
|
close_path = False
|
||||||
|
if current_subpath == 'lines':
|
||||||
|
path['lines'].pop(-1)
|
||||||
|
if current_subpath == 'rectangle':
|
||||||
|
path['rectangle'].pop(-1)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Close SUBPATH
|
||||||
|
match = self.end_subpath_re.search(pline)
|
||||||
|
if match:
|
||||||
|
close_path = True
|
||||||
|
if current_subpath == 'lines':
|
||||||
|
subpath['lines'].append(start_point)
|
||||||
|
# since we are closing the subpath add it to the path, a path may have chained subpaths
|
||||||
|
path['lines'].append(copy(subpath['lines']))
|
||||||
|
subpath['lines'] = []
|
||||||
|
elif current_subpath == 'bezier':
|
||||||
|
# subpath['bezier'].append(start_point)
|
||||||
|
# since we are closing the subpath add it to the path, a path may have chained subpaths
|
||||||
|
path['bezier'].append(copy(subpath['bezier']))
|
||||||
|
subpath['bezier'] = []
|
||||||
|
elif current_subpath == 'rectangle':
|
||||||
|
subpath['rectangle'].append(start_point)
|
||||||
|
# since we are closing the subpath add it to the path, a path may have chained subpaths
|
||||||
|
path['rectangle'].append(copy(subpath['rectangle']))
|
||||||
|
subpath['rectangle'] = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# PATH PAINTING #
|
# PATH PAINTING #
|
||||||
@@ -376,128 +438,303 @@ class ToolPDF(FlatCAMTool):
|
|||||||
# Detect Stroke width / aperture
|
# Detect Stroke width / aperture
|
||||||
match = self.strokewidth_re.search(pline)
|
match = self.strokewidth_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
size = float(match.group(1)) * self.point_to_unit_factor * scale_geo[0]
|
size = float(match.group(1))
|
||||||
flag = 0
|
# flag = 0
|
||||||
|
#
|
||||||
if not apertures_dict:
|
# if not apertures_dict:
|
||||||
apertures_dict[str(aperture)] = dict()
|
# apertures_dict[str(aperture)] = dict()
|
||||||
apertures_dict[str(aperture)]['size'] = size
|
# apertures_dict[str(aperture)]['size'] = size
|
||||||
apertures_dict[str(aperture)]['type'] = 'C'
|
# apertures_dict[str(aperture)]['type'] = 'C'
|
||||||
apertures_dict[str(aperture)]['solid_geometry'] = []
|
# apertures_dict[str(aperture)]['solid_geometry'] = []
|
||||||
else:
|
# else:
|
||||||
for k in apertures_dict:
|
# for k in apertures_dict:
|
||||||
if size == apertures_dict[k]['size']:
|
# if size == apertures_dict[k]['size']:
|
||||||
flag = 1
|
# flag = 1
|
||||||
break
|
# break
|
||||||
if flag == 0:
|
# if flag == 0:
|
||||||
aperture += 1
|
# aperture += 1
|
||||||
apertures_dict[str(aperture)] = dict()
|
# apertures_dict[str(aperture)] = dict()
|
||||||
apertures_dict[str(aperture)]['size'] = size
|
# apertures_dict[str(aperture)]['size'] = size
|
||||||
apertures_dict[str(aperture)]['type'] = 'C'
|
# apertures_dict[str(aperture)]['type'] = 'C'
|
||||||
apertures_dict[str(aperture)]['solid_geometry'] = []
|
# apertures_dict[str(aperture)]['solid_geometry'] = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Detect No_Op command, ignore the current subpath
|
# Detect No_Op command, ignore the current subpath
|
||||||
match = self.no_op_re.search(pline)
|
match = self.no_op_re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
path['lines'] = []
|
subpath['lines'] = []
|
||||||
path['bezier'] = []
|
subpath['bezier'] = []
|
||||||
path['rectangle'] = []
|
subpath['rectangle'] = []
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Stroke the path
|
# Stroke the path
|
||||||
match = self.stroke_path__re.search(pline)
|
match = self.stroke_path__re.search(pline)
|
||||||
if match:
|
if match:
|
||||||
# path['lines'] = []
|
# scale the size here; some PDF printers apply transformation after the size is declared
|
||||||
# path['bezier'] = []
|
applied_size = size * scale_geo[0] * c_scale_f[0] * self.point_to_unit_factor
|
||||||
# path['rectangle'] = []
|
|
||||||
# continue
|
|
||||||
geo = None
|
|
||||||
if path['lines']:
|
|
||||||
path['lines'].insert(0, start_point)
|
|
||||||
geo = copy(path['lines'])
|
|
||||||
if flag_close_path:
|
|
||||||
flag_close_path = False
|
|
||||||
geo.append(start_point)
|
|
||||||
path['lines'] = []
|
|
||||||
|
|
||||||
if path['bezier']:
|
path_geo = list()
|
||||||
geo = list()
|
if current_subpath == 'lines':
|
||||||
geo.append(start_point)
|
if path['lines']:
|
||||||
for b in path['bezier']:
|
for subp in path['lines']:
|
||||||
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
geo = copy(subp)
|
||||||
if flag_close_path:
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
flag_close_path = False
|
path_geo.append(geo)
|
||||||
geo.append(start_point)
|
# the path was painted therefore initialize it
|
||||||
path['bezier'] = []
|
path['lines'] = []
|
||||||
|
else:
|
||||||
|
geo = copy(subpath['lines'])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
subpath['lines'] = []
|
||||||
|
|
||||||
if path['rectangle']:
|
if current_subpath == 'bezier':
|
||||||
geo = copy(path['rectangle'])
|
if path['bezier']:
|
||||||
# if flag_close_path:
|
for subp in path['bezier']:
|
||||||
# flag_close_path = False
|
geo = []
|
||||||
# geo.append(start_point)
|
for b in subp:
|
||||||
path['rectangle'] = []
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['bezier'] = []
|
||||||
|
else:
|
||||||
|
geo = []
|
||||||
|
for b in subpath['bezier']:
|
||||||
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
subpath['bezier'] = []
|
||||||
|
|
||||||
|
if current_subpath == 'rectangle':
|
||||||
|
if path['rectangle']:
|
||||||
|
for subp in path['rectangle']:
|
||||||
|
geo = copy(subp)
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['rectangle'] = []
|
||||||
|
else:
|
||||||
|
geo = copy(subpath['rectangle'])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
subpath['rectangle'] = []
|
||||||
|
|
||||||
ext_geo = LineString(geo)
|
|
||||||
ext_geo = ext_geo.buffer((float(size) / 2), resolution=self.step_per_circles)
|
|
||||||
# ext_geo = affinity.scale(ext_geo, scale_geo[0], scale_geo[1])
|
|
||||||
# off_x = offset_geo[0]
|
|
||||||
# off_y = offset_geo[1]
|
|
||||||
#
|
|
||||||
# ext_geo = affinity.translate(ext_geo, off_x, off_y)
|
|
||||||
try:
|
try:
|
||||||
apertures_dict[str(aperture)]['solid_geometry'].append(deepcopy(ext_geo))
|
apertures_dict[str(aperture)]['solid_geometry'] += path_geo
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# in case there is no stroke width yet therefore no aperture
|
# in case there is no stroke width yet therefore no aperture
|
||||||
apertures_dict['0'] = {}
|
apertures_dict[str(aperture)] = {}
|
||||||
apertures_dict['0']['solid_geometry'] = []
|
apertures_dict[str(aperture)]['size'] = applied_size
|
||||||
apertures_dict['0']['size'] = size
|
apertures_dict[str(aperture)]['type'] = 'C'
|
||||||
apertures_dict['0']['type'] = 'C'
|
apertures_dict[str(aperture)]['solid_geometry'] = []
|
||||||
apertures_dict['0']['solid_geometry'].append(deepcopy(ext_geo))
|
apertures_dict[str(aperture)]['solid_geometry'] += path_geo
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Fill the path
|
# Fill the path
|
||||||
match = self.fill_path_re.search(pline)
|
match = self.fill_path_re.search(pline)
|
||||||
match2 = self.fill_stroke_path_re.search(pline)
|
if match:
|
||||||
if match or match2:
|
# scale the size here; some PDF printers apply transformation after the size is declared
|
||||||
|
applied_size = size * scale_geo[0] * c_scale_f[0] * self.point_to_unit_factor
|
||||||
|
|
||||||
geo = None
|
path_geo = list()
|
||||||
if path['lines']:
|
if current_subpath == 'lines':
|
||||||
path['lines'].insert(0, start_point)
|
if path['lines']:
|
||||||
geo = copy(path['lines'])
|
for subp in path['lines']:
|
||||||
geo.append(start_point)
|
geo = copy(subp)
|
||||||
path['lines'] = []
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(geo[0])
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['lines'] = []
|
||||||
|
else:
|
||||||
|
geo = copy(subpath['lines'])
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(start_point)
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
subpath['lines'] = []
|
||||||
|
|
||||||
elif path['bezier']:
|
if current_subpath == 'bezier':
|
||||||
geo = []
|
geo = []
|
||||||
for b in path['bezier']:
|
if path['bezier']:
|
||||||
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
for subp in path['bezier']:
|
||||||
geo.append(start_point)
|
for b in subp:
|
||||||
path['bezier'] = []
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(geo[0])
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['bezier'] = []
|
||||||
|
else:
|
||||||
|
for b in subpath['bezier']:
|
||||||
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(start_point)
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
subpath['bezier'] = []
|
||||||
|
|
||||||
elif path['rectangle']:
|
if current_subpath == 'rectangle':
|
||||||
# path['rectangle'].append(start_point)
|
if path['rectangle']:
|
||||||
geo = copy(path['rectangle'])
|
for subp in path['rectangle']:
|
||||||
path['rectangle'] = []
|
geo = copy(subp)
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(geo[0])
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['rectangle'] = []
|
||||||
|
else:
|
||||||
|
geo = copy(subpath['rectangle'])
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(start_point)
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
subpath['rectangle'] = []
|
||||||
|
|
||||||
|
# we finished painting and also closed the path if it was the case
|
||||||
|
close_path = True
|
||||||
|
|
||||||
ext_geo = Polygon(geo)
|
|
||||||
ext_geo = ext_geo.buffer(0.000001, resolution=self.step_per_circles)
|
|
||||||
# ext_geo = affinity.scale(ext_geo, scale_geo[0], scale_geo[1])
|
|
||||||
# off_x = offset_geo[0]
|
|
||||||
# off_y = offset_geo[1]
|
|
||||||
#
|
|
||||||
# ext_geo = affinity.translate(ext_geo, off_x, off_y)
|
|
||||||
try:
|
try:
|
||||||
apertures_dict[str(aperture)]['solid_geometry'].append(deepcopy(ext_geo))
|
apertures_dict['0']['solid_geometry'] += path_geo
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# in case there is no stroke width yet therefore no aperture
|
# in case there is no stroke width yet therefore no aperture
|
||||||
apertures_dict['0'] = {}
|
apertures_dict['0'] = {}
|
||||||
apertures_dict['0']['solid_geometry'] = []
|
apertures_dict['0']['size'] = applied_size
|
||||||
apertures_dict['0']['size'] = size
|
|
||||||
apertures_dict['0']['type'] = 'C'
|
apertures_dict['0']['type'] = 'C'
|
||||||
apertures_dict['0']['solid_geometry'].append(deepcopy(ext_geo))
|
apertures_dict['0']['solid_geometry'] = []
|
||||||
|
apertures_dict['0']['solid_geometry'] += path_geo
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# fill and stroke the path
|
||||||
|
match = self.fill_stroke_path_re.search(pline)
|
||||||
|
if match:
|
||||||
|
# scale the size here; some PDF printers apply transformation after the size is declared
|
||||||
|
applied_size = size * scale_geo[0] * c_scale_f[0] * self.point_to_unit_factor
|
||||||
|
|
||||||
|
path_geo = list()
|
||||||
|
if current_subpath == 'lines':
|
||||||
|
if path['lines']:
|
||||||
|
# fill
|
||||||
|
for subp in path['lines']:
|
||||||
|
geo = copy(subp)
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(geo[0])
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# stroke
|
||||||
|
for subp in path['lines']:
|
||||||
|
geo = copy(subp)
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['lines'] = []
|
||||||
|
else:
|
||||||
|
# fill
|
||||||
|
geo = copy(subpath['lines'])
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(start_point)
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# stroke
|
||||||
|
geo = copy(subpath['lines'])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
subpath['lines'] = []
|
||||||
|
subpath['lines'] = []
|
||||||
|
|
||||||
|
if current_subpath == 'bezier':
|
||||||
|
geo = []
|
||||||
|
if path['bezier']:
|
||||||
|
# fill
|
||||||
|
for subp in path['bezier']:
|
||||||
|
for b in subp:
|
||||||
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(geo[0])
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# stroke
|
||||||
|
for subp in path['bezier']:
|
||||||
|
geo = []
|
||||||
|
for b in subp:
|
||||||
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['bezier'] = []
|
||||||
|
else:
|
||||||
|
# fill
|
||||||
|
for b in subpath['bezier']:
|
||||||
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(start_point)
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# stroke
|
||||||
|
geo = []
|
||||||
|
for b in subpath['bezier']:
|
||||||
|
geo += self.bezier_to_points(start=b[0], c1=b[1], c2=b[2], stop=b[3])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
subpath['bezier'] = []
|
||||||
|
|
||||||
|
if current_subpath == 'rectangle':
|
||||||
|
if path['rectangle']:
|
||||||
|
# fill
|
||||||
|
for subp in path['rectangle']:
|
||||||
|
geo = copy(subp)
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(geo[0])
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# stroke
|
||||||
|
for subp in path['rectangle']:
|
||||||
|
geo = copy(subp)
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
# the path was painted therefore initialize it
|
||||||
|
path['rectangle'] = []
|
||||||
|
else:
|
||||||
|
# fill
|
||||||
|
geo = copy(subpath['rectangle'])
|
||||||
|
# close the subpath if it was not closed already
|
||||||
|
if close_path is False:
|
||||||
|
geo.append(start_point)
|
||||||
|
geo_el = Polygon(geo).buffer(0.0000001, resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo_el)
|
||||||
|
# stroke
|
||||||
|
geo = copy(subpath['rectangle'])
|
||||||
|
geo = LineString(geo).buffer((float(applied_size) / 2), resolution=self.step_per_circles)
|
||||||
|
path_geo.append(geo)
|
||||||
|
subpath['rectangle'] = []
|
||||||
|
|
||||||
|
# we finished painting and also closed the path if it was the case
|
||||||
|
close_path = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
apertures_dict['0']['solid_geometry'] += path_geo
|
||||||
|
except KeyError:
|
||||||
|
# in case there is no stroke width yet therefore no aperture
|
||||||
|
apertures_dict['0'] = {}
|
||||||
|
apertures_dict['0']['size'] = applied_size
|
||||||
|
apertures_dict['0']['type'] = 'C'
|
||||||
|
apertures_dict['0']['solid_geometry'] = []
|
||||||
|
apertures_dict['0']['solid_geometry'] += path_geo
|
||||||
|
continue
|
||||||
return apertures_dict
|
return apertures_dict
|
||||||
|
|
||||||
def bezier_to_points(self, start, c1, c2, stop):
|
def bezier_to_points(self, start, c1, c2, stop):
|
||||||
|
|||||||
Reference in New Issue
Block a user