def _Plot2(self): vv.figure(self.fig.nr) vv.clf() ax1f2 = vv.cla() ax1f2.daspect = 1,-1,1 vv.surf(self.z) vv.axis('off') ax1f1 = self.fig2.add_subplot(221) ax1f1.imshow(self.Nx) ax1f1.axis('off') ax2f1 = self.fig2.add_subplot(222) ax2f1.imshow(self.Ny) ax2f1.axis('off') ax3f1 = self.fig2.add_subplot(223) ax3f1.imshow(self.Nz) ax3f1.axis('off') ax4f1 = self.fig2.add_subplot(224) ax4f1.imshow(self.A, cmap='gray') ax4f1.axis('off') self.canvas.draw() if not hasattr(self, 'toolbar'): self.toolbar = NavigationToolbar(self.canvas, self.mplwindow3, coordinates=True) self.mplvl3.addWidget(self.toolbar) self.setWindowTitle('PS Acquisition Tool - %s' % self.currentArchive)
def eldraw2(ex, ey, plotpar=[1, 2, 1], elnum=[]): """ eldraw2(ex,ey,plotpar,elnum) eldraw2(ex,ey,plotpar) eldraw2(ex,ey) PURPOSE Draw the undeformed 2D mesh for a number of elements of the same type. Supported elements are: 1) -> bar element 2) -> beam el. 3) -> triangular 3 node el. 4) -> quadrilateral 4 node el. 5) -> 8-node isopar. elemen INPUT ex,ey:.......... nen: number of element nodes nel: number of elements plotpar=[ linetype, linecolor, nodemark] linetype=1 -> solid linecolor=1 -> black 2 -> dashed 2 -> blue 3 -> dotted 3 -> magenta 4 -> red nodemark=1 -> circle 2 -> star 0 -> no mark elnum=edof(:,1) ; i.e. the first column in the topology matrix Rem. Default is solid white lines with circles at nodes. """ line_type = plotpar[0] line_color = plotpar[1] node_mark = plotpar[2] # Translate CALFEM plotpar to visvis vv_line_type = '-' vv_line_color = 'b' vv_node_mark = 'o' if line_type == 1: vv_line_type = '-' elif line_type == 2: vv_line_type = '--' elif line_type == 3: vv_line_type = ':' if line_color == 1: vv_line_color = 'k' elif line_color == 2: vv_line_color = 'b' elif line_color == 3: vv_line_color = 'm' elif line_color == 4: vv_line_color = 'r' if node_mark == 1: vv_node_mark = 'o' elif node_mark == 2: vv_node_mark = 'x' elif node_mark == 0: vv_node_mark = '' vv_marker_color = vv_line_color vv.axis('equal') draw_element_numbers = False if len(elnum) == ex.shape[0]: draw_element_numbers = True i = 0 for elx, ely in zip(ex, ey): x = elx.tolist() x.append(elx[0]) y = ely.tolist() y.append(ely[0]) xm = sum(x) / len(x) ym = sum(y) / len(y) vv.plot(x, y, ls=vv_line_type, lc=vv_line_color, ms=vv_node_mark, mc=vv_marker_color) if draw_element_numbers: text(str(elnum[i]), [xm, ym]) i += 1
# Set radius as scaled version of grayscale values. r = 5 + (np.sqrt((gray + 1)) - 1) * scalefactor # Equirectangular parametric equations to convert 2D map to 3D projection x = r * sin(phi) * cos(theta) y = r * sin(phi) * sin(theta) z = r * cos(phi) #+ 0.5* sin(sqrt(x**2 + y**2)) * cos(2*theta) # ____ _ _ # | _ \| | ___ | |_ # | |_) | |/ _ \| __| # | __/| | (_) | |_ # |_| |_|\___/ \__| vv.figure() vv.axis('off') k = vv.surf(x, y, z, img) # If you turn on edge shading, things get weird k.faceShading = 'smooth' k.edgeShading = None Rot = vv.Transform_Rotate(1) k.transformations.insert(0, Rot) axes = vv.gca() # Zoom axes.SetLimits(margin=0.0) axes.SetLimits(margin=0.0, rangeX=(-1, 1)) # Control lighting #axes.bgcolor='k'
""" # Get axes if axes is None: axes = vv.gca() if command == 'off': axes.axis.visible = 0 elif command == 'on': axes.axis.visible = 1 elif command == 'equal': axes.daspectAuto = 0 elif command == 'auto': axes.daspectAuto = 1 elif command == 'tight': axes.SetLimits() elif command == 'ij': da = [abs(tmp) for tmp in axes.daspect] axes.daspect = da[0], -abs(da[1]), da[2] elif command == 'xy': da = [abs(tmp) for tmp in axes.daspect] axes.daspect = da[0], abs(da[1]), da[2] else: raise ValueError('Unknown command in vv.axis().') if __name__ == '__main__': l = vv.plot([1,2,3,1,4,0]) vv.axis('off')
def view(mol, viewer='native'): '''Render the molecule The mayavi backend doesn't work under python 3. The native backend uses visvis to render the molecule. This is very slow. It's better to use the molecular viewer. Args: mol (molecule.Molecule): The molecule instance to render viewer: The backend to use. Valid choices are 'native', 'maya' and, 'avogadro' (default: native). Rturns: None ''' # mayavi if viewer == 'maya': from mayavi import mlab for atom in mol.atoms: pts = mlab.points3d(atom.r[0], atom.r[1], atom.r[2], scale_factor=0.75, scale_mode='none', resolution=20, color=atom.color()) for i, j in mol.bonds(): mlab.plot3d([mol.atoms[i].r[0], mol.atoms[j].r[0]], [mol.atoms[i].r[1], mol.atoms[j].r[1]], [mol.atoms[i].r[2], mol.atoms[j].r[2]], tube_radius=0.1, tube_sides=20) mlab.show() # avogadro if viewer == 'avogadro': from subprocess import call write_xyz(mol, 'avogadro.xyz') call(['avogadro', 'avogadro.xyz']) call(['rm', 'avogadro.xyz']) # visvis if viewer == 'native': import visvis as vv for atom in mol.atoms: x, y, z = atom.r at = vv.solidSphere((x, y, z), atom.radius()*0.25) at.faceColor = atom.color() for bond in mol.bonds(): pp = vv.Pointset(3) pp.append(bond.atoms[0].r) pp.append(bond.atoms[1].r) vv.solidLine(pp, radius=0.15, N=16) pp = vv.Pointset(3) pp.append([3, 3, 3]) pp.append([4, 3, 3]) x = vv.solidLine(pp, radius=0.05) x.faceColor = 'r' conex = vv.solidCone([4, 3, 3], scaling=[0.1, 0.1, 0.1], direction=[1, 0, 0]) conex.faceColor = 'r' pp = vv.Pointset(3) pp.append([3, 3, 3]) pp.append([3, 4, 3]) y = vv.solidLine(pp, radius=0.05) y.faceColor = 'g' coney = vv.solidCone([3, 4, 3], scaling=[0.1, 0.1, 0.1], direction=[0, 1, 0]) coney.faceColor = 'g' pp = vv.Pointset(3) pp.append([3, 3, 3]) pp.append([3, 3, 4]) z = vv.solidLine(pp, radius=0.05) z.faceColor = 'b' conez = vv.solidCone([3, 3, 4], scaling=[0.1, 0.1, 0.1], direction=[0, 0, 1]) conez.faceColor = 'b' # Set axes settings axes = vv.gca() axes.SetLimits(rangeX=(-5, 5), rangeY=(-5, 5), rangeZ=(-5, 5)) vv.axis('off') app = vv.use() app.Run()