Skip to content

Commit

Permalink
Merge pull request #1296 from UV-CDAT/sync_master
Browse files Browse the repository at this point in the history
Sync master
aashish24 committed May 8, 2015
2 parents 538cf4b + 8a9b545 commit b14e373
Showing 29 changed files with 514 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
os:
- linux
- osx
# - osx

language: c++

2 changes: 1 addition & 1 deletion CMake/cdat_modules/cdat_deps.cmake
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ set(CDAT_deps ${wget_pkg} ${python_pkg} ${numpy_pkg}
${libcdms_pkg}
${libcf_pkg} ${netcdf_pkg} ${myproxyclient_pkg} ${udunits2_pkg})
if (CDAT_BUILD_GRAPHICS)
if (CDAT_BUILD_PARALLEL)
if (CDAT_BUILD_PARAVIEW)
list(APPEND CDAT_deps ${paraview_pkg})
else()
list(APPEND CDAT_deps ${vtk_pkg})
4 changes: 4 additions & 0 deletions CMake/cdat_modules_extra/runtest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# source is not portable whereas . is
. "@CMAKE_INSTALL_PREFIX@/bin/setup_runtime.sh"
python@PYVER@ "$@"
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -284,6 +284,7 @@ option(CDAT_BUILD_GUI "Builds GUI-based dependencies (Vistrails, ParaView, VisIt
option(CDAT_BUILD_GRAPHICS "Build graphics-based dependencies (vcs, pyqt, Vistrails, ParaView, VisIt, R, etc.) " ON)
option(CDAT_BUILD_ESGF "Alias for CDAT_BUILD_LEAN" OFF)
option(CDAT_BUILD_UVCMETRICSPKG "Builds uvcmetrics package " ON)
option(CDAT_BUILD_PARAVIEW "Build ParaView rather than just VTK" OFF)

# If ESGF option is on then our build mode is LEAN.
if (CDAT_BUILD_ESGF)
@@ -498,7 +499,7 @@ include(osmesa_pkg)
include(python_pkg)
include(seawater_pkg)
include(vacumm_pkg)
if (CDAT_BUILD_PARALLEL)
if (CDAT_BUILD_PARAVIEW)
include(paraview_pkg)
else()
include(vtk_pkg)
@@ -729,6 +730,11 @@ configure_file(${cdat_CMAKE_SOURCE_DIR}/cdat_modules_extra/cdat.in
@ONLY
)

configure_file(${cdat_CMAKE_SOURCE_DIR}/cdat_modules_extra/runtest.in
${CMAKE_INSTALL_PREFIX}/bin/runtest
@ONLY
)


if (BUILD_TESTING)
configure_file(${cdat_CMAKE_SOURCE_DIR}/cdat_modules_extra/runpytest.in
101 changes: 67 additions & 34 deletions Packages/DV3D/MultiVarPointCollection.py
Original file line number Diff line number Diff line change
@@ -101,6 +101,7 @@ def getCoordIndex( self, var, coord ):
return axis_order.index(coord)
except ValueError, err:
print>>sys.stderr, "Can't find axis %s in axis order spec '%s' " % ( coord, axis_order )
return None


def getCoordDataBlock( self, var ):
@@ -109,42 +110,74 @@ def getCoordDataBlock( self, var ):
def getDataBlock( self, var ):
np_var_data_block = None
iTimeIndex = self.getCoordIndex( var, 't' )
if iTimeIndex <> 0:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
else:
if self.lev == None:
if len( var.shape ) == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep ].data
if self.roi_mask <> None:
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block )
elif len( var.shape ) == 3:
np_var_data_block = var[ self.iTimeStep, :, self.istart::self.istep ].data
np_var_data_block = np_var_data_block.reshape( [ np_var_data_block.shape[0] * np_var_data_block.shape[1], ] )
self.nLevels = 1
try:
if iTimeIndex > 0:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
elif iTimeIndex is None:
if self.lev == None:
if len( var.shape ) == 1:
np_var_data_block = var[ self.istart::self.istep ].data
if self.roi_mask <> None:
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block )
elif len( var.shape ) == 2:
np_var_data_block = var[ :, self.istart::self.istep ].data
np_var_data_block = np_var_data_block.reshape( [ np_var_data_block.shape[0] * np_var_data_block.shape[1], ] )
self.nLevels = 1
else:
iLevIndex = self.getCoordIndex( var, 'z' )
if len( var.shape ) == 2:
if iLevIndex == 0:
np_var_data_block = var[ :, self.istart::self.istep ].data
elif iLevIndex == 1:
np_var_data_block = var[ self.istart::self.istep, : ].data
np_var_data_block = numpy.swapaxes( np_var_data_block, 0, 1 )
else:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
if not isNone( np_var_data_block ):
if not isNone( self.roi_mask ):
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block, axis = 1 )
elif len( var.shape ) == 3:
lev_data_arrays = []
for ilev in range( var.shape[1] ):
data_z_slice = var[ ilev ].flatten()
lev_data_arrays.append( data_z_slice[self.istart::self.istep] )
np_var_data_block = numpy.concatenate( lev_data_arrays ).astype( numpy.float32 )
else:
iLevIndex = self.getCoordIndex( var, 'z' )
if len( var.shape ) == 3:
if iLevIndex == 1:
if self.lev == None:
if len( var.shape ) == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep ].data
if self.roi_mask <> None:
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block )
elif len( var.shape ) == 3:
np_var_data_block = var[ self.iTimeStep, :, self.istart::self.istep ].data
elif iLevIndex == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep, : ].data
np_var_data_block = numpy.swapaxes( np_var_data_block, 0, 1 )
else:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
if not isNone( np_var_data_block ):
if not isNone( self.roi_mask ):
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block, axis = 1 )
elif len( var.shape ) == 4:
lev_data_arrays = []
for ilev in range( var.shape[1] ):
data_z_slice = var[ self.iTimeStep, ilev ].flatten()
lev_data_arrays.append( data_z_slice[self.istart::self.istep] )
np_var_data_block = numpy.concatenate( lev_data_arrays ).astype( numpy.float32 )
# print " GetDataBlock, var.shape = %s, grid = %s, ts = %d, newshape = %s, type = %s " % ( str(var.shape), str((self.istart,self.istep)), self.iTimeStep, str(np_var_data_block.shape), np_var_data_block.__class__.__name__ )

