From 667750c9d7e0ce13acdc123d1d103e3aa9d5b19b Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 13 Jul 2016 12:52:23 -0400 Subject: [PATCH 1/2] Fixed text and quality of vector graphics as exported --- Packages/vcs/vcs/VTKPlots.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py index 4cb9e5df23..b2f1dc63bb 100644 --- a/Packages/vcs/vcs/VTKPlots.py +++ b/Packages/vcs/vcs/VTKPlots.py @@ -1109,17 +1109,18 @@ def vectorGraphics(self, output_type, file, width=None, height=None, # Since the patterns are applied as textures on vtkPolyData, enabling # background rasterization is required to write them out - if self._rasterPropsInVectorFormats: - gl.Write3DPropsAsRasterImageOn() + # if self._rasterPropsInVectorFormats: + # gl.Write3DPropsAsRasterImageOn() gl.SetInput(self.renWin) gl.SetCompress(0) # Do not compress gl.SetFilePrefix(".".join(file.split(".")[:-1])) if textAsPaths: - gl.TextAsPathOff() - else: gl.TextAsPathOn() + else: + gl.TextAsPathOff() + if output_type == "svg": gl.SetFileFormatToSVG() elif output_type == "ps": @@ -1252,16 +1253,16 @@ def gettextextent(self, textorientation, texttable): texttable = vcs.gettexttable(texttable) from vtk_ui.text import text_dimensions - + text_property = vtk.vtkTextProperty() info = self.canvasinfo() win_size = info["width"], info["height"] vcs2vtk.prepTextProperty(text_property, win_size, to=textorientation, tt=texttable) - + dpi = self.renWin.GetDPI() - + length = max(len(texttable.string), len(texttable.x), len(texttable.y)) - + strings = texttable.string + [texttable.string[-1]] * (length - len(texttable.string)) xs = texttable.x + [texttable.x[-1]] * (length - len(texttable.x)) ys = texttable.y + [texttable.y[-1]] * (length - len(texttable.y)) From 8991302edff913ddeae4ede4e997e50e0f24c23c Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 13 Jul 2016 13:04:15 -0400 Subject: [PATCH 2/2] Export to vector works for transparent geometries as well --- Packages/vcs/vcs/VTKPlots.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py index b2f1dc63bb..ec388c726d 100644 --- a/Packages/vcs/vcs/VTKPlots.py +++ b/Packages/vcs/vcs/VTKPlots.py @@ -688,21 +688,16 @@ def plot(self, data1, data2, template, gtype, gname, bg, *args, **kargs): self.scaleLogo() # Decide whether to rasterize background in vector outputs - # Current criteria to rasterize: + # Current limitation to vectorize: # * if fillarea style is either pattern or hatch - # * if fillarea opacity is less than 100 for solid fill try: if gm.style and all(style != 'solid' for style in gm.style): self._rasterPropsInVectorFormats = True - elif gm.opacity and not all(o == 100 for o in gm.opacity): - self._rasterPropsInVectorFormats = True except: pass try: if gm.fillareastyle in ['pattern', 'hatch']: self._rasterPropsInVectorFormats = True - elif not all(o == 100 for o in gm.fillareaopacity): - self._rasterPropsInVectorFormats = True except: pass @@ -1109,8 +1104,9 @@ def vectorGraphics(self, output_type, file, width=None, height=None, # Since the patterns are applied as textures on vtkPolyData, enabling # background rasterization is required to write them out - # if self._rasterPropsInVectorFormats: - # gl.Write3DPropsAsRasterImageOn() + + if self._rasterPropsInVectorFormats: + gl.Write3DPropsAsRasterImageOn() gl.SetInput(self.renWin) gl.SetCompress(0) # Do not compress