from org.das2.qds.examples import Schemes

setScriptDescription('''Tests both the detection and autoranging of all QDataSet schemes.''')
setScriptTitle('Show All Schemes')

mmex= [ 'complexBundleDataSet', 'datum', 'rank1AlongTrajectory', 'bundleDescriptor' ]

mm1= getParam( 's1', '', 'One scheme', { 'examples':mmex } )

mm= dir( Schemes )
mm.remove( 'polyMesh' )
mm.remove( 'isPolyMesh' )

if len(mm1)>0:
    mm= [ mm1 ]

# count the number of methods
i=0
for m in mm:
    if ( m[0:2]=='is' ):
        continue
    else:
        i=i+1
i=i+1 # leave room for text panel

ncolumn= int(floor(sqrt(i)))
nrow= int( ceil( float(i)/ncolumn ) )

setLayout( nrow, ncolumn )
setCanvasSize( 1569, 904 )

i=0
for m in mm:
    if ( m[0:2]=='is' ):
        continue
    else:
        method= getattr( Schemes, m )
        ds= method()
        if ds.rank()>0:
            xt= xtags(ds)
        plot( i, ds, title=m )
        i=i+1

waitUntilIdle()
#dst= Units.nominal().createDatum('%s,%s' % ( dom.canvases[0].marginRow.top, dom.canvases[0].marginRow.bottom ) )
#plot( i, dataset(dst) )

writeToPng('test037_showAllSchemes.png')
waitUntilIdle()
print '------'
print dom.canvases[0].marginRow.top, ',', dom.canvases[0].marginRow.bottom

