예제 #1
0
 def debug_solver_viewer(self, coordinates, value, cmap, norm_method, gamma, base_opacity, opacity_filter=None, opacity_param=0.1):
     #
     import image_filter
     self.image_filter = image_filter.ImageFilter()
     #
     self.gl_widget = gl.GLViewWidget()
     self.gl_widget.show()
     self.gl_widget.setWindowTitle('FEM Solver Viewer')
     self.gl_widget.setCameraPosition(distance=0.05*self.unit_scale)
     # Add Grid Item
     gl_grid = gl.GLGridItem()
     gl_grid.scale(0.01*self.unit_scale, 0.01*self.unit_scale, 0.01*self.unit_scale)
     self.gl_widget.addItem(gl_grid)
     # Add Geometry Item
     # self.add_geometry_view(gl_widget)
     (values_norm, color_values_norm) = self.image_filter.color_normalizer(value=value,
                                                            cmap=cmap,
                                                            base_opacity=base_opacity,
                                                            norm_method=norm_method,
                                                            gamma=gamma,
                                                            initial=True,
                                                            coordinates=self.sensing_domain_coordinates)
     # Set opacity filter
     color_values_final = self.image_filter.opacity_filter(opacity_filter=opacity_filter,
                                                           opacity_param=opacity_param,
                                                           values=value,
                                                           values_norm=values_norm,
                                                           color_values_norm=color_values_norm,
                                                           coordinates=self.sensing_domain_coordinates)
     #
     self.item_dof = gl.GLScatterPlotItem(pos=coordinates, color=color_values_final, size=0.001*self.unit_scale, pxMode=False)
     self.item_dof.setGLOptions('additive')
     self.gl_widget.addItem(self.item_dof)
예제 #2
0
def pgPlotSurface(x, y, z, shader='normalColor', autoscale=True, title=None):
    '''
    Adds a new window with a surface plot and a grid item.
    
    Returns
    w = view widget item
    g = grid item
    p = plot item
    '''

    # win = pg.GraphicsWindow()
    w = gl.GLViewWidget()
    w.show()
    w.setWindowTitle(title)

    g = gl.GLGridItem()

    if autoscale == True:
        sx = np.max(np.abs(x))
        sy = np.max(np.abs(y))
        g.scale(sx, sy, 1)

        w.setCameraPosition(distance=np.max([sx, sy]) * 2)

    g.setDepthValue(
        10)  # draw grid after surfaces since they may be translucent
    w.addItem(g)

    p = gl.GLSurfacePlotItem(x=x, y=y, z=z, shader=shader)
    w.addItem(p)

    return w, g, p
예제 #3
0
def visualize_3d():
    #app = QtGui.QApplication([])
    w = gl.GLViewWidget()
    w.show()
    g = gl.GLGridItem()
    w.addItem(g)

    df = pd.read_csv('positions_d.txt')
    df = df[df.columns[0:3]].values / 5

    cmap = plt.get_cmap('cool')
    colors = []
    for i in range(df.shape[0]):
        normal_num = i / df.shape[0]
        colors.append(cmap(normal_num))

    colors = np.array(colors)

    indexesFinal = np.array([[1, 2]])
    sp2 = gl.GLScatterPlotItem(pos=df, size=0.1, pxMode=False, color=colors)
    w.addItem(sp2)

    sp2 = gl.GLLinePlotItem(pos=df, width=0.5)
    w.addItem(sp2)

    ## 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_()
예제 #4
0
 def __init__(self):
     super(PositionGraph, self).__init__()
     self.setWindowTitle('Anser Position')
     self.setBackgroundColor('w')
     anser_mesh = mesh.Mesh.from_file(
         utils.resource_path('./app/resources/cad/mesh.stl'))
     anser_mesh = gl.MeshData(vertexes=anser_mesh.vectors)
     m = gl.GLMeshItem(meshdata=anser_mesh,
                       shader='shaded',
                       color=(0, 1, 0, 0.1))
     m.rotate(135, 0, 0, 1)
     m.translate(240, 0, -240)
     m.scale(1, 1, 1)
     self.addItem(m)
     gx = gl.GLGridItem()
     gx.setSize(7, 7, 7)
     gx.scale(45, 45, 45)
     gx.rotate(45, 0, 0, 1)
     #self.addItem(gx)
     self.pos = np.empty((MAX_NUM_OF_SENSORS, 3))
     self.color = np.empty((MAX_NUM_OF_SENSORS, 4))
     size = np.empty(MAX_NUM_OF_SENSORS)
     for i in range(MAX_NUM_OF_SENSORS):
         self.pos[i] = (0, 0, 0)
         self.color[i] = (0, 0.0, 0.0, 0.0)
         size[i] = 6
     self.sp1 = gl.GLScatterPlotItem(pos=self.pos,
                                     size=size,
                                     color=self.color[0],
                                     pxMode=True)
     self.sp1.setGLOptions('translucent')
     self.addItem(self.sp1)
     self.setCameraPosition(100, 800, 30)
     self.sp1.rotate(135, 0, 0, 1)
