Exemple #1
0
    def __init__(self, session, tool_name, *, title=None):
        ToolInstance.__init__(self, session, tool_name)

        from chimerax.ui import MainToolWindow
        tw = MainToolWindow(self)
        if title is not None:
            tw.title = title
        self.tool_window = tw
        parent = tw.ui_area

        from matplotlib import figure
        self.figure = f = figure.Figure(dpi=100, figsize=(2, 2))

        from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas
        self.canvas = c = Canvas(f)
        parent.setMinimumHeight(
            1
        )  # Matplotlib gives divide by zero error when plot resized to 0 height.
        c.setParent(parent)

        from PyQt5.QtWidgets import QHBoxLayout
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(c)
        parent.setLayout(layout)
        tw.manage(placement="side")

        self.axes = axes = f.gca()

        self._pan = None  # Pan/zoom mouse control
Exemple #2
0
    def initUI(self):
        self.resize(1100, 650)
        self.setWindowTitle("Stok Viewer")
        vbox = QVBoxLayout()
        self.setLayout(vbox)

        dailyBtn = QPushButton("Daily", self)
        weeklyBtn = QPushButton("Weeky", self)
        monthlyBtn = QPushButton("Monthly", self)
        dailyBtn.clicked.connect(lambda: self.plot("day"))
        weeklyBtn.clicked.connect(lambda: self.plot("week"))
        monthlyBtn.clicked.connect(lambda: self.plot("month"))
        timelineBtnBox = QHBoxLayout()
        timelineBtnBox.addStretch(1)
        timelineBtnBox.addWidget(dailyBtn)
        timelineBtnBox.addWidget(weeklyBtn)
        timelineBtnBox.addWidget(monthlyBtn)

        # widgets and layouts for plotting
        self.ybuffer = 5.5  # buffer area for bottom and top(%)
        self.zoomSpeed = 5  # How much area to zoom for one scroll
        self.figure = Figure()
        self.canvas = Canvas(self.figure)
        self.canvas.mpl_connect("button_press_event", self.onPressEvent)
        self.canvas.mpl_connect("button_release_event", self.onReleaseEvent)
        self.canvas.mpl_connect("scroll_event", self.onScrollEvent)
        self.chartBox = QHBoxLayout()
        self.chartBox.addWidget(self.canvas)
        vbox.addLayout(timelineBtnBox)
        vbox.addLayout(self.chartBox)
        self.plot("day")
        self.show()
Exemple #3
0
    def __init__(self,
                 parent_gui,
                 shift_distribution,
                 signal_finished,
                 parent=None):
        """
        Initialize the Viewer. The widget has a fixed size and is rendered as a QFrame.

        :param parent_gui: GUI object by which the viewer is invoked.
        :param parent: Parent object
        :param shift_distribution: 1D Numpy array (int) with counts for each shift size.
        :param signal_finished: Qt signal with signature () telling the workflow thread that the
                                viewer has finished, or None (no signalling).
        """

        QtWidgets.QFrame.__init__(self, parent)
        self.setupUi(self)

        self.setFrameShape(QtWidgets.QFrame.Panel)
        self.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.setObjectName("shift_distribution_viewer")

        self.setFixedSize(900, 600)

        self.parent_gui = parent_gui
        self.shift_distribution = shift_distribution
        self.signal_finished = signal_finished

        self.buttonBox.accepted.connect(self.accept)

        # Create the Matplotlib widget showing the shift statistics.
        self.matplotlib_widget = MatplotlibWidget()
        self.verticalLayout.insertWidget(0, Canvas(self.matplotlib_widget.fig))

        self.matplotlib_widget.draw_distribution(self.shift_distribution)
Exemple #4
0
 def __init__(self, qvlayout):
     self.fig1 = plt.figure(figsize=(1.9, 2.1), dpi=90)
     self.ax = self.fig1.add_subplot()
     self.plot_layout = Canvas(self.fig1)
     qvlayout.addWidget(self.plot_layout)
     self.ax.get_xaxis().set_visible(False)
     self.ax.get_yaxis().set_visible(False)
