def initDialog(self): print("init stat viewer") plt.figure(num=1) canvas = FigureCanvas(plt.figure(1)) NavToolbar(canvas=canvas, parent=None) self.ui.vlPlot.addWidget(canvas) self.ui.vlPlot.addWidget(canvas.toolbar) sizes, labels = self._domainModel.getBillStats() total = sum(sizes) new_sizes = list() new_labels = list() for s, l in zip(sizes, labels): if s / total > 0.05: new_sizes.append(s) new_labels.append(l) _, _, _ = plt.pie(x=new_sizes, labels=new_labels, shadow=True, autopct='%1.1f%%', pctdistance=1.1, labeldistance=1.2) # plt.legend(patches, new_labels, loc='best') plt.axis('equal') plt.tight_layout()
def __init__(self, parent): self.current_units = [] super(PsthViewWidget, self).__init__(parent) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) layout = QHBoxLayout(self) plt_layout = QVBoxLayout() self.plot = _PlotCanvas(self) self.toolbar = NavToolbar(self.plot, self) plt_layout.addWidget(self.toolbar) plt_layout.addWidget(self.plot) layout.addLayout(plt_layout) controls_layout = QVBoxLayout() pre_pad_label = QLabel('Pre plot (ms)') pre_pad_box = QSpinBox(self) pre_pad_box.setSingleStep(20) pre_pad_box.setRange(0, 5000) pre_pad_box.setValue(100) pre_pad_box.valueChanged.connect(self.plot_param_changed) self.pre_pad_box = pre_pad_box post_pad_label = QLabel('Post plot (ms)') post_pad_box = QSpinBox(self) post_pad_box.setSingleStep(20) post_pad_box.setRange(0, 5000) post_pad_box.setValue(200) post_pad_box.valueChanged.connect(self.plot_param_changed) self.post_pad_box = post_pad_box binsize_label = QLabel('Binsize (ms)') binsize_box = QSpinBox(self) binsize_box.setSingleStep(5) binsize_box.setRange(1, 200) binsize_box.setValue(20) binsize_box.valueChanged.connect(self.plot_param_changed) self.binsize_box = binsize_box method_label = QLabel('Binning method') method_box = QComboBox(self) method_box.addItems(('gaussian', 'boxcar', 'histogram')) method_box.setInsertPolicy(QComboBox.NoInsert) method_box.activated.connect(self.plot_param_changed) self.method_box = method_box # todo: make controls hideable. controls_layout.addWidget(pre_pad_label) controls_layout.addWidget(pre_pad_box) controls_layout.addWidget(post_pad_label) controls_layout.addWidget(post_pad_box) controls_layout.addWidget(binsize_label) controls_layout.addWidget(binsize_box) controls_layout.addWidget(method_label) controls_layout.addWidget(method_box) controls_layout.addStretch() self.controls_layout = controls_layout layout.addLayout(controls_layout)
def __init__(self, dialog): super(MyProgram, self).__init__() self.setupUi(dialog) self.m = MyMplCanvas(self.dockWidgetContents) self.mpl_toolbar = NavToolbar(self.m, self.dockWidgetContents) self.dataConverted = [] self.intervals2plot_eval = set() self.intervals2plot_train = set() # ============================================================================== # Connect signals # ============================================================================== self.openButn.clicked.connect(lambda: self.openFile(dialog)) self.drawButn.clicked.connect(lambda: self.drawPlotTop( dialog, np.arange(0, (self.rawRangeSld.value()) * 5, 5), self. dataConverted[self.rawStartSld.value() - 1:self.rawStartSld.value( ) + self.rawRangeSld.value() - 1])) self.rawStartSld.valueChanged.connect(lambda: self.updateSpinBox( self.startInp, self.rawStartSld.value())) self.rawRangeSld.valueChanged.connect(lambda: self.updateSpinBox( self.rangeInp, self.rawRangeSld.value())) self.integrateButn.clicked.connect( lambda: self.integrateData(self.dataConverted)) self.integrateButn_2.clicked.connect( lambda: self.integrateDataCustomIntervals(self.dataConverted)) self.startInp.valueChanged.connect( lambda: self.rawStartSld.setValue(self.startInp.value())) self.rangeInp.valueChanged.connect( lambda: self.rawRangeSld.setValue(self.rangeInp.value())) self.rangeInp.valueChanged.connect( lambda: self.changeRangeAdjustStart()) self.recalButn.clicked.connect(self.convertData) self.addIntervalButton.clicked.connect(self.addInterval) self.addIntervalButton_2.clicked.connect(self.addInterval_2) self.removeIntervalButton.clicked.connect(self.removeInterval) self.removeIntervalButton_2.clicked.connect(self.removeInterval_2) self.intervalTable.itemClicked.connect(self.handleIntervalTable1Click) self.intervalTable_2.itemClicked.connect( self.handleIntervalTable2Click) self.reopenButn.clicked.connect(self.reopenFile)
def __init__(self, plotFrame): self.plotFrame = plotFrame self.figure = Figure() self.canvas = FigureCanvas(self.figure) self.toolbar = NavToolbar(self.canvas, self.plotFrame) self.toolbar.setVisible(False) layout = QtWidgets.QVBoxLayout() layout.addWidget(self.toolbar) layout.addWidget(self.canvas) plotFrame.setLayout(layout) self.axes = [] self.plot_map = {} self.data_map = {} self.setup_all()
def __init__(self, parent=None): print('GRAPH WIDGET INIT') super().__init__(parent) self._figure = plt.Figure() # Widget self._canvas = FigureCanvas(self._figure) # Widget toolbar = NavToolbar(self._canvas, self) # Widget plot_button = QtWidgets.QPushButton('Plot!') plot_button.clicked.connect(self.plot) layout = QtWidgets.QVBoxLayout() layout.addWidget(toolbar) layout.addWidget(self._canvas) layout.addWidget(plot_button) self.setLayout(layout) self.plot()
def __init__(self, parent=None): super().__init__(parent) self._figure = plt.Figure() # Widget! self._canvas = FigureCanvas(self._figure) # widget! toolbar = NavToolbar(self._canvas, self) # Widget! plot_button = QtWidgets.QPushButton('Plot!') plot_button.clicked.connect(self.plot) layout = QtWidgets.QVBoxLayout() layout.addWidget(toolbar) layout.addWidget(self._canvas) layout.addWidget(plot_button) self.setLayout(layout) self.plot self.random_signal.connect(self.random_slot) self.random_signal.emit('hello', 5, False)
def __init__(self, parent=None): super(Window, self).__init__(parent) # """ Acquisition and Plot Variables """ self.is_space = True # Switch for X axis type selection: True [m], False array index [i]index self.sample_shown = 0 # Samples shown self.X_View_Percent = 0 # Fraction of X-axis shown, selected by self.X_View_Percent_SpBox self.t = None # X axis: Time self.x = None # X axis: space [m] self.indx = None # X axis: index of array self.x_scale = None # X axis: actual selected scale self.dt = None # Time resolution self.y1 = None # Force signal (ch1) self.y2 = None # Accel. signal (ch2) self.y1_full = None # Force signal (ch2) full length vector self.y2_full = None # Accel. signal (ch2) full length vector # self.fileIndex = 1 # Actual number of used file self.path = "" # Actual full path of Pile self.outGain = t.PI_OUT_GAIN # Scaling factor of data to put to Output # self.actual_path = "" # Path of selected Work and Pile # self.shortSpace = 15 # Widget base fixed space self.longSpace = 40 # Widget longer fixed space """ Temporary values overvritten when loading acquired data. """ self.Length = c.LengthBase # Pile length self.Speed = c.SpeedBase # P wave speed in concrete self.SamplingFreq = c.SAMPRATE # Sampling frequency self.T_echo_0 = 2 * self.Length / self.Speed # Return time of echo_0 self.indx_echo_0 = round( self.T_echo_0 * self.SamplingFreq) # Index of the 1.st echo_0 sample # # ======================================================== # SET THE LAYOUT # ======================================================== layout_V_1 = QVBoxLayout() # Most external Vertical layout_H_1 = QHBoxLayout() # 1.st Horizontal inside layout_V_1 layout_H_2 = QHBoxLayout() # 2.nd Horizontal inside layout_V_1 self.setLayout(layout_V_1) # Put layout_V_1 inside the MinWindow spacerItem = QtWidgets.QSpacerItem(1, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Maximum) # # ======================================================== # FIGURE instance to plotData on # ======================================================== self.figure = plt.figure() self.figure.subplots_adjust(top=0.92, bottom=0.09, left=0.06, right=0.99, hspace=0.14) self.ax1 = self.figure.add_subplot( 211, facecolor=v.face_color_Time) # Subplot upper: ch1, Force self.ax2 = self.figure.add_subplot( 212, facecolor=v.face_color_Time) # Subplot lower: ch2, Accel self.ax1.grid(True) self.ax2.grid(True) # # ======================================================== # FIGURE CANVAS widget that displays the `figure` # it takes the `figure` instance as a parameter to __init__ # ======================================================== self.canvas = FigureCanvas(self.figure) layout_V_1.addWidget(self.canvas) # # ======================================================== # NAVIGATION TOOLBAR # it takes the Canvas widget and the Window as parent # ======================================================== self.NavToolBar = NavToolbar(self.canvas, parent=self) self.NavToolBar.setFixedWidth(int(c.nav_toolbar_width * 1.6)) layout_V_1.addWidget(self.NavToolBar) # layout_V_1.addLayout(layout_H_1) # Put layout_H_1 under the NavToolbar layout_V_1.addLayout(layout_H_2) # Put layout_H_2 under layout_H_1 # # ======================================================== # LOAD MEASURE Button to load a Measure file # ======================================================== self.loadMeasureButton = QPushButton("&Load") self.loadMeasureButton.setToolTip("Load a Measure.") self.loadMeasureButton.clicked.connect(self.loadMeasure) # layout_H_1.addWidget(self.loadMeasureButton) layout_H_1.addSpacing(self.shortSpace) # # ======================================================== # FILE NAME QLineEdit # ======================================================== # self.WorkPile_Edit = QtWidgets.QLineEdit() self.WorkPile_Edit.setAlignment(QtCore.Qt.AlignCenter) self.WorkPile_Edit.setToolTip( "Actual Pile path showing Work and Pile Numbers.") self.WorkPile_Edit.setMinimumWidth(330) self.WorkPile_Edit.setMaximumWidth(350) self.WorkPile_Edit.setReadOnly(True) self.WorkPile_Edit.setText("Load a Measure.") layout_H_1.addWidget(self.WorkPile_Edit) layout_H_1.addSpacing(self.longSpace) # # ======================================================== # PERCENTAGE OF VISIBLE X AXIS SELECTION # ======================================================== # msg = "Selection of the extension of x-axis to view." X_View_Percent_Label = QtWidgets.QLabel("X-View %") X_View_Percent_Label.setFrameShape(QtWidgets.QFrame.Box) X_View_Percent_Label.setAlignment(QtCore.Qt.AlignCenter) X_View_Percent_Label.setMaximumWidth(c.x_button) X_View_Percent_Label.setToolTip(msg) # self.X_View_Percent_SpBox = QtWidgets.QDoubleSpinBox() self.X_View_Percent_SpBox.setToolTip(msg) self.X_View_Percent_SpBox.setMaximumWidth(100) self.X_View_Percent_SpBox.setRange(0.05, 100) self.X_View_Percent_SpBox.setValue(c.X_View_PercentBase / 50) self.X_View_Percent_SpBox.setDecimals(2) self.X_View_Percent_SpBox.setSingleStep(0.05) self.X_View_Percent_SpBox.valueChanged.connect( self.set_X_View_Percentage) self.X_View_Percent = self.X_View_Percent_SpBox.value( ) / 100 # Fraction of X-axis to show # layout_H_1.addWidget(X_View_Percent_Label) layout_H_1.addWidget(self.X_View_Percent_SpBox) layout_H_1.addSpacing(self.longSpace) # # ======================================================== # X-SCALE BUTTON SELECTING X SCALE AS [m] OR ARRAY INDEX # ======================================================== # msg = "When pushed change the X scale from [ m ] to the array index [ i ]." x_scale_label = QtWidgets.QLabel("X scale") x_scale_label.setFrameShape(QtWidgets.QFrame.Box) x_scale_label.setMaximumWidth(c.x_button) x_scale_label.setAlignment(QtCore.Qt.AlignCenter) x_scale_label.setToolTip(msg) # self.x_scaleButton = QPushButton("[ m ]") self.x_scaleButton.setToolTip(msg) self.x_scaleButton.setCheckable(True) self.x_scaleButton.toggled.connect(self.setXscale) # layout_H_1.addWidget(x_scale_label) layout_H_1.addWidget(self.x_scaleButton) layout_H_1.addSpacing(self.longSpace) # #------------------ # END OF layout_H_1 #------------------ layout_H_1.addItem(spacerItem) # # ======================================================== # ACTUAL NUMBER OF HAMMER BLOWS # ======================================================== # msg = "Actual Blow Number / Total number." Blows_label = QtWidgets.QLabel("Blow / Blows") Blows_label.setAlignment(QtCore.Qt.AlignCenter) Blows_label.setToolTip(msg) # self.Blows_Edit = QtWidgets.QLineEdit() self.Blows_Edit.setReadOnly(True) self.Blows_Edit.setToolTip(msg) self.Blows_Edit.setMaximumWidth(70) self.Blows_Edit.setAlignment(QtCore.Qt.AlignCenter) msg = "" self.Blows_Edit.setText(msg) # layout_H_2.addWidget(Blows_label) layout_H_2.addWidget(self.Blows_Edit) layout_H_2.addSpacing(self.shortSpace) # ======================================================== # [ < ] FILE LOWER QPushButton # ======================================================== # self.FileLower_Button = QtWidgets.QPushButton("&<") self.FileLower_Button.setFixedSize(c.button_size) self.FileLower_Button.setToolTip("Load precedent File.") self.FileLower_Button.pressed.connect(self.fileLower) # layout_H_2.addWidget(self.FileLower_Button) layout_H_2.addSpacing(self.shortSpace) # # ======================================================== # [ > ] FILE UPPER QPushButton # ======================================================== # self.FileUpper_Button = QtWidgets.QPushButton("&>") self.FileUpper_Button.setFixedSize(c.button_size) self.FileUpper_Button.setToolTip("Load next file.") self.FileUpper_Button.pressed.connect(self.fileUpper) # layout_H_2.addWidget(self.FileUpper_Button) layout_H_2.addSpacing(self.longSpace) # # ======================================================== # PUT OUT Button to send a file Data to D/A ch1, ch2 # ======================================================== # self.putOutButton = QPushButton("Put&Out") self.putOutButton.setStyleSheet("background-color: orange") self.putOutButton.setToolTip("Put on Output the actual File data.") self.putOutButton.clicked.connect(self.putOut) # layout_H_2.addWidget(self.putOutButton) layout_H_2.addSpacing(self.longSpace) # # ======================================================== # OUT GAIN Button to apply t.PI_OUT_GAIN factor to Ouptut # ======================================================== # msg = "When pushed change the Output Gain from 1 V/V to ~3 V/V." outGain_label = QtWidgets.QLabel("Out Gain") outGain_label.setAlignment(QtCore.Qt.AlignCenter) outGain_label.setToolTip(msg) # self.outGainButton = QPushButton("1/3") self.outGainButton.setToolTip(msg) self.outGainButton.setCheckable(True) self.outGainButton.toggled.connect(self.setOutGain) # layout_H_2.addWidget(outGain_label) layout_H_2.addWidget(self.outGainButton) layout_H_2.addSpacing(self.longSpace) # # ======================================================== # PLOT Button connected to `plotData` method # ======================================================== self.plotButton = QPushButton("&Plot") self.plotButton.setToolTip("Repeat the Plot.") self.plotButton.clicked.connect(self.plotData) # layout_H_2.addWidget(self.plotButton) layout_H_2.addSpacing(self.longSpace) # #------------------ # END OF layout_H_2 #------------------ layout_H_2.addItem(spacerItem) # self.set_X_View_Percentage()
def __init__(self, main_win=None): super().__init__(main_win) self.main_win = main_win # set the application name and the version self.name = unc_name self.version = unc_version if self.main_win is None: self.setWindowTitle('%s v.%s' % (self.name, self.version)) else: self.setWindowTitle('%s' % (self.name, )) self.setMinimumSize(200, 200) self.resize(600, 900) # only called when stand-alone (without Sound Speed Manager) # noinspection PyArgumentList _app = QtCore.QCoreApplication.instance() if _app.applicationName() == 'python': _app.setApplicationName('%s v.%s' % (self.name, self.version)) _app.setOrganizationName("HydrOffice") _app.setOrganizationDomain("hydroffice.org") logger.debug("set application name: %s" % _app.applicationName()) # set icons icon_info = QtCore.QFileInfo(os.path.join(self.media, 'unccalc.png')) self.setWindowIcon(QtGui.QIcon(icon_info.absoluteFilePath())) if (sys.platform == 'win32') or (os.name is "nt"): # is_windows() try: # This is needed to display the app icon on the taskbar on Windows 7 import ctypes app_id = '%s v.%s' % (self.name, self.version) ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id) except AttributeError as e: logger.debug("Unable to change app icon: %s" % e) # set palette style_info = QtCore.QFileInfo(os.path.join(self.here, 'styles', 'main.stylesheet')) style_content = open(style_info.filePath()).read() self.setStyleSheet(style_content) # settings = QtCore.QSettings() # mpl figure settings self.is_drawn = False self.f_dpi = 120 # dots-per-inch self.f_sz = (3.0, 6.0) # inches self.tvu_plot = None self.thu_plot = None self.iho_color = '#E69F24' self.noaa_color = '#1C75C3' # outline ui self.top_widget = QtWidgets.QWidget() self.setCentralWidget(self.top_widget) self.vbox = QtWidgets.QVBoxLayout() self.vbox.setContentsMargins(4, 4, 4, 4) self.top_widget.setLayout(self.vbox) # ### Settings ### self.settings = QtWidgets.QGroupBox("Settings") self.vbox.addWidget(self.settings) settings_vbox = QtWidgets.QVBoxLayout() self.settings.setLayout(settings_vbox) label_hbox = QtWidgets.QHBoxLayout() settings_vbox.addLayout(label_hbox) # stretch label_hbox.addStretch() # specs text_1ab = QtWidgets.QLabel("Order 1") text_1ab.setAlignment(QtCore.Qt.AlignCenter) text_1ab.setFixedWidth(120) label_hbox.addWidget(text_1ab) # stretch label_hbox.addStretch() toggle_hbox = QtWidgets.QHBoxLayout() settings_vbox.addLayout(toggle_hbox) # stretch toggle_hbox.addStretch() # specs self.toggle_order = QtWidgets.QDial() self.toggle_order.setNotchesVisible(True) self.toggle_order.setFocusPolicy(QtCore.Qt.StrongFocus) self.toggle_order.setRange(0, 2) self.toggle_order.setValue(0) self.toggle_order.setFixedSize(QtCore.QSize(50, 50)) self.toggle_order.setInvertedAppearance(False) # noinspection PyUnresolvedReferences self.toggle_order.valueChanged.connect(self.on_tvu_changed) toggle_hbox.addWidget(self.toggle_order) # self.toggle_specs_v5.valueChanged.connect(self.click_set_profile) # stretch toggle_hbox.addStretch() label2_hbox = QtWidgets.QHBoxLayout() settings_vbox.addLayout(label2_hbox) # stretch label2_hbox.addStretch() # specs text_special = QtWidgets.QLabel("Special Order") text_special.setAlignment(QtCore.Qt.AlignCenter) text_special.setFixedWidth(80) label2_hbox.addWidget(text_special) text_2 = QtWidgets.QLabel("Order 2") text_2.setAlignment(QtCore.Qt.AlignCenter) text_2.setFixedWidth(80) label2_hbox.addWidget(text_2) # stretch label2_hbox.addStretch() settings_vbox.addSpacing(8) hbox = QtWidgets.QHBoxLayout() hbox.addStretch() formula_text = QtWidgets.QLabel("TVU: ") formula_text.setFixedWidth(60) hbox.addWidget(formula_text) formula_label = QtWidgets.QLabel() formula_label.setPixmap(QtGui.QPixmap(os.path.join(self.media, 'tvu_formula.png'))) formula_label.setFixedWidth(120) hbox.addWidget(formula_label) hbox.addSpacing(6) self.thu_a_text = QtWidgets.QLabel("a") hbox.addWidget(self.thu_a_text) self.thu_a_value = QtWidgets.QLineEdit() self.thu_a_value.setFixedWidth(60) self.thu_a_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.thu_a_value)) self.thu_a_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.thu_a_value.setDisabled(True) self.thu_a_value.setText("0.25") hbox.addWidget(self.thu_a_value) self.thu_b_text = QtWidgets.QLabel(", b") hbox.addWidget(self.thu_b_text) self.thu_b_value = QtWidgets.QLineEdit() self.thu_b_value.setFixedWidth(60) self.thu_b_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.thu_b_value)) self.thu_b_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.thu_b_value.setDisabled(True) self.thu_b_value.setText("0.0075") hbox.addWidget(self.thu_b_value) hbox.addStretch() settings_vbox.addLayout(hbox) hbox = QtWidgets.QHBoxLayout() hbox.addStretch() formula_text = QtWidgets.QLabel("IHO THU: ") formula_text.setFixedWidth(60) hbox.addWidget(formula_text) formula_label = QtWidgets.QLabel() formula_label.setPixmap(QtGui.QPixmap(os.path.join(self.media, 'thu_formula.png'))) formula_label.setFixedWidth(120) hbox.addWidget(formula_label) hbox.addSpacing(6) self.thu_k_text = QtWidgets.QLabel("k") hbox.addWidget(self.thu_k_text) self.thu_k_value = QtWidgets.QLineEdit() self.thu_k_value.setFixedWidth(60) self.thu_k_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.thu_k_value)) self.thu_k_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.thu_k_value.setDisabled(True) self.thu_k_value.setText("2.0") hbox.addWidget(self.thu_k_value) self.tvu_p_text = QtWidgets.QLabel(", p") hbox.addWidget(self.tvu_p_text) self.thu_p_value = QtWidgets.QLineEdit() self.thu_p_value.setFixedWidth(60) self.thu_p_value.setValidator(QtGui.QDoubleValidator(0.00001, 1.0, 5, self.thu_p_value)) self.thu_p_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.thu_p_value.setDisabled(True) self.thu_p_value.setText("0.0") hbox.addWidget(self.thu_p_value) hbox.addStretch() settings_vbox.addLayout(hbox) hbox = QtWidgets.QHBoxLayout() hbox.addStretch() formula_text = QtWidgets.QLabel("NOAA THU: ") formula_text.setFixedWidth(60) hbox.addWidget(formula_text) formula_label = QtWidgets.QLabel() formula_label.setPixmap(QtGui.QPixmap(os.path.join(self.media, 'thu_formula.png'))) formula_label.setFixedWidth(120) hbox.addWidget(formula_label) hbox.addSpacing(6) self.noaa_thu_k_text = QtWidgets.QLabel("k") hbox.addWidget(self.noaa_thu_k_text) self.noaa_thu_k_value = QtWidgets.QLineEdit() self.noaa_thu_k_value.setFixedWidth(60) self.noaa_thu_k_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.noaa_thu_k_value)) self.noaa_thu_k_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.noaa_thu_k_value.setDisabled(True) self.noaa_thu_k_value.setText("5.0") hbox.addWidget(self.noaa_thu_k_value) self.noaa_thu_p_text = QtWidgets.QLabel(", p") hbox.addWidget(self.noaa_thu_p_text) self.noaa_thu_p_value = QtWidgets.QLineEdit() self.noaa_thu_p_value.setFixedWidth(60) self.noaa_thu_p_value.setValidator(QtGui.QDoubleValidator(0.00001, 1.0, 5, self.noaa_thu_p_value)) self.noaa_thu_p_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.noaa_thu_p_value.setDisabled(True) self.noaa_thu_p_value.setText("0.05") hbox.addWidget(self.noaa_thu_p_value) hbox.addStretch() settings_vbox.addLayout(hbox) # ### Inputs ### self.inputs = QtWidgets.QGroupBox("Input") self.vbox.addWidget(self.inputs) inputs_vbox = QtWidgets.QVBoxLayout() self.inputs.setLayout(inputs_vbox) # Depth hbox = QtWidgets.QHBoxLayout() hbox.addStretch() depth_text = QtWidgets.QLabel("Depth [m]: ") hbox.addWidget(depth_text) self.depth_value = QtWidgets.QLineEdit() self.depth_value.setFixedWidth(60) self.depth_value.setValidator(QtGui.QDoubleValidator(-9999, 9999, 5, self.depth_value)) self.depth_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.depth_value.setText("100.0") hbox.addWidget(self.depth_value) hbox.addSpacing(16) self.calculate = QtWidgets.QPushButton("Run") self.calculate.setFixedHeight(28) self.calculate.setFixedWidth(42) # noinspection PyUnresolvedReferences self.calculate.clicked.connect(self.on_calculate) hbox.addWidget(self.calculate) button = QtWidgets.QPushButton() hbox.addWidget(button) button.setFixedHeight(GuiSettings.single_line_height()) button.setFixedWidth(GuiSettings.single_line_height()) icon_info = QtCore.QFileInfo(os.path.join(self.media, 'small_info.png')) button.setIcon(QtGui.QIcon(icon_info.absoluteFilePath())) button.setToolTip('Open the manual page') button.setStyleSheet(GuiSettings.stylesheet_info_button()) # noinspection PyUnresolvedReferences button.clicked.connect(self.click_open_manual) hbox.addStretch() inputs_vbox.addLayout(hbox) # ### Outputs ### self.outputs = QtWidgets.QGroupBox("Outputs") self.vbox.addWidget(self.outputs) outputs_vbox = QtWidgets.QVBoxLayout() self.outputs.setLayout(outputs_vbox) # IHO hbox = QtWidgets.QHBoxLayout() hbox.addStretch() self.iho_tpu_box = QtWidgets.QGroupBox("IHO") hbox.addWidget(self.iho_tpu_box) tvu_vbox = QtWidgets.QVBoxLayout() self.iho_tpu_box.setLayout(tvu_vbox) iho_tvu_hbox = QtWidgets.QHBoxLayout() tvu_vbox.addLayout(iho_tvu_hbox) iho_tvu_text = QtWidgets.QLabel("TVU: ") iho_tvu_text.setFixedWidth(50) iho_tvu_hbox.addWidget(iho_tvu_text) self.out_tvu_value = QtWidgets.QLineEdit() self.out_tvu_value.setFixedWidth(80) self.out_tvu_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.out_tvu_value)) self.out_tvu_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.out_tvu_value.setDisabled(True) iho_tvu_hbox.addWidget(self.out_tvu_value) iho_tvu_hbox = QtWidgets.QHBoxLayout() tvu_vbox.addLayout(iho_tvu_hbox) iho_thu_text = QtWidgets.QLabel("THU: ") iho_thu_text.setFixedWidth(50) iho_tvu_hbox.addWidget(iho_thu_text) self.out_thu_value = QtWidgets.QLineEdit() self.out_thu_value.setFixedWidth(80) self.out_thu_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.out_thu_value)) self.out_thu_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.out_thu_value.setDisabled(True) iho_tvu_hbox.addWidget(self.out_thu_value) self.noaa_tpu_box = QtWidgets.QGroupBox("NOAA") hbox.addWidget(self.noaa_tpu_box) noaa_vbox = QtWidgets.QVBoxLayout() self.noaa_tpu_box.setLayout(noaa_vbox) noaa_hbox = QtWidgets.QHBoxLayout() noaa_vbox.addLayout(noaa_hbox) noaa_tvu_text = QtWidgets.QLabel("TVU: ") noaa_tvu_text.setFixedWidth(50) noaa_hbox.addWidget(noaa_tvu_text) self.out_noaa_tvu_value = QtWidgets.QLineEdit() self.out_noaa_tvu_value.setFixedWidth(80) self.out_noaa_tvu_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.out_noaa_tvu_value)) self.out_noaa_tvu_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.out_noaa_tvu_value.setDisabled(True) noaa_hbox.addWidget(self.out_noaa_tvu_value) noaa_hbox = QtWidgets.QHBoxLayout() noaa_vbox.addLayout(noaa_hbox) noaa_thu_text = QtWidgets.QLabel("THU: ") noaa_thu_text.setFixedWidth(50) noaa_hbox.addWidget(noaa_thu_text) self.out_noaa_thu_value = QtWidgets.QLineEdit() self.out_noaa_thu_value.setFixedWidth(80) self.out_noaa_thu_value.setValidator(QtGui.QDoubleValidator(0.00001, 9999, 5, self.out_noaa_thu_value)) self.out_noaa_thu_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.out_noaa_thu_value.setDisabled(True) noaa_hbox.addWidget(self.out_noaa_thu_value) hbox.addStretch() outputs_vbox.addLayout(hbox) # ### PLOTS ### # figure and canvas with rc_context(self.rc_context): self.f = Figure(figsize=self.f_sz, dpi=self.f_dpi) self.f.patch.set_alpha(0.0) self.c = FigureCanvas(self.f) self.c.setParent(self) self.c.setFocusPolicy(QtCore.Qt.ClickFocus) # key for press events!!! self.c.setFocus() outputs_vbox.addWidget(self.c) # axes self.tvu_ax = self.f.add_subplot(211) self.tvu_ax.invert_yaxis() self.thu_ax = self.f.add_subplot(212, sharex=self.tvu_ax) self.thu_ax.invert_yaxis() # toolbar self.hbox = QtWidgets.QHBoxLayout() outputs_vbox.addLayout(self.hbox) # navigation self.nav = NavToolbar(canvas=self.c, parent=self.top_widget) self.hbox.addWidget(self.nav) self.on_first_draw()
def __init__(self, main_win=None): super().__init__(main_win) self.main_win = main_win # set the application name and the version self.name = rori_name self.version = rori_version if self.main_win is None: self.setWindowTitle('%s v.%s' % (self.name, self.version)) else: self.setWindowTitle('%s' % (self.name,)) self.setMinimumSize(200, 200) self.resize(600, 900) # only called when stand-alone (without Sound Speed Manager) # noinspection PyArgumentList _app = QtCore.QCoreApplication.instance() if _app.applicationName() == 'python': _app.setApplicationName('%s v.%s' % (self.name, self.version)) _app.setOrganizationName("HydrOffice") _app.setOrganizationDomain("hydroffice.org") logger.debug("set application name: %s" % _app.applicationName()) # set icons icon_info = QtCore.QFileInfo(os.path.join(self.media, 'rori.png')) self.setWindowIcon(QtGui.QIcon(icon_info.absoluteFilePath())) if (sys.platform == 'win32') or (os.name == "nt"): # is_windows() try: # This is needed to display the app icon on the taskbar on Windows 7 import ctypes app_id = '%s v.%s' % (self.name, self.version) ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id) except AttributeError as e: logger.debug("Unable to change app icon: %s" % e) # set palette style_info = QtCore.QFileInfo(os.path.join(self.here, 'styles', 'main.stylesheet')) style_content = open(style_info.filePath()).read() self.setStyleSheet(style_content) # mpl figure settings self.is_drawn = False self.f_dpi = 120 # dots-per-inch self.f_sz = (3.0, 6.0) # inches self.tvu_plot = None self.thu_plot = None self.iho_color = '#E69F24' self.noaa_color = '#1C75C3' # outline ui self.top_widget = QtWidgets.QWidget() self.setCentralWidget(self.top_widget) self.vbox = QtWidgets.QVBoxLayout() self.vbox.setContentsMargins(4, 4, 4, 4) self.top_widget.setLayout(self.vbox) # ### Settings ### self.settings = QtWidgets.QGroupBox("Settings") self.vbox.addWidget(self.settings) settings_vbox = QtWidgets.QVBoxLayout() self.settings.setLayout(settings_vbox) label_hbox = QtWidgets.QHBoxLayout() settings_vbox.addLayout(label_hbox) # stretch label_hbox.addStretch() # hssd text_1ab = QtWidgets.QLabel("") text_1ab.setAlignment(QtCore.Qt.AlignCenter) text_1ab.setFixedWidth(100) label_hbox.addWidget(text_1ab) # spacing label_hbox.addSpacing(10) # specs text_1ab = QtWidgets.QLabel("Great Lakes") text_1ab.setAlignment(QtCore.Qt.AlignCenter) text_1ab.setFixedWidth(100) label_hbox.addWidget(text_1ab) # spacing label_hbox.addSpacing(10) # specs text_1ab = QtWidgets.QLabel("") text_1ab.setAlignment(QtCore.Qt.AlignCenter) text_1ab.setFixedWidth(100) label_hbox.addWidget(text_1ab) # stretch label_hbox.addStretch() toggle_hbox = QtWidgets.QHBoxLayout() settings_vbox.addLayout(toggle_hbox) # stretch toggle_hbox.addStretch() # HSSD self.toggle_hssd = QtWidgets.QDial() self.toggle_hssd.setNotchesVisible(True) self.toggle_hssd.setFocusPolicy(QtCore.Qt.StrongFocus) self.toggle_hssd.setRange(0, 1) self.toggle_hssd.setValue(0) self.toggle_hssd.setFixedSize(QtCore.QSize(50, 50)) self.toggle_hssd.setInvertedAppearance(False) # noinspection PyUnresolvedReferences self.toggle_hssd.valueChanged.connect(self.on_settings_changed) toggle_hbox.addWidget(self.toggle_hssd) # spacing toggle_hbox.addSpacing(105) # area self.toggle_area = QtWidgets.QDial() self.toggle_area.setNotchesVisible(True) self.toggle_area.setFocusPolicy(QtCore.Qt.StrongFocus) self.toggle_area.setRange(0, 2) self.toggle_area.setValue(0) self.toggle_area.setFixedSize(QtCore.QSize(50, 50)) self.toggle_area.setInvertedAppearance(False) # noinspection PyUnresolvedReferences self.toggle_area.valueChanged.connect(self.on_settings_changed) toggle_hbox.addWidget(self.toggle_area) # spacing0 toggle_hbox.addSpacing(105) # specs self.toggle_z = QtWidgets.QDial() self.toggle_z.setNotchesVisible(True) self.toggle_z.setFocusPolicy(QtCore.Qt.StrongFocus) self.toggle_z.setRange(0, 1) self.toggle_z.setValue(0) self.toggle_z.setFixedSize(QtCore.QSize(50, 50)) self.toggle_z.setInvertedAppearance(False) # noinspection PyUnresolvedReferences self.toggle_z.valueChanged.connect(self.on_settings_changed) toggle_hbox.addWidget(self.toggle_z) # stretch toggle_hbox.addStretch() label2_hbox = QtWidgets.QHBoxLayout() settings_vbox.addLayout(label2_hbox) # stretch label2_hbox.addStretch() # specs text_special = QtWidgets.QLabel("HSSD 2018 ") text_special.setAlignment(QtCore.Qt.AlignRight) text_special.setFixedWidth(70) label2_hbox.addWidget(text_special) text_2 = QtWidgets.QLabel(" HSSD 2019+") text_2.setAlignment(QtCore.Qt.AlignLeft) text_2.setFixedWidth(70) label2_hbox.addWidget(text_2) # stretch label2_hbox.addSpacing(10) # area text_special = QtWidgets.QLabel("Pacific Coast ") text_special.setAlignment(QtCore.Qt.AlignRight) text_special.setFixedWidth(70) label2_hbox.addWidget(text_special) text_2 = QtWidgets.QLabel(" Atlantic Coast") text_2.setAlignment(QtCore.Qt.AlignLeft) text_2.setFixedWidth(70) label2_hbox.addWidget(text_2) # stretch label2_hbox.addSpacing(10) # specs text_special = QtWidgets.QLabel("Depth ") text_special.setAlignment(QtCore.Qt.AlignRight) text_special.setFixedWidth(70) label2_hbox.addWidget(text_special) text_2 = QtWidgets.QLabel(" Elevation") text_2.setAlignment(QtCore.Qt.AlignLeft) text_2.setFixedWidth(70) label2_hbox.addWidget(text_2) # stretch label2_hbox.addStretch() settings_vbox.addSpacing(8) hbox = QtWidgets.QHBoxLayout() hbox.addStretch() watlev_text = QtWidgets.QLabel("Always Dry: ") watlev_text.setFixedWidth(100) hbox.addWidget(watlev_text) self.always_dry_min_value = QtWidgets.QLineEdit() self.always_dry_min_value.setFixedWidth(120) self.always_dry_min_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.always_dry_min_value.setDisabled(True) self.always_dry_min_value.setText("") hbox.addWidget(self.always_dry_min_value) self.always_dry_max_value = QtWidgets.QLineEdit() self.always_dry_max_value.setFixedWidth(120) self.always_dry_max_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.always_dry_max_value.setDisabled(True) self.always_dry_max_value.setText("") hbox.addWidget(self.always_dry_max_value) hbox.addStretch() settings_vbox.addLayout(hbox) hbox = QtWidgets.QHBoxLayout() hbox.addStretch() watlev_text = QtWidgets.QLabel("Covers & Uncovers: ") watlev_text.setFixedWidth(100) hbox.addWidget(watlev_text) self.covers_and_uncovers_min_value = QtWidgets.QLineEdit() self.covers_and_uncovers_min_value.setFixedWidth(120) self.covers_and_uncovers_min_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.covers_and_uncovers_min_value.setDisabled(True) self.covers_and_uncovers_min_value.setText("") hbox.addWidget(self.covers_and_uncovers_min_value) self.covers_and_uncovers_max_value = QtWidgets.QLineEdit() self.covers_and_uncovers_max_value.setFixedWidth(120) self.covers_and_uncovers_max_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.covers_and_uncovers_max_value.setDisabled(True) self.covers_and_uncovers_max_value.setText("") hbox.addWidget(self.covers_and_uncovers_max_value) hbox.addStretch() settings_vbox.addLayout(hbox) hbox = QtWidgets.QHBoxLayout() hbox.addStretch() watlev_text = QtWidgets.QLabel("Awash: ") watlev_text.setFixedWidth(100) hbox.addWidget(watlev_text) self.awash_min_value = QtWidgets.QLineEdit() self.awash_min_value.setFixedWidth(120) self.awash_min_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.awash_min_value.setDisabled(True) self.awash_min_value.setText("") hbox.addWidget(self.awash_min_value) self.awash_max_value = QtWidgets.QLineEdit() self.awash_max_value.setFixedWidth(120) self.awash_max_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.awash_max_value.setDisabled(True) self.awash_max_value.setText("") hbox.addWidget(self.awash_max_value) hbox.addStretch() settings_vbox.addLayout(hbox) hbox = QtWidgets.QHBoxLayout() hbox.addStretch() watlev_text = QtWidgets.QLabel("Always underwater: ") watlev_text.setFixedWidth(100) hbox.addWidget(watlev_text) self.always_underwater_min_value = QtWidgets.QLineEdit() self.always_underwater_min_value.setFixedWidth(120) self.always_underwater_min_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.always_underwater_min_value.setDisabled(True) self.always_underwater_min_value.setText("") hbox.addWidget(self.always_underwater_min_value) self.always_underwater_max_value = QtWidgets.QLineEdit() self.always_underwater_max_value.setFixedWidth(120) self.always_underwater_max_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.always_underwater_max_value.setDisabled(True) self.always_underwater_max_value.setText("") hbox.addWidget(self.always_underwater_max_value) hbox.addStretch() settings_vbox.addLayout(hbox) # ### Inputs ### self.inputs = QtWidgets.QGroupBox("Input") self.vbox.addWidget(self.inputs) inputs_vbox = QtWidgets.QVBoxLayout() self.inputs.setLayout(inputs_vbox) # MHW hbox = QtWidgets.QHBoxLayout() hbox.addStretch() self.mhw_text = QtWidgets.QLabel("MHW [m]: ") hbox.addWidget(self.mhw_text) self.mhw_value = QtWidgets.QLineEdit() self.mhw_value.setFixedWidth(60) self.mhw_value.setValidator(QtGui.QDoubleValidator(-9999, 9999, 5, self.mhw_value)) self.mhw_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.mhw_value.setText("5.0") hbox.addWidget(self.mhw_value) depth_text = QtWidgets.QLabel("Depth [m]: ") hbox.addWidget(depth_text) self.depth_value = QtWidgets.QLineEdit() self.depth_value.setFixedWidth(60) self.depth_value.setValidator(QtGui.QDoubleValidator(-9999, 9999, 5, self.depth_value)) self.depth_value.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.depth_value.setText("1.0") hbox.addWidget(self.depth_value) hbox.addSpacing(16) self.calculate = QtWidgets.QPushButton("Run") self.calculate.setFixedHeight(28) self.calculate.setFixedWidth(42) # noinspection PyUnresolvedReferences self.calculate.clicked.connect(self.on_calculate) hbox.addWidget(self.calculate) button = QtWidgets.QPushButton() hbox.addWidget(button) button.setFixedHeight(GuiSettings.single_line_height()) button.setFixedWidth(GuiSettings.single_line_height()) icon_info = QtCore.QFileInfo(os.path.join(self.media, 'small_info.png')) button.setIcon(QtGui.QIcon(icon_info.absoluteFilePath())) button.setToolTip('Open the manual page') button.setStyleSheet(GuiSettings.stylesheet_info_button()) # noinspection PyUnresolvedReferences button.clicked.connect(self.click_open_manual) hbox.addStretch() inputs_vbox.addLayout(hbox) # ### Outputs ### self.outputs = QtWidgets.QGroupBox("Outputs") self.vbox.addWidget(self.outputs) outputs_vbox = QtWidgets.QVBoxLayout() self.outputs.setLayout(outputs_vbox) outputs_hbox = QtWidgets.QHBoxLayout() outputs_vbox.addLayout(outputs_hbox) outputs_hbox.addStretch() # pic self.out_pic_label = QtWidgets.QLabel() outputs_hbox.addWidget(self.out_pic_label) # info hbox = QtWidgets.QHBoxLayout() hbox.addStretch() out_text_vbox = QtWidgets.QVBoxLayout() hbox.addLayout(out_text_vbox) self.out_main_label = QtWidgets.QLabel() self.out_main_label.setFixedWidth(320) self.out_main_label.setStyleSheet("font-weight: bold") out_text_vbox.addWidget(self.out_main_label) self.out_more_label = QtWidgets.QLabel() self.out_more_label.setFixedWidth(320) out_text_vbox.addWidget(self.out_more_label) hbox.addStretch() outputs_hbox.addLayout(hbox) outputs_hbox.addStretch() # ### PLOTS ### # figure and canvas with rc_context(self.rc_context): self.f = Figure(figsize=self.f_sz, dpi=self.f_dpi) self.f.patch.set_alpha(0.0) self.c = FigureCanvas(self.f) self.c.setParent(self) self.c.setFocusPolicy(QtCore.Qt.ClickFocus) # key for press events!!! self.c.setFocus() outputs_vbox.addWidget(self.c) # axes self.levels_ax = self.f.add_subplot(111) self.levels_ax.invert_yaxis() # toolbar self.hbox = QtWidgets.QHBoxLayout() outputs_vbox.addLayout(self.hbox) # navigation self.nav = NavToolbar(canvas=self.c, parent=self.top_widget) self.hbox.addWidget(self.nav) self.on_settings_changed() self.on_first_draw()