- added option to save objects as PDF files in File -> Save menu

This commit is contained in:
Marius Stanciu
2019-12-12 03:18:52 +02:00
committed by Marius
parent b429f9b0c8
commit 6d826fa143
6 changed files with 90 additions and 15 deletions

View File

@@ -197,6 +197,9 @@ class ToolCalibration(FlatCAMTool):
self.obj_type_combo.addItem(_("Excellon"))
self.obj_type_combo.setCurrentIndex(1)
self.obj_type_combo.setItemIcon(0, QtGui.QIcon("share/flatcam_icon16.png"))
self.obj_type_combo.setItemIcon(1, QtGui.QIcon("share/drill16.png"))
grid_lay.addWidget(self.obj_type_label, 12, 0)
grid_lay.addWidget(self.obj_type_combo, 12, 1, 1, 2)
@@ -631,6 +634,10 @@ class ToolCalibration(FlatCAMTool):
self.adj_object_type_combo.addItems([_("Gerber"), _("Excellon"), _("Geometry")])
self.adj_object_type_combo.setCurrentIndex(0)
self.adj_object_type_combo.setItemIcon(0, QtGui.QIcon("share/flatcam_icon16.png"))
self.adj_object_type_combo.setItemIcon(1, QtGui.QIcon("share/drill16.png"))
self.adj_object_type_combo.setItemIcon(2, QtGui.QIcon("share/geometry16.png"))
self.adj_object_type_label = QtWidgets.QLabel("%s:" % _("Adjusted object type"))
self.adj_object_type_label.setToolTip(
_("Type of the FlatCAM Object to be adjusted.")

View File

@@ -19,7 +19,7 @@ from reportlab.graphics import renderPDF
from reportlab.pdfgen import canvas
from reportlab.graphics import renderPM
from reportlab.lib.units import inch, mm
from reportlab.lib.pagesizes import landscape, portrait, A4
from reportlab.lib.pagesizes import landscape, portrait
from svglib.svglib import svg2rlg
from xml.dom.minidom import parseString as parse_xml_string
@@ -742,12 +742,18 @@ class Film(FlatCAMTool):
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Export positive film cancelled."))
return
else:
pagesize = self.pagesize_combo.get_value()
orientation = self.orientation_radio.get_value()
color = self.app.defaults['tools_film_color']
self.export_positive(name, boxname, filename,
scale_stroke_factor=factor,
scale_factor_x=scale_factor_x, scale_factor_y=scale_factor_y,
skew_factor_x=skew_factor_x, skew_factor_y=skew_factor_y,
skew_reference=skew_reference,
mirror=mirror, ftype=ftype
mirror=mirror,
pagesize=pagesize, orientation=orientation, color=color, opacity=1.0,
ftype=ftype
)
def generate_positive_punched_film(self, name, boxname, source, factor, ftype='svg'):
@@ -1072,7 +1078,7 @@ class Film(FlatCAMTool):
scale_stroke_factor=0.00,
scale_factor_x=None, scale_factor_y=None,
skew_factor_x=None, skew_factor_y=None, skew_reference='center',
mirror=None,
mirror=None, orientation='p', pagesize='A4', color='black', opacity=1.0,
use_thread=True, ftype='svg'):
"""
Exports a Geometry Object to an SVG file in positive black.
@@ -1116,6 +1122,11 @@ class Film(FlatCAMTool):
self.inform.emit('[WARNING_NOTCL] %s: %s' % (_("No object Box. Using instead"), obj))
box = obj
p_size = pagesize
orientation = orientation
color = color
transparency_level = opacity
def make_positive_film():
log.debug("FilmTool.export_positive().make_positive_film()")
@@ -1131,9 +1142,9 @@ class Film(FlatCAMTool):
# We set the colour to WHITE
root = ET.fromstring(exported_svg)
for child in root:
child.set('fill', str(self.app.defaults['tools_film_color']))
child.set('opacity', '1.0')
child.set('stroke', str(self.app.defaults['tools_film_color']))
child.set('fill', str(color))
child.set('opacity', str(transparency_level))
child.set('stroke', str(color))
exported_svg = ET.tostring(root)
@@ -1194,7 +1205,7 @@ class Film(FlatCAMTool):
return 'fail'
else:
try:
if self.units == 'INCH':
if self.units == 'IN':
unit = inch
else:
unit = mm
@@ -1202,11 +1213,10 @@ class Film(FlatCAMTool):
doc_final = StringIO(doc_final)
drawing = svg2rlg(doc_final)
p_size = self.pagesize_combo.get_value()
if p_size == 'Bounds':
renderPDF.drawToFile(drawing, filename)
else:
if self.orientation_radio.get_value() == 'p':
if orientation == 'p':
page_size = portrait(self.pagesize[p_size])
else:
page_size = landscape(self.pagesize[p_size])