Exemple #5
0
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        # 오디오스트림을 위한 변수 선언
        self.frames = []
        self.CHUNK = 1024
        self.FORMAT = pyaudio.paInt16
        self.RATE = 44100
        self.CHANNEL = 1
        self.pa = pyaudio.PyAudio()
        self.stream = self.pa.open(
            format=self.FORMAT,
            channels=self.CHANNEL,
            rate=self.RATE,
            input=True,
            input_device_index=2,
            stream_callback=self.callback)  # 1=mic, #2=stereomix, #3=ux1
        # 악보객체를 위한 변수
        self.music_sheet = None
        # 그래프를 그리기 위한 변수 선언
        self.t = np.arange(0, self.CHUNK * 100)
        self.sample = np.zeros([102400])
        self.freq = np.fft.rfftfreq(1024, 1 / self.RATE)
        self.spec = np.zeros([1024], dtype=complex)
        self.fig = plt.figure()
        self.canvas = Canvas(self.fig)
        self.plot = self.fig.add_subplot(111, xlim=(0, 3500), ylim=(0, 800000))
        self.graph, = self.plot.plot([], [])
        self.plot.axes.get_xaxis().set_visible(False)
        self.plot.axes.get_yaxis().set_visible(False)
        self.canvas.draw()
        self.ani = FuncAnimation(self.canvas.figure,
                                 self.graph_update,
                                 frames=50,
                                 interval=20,
                                 repeat=True)
        self.QV_plot.addWidget(self.canvas)

        # 스톱워치관련
        self.timer = qtcore.QTimer()
        self.stopwatch_reset()
        self.timer.timeout.connect(self.stopwatch_run)
        # 시그널 연결
        self.pbtn_start.clicked.connect(self.start_recording)
        self.pbtn_stop.clicked.connect(self.stop_recording)
        self.pbtn_save.clicked.connect(self.show_sheet_musescore)
        self.pbtn_midi.clicked.connect(self.play_sheet_MIDI)
        self.pbtn_play.clicked.connect(self.play_recoded_wav)
        self.pbtn_pause.clicked.connect(self.pause_recorded_wav)
        # ui기본설정
        self.pbtn_play.setEnabled(False)
        self.pbtn_save.setEnabled(False)
        self.pbtn_midi.setEnabled(False)
        self.pbtn_stop.setEnabled(False)
        self.pbtn_pause.setEnabled(False)
        self.pbtn_start.setStyleSheet('QPushButton {color: red;}')
Exemple #6
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)   # Inherit from QWidget
     self.canvas = Canvas(Figure())                  # Create canvas object
     self.canvas.axes = self.canvas.figure.gca(projection='3d')
     #self.canvas.axes.contour3D(X, Y, Z, 50, cmap='binary')
     
     
     self.vbl = QVBoxLayout()         # Set box for plotting
     self.vbl.addWidget(self.canvas)
     self.setLayout(self.vbl)
    def __init__(self, parent=None):
        list_port = ['/processing/xsens/JointAngles:o', '/AE/reconstruct:o']

        self.input_port = []
        self.port = []

        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111, projection='3d')

        data = np.zeros((1, 66))

        color = ['b', 'r']
        self.lines = []
        self.skeleton = []

        self.skeleton = Skeleton('dhm66_ISB_Xsens.urdf')

        for i, name_port in enumerate(list_port):
            self.input_port.append(name_port)
            self.port.append(yarp.BufferedPortBottle())
            self.port[i].open('/plot_skeleton' + name_port)

            yarp.Network.connect(name_port, self.port[i].getName())

        QtWidgets.QWidget.__init__(self, parent)  # Inherit from QWidget

        self.fig = Figure()

        self.pltCanv = Canvas(self.fig)
        self.pltCanv.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        self.pltCanv.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.pltCanv.setFocus()
        self.pltCanv.updateGeometry()
        self.ax = self.fig.add_subplot(111, projection='3d')

        self.ax.mouse_init()

        #=============================================
        # Main plot widget layout
        #=============================================
        self.layVMainMpl = QVBoxLayout()
        self.layVMainMpl.addWidget(self.pltCanv)
        self.setLayout(self.layVMainMpl)

        self.lines = []
        self.skeleton = []

        self.skeleton = Skeleton('dhm66_ISB_Xsens.urdf')

        self.timer = self.pltCanv.new_timer(100,
                                            [(self.update_canvas, (), {})])
        self.timer.start()
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        # audio process module call
        self.audio = ap.AudioProcessing()
        devicelst = []
        self.devicelst = []
        for idx in range(self.audio.pa.get_device_count()):
            devicelst.append(self.audio.pa.get_device_info_by_index(idx))
        for info in devicelst:
            if info['maxInputChannels'] != 0 and info['hostApi'] == 0:
                self.devicelst.append(info)
        del devicelst
        self.cb_initialize()

        # draw wave
        self.fig = plt.figure()
        self.canvas = Canvas(self.fig)
        self.plot = self.fig.add_subplot(111, xlim=(0, 3500), ylim=(0, 800000))
        self.graph, = self.plot.plot([], [])
        self.plot.axes.get_xaxis().set_visible(False)
        self.plot.axes.get_yaxis().set_visible(False)
        self.canvas.draw()
        self.ani = FuncAnimation(self.canvas.figure,
                                 self.graph_update,
                                 frames=50,
                                 interval=20,
                                 repeat=True)
        self.QV_plot.addWidget(self.canvas)

        # 스톱워치관련
        self.timer = qtcore.QTimer()
        self.stopwatch_reset()
        self.timer.timeout.connect(self.stopwatch_run)
        # 시그널 연결
        self.pbtn_start.clicked.connect(self.start_recording)
        self.pbtn_stop.clicked.connect(self.stop_recording)
        self.pbtn_save.clicked.connect(self.saveMusicSheet)
        self.pbtn_midi.clicked.connect(self.playMusicSheet)
        self.pbtn_play.clicked.connect(self.play_recoded_wav)
        self.pbtn_pause.clicked.connect(self.pause_recorded_wav)
        self.pbtn_genMusic.clicked.connect(self.generateMusic)
        self.cb_devices.currentIndexChanged.connect(self.cb_changed)
        # ui기본설정
        self.pbtn_play.setEnabled(False)
        self.pbtn_save.setEnabled(False)
        self.pbtn_midi.setEnabled(False)
        self.pbtn_stop.setEnabled(False)
        self.pbtn_pause.setEnabled(False)
        self.pbtn_genMusic.setEnabled(False)
        self.pbtn_start.setStyleSheet('QPushButton {color: red;}')
