""" pygl/clip.py: CCP4MG Molecular Graphics Program Copyright (C) 2001-2006 University of York, CCLRC This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3, modified in accordance with the provisions of the license to address the requirements of UK law. You should have received a copy of the modified GNU Lesser General Public License along with this library. If not, copies may be downloaded from http://www.ccp4.ac.uk/ccp4license.php This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. """ import util from opengl import * class clipping: def __init__(self,id,eqn=(1,0,0,0),vertices="NULL"): self.id = id self.eqn = eqn if vertices != "NULL": self.eqn = util.define_plane(vertices) self.on = 0 def turn_on(self): self.on = 1 def turn_off(self): self.on = 0 def apply(self): if self.on == 0: glDisable(self.id); return glEnable(self.id); glClipPlane(self.id,newdv4(self.eqn[0],self.eqn[1],self.eqn[2],self.eqn[3]))