def __init__(self): QtGui.QMainWindow.__init__(self) self.resize(300, 300) self.setWindowTitle('pyqtgraph example: Cone GLMeshItem') self.initActions() self.initMenus() self.propsWidget = ConeWidget() self.propsWidget.signalObjetChanged.connect(self.updateView) self.glWidget = gl.GLViewWidget(self) cols = self.propsWidget.param.props['cols'] l = self.propsWidget.param.props['length'] r = self.propsWidget.param.props['radius'] md = MyMeshData.cone(cols, length=l, radius=r) colors = self.getColors(md.faceCount()) md.setFaceColors(colors) self.glCone = gl.GLMeshItem(meshdata=md, smooth=True, drawEdges=True, edgeColor=(1,0,0,1)) self.glWidget.addItem(self.glCone) self.glWidget.setCameraPosition(distance=40) # Central Widget splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal) splitter1.addWidget(self.propsWidget ) splitter1.addWidget(self.glWidget ) self.setCentralWidget(splitter1)
def __init__(self): QtGui.QMainWindow.__init__(self) self.resize(300, 300) self.setWindowTitle("pyqtgraph example: GLTriadItem") self.initActions() self.initMenus() self.propsWidget = TriadWidget() self.propsWidget.signalObjetChanged.connect(self.updateView) self.glWidget = gl.GLViewWidget(self) rows = self.propsWidget.param.props["rows"] cols = self.propsWidget.param.props["cols"] Lx = self.propsWidget.param.props["Lx"] Ly = self.propsWidget.param.props["Ly"] Lz = self.propsWidget.param.props["Lz"] md = MyMeshData.triad(rows, cols) self.glTriad = gl.GLMeshItem(meshdata=md, smooth=False) self.glWidget.addItem(self.glTriad) self.glWidget.setCameraPosition(distance=5) # Central Widget splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal) splitter1.addWidget(self.propsWidget) splitter1.addWidget(self.glWidget) self.setCentralWidget(splitter1)
def updateView(self, param): cols = param.props['cols'] l = param.props['length'] r = param.props['radius'] flag = param.props['visible'] md = MyMeshData.cone(cols, length=l, radius=r) colors = self.getColors(md.faceCount()) md.setFaceColors(colors) self.glCone.setMeshData(meshdata=md) self.glCone.setVisible(flag)
def updateView(self, param): rows = param.props["rows"] cols = param.props["cols"] flag = param.props["visible"] Lx = param.props["Lx"] Ly = param.props["Ly"] Lz = param.props["Lz"] md = MyMeshData.triad(rows, cols, lx=Lx, ly=Ly, lz=Lz) self.glTriad.setMeshData(meshdata=md) self.glTriad.setVisible(flag)
def updateView(self, param): cols = param.props['cols'] rows = param.props['rows'] l = param.props['length'] r = param.props['radius'] fRC = param.props['fRC'] fLC = param.props['fLC'] flag = param.props['visible'] md = MyMeshData.arrow(rows, cols, length=l, radius=r, fRC=fRC, fLC=fLC) colors = self.getColors(md.faceCount()) md.setFaceColors(colors) self.glArrow.setMeshData(meshdata=md) self.glArrow.setVisible(flag)
## Define a top-level widget to hold everything w = QtGui.QWidget() w.resize(1000,600) ## Create some widgets to be placed inside btn = QtGui.QPushButton('press me') text = QtGui.QLineEdit('enter text') listw = QtGui.QListWidget() plot = gl.GLViewWidget() plot.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) g = gl.GLGridItem() #g.rotate(90,1,0,0) plot.addItem(g) ## Create arrow arrow_md = MyMeshData.arrow(rows=10, cols=20, radius = 0.05) colors = np.zeros((arrow_md.faceCount(), 4), dtype=float) colors[:,0] = 1.0 colors[:,3] = 1.0 arrow_md.setFaceColors(colors) arrow = gl.GLMeshItem(meshdata=arrow_md, smooth=True, drawEdges=True, edgeColor=(1,0,0,1), shader='balloon') plot.addItem(arrow) ## Create a grid layout to manage the widgets size and position layout = QtGui.QGridLayout() w.setLayout(layout) layout.setColumnStretch (1, 2) ## Add widgets to the layout in their proper positions layout.addWidget(btn, 0, 0) # button goes in upper-left layout.addWidget(text, 1, 0) # text edit goes in middle-left