Exemple #9
0
 def __init__(self, parent=None):
     figure = Figure(figsize=(4, 3))
     self.ax = figure.add_subplot(111)
     Canvas.__init__(self, figure)
     c = Canvas(Figure())
     self.setParent(parent)
     Canvas.setSizePolicy(self, QSizePolicy.Expanding,
                          QSizePolicy.Expanding)
     Canvas.updateGeometry(self)
     self.figure = figure
     self.ax.grid()
     self.tb = NavTB(self.figure.canvas, parent)
     self.tb.hide()
     self.marker = itertools.cycle(('s', 'v', 'd', 'o', '*', '^', '8'))
    def __init__(self,
                 parent=None,
                 title="Title",
                 width=5,
                 height=5,
                 dpi=100,
                 hold=True):
        super(MatplotlibWidget, self).__init__(Figure())

        self.setParent(parent)
        self.figure = Figure(figsize=(width, height), dpi=dpi)
        self.figure.patch.set_facecolor("xkcd:black")

        self.canvas = Canvas(self.figure)
Exemple #11
0
    def __init__(self,
                 parent_gui,
                 shift_distribution,
                 shift_failure_percent,
                 signal_finished,
                 parent=None):
        """
        Initialize the Viewer. The widget has a fixed size and is rendered as a QFrame.

        :param parent_gui: GUI object by which the viewer is invoked.
        :param parent: Parent object
        :param shift_distribution: 1D Numpy array (int) with counts for each shift size.
        :param shift_failure_percent: Percent of failed warp shift measurements.
        :param signal_finished: Qt signal with signature () telling the workflow thread that the
                                viewer has finished, or None (no signalling).
        """

        QtWidgets.QFrame.__init__(self, parent)
        self.setupUi(self)

        self.setFrameShape(QtWidgets.QFrame.Panel)
        self.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.setObjectName("shift_distribution_viewer")

        self.setFixedSize(900, 600)

        self.parent_gui = parent_gui
        self.shift_distribution = shift_distribution
        self.signal_finished = signal_finished

        self.buttonBox.accepted.connect(self.accept)

        # Create the Matplotlib widget showing the shift statistics.
        self.matplotlib_widget = MatplotlibWidget()
        self.verticalLayout.insertWidget(0, Canvas(self.matplotlib_widget.fig))

        self.matplotlib_widget.draw_distribution(self.shift_distribution)

        # Display the fraction of failed shift measurements. Use red ink if the value exceeds 5%.
        if shift_failure_percent >= 0.:
            self.failedShiftsLabel.setText("Failed shift measurements: " +
                                           str(shift_failure_percent) + "%")
            if shift_failure_percent > 5.:
                self.failedShiftsLabel.setStyleSheet('color: red')
            else:
                self.failedShiftsLabel.setStyleSheet('color: black')
        else:
            self.failedShiftsLabel.setText("")
