Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Packages/vcs/Lib/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3686,7 +3686,7 @@ def set_convert_labels(copy_mthd,test=0):

# Now executes output commands
for cc in cmds.keys():
c=string.lower(cc)
c=cc.lower()
if type(cmds[cc])!=type(''):
args=tuple(cmds[cc])
else:
Expand Down Expand Up @@ -5517,7 +5517,7 @@ def gif(self, filename='noname.gif', merge='r', orientation=None, geometry='1600
""" % (self._dotdir)
if orientation is None:
orientation=self.orientation()[0]
g = string.split(geometry,'x')
g = geometry.split('x')
f1 = f1=float(g[0]) / 1100.0 * 100.0
f2 = f2=float(g[1]) / 849.85 * 100.0
geometry = "%4.1fx%4.1f" % (f2,f1)
Expand Down Expand Up @@ -5566,7 +5566,7 @@ def gs(self, filename='noname.gs', device='png256', orientation=None, resolution
""" % (self._dotdir)
if orientation is None:
orientation=self.orientation()[0]
r = string.split(resolution,'x')
r = resolution.split('x')
f1 = f1=float(r[0]) / 1100.0 * 100.0
f2 = f2=float(r[1]) / 849.85 * 100.0
resolution = "%4.1fx%4.1f" % (f2,f1)
Expand Down
2 changes: 1 addition & 1 deletion Packages/vcs/Lib/Pboxeslines.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# Template text (Pbl) Class. #
# #
#############################################################################
class Pbl:
class Pbl(object):
'''
Class: Pbl # Template text

Expand Down
3 changes: 3 additions & 0 deletions Packages/vcs/Lib/VTKPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,9 @@ def pdf(self, file, width=None, height=None, units=None):
def svg(self, file, width=None, height=None, units=None):
return self.vectorGraphics("svg", file, width, height, units)

def gif(self,filename='noname.gif', merge='r', orientation=None, geometry='1600x1200'):
raise RuntimeError("gif method not implemented in VTK backend yet")

def png(self, file, width=None,height=None,units=None,draw_white_background = True, **args ):

if self.renWin is None:
Expand Down
8 changes: 4 additions & 4 deletions Packages/vcs/Lib/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,24 +1049,24 @@ def reset(self,sub_name,v1,v2,ov1=None,ov2=None):
ov=getattr(v,sub_name+'1')
if ov1 is not None:
delta=(ov-ov1)*ratio
setattr(v,sub_name+'1',v1+delta)
setattr(v,sub_name+'1',min(1,max(0,v1+delta)))
delta=0.
if sub_name+'2' in subattr:
ov=getattr(v,sub_name+'2')
if ov2 is not None:
delta=(ov-ov2)*ratio
setattr(v,sub_name+'2',v2+delta)
setattr(v,sub_name+'2',min(1,max(0,v2+delta)))
delta=0.
if sub_name in subattr:
ov=getattr(v,sub_name)
if ov1 is not None:
delta=(ov-ov1)*ratio
setattr(v,sub_name,v1+delta)
setattr(v,sub_name,min(1,max(0,v1+delta)))
if a[-1]=='2':
ov=getattr(v,sub_name+'2')
if ov2 is not None:
delta=(ov-ov2)*ratio
setattr(v,sub_name,v2+delta)
setattr(v,sub_name,min(1,max(0,v2+delta)))
except Exception,err:
pass

Expand Down
13 changes: 7 additions & 6 deletions Packages/vcsaddons/Lib/Multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def clean(self):
self.x.removeP(t)
self.template_names=[]

def get(self,column=None,row=None,legend=None,font=True,fontlimit=0.):
def get(self,column=None,row=None,legend=None,font=True,fontlimit=0.8):
"""
Returns a template to use in vcs
Usage:
Expand Down Expand Up @@ -337,10 +337,10 @@ def get(self,column=None,row=None,legend=None,font=True,fontlimit=0.):
dx=self.legend.stretch
dy=self.legend.thickness
## print x1,x2,y1,y2,dx,dy
t.legend.x1=x1+(x2-x1)*(1.-dx)/2.
t.legend.x2=x2-(x2-x1)*(1.-dx)/2.
t.legend.y1=y1+(y2-y1)*(1.-dy)/2.
t.legend.y2=y2-(y2-y1)*(1.-dy)/2.
t.legend.x1=min(1,max(0,x1+(x2-x1)*(1.-dx)/2.))
t.legend.x2=min(1,max(0,x2-(x2-x1)*(1.-dx)/2.))
t.legend.y1=min(1,max(0,y1+(y2-y1)*(1.-dy)/2.))
t.legend.y2=min(1,max(0,y2-(y2-y1)*(1.-dy)/2.))
return t

def preview(self,out='EZTemplate_Multi',bg=1):
Expand Down Expand Up @@ -386,7 +386,8 @@ def preview(self,out='EZTemplate_Multi',bg=1):


self.x.postscript(out)
self.x.gif(out)
self.x.pdf(out)
self.x.png(out)



Expand Down
1 change: 1 addition & 0 deletions testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if (CDAT_BUILD_VCS_LEGACY)
add_subdirectory(vcs_legacy)
endif()
add_subdirectory(vcs)
add_subdirectory(vcsaddons)
add_subdirectory(dv3d)
add_subdirectory(cdutil)
add_subdirectory(cdms2)
Expand Down
45 changes: 45 additions & 0 deletions testing/vcsaddons/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
set(BASELINE_DIR "${UVCDAT_GIT_TESTDATA_DIR}/baselines/vcsaddons")

add_test(vcs_addons_preview_2x2
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_vcsaddons_preview_2x2.py
${BASELINE_DIR}/test_vcsaddons_preview_2x2.png
)
add_test(vcs_addons_test_12_plot_one_leg_per_row
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_12_plot_one_leg_per_row.py
${BASELINE_DIR}/test_12_plot_one_leg_per_row.png
)
add_test(vcs_addons_test_12_plot_one_leg_per_row_right
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py
${BASELINE_DIR}/test_12_plot_one_leg_per_row_right.png
)
add_test(vcs_addons_test_EzTemplate_12_plots_margins_thickness
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py
${BASELINE_DIR}/test_EzTemplate_12_plots_margins_thickness.png
)
add_test(vcs_addons_test_EzTemplate_12_plots_legd_direction
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py
${BASELINE_DIR}/test_EzTemplate_12_plots_legd_direction.png
)
add_test(vcs_addons_test_EzTemplate_12_plots_mix_glb_local
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py
${BASELINE_DIR}/test_EzTemplate_12_plots_mix_glb_local.png
)
add_test(vcs_addons_test_EzTemplate_12_plots_spacing
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py
${BASELINE_DIR}/test_EzTemplate_12_plots_spacing.png
)

if (CDAT_DOWNLOAD_SAMPLE_DATA)
add_test(vcs_addons_EzTemplate_2x2
${CMAKE_INSTALL_PREFIX}/bin/python
${cdat_SOURCE_DIR}/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py
${BASELINE_DIR}/test_vcs_addons_EzTemplate_2x2.png
)
endif()
26 changes: 26 additions & 0 deletions testing/vcsaddons/test_12_plot_one_leg_per_row.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage
import EzTemplate,vcs
## 12 plot one legend per row

## Initialize VCS
x=vcs.init()

bg = True
M=EzTemplate.Multi(rows=4,columns=3)
M.legend.stretch=2.5 # 250% of width (for middle one)
for i in range(12):
t=M.get(legend='local')
if i%3 !=1:
t.legend.priority=0 # Turn off legend
fnm = "test_12_plot_one_leg_per_row.png"
M.preview(fnm,bg=bg)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)
25 changes: 25 additions & 0 deletions testing/vcsaddons/test_12_plot_one_leg_per_row_right.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage
import EzTemplate,vcs
import cdms,EzTemplate,vcs,sys
## 12 plots 1 legend per row on the right
## Initialize VCS
x=vcs.init()
bg=True
M=EzTemplate.Multi(rows=4,columns=3)
M.legend.direction='vertical'
for i in range(12):
t=M.get(legend='local')
if i%3 !=2:
t.legend.priority=0 # Turn off legend
fnm = "test_12_plot_one_leg_per_row_right.png"
M.preview(fnm,bg=bg)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)
33 changes: 33 additions & 0 deletions testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage
import EzTemplate,vcs
## 12 plot one legend per row

## Initialize VCS
x=vcs.init()

bg = True
M=EzTemplate.Multi(rows=4,columns=3)
M.margins.top=.25
M.margins.bottom=.25
M.margins.left=.25
M.margins.right=.25

M.legend.direction='vertical'
## The legend uses the right margin for display are
## We need to "shrink it"
M.legend.thickness=.05
for i in range(12):
t=M.get()

fnm = "test_EzTemplate_12_plots_legd_direction.png"
M.preview(fnm,bg=bg)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)
31 changes: 31 additions & 0 deletions testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage
import EzTemplate,vcs
## 12 plot one legend per row

## Initialize VCS
x=vcs.init()

bg = True
M=EzTemplate.Multi(rows=4,columns=3)
M.margins.top=.25
M.margins.bottom=.25
M.margins.left=.25
M.margins.right=.25

## The legend uses the bottom margin for display are
## We need to "shrink it"
M.legend.thickness=.1
for i in range(12):
t=M.get()
fnm = "test_EzTemplate_12_plots_margins_thickness.png"
M.preview(fnm,bg=bg)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)
30 changes: 30 additions & 0 deletions testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage
import EzTemplate,vcs
## 12 plot one legend per row

## Initialize VCS
x=vcs.init()

bg = True
M=EzTemplate.Multi(rows=4,columns=3)
for i in range(12):
if i%2==1:
if i%4 == 3:
M.legend.direction='vertical'
t=M.get(legend='local')
M.legend.direction='horizontal'
else:
t=M.get()

fnm = "test_EzTemplate_12_plots_mix_glb_local.png"
M.preview(fnm,bg=bg)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)
24 changes: 24 additions & 0 deletions testing/vcsaddons/test_EzTemplate_12_plots_spacing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage
import EzTemplate,vcs
## 12 plot one legend per row

## Initialize VCS
x=vcs.init()

bg = True
M=EzTemplate.Multi(rows=4,columns=3)
M.spacing.horizontal=.25
M.spacing.vertical=.1

fnm = "test_EzTemplate_12_plots_spacing.png"
M.preview(fnm,bg=bg)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)
30 changes: 30 additions & 0 deletions testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage

import vcs
import vcsaddons
import cdms2

f=cdms2.open(os.path.join(sys.prefix,'sample_data','clt.nc'))
s=f("clt",time=slice(0,1),squeeze=1)

bg = True

M=vcsaddons.EzTemplate.Multi(rows=2,columns=2)
x=vcs.init()
if bg:
x.setbgoutputdimensions(1200,1091,units="pixels")
for i in range(4):
x.plot(s,M.get(),bg=bg)

fnm = "test_vcs_addons_EzTemplate_2x2.png"
x.png(fnm)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)
21 changes: 21 additions & 0 deletions testing/vcsaddons/test_vcsaddons_preview_2x2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys,os
src = sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage

import vcsaddons

bg = True

M=vcsaddons.EzTemplate.Multi(rows=2,columns=2)
if bg:
M.x.setbgoutputdimensions(1200,1091,units="pixels")
fnm = "test_vcsaddons_preview_2x2.png"
M.preview(out=fnm,bg=bg)
print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
if not bg:
raw_input("Press Enter")
sys.exit(ret)