- added ability to save the Source File as PDF (still have to adjust the page size)
This commit is contained in:
parent
4ac5f8e239
commit
2565dd75f1
|
@ -9975,11 +9975,11 @@ class App(QtCore.QObject):
|
||||||
|
|
||||||
flt = "All Files (*.*)"
|
flt = "All Files (*.*)"
|
||||||
if obj.kind == 'gerber':
|
if obj.kind == 'gerber':
|
||||||
flt = "Gerber Files (*.GBR);;All Files (*.*)"
|
flt = "Gerber Files (*.GBR);;PDF Files (*.PDF);;All Files (*.*)"
|
||||||
elif obj.kind == 'excellon':
|
elif obj.kind == 'excellon':
|
||||||
flt = "Excellon Files (*.DRL);;All Files (*.*)"
|
flt = "Excellon Files (*.DRL);;PDF Files (*.PDF);;All Files (*.*)"
|
||||||
elif obj.kind == 'cncjob':
|
elif obj.kind == 'cncjob':
|
||||||
"GCode Files (*.NC);;All Files (*.*)"
|
flt = "GCode Files (*.NC);;PDF Files (*.PDF);;All Files (*.*)"
|
||||||
|
|
||||||
self.source_editor_tab = TextEditor(app=self, plain_text=True)
|
self.source_editor_tab = TextEditor(app=self, plain_text=True)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
- maximum range for Cut Z is now zero to deal with the situation when using V-shape with tip-dia same value with cut width
|
- maximum range for Cut Z is now zero to deal with the situation when using V-shape with tip-dia same value with cut width
|
||||||
- modified QValidator in FCDoubleSpinner() GUI element to allow entering the minus sign when the range maximum is set as 0.0; also for positive numbers allowed entering the symbol plus
|
- modified QValidator in FCDoubleSpinner() GUI element to allow entering the minus sign when the range maximum is set as 0.0; also for positive numbers allowed entering the symbol plus
|
||||||
- made sure that if in Gerber UI the isolation is made with a V-Shape tool then the tool type is automatically updated on the generated Geometry Object
|
- made sure that if in Gerber UI the isolation is made with a V-Shape tool then the tool type is automatically updated on the generated Geometry Object
|
||||||
|
- added ability to save the Source File as PDF (still have to adjust the page size)
|
||||||
|
|
||||||
16.12.2019
|
16.12.2019
|
||||||
|
|
||||||
|
|
|
@ -217,9 +217,42 @@ class TextEditor(QtWidgets.QWidget):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
my_gcode = self.code_editor.toPlainText()
|
my_gcode = self.code_editor.toPlainText()
|
||||||
with open(filename, 'w') as f:
|
if filename.rpartition('.')[2].lower() == 'pdf':
|
||||||
for line in my_gcode:
|
from reportlab.platypus import SimpleDocTemplate, Paragraph
|
||||||
f.write(line)
|
from reportlab.lib.styles import getSampleStyleSheet
|
||||||
|
from reportlab.lib.units import inch
|
||||||
|
|
||||||
|
if self.app.defaults['units'].upper() == 'MM':
|
||||||
|
dims = self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']]
|
||||||
|
else:
|
||||||
|
dims = (
|
||||||
|
self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][0] / 25.4,
|
||||||
|
self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][1] / 25.4
|
||||||
|
)
|
||||||
|
|
||||||
|
styles = getSampleStyleSheet()
|
||||||
|
styleN = styles['Normal']
|
||||||
|
styleH = styles['Heading1']
|
||||||
|
story = []
|
||||||
|
|
||||||
|
doc = SimpleDocTemplate(
|
||||||
|
filename,
|
||||||
|
pagesize=dims,
|
||||||
|
bottomMargin=0.4 * 72,
|
||||||
|
topMargin=0.6 * 72,
|
||||||
|
rightMargin=0.8 * 72,
|
||||||
|
leftMargin=0.8 * 72)
|
||||||
|
|
||||||
|
P = Paragraph(my_gcode, styleN)
|
||||||
|
story.append(P)
|
||||||
|
|
||||||
|
doc.build(
|
||||||
|
story,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
with open(filename, 'w') as f:
|
||||||
|
for line in my_gcode:
|
||||||
|
f.write(line)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.app.inform.emit('[WARNING] %s' % _("No such file or directory"))
|
self.app.inform.emit('[WARNING] %s' % _("No such file or directory"))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue