A plug-in is a python script that allows to modify the model. Two examples are proposed. The first one reduc.py, keep only one tens of particles, using the function reduc.
self.X = self.X.reduc(10) # redisplay self.display() self.display_info(self.X)
The second one, more complex (cut.py), keep only particles that are displayed in the window :
from Nbody import *
from Numeric import *
xm = self.params.get('size')[0]
zm = self.params.get('size')[1]
xmin = - xm
xmax = + xm
zmin = - zm
zmax = + zm
# expose the model
self.nbodyviewer.pose()
# keep only particles that are in the window
self.X = self.X.selectp(self.nbodyviewer.X.num)
x = self.nbodyviewer.X.pos[:,0]
z = self.nbodyviewer.X.pos[:,2]
cx1 = greater(x,xmin)
cx2 = less(x,xmax)
cz1 = greater(z,zmin)
cz2 = less(z,zmax)
self.X = self.X.selectc(cx1 * cx2 * cz1 * cz2)
# redisplay
self.display()
self.display_info(self.X)
See About this document... for information on suggesting changes.