# # Mouse mode (ctrl-right-mouse-button) to delete individual surface triangles. # Open this file in Chimera to activate the mouse mode. # # Warning: Deleted triangles will not be recorded in Chimera session files. # # Tested in Chimera version 1.2524, daily build from June 4, 2008. # Will not work in production release 1.2470 from Nov 2007. # def mouse_down_cb(viewer, event): from VolumeViewer import slice xyz_in, xyz_out = slice.clip_plane_points(event.x, event.y) import PickBlobs smlist = PickBlobs.surface_models() dist, p, tri = PickBlobs.closest_surface_intercept(smlist, xyz_in, xyz_out) if p is None: from chimera.replyobj import status status('Missed surface (%d,%d)' % (event.x, event.y)) return m = p.triangleAndEdgeMask if m is None: # No triangles hidden yet from numpy import zeros, int32 m = zeros((p.triangleCount), int32) m.fill(0xf) # Convert masked geometry triangle index to full geometry index t = (m&0x8).nonzero()[0][tri] m[t] ^= 0x8 # Toggle triangle display. p.triangleAndEdgeMask = m import Surface if hasattr(Surface, 'set_visibility_method'): Surface.set_visibility_method('static', p.model) from chimera import mousemodes as m m.addFunction('hide triangle', (mouse_down_cb, None, None)) m.setButtonFunction('3', ['Ctrl'], 'hide triangle')