if not isNone( np_var_data_block ):
if self.missing_value: np_var_data_block = numpy.ma.masked_equal( np_var_data_block, self.missing_value, False ).flatten()
else: np_var_data_block = np_var_data_block.flatten()
np_var_data_block = np_var_data_block.reshape( [ np_var_data_block.shape[0] * np_var_data_block.shape[1], ] )
self.nLevels = 1
else:
iLevIndex = self.getCoordIndex( var, 'z' )
if len( var.shape ) == 3:
if iLevIndex == 1:
np_var_data_block = var[ self.iTimeStep, :, self.istart::self.istep ].data
elif iLevIndex == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep, : ].data
np_var_data_block = numpy.swapaxes( np_var_data_block, 0, 1 )
else:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
if not isNone( np_var_data_block ):
if not isNone( self.roi_mask ):
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block, axis = 1 )
elif len( var.shape ) == 4:
lev_data_arrays = []
for ilev in range( var.shape[1] ):
data_z_slice = var[ self.iTimeStep, ilev ].flatten()
lev_data_arrays.append( data_z_slice[self.istart::self.istep] )
np_var_data_block = numpy.concatenate( lev_data_arrays ).astype( numpy.float32 )
except Exception, err:
print " Error in GetDataBlock, var.shape = %s, grid = %s, ts = %d " % ( str(var.shape), str((self.istart,self.istep)), self.iTimeStep )
print str(err)

if not isNone( np_var_data_block ):
if self.missing_value: np_var_data_block = numpy.ma.masked_equal( np_var_data_block, self.missing_value, False ).flatten()
else: np_var_data_block = np_var_data_block.flatten()

return np_var_data_block

11 changes: 5 additions & 6 deletions Packages/DV3D/StructuredVariableReader.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@
from StructuredDataset import *

def getVarName( var ):
if hasattr( var,'outvar'): return var.outvar.name
if hasattr( var,'name'): return var.name
if hasattr( var,'name_in_file'): return var.name_in_file
if hasattr( var,'id'): return var.id
@@ -110,10 +109,10 @@ def __init__(self, **args):
self.varSpecs = [ var.name_in_file for var in self.vars ]
self.df = cdms2.open( self.fileSpecs )
else:
self.varSpecs = [ var.name for var in self.vars ]
self.varSpecs = [ var.id for var in self.vars ]
plot_attributes = args.get( 'plot_attributes', None )
if plot_attributes <> None:
self.datasetId = plot_attributes.get( 'filename', self.vars[0].name )
self.datasetId = plot_attributes.get( 'filename', self.vars[0].id )
for file_attribute_name in ['url', 'filename', 'file' ]:
self.fileSpecs = plot_attributes.get( file_attribute_name, None )
if self.fileSpecs <> None: break
@@ -122,8 +121,8 @@ def __init__(self, **args):
print>>sys.stderr, "Warning, can't open data file '%s'" % self.fileSpecs
self.df = None
else:
self.datasetId = self.vars[0].name
self.fileSpecs = self.vars[0].name
self.datasetId = self.vars[0].id
self.fileSpecs = self.vars[0].id
self.df = None

self.referenceTimeUnits = None
@@ -371,7 +370,7 @@ def getPortData( self, **args ):