예제 #5
0
    def initUI(self):
        layout = QGridLayout()
        self.setLayout(layout)

        tabs = QTabWidget()

        self.canvas = pg.GraphicsLayoutWidget()
        self.plot = self.canvas.addPlot()
        self.plot.setRange(xRange=(-3, 2), yRange=(-1, 1))
        self.pt = self.plot.plot(pen='w')
        self.pt2 = self.plot.plot()
        self.pt2.setPen(pg.mkPen('r', style=Qt.DotLine))

        self.view = gl.GLViewWidget()
        self.view.show()

        #Create gird
        zgrid = gl.GLGridItem()
        zgrid.scale(0.1, 0.1, 0.1)
        self.view.addItem(zgrid)

        tabs.addTab(self.canvas, "Sketch")
        tabs.addTab(self.view, "3D View")
        tabs.setMaximumHeight(600)

        layout.addWidget(tabs, 0, 0, 5, 15)

        specs = SpecWidget()
        specs.setMaximumHeight(600)
        layout.addWidget(specs, 15, 0)
        specs.drawKey()

        self.show()
예제 #6
0
def track3D(state):
    app = QtGui.QApplication([])
    w = gl.GLViewWidget()
    w.setWindowTitle('3d trajectory')
    w.resize(600, 500)
    # instance of Custom3DAxis
    axis = Custom3DAxis(w, color=(0.6, 0.6, 0.2, .6))
    w.addItem(axis)
    w.opts['distance'] = 75
    w.opts['center'] = Vector(0, 0, 15)
    # add xy grid
    gx = gl.GLGridItem()
    gx.setSize(x=40, y=40, z=10)
    gx.setSpacing(x=5, y=5)
    w.addItem(gx)
    # trajectory line
    pos0 = np.array([[0, 0, 0]])
    pos, q = np.array(state[:3]), state[3:7]
    uAxis, angle = q2ua(*q)
    track0 = np.concatenate((pos0, pos.reshape(1, 3)))
    plt = gl.GLLinePlotItem(pos=track0, width=2, color=(1, 0, 0, .6))
    w.addItem(plt)
    # orientation arrow
    sphereData = gl.MeshData.sphere(rows=20, cols=20, radius=0.3)
    sphereMesh = gl.GLMeshItem(meshdata=sphereData, smooth=True, shader='shaded', glOptions='opaque')
    w.addItem(sphereMesh)
    ArrowData = gl.MeshData.cylinder(rows=20, cols=20, radius=[0.2, 0.], length=0.7)
    ArrowMesh = gl.GLMeshItem(meshdata=ArrowData, smooth=True, color=(1, 0, 0, 0.6), shader='balloon',
                              glOptions='opaque')
    ArrowMesh.rotate(90, 0, 1, 0)
    w.addItem(ArrowMesh)
    w.show()

    i = 1
    pts = pos.reshape(1, 3)

    def update():
        '''update position and orientation'''
        nonlocal i, pts, state
        pos, q = np.array(state[:3]) * 100, state[3:7]
        uAxis, angle = q2ua(*q)
        pt = (pos).reshape(1, 3)
        if pts.size < 150:
            pts = np.concatenate((pts, pt))
        else:
            pts = np.concatenate((pts[-50:, :], pt))
        plt.setData(pos=pts)
        ArrowMesh.resetTransform()
        sphereMesh.resetTransform()
        ArrowMesh.rotate(angle, uAxis[0], uAxis[1], uAxis[2])
        ArrowMesh.translate(*pos)
        sphereMesh.translate(*pos)
        i += 1

    timer = QtCore.QTimer()
    timer.timeout.connect(update)
    timer.start(50)

    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
