Python源码示例:pyqtgraph.opengl.GLMeshItem()

示例1
def clearControls(self):
    """
    Reset all controls.
    """

    # Remove all items
    while len(self.simulationViewer.items) > 0:
      self.simulationViewer.removeItem(self.simulationViewer.items[0])

    # Draw a sphere only to initialize simulation.
    # If we don't do this, viewer crashes. Probably a PYQtGraph bug
    fooMd = gl.MeshData.sphere(rows=10, cols=10)
    self.fooItem = gl.GLMeshItem(meshdata=fooMd, smooth=False, shader='shaded', glOptions='opaque')
    self.fooItem.translate(0, 0, 0)
    self.simulationViewer.addItem(self.fooItem)
    self.simulationViewer.setCameraPosition(distance = 10000) 
示例2
def __drawBit(self, bit):

    # Update properties according to state
    isVisible = True
    if self.menuShowBitsNone.isChecked():
      isVisible = False
    elif bit.isFalselyPredicted.atGivenStepAgo(Global.selStep) and self.menuShowBitsFalselyPredicted.isChecked():
      color = self.colorBitFalselyPredicted
    elif bit.isPredicted.atGivenStepAgo(Global.selStep) and self.menuShowBitsPredicted.isChecked():
      color = self.colorBitPredicted
    elif bit.isActive.atGivenStepAgo(Global.selStep) and self.menuShowBitsActive.isChecked():
      color = self.colorBitActive
    else:
      color = self.colorInactive

    if isVisible:
      # Draw the input bit
      if not bit.tree3d_initialized:
        # TODO: Use cube instead of sphere
        bitMd = gl.MeshData.sphere(rows=2, cols=4)
        bit.tree3d_item = gl.GLMeshItem(meshdata=bitMd, shader='shaded', smooth=False, glOptions='opaque')
        bit.tree3d_item.translate(bit.tree3d_x, bit.tree3d_y, bit.tree3d_z)
        bit.tree3d_initialized = True
        self.simulationViewer.addItem(bit.tree3d_item)

      # Update the color
      if bit.tree3d_selected:
        color = self.colorSelected
      bit.tree3d_item.setColor(color)

    if bit.tree3d_item != None:
      bit.tree3d_item.setVisible(isVisible) 
示例3
def draw_3d_bbox_meshes_in_pyqt(widget,
                                bboxes,
                                colors=GLColor.Gray,
                                alpha=1.0,
                                edgecolors=None):
    verts, faces = _3d_bbox_to_mesh(bboxes)
    if not isinstance(colors, list):
        if isinstance(colors, GLColor):
            colors = gl_color(colors, alpha)
        colors = np.array([colors for i in range(len(verts))])
    m1 = gl.GLMeshItem(
        vertexes=verts, faces=faces, faceColors=colors, smooth=False)
    m1.setGLOptions('additive')
    widget.addItem(m1)
    return widget 
示例4
def draw_3d_bbox_meshes_in_pyqt(widget,
                                bboxes,
                                colors=GLColor.Gray,
                                alpha=1.0,
                                edgecolors=None):
    verts, faces = _3d_bbox_to_mesh(bboxes)
    if not isinstance(colors, list):
        if isinstance(colors, GLColor):
            colors = gl_color(colors, alpha)
        colors = np.array([colors for i in range(len(verts))])
    m1 = gl.GLMeshItem(
        vertexes=verts, faces=faces, faceColors=colors, smooth=False)
    m1.setGLOptions('additive')
    widget.addItem(m1)
    return widget 
示例5
def __drawCell(self, cell):

    # Update properties according to state
    isVisible = True
    if self.menuShowCellsNone.isChecked():
      isVisible = False
    elif cell.isFalselyPredicted.atGivenStepAgo(Global.selStep) and self.menuShowCellsFalselyPredicted.isChecked():
      color = self.colorCellFalselyPredicted
    elif cell.isPredicted.atGivenStepAgo(Global.selStep) and self.menuShowCellsPredicted.isChecked():
      color = self.colorCellPredicted
    elif cell.isLearning.atGivenStepAgo(Global.selStep) and self.menuShowCellsLearning.isChecked():
      color = self.colorCellLearning
    elif cell.isActive.atGivenStepAgo(Global.selStep) and self.menuShowCellsActive.isChecked():
      color = self.colorCellActive
    elif self.menuShowCellsInactive.isChecked():
      color = self.colorInactive
    else:
      isVisible = False

    if isVisible:
      # Draw the cell
      if not cell.tree3d_initialized:
        cellMd = gl.MeshData.sphere(rows=10, cols=10)
        cell.tree3d_item = gl.GLMeshItem(meshdata=cellMd, shader='shaded', smooth=False, glOptions='opaque')
        cell.tree3d_item.translate(cell.tree3d_x, cell.tree3d_y, cell.tree3d_z)
        cell.tree3d_initialized = True
        self.simulationViewer.addItem(cell.tree3d_item)

      # Update the color
      if cell.tree3d_selected:
        color = self.colorSelected
      cell.tree3d_item.setColor(color)

    if cell.tree3d_item != None:
      cell.tree3d_item.setVisible(isVisible)

    # Draw/update all distal segments
    for segment in cell.segments:
      segment.tree3d_x1 = cell.tree3d_x
      segment.tree3d_y1 = cell.tree3d_y
      segment.tree3d_z1 = cell.tree3d_z
      segment.tree3d_x2, segment.tree3d_y2, segment.tree3d_z2 = self.__calculateSegmentEndPos(segment, segment.tree3d_x1, segment.tree3d_y1, segment.tree3d_z1)
      self.__drawSegment(segment)