def generateVariableOutput( self, cdms_var ):
print str(cdms_var.var)
self.set3DOutput( name=cdms_var.name, output=cdms_var.var )
self.set3DOutput( name=cdms_var.id, output=cdms_var.var )

def refreshVersion(self):
portData = self.getPortData()
16 changes: 16 additions & 0 deletions Packages/DV3D/demo/demo_plots/gallery_vector_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import vcs, cdms2, sys

x = vcs.init()
f = cdms2.open( sys.prefix+"/sample_data/geos5-sample.nc" )
dv3d = vcs.get3d_vector()
dv3d.VerticalScaling = 4.0
dv3d.BasemapOpacity = 0.5
dv3d.ScaleColormap = [50.0, 75.0, 1]
dv3d.ZSlider = [26.0], vcs.on
dv3d.GlyphDensity = 3.0
dv3d.GlyphSize = 0.6
dv3d = vcs.get3d_vector()
v0 = f["uwnd"]
v1 = f["vwnd"]
x.plot( v0, v1, dv3d )
x.interact()
6 changes: 3 additions & 3 deletions Packages/cdms2/Lib/dataset.py
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ def setNetcdfDeflateFlag(value):
def setNetcdfDeflateLevelFlag(value):
""" Sets NetCDF deflate level flag value"""
if value not in [0,1,2,3,4,5,6,7,8,9]:
raise CDMSError, "Error NetCDF deflate_level flag must be an integer < 10"
raise CDMSError("Error NetCDF deflate_level flag must be an integer < 10")
Cdunif.CdunifSetNCFLAGS("deflate_level",value)

def getNetcdfClassicFlag():
@@ -245,14 +245,14 @@ def openDataset(uri,mode='r',template=None,dods=1,dpath=None, hostObj=None):
file = CdmsFile(uri,mode)
return file
except:
raise CDMSError("Error in DODS open of: ",uri)
raise CDMSError("Error in DODS open of: "+uri)
else:
try:
datanode = loadURI(uri)
return datanode
except:
datanode = loadURI(uri)
raise CDMSError("Error in loadURI of: ",uri)
raise CDMSError("Error in loadURI of: "+uri)

else:
raise SchemeNotSupported(scheme)
4 changes: 2 additions & 2 deletions Packages/vcs/Lib/Canvas.py
Original file line number Diff line number Diff line change
@@ -2727,11 +2727,11 @@ def __plot (self, arglist, keyargs):
xs=arglist[0].getAxis(-1)
ys=arglist[0].getAxis(-2)
if xs.isLongitude() and ys.isLatitude() and isinstance(inGrid,cdms2.grid.TransientRectGrid):
arglist[1]=MV2.array(g.getMesh())
arglist[1]=MV2.array(inGrid.getMesh())
if not 'wrap' in keyargs.keys():
keyargs['wrap']=[0.,360.]
elif ys.isLongitude() and xs.isLatitude() and isinstance(inGrid,cdms2.grid.TransientRectGrid):
arglist[1]=MV2.array(g.getMesh())
arglist[1]=MV2.array(inGrid.getMesh())
if not 'wrap' in keyargs.keys():
keyargs['wrap']=[360.,0.]
else:
2 changes: 2 additions & 0 deletions Packages/vcs/Lib/VTKPlots.py
Original file line number Diff line number Diff line change
@@ -753,6 +753,7 @@ def hideGUI(self):
if manager_exists(self.renWin.GetInteractor()):
manager = get_manager(self.renWin.GetInteractor())
self.renWin.RemoveRenderer(manager.renderer)
self.renWin.RemoveRenderer(manager.actor_renderer)

def showGUI(self, render=True):
plot = self.get3DPlot()
@@ -764,6 +765,7 @@ def showGUI(self, render=True):
if manager_exists(self.renWin.GetInteractor()):
manager = get_manager(self.renWin.GetInteractor())
self.renWin.AddRenderer(manager.renderer)
self.renWin.AddRenderer(manager.actor_renderer)
# Bring the manager's renderer to the top of the stack
manager.elevate()
if render:
4 changes: 2 additions & 2 deletions Packages/vcs/Lib/colorpicker.py
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ def cancel(self, state):
self.close()

def selectCell(self, cellId):
if cellId == -1:
if cellId in (None, -1):
return
ids = vtk.vtkIdTypeArray();
ids.SetNumberOfComponents(1);
@@ -152,7 +152,7 @@ def clickEvent(self, obj, event):

x, y = inter.GetEventPosition()

renderer = self.topRendererAtPoint(x, y)
renderer = self.color_renderer

if renderer:
picker = vtk.vtkCellPicker()
3 changes: 2 additions & 1 deletion Packages/vcs/Lib/dv3d.py
Original file line number Diff line number Diff line change
@@ -184,7 +184,8 @@ def list(self):
print 'name =',self.name
print 'axes =',self.axes
for pname in self.parameter_names:
print ' = '.join( [ pname, self.getParameter( pname ) ] )
pval = self.getParameter( pname )
print pname,'=',repr(pval)