예제 #7
0
    def __init__(self):

        self.app = QtGui.QApplication([])
        self.view = gl.GLViewWidget()
        self.view.opts['distance'] = 10
        self.view.show()
        self.view.setWindowTitle("Points Visualizer")

        grid = gl.GLGridItem(size=QtGui.QVector3D(10, 10, 1))
        grid.setSpacing(0.5, 0.5, 0.5)
        self.view.addItem(grid)

        axis = GLRGBAxisItem(size=QtGui.QVector3D(0.5, 0.5, 0.5))
        self.view.addItem(axis)

        self.gtFrustum = GLFrustumItem(frustumColor=(0.8, 0, 0, 0.6),
                                       size=QtGui.QVector3D(0.5, 0.5, 0.5))
        self.view.addItem(self.gtFrustum)

        self.gtLine = gl.GLLinePlotItem(color=(0.8, 0, 0, 0.6))
        self.view.addItem(self.gtLine)
        self.gtPositions = []

        self.estimatedFrustum = GLFrustumItem(frustumColor=(1, 1, 1, 0.6),
                                              size=QtGui.QVector3D(
                                                  0.5, 0.5, 0.5))
        self.view.addItem(self.estimatedFrustum)

        self.estimatedLine = gl.GLLinePlotItem(color=(1, 1, 1, 0.6))
        self.view.addItem(self.estimatedLine)
        self.estimatedPositions = []

        self.points = gl.GLScatterPlotItem(color=(0, 0.8, 0, 1), size=3.0)
        self.points.setData(pos=np.zeros((1, 3)))
        self.view.addItem(self.points)
예제 #8
0
    def __init__(self):
        self.traces = dict()
        self.app = QtGui.QApplication(sys.argv)
        self.w = gl.GLViewWidget()
        self.w.opts['distance'] = 450
        self.w.orbit(-180, -15)
        self.w.pan(100, 75, 50)
        self.w.setWindowTitle('FEAGI')
        # self.w.setGeometry(0, 110, 1920, 1080)
        self.w.show()
        print("Camera position is:", self.w.cameraPosition())

        g = gl.GLGridItem()
        g.scale(20, 20, 20)
        g.translate(200, 200, 0)
        self.w.addItem(g)

        # self.pts = np.array(neuron_positions('vision_memory'))
        self.pts = neuron_positions('vision_memory')
        for i in range(self.pts.shape[0]):
            self.traces[i] = gl.GLScatterPlotItem(pos=self.pts,
                                                  color=(1, 1, 1, .3),
                                                  size=0.1,
                                                  pxMode=True)
            self.w.addItem(self.traces[i])
예제 #9
0
def plot_single(x, y, z, pitch, roll, yaw):
    print("in plot_single ")

    w = gl.GLViewWidget()
    w.show()
    w.setWindowTitle("pyqtgraph example: GLMeshItem")
    w.setCameraPosition(distance=40)

    g = gl.GLGridItem()
    g.scale(2, 2, 1)
    w.addItem(g)
    # Example 4:
    # Cylinder

    md = gl.MeshData.cylinder(rows=10, cols=20, radius=[2.0, 2.0], length=5.0)
    m1 = gl.GLMeshItem(
        meshdata=md,
        smooth=False,
        drawFaces=False,
        drawEdges=True,
        edgeColor=(1, 1, 1, 1),
    )
    m1.translate(x, y, z)

    m1.rotate(pitch, 0, 1, 0)
    m1.rotate(roll, 1, 0, 0)
    m1.rotate(yaw, 0, 0, 1)
    w.addItem(m1)
예제 #10
0
    def __init__(self, osc_worker):
        super().__init__()
        self.widget = w = gl.GLViewWidget()
        w.setCameraPosition(distance=40)
        w.show()
        g = gl.GLGridItem()
        g.scale(2, 2, 1)
        w.addItem(g)

        self._quaternion_reps = {}

        self._osc_worker = osc_worker
        self._osc_worker.message.connect(self._got_osc)
        self._osc_worker.new_path.connect(self.new_path)  # just forward
        self.reset.connect(lambda path: self._osc_worker.reset(path))
        self.update_mask.connect(
            lambda path, mask: self._osc_worker.update_mask(path, mask),
        )
        self.update_gain.connect(
            lambda path, sensor_no, gain: self._osc_worker.update_gain(
                path,
                sensor_no,
                gain,
            ),
        )
        self._osc_worker.start()
