def plotRefPoints(self, pos, size): pos[..., 0] -= self.main.pointCloud.medians[0] pos[..., 1] -= self.main.pointCloud.medians[1] self.refBarItem = gl.GLBarGraphItem(pos, size) self.refBarItem.setGLOptions('additive') self.refBarItem.setColor([1, 0, 0, 0.75]) self.addItem(self.refBarItem)
def initialize(self, Network_UI): self.my_Tab = Network_UI.Next_Tab(self.title) self.glvw = gl.GLViewWidget() self.glvw.setBackgroundColor((255.0, 255.0, 255.0, 255.0)) #self.glvw.setAutoFillBackground(True) #pg.setConfigOption('background', 'w') #pg.setConfigOption('foreground', 'k') #n = Network_UI.network[Network_UI.neuron_select_group, 0] for n in Network_UI.network.NeuronGroups: n.bars = [] for i in range(n.size): pos = np.array([[[n.y[i]-0.25, n.x[i]-0.25, n.z[i]-0.25]]]) size = np.array([.5, .5, .5]) bg = gl.GLBarGraphItem(pos, size) bg.setColor((.5, 1., .5, .5)) #bg.setGLOptions('translucent') self.glvw.addItem(bg) n.bars.append(bg) #Xdot = (0, 0, 0) #Ydot = (100, 100, 100) #pts = np.array([Xdot, Ydot]) #line = gl.GLLinePlotItem(pos=pts, width=1, antialias=True) #bg.setColor((1., 1., 1., 1.)) #self.glvw.addItem(line) Network_UI.Add_element(self.glvw)
def get_mapping(self): mapped_grid = np.empty((nx, ny), dtype=object) for x in range(nx): for y in range(ny): size = np.empty((nx, ny, 3)) pos = np.empty((nx, ny, 3)) size[..., :] = [1, 1, 0] pos[..., :] = [x - nx / 2, y - ny / 2, 0] area = opengl.GLBarGraphItem(pos, size) area.setColor(self.black) self.window.addItem(area) mapped_grid[x, y] = area return mapped_grid
w.show() w.setWindowTitle('pyqtgraph example: GLBarGraphItem') gx = gl.GLGridItem() gx.rotate(90, 0, 1, 0) gx.translate(-10, 0, 10) w.addItem(gx) gy = gl.GLGridItem() gy.rotate(90, 1, 0, 0) gy.translate(0, -10, 10) w.addItem(gy) gz = gl.GLGridItem() gz.translate(0, 0, 0) w.addItem(gz) # regular grid of starting positions pos = np.mgrid[0:10, 0:10, 0:1].reshape(3, 10, 10).transpose(1, 2, 0) # fixed widths, random heights size = np.empty((10, 10, 3)) size[..., 0:2] = 0.4 size[..., 2] = np.random.normal(size=(10, 10)) bg = gl.GLBarGraphItem(pos, size) w.addItem(bg) ## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': import sys if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): QtGui.QApplication.instance().exec_()