class Gf3Dvector(Gfdv3d):

17 changes: 11 additions & 6 deletions Packages/vcs/Lib/vtk_ui/button.py
Original file line number Diff line number Diff line change
@@ -135,12 +135,20 @@ def add_state(self, label=None, image=None, bgcolor=None, fgcolor=None, opacity=
self.states.append(ButtonState(label=label, image=image, bgcolor=bgcolor, fgcolor=fgcolor, opacity=opacity))

def place(self):

width, height = self.get_dimensions()
x, y = self.get_position()
bounds = (x, x + width, y - height, y, 0, 0)

self.repr.SetPlaceFactor(1)
self.repr.PlaceWidget(bounds)
self.repr.Modified()
if self.showing():
# This One Weird Hack will make your Buttons Go In the Right Place - Developers hate it!
# Buttons weren't always getting properly placed (toolbars in toolbars being the canonical example)
# This makes them show up correctly. Weird, but it works.
h_state = self.repr.GetHighlightState()
self.repr.Highlight((h_state + 1) % 3)
self.repr.Highlight(h_state)

text_width, text_height = self.text_widget.get_dimensions()
swidth, sheight = self.interactor.GetRenderWindow().GetSize()
@@ -289,7 +297,7 @@ def in_bounds(self, x, y):
def __advance__(self, point):
state = self.repr.GetState()
self.set_state( (state + 1) % len(self.states) )
#self.clicked(self.widget, "StateChangedEvent") Do we need to call this? I bet we don't.
self.clicked(self.widget, "StateChangedEvent")

def clicked(self, obj, event):
state = self.get_state()
@@ -332,10 +340,7 @@ def __init__(self, interactor, label, on=None, off=None, corner_radius=5, width=
self.label = label

def get_text(self):
if self.get_state() == 0:
return self.label.get_text()[len(on_prefix):]
else:
return self.label.get_text()[len(off_prefix):]
return self.label

def toggle(self, state):
if state == 1:
29 changes: 20 additions & 9 deletions Packages/vcs/Lib/vtk_ui/toolbar.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

class Toolbar(object):

def __init__(self, interactor, label, vertical=True, left=10, top=10, open_label="Open", on_open=None, close_label="Close", button_margin=5, parent=None, save=None):
def __init__(self, interactor, label, vertical=True, left=10, top=10, open_label="Open", on_open=None, close_label="Close", on_close=None, button_margin=5, parent=None, save=None):

self.save = save
self.interactor = interactor
@@ -12,13 +12,13 @@ def __init__(self, interactor, label, vertical=True, left=10, top=10, open_label
self.top = top
self.label = ToggleButton(self.interactor, label, on=self.__on__, off=self.__off__, on_prefix=open_label, off_prefix=close_label, left=self.left - self.margin, top=self.top)
self.on_open = on_open
self.on_close = on_close
self.vertical = vertical

self.open = False

# Increment this as widgets are added
self.width, self.height = self.label.get_dimensions()
self.height += button_margin

self.widgets = []
self.bars = {}
@@ -47,13 +47,15 @@ def __delleft(self):

def __on__(self):
self.open = True
self.show_widgets()
if self.on_open is not None:
self.on_open()
self.show_widgets()

def __off__(self):
self.open = False
self.hide_widgets()
if self.on_close is not None:
self.on_close()

def copy(self, interactor):
t = Toolbar(interactor, self.label.label, vertical=self.vertical, left=self.left - self.margin, top=self.top, button_margin=self.margin)
@@ -87,9 +89,6 @@ def place(self):
self.width += self.margin

for widget in self.widgets:

widget_width, widget_height = widget.get_dimensions()

if self.vertical:
widget.left = self.left
widget.top = self.top + self.height
@@ -107,6 +106,7 @@ def place(self):
self.height += widget_height + self.margin
else:
self.width += widget_width + self.margin
self.label.manager.queue_render()

def get_dimensions(self):
"""
@@ -136,11 +136,10 @@ def hide(self):
self.hide_widgets()

def show_widgets(self):
self.place()
for widget in self.widgets:
widget.show()

self.place()

def hide_widgets(self):
"""
Hides all widgets in this toolbar
@@ -182,7 +181,6 @@ def add_button(self, labels, **kwargs):
kwargs["top"] = self.top

b = Button(self.interactor, **kwargs)

if self.open:
b.show()

@@ -192,6 +190,7 @@ def add_button(self, labels, **kwargs):
self.width = kwargs["left"] + b.get_dimensions()[0]

self.widgets.append(b)

return b


@@ -211,6 +210,18 @@ def add_toolbar(self, label, **kwargs):

if "vertical" not in kwargs:
kwargs["vertical"] = self.vertical
_open = kwargs.get("on_open", None)
def hook_open():
self.place()
if _open:
_open()
_close = kwargs.get("on_close", None)
def hook_close():
self.place()
if _close:
_close()
kwargs["on_open"] = hook_open
kwargs["on_close"] = hook_close

toolbar = Toolbar(self.interactor, label, **kwargs)

3 changes: 2 additions & 1 deletion testing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
# Helper macro that sets the environment correctly
macro (cdat_add_test name python_exe script)
#string (REPLACE ";" " " TEST_ARGS "${ARGN}")
add_test (${name} "${python_exe}" ${script} ${ARGN})
add_test(${name} "${CMAKE_INSTALL_PREFIX}/bin/runtest"
${script} ${ARGN})
if(DEFINED ENV{UVCDAT_ANONYMOUS_LOG})
set_tests_properties (${name}
PROPERTIES ENVIRONMENT "UVCDAT_ANONYMOUS_LOG=$ENV{UVCDAT_ANONYMOUS_LOG}"
16 changes: 16 additions & 0 deletions testing/vcs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -266,6 +266,11 @@ cdat_add_test(vcs_test_taylor_2_quads

# These test actually plot things need sample data
if (CDAT_DOWNLOAD_SAMPLE_DATA)
cdat_add_test(test_vcs_meshfill_regular_grid
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_meshfill_regular_grid.py
"${BASELINE_DIR}/test_meshfill_regular_grid.png"
)
cdat_add_test(test_vcs_plot_unstructured_via_boxfill
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_plot_unstructured_via_boxfill.py
@@ -623,6 +628,11 @@ cdat_add_test(vcs_test_endconfigure
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_endconfigure.py
)

cdat_add_test(vcs_test_colorpicker_selection
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_colorpicker_selection.py
)

cdat_add_test(vcs_test_configurator_click_text
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_configurator_click_text.py
@@ -635,6 +645,12 @@ cdat_add_test(vcs_test_configurator_click_marker
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_configurator_click_marker.py
)
cdat_add_test(vcs_test_configurator_resize
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_configurator_resize.py
${BASELINE_DIR}/test_vcs_configurator_resize.png
)

cdat_add_test(vcs_test_colorpicker_appearance
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_colorpicker_appearance.py
20 changes: 20 additions & 0 deletions testing/vcs/test_meshfill_regular_grid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import vcs, cdms2, os, sys
src=sys.argv[1]
pth = os.path.join(os.path.dirname(__file__),"..")
sys.path.append(pth)
import checkimage
x=vcs.init()
x.drawlogooff()

x.setbgoutputdimensions(1200,1091,units="pixels")
x = vcs.init()
f = cdms2.open(os.path.join(vcs.prefix, "sample_data", "clt.nc"))
s = f("clt")
x.meshfill(s,bg=1)
fnm = "test_meshfill_regular_grid.png"
x.png(fnm)

print "fnm:",fnm
print "src:",src
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
sys.exit(ret)
19 changes: 19 additions & 0 deletions testing/vcs/test_vcs_colorpicker_selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import vcs, sys

passing = False


def save_clicked(colormap, color):
if color == 135:
global passing
passing = True


picker = vcs.colorpicker.ColorPicker(500, 500, None, None, on_save=save_clicked)

interactor = picker.render_window.GetInteractor()
interactor.SetEventInformation(250, 260)
picker.clickEvent(None, None)
picker.save(0)

sys.exit(0 if passing else 1)
29 changes: 29 additions & 0 deletions testing/vcs/test_vcs_configurator_resize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import vcs, vtk

x = vcs.init()
x.open()
x.configure()

x.backend.renWin.SetSize(814, 303)
x.backend.renWin.Modified()

fnm = "test_vcs_configurator_resize.png"

win = x.backend.renWin
win.Render()
out_filter = vtk.vtkWindowToImageFilter()
out_filter.SetInput(win)

png_writer = vtk.vtkPNGWriter()
png_writer.SetFileName(fnm)
png_writer.SetInputConnection(out_filter.GetOutputPort())
png_writer.Write()

import sys, os
if len(sys.argv) > 1:
pth = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(pth)
import checkimage
src = sys.argv[1]
ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
sys.exit(ret)
105 changes: 75 additions & 30 deletions testing/vcs/vtk_ui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,173 +2,218 @@ set(BASELINE_DIR "${UVCDAT_GIT_TESTDATA_DIR}/baselines/vcs/vtk_ui")
set(TEST_DIR "${cdat_SOURCE_DIR}/testing/vcs/vtk_ui")

# Button tests
add_test(test_vtk_ui_button_draw
cdat_add_test(test_vtk_ui_button_draw
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_draw.py
${BASELINE_DIR}/test_vtk_ui_button_draw.png
)

add_test(test_vtk_ui_button_action
cdat_add_test(test_vtk_ui_button_action
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_action.py
)

add_test(test_vtk_ui_button_corner_radius
cdat_add_test(test_vtk_ui_button_corner_radius
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_corner_radius.py
${BASELINE_DIR}/test_vtk_ui_button_corner_radius.png
)

add_test(test_vtk_ui_button_dimensions
cdat_add_test(test_vtk_ui_button_dimensions
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_dimensions.py
${BASELINE_DIR}/test_vtk_ui_button_dimensions.png
)

add_test(test_vtk_ui_button_states
cdat_add_test(test_vtk_ui_button_states
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_states.py
${BASELINE_DIR}/test_vtk_ui_button_states.png
)

add_test(test_vtk_ui_button_click
cdat_add_test(test_vtk_ui_button_click
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_click.py
)

add_test(test_vtk_ui_button_font
cdat_add_test(test_vtk_ui_button_font
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_font.py
${BASELINE_DIR}/test_vtk_ui_button_font.png
)

add_test(test_vtk_ui_button_alignment
cdat_add_test(test_vtk_ui_button_alignment
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_alignment.py
${BASELINE_DIR}/test_vtk_ui_button_alignment.png
)

add_test(test_vtk_ui_button_image
cdat_add_test(test_vtk_ui_button_image
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_image.py
${BASELINE_DIR}/test_vtk_ui_button_image.png
)

add_test(test_vtk_ui_button_tooltip_show
cdat_add_test(test_vtk_ui_button_tooltip_show
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_tooltip_show.py
${BASELINE_DIR}/test_vtk_ui_button_tooltip_show.png
)

add_test(test_vtk_ui_button_tooltip_hide
cdat_add_test(test_vtk_ui_button_tooltip_hide
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_tooltip_hide.py
${BASELINE_DIR}/test_vtk_ui_button_tooltip_hide.png
)

add_test(test_vtk_ui_slider_jumps
cdat_add_test(test_vtk_ui_slider_jumps
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_slider_jumps.py
${BASELINE_DIR}/test_vtk_ui_slider_jumps.png
)

add_test(test_vtk_ui_textbox_highlight
cdat_add_test(test_vtk_ui_textbox_highlight
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_textbox_highlight.py
${BASELINE_DIR}/test_vtk_ui_textbox_highlight.png
)

add_test(test_vtk_ui_label_top
cdat_add_test(test_vtk_ui_label_top
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_top.py
${BASELINE_DIR}/test_vtk_ui_label_top.png
)
add_test(test_vtk_ui_label_y
cdat_add_test(test_vtk_ui_label_y
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_y.py
${BASELINE_DIR}/test_vtk_ui_label_y.png
)

add_test(test_vtk_ui_contrasting_colors
cdat_add_test(test_vtk_ui_contrasting_colors
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_contrasting_colors.py
)

add_test(test_vtk_ui_hsv_rgb
cdat_add_test(test_vtk_ui_hsv_rgb
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_hsv_rgb.py
)

add_test(test_vtk_ui_label_behaviors
cdat_add_test(test_vtk_ui_label_behaviors
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_behaviors.py
${BASELINE_DIR}/test_vtk_ui_label_behaviors.png
)

add_test(test_vtk_ui_label_bounds
cdat_add_test(test_vtk_ui_label_bounds
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_bounds.py
)

add_test(test_vtk_ui_label_detach
cdat_add_test(test_vtk_ui_label_detach
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_detach.py
${BASELINE_DIR}/test_vtk_ui_label_detach.png
)

add_test(test_vtk_ui_label_font_attrs
cdat_add_test(test_vtk_ui_label_font_attrs
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_font_attrs.py
${BASELINE_DIR}/test_vtk_ui_label_font_attrs.png
)

add_test(test_vtk_ui_label_left
cdat_add_test(test_vtk_ui_label_left
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_left.py
${BASELINE_DIR}/test_vtk_ui_label_left.png
)

add_test(test_vtk_ui_label_render
cdat_add_test(test_vtk_ui_label_render
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_render.py
${BASELINE_DIR}/test_vtk_ui_label_render_initial.png
${BASELINE_DIR}/test_vtk_ui_label_render_color_change.png
)

add_test(test_vtk_ui_label_show_hide
cdat_add_test(test_vtk_ui_label_show_hide
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_show_hide.py
${BASELINE_DIR}/test_vtk_ui_label_show_hide.png
)

add_test(test_vtk_ui_label_text
cdat_add_test(test_vtk_ui_label_text
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_text.py
${BASELINE_DIR}/test_vtk_ui_label_text.png
)

add_test(test_vtk_ui_label_x
cdat_add_test(test_vtk_ui_label_x
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_label_x.py
${BASELINE_DIR}/test_vtk_ui_label_x.png
)

add_test(test_vtk_ui_set_font
cdat_add_test(test_vtk_ui_set_font
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_set_font.py
)

add_test(test_vtk_ui_text_dimensions
cdat_add_test(test_vtk_ui_text_dimensions
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_text_dimensions.py
)

add_test(test_vtk_ui_white_or_black
cdat_add_test(test_vtk_ui_white_or_black
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_white_or_black.py
)

add_test(test_vtk_ui_textbox_blank_text
cdat_add_test(test_vtk_ui_manager_resize
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_manager_resize.py
${BASELINE_DIR}/test_vtk_ui_manager_resize.png
)
cdat_add_test(test_vtk_ui_textbox_blank_text
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_textbox_blank_text.py
)

cdat_add_test(test_vtk_ui_toolbar_label
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_toolbar_label.py
${BASELINE_DIR}/test_vtk_ui_toolbar_label.png
)

cdat_add_test(test_vtk_ui_toolbar_open
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_toolbar_open.py
${BASELINE_DIR}/test_vtk_ui_toolbar_open.png
)

cdat_add_test(test_vtk_ui_toolbar_close
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_toolbar_close.py
${BASELINE_DIR}/test_vtk_ui_toolbar_close.png
)

cdat_add_test(test_vtk_ui_toggle_button_get_text
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_toggle_button_get_text.py
)

cdat_add_test(test_vtk_ui_toolbar_in_toolbar_open
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_toolbar_in_toolbar_open.py
${BASELINE_DIR}/test_vtk_ui_toolbar_in_toolbar_open.png
)

cdat_add_test(test_vtk_ui_toolbar_in_toolbar_closed
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_toolbar_in_toolbar_closed.py
${BASELINE_DIR}/test_vtk_ui_toolbar_in_toolbar_closed.png
)

cdat_add_test(test_vtk_ui_button_state_advance
"${PYTHON_EXECUTABLE}"
${TEST_DIR}/test_vtk_ui_button_state_advance.py
)
32 changes: 32 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_button_state_advance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Test button state change
"""
import vcs.vtk_ui


from vtk_ui_test import vtk_ui_test

class test_vtk_ui_button_state_advance(vtk_ui_test):
def do_test(self):
self.win.SetSize(100, 100)
states = [vcs.vtk_ui.ButtonState(label="State %d" % i, fgcolor=(.1 * i + .5, .1 * i + .5, .1 * i + .5), bgcolor=(.5 - .1 * i,.5 - .1 * i,.5 - .1 * i)) for i in range(5)]

b = vcs.vtk_ui.Button(self.inter, states=states, action=self.pass_me, left=0, top=0)
b.show()

b.set_state(1)
b.repr.NextState()
b.widget.InvokeEvent("StateChangedEvent")


def pass_me(self, state):
if state == 2:
print "Button action executed"
self.passed = 0
else:
print state, "Action passed inaccurate state"
from sys import exit
sys.exit(1)

if __name__ == "__main__":
test_vtk_ui_button_state_advance().test()
26 changes: 26 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_manager_resize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Test window resizing placing widgets correctly
"""
import vcs.vtk_ui

from vtk_ui_test import vtk_ui_test


class test_vtk_ui_manager_resize(vtk_ui_test):
def do_test(self):
self.win.SetSize(250, 100)
# Due to UV-CDAT/uvcdat#1148, have to render on screen when resizing
self.win.SetOffScreenRendering(0)

button = vcs.vtk_ui.Button(self.inter, label="Position me", left=10, top=10)
button.place()
button.show()

self.win.SetSize(200, 50)

self.win.Modified()

self.test_file = "test_vtk_ui_manager_resize.png"

if __name__ == "__main__":
test_vtk_ui_manager_resize().test()
16 changes: 16 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_toggle_button_get_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Test toggle_button get text
"""
import vcs.vtk_ui


from vtk_ui_test import vtk_ui_test

class test_vtk_ui_toggle_button_get_text(vtk_ui_test):
def do_test(self):
b = vcs.vtk_ui.ToggleButton(self.inter, "Simple label")
b.set_state(1)
assert b.get_text() == "Simple label"
b.set_state(0)
assert b.get_text() == "Simple label"
self.passed = 0
24 changes: 24 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_toolbar_close.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Test toolbar placement and basic appearance
"""
import vcs.vtk_ui


from vtk_ui_test import vtk_ui_test

class test_vtk_ui_toolbar_close(vtk_ui_test):
def do_test(self):
self.win.SetSize(200, 100)

toolbar = vcs.vtk_ui.Toolbar(self.inter, "Test Bar")
toolbar.add_button(["Test Button"])
toolbar.add_button(["Other Test"])
toolbar.label.__advance__(1)
toolbar.label.__advance__(0)
assert toolbar.open == False
toolbar.show()

self.test_file = "test_vtk_ui_toolbar_close.png"

if __name__ == "__main__":
test_vtk_ui_toolbar_close().test()
29 changes: 29 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_toolbar_in_toolbar_closed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Test toolbar placement inside toolbar
"""
import vcs.vtk_ui


from vtk_ui_test import vtk_ui_test

class test_vtk_ui_toolbar_in_toolbar_closed(vtk_ui_test):
def do_test(self):
self.win.SetSize(200, 250)

toolbar = vcs.vtk_ui.Toolbar(self.inter, "Test Bar")
tb = toolbar.add_toolbar("Sub-bar")
tb.add_button(["first"])
tb.add_button(["second"])
toolbar.add_button(["Test Button"])
toolbar.add_button(["Other Test"])
toolbar.show()

# Open both toolbars
toolbar.label.__advance__(1)
tb.label.__advance__(1)
tb.label.__advance__(0)

self.test_file = "test_vtk_ui_toolbar_in_toolbar_closed.png"

if __name__ == "__main__":
test_vtk_ui_toolbar_in_toolbar_closed().test()
28 changes: 28 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_toolbar_in_toolbar_open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Test toolbar placement inside toolbar
"""
import vcs.vtk_ui


from vtk_ui_test import vtk_ui_test

class test_vtk_ui_toolbar_in_toolbar_open(vtk_ui_test):
def do_test(self):
self.win.SetSize(200, 250)

toolbar = vcs.vtk_ui.Toolbar(self.inter, "Test Bar")
tb = toolbar.add_toolbar("Sub-bar")
tb.add_button(["first"])
tb.add_button(["second"])
toolbar.add_button(["Test Button"])
toolbar.add_button(["Other Test"])
toolbar.show()

# Open both toolbars
toolbar.label.__advance__(1)
tb.label.__advance__(1)

self.test_file = "test_vtk_ui_toolbar_in_toolbar_open.png"

if __name__ == "__main__":
test_vtk_ui_toolbar_in_toolbar_open().test()
23 changes: 23 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_toolbar_label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Test toolbar placement and basic appearance
"""
import vcs.vtk_ui


from vtk_ui_test import vtk_ui_test

class test_vtk_ui_toolbar_label(vtk_ui_test):
def do_test(self):
self.win.SetSize(200, 100)

toolbar = vcs.vtk_ui.Toolbar(self.inter, "Test Bar")
# Should default to closed; these will help make sure
toolbar.add_button(["Test Button"])
toolbar.add_button(["Other Test"])
assert toolbar.open == False
toolbar.show()

self.test_file = "test_vtk_ui_toolbar_label.png"

if __name__ == "__main__":
test_vtk_ui_toolbar_label().test()
24 changes: 24 additions & 0 deletions testing/vcs/vtk_ui/test_vtk_ui_toolbar_open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Test toolbar placement and basic appearance
"""
import vcs.vtk_ui


from vtk_ui_test import vtk_ui_test

class test_vtk_ui_toolbar_open(vtk_ui_test):
def do_test(self):
self.win.SetSize(200, 100)

toolbar = vcs.vtk_ui.Toolbar(self.inter, "Test Bar")
toolbar.add_button(["Test Button"])
toolbar.add_button(["Other Test"])
toolbar.label.__advance__(1)
assert toolbar.open == True
toolbar.show()


self.test_file = "test_vtk_ui_toolbar_open.png"

if __name__ == "__main__":
test_vtk_ui_toolbar_open().test()
16 changes: 8 additions & 8 deletions testing/vcsaddons/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
set(BASELINE_DIR "${UVCDAT_GIT_TESTDATA_DIR}/baselines/vcsaddons")

add_test(vcs_addons_preview_2x2
cdat_add_test(vcs_addons_preview_2x2
"${PYTHON_EXECUTABLE}"
${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
cdat_add_test(vcs_addons_test_12_plot_one_leg_per_row
"${PYTHON_EXECUTABLE}"
${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
cdat_add_test(vcs_addons_test_12_plot_one_leg_per_row_right
"${PYTHON_EXECUTABLE}"
${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
cdat_add_test(vcs_addons_test_EzTemplate_12_plots_margins_thickness
"${PYTHON_EXECUTABLE}"
${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
cdat_add_test(vcs_addons_test_EzTemplate_12_plots_legd_direction
"${PYTHON_EXECUTABLE}"
${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
cdat_add_test(vcs_addons_test_EzTemplate_12_plots_mix_glb_local
"${PYTHON_EXECUTABLE}"
${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
cdat_add_test(vcs_addons_test_EzTemplate_12_plots_spacing
"${PYTHON_EXECUTABLE}"
${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
cdat_add_test(vcs_addons_EzTemplate_2x2
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py
${BASELINE_DIR}/test_vcs_addons_EzTemplate_2x2.png

0 comments on commit b14e373

Please sign in to comment.