예제 #11
0
    def __init__(self):
        self.app = QtGui.QApplication(sys.argv)
        self.w = gl.GLViewWidget()
        self.w.opts['distance'] = 40
        self.w.setWindowTitle('pyqtgraph example: GLLinePlotItem')
        self.w.setGeometry(0, 110, 700, 700)
        self.w.show()
        self.dt = 0.015



        # gx = gl.GLGridItem()
        # gx.rotate(90, 0, 1, 0)
        # gx.translate(-10, 0, 0)
        # self.w.addItem(gx)
        # gy = gl.GLGridItem()
        # gy.rotate(90, 1, 0, 0)
        # gy.translate(0, -10, 0)
        # self.w.addItem(gy)
        gz = gl.GLGridItem()
        gz.translate(0, 0, -10)
        self.w.addItem(gz)
        self.color = 1
        self.x = 0.01
        self.y = 0
        self.z = 0

        self.a = 10
        self.b = 28
        self.c = 8/3
        self.lastPosition = np.array([0,0,-10])
예제 #12
0
 def __init__(self):
     super(Structure3DScatterWidget, self).__init__()
     self.glViewWidget = gl.GLViewWidget(self)
     self.glViewWidget.opts['distance'] = 30
     self.glViewWidget.show()
     g = gl.GLGridItem() #grid layer
     self.glViewWidget.addItem(g)
예제 #13
0
    def __init__(self, mesh_path, *args, **kwargs):
        super(PlaneWidget, self).__init__(*args, **kwargs)
        self.setCameraPosition(distance=40)

        g = gl.GLGridItem()
        g.scale(2, 2, 1)
        g.translate(0, 0, -2)
        self.addItem(g)

        self.plane_axis = gl.GLAxisItem()
        self.plane_axis.setSize(x=1000, y=500, z=500)
        self.addItem(self.plane_axis)

        verts = self._get_mesh_points(mesh_path)
        faces = np.array([(
            i,
            i + 1,
            i + 2,
        ) for i in range(0, len(verts), 3)])
        colors = np.array([(
            0.0,
            1.0,
            0.0,
            1.0,
        ) for i in range(0, len(verts), 3)])
        self.mesh = gl.GLMeshItem(vertexes=verts,
                                  faces=faces,
                                  faceColors=colors,
                                  smooth=False,
                                  shader='shaded')
        self.addItem(self.mesh)
        self._update_mesh(Record(None))
예제 #14
0
def show_strokes_3d(key, strokes, mean_stroke):
    view = gl.GLViewWidget()

    view.orbit(75, -15)
    view.show()
    # view.readQImage().save('%s-r.png'%key)
    # view.setBackgroundColor([255, 255, 255, 0])
    ## create three grids, add each to the view
    # xgrid = gl.GLGridItem(color=(0,0,0,255))
    # ygrid = gl.GLGridItem()
    zgrid = gl.GLGridItem()

    # color = np.array([0, 0, 1, 0.2])
    # for stroke in strokes:
    #     pos = stroke['data']

    #     colors = np.tile(color, (pos.shape[0], 1))

    #     line = gl.GLLinePlotItem(pos=pos, color=colors, width=5)
    #     view.addItem(line)

    pos = mean_stroke[:, :3]

    color1 = np.array([0, 1, 0, 1])
    color2 = np.array([1, 0, 0, 1])

    steps = np.linspace(0, 1, pos.shape[0])

    R = np.interp(steps, np.array([0, 1]), np.array([color1[0], color2[0]]))
    G = np.interp(steps, np.array([0, 1]), np.array([color1[1], color2[1]]))
    B = np.interp(steps, np.array([0, 1]), np.array([color1[2], color2[2]]))
    A = np.interp(steps, np.array([0, 1]), np.array([color1[3], color2[3]]))

    colors = np.vstack((R, G, B, A)).T

    line = gl.GLLinePlotItem(pos=pos,
                             color=colors,
                             width=40,
                             mode='line_strip')
    view.addItem(line)

    # view.addItem(xgrid)
    # view.addItem(ygrid)
    view.addItem(zgrid)

    ## rotate x and y grids to face the correct direction
    # xgrid.rotate(90, 0, 1, 0)
    # ygrid.rotate(90, 1, 0, 0)

    print 'var geometry = new THREE.Geometry();\ngeometry.vertices.push(\n'
    for point in pos:
        print 'new THREE.Vector3(%f, %f, %f),' % (point[0], point[1], point[2])
    print ');\ngeometry.colors.push(\n'
    for color in colors:
        hexc = hex(
            int(color[0] * 255) * 65536 + int(color[1] * 255) * 256 +
            int(color[2] * 255))

        print 'new THREE.Color( %s ),' % hexc
    print ');'
