def voron( to_ipe = False ): from draw_gl import drawgl from voron import Voron import vec_gl import ucell_gl import voron_gl import voron_inout def draw_with( eng ): eng.clear() vo = Voron( *u.rep ) eng( vo ) u.to_decart() for n, vs in u*1: ## for each atoms in extended unitcell r, col = UCell.data[ n ] col = [ x/255.0 for x in col ] for v in vo.touch( vs ): eng( v, r = r, color = col, invis = False ) eng( n, pos = v ) for v in vo.has( vs ): ## only draw atoms which are in Voron cell if not vo.touch( v ): eng( v, r = r, color = col, invis = False ) eng( n, pos = v ) def save2ipe( *args ): from draw_ipe import drawipe i = 0 fname = '/tmp/out_%s.ipe' while os.path.exists( fname % i ): i += 1 fname = fname % i print 'saving to %s...' % fname drawipe.setup_drawgl( drawgl ) draw_with( drawipe ) drawipe.save( fname ) def minimize( *args ): global u u = u.to_min() draw_with( drawgl ) draw_with( drawgl ) if to_ipe: drawgl.button( 'save to ipe', save2ipe ) if args.min: drawgl.button( 'minimize', minimize ) drawgl.start()
def voron(to_ipe=False): from draw_gl import drawgl from voron import Voron import vec_gl import ucell_gl import voron_gl import voron_inout def draw_with(eng): eng.clear() vo = Voron(*u.rep) eng(vo) u.to_decart() for n, vs in u * 1: ## for each atoms in extended unitcell r, col = UCell.data[n] col = [x / 255.0 for x in col] for v in vo.touch(vs): eng(v, r=r, color=col, invis=False) eng(n, pos=v) for v in vo.has(vs): ## only draw atoms which are in Voron cell if not vo.touch(v): eng(v, r=r, color=col, invis=False) eng(n, pos=v) def save2ipe(*args): from draw_ipe import drawipe i = 0 fname = '/tmp/out_%s.ipe' while os.path.exists(fname % i): i += 1 fname = fname % i print 'saving to %s...' % fname drawipe.setup_drawgl(drawgl) draw_with(drawipe) drawipe.save(fname) def minimize(*args): global u u = u.to_min() draw_with(drawgl) draw_with(drawgl) if to_ipe: drawgl.button('save to ipe', save2ipe) if args.min: drawgl.button('minimize', minimize) drawgl.start()
vo1 = Voron(*r1) vo2 = Voron(*r2) ds1 = r1.to_dots(5, 5, 5) ds2 = r2.to_dots(2, 2, 2) drawgl(vo1) drawgl(vo2) for v in r2: drawgl(v, style="line") for d in vo2.has(ds1): drawgl(d, r=0.05, color=(0, 1, 0)) for d in vo2.has(ds2): drawgl(d, r=0.06, color=(1, 0, 0)) drawgl.start() print "%s %s %s" % tuple(r2[0]) print "%s %s %s" % tuple(r2[1]) print "%s %s %s" % tuple(r2[2]) for d in vo2.has(ds2): print "b %s %s %s" % tuple(d) for d in vo2.has(ds1): print "a %s %s %s" % tuple(d)
def draw(to_ipe=False): from draw_gl import drawgl import vec_gl import ucell_gl drawgl(u) drawgl.start()
vo1.draw() for p in plns[n].touch(fd1): p.draw(r=0.02, color=(0, 1, 0)) for p in plns[n].touch(fd2): p.draw(r=0.04, color=(1, 0, 0)) nl, n = None, 1 def up(*args): global nl, n if n < len(plns) - 1: nl, n = n, n + 1 draw(nl, n) def down(*args): global nl, n if n > 0: nl, n = n, n - 1 draw(nl, n) drawgl.button("up", up) drawgl.button("down", down) drawgl.start()
def draw( to_ipe = False ): from draw_gl import drawgl import vec_gl import ucell_gl drawgl( u ) drawgl.start()