OpenStructure
Loading...
Searching...
No Matches
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
6scene.RemoveAll()
7
8# load pdb structure
9eh=io.LoadPDB("data/sdh.pdb")
10
11
12sdh_go=gfx.Entity("SDH2", eh.Select("cname=A"))
13# create graphical object and add it to the scene
14scene.Add(sdh_go)
15scene.CenterOn(sdh_go)
16
17def 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
25def Trace():
26 sdh_go.SetRenderMode(gfx.LINE_TRACE)
27 sdh_go.GetOptions(gfx.LINE_TRACE).SetLineWidth(2.5)
28
29def Spheres():
30 sdh_go.SetRenderMode(gfx.CPK)
31 sdh_go.GetOptions(gfx.CPK).SetSphereDetail(4)
32
33def 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
52Cartoon()
53