예제 #15
0
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.setWindowTitle("Multiagent Communication")
        uic.loadUi('crazyflie_multiagent.ui', self)

        self.gl_widget = gl.GLViewWidget()
        self.gl_widget.setWindowTitle('Multi-agent Plotter')

        self.gl_widget.addItem(gl.GLGridItem())  # Add the grid to the plot

        self.addAxis()

        # Initialise mesh item to represent an agent
        md = gl.MeshData.sphere(rows=5, cols=5, radius=0.25)
        self.agent_mesh = gl.GLMeshItem(meshdata=md,
                                        smooth=False,
                                        drawFaces=False,
                                        drawEdges=True,
                                        edgeColor=(1, 1, 1, 1))

        self.gl_widget.addItem(self.agent_mesh)

        self.btn_exit.clicked.connect(self.btn_exit_clicked)
        self.action3D_visualiser.triggered.connect(self.open_visualiser)
예제 #16
0
    def __init__(self):
        self.app = QtGui.QApplication(sys.argv)
        self.w = gl.GLViewWidget()
        self.w.setGeometry(0, 110, 1920, 1080)
        self.w.show()
        self.w.setWindowTitle('Example')
        self.w.setCameraPosition(distance=30, elevation=8)

        grid = gl.GLGridItem()
        grid.scale(2,2,2)
        self.w.addItem(grid)

        self.nstep = 1
        self.ypoints = range(-20, 22, self.nstep)
        self.xpoints = range(-20, 22, self.nstep)
        self.nfaces = len(self.ypoints)

        verts = np.array([
            [
                x,y,0
            ] for n, x in enumerate(self.xpoints) for m, y in enumerate(self.ypoints)

        ], dtype=np.float32)

        faces = []

        for m in range(self.nfaces - 1):
            yoff = m * self.nfaces
            for n in range(self.nfaces - 1):
                faces.append()
def start_graph():
    print("Setting up graph")
    global app, graph_region, w, g, d3, t
    app = QtGui.QApplication([])
    w = gl.GLViewWidget()
    w.resize(800, 600)
    w.opts['distance'] = 20
    w.show()
    w.setWindowTitle('LIDAR Point Cloud')

    g = gl.GLGridItem()
    #g.translate(0,0,-10)
    w.addItem(g)

    #pos3 = np.zeros((100, 100, 3))
    #pos3[:, :, :2] = np.mgrid[:100, :100].transpose(1, 2, 0) * [-0.1, 0.1]
    #pos3 = pos3.reshape(10000, 3)
    #d3 = (pos3 ** 2).sum(axis=1) ** 0.5

    graph_region = gl.GLScatterPlotItem(pos=np.zeros((1, 3), dtype=np.float32), color=(0, 1, 0, 0.5), size=0.1, pxMode=False)
    #graph_region.rotate(180, 1, 0, 0)
    #graph_region.translate(0, 0, 2.4)
    w.addItem(graph_region)
    t = QtCore.QTimer()
    t.timeout.connect(update_graph)
    t.start(50)

    QtGui.QApplication.instance().exec_()
    global RUNNING
    RUNNING = False
    print("\n[STOP]\tGraph Window closed. Stopping...")
