Esempio n. 1
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.resize(300, 300)
        self.setWindowTitle('pyqtgraph example: Cone GLMeshItem')

        self.initActions()
        self.initMenus()


        self.propsWidget = ArrowWidget()
        self.propsWidget.signalObjetChanged.connect(self.updateView)

        self.glWidget = gl.GLViewWidget(self)
        cols = self.propsWidget.param.props['cols']
        rows = self.propsWidget.param.props['rows']
        l = self.propsWidget.param.props['length']
        r = self.propsWidget.param.props['radius']
        fRC = self.propsWidget.param.props['fRC']
        fLC =  self.propsWidget.param.props['fLC']
        md = MyMeshData.arrow(rows, cols, radius=r, length=l, fLC=fLC, fRC=fRC)
        colors = self.getColors(md.faceCount())
        md.setFaceColors(colors)
        self.glArrow = gl.GLMeshItem(meshdata=md, drawEdges=True, edgeColor=(1,0,0,1))
        self.glWidget.addItem(self.glArrow)
        self.glWidget.setCameraPosition(distance=5)
        
        # Central Widget
        splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal) 

        splitter1.addWidget(self.propsWidget )
        splitter1.addWidget(self.glWidget )
               
        self.setCentralWidget(splitter1)        
Esempio n. 2
0
 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