Example #1
0
    def __init__(self, cut_processor, machine):
        super().__init__()
        self._cut_proc = cut_processor
        self._machine = machine
        length, width, height = self._machine.get_dimensions()

        self.canvas = scene.SceneCanvas(keys='interactive',
                                        size=(800, 600),
                                        create_native=True)
        self.camera = scene.cameras.TurntableCamera(fov=45.0,
                                                    elevation=30.0,
                                                    azimuth=30.0,
                                                    roll=0.0,
                                                    distance=None)
        self.view = self.canvas.central_widget.add_view(self.camera)

        # set ortho
        self.camera.fov = 0.0

        self.plot_l = scene.LinePlot(width=2.0,
                                     color=(0.91, 0.31, 0.22, 1.0),
                                     parent=self.view.scene)
        self.plot_r = scene.LinePlot(width=2.0,
                                     color=(0.18, 0.53, 0.67, 1.0),
                                     parent=self.view.scene)
        self.mplot_l = scene.LinePlot(width=2.0,
                                      color=(1.0, 0.0, 0.0, 1.0),
                                      parent=self.view.scene)
        self.mplot_r = scene.LinePlot(width=2.0,
                                      color=(1.0, 0.0, 0.0, 1.0),
                                      parent=self.view.scene)
        self.face_l = scene.visuals.Mesh(color=(0.82, 0.28, 0.20, 1.0),
                                         mode='triangles',
                                         parent=self.view.scene)
        self.face_r = scene.visuals.Mesh(color=(0.16, 0.48, 0.60, 1.0),
                                         mode='triangles',
                                         parent=self.view.scene)

        CuttingPathNode = scene.visuals.create_visual_node(CuttingPathVisual)
        self.cutting_path = CuttingPathNode(color=(0.5, 0.5, 0.5, 1),
                                            parent=self.view.scene)

        m_grid = machine_grid(length, width, height, 50)
        self.mgrid_visual = scene.visuals.Line(pos=m_grid,
                                               color=(0.8, 0.8, 0.8, 0.5),
                                               connect='segments',
                                               antialias=True,
                                               parent=self.view.scene)

        self.canvas.events.mouse_press.connect(on_mouse_press)
        self.canvas.events.mouse_move.connect(on_mouse_move)

        self._cut_proc.update.connect(self.draw)
Example #2
0
 def add_var(self, var):
     self._tracked_vars.append(var)
     self.lines.append(
         scene.LinePlot(
             np.empty((2, 1)),
             color=COLORS[len(self.lines) % len(COLORS)],
             marker_size=0,
             parent=self.view.scene,
         ))
Example #3
0
 def _plot_line(self, color, data, width):
     line = scene.LinePlot(data, connect='strip', color=color, width=width)
     self.view.add(line)
     self.view.camera.set_range()
     return line
Example #4
0
 def add_curve(self, curve, index):
     self.n += 1
     self.lines[index] = scene.LinePlot(curve,
                                        color=self.colormap[self.n],
                                        parent=self.view.scene)
Example #5
0
    def plot(self,
             data,
             color='k',
             symbol=None,
             line_kind='-',
             width=1.,
             marker_size=10.,
             edge_color='k',
             face_color='b',
             edge_width=1.,
             linked=True):
        """Plot a series of data using lines and markers

        Parameters
        ----------
        data : array | two arrays
            Arguments can be passed as ``(Y,)``, ``(X, Y)`` or
            ``np.array((X, Y))``.
        color : instance of Color
            Color of the line.
        symbol : str
            Marker symbol to use.
        line_kind : str
            Kind of line to draw. For now, only solid lines (``'-'``)
            are supported.
        width : float
            Line width.
        marker_size : float
            Marker size. If `size == 0` markers will not be shown.
        edge_color : instance of Color
            Color of the marker edge.
        face_color : instance of Color
            Color of the marker face.
        edge_width : float
            Edge width of the marker.
        title : str | None
            The title string to be displayed above the plot
        xlabel : str | None
            The label to display along the bottom axis
        ylabel : str | None
            The label to display along the left axis.

        Returns
        -------
        line : instance of LinePlot
            The line plot.

        See also
        --------
        marker_types, LinePlot
        """
        self._configure_2d()
        line = scene.LinePlot(data,
                              connect='strip',
                              color=color,
                              symbol=symbol,
                              line_kind=line_kind,
                              width=width,
                              marker_size=marker_size,
                              edge_color=edge_color,
                              face_color=face_color,
                              edge_width=edge_width)
        self.view.add(line)
        self.view.camera.set_range()
        self.visuals.append(line)
        self.linked = linked
        return line