예제 #18
0
    def __init__(self, x=0, y=0, z=0, scale=0.1, widget=None):
        """
        If there is no widget given a new window is created and its id is accessible via self.widget.
        :param x: optional, float
        :param y: optional, float
        :param z: optional, float
        :param widget: optional, gl.GLViewWidget
        :return: None
        """
        if not widget:
            self.app = QtGui.QApplication([])
            self.widget = gl.GLViewWidget()
            self.widget.opts['distance'] = 40
            self.widget.show()
        else:
            self.app = False
            self.widget = widget

        self.scale = scale
        self.x = x
        self.y = y
        self.z = z
        self.rot0 = 0
        self.rot1 = 0
        self.rot2 = 0

        self.grid = gl.GLGridItem()
        self.grid.translate(self.x, self.y, self.z)
        self.widget.addItem(self.grid)
    def __init__(self,
                 data_shape=1024,
                 color=(1.0, 0.0, 0.0, 1.0),
                 start_angle=-3 * np.pi / 4.,
                 stop_angle=3 * np.pi / 4.,
                 widget=None):
        if not widget:
            self.app = QtGui.QApplication([])
            self.widget = gl.GLViewWidget()
            self.widget.opts['distance'] = 40
            self.widget.show()
        else:
            self.widget = widget

        self.axis = gl.GLAxisItem()
        self.axis.translate(0, 0, 1)
        self.widget.addItem(self.axis)

        self.gz = gl.GLGridItem()
        self.widget.addItem(self.gz)

        radius = np.ones((data_shape)) * 5
        self.start_angle = start_angle
        self.stop_angle = stop_angle
        self.angle = np.linspace(self.start_angle, self.stop_angle, data_shape)
        x = np.sin(self.angle) * radius
        y = np.cos(self.angle) * radius
        z = np.ones((data_shape))
        pts = np.vstack([x, y, z]).transpose()
        # self.line_plot = gl.GLLinePlotItem(pos=pts, color=np.array(color * data_shape).reshape((data_shape, 3)))
        self.line_plot = gl.GLScatterPlotItem(
            pos=pts,
            color=np.array(color * data_shape).reshape((data_shape, 4)),
            size=3.0)
        self.widget.addItem(self.line_plot)
 def __init__(self, parent=None):
     super().__init__(parent)
     
     self.computation=Computation()
     
     self.axes=gl.GLAxisItem(size=None, antialias=True, glOptions='translucent')
     self.addItem(self.axes)
     
     self.BrittleStar=BrittleStar()
     self.brittlestar_tail=BrittleStar_Tail()
     
     self.addItem(self.BrittleStar)
     self.addItem(self.brittlestar_tail)
     
     self.xygrid = gl.GLGridItem()
     self.xygrid.setSize(5,5,0)
     self.xygrid.setSpacing(1,1,0)
     self.xygrid.translate(0, 0, 0)
     self.addItem(self.xygrid)
     
     self.timer=QtCore.QTimer()
     self.timer.setInterval(100) #in ms
     self.timer.timeout.connect(self.refresh_anim)
     
     self.initial_pos=np.array([0,0,0])
     self.prev_pos=self.initial_pos
     self.initial_angle=np.array([0,0,0])
     self.prev_angle=self.initial_angle
예제 #21
0
    def __init__(self, geometry):
        super(viewport3D, self).__init__()
        # add a view box, which is a widget that allows an image to be shown
        # add an image item which handles drawing (and refreshing) the image
        self.setBackgroundColor((50, 50, 50, 255))
        self._geometry = geometry
        gy = gl.GLGridItem()
        gy.scale(0.1 * self._geometry.length(), 0.1 * self._geometry.length(),
                 0.1 * self._geometry.length())
        gy.rotate(90, 1, 0, 0)
        gy.translate(0, -self._geometry.halfheight(), 0)
        self.addItem(gy)

        self.buildDetector()

        if self._geometry.name() == "uboone":
            self.buildPaddleBox1()
            self.buildPaddleBox2()

        self.pan(self._geometry.halfwidth(), 0, 0.5 * self._geometry.length())

        # Set the camera to the correct starting position:
        pos = (self._geometry.halfwidth(), 5 * self._geometry.halfheight(),
               0.5 * geometry.length())
        self.setCameraPos(pos=pos)

        # print self.cameraPosition()
        # self.orbit(0,180)
        # print self.cameraPosition()
        # self.orbit(225,0)
        # print self.cameraPosition()

        # self.pan(0,0,self._geometry.length())
        self.show()
예제 #22
0
    def __init__(self, parent, palette):
        gl.GLViewWidget.__init__(self)
        self.parent = parent
        self.palette = palette
        self.release_ignore = False
        self.cut_widget = CutMagnetWidget(self, parent)

        self.objects = {}

        self.opts['distance'] = 300
        self.setBackgroundColor(pg.mkColor((127, 127, 127)))
        self.gridx = gl.GLGridItem()
        self.gridx.scale(1, 1, 1)
        self.gridx.setSize(x=10000, y=10000, z=10000)
        self.gridx.setSpacing(x=1000, y=1000, z=1000, spacing=None)
        self.gridx.setDepthValue(10)
        self.grid_start = [0, 0]
        self.addItem(self.gridx)
        self.objects['gridx'] = {'object': self.gridx}

        self.utm_zone = None
        self.utm_letter = None

        self.palette.recolor_signal.connect(
            lambda min, max: self.recolor_flying(min, max))
