diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py index e95609e3ea..4fe29ea2b5 100644 --- a/Packages/vcs/vcs/Canvas.py +++ b/Packages/vcs/vcs/Canvas.py @@ -18,7 +18,7 @@ # landscape (width exceeding height), portrait (height exceeding# # width), or full-screen mode. # # # -# Version: 2.4 # +# Version: 2.4 # # # ############################################################################### @@ -322,9 +322,9 @@ class Canvas(object): a=vcs.Canvas() # This examples constructs a VCS Canvas """ ########################################################################## - # # - # Set attributes for VCS Canvas Class (i.e., set VCS Canvas Mode). # - # # + # # + # Set attributes for VCS Canvas Class (i.e., set VCS Canvas Mode). # + # # ########################################################################## __slots__ = [ '_mode', @@ -835,9 +835,9 @@ def _reconstruct_tv(self, arglist, keyargs): return tv ########################################################################## - # # - # Print out the object's doc string. # - # # + # # + # Print out the object's doc string. # + # # ########################################################################## def objecthelp(self, *arg): """ @@ -855,13 +855,13 @@ def objecthelp(self, *arg): for x in arg: print getattr(x, "__doc__", "") - ########################################################################## - # # - # Initialize the VCS Canvas and set the Canvas mode to 0. Because the mode # - # is set to 0, the user will have to manually update the VCS Canvas by # - # using the "update" function. # - # # - ########################################################################## + ############################################################################ + # # + # Initialize the VCS Canvas and set the Canvas mode to 0. Because the mode # + # is set to 0, the user will have to manually update the VCS Canvas by # + # using the "update" function. # + # # + ############################################################################ def __init__(self, mode=1, pause_time=0, call_from_gui=0, size=None, backend="vtk", geometry=None, bg=None): self._canvas_id = vcs.next_canvas_id @@ -964,12 +964,12 @@ def __init__(self, mode=1, pause_time=0, # Initial.attributes is being called in main.c, so it is not needed here! # Actually it is for taylordiagram graphic methods.... -########################################################################## +########################################################################################### # Okay, then this is redundant since it is done in main.c. When time perments, put the # # taylordiagram graphic methods attributes in main.c Because this is here we must check # # to make sure that the initial attributes file is called only once for normalization # # purposes.... # -########################################################################## +########################################################################################### self.canvas_template_editor = None self.ratio = '0' @@ -1013,11 +1013,11 @@ def getdrawlogo(self): def initLogoDrawing(self): self.drawLogo = self.enableLogo - ########################################################################## + ############################################################################# # # # Update wrapper function for VCS. # # # - ########################################################################## + ############################################################################# def update(self, *args, **kargs): """ @@ -1046,11 +1046,11 @@ def update(self, *args, **kargs): return self.backend.update(*args, **kargs) - ########################################################################## + ############################################################################# # # # Update wrapper function for VCS with a check to update the continents. # # # - ########################################################################## + ############################################################################# def _update_continents_check(self, *args): a = self.canvas.updatecanvas_continents(*args) @@ -1060,11 +1060,11 @@ def _update_continents_check(self, *args): return a - ########################################################################## + ############################################################################# # # # Script VCS primary or secondary elements wrapper functions for VCS. # # # - ########################################################################## + ############################################################################# def scriptobject(self, obj, script_filename=None, mode=None): """ Function: scriptobject # Script a single primary or secondary class object @@ -1139,11 +1139,11 @@ def scriptobject(self, obj, script_filename=None, mode=None): else: print 'This is not a template, graphics method or secondary method object.' - ########################################################################## + ############################################################################# # # # Remove VCS primary and secondary methods wrapper functions for VCS. # # # - ########################################################################## + ############################################################################# def removeobject(self, obj): __doc__ = vcs.removeobject.__doc__ # noqa @@ -1193,11 +1193,11 @@ def clean_auto_generated_objects(self, type=None): def check_name_source(self, name, source, typ): return vcs.check_name_source(name, source, typ) - ########################################################################## + ############################################################################# # # # Template functions for VCS. # # # - ########################################################################## + ############################################################################# def createtemplate(self, name=None, source='default'): return vcs.createtemplate(name, source) createtemplate.__doc__ = vcs.manageElements.createtemplate.__doc__ @@ -1206,11 +1206,11 @@ def gettemplate(self, Pt_name_src='default'): return vcs.gettemplate(Pt_name_src) gettemplate.__doc__ = vcs.manageElements.gettemplate.__doc__ - ########################################################################## + ############################################################################# # # # Projection functions for VCS. # # # - ########################################################################## + ############################################################################# def createprojection(self, name=None, source='default'): return vcs.createprojection(name, source) createprojection.__doc__ = vcs.manageElements.createprojection.__doc__ @@ -1219,11 +1219,11 @@ def getprojection(self, Proj_name_src='default'): return vcs.getprojection(Proj_name_src) getprojection.__doc__ = vcs.manageElements.getprojection.__doc__ - ########################################################################## + ############################################################################# # # # Boxfill functions for VCS. # # # - ########################################################################## + ############################################################################# def createboxfill(self, name=None, source='default'): return vcs.createboxfill(name, source) createboxfill.__doc__ = vcs.manageElements.createboxfill.__doc__ @@ -1282,11 +1282,11 @@ def boxfill(self, *args, **parms): boxfill.__doc__ = boxfill.__doc__ % ( plot_keywords_doc, graphics_method_core, axesconvert, plot_2D_input, plot_output) - ########################################################################## + ############################################################################# # # # Taylordiagram functions for VCS. # # # - ########################################################################## + ############################################################################# def createtaylordiagram(self, name=None, source='default'): return vcs.createtaylordiagram(name, source) createtaylordiagram.__doc__ = vcs.manageElements.createtaylordiagram.__doc__ @@ -1317,11 +1317,11 @@ def taylordiagram(self, *args, **parms): arglist = _determine_arg_list('taylordiagram', args) return self.__plot(arglist, parms) - ########################################################################## + ############################################################################# # # # Meshfill functions for VCS. # # # - ########################################################################## + ############################################################################# def createmeshfill(self, name=None, source='default'): return vcs.createmeshfill(name, source) @@ -1368,11 +1368,11 @@ def meshfill(self, *args, **parms): # noqa arglist = _determine_arg_list('meshfill', args) return self.__plot(arglist, parms) - ########################################################################## + ############################################################################# # # - # DV3D functions for VCS. # + # DV3D functions for VCS. # # # - ########################################################################## + ############################################################################# def create3d_scalar(self, name=None, source='default'): return vcs.create3d_scalar(name, source) @@ -1413,11 +1413,11 @@ def dual_scalar3d(self, *args, **parms): arglist = _determine_arg_list('3d_dual_scalar', args) return self.__plot(arglist, parms) - ########################################################################## + ############################################################################# # # # Isofill functions for VCS. # # # - ########################################################################## + ############################################################################# def createisofill(self, name=None, source='default'): return vcs.createisofill(name, source) createisofill.__doc__ = vcs.manageElements.createisofill.__doc__ @@ -1469,11 +1469,11 @@ def isofill(self, *args, **parms): isofill.__doc__ = isofill.__doc__ % ( plot_keywords_doc, graphics_method_core, axesconvert, plot_2D_input, plot_output) - ########################################################################## + ############################################################################# # # # Isoline functions for VCS. # # # - ########################################################################## + ############################################################################# def createisoline(self, name=None, source='default'): return vcs.createisoline(name, source) createisoline.__doc__ = vcs.manageElements.createisoline.__doc__ @@ -1533,11 +1533,11 @@ def get1d(self, name): return vcs.get1d(name) create1d.__doc__ = vcs.manageElements.create1d.__doc__ - ########################################################################## + ############################################################################# # # # Xyvsy functions for VCS. # # # - ########################################################################## + ############################################################################# def createxyvsy(self, name=None, source='default'): return vcs.createxyvsy(name, source) createxyvsy.__doc__ = vcs.manageElements.createxyvsy.__doc__ @@ -1589,11 +1589,11 @@ def xyvsy(self, *args, **parms): xyvsy.__doc__ = xyvsy.__doc__ % ( plot_keywords_doc, graphics_method_core, xaxisconvert, plot_1D_input, plot_output) - ########################################################################## + ############################################################################# # # # Yxvsx functions for VCS. # # # - ########################################################################## + ############################################################################# def createyxvsx(self, name=None, source='default'): return vcs.createyxvsx(name, source) createyxvsx.__doc__ = vcs.manageElements.createyxvsx.__doc__ @@ -1645,11 +1645,11 @@ def yxvsx(self, *args, **parms): yxvsx.__doc__ = yxvsx.__doc__ % ( plot_keywords_doc, graphics_method_core, xaxisconvert, plot_1D_input, plot_output) - ########################################################################## + ############################################################################# # # # XvsY functions for VCS. # # # - ########################################################################## + ############################################################################# def createxvsy(self, name=None, source='default'): return vcs.createxvsy(name, source) createxvsy.__doc__ = vcs.manageElements.createxvsy.__doc__ @@ -1702,11 +1702,11 @@ def xvsy(self, *args, **parms): plot_2_1D_input, plot_output) - ########################################################################## + ############################################################################# # # # Vector functions for VCS. # # # - ########################################################################## + ############################################################################# def createvector(self, name=None, source='default'): return vcs.createvector(name, source) createvector.__doc__ = vcs.manageElements.createvector.__doc__ @@ -1737,11 +1737,11 @@ def vector(self, *args, **parms): arglist = _determine_arg_list('vector', args) return self.__plot(arglist, parms) - ########################################################################## + ############################################################################# # # # Scatter functions for VCS. # # # - ########################################################################## + ############################################################################# def createscatter(self, name=None, source='default'): return vcs.createscatter(name, source) createscatter.__doc__ = vcs.manageElements.createscatter.__doc__ @@ -1792,11 +1792,11 @@ def scatter(self, *args, **parms): scatter.__doc__ = scatter.__doc__ % ( plot_keywords_doc, graphics_method_core, axesconvert, plot_2_1D_input, plot_output) - ########################################################################## + ############################################################################# # # # Line functions for VCS. # # # - ########################################################################## + ############################################################################# def createline(self, name=None, source='default', ltype=None, # noqa width=None, color=None, priority=None, viewport=None, worldcoordinate=None, @@ -1876,11 +1876,11 @@ def drawline(self, name=None, ltype='solid', width=1, color=241, # noqa return ln - ########################################################################## + ############################################################################# # # # Marker functions for VCS. # # # - ########################################################################## + ############################################################################# def createmarker(self, name=None, source='default', mtype=None, # noqa size=None, color=None, priority=1, viewport=None, worldcoordinate=None, @@ -1959,11 +1959,11 @@ def drawmarker(self, name=None, mtype='solid', size=1, color=241, return mrk - ########################################################################## + ############################################################################# # # # Fillarea functions for VCS. # # # - ########################################################################## + ############################################################################# def createfillarea(self, name=None, source='default', style=None, index=None, color=None, priority=1, viewport=None, worldcoordinate=None, @@ -2044,11 +2044,11 @@ def drawfillarea(self, name=None, style=1, index=1, color=241, return fa - ########################################################################## + ############################################################################# # # # Text Table functions for VCS. # # # - ########################################################################## + ############################################################################# def createtexttable(self, name=None, source='default', font=None, spacing=None, expansion=None, color=None, priority=None, viewport=None, worldcoordinate=None, @@ -2066,11 +2066,11 @@ def gettexttable(self, name='default', font=None, viewport, worldcoordinate, x, y) gettexttable.__doc__ = vcs.manageElements.gettexttable.__doc__ - ########################################################################## + ############################################################################# # # # Text Orientation functions for VCS. # # # - ########################################################################## + ############################################################################# def createtextorientation(self, name=None, source='default'): return vcs.createtextorientation(name, source) createtextorientation.__doc__ = vcs.manageElements.createtextorientation.__doc__ @@ -2079,11 +2079,11 @@ def gettextorientation(self, To_name_src='default'): return vcs.gettextorientation(To_name_src) gettextorientation.__doc__ = vcs.manageElements.gettextorientation.__doc__ - ########################################################################## + ############################################################################# # # # Text Combined functions for VCS. # # # - ########################################################################## + ############################################################################# def createtextcombined(self, Tt_name=None, Tt_source='default', To_name=None, To_source='default', # noqa font=None, spacing=None, expansion=None, color=None, priority=None, viewport=None, worldcoordinate=None, x=None, y=None, @@ -2313,7 +2313,7 @@ def plot(self, *actual_args, **keyargs): Other: [x|y]rev = 0|1 # if ==1, reverse the direction of the x or y axis - continents = 0,1,2,3,4,5,6,7,8,9,10,11 # if >=1, plot continental outlines + continents = 0,1,2,3,4,5,6,7,8,9,10,11 # if >=1, plot continental outlines (default: plot if xaxis is longitude, yaxis is latitude -or- xname is 'longitude' and yname is @@ -3802,33 +3802,33 @@ def setAnimationStepper(self, stepper): self.backend.setAnimationStepper(stepper) ########################################################################## - # # - # VCS utility wrapper to return the number of displays that are "ON". # - # # + # # + # VCS utility wrapper to return the number of displays that are "ON". # + # # ########################################################################## def return_display_ON_num(self, *args): return self.canvas.return_display_ON_num(*args) ########################################################################## - # # - # VCS utility wrapper to return the current display names. # - # # + # # + # VCS utility wrapper to return the current display names. # + # # ########################################################################## def return_display_names(self, *args): return self.display_names ########################################################################## - # # - # VCS utility wrapper to remove the display names. # - # # + # # + # VCS utility wrapper to remove the display names. # + # # ########################################################################## def remove_display_name(self, *args): return self.canvas.remove_display_name(*args) ########################################################################## - # # - # CGM wrapper for VCS. # - # # + # # + # CGM wrapper for VCS. # + # # ########################################################################## def cgm(self, file, mode='w'): """ @@ -3861,9 +3861,9 @@ def cgm(self, file, mode='w'): return self.backend.cgm(file) ########################################################################## - # # - # Clear VCS Canvas wrapper for VCS. # - # # + # # + # Clear VCS Canvas wrapper for VCS. # + # # ########################################################################## def clear(self, *args, **kargs): """ @@ -3912,9 +3912,9 @@ def clear(self, *args, **kargs): return ########################################################################## - # # - # Close VCS Canvas wrapper for VCS. # - # # + # # + # Close VCS Canvas wrapper for VCS. # + # # ########################################################################## def close(self, *args, **kargs): """ @@ -3938,9 +3938,9 @@ def close(self, *args, **kargs): return a ########################################################################## - # # - # Destroy VCS Canvas Object (i.e., call the Dealloc C code). # - # # + # # + # Destroy VCS Canvas Object (i.e., call the Dealloc C code). # + # # ########################################################################## def destroy(self): """ @@ -3962,9 +3962,9 @@ def destroy(self): gc.collect() ########################################################################## - # # - # Graphics Method Change display. # - # # + # # + # Graphics Method Change display. # + # # ########################################################################## def change_display_graphic_method(self, display, type, name): ''' @@ -3977,9 +3977,9 @@ def change_display_graphic_method(self, display, type, name): return self.canvas.change_display_graphic_method( *(display, type, name)) ########################################################################## - # # - # Figures out which display is selected in graphic method editor mode # - # # + # # + # Figures out which display is selected in graphic method editor mode # + # # ########################################################################## def get_selected_display(self): @@ -3990,9 +3990,9 @@ def get_selected_display(self): return self.canvas.get_selected_display(*()) ########################################################################## - # # - # Send a request to turn on a picture template object in the VCS Canvas. # - # # + # # + # Send a request to turn on a picture template object in the VCS Canvas. # + # # ########################################################################## def _select_one(self, template_name, attr_name, X1, X2, Y1, Y2): # flush and block the X main loop @@ -4000,19 +4000,19 @@ def _select_one(self, template_name, attr_name, X1, X2, Y1, Y2): self.canvas._select_one(template_name, attr_name, X1, X2, Y1, Y2) ########################################################################## - # # - # Send a request to turn off a picture template object in the VCS Canvas. # - # # + # # + # Send a request to turn off a picture template object in the VCS Canvas.# + # # ########################################################################## def _unselect_one(self, template_name, attr_name, X1, X2, Y1, Y2): self.canvas._unselect_one(template_name, attr_name, X1, X2, Y1, Y2) ########################################################################## - # # - # Set the template editor event flag to select all template objects on the # - # VCS Canvas. # - # # + # # + # Set the template editor event flag to select all template objects on # + # the VCS Canvas. # + # # ########################################################################## def _select_all(self): # flush and block the X main loop @@ -4020,10 +4020,10 @@ def _select_all(self): self.canvas._select_all() ########################################################################## - # # - # Set the template editor event flag to unselect all the template objects # - # on the VCS Canvas. # - # # + # # + # Set the template editor event flag to unselect all the template # + # objects on the VCS Canvas. # + # # ########################################################################## def _unselect_all(self): # flush and block the X main loop @@ -4031,57 +4031,57 @@ def _unselect_all(self): self.canvas._unselect_all() ########################################################################## - # # - # Set the template editor mode for the VCS Canvas screen. # - # # + # # + # Set the template editor mode for the VCS Canvas screen. # + # # ########################################################################## def _SCREEN_TEMPLATE_FLAG(self): self.canvas.SCREEN_TEMPLATE_FLAG() ########################################################################## - # # - # Set the graphic method editor mode for the VCS Canvas screen. # - # # + # # + # Set the graphic method editor mode for the VCS Canvas screen. # + # # ########################################################################## def _SCREEN_GM_FLAG(self): self.canvas.SCREEN_GM_FLAG() ########################################################################## - # # - # Set the data mode for the VCS Canvas screen. # - # # + # # + # Set the data mode for the VCS Canvas screen. # + # # ########################################################################## def _SCREEN_DATA_FLAG(self): self.canvas.SCREEN_DATA_FLAG() ########################################################################## - # # - # Set the screen check mode to DATA for the VCS Canvas. # - # # + # # + # Set the screen check mode to DATA for the VCS Canvas. # + # # ########################################################################## def _SCREEN_CHECKMODE_DATA_FLAG(self): self.canvas.SCREEN_CHECKMODE_DATA_FLAG() ########################################################################## - # # - # Return the Screen mode, either data mode or template editor mode. # - # # + # # + # Return the Screen mode, either data mode or template editor mode. # + # # ########################################################################## def SCREEN_MODE(self, *args): return self.canvas.SCREEN_MODE(*args) ########################################################################## - # # - # Return the Screen mode, either data mode or template editor mode. # - # # + # # + # Return the Screen mode, either data mode or template editor mode. # + # # ########################################################################## def plot_annotation(self, *args): self.canvas.plot_annotation(*args) ########################################################################## - # # - # Flush X event que wrapper for VCS. # - # # + # # + # Flush X event que wrapper for VCS. # + # # ########################################################################## def flush(self, *args): """ @@ -4099,9 +4099,9 @@ def flush(self, *args): return self.backend.flush(*args) ########################################################################## - # # - # Geometry wrapper for VCS. # - # # + # # + # Geometry wrapper for VCS. # + # # ########################################################################## def geometry(self, *args): """ @@ -4129,9 +4129,9 @@ def geometry(self, *args): return a ########################################################################## - # # - # VCS Canvas Information wrapper. # - # # + # # + # VCS Canvas Information wrapper. # + # # ########################################################################## def canvasinfo(self, *args, **kargs): """ @@ -4149,9 +4149,9 @@ def canvasinfo(self, *args, **kargs): return self.backend.canvasinfo(*args, **kargs) ########################################################################## - # # - # Get continents type wrapper for VCS. # - # # + # # + # Get continents type wrapper for VCS. # + # # ########################################################################## def getcontinentstype(self, *args): """ @@ -4219,9 +4219,9 @@ def pstogif(self, filename, *opt): return ########################################################################## - # # - # Grid wrapper for VCS. # - # # + # # + # Grid wrapper for VCS. # + # # ########################################################################## def grid(self, *args): """ @@ -4243,9 +4243,9 @@ def grid(self, *args): return p ########################################################################## - # # - # Landscape VCS Canvas orientation wrapper for VCS. # - # # + # # + # Landscape VCS Canvas orientation wrapper for VCS. # + # # ########################################################################## def landscape(self, width=-99, height=-99, x=-99, y=-99, clear=0): """ @@ -4305,9 +4305,9 @@ def landscape(self, width=-99, height=-99, x=-99, y=-99, clear=0): return l ########################################################################## - # # - # List Primary and Secondary elements wrapper for VCS. # - # # + # # + # List Primary and Secondary elements wrapper for VCS. # + # # ########################################################################## def listelements(self, *args): """ @@ -4331,9 +4331,9 @@ def listelements(self, *args): return L ########################################################################## - # # - # update VCS's Canvas orientation wrapper for VCS. # - # # + # # + # update VCS's Canvas orientation wrapper for VCS. # + # # ########################################################################## def updateorientation(self, *args): """ @@ -4347,9 +4347,9 @@ def updateorientation(self, *args): return a ########################################################################## - # # - # Open VCS Canvas wrapper for VCS. # - # # + # # + # Open VCS Canvas wrapper for VCS. # + # # ########################################################################## def open(self, width=None, height=None, **kargs): """ @@ -4370,9 +4370,9 @@ def open(self, width=None, height=None, **kargs): return a ########################################################################## - # # - # Return VCS Canvas ID. # - # # + # # + # Return VCS Canvas ID. # + # # ########################################################################## def canvasid(self, *args): ''' @@ -4390,17 +4390,18 @@ def canvasid(self, *args): return self._canvas_id ########################################################################## - # # - # Connect the VCS Canvas to the GUI. # - # # + # # + # Connect the VCS Canvas to the GUI. # + # # ########################################################################## def _connect_gui_and_canvas(self, *args): return self.canvas.connect_gui_and_canvas(*args) ########################################################################## - # # - # Page VCS Canvas orientation ('portrait' or 'landscape') wrapper for VCS. # - # # + # # + # Page VCS Canvas orientation ('portrait' or 'landscape') wrapper for # + # VCS. # + # # ########################################################################## def page(self, *args): """ @@ -4424,9 +4425,9 @@ def page(self, *args): return l ########################################################################## - # # - # Portrait VCS Canvas orientation wrapper for VCS. # - # # + # # + # Portrait VCS Canvas orientation wrapper for VCS. # + # # ########################################################################## def portrait(self, width=-99, height=-99, x=-99, y=-99, clear=0): """ @@ -4676,11 +4677,12 @@ def png(self, file, width=None, height=None, file, W, H, units, draw_white_background, **args) ########################################################################## - # # - # pdf wrapper for VCS. # - # # + # # + # pdf wrapper for VCS. # + # # ########################################################################## - def pdf(self, file, width=None, height=None, units='inches'): + def pdf(self, file, width=None, height=None, units='inches', + textAsPaths=True): """ Function: postscript @@ -4704,14 +4706,15 @@ def pdf(self, file, width=None, height=None, units='inches'): if not file.split('.')[-1].lower() in ['pdf']: file += '.pdf' - return self.backend.pdf(file, W, H) + return self.backend.pdf(file, W, H, textAsPaths) ########################################################################## - # # - # SVG wrapper for VCS. # - # # + # # + # SVG wrapper for VCS. # + # # ########################################################################## - def svg(self, file, width=None, height=None, units='inches'): + def svg(self, file, width=None, height=None, units='inches', + textAsPaths=True): """ Function: postscript @@ -4735,7 +4738,7 @@ def svg(self, file, width=None, height=None, units='inches'): if not file.split('.')[-1].lower() in ['svg']: file += '.svg' - return self.backend.svg(file, W, H) + return self.backend.svg(file, W, H, textAsPaths) def _compute_margins( self, W, H, top_margin, bottom_margin, right_margin, left_margin, dpi): @@ -4910,8 +4913,9 @@ def _compute_width_height(self, width, height, units, ps=False): H = tmp return W, H + def postscript(self, file, mode='r', orientation=None, width=None, height=None, - units='inches'): + units='inches', textAsPaths=True): """ Function: postscript @@ -4950,7 +4954,7 @@ def postscript(self, file, mode='r', orientation=None, width=None, height=None, if not file.split('.')[-1].lower() in ['ps', 'eps']: file += '.ps' if mode == 'r': - return self.backend.postscript(file, W, H, units="pixels") + return self.backend.postscript(file, W, H, units="pixels", textAsPaths=textAsPaths) else: n = random.randint(0, 10000000000000) psnm = '/tmp/' + '__VCS__tmp__' + str(n) + '.ps' @@ -4967,9 +4971,9 @@ def postscript(self, file, mode='r', orientation=None, width=None, height=None, shutil.move(psnm, file) ########################################################################## - # # - # Showbg wrapper for VCS. # - # # + # # + # Showbg wrapper for VCS. # + # # ########################################################################## def showbg(self, *args): """ @@ -4992,9 +4996,9 @@ def showbg(self, *args): return a ########################################################################## - # # - # Backing Store wrapper for VCS. # - # # + # # + # Backing Store wrapper for VCS. # + # # ########################################################################## def backing_store(self, *args): """ @@ -5010,25 +5014,25 @@ def backing_store(self, *args): return self.canvas.backing_store(*args) ########################################################################## - # # - # Update the animation slab. Used only for the VCS Canvas GUI. # - # # + # # + # Update the animation slab. Used only for the VCS Canvas GUI. # + # # ########################################################################## def update_animation_data(self, *args): return self.canvas.update_animation_data(*args) ########################################################################## - # # - # Return the dimension information. Used only for the VCS Canvas GUI. # - # # + # # + # Return the dimension information. Used only for the VCS Canvas GUI. # + # # ########################################################################## def return_dimension_info(self, *args): return self.canvas.return_dimension_info(*args) ########################################################################## - # # - # Raster wrapper for VCS. # - # # + # # + # Raster wrapper for VCS. # + # # ########################################################################## def raster(self, file, mode='a'): """ @@ -5058,9 +5062,9 @@ def raster(self, file, mode='a'): return self.canvas.raster(*(file, mode)) ########################################################################## - # # - # Reset grid wrapper for VCS. # - # # + # # + # Reset grid wrapper for VCS. # + # # ########################################################################## def resetgrid(self, *args): """ @@ -5075,9 +5079,9 @@ def resetgrid(self, *args): return self.canvas.resetgrid(*args) ########################################################################## - # # - # Script wrapper for VCS. # - # # + # # + # Script wrapper for VCS. # + # # ########################################################################## def _scriptrun(self, *args): return vcs._scriptrun(*args) @@ -5086,9 +5090,9 @@ def scriptrun(self, aFile, *args, **kargs): vcs.scriptrun(aFile, *args, **kargs) ########################################################################## - # # - # Set default graphics method and template wrapper for VCS. # - # # + # # + # Set default graphics method and template wrapper for VCS. # + # # ########################################################################## def set(self, *args): """ @@ -5108,9 +5112,9 @@ def set(self, *args): return self.canvas.set(*args) ########################################################################## - # # - # Set VCS color map wrapper for VCS. # - # # + # # + # Set VCS color map wrapper for VCS. # + # # ########################################################################## def setcolormap(self, name): """ @@ -5140,9 +5144,9 @@ def setcolormap(self, name): return ########################################################################## - # # - # Set VCS color map cell wrapper for VCS. # - # # + # # + # Set VCS color map cell wrapper for VCS. # + # # ########################################################################## def setcolorcell(self, *args): """ @@ -5209,7 +5213,7 @@ def getcontinentsline(self): ########################################################################## # # - # Set continents type wrapper for VCS. # + # Set continents type wrapper for VCS. # # # ########################################################################## def setcontinentstype(self, value): @@ -5312,9 +5316,9 @@ def gif(self, filename='noname.gif', merge='r', orientation=None, return self.backend.gif(nargs) ########################################################################## - # # - # Screen GhostScript (gs) wrapper for VCS. # - # # + # # + # Screen GhostScript (gs) wrapper for VCS. # + # # ########################################################################## def gs(self, filename='noname.gs', device='png256', orientation=None, resolution='792x612'): @@ -5322,12 +5326,12 @@ def gs(self, filename='noname.gs', device='png256', warnings.warn("Export to GhostScript is no longer supported", DeprecationWarning) ########################################################################## - # # - # Screen Encapsulated PostScript wrapper for VCS. # - # # + # # + # Screen Encapsulated PostScript wrapper for VCS. # + # # ########################################################################## - def eps(self, file, mode='r', orientation=None, width=None, height=None, units='inches', - left_margin=None, right_margin=None, top_margin=None, bottom_margin=None): + def eps(self, file, mode='r', orientation=None, width=None, height=None, + units='inches', textAsPaths=True): """ Function: Encapsulated PostScript @@ -5365,26 +5369,24 @@ def eps(self, file, mode='r', orientation=None, width=None, height=None, units=' width, height, units, - left_margin, - right_margin, - top_margin, - bottom_margin) + textAsPaths) + os.popen("ps2epsi %s %s" % (tmpfile, file)).readlines() os.remove(tmpfile) ########################################################################## - # # - # Show VCS primary and secondary elements wrapper for VCS. # - # # + # # + # Show VCS primary and secondary elements wrapper for VCS. # + # # ########################################################################## def show(self, *args): return vcs.show(*args) show.__doc__ = vcs.__doc__ ########################################################################## - # # - # Look if a graphic method is in a file . # - # # + # # + # Look if a graphic method is in a file . # + # # ########################################################################## def isinfile(self, GM, file=None): """ Checks if a graphic method is stored in a file @@ -5404,9 +5406,9 @@ def isinfile(self, GM, file=None): return 1 return 0 ########################################################################## - # # - # Save VCS initial.attribute file wrapper for VCS. # - # # + # # + # Save VCS initial.attribute file wrapper for VCS. # + # # ########################################################################## def saveinitialfile(self): @@ -5443,9 +5445,9 @@ def saveinitialfile(self): return vcs.saveinitialfile() ########################################################################## - # # - # Raise VCS Canvas to the top of all its siblings. # - # # + # # + # Raise VCS Canvas to the top of all its siblings. # + # # ########################################################################## def canvasraised(self, *args): """ @@ -5465,10 +5467,10 @@ def canvasraised(self, *args): return self.backend.canvasraised(*args) ########################################################################## - # # - # Returns 1 if a VCS Canvas is displayed on the screen. Returns a 0 if no # - # VCS Canvas is displayed on the screen. # - # # + # # + # Returns 1 if a VCS Canvas is displayed on the screen. Returns a 0 if no# + # VCS Canvas is displayed on the screen. # + # # ########################################################################## def iscanvasdisplayed(self, *args): """ @@ -5488,9 +5490,9 @@ def iscanvasdisplayed(self, *args): return self.canvas.iscanvasdisplayed(*args) ########################################################################## - # # - # Is VCS's orientation landscape? # - # # + # # + # Is VCS's orientation landscape? # + # # ########################################################################## def islandscape(self): """ @@ -5515,9 +5517,9 @@ def islandscape(self): return 0 ########################################################################## - # # - # Is VCS's orientation portrait? # - # # + # # + # Is VCS's orientation portrait? # + # # ########################################################################## def isportrait(self): """ @@ -5541,9 +5543,9 @@ def isportrait(self): else: return 0 ########################################################################## - # # - # Dislplay plot functions for VCS. # - # # + # # + # Dislplay plot functions for VCS. # + # # ########################################################################## def getplot(self, Dp_name_src='default', template=None): @@ -5570,9 +5572,9 @@ def getplot(self, Dp_name_src='default', template=None): return display ########################################################################## - # # - # Colormap functions for VCS. # - # # + # # + # Colormap functions for VCS. # + # # ########################################################################## def createcolormap(self, Cp_name=None, Cp_name_src='default'): return vcs.createcolormap(Cp_name, Cp_name_src) @@ -5583,9 +5585,9 @@ def getcolormap(self, Cp_name_src='default'): getcolormap.__doc__ = vcs.manageElements.getcolormap.__doc__ ########################################################################## - # # - # Font functions. # - # # + # # + # Font functions. # + # # ########################################################################## def addfont(self, path, name=""): """ @@ -5698,9 +5700,9 @@ def setdefaultfont(self, font): return self.copyfontto(font, 1) ########################################################################## - # # - # Orientation VCS Canvas orientation wrapper for VCS. # - # # + # # + # Orientation VCS Canvas orientation wrapper for VCS. # + # # ########################################################################## def orientation(self, *args, **kargs): """ @@ -5716,9 +5718,9 @@ def orientation(self, *args, **kargs): return self.backend.orientation(*args, **kargs) ########################################################################## - # # - # Get VCS color map cell wrapper for VCS. # - # # + # # + # Get VCS color map cell wrapper for VCS. # + # # ########################################################################## def getcolorcell(self, *args): """ @@ -5750,9 +5752,9 @@ def getcolorcell(self, *args): return vcs.getcolorcell(args[0], self) ########################################################################## - # # - # Get VCS color map name wrapper for VCS. # - # # + # # + # Get VCS color map name wrapper for VCS. # + # # ########################################################################## def getcolormapname(self, *args): """ diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py index 9d3d85c748..33d30434f8 100644 --- a/Packages/vcs/vcs/VTKPlots.py +++ b/Packages/vcs/vcs/VTKPlots.py @@ -1063,8 +1063,28 @@ def get3DPlot(self): break return plot - def vectorGraphics( - self, output_type, file, width=None, height=None, units=None): + def vectorGraphics(self, output_type, file, width=None, height=None, + units=None, textAsPaths=True): + """Export vector graphics to PDF, Postscript, SVG and EPS format. + + Reasoning for textAsPaths as default: + The output formats supported by gl2ps which VTK uses for postscript/pdf/svg/etc + vector exports) handle text objects inconsistently. For example, postscript mangles + newlines, pdf doesn't fully support rotation and alignment, stuff like that. + These are limitations in the actual format specifications themselves. + + On top of that, embedding text objects then relies on the viewer to locate + a similar font and render the text, and odds are good that the fonts used + by the viewer will have different characteristics than the ones used in the + original rendering. So, for instance, you have some right-justified lines of + text, like the data at the top of the VCS plots. If the font used by the viewer + uses different widths for any of glyphs composing the text, the text will be + unaligned along the right-hand side, since the text is always anchored on + it's left side due to how these formats represent text objects. This just looks bad. + Exporting text as paths eliminates all of these problems with portability across + viewers and inconsistent text object handling between output formats. + """ + if self.renWin is None: raise Exception("Nothing on Canvas to dump to file") @@ -1095,7 +1115,11 @@ def vectorGraphics( gl.SetInput(self.renWin) gl.SetCompress(0) # Do not compress gl.SetFilePrefix(".".join(file.split(".")[:-1])) - gl.TextAsPathOn() + + if textAsPaths: + gl.TextAsPathOff() + else: + gl.TextAsPathOn() if output_type == "svg": gl.SetFileFormatToSVG() elif output_type == "ps": @@ -1112,14 +1136,17 @@ def vectorGraphics( self.showGUI() def postscript(self, file, width=None, height=None, - units=None): - return self.vectorGraphics("ps", file, width, height, units) + units=None, textAsPaths=True): + return self.vectorGraphics("ps", file, width, height, + units, textAsPaths) - def pdf(self, file, width=None, height=None, units=None): - return self.vectorGraphics("pdf", file, width, height, units) + def pdf(self, file, width=None, height=None, units=None, textAsPaths=True): + return self.vectorGraphics("pdf", file, width, height, + units, textAsPaths) - def svg(self, file, width=None, height=None, units=None): - return self.vectorGraphics("svg", file, width, height, units) + def svg(self, file, width=None, height=None, units=None, textAsPaths=True): + return self.vectorGraphics("svg", file, width, + height, units, textAsPaths) def gif(self, filename='noname.gif', merge='r', orientation=None, geometry='1600x1200'): diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index d32e9cb909..85b2ee5e26 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -400,6 +400,10 @@ cdat_add_test(test_vcs_geometry "${PYTHON_EXECUTABLE}" ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_geometry.py ) +cdat_add_test(test_vcs_export_text + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_export_text.py + ) ############################################################################## # # These tests perform plotting and need sample data diff --git a/testing/vcs/test_vcs_export_text.py b/testing/vcs/test_vcs_export_text.py new file mode 100644 index 0000000000..d4507e3d80 --- /dev/null +++ b/testing/vcs/test_vcs_export_text.py @@ -0,0 +1,51 @@ +import cdms2, vcs, tempfile + +x = vcs.init(bg=1, geometry=(800, 600)) +txt = x.createtext() +txt.x = [0.2, 0.2, 0.5, 0.8, 0.8] +txt.y = [0.2, 0.8, 0.5, 0.8, 0.2] +txt.string = ["SAMPLE TEXT A","SAMPLE TEXT B","SAMPLE TEXT C","SAMPLE TEXT D","SAMPLE TEXT E"] +txt.halign = "center" +txt.valign = "base" +txt.height = 10 +x.plot(txt) + +tmpfile = tempfile.NamedTemporaryFile(suffix='.ps', \ + prefix='textAsPathsFalse', delete=False) +x.postscript(tmpfile.name, textAsPaths=False) +tmpfile.close() + +tmpfile = tempfile.NamedTemporaryFile(suffix='.ps', \ + prefix='textAsPathsTrue', delete=False) +x.postscript(tmpfile.name, textAsPaths=True) +tmpfile.close() + +tmpfile = tempfile.NamedTemporaryFile(suffix='.pdf', \ + prefix='textAsPathsFalse', delete=False) +x.pdf(tmpfile.name, textAsPaths=False) +tmpfile.close() + +tmpfile = tempfile.NamedTemporaryFile(suffix='.pdf', \ + prefix='textAsPathsTrue', delete=False) +x.pdf(tmpfile.name, textAsPaths=True) +tmpfile.close() + +tmpfile = tempfile.NamedTemporaryFile(suffix='.svg', \ + prefix='textAsPathsFalse', delete=False) +x.svg(tmpfile.name, textAsPaths=False) +tmpfile.close() + +tmpfile = tempfile.NamedTemporaryFile(suffix='.svg', \ + prefix='textAsPathsTrue', delete=False) +x.svg(tmpfile.name, textAsPaths=True) +tmpfile.close() + +tmpfile = tempfile.NamedTemporaryFile(suffix='.eps', \ + prefix='textAsPathsFalse', delete=False) +x.eps(tmpfile.name, textAsPaths=False) +tmpfile.close() + +tmpfile = tempfile.NamedTemporaryFile(suffix='.eps', \ + prefix='textAsPathsTrue', delete=False) +x.eps(tmpfile.name, textAsPaths=True) +tmpfile.close() \ No newline at end of file