Exemple #12
0
    def set_data(self, x, y, z, min_alt, max_alt, vbur, radius, include_vbur):
        fig, ax = plt.subplots()
        steric_map = ax.contourf(x,
                                 y,
                                 z,
                                 extend="min",
                                 cmap=copy.copy(plt.cm.get_cmap("jet")),
                                 levels=np.linspace(min_alt, max_alt, num=21))
        steric_map.cmap.set_under('w')
        ax.contour(x,
                   y,
                   z,
                   extend="min",
                   colors='k',
                   levels=np.linspace(min_alt, max_alt, num=21))
        bar = fig.colorbar(steric_map, format="%.1f")
        bar.set_label("altitude (Å)")
        ax.set_aspect("equal")

        if include_vbur:
            ax.hlines(0, -radius, radius, color='k')
            ax.vlines(0, -radius, radius, color='k')

            vbur_1 = vbur[0] + vbur[7]
            vbur_2 = vbur[1] + vbur[6]
            vbur_3 = vbur[2] + vbur[5]
            vbur_4 = vbur[3] + vbur[4]
            ax.text(+0.7 * radius, +0.9 * radius, "%.1f%%" % vbur_1)
            ax.text(-0.9 * radius, +0.9 * radius, "%.1f%%" % vbur_2)
            ax.text(-0.9 * radius, -0.9 * radius, "%.1f%%" % vbur_3)
            ax.text(+0.7 * radius, -0.9 * radius, "%.1f%%" % vbur_4)

        if include_vbur:
            circle = plt.Circle((0, 0),
                                radius,
                                color="k",
                                fill=False,
                                linewidth=4)
            ax.add_artist(circle)

        canvas = Canvas(fig)

        self.layout.addWidget(canvas)

        toolbar_widget = QWidget()
        toolbar = NavigationToolbar(canvas, toolbar_widget)
        toolbar.setMaximumHeight(32)
        self.layout.addWidget(toolbar)
Exemple #13
0
    def __init__(self,
                 parent=None,
                 title='Title',
                 xlabel='x label',
                 ylabel='y label',
                 dpi=70,
                 hold=False):
        super(MatplotlibWidget, self).init__(Figure())

        self.setParent(parent)
        self.figure = Figure(figsize=(2, 1), dpi=dpi)
        self.canvas = Canvas(self.figure)
        self.theplot = self.figure.add_subplot(111)

        self.theplot.set_title(title)
        self.theplot.set_xlabel(xlabel)
        self.theplot.set_ylabel(ylabel)
Exemple #14
0
    def __init__(self,
                 parent=None,
                 title='Title',
                 xlabel='x label',
                 ylabel='y label',
                 dpi=100):
        super(MatplotlibWidget, self).__init__(Figure())

        self.setParent(parent)
        self.figure = Figure(dpi=dpi)
        self.canvas = Canvas(self.figure)
        self.ax = self.figure.add_subplot(111)
        #         self.ax.hold(False)
        self.ax.clear()

        self.ax.set_title(title)
        self.ax.set_xlabel(xlabel)
        self.ax.set_ylabel(ylabel)
    def __init__(self, parent=None):
        super(MplGraphQt5Widget, self).__init__(parent)

        self.width = 3
        self.height = 3
        self.dpi = 100

        self._dataY = np.array([])
        self._dataX = np.array([])

        self._spCols = 1
        self._spRows = 1
        self.all_sp_axes = []
        self.fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
        self.all_sp_axes.append(
            self.fig.add_subplot(self._spCols, self._spRows, 1))
        self.fig.set_frameon(False)
        self.fig.set_tight_layout(True)

        self.canvas = Canvas(self.fig)

        self._navBarOn = False
        self.mpl_toolbar = NavigationToolbar(self.canvas, parent)
        self.mpl_toolbar.dynamic_update()

        self.canvas.mpl_connect('key_press_event', self.on_key_press)
        self.canvas.mpl_connect('button_press_event', self.on_button_press)
        self.canvas.mpl_connect('motion_notify_event', self.on_mouse_move)
        self.canvas.setFocusPolicy(Qt.ClickFocus)
        self.canvas.setFocus()

        self.canvas.setParent(parent)
        self.canvas.clearMask()
        self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.canvas.updateGeometry()

        vbox = QVBoxLayout()
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.mpl_toolbar)
        if not self._navBarOn:
            self.mpl_toolbar.hide()
        self.setLayout(vbox)
