Merge remote-tracking branch 'origin/Beta_8.995' into Beta_8.995
This commit is contained in:
@@ -17,6 +17,8 @@ CHANGELOG for FlatCAM beta
|
||||
11.11.2020
|
||||
|
||||
- removed the forcing of multigeo geometry usage when creating CNCJobs
|
||||
- in Film Tool added messages to warn the user that it can't save a film to file due of existing locked file, if the file needs to overwrite another file who is opened in another application
|
||||
- in Film Tool warn the user if it tries to save a film to file but the artwork is outside the page size therefore invisible
|
||||
|
||||
10.11.2020
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ from svglib.svglib import svg2rlg
|
||||
from xml.dom.minidom import parseString as parse_xml_string
|
||||
from lxml import etree as ET
|
||||
from io import StringIO
|
||||
import re
|
||||
|
||||
import gettext
|
||||
import appTranslation as fcTranslate
|
||||
@@ -585,7 +586,7 @@ class Film(AppTool):
|
||||
with open(filename, 'w') as fp:
|
||||
fp.write(doc_final)
|
||||
except PermissionError:
|
||||
self.app.inform.emit('[WARNING] %s' %
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
@@ -599,32 +600,61 @@ class Film(AppTool):
|
||||
# renderPM.drawToFile(drawing, filename, 'PNG')
|
||||
# else:
|
||||
# renderPM.drawToFile(drawing, filename, 'PNG', dpi=new_png_dpi)
|
||||
except PermissionError:
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
except Exception as e:
|
||||
log.debug("FilmTool.export_negative() --> PNG output --> %s" % str(e))
|
||||
return 'fail'
|
||||
else:
|
||||
else: # PDF
|
||||
try:
|
||||
if self.units == 'INCH':
|
||||
if self.units == 'IN':
|
||||
unit = inch
|
||||
else:
|
||||
unit = mm
|
||||
|
||||
doc_final = StringIO(doc_final)
|
||||
drawing = svg2rlg(doc_final)
|
||||
|
||||
p_size = self.ui.pagesize_combo.get_value()
|
||||
if p_size == 'Bounds':
|
||||
renderPDF.drawToFile(drawing, filename)
|
||||
else:
|
||||
if self.ui.orientation_radio.get_value() == 'p':
|
||||
page_size = None
|
||||
elif self.ui.orientation_radio.get_value() == 'p':
|
||||
page_size = portrait(self.ui.pagesize[p_size])
|
||||
else:
|
||||
page_size = landscape(self.ui.pagesize[p_size])
|
||||
|
||||
xmin, ymin, xmax, ymax = obj.bounds()
|
||||
if page_size:
|
||||
page_xmax, page_ymax = (
|
||||
page_size[0] / mm,
|
||||
page_size[1] / mm
|
||||
)
|
||||
else:
|
||||
page_xmax, page_ymax = xmax, ymax
|
||||
|
||||
if xmax < 0 or ymax < 0 or xmin > page_xmax or ymin > page_ymax:
|
||||
err_msg = '[ERROR_NOTCL] %s %s' % \
|
||||
(_("Failed."),
|
||||
_("The artwork has to be within the selected page size in order to be visible.\n"
|
||||
"For 'Bounds' page size, it needs to be in the first quadrant."))
|
||||
self.app.inform.emit(err_msg)
|
||||
return 'fail'
|
||||
|
||||
doc_final = StringIO(doc_final)
|
||||
drawing = svg2rlg(doc_final)
|
||||
|
||||
if p_size == 'Bounds':
|
||||
renderPDF.drawToFile(drawing, filename)
|
||||
else:
|
||||
my_canvas = canvas.Canvas(filename, pagesize=page_size)
|
||||
my_canvas.translate(bounds[0] * unit, bounds[1] * unit)
|
||||
renderPDF.draw(drawing, my_canvas, 0, 0)
|
||||
my_canvas.save()
|
||||
except PermissionError:
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
except Exception as e:
|
||||
log.debug("FilmTool.export_negative() --> PDF output --> %s" % str(e))
|
||||
return 'fail'
|
||||
@@ -835,7 +865,7 @@ class Film(AppTool):
|
||||
with open(filename, 'w') as fp:
|
||||
fp.write(doc_final)
|
||||
except PermissionError:
|
||||
self.app.inform.emit('[WARNING] %s' %
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
@@ -844,6 +874,11 @@ class Film(AppTool):
|
||||
doc_final = StringIO(doc_final)
|
||||
drawing = svg2rlg(doc_final)
|
||||
renderPM.drawToFile(drawing, filename, 'PNG')
|
||||
except PermissionError:
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
except Exception as e:
|
||||
log.debug("FilmTool.export_positive() --> PNG output --> %s" % str(e))
|
||||
return 'fail'
|
||||
@@ -854,21 +889,45 @@ class Film(AppTool):
|
||||
else:
|
||||
unit = mm
|
||||
|
||||
if p_size == 'Bounds':
|
||||
page_size = None
|
||||
elif orientation == 'p':
|
||||
page_size = portrait(self.ui.pagesize[p_size])
|
||||
else:
|
||||
page_size = landscape(self.ui.pagesize[p_size])
|
||||
|
||||
xmin, ymin, xmax, ymax = obj.bounds()
|
||||
if page_size:
|
||||
page_xmax, page_ymax = (
|
||||
page_size[0] / mm,
|
||||
page_size[1] / mm
|
||||
)
|
||||
else:
|
||||
page_xmax, page_ymax = xmax, ymax
|
||||
|
||||
if xmax < 0 or ymax < 0 or xmin > page_xmax or ymin > page_ymax:
|
||||
err_msg = '[ERROR_NOTCL] %s %s' % \
|
||||
(_("Failed."),
|
||||
_("The artwork has to be within the selected page size in order to be visible.\n"
|
||||
"For 'Bounds' page size, it needs to be in the first quadrant."))
|
||||
self.app.inform.emit(err_msg)
|
||||
return 'fail'
|
||||
|
||||
doc_final = StringIO(doc_final)
|
||||
drawing = svg2rlg(doc_final)
|
||||
|
||||
if p_size == 'Bounds':
|
||||
renderPDF.drawToFile(drawing, filename)
|
||||
else:
|
||||
if orientation == 'p':
|
||||
page_size = portrait(self.ui.pagesize[p_size])
|
||||
else:
|
||||
page_size = landscape(self.ui.pagesize[p_size])
|
||||
|
||||
my_canvas = canvas.Canvas(filename, pagesize=page_size)
|
||||
my_canvas.translate(bounds[0] * unit, bounds[1] * unit)
|
||||
renderPDF.draw(drawing, my_canvas, 0, 0)
|
||||
my_canvas.save()
|
||||
except PermissionError:
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("Permission denied, saving not possible.\n"
|
||||
"Most likely another app is holding the file open and not accessible."))
|
||||
return 'fail'
|
||||
except Exception as e:
|
||||
log.debug("FilmTool.export_positive() --> PDF output --> %s" % str(e))
|
||||
return 'fail'
|
||||
@@ -1288,9 +1347,7 @@ class FilmUI:
|
||||
|
||||
self.pagesize_combo = FCComboBox()
|
||||
|
||||
self.pagesize = {}
|
||||
self.pagesize.update(
|
||||
{
|
||||
self.pagesize = {
|
||||
'Bounds': None,
|
||||
'A0': (841 * mm, 1189 * mm),
|
||||
'A1': (594 * mm, 841 * mm),
|
||||
@@ -1340,7 +1397,6 @@ class FilmUI:
|
||||
'GOV_LEGAL': (8.5 * inch, 13 * inch),
|
||||
'LEDGER': (17 * inch, 11 * inch),
|
||||
}
|
||||
)
|
||||
|
||||
page_size_list = list(self.pagesize.keys())
|
||||
self.pagesize_combo.addItems(page_size_list)
|
||||
|
||||
Reference in New Issue
Block a user