Visit-tutorial-sl-movie-script

Revision as of 20:05, 5 March 2014 by BradWhitlock (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
import math

SetWindowLayout(2)
SetActiveWindow(2)
OpenDatabase("int_over_time.curve")
AddPlot("Curve", "curve")
DrawPlots()
SetActiveWindow(1)
OpenDatabase("~/visit/data/hgx.visit")

a = GetAnnotationAttributes()
a.axes3D.xAxis.title.visible = 0
a.axes3D.yAxis.title.visible = 0
a.axes3D.zAxis.title.visible = 0
a.foregroundColor = (255,255,255,255)
a.databaseInfoFlag = 0
a.userInfoFlag = 0
a.legendInfoFlag = 0
a.backgroundMode = a.Gradient
SetAnnotationAttributes(a)

SetActiveWindow(2)
a = GetAnnotationAttributes()
a.databaseInfoFlag = 0
a.userInfoFlag = 0
a.legendInfoFlag = 0
a.axes2D.xAxis.title.visible = 0
a.axes2D.yAxis.title.visible = 0
SetAnnotationAttributes(a)
c = CurveAttributes()
c.doBallTimeCue = 1
c.timeCueBallSize = 0.001
c.showLegend = 0
c.showLabels = 0
SetPlotOptions(c)
v = GetViewCurve()
v.viewportCoords = (0.1, 0.95, 0.05, 0.95)
SetViewCurve(v)
SetActiveWindow(1)

DefineVectorExpression("vel", "gradient(hgx)")
AddPlot("Streamline", "vel")
s = StreamlineAttributes()
s.sourceType = s.SpecifiedBox
s.termination = 200
s.sampleDensity0 = 4
s.sampleDensity1 = 4
s.sampleDensity2 = 4
s.lineWidth = 3
s.showHeads = 1
s.headDisplayType = s.Cone
s.colorTableName = "amino_shapely"
s.coloringMethod = s.ColorBySeedPointID
s.terminationType = s.Step
SetPlotOptions(s)
DrawPlots()

ts = CreateAnnotationObject("TimeSlider")
ts.position = (0.01, 0.9)

AddPlot("Streamline", "vel")
s.showHeads = 0
s.displayMethod = s.Tubes
s.tubeRadius = 0.25
SetPlotOptions(s)
DrawPlots()

nTimes=20
nSteps=30
nTotalSteps=nTimes*nSteps
for i in range(nTimes):
   TimeSliderSetState(i)
   ts.text = "Time Index: %d" %(i)
   thetaMin = i/(nTimes-1.0)
   thetaMax = (i+1.0)/(nTimes-1.0)
   TimeSliderSetState(i)
   SetActiveWindow(2)
   c.timeForTimeCue = i
   SetPlotOptions(c)
   SetActiveWindow(1)
   for j in range(nSteps):
      # Set the view
      theta = thetaMin+j/float(nSteps)
      v = GetView3D()
      v.viewNormal = (math.sin(theta), math.cos(theta), 0)
      v.viewUp = (0,0,1)
      SetView3D(v)
      # Set the part of the streamline we see
      distPer=100/nSteps # only go 100 steps, even though we terminate at 200
      s.displayBeginFlag = 1
      s.displayBegin = 2*distPer*j
      s.displayEndFlag = 1
      s.displayEnd = 2*distPer*j+5
      SetPlotOptions(s)
      sw = SaveWindowAttributes()
      sw.advancedMultiWindowSave = 1
      sw.resConstraint = sw.NoConstraint
      sw.width = 1024
      sw.height = 1024
      sw.subWindowAtts.win1.position = (0,0)
      sw.subWindowAtts.win1.size = (1024, 1024)
      sw.subWindowAtts.win2.position = (768,11)
      sw.subWindowAtts.win2.size = (245,245)
      sw.fileName = "sl_movie%d" %(nSteps*i+j)
      sw.family = 0
      SetSaveWindowAttributes(sw)
      SaveWindow()