~yade-dev/yade/0.80

« back to all changes in this revision

Viewing changes to examples/test/force-network-video.py

  • Committer: Anton Gladky
  • Date: 2012-05-02 21:50:42 UTC
  • Revision ID: gladky.anton@gmail.com-20120502215042-v1fa9r65usqe7kfk
0.80.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
print 30*'*'+' WARNING '+30*'*'+'\nFor hardware/driver/...? reasons related to 3d, this script might\nsometimes crash when the first snapshot is taken with message such as\n\n\tQGLContext::makeCurrent(): Failed.\n\nor\n\n\tFatal IO error 11 (Resource temporarily unavailable) on X server :0.0.\n\nA workaround is to open the 3d view by hand, rather than having it\nopen by SnapshotEngine automatically when the first snapshot is\nabout to be taken. Sometimes only the message is displayed,\nwithout crash.\n'+25*'*'+' This is a known bug. '+25*'*'
 
2
TriaxialTest(noFiles=True).load()
 
3
from yade import qt,utils
 
4
O.engines=O.engines+[
 
5
        qt.SnapshotEngine(fileBase=O.tmpFilename(),label='snapshotter',iterPeriod=5,ignoreErrors=False),
 
6
        PyRunner(iterPeriod=500,command='finito()')
 
7
]
 
8
rr=qt.Renderer()
 
9
rr.shape,rr.intrPhys=False,True
 
10
 
 
11
def finito():
 
12
        """This function will be called after 500 steps. Since SnapshotEngine waits for a new 3d view to open,
 
13
        it must run after the script has finished and the command line appears
 
14
        (see https://bugs.launchpad.net/yade/+bug/622669).
 
15
 
 
16
        For that reason, O.run() is at the end of the script and this function will be called
 
17
        once we want to exit really.
 
18
        """
 
19
        utils.makeVideo(snapshotter.snapshots,out='/tmp/video.avi')
 
20
        print "Video saved in /tmp/video.avi"
 
21
        import sys
 
22
        sys.exit(0)
 
23
 
 
24
O.run()
 
25