Exemple #16
0
    def __init__(self, parent=None, width=12, height=9):
        QWidget.__init__(self, parent)
        super(MatplotlibWidget, self).__init__()

        #self.figure, self.axs = plt.subplots(figsize=(width, height))
        self.gs = GridSpec(1, 1)
        # self.figure = plt.figure(0, facecolor="#949699", edgecolor="#949699")
        self.figure = plt.figure()
        self.axs = self.figure.add_subplot(self.gs[0, 0])
        # self.axs.patch.set_facecolor("#949699")
        self.canvas = Canvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
        self.setLayout(self.layout)
        self.setParent(parent)
        super(MatplotlibWidget, self).setSizePolicy(QSizePolicy.Expanding,
                                                    QSizePolicy.Expanding)
        super(MatplotlibWidget, self).updateGeometry()
Exemple #17
0
    def __init__(self, parent_gui, configuration, frames, rank_frames,
                 align_frames, stacked_image_log_file, signal_finished,
                 signal_payload):
        """
        Initialization of the widget.

        :param parent_gui: Parent GUI object
        :param configuration: Configuration object with parameters
        :param frames: Frames object with all video frames
        :param rank_frames: RankFrames object with global quality ranks (between 0. and 1.,
                            1. being optimal) for all frames
        :param align_frames: AlignFrames object with global shift information for all frames
        :param stacked_image_log_file: Log file to be stored with results, or None.
        :param signal_finished: Qt signal with signature (str) to trigger the next activity when
                                the viewer exits.
        :param signal_payload: Payload of "signal_finished" (str).
        """

        super(FrameViewerWidget, self).__init__(parent_gui)
        self.setupUi(self)

        # Keep references to upper level objects.
        self.parent_gui = parent_gui
        self.configuration = configuration
        self.stacked_image_log_file = stacked_image_log_file
        self.signal_finished = signal_finished
        self.signal_payload = signal_payload
        self.frames = frames
        self.rank_frames = rank_frames
        self.align_frames = align_frames

        # Be careful: Indices are counted from 0, while widget contents are counted from 1 (to make
        # it easier for the user.
        self.quality_index = 0
        self.frame_index = self.rank_frames.quality_sorted_indices[
            self.quality_index]

        # Set up the frame viewer and put it in the upper left corner.
        self.frame_viewer = VideoFrameViewer(self.frames, self.align_frames,
                                             self.frame_index)
        self.frame_viewer.setObjectName("framewiever")
        self.grid_layout.addWidget(self.frame_viewer, 0, 0, 4, 3)

        self.widget_elements = [
            self.spinBox_chronological, self.spinBox_quality,
            self.slider_frames, self.pushButton_play
        ]

        # Initialize variables. The values for "alignment_point_frame_number" and
        # "alignment_points_frame_percent" are held as copies in this object. Only if the user
        # presses "OK" at the end, the values are copied back into the configuration object.
        self.alignment_points_frame_number = self.configuration.alignment_points_frame_number
        self.alignment_points_frame_percent = self.configuration.alignment_points_frame_percent
        if self.alignment_points_frame_number is None or 0 < self.alignment_points_frame_number \
                <= self.frames.number:
            self.alignment_points_frame_number = max(
                1,
                int(
                    round(self.frames.number *
                          self.alignment_points_frame_percent / 100.)))
        self.frame_ranks = rank_frames.frame_ranks
        self.quality_sorted_indices = rank_frames.quality_sorted_indices

        # Start with ordering frames by quality. This can be changed by the user using a radio
        # button.
        self.frame_ordering = "quality"

        # Initialize a variable for communication with the frame_player object later.
        self.run_player = False

        # Create the frame player thread and start it. The player displays frames in succession.
        # It is pushed on a different thread because otherwise the user could not stop it before it
        # finishes.
        self.player_thread = QtCore.QThread()
        self.frame_player = FramePlayer(self)
        self.frame_player.moveToThread(self.player_thread)
        self.frame_player.block_widgets_signal.connect(self.block_widgets)
        self.frame_player.unblock_widgets_signal.connect(self.unblock_widgets)
        self.frame_player.set_photo_signal.connect(self.frame_viewer.setPhoto)
        self.frame_player.set_slider_value.connect(self.slider_frames.setValue)
        self.frame_player_start_signal.connect(self.frame_player.play)
        self.player_thread.start()

        # Initialization of GUI elements
        self.slider_frames.setMinimum(1)
        self.slider_frames.setMaximum(self.frames.number)
        self.slider_frames.setValue(self.quality_index + 1)
        self.spinBox_chronological.setMinimum(1)
        self.spinBox_chronological.setMaximum(self.frames.number)
        self.spinBox_chronological.setValue(self.frame_index + 1)
        self.spinBox_quality.setMinimum(1)
        self.spinBox_quality.setMaximum(self.frames.number)
        self.spinBox_quality.setValue(self.quality_index + 1)
        self.radioButton_quality.setChecked(True)

        self.spinBox_number_frames.setMaximum(self.frames.number)
        self.spinBox_percentage_frames.setValue(
            self.alignment_points_frame_percent)

        self.spinBox_number_frames.setValue(self.alignment_points_frame_number)

        # Create the Matplotlib widget showing the quality lines.
        self.matplotlib_widget = MatplotlibWidget(self.configuration,
                                                  self.rank_frames)

        self.grid_layout.addWidget(Canvas(self.matplotlib_widget.fig), 0, 3, 2,
                                   1)

        self.grid_layout.setColumnStretch(0, 5)
        self.grid_layout.setColumnStretch(1, 0)
        self.grid_layout.setColumnStretch(2, 0)
        self.grid_layout.setColumnStretch(3, 1)
        self.grid_layout.setRowStretch(0, 1)
        self.grid_layout.setRowStretch(1, 0)
        self.grid_layout.setRowStretch(2, 0)
        self.grid_layout.setRowStretch(3, 0)

        # Connect signals with slots.
        self.buttonBox.accepted.connect(self.done)
        self.buttonBox.rejected.connect(self.reject)
        self.slider_frames.valueChanged.connect(self.slider_frames_changed)
        self.spinBox_number_frames.valueChanged.connect(
            self.spinbox_number_frames_changed)
        self.spinBox_percentage_frames.valueChanged.connect(
            self.spinbox_percentage_frames_changed)
        self.radioButton_quality.toggled.connect(
            self.radiobutton_quality_changed)
        self.spinBox_chronological.valueChanged.connect(
            self.spinbox_chronological_changed)
        self.spinBox_quality.valueChanged.connect(self.spinbox_quality_changed)
        self.pushButton_set_stacking_limit.clicked.connect(
            self.pushbutton_set_stacking_limit_clicked)
        self.pushButton_play.clicked.connect(self.pushbutton_play_clicked)
        self.pushButton_stop.clicked.connect(self.pushbutton_stop_clicked)

        # Initialize the Matplotlib widget contents.
        self.matplotlib_widget.renew_plot(self.quality_index,
                                          self.frame_ordering,
                                          self.alignment_points_frame_number)