예제 #23
0
 def init_plot(self):
     if USE_GL:
         self.plotWidget = gl.GLViewWidget()
         g = gl.GLGridItem()
         self.plotWidget.addItem(g)
     else:
         self.plotWidget = pg.PlotWidget()
    def __init__(self, parent=None):
        super(App, self).__init__(parent)

        #### Create Gui Elements ###########
        self.mainbox = gl.GLViewWidget()
        self.setFixedSize(800, 800)
        self.setCentralWidget(self.mainbox)
        self.mainbox.setFixedSize(1600, 1200)
        self.mainbox.opts['viewport'] = (0, 0, 1600, 1200)
        self.mainbox.setWindowTitle('test')
        g = gl.GLGridItem()
        self.mainbox.addItem(g)
        pos = np.empty((21, 3))
        sizes = np.ones((21)) * 0.1
        colors = []
        colors_tpt = [[0, 1, 1, 1]]
        for i in range(5):
            colors.append(colors_tpt[0])
            colors.append(colors_tpt[0])
            colors.append(colors_tpt[0])
            colors.append(colors_tpt[0])
        colors.append([1, 0, 1, 1])

        self.sp = gl.GLScatterPlotItem(pos=pos,
                                       size=sizes,
                                       color=np.array(colors),
                                       pxMode=False)
        self.mainbox.addItem(self.sp)

        self.client = Client(app)
        # print(self.mainbox.getViewport())

        #### Start  #####################
        self._update()
예제 #25
0
    def add_grid(self):
        try:
            self.display.removeItem(self.grid)
            for axis in self.axis_lines:
                self.display.removeItem(axis)
            self.axis_lines = []
        except:
            pass
        self.grid = gl.GLGridItem(size=QtGui.QVector3D(self.grid_size[0] *
                                                       2, self.grid_size[1] *
                                                       2, 1))
        self.grid.setSpacing(spacing=QtGui.QVector3D(0.5, 0.5, 0.5))
        self.grid.translate(self.grid_size[0], self.grid_size[1], 0)

        line = gl.GLLinePlotItem(pos=self.axis_x,
                                 color=self.axis_colour,
                                 width=2,
                                 antialias=True)
        self.axis_lines.append(line)
        line = gl.GLLinePlotItem(pos=self.axis_y,
                                 color=self.axis_colour,
                                 width=2,
                                 antialias=True)
        self.axis_lines.append(line)
        line = gl.GLLinePlotItem(pos=self.axis_z,
                                 color=self.axis_colour,
                                 width=2,
                                 antialias=True)
        self.axis_lines.append(line)

        self.display.addItem(self.grid)
        for axis in self.axis_lines:
            self.display.addItem(axis)
예제 #26
0
    def addSurfaceGraph(self):
        self.x = np.linspace(-self.widthOfData / 2, self.widthOfData / 2,
                             self.widthOfData)
        self.y = np.linspace(-self.numberOfData / 2, self.numberOfData / 2,
                             self.numberOfData)
        self.surfacePlot = gl.GLSurfacePlotItem(
            self.x,
            self.y,
            shader='heightColor',
            computeNormals=False,
            smooth=False)  # smooth true = faster; dont turn on computenormals
        self.surfacePlot.shader()['colorMap'] = np.array(
            [0.01, 0, 0.5, 0.01, 0, 1, 0.01, 0, 2])  # lut
        self.surfaceData = np.zeros((self.widthOfData, self.numberOfData),
                                    dtype=int)

        ## create a surface plot, tell it to use the 'heightColor' shader
        ## since this does not require normal vectors to render (thus we
        ## can set computeNormals=False to save time when the mesh updates)
        # p4.translate(100, 100, 0)
        self.addItem(self.surfacePlot)

        ## Add a grid to the view
        self.g = gl.GLGridItem()
        self.g.setSize(x=self.widthOfData * 2, y=self.numberOfData * 2)
        # g.scale(2,2,1000)
        self.g.setDepthValue(
            10)  # draw grid after surfaces since they may be translucent
        self.addItem(self.g)
