Example #1
0
 def changeTimes(self, new_starttime, new_endtime):
     self.env.st.showMessage('Changing Times...')
     ns = new_starttime
     ne = new_endtime
     new_range = ne - ns
     # Do nothing if the times are the same.
     if self.env.starttime == new_starttime and \
        self.env.endtime == new_endtime:
         return
     # Do not zoom in more than possible to avoid resampling errors.
     if new_range < self.env.maximum_zoom_level:
         half = self.env.maximum_zoom_level / 2.0
         middle = ns + new_range / 2.0
         ns = middle - half
         ne = ns + self.env.maximum_zoom_level
     self.env.starttime = UTCDateTime(ns.year, ns.month, ns.day, ns.hour,
                                      ns.minute)
     self.env.endtime = UTCDateTime(ne.year, ne.month, ne.day, ne.hour,
                                      ne.minute)
     self.env.time_range = self.env.endtime - self.env.starttime
     self.waveforms.redraw()
     self.start_date.setDateTime(utils.toQDateTime(self.env.starttime))
     self.end_date.setDateTime(utils.toQDateTime(self.env.endtime))
     # Set the labels to the new values.
     self.env.st.showMessage('')
Example #2
0
    def __init__(self, env, parent=None):
        """
        Build the main window.
        """
        QtGui.QWidget.__init__(self, parent)
        self.env = env
        self.env.main_window = self
        # Set title and layout for the main_window.
        self.setWindowTitle('Database Viewer')
        grid = QtGui.QGridLayout()

        # Add a frame to group all plot related gui elements.
        self.plotFrame = QtGui.QGroupBox()
        # XXX: This style sheet results in very flickery graphics...i have no
        # idea why that would happen.
        #self.plotFrame.setStyleSheet('border:1px solid #AAAAAA;')
        self.plotFrameLayout = QtGui.QVBoxLayout()
        self.plotFrameLayout.setMargin(1)
        self.plotFrame.setLayout(self.plotFrameLayout)
        grid.addWidget(self.plotFrame, 0, 0, 12, 8)

        # Add plot status bar. Needs to be done before initializing the
        # Waveform class.
        self.plotStatus = QtGui.QLabel(' ')
        self.plotStatus.setStyleSheet('border:0px;')
        font = QtGui.QFont()
        font.setPointSize(9)

        # Add the waveform viewer.
        self.waveforms = Waveforms(env=self.env)
        self.plotFrameLayout.addWidget(self.waveforms)

        # Add navigation widget.
        self.navigation = NavigationBar(env=self.env)
        #self.plotControlLayout.addWidget(self.navigation)
        self.plotFrameLayout.addWidget(self.navigation)
        self.plotStatus.setFont(font)
        self.plotFrameLayout.addWidget(self.plotStatus)

        # Add the menu for the time_selection.
        times = QtGui.QGroupBox('Timeframe')
        grid.addWidget(times, 0, 8, 1, 2)
        # Time frame layout.
        time_layout = QtGui.QGridLayout()
        # Labels.
        start_label = QtGui.QLabel('Starttime:')
        time_layout.addWidget(start_label, 0, 0)
        end_label = QtGui.QLabel('Endtime:')
        time_layout.addWidget(end_label, 1, 0)
        # Init date selector.
        self.start_date = QtGui.QDateTimeEdit(utils.toQDateTime(self.env.starttime))
        self.start_date.setCalendarPopup(True)
        time_layout.addWidget(self.start_date, 0, 1)
        self.end_date = QtGui.QDateTimeEdit(utils.toQDateTime(self.env.endtime))
        self.end_date.setCalendarPopup(True)
        time_layout.addWidget(self.end_date, 1, 1)
        self.time_button = QtGui.QPushButton('Apply')
        time_layout.addWidget(self.time_button, 2, 1)
        times.setLayout(time_layout)

        QtCore.QObject.connect(self.time_button, QtCore.SIGNAL("clicked()"),
                               self.applyTimes)

        # Add the pick group box.
        self.picks = Picks(env=self.env)
        grid.addWidget(self.picks, 1, 8, 1, 2)
        # Add the network tree.

        self.nw_tree = NetworkTree(self.waveforms, env=self.env)
        grid.addWidget(self.nw_tree, 2, 8, 9, 2)

        # Add the edit lists button.
        self.channelListFrame = QtGui.QFrame()
        self.horizontalChannelListLayout = QtGui.QHBoxLayout()
        self.horizontalChannelListLayout.setMargin(0)
        self.channelListFrame.setLayout(self.horizontalChannelListLayout)
        self.editChannelListsButton = QtGui.QPushButton('Edit Groups')
        self.loadEventsButton = QtGui.QPushButton('Load events')
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalChannelListLayout.addWidget(self.loadEventsButton)
        self.horizontalChannelListLayout.addItem(spacerItem)
        self.horizontalChannelListLayout.addWidget(self.editChannelListsButton)
        grid.addWidget(self.channelListFrame, 11, 8, 1, 2)
        QtCore.QObject.connect(self.editChannelListsButton, QtCore.SIGNAL("clicked()"),
                               self.callEditChannelListDialog)
        QtCore.QObject.connect(self.loadEventsButton, QtCore.SIGNAL("clicked()"),
                               self.loadEvents)

        # Set the layout and therefore display everything.
        self.setLayout(grid)