Exemple #18
0
    def _build_ui(self):
        layout = QGridLayout()

        self.figure = Figure(figsize=(2, 2))
        self.canvas = Canvas(self.figure)

        ax = self.figure.add_axes((0.15, 0.20, 0.80, 0.70))

        fr = self.filereader
        if fr.all_geom is None:
            self.opened = False
            return

        data = []
        for step in fr.all_geom:
            info = [
                item for item in step
                if isinstance(item, dict) and "energy" in item
            ]
            if len(info) < 1:
                #we will be unable to load an enegy plot because some structure does not have an associated energy
                self.opened = False
                self.session.logger.error(
                    "not enough iterations to plot - %i found" % len(info))
                return
            else:
                info = info[0]
            data.append(info["energy"])

        self.ys = data

        se = np.ptp(data)

        self.nrg_plot = ax.plot(self.structure.coordset_ids,
                                data,
                                marker='o',
                                c='gray',
                                markersize=3)
        self.nrg_plot = self.nrg_plot[0]
        ax.set_xlabel('iteration')
        ax.set_ylabel(r'energy ($E_h$)')
        ax.set_ylim(bottom=(min(data) - se / 10), top=(max(data) + se / 10))

        minlocs = [
            self.structure.coordset_ids[i]
            for i in range(0, self.structure.num_coordsets)
            if data[i] == min(data)
        ]
        mins = [min(data) for m in minlocs]

        maxlocs = [
            self.structure.coordset_ids[i]
            for i in range(0, self.structure.num_coordsets)
            if data[i] == max(data)
        ]
        maxs = [max(data) for m in minlocs]

        ax.plot(minlocs, mins, marker='*', c='blue', markersize=5)
        ax.plot(maxlocs, maxs, marker='*', c='red', markersize=5)

        ax.ticklabel_format(axis='y',
                            style='sci',
                            scilimits=(0, 0),
                            useOffset=True)
        ax.ticklabel_format(axis='x', style='plain', useOffset=False)

        self.canvas.mpl_connect('button_release_event', self.unclick)
        self.canvas.mpl_connect('button_press_event', self.onclick)
        self.canvas.mpl_connect('motion_notify_event', self.drag)
        self.canvas.mpl_connect('scroll_event', self.zoom)

        self.annotation = ax.annotate("",
                                      xy=(0, 0),
                                      xytext=(0, 10),
                                      textcoords="offset points",
                                      fontfamily='Arial')
        self.annotation.set_visible(False)

        ax.autoscale()
        self.canvas.draw()
        self.canvas.setMinimumWidth(400)
        self.canvas.setMinimumHeight(200)
        layout.addWidget(self.canvas)

        toolbar_widget = QWidget()
        toolbar = NavigationToolbar(self.canvas, toolbar_widget)

        toolbar.setMaximumHeight(32)
        self.toolbar = toolbar
        layout.addWidget(toolbar)

        #menu bar for saving stuff
        menu = QMenuBar()
        file = menu.addMenu("&Export")
        file.addAction("&Save CSV...")

        file.triggered.connect(self.save)

        menu.setNativeMenuBar(False)
        self._menu = menu
        layout.setMenuBar(menu)

        self.tool_window.ui_area.setLayout(layout)

        self.tool_window.manage(None)

        self.opened = True
