From fa2d9dad806dea5d0cad1cc2f2ed622820baeebe Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Tue, 15 Jun 2010 08:43:41 +0000 Subject: [PATCH] unbreak examples and make sure they run from dng git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2397 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- examples/img/create_split_image.py | 6 +++- examples/img/fft_li.py | 6 ++-- examples/img/spoke_pattern.py | 14 ++++---- examples/img/view_phase_diff.py | 8 +++-- examples/misc/ambient_occlusion.py | 53 ------------------------------ examples/seq/seq_viewer.py | 2 +- examples/trj/test_trj.py | 4 +-- examples/trj/test_trj_blur.py | 4 +-- 8 files changed, 24 insertions(+), 73 deletions(-) delete mode 100644 examples/misc/ambient_occlusion.py diff --git a/examples/img/create_split_image.py b/examples/img/create_split_image.py index 084244455..30ae40808 100644 --- a/examples/img/create_split_image.py +++ b/examples/img/create_split_image.py @@ -35,7 +35,11 @@ def CreateSplitImage(imagelist, start_at_y=True): count+=1 return result -imagelist=io.LoadImageList(sys.argv[1:-1]) +if len(sys.argv)<3: + imagelist=io.LoadImageList(['circle.png', 'square.png']) +else: + imagelist=io.LoadImageList(sys.argv[1:-1]) + result=CreateSplitImage(imagelist) v_result=gui.CreateDataViewer(result) io.SaveImage(result,sys.argv[-1]) diff --git a/examples/img/fft_li.py b/examples/img/fft_li.py index f272d4c22..983a45c92 100644 --- a/examples/img/fft_li.py +++ b/examples/img/fft_li.py @@ -1,7 +1,9 @@ import sys import ost.img.alg - -images=io.LoadImageList(sys.argv[1:]) +if len(sys.argv)<2: +images=io.LoadImageList(['square.png']) +else: + images=io.LoadImageList(sys.argv[1:]) viewers=[] i=1 for im in images: diff --git a/examples/img/spoke_pattern.py b/examples/img/spoke_pattern.py index 7a11e42a1..2e188f157 100644 --- a/examples/img/spoke_pattern.py +++ b/examples/img/spoke_pattern.py @@ -2,15 +2,12 @@ import math import sys import ost.img.alg -if len(sys.argv)!=2: - raise RuntimeError('Wrong number of command line arguments. The name of the output file should be the only argument.') - # Tweakable parameters -wedge_start = 80 # Width of wedge at the narrower point -wedge_end = 2000 # Width of wedge at the broader point +wedge_start = 20 # Width of wedge at the narrower point +wedge_end = 500 # Width of wedge at the broader point number_of_bands = 11 # Number of alternating bands (must be odd) -size_of_image_x = 2000 # Size of the image (X) -size_of_image_y = 2000 # Size of the image (Y) +size_of_image_x = 500 # Size of the image (X) +size_of_image_y = 500 # Size of the image (Y) pixel_sampling = 1.0 * Units.A # Pixel width threshold = 2.0 * Units.A # Threshold for low pass filtering amplitude = 255 # amplitude of the obscillations @@ -43,7 +40,8 @@ filter=ost.img.alg.GaussianLowPassFilter(threshold) image.ApplyIP(filter) # Image is saved -io.SaveImage(image,sys.argv[1]) +if len(sys.argv)==2: + io.SaveImage(image,sys.argv[1]) # Viewer is launched to show the result v=gui.CreateDataViewer(image) \ No newline at end of file diff --git a/examples/img/view_phase_diff.py b/examples/img/view_phase_diff.py index 0228a0e02..98de6364c 100644 --- a/examples/img/view_phase_diff.py +++ b/examples/img/view_phase_diff.py @@ -2,8 +2,12 @@ import sys import math import ost.img.alg -image1=io.LoadImage(sys.argv[1]) -image2=io.LoadImage(sys.argv[2]) +if len(sys.argv)==2: + image1=io.LoadImage(sys.argv[1]) + image2=io.LoadImage(sys.argv[2]) +else: + image1=io.LoadImage('square.png') + image2=io.LoadImage('circle.png') if image1.GetExtent() != image2.GetExtent(): raise RuntimeError('The input images should have the same size.') image1.CenterSpatialOrigin() diff --git a/examples/misc/ambient_occlusion.py b/examples/misc/ambient_occlusion.py deleted file mode 100644 index 3ed9da4e8..000000000 --- a/examples/misc/ambient_occlusion.py +++ /dev/null @@ -1,53 +0,0 @@ -def test1(): - global surf - prot=io.LoadPDB("fragment.pdb") - surf=io.LoadSurface("fragment","msms") - surf.Attach(prot,5.0) - scene.Add(gfx.Surface("surf",surf)) - scene["surf"].SetColor(gfx.RED,"ele=O") - scene["surf"].SetColor(gfx.BLUE,"ele=N") - scene.CenterOn("surf") - scene.SetFog(False) - # turn on full contribution from light - scene.SetLightProp(1,1,1) - - # use a material with 10% global ambient light, - # 90% diffuse light, and full specular with small - # hilights - scene["surf"].SetMat(0.1,0.9,1,128) - - # turn on ambient occlusion - # this may take seconds to calculate - scene["surf"].AmbientOcclusion(True) - - # blend the ambient occlusion 100% into the surface, - # reducing the color intensity - scene["surf"].AmbientOcclusionWeight(1) - # blend the local color 30% percent into the surface - scene["surf"].AmbientLocalWeight(0.3) - - scene.AutoAutoslab(False) - scene.Autoslab() - -def test2(): - global plist - plist=gfx.PrimList("t") - plist.AddPoint(geom.Vec3(-1,-1,0), gfx.RED) - plist.AddPoint(geom.Vec3(1,-1,0), gfx.GREEN) - plist.AddPoint(geom.Vec3(1,1,0), gfx.YELLOW) - plist.AddPoint(geom.Vec3(-1,1,0), gfx.BLUE) - plist.AddPoint(geom.Vec3(0,0,4), gfx.MAGENTA) - plist.SetMat(1,1,1,64) - scene.SetLightProp(0,1,0) - plist.SetRadius(1.5) - plist.SetSphereDetail(4) - plist.SetRenderMode(gfx.CUSTOM) - plist.AmbientOcclusion(True) - scene.Add(plist) - scene.CenterOn(plist) - scene.AutoAutoslab(False) - scene.Autoslab() - plist.AmbientOcclusion(True) - - -test1() diff --git a/examples/seq/seq_viewer.py b/examples/seq/seq_viewer.py index 2d5239253..1ca2535e8 100644 --- a/examples/seq/seq_viewer.py +++ b/examples/seq/seq_viewer.py @@ -1,4 +1,4 @@ aln=io.LoadAlignment('sh2.aln') -v=gui.SequenceViewerV2() +v=gui.SequenceViewer() v.AddAlignment(aln) v.Show() diff --git a/examples/trj/test_trj.py b/examples/trj/test_trj.py index ae23e8274..0c3ed1f31 100644 --- a/examples/trj/test_trj.py +++ b/examples/trj/test_trj.py @@ -26,6 +26,4 @@ scene.SetCenter(go.GetCenter()) scene.AutoAutoslab(True) anim=Anim(cg,go) - -print "enter anim.start(10) to start trajectory animation; use anim.stop() to turn it off again." - +anim.start(10) diff --git a/examples/trj/test_trj_blur.py b/examples/trj/test_trj_blur.py index dbbab5f8d..2a762bda8 100644 --- a/examples/trj/test_trj_blur.py +++ b/examples/trj/test_trj_blur.py @@ -29,6 +29,4 @@ scene.SetCenter(go.GetCenter()) scene.AutoAutoslab(True) anim=Anim(cg,go) - -print "enter anim.start(10) to start trajectory animation; use anim.stop() to turn it off again." - +anim.start(10) -- GitLab