OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rendermodes.py

Shows how to switch between different render modes and explains some of the rendermode parameters.

See Also
Loading and Displaying an Entity
1 # This script shows how to switch between different render modes
2 # programmatically and change render options.
3 
4 
5 # remove all objects from scene, just in case
6 scene.RemoveAll()
7 
8 # load pdb structure
9 eh=io.LoadPDB("data/sdh.pdb")
10 
11 
12 sdh_go=gfx.Entity("SDH2", eh.Select("cname=A"))
13 # create graphical object and add it to the scene
14 scene.Add(sdh_go)
15 scene.CenterOn(sdh_go)
16 
17 def Tube():
18  sdh_go.SetRenderMode(gfx.TUBE)
19  sdh_go.tube_options.SetTubeRadius(0.8)
20  # apply color gradient for the atomic bfactors
21  sdh_go.ColorBy("abfac",gfx.BLUE,gfx.RED)
22  # and apply radius gradient as well
23  sdh_go.RadiusBy("abfac",0.8,2.2)
24 
25 def Trace():
26  sdh_go.SetRenderMode(gfx.LINE_TRACE)
27  sdh_go.GetOptions(gfx.LINE_TRACE).SetLineWidth(2.5)
28 
29 def Spheres():
30  sdh_go.SetRenderMode(gfx.CPK)
31  sdh_go.GetOptions(gfx.CPK).SetSphereDetail(4)
32 
33 def Cartoon():
34  sdh_go.SetRenderMode(gfx.RenderMode.HSC)
35  sdh_go.SetColor(gfx.Color(0.5, 0.5, 0.5), '')
36  sdh_go.SetColor(gfx.Color(0,1,0),"rtype=H")
37  sdh_go.SetDetailColor(gfx.Color(0.7,1.0,0.8),"rtype=H")
38  # strands
39  sdh_go.SetColor(gfx.Color(1,0,0),"rtype=E")
40  sdh_go.SetDetailColor(gfx.Color(1.0,0.8,0.2),"rtype=E")
41  # these are the default params for the rendering
42  #sdh_go.cartoon_options.SetArcDetail(4) # circular profile detail
43  #sdh_go.cartoon_options.SetSphereDetail(4) # sphere detail
44  #sdh_go.cartoon_options.SetSplineDetail(8) # segments between backbone atoms
45  #sdh_go.cartoon_options.SetTubeRadius(0.4) # coil radius
46  #sdh_go.cartoon_options.SetTubeRatio(1.0) # coil axial ratio
47  #sdh_go.cartoon_options.SetHelixWidth(1.1) # helical width
48  #sdh_go.cartoon_options.SetHelixThickness(0.2) # helical thickness
49  #sdh_go.cartoon_options.SetStrandWidth(1.2) # strand width
50  #sdh_go.cartoon_options.SetStrandThickness(0.2) # strand thickness
51 
52 Cartoon()
53