Exemple #19
0
 def __init__(self, parent):
     self.figure = plt.figure(facecolor='white')
     self.canvas = Canvas(self.figure)
     self.toolbar = NavBar(self.canvas, parent)
    def setupUi(self, graphWindow):
        graphWindow.setObjectName("graphWindow")
        graphWindow.resize(800, 600)

        self.centralwidget = QtWidgets.QWidget(graphWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout_4 = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.gridLayout_3 = QtWidgets.QGridLayout()
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.gridLayout = QtWidgets.QGridLayout(self.frame)
        self.gridLayout.setObjectName("gridLayout")
        self.backButton = QtWidgets.QPushButton(self.frame)
        self.backButton.setObjectName("backButton")
        self.gridLayout.addWidget(self.backButton, 0, 0, 1, 1)
        self.gridLayout_3.addWidget(self.frame, 0, 0, 1, 1)
        self.frame_2 = QtWidgets.QFrame(self.centralwidget)
        self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_2.setObjectName("frame_2")

        #pitch = pitch = [0.79, 0.5, 0.33, 0.28, 0.35]

        self.gridLayout_2 = QtWidgets.QGridLayout(self.frame_2)
        self.gridLayout_2.setObjectName("gridLayout_2")
        #self.graphArea = PlotWidget(self.frame_2)
        #self.graphArea.setObjectName("graphArea")
        self.graphArea = plt.figure()
        self.canvas = Canvas(self.graphArea)


        #plt.show()
        #self.canvas.draw()


        #pw = pg.Plot
        #self.graphArea.plot(pitch)
        #self.graphArea


        self.gridLayout_2.addWidget(self.canvas, 0, 0, 1, 1)

        #self.graphArea.plot(pitch)

        self.gridLayout_3.addWidget(self.frame_2, 1, 0, 1, 1)
        self.gridLayout_4.addLayout(self.gridLayout_3, 0, 0, 1, 1)
        graphWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(graphWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
        self.menubar.setObjectName("menubar")
        graphWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(graphWindow)
        self.statusbar.setObjectName("statusbar")
        graphWindow.setStatusBar(self.statusbar)

        self.retranslateUi(graphWindow)
        QtCore.QMetaObject.connectSlotsByName(graphWindow)