File: bbox.py

package info (click to toggle)
openstructure 2.11.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,256 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (26 lines) | stat: -rw-r--r-- 851 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# This code example shows how to calculate and display an oriented bounding box 
# that contains all the atoms of an entity.

# remove all objects from scene, just in case
scene.RemoveAll()

# Load sdh molecule
sdh=io.LoadPDB('data/sdh.pdb')
# Select backbone atoms of residues 99-128, which form a helix.
helix=sdh.Select('rnum=99:128 and cname=A and aname=CA,C,N,O')
# create a graphical representation of the helix and render it with simple 
# lines.
go=gfx.Entity('helix', gfx.SIMPLE, helix)
# add it to the scene
scene.Add(go)

# calculate the bounding box for the helix
bbox=mol.BoundingBoxFromEntity(helix)

# create a graphical representation of the bounding box and add it to the scene
bb=gfx.Cuboid('xxx', bbox)
bb.SetFillColor(gfx.Color(0.5, 0.8, 0.5, 0.2))
scene.Add(bb)

# center the camera on the graphical object
scene.center=go.center