예제 #27
0
 def __init__(self):
     self.scale = 4000
     # initialize Qt gui application and window
     self.app = pg.QtGui.QApplication([])  # initialize QT
     self.window = gl.GLViewWidget()  # initialize the view object
     self.window.setWindowTitle('Path Viewer')
     self.window.setGeometry(
         0, 0, 1500,
         1500)  # args: upper_left_x, upper_right_y, width, height
     grid = gl.GLGridItem()  # make a grid to represent the ground
     grid.scale(self.scale / 20, self.scale / 20, self.scale /
                20)  # set the size of the grid (distance between each line)
     self.window.addItem(grid)  # add grid to viewer
     self.window.setCameraPosition(distance=self.scale,
                                   elevation=50,
                                   azimuth=-90)
     self.window.setBackgroundColor('k')  # set background color to black
     self.window.show()  # display configured window
     self.window.raise_()  # bring window to the front
     self.plot_initialized = False  # has the mav been plotted yet?
     # get points that define the non-rotated, non-translated mav and the mesh colors
     self.mav_points, self.mav_meshColors = self.get_mav_points()
     # dubins path parameters
     self.dubins_path = dubins_parameters()
     self.mav_body = []
예제 #28
0
def show_tri_qtgraph(M, T, v):

    x, y, z = get_xyz(M, T, v)

    ## Create a GL View widget to display data
    app = QtGui.QApplication([])
    w = gl.GLViewWidget()
    w.show()
    w.setCameraPosition(distance=50)

    ## Add a grid to the view
    g = gl.GLGridItem()
    g.scale(2, 2, 1)
    # draw grid after surfaces since they may be translucent
    g.setDepthValue(10)
    w.addItem(g)

    ## Saddle example with x and y specified
    print x.shape
    print y.shape
    print z.shape
    x = np.linspace(-8, 8, 50)
    y = np.linspace(-8, 8, 50)
    z = 0.1 * ((x.reshape(50, 1)**2) - (y.reshape(1, 50)**2))
    print x.shape
    print y.shape
    print z.shape
    #p2 = gl.GLSurfacePlotItem(x=x, y=y, z=z, shader='normalColor')
    p2 = gl.GLSurfacePlotItem(x=x, y=y, z=z, shader='shaded')
    #p2.translate(-10,-10,0)
    w.addItem(p2)

    app.exec_()
예제 #29
0
def init_3d_plot():
    pg.mkQApp()
    view = gl.GLViewWidget()
    view.show()
    xgrid = gl.GLGridItem()
    ygrid = gl.GLGridItem()
    zgrid = gl.GLGridItem()
    view.addItem(xgrid)
    view.addItem(ygrid)
    view.addItem(zgrid)
    xgrid.rotate(90, 0, 1, 0)
    ygrid.rotate(90, 1, 0, 0)
    xgrid.scale(0.2, 0.1, 0.1)
    ygrid.scale(0.2, 0.1, 0.1)
    zgrid.scale(0.1, 0.2, 0.1)
    return view
예제 #30
0
 def __init__(self):
     self.app=QtGui.QApplication(sys.argv)
     self.window = opengl.GLViewWidget()
     self.window.setGeometry(0,410,800,800)
     self.window.setCameraPosition(distance=12,azimuth=270)
     x_axis=opengl.GLGridItem()
     x_axis.setSize(x=10,y=10)
     #y_axis=opengl.GLGridItem()
     #y_axis.rotate(90,0,1,0)
     #self.window.addItem(y_axis)
     self.grid=Cell()
     self.q=Qlearning(no_of_actions,no_of_states,state_combinations)
     self.window.addItem(x_axis)
     self.current_node=self.grid.grid_nodes[0]
     self.nodes=opengl.GLScatterPlotItem(pos=self.grid.grid_nodes,color=glColor((0,255,0)),size=7)
     self.goal=opengl.GLScatterPlotItem(pos=self.grid.goal_node,color=glColor((0,0,255)),size=15)
     self.current_node_item=opengl.GLScatterPlotItem(pos=self.current_node,color=glColor((255,0,0)),size=9)
     self.blocked=opengl.GLScatterPlotItem(pos=self.grid.blocked_nodes,color=glColor((255,255,255)),size=13)
     self.counter=0
     self.generation_counter=0
     self.step_counter=0
     self.tracker=[]
     self.window.addItem(self.nodes)
     self.window.addItem(self.blocked)
     self.window.addItem(self.current_node_item)
     self.window.addItem(self.goal)
     self.window.show()