def __init__(self, chart, ctrl): super().__init__() self.chart = chart self.ctrl = ctrl self.hoverItem = None # build user interface (it was easier to do it here than via developer) self.view = FlowchartGraphicsView(self) self.viewDock = dockarea.Dock('view', size=(1000, 600)) self.viewDock.addWidget(self.view) self.viewDock.hideTitleBar() self.addDock(self.viewDock) self.hoverText = QtGui.QTextEdit() self.hoverText.setReadOnly(True) self.hoverDock = dockarea.Dock('Hover Info', size=(1000, 20)) self.hoverDock.addWidget(self.hoverText) self.addDock(self.hoverDock, 'bottom') self.statusText = QtGui.QTextEdit() self.statusText.setReadOnly(True) self.statusDock = dockarea.Dock('Status', size=(1000, 20)) self.statusDock.addWidget(self.statusText) self.addDock(self.statusDock, 'bottom') self._scene = self.view.scene() self._viewBox = self.view.viewBox() self._scene.selectionChanged.connect(self.selectionChanged) self._scene.sigMouseHover.connect(self.hoverOver)
def __init__(self): dockarea.DockArea.__init__(self) self.tool_docks = [] self.tools = getattr(self, "tools", {}) self.colormap = KiteToolColormap(self.main_widget) dock_main = dockarea.Dock(self.title, autoOrientation=False, widget=self.main_widget) dock_colormap = dockarea.Dock("Colormap", autoOrientation=False, widget=self.colormap) dock_colormap.setStretch(1, None) for i, (name, tool) in enumerate(self.tools.items()): self.tool_docks.append( dockarea.Dock(name, widget=tool, size=(2, 2), autoOrientation=False)) self.addDock(self.tool_docks[-1], position="bottom") self.addDock(dock_main, position="left") self.addDock(dock_colormap, position="right")
def __init__(self): dockarea.DockArea.__init__(self) self.tool_docks = [] dock_main = dockarea.Dock( self.title, autoOrientation=False, widget=self.main_widget) dock_colormap = dockarea.Dock( 'Colormap', autoOrientation=False, widget=KiteToolColormap(self.main_widget)) dock_colormap.setStretch(1, None) for i, (name, tool) in enumerate(self.tools.items()): self.tool_docks.append( dockarea.Dock( name, widget=tool, size=(2, 2), autoOrientation=False)) self.addDock(self.tool_docks[-1], position='bottom') self.addDock(dock_main, position='left') self.addDock(dock_colormap, position='right')
def __init__(self, dock_area): super(DrawSelection, self).__init__() self.container = None self.dock_area = dock_area self.dock_mag = da.Dock('') self.dock_area.addDock(self.dock_mag, 'above') self.dock_geom = da.Dock('') self.dock_area.addDock(self.dock_geom, 'above')
def init_UI(self): # ini the widgets self.Frame_Visualizer = Frame_Visualizer_Widget(self.Main, self) self.LUT_Controlers = LUT_Controlers_Widget(self.Main, self) self.Traces_Visualizer = Traces_Visualizer_Widget(self.Main, self) self.Traces_Visualizer_Stimsorted = Traces_Visualizer_Stimsorted_Widget( self.Main, self) ### layout # The main Layout: Stacks Frame_Visualizer (+ LUT_Controlers) and Traces_Visualizer # Frame_Visualizer + LUT_Controlers self.FrameWidget = QtGui.QWidget(self) self.FrameLayout = QtGui.QHBoxLayout() self.FrameLayout.setMargin(0) self.FrameLayout.setSpacing(0) self.FrameLayout.addWidget(self.Frame_Visualizer) self.FrameLayout.addWidget(self.LUT_Controlers) self.FrameLayout.setStretchFactor(self.Frame_Visualizer, 5) self.FrameLayout.setStretchFactor(self.LUT_Controlers, 1) self.FrameWidget.setLayout(self.FrameLayout) self.DockArea = pg.dockarea.DockArea() self.setCentralWidget(self.DockArea) self.FrameDock = pgd.Dock('current frame', size=(10, 10), autoOrientation=False) self.TracesDock = pgd.Dock('traces with common time base', size=(10, 10)) self.TracesStimsortedDock = pgd.Dock('traces sorted to stim class', size=(10, 10)) # self.FrameDock = myDock('current frame',size=(10,10),autoOrientation=False) # self.TracesDock = myDock('traces with common time base',size=(10,10)) # self.TracesStimsortedDock = myDock('traces sorted to stim class',size=(10,10)) self.DockArea.addDock(dock=self.FrameDock, position='top') self.DockArea.addDock(dock=self.TracesDock, position='bottom') self.DockArea.addDock(dock=self.TracesStimsortedDock, position='below', relativeTo=self.TracesDock) self.FrameDock.addWidget(self.FrameWidget) self.TracesStimsortedDock.addWidget(self.Traces_Visualizer_Stimsorted) self.TracesDock.addWidget(self.Traces_Visualizer) self.DockArea.getContainer(self.TracesDock).tabClicked( self.TracesDock.label) # sizing the FrameDock bigger than TracesDock DesktopWidget = QtGui.QDesktopWidget() qrect = DesktopWidget.screenGeometry() height, width = qrect.height(), qrect.width() self.FrameDock.setStretch(y=(height / 3.0) * 2) self.TracesDock.setStretch(y=(height / 3.0) * 1)
def __init__(self, chart, ctrl): #QtGui.QWidget.__init__(self) dockarea.DockArea.__init__(self) self.chart = chart self.ctrl = ctrl self.hoverItem = None #self.setMinimumWidth(250) #self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)) #self.ui = FlowchartTemplate.Ui_Form() #self.ui.setupUi(self) ## build user interface (it was easier to do it here than via developer) self.view = FlowchartGraphicsView.FlowchartGraphicsView(self) self.viewDock = dockarea.Dock('view', size=(1000, 600)) self.viewDock.addWidget(self.view) self.viewDock.hideTitleBar() self.addDock(self.viewDock) self.hoverText = QtGui.QTextEdit() self.hoverText.setReadOnly(True) self.hoverDock = dockarea.Dock('Hover Info', size=(1000, 20)) self.hoverDock.addWidget(self.hoverText) self.addDock(self.hoverDock, 'bottom') self.selInfo = QtGui.QWidget() self.selInfoLayout = QtGui.QGridLayout() self.selInfo.setLayout(self.selInfoLayout) self.selDescLabel = QtGui.QLabel() self.selNameLabel = QtGui.QLabel() self.selDescLabel.setWordWrap(True) self.selectedTree = pg.DataTreeWidget() #self.selectedTree.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) #self.selInfoLayout.addWidget(self.selNameLabel) self.selInfoLayout.addWidget(self.selDescLabel) self.selInfoLayout.addWidget(self.selectedTree) self.selDock = dockarea.Dock('Selected Node', size=(1000, 200)) self.selDock.addWidget(self.selInfo) self.addDock(self.selDock, 'bottom') self._scene = self.view.scene() self._viewBox = self.view.viewBox() #self._scene = QtGui.QGraphicsScene() #self._scene = FlowchartGraphicsView.FlowchartGraphicsScene() #self.view.setScene(self._scene) self.buildMenu() #self.ui.addNodeBtn.mouseReleaseEvent = self.addNodeBtnReleased self._scene.selectionChanged.connect(self.selectionChanged) self._scene.sigMouseHover.connect(self.hoverOver)
def __init__(self, sandbox, *args, **kwargs): dockarea.DockArea.__init__(self) layout = ModelReferenceLayout(sandbox) cmap = ColormapPlots() for plt in layout.plots: cmap.addPlot(plt) cmap_dock = dockarea.Dock('Colormap', widget=cmap) cmap_dock.setStretch(1, None) layout_dock = dockarea.Dock('Model Sandbox', widget=layout) self.addDock(layout_dock, position='right') self.addDock(cmap_dock, position='right')
def __init__(self, model, parent=None): QtWidgets.QDialog.__init__(self, parent) loadUi(get_resource("noise_dialog.ui"), baseinstance=self) self.closeButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_DialogCloseButton)) self.setWindowFlags(QtCore.Qt.Window) self.noise_patch = self.NoisePlot(model) self.noise_synthetic = self.NoiseSyntheticPlot(model) colormap = KiteToolColormap(self.noise_patch) self.noise_synthetic.setGradientEditor(colormap) self.dockarea = dockarea.DockArea(self) self.dockarea.addDock( dockarea.Dock( "Covariance.noise_data", widget=self.noise_patch, size=(6, 6), autoOrientation=False, ), position="top", ) self.dockarea.addDock( dockarea.Dock( "Covariance.syntheticNoise", widget=self.noise_synthetic, size=(6, 6), autoOrientation=False, ), position="bottom", ) self.dockarea.addDock( dockarea.Dock( "Colormap", widget=colormap, size=(1, 1), autoOrientation=False, ), position="right", ) self.horizontalLayoutPlot.addWidget(self.dockarea) self.resetSizeButton.released.connect(self.noise_synthetic.resetSize) self.anisotropicCB.toggled.connect( lambda b: self.noise_synthetic.enableAnisotropic(b))
def initializePlot(self): self.win.setWindowTitle("szenergy gps visualizer") self.win.resize(1200,600) self.win.setCentralWidget(self.area) self.dleft1 = darea.Dock("left 1", size = (1,1)) # give this dock minimum possible size self.dleft2 = darea.Dock("left 2", size = (500,400)) # size is only a suggestion self.dright1 = darea.Dock("right 1", size=(500,200)) self.dright2 = darea.Dock("right 2", size=(500,200)) self.area.addDock(self.dleft1, "left") self.area.addDock(self.dleft2, "bottom", self.dleft1) self.area.addDock(self.dright1, "right") self.area.addDock(self.dright2, "below", self.dright1) ## place dright2 at top edge of dright1 self.area.moveDock(self.dright2, "below", self.dright1) self.wleft1 = pg.LayoutWidget() self.mainlabel = qtgqt.QtGui.QLabel("No data\n\n") self.seclabel = qtgqt.QtGui.QLabel("No data\n\n") self.saveBtn = qtgqt.QtGui.QPushButton("Save dock state") self.restoreBtn = qtgqt.QtGui.QPushButton("Restore dock state") self.rndBtn = qtgqt.QtGui.QPushButton("Random") self.restoreBtn.setEnabled(False) self.wleft1.addWidget(self.mainlabel, row=0, col=0) self.wleft1.addWidget(self.seclabel, row=0, col=1) self.wleft1.addWidget(self.saveBtn, row=1, col=0) self.wleft1.addWidget(self.restoreBtn, row=2, col=0) self.wleft1.addWidget(self.rndBtn, row=3, col=2) self.wleft1.setStyleSheet("background-color: rgb(40, 44, 52); color: rgb(171, 178, 191);") self.dleft1.setStyleSheet("background-color: rgb(18, 20, 23);") self.mainlabel.setStyleSheet("font: 30pt; background-color: rgb(44, 48, 56)") self.dleft1.addWidget(self.wleft1) self.state = None self.wleft2 = pg.PlotWidget(title="Plot left 2 (bottom)") self.plot_left2 = pg.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(6,106,166,255)) self.wleft2.showGrid(x=True, y=True) self.wleft2.addItem(self.plot_left2) self.dleft2.addWidget(self.wleft2) self.rndBtn.clicked.connect(self.rnd) self.saveBtn.clicked.connect(self.save) self.restoreBtn.clicked.connect(self.load) self.wright1 = pg.PlotWidget(title="Plot right 1") self.wright1.plot(np.random.normal(size=20)) self.wright1.showGrid(x=True, y=True) self.dright1.addWidget(self.wright1) self.wright2 = pg.PlotWidget(title="Plot right") self.plot_right2 = pg.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(200,66,66,255)) self.wright2.showGrid(x=True, y=True) self.wright2.addItem(self.plot_right2) self.dright2.addWidget(self.wright2) self.win.show()
def __init__(self, sandbox, *args, **kwargs): dockarea.DockArea.__init__(self) layout = SandboxSceneLayout(sandbox) cmap = ColormapPlots() for plt in layout.plots: cmap.addPlot(plt) sandbox.sigModelUpdated.connect(cmap.setSymColormap) cmap_dock = dockarea.Dock("Colormap", widget=cmap) cmap_dock.setStretch(1, None) layout_dock = dockarea.Dock("Model Sandbox", widget=layout) self.addDock(layout_dock, position="right") self.addDock(cmap_dock, position="right")
def create_widgets(self, parent): h_layout = QHBoxLayout() self.viewer_cbox = self.builder.checkable_combobox(parent, [], self._set_cb_changed) self.information_cbox = self.builder.checkable_combobox(parent, [], self._set_information_changed) self.information_cbox.setFixedWidth(150) cnt = 0 for info in self._information_box_items: self.information_cbox.addItem(info) new_row = self.information_cbox.count() - 1 item = self.information_cbox.model().item(new_row, 0) if self._information_checked[info]: item.setCheckState(QtCore.Qt.Checked) else: item.setCheckState(QtCore.Qt.Unchecked) self._info_widget_index[cnt] = info cnt += 1 h_layout.addWidget(self.viewer_cbox) h_layout.addItem(QSpacerItem(10, 10)) h_layout.addWidget(self.information_cbox) # add ecu selection self.label_top = QtGui.QLabel() self.label_top.setText("Message View") self.viewDock = dockarea.Dock('view', size=(1000, 600)) self.layout.addWidget(self.label_top) self.label_top.setFixedHeight(20) self.layout.addLayout(h_layout) self.layout.addItem(QSpacerItem(10, 10))
def __set_design(self): """ Sets general settings of frame widget, adds dock area and dock widgets. """ self.setWindowTitle('Player') self.resize(1200, 550) self.dock_area = DockAreaWidget() # dock fixed waveform dock_waveform = pgdock.Dock(name="Waveform", area='Top', hideTitle=True, closable=False, autoOrientation=False) dock_waveform.setMinimumHeight(100) dock_waveform.layout.setSizeConstraint(QLayout.SetMinimumSize) dock_waveform.widgetArea.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) # initializing waveform widget self.waveform_widget = WaveformWidget() # adding waveform widget to waveform dock dock_waveform.addWidget(self.waveform_widget) dock_waveform.allowedAreas = ['top'] dock_waveform.setAcceptDrops(False) # adding waveform dock to dock area self.dock_area.addDock(dock_waveform, position='top') # adding dock area to frame layout = QVBoxLayout(self) layout.addWidget(self.dock_area)
def test_dock(): name = pg.asUnicode("évènts_zà héér") dock = da.Dock(name=name) # make sure unicode names work correctly assert dock.name() == name # no surprises in return type. assert type(dock.name()) == type(name)
def __init__(self, model, parent=None): QtWidgets.QDialog.__init__(self, parent) self.model = model loadUi(get_resource("gacos_correction.ui"), baseinstance=self) self.closeButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_DialogCloseButton)) self.gacos_plot = self.GACOSPlot(model, self) self.dockarea = dockarea.DockArea(self) self.dockarea.addDock( dockarea.Dock( "GACOS.get_correction()", widget=self.gacos_plot, size=(4, 4), autoOrientation=False, ), position="left", ) self.horizontalLayoutPlot.addWidget(self.dockarea) self.loadGrids.released.connect(self.load_grids) self.toggleGACOS.released.connect(self.toggle_gacos) self.update_widgets()
def add_item(self, title_text): # add item to dock new_widget = QTextEdit() new_widget.setText("") new_widget.setReadOnly(True) new_dock = dockarea.Dock(title_text, size=(1000, 20)) new_dock.setOrientation('horizontal') new_dock.addWidget(new_widget) self.addDock(new_dock, 'right') # add item to combobox self.viewer_cbox.addItem(title_text) new_row = self.viewer_cbox.count() - 1 item = self.viewer_cbox.model().item(new_row, 0) item.setCheckState(QtCore.Qt.Checked) # link items self.widget_index[new_row] = new_widget self.widget_text[title_text] = new_widget self.dock_index[new_row] = new_dock return item
def _add_dock(self, title="Dock", size=(500, 200), position="bottom"): if self.area is None: self.area = dockarea.DockArea() self.win.setCentralWidget(self.area) d = dockarea.Dock(title, size=size) self.area.addDock(d, position) logger.debug("Function _add_dock: " + repr(d))
def draw(self): # .. Set colors. N = len(self.rownr) i = 0 self.dock_mag.close() self.dock_mag = da.Dock('Magnitude and Phase') self.dock_area.addDock(self.dock_mag, 'above') graphics_view = pg.GraphicsView() layout = QtGui.QGridLayout() fig_mag = pg.PlotWidget(name='Magnitude') fig_mag.setMinimumHeight(325) fig_mag.setLabel('left', 'Magnitude dB') fig_mag.setLabel('bottom', 'Frequency', units='Hz') fig_mag.setLogMode(x=False, y=True) fig_ang = pg.PlotWidget(name='Angle') fig_ang.setMinimumHeight(125) fig_ang.setMaximumHeight(300) fig_ang.setLabel('left', 'Angle', units='rad') fig_ang.setLabel('bottom', 'Frequency', units='Hz') fig_ang.setXLink('Magnitude') layout.addWidget(fig_mag, 0, 0, 10, 1) layout.addWidget(fig_ang, 10, 0, 11, 1) graphics_view.setLayout(layout) self.dock_mag.addWidget(graphics_view) # .. Prepare data. # TODO: optimize reading here self.fig_container = [] for row in self.rownr: uffid = self.data.tables['measurement_index']['uffid'][row] xy = self.data.tables['measurement_values'][[ 'frq', 'amp' ]][self.data.tables['measurement_values']['uffid'] == uffid].values.astype('complex') y = np.abs(xy[:, 1]) x = xy[:, 0].real mask = y > 1e-8 # v = np.log10(list(y[mask])) fig_mag.plot(x[mask], y[mask], pen=pg.colorTuple(pg.intColor(i, hues=N))) fig_ang.plot(xy[:, 0][mask].real, np.angle(xy[:, 1][mask]), pen=pg.colorTuple(pg.intColor(i, hues=N))) # i += 1
def add_dock(self, title, x_pos, y_pos, position): """Add a dock to the window Arguments: title {string} -- Title of the dock x {int} -- Width y {int} -- Height position {string} -- Grid position """ self.docks.append(qtdk.Dock(title, size=(x_pos, y_pos))) self.area.addDock(self.docks[-1], position)
def __init__(self, scene_proxy, parent=None): QtGui.QDialog.__init__(self, parent) cov_ui = path.join(path.dirname(path.realpath(__file__)), 'ui/noise_dialog.ui') loadUi(cov_ui, baseinstance=self) self.closeButton.setIcon(self.style().standardPixmap( QtGui.QStyle.SP_DialogCloseButton)) self.setWindowFlags(QtCore.Qt.Window) self.noise_patch = self.NoisePlot(scene_proxy) self.noise_synthetic = self.NoiseSyntheticPlot(scene_proxy) colormap = QKiteToolColormap(self.noise_patch) self.noise_synthetic.setGradientEditor(colormap) self.dockarea = dockarea.DockArea(self) self.dockarea.addDock( dockarea.Dock('Covariance.noise_data', widget=self.noise_patch, size=(6, 6), autoOrientation=False,), position='top') self.dockarea.addDock( dockarea.Dock('Covariance.syntheticNoise', widget=self.noise_synthetic, size=(6, 6), autoOrientation=False,), position='bottom') self.dockarea.addDock( dockarea.Dock('Colormap', widget=colormap, size=(1, 1), autoOrientation=False,), position='right') self.horizontalLayoutPlot.addWidget(self.dockarea) self.resetSizeButton.released.connect(self.noise_synthetic.resetSize) self.anisotropicCB.toggled.connect( lambda b: self.noise_synthetic.enableAnisotropic(b))
def __add_ts_widget(self): self.ts_widget = TimeSeriesWidget(self) self.ts_widget.add_1d_view() dock_ts = pgdock.Dock(name='Time Series', area='bottom', closable=True) dock_ts.allowedAreas = ['top', 'bottom'] dock_ts.addWidget(self.ts_widget) dock_ts.layout.setSizeConstraint(QLayout.SetMinimumSize) dock_ts.sigClosed.connect(self.__dock_ts_closed) self.dock_area.addDock(dock_ts) # signals self.ts_widget.wheel_event.connect(self.waveform_widget.wheelEvent)
def setup_ui(self): """ """ self.setLayout(QtGui.QVBoxLayout()) self.area = dockarea.DockArea() self.layout().addWidget(self.area) self.dock_traj = dockarea.Dock("Trajectories Plot", size=(3, 12)) self.dock_info = dockarea.Dock("Info Panel", size=(1, 12)) self.dock_buttons = dockarea.Dock("Buttons", size=(3, 1), hideTitle=True) self.dock_status = dockarea.Dock("Status", size=(3, 0.5), hideTitle=True) self.area.addDock(self.dock_traj, 'left') self.area.addDock(self.dock_info, 'right', self.dock_traj) self.area.addDock(self.dock_buttons, 'bottom') self.area.addDock(self.dock_status, 'bottom') # Trajectory Plot Dock self.vb = DataSelectorViewBox() self.pw = pg.PlotWidget(viewBox=self.vb) self.vb.traj_widget = self self.dock_traj.addWidget(self.pw) self.dock_traj.layout.setContentsMargins(5, 5, 5, 5) self.dock_status.layout.setContentsMargins(5, 5, 5, 5) self.status = QtGui.QLabel(self) self.dock_status.addWidget(self.status) self.pw.scene().sigMouseMoved.connect(self.update_mouse_infos) self.setup_buttons() self.setup_menus()
def create_widgets(self, parent): h_layout = QHBoxLayout() self.viewer_cbox = self.builder.checkable_combobox(parent, [], self._set_cb_changed) h_layout.addWidget(self.viewer_cbox) h_layout.addItem(QSpacerItem(10, 10)) # add ecu selection self.label_top = QtGui.QLabel() self.label_top.setText("Message View: green: received messages red: send message") self.viewDock = dockarea.Dock('view', size=(1000, 600)) self.layout.addWidget(self.label_top) self.label_top.setFixedHeight(20) self.layout.addLayout(h_layout) self.layout.addItem(QSpacerItem(10, 10))
def drawgeom(self, cube_scale=0.01): xyz = self.data.tables['geometry'][['x', 'y', 'z']].iloc[self.rownr, :].values self.dock_geom.close() self.dock_geom = da.Dock('Geometry') self.dock_area.addDock(self.dock_geom, 'above') glview = gl.GLViewWidget() self.dock_geom.addWidget(glview) cube = _CUBE * cube_scale cube = np.tile(cube, (xyz.shape[0], 1, 1)) xyz = xyz.repeat(36, axis=0).reshape(cube.shape[0], 3, 3) m1 = gl.GLMeshItem(vertexes=(cube + xyz)) glview.addItem(m1)
def __init__(self, *args, **kwargs): # GUI items must be initialised before values are set in super() call self._gui_init() super().__init__(*args, **kwargs) # This has to go after the name has been initialised for the dock title self._dock = dock.Dock(self.name, autoOrientation=False) self._build_menu() self._gui_layout() self._connect_callbacks() self._enable_all(False) for label in [self._detuning, self._alias, self._frequency]: label.contextMenuEvent = lambda ev: self.menu.popup(QtGui.QCursor. pos()) label.mousePressEvent = self.clickSlot label.mouseReleaseEvent = lambda ev: None
def __init__(self, scene_proxy, parent=None): QtGui.QDialog.__init__(self, parent) cov_ui = path.join(path.dirname(path.realpath(__file__)), 'ui/covariance_matrix.ui') loadUi(cov_ui, baseinstance=self) self.closeButton.setIcon(self.style().standardPixmap( QtGui.QStyle.SP_DialogCloseButton)) self.weight_matrix = self.MatrixPlot(scene_proxy) self.dockarea = dockarea.DockArea(self) self.dockarea.addDock( dockarea.Dock('Covariance.weight_matrix_focal', widget=self.weight_matrix, size=(4, 4), autoOrientation=False,), position='left') self.horizontalLayoutPlot.addWidget(self.dockarea)
def __init__(self, model, parent=None): QtGui.QDialog.__init__(self, parent) loadUi(get_resource('covariance_matrix.ui'), baseinstance=self) self.closeButton.setIcon(self.style().standardPixmap( QtGui.QStyle.SP_DialogCloseButton)) self.weight_matrix = self.MatrixPlot(model) self.dockarea = dockarea.DockArea(self) self.dockarea.addDock(dockarea.Dock( 'Covariance.weight_matrix_focal', widget=self.weight_matrix, size=(4, 4), autoOrientation=False, ), position='left') self.horizontalLayoutPlot.addWidget(self.dockarea)
def __init__(self, internal_state, parent=None): super().__init__(parent) self.internal_state = internal_state DockLabel.updateStyle = dstyle.updateStylePatched self.plots = {key:PlotWidget(key, self.internal_state) for key in PLOT_VARIABLES.keys()} self.docks = {key:dock.Dock(key) for key in PLOT_VARIABLES.keys()} for key in PLOT_VARIABLES.keys(): self.docks[key].addWidget(self.plots[key]) # Layout of the plots self.addDock(self.docks['X']) self.addDock(self.docks['Z'],'above',self.docks['X']) prev_key = 'Z' for key in PLOT_VARIABLES: if key not in DEFAULT_PLOTS: self.addDock(self.docks[key],'above',self.docks[prev_key]) prev_key = key self.initialise_plot_area()
def setup_gui(self): """Creates a DockArea and fills it with the Slm.options given For each option, it extracts the correct ui from gui by name, loads it into a widget and adds it to the DockArea :return: """ uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_base.ui'), self) self.dockarea = dockarea.DockArea() self.splitter.insertWidget(0, self.dockarea) self.dockarea.show() # Absolutely no idea why this is needed self.all_widgets = dict() self.all_docks = [] for option in self.SLM.options: widget = getattr(gui, '%sUi' % option)(self) dock = dockarea.Dock(option) dock.addWidget(widget) self.dockarea.addDock(dock, 'bottom') self.all_widgets[option] = widget self.all_docks += [dock] self.make_pushButton.pressed.connect(self.make)
def __init__(self, model, parent=None): QtWidgets.QDialog.__init__(self, parent) self.model = model loadUi(get_resource("weight_matrix.ui"), baseinstance=self) self.closeButton.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_DialogCloseButton)) self.weight_matrix = self.MatrixPlot(model, self) self.dockarea = dockarea.DockArea(self) self.dockarea.addDock( dockarea.Dock( "Covariance.weight_matrix_focal", widget=self.weight_matrix, size=(4, 4), autoOrientation=False, ), position="left", ) self.horizontalLayoutPlot.addWidget(self.dockarea) self.model.sigCovarianceChanged.connect(self.updateMatrixButtons) self.model.sigCovarianceConfigChanged.connect(self.updateMatrixButtons)
def respfunc_viewer(path): app = QtGui.QApplication([]) pyqtgraph.setConfigOption("background", "w") pyqtgraph.setConfigOption("foreground", "k") win = QtGui.QMainWindow() win.setWindowTitle("MT response function data viewer") darea = dockarea.DockArea() w = QtGui.QWidget() win.setCentralWidget(darea) taglist = QtGui.QListWidget(win) taglist.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) taglist_dock = dockarea.Dock("Tags") taglist_dock.addWidget(taglist) darea.addDock(taglist_dock) sitelist = QtGui.QListWidget() sitelist.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) sitelist_dock = dockarea.Dock("Tree...") sitelist_dock.addWidget(sitelist) darea.addDock(sitelist_dock, "left", taglist_dock) resplot = pyqtgraph.PlotWidget() resplot_dock = dockarea.Dock("APPARENT RESISTIVITY") resplot_dock.addWidget(resplot) darea.addDock(resplot_dock, "left", sitelist_dock) phaseplot = pyqtgraph.PlotWidget() phaseplot_dock = dockarea.Dock("PHASE") phaseplot_dock.addWidget(phaseplot) darea.addDock(phaseplot_dock, "bottom", resplot_dock) default_pen = [[(255, 255, 255, 90)], dict(width=1)] select_pen = [["r"], dict(width=1.5)] skipflag_pen = [[(255, 255, 255, 30)], dict(width=0.5)] resplotitem = resplot.getPlotItem() phaseplotitem = phaseplot.getPlotItem() resplotitem.invertX(True) phaseplotitem.invertX(True) resplotitem.setLogMode(x=True, y=True) phaseplotitem.setLogMode(x=True, y=False) phaseplotitem.vb.setXLink(resplotitem.vb) resplotitem.setYRange(np.log10(0.1), np.log10(1000)) phaseplotitem.setYRange(0, 90) resvb = resplotitem.vb phasevb = phaseplotitem.vb data = utils.AttrDict() tagfns = glob.glob(op.join(path, "*-cal.json")) tag2fn = {} fn2tag = {} sites = set() tagfns.sort() data = utils.AttrDict() with open(op.join(path, "maskedfreqs.json"), mode="r") as f: maskedfreqs = utils.read_json(f) maskedlines = utils.AttrDict() datasymbols = utils.AttrDict() psymbols = utils.AttrDict({ "xy": dict(pen=None, symbol="o", symbolBrush="b"), "yx": dict(pen=None, symbol="s", symbolBrush="r") }) plines = utils.AttrDict({"xy": dict(pen="b"), "yx": dict(pen="r")}) plotpens = utils.AttrDict({ "xy": "b", "yx": "r", }) plotsymbols = utils.AttrDict({"xy": "o", "yx": "s"}) def plot(tag): if not hasattr(datasymbols[tag], "res_xy"): datasymbols[tag].res_xy = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].res_xy, **psymbols.xy) datasymbols[tag].res_yx = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].res_yx, **psymbols.yx) datasymbols[tag].phase_xy = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].phase_xy, **psymbols.xy) datasymbols[tag].phase_yx = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].phase_yx, **psymbols.yx) maskedlines[tag].res_xy = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].res_xy, **plines.xy) maskedlines[tag].res_yx = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].res_yx, **plines.yx) maskedlines[tag].phase_xy = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].phase_xy, **plines.xy) maskedlines[tag].phase_yx = pyqtgraph.PlotDataItem( data[tag].freqs, data[tag].phase_yx, **plines.yx) resplotitem.addItem(datasymbols[tag].res_xy) resplotitem.addItem(datasymbols[tag].res_yx) resplotitem.addItem(maskedlines[tag].res_xy) resplotitem.addItem(maskedlines[tag].res_yx) phaseplotitem.addItem(datasymbols[tag].phase_xy) phaseplotitem.addItem(datasymbols[tag].phase_yx) phaseplotitem.addItem(maskedlines[tag].phase_xy) phaseplotitem.addItem(maskedlines[tag].phase_yx) for i, freq in enumerate(data[tag].freqs): if maskedfreqs[tag]["masks"][i] == 0: data[tag].freqs[i] = float(maskedfreqs[tag]["freqs"][i]) else: data[tag].freqs[i] = np.nan maskedlines[tag].res_xy.setData(data[tag].freqs, data[tag].res_xy) maskedlines[tag].res_yx.setData(data[tag].freqs, data[tag].res_yx) maskedlines[tag].phase_xy.setData(data[tag].freqs, data[tag].phase_xy) maskedlines[tag].phase_yx.setData(data[tag].freqs, data[tag].phase_yx) progress = QtGui.QProgressDialog("Loading data...", "Abort", 0, len(tagfns), win) progress.setWindowModality(QtCore.Qt.WindowModal) for i, tagfn in enumerate(tagfns): progress.setValue(i) tag = op.basename(tagfn).replace("-cal.json", "") tag2fn[tag] = tagfn fn2tag[tagfn] = tag site = tag.split("-")[0] sites.add(site) data[tag] = utils.read_json(tagfn) if not tag in maskedfreqs: maskedfreqs[tag] = utils.AttrDict({ "freqs": data[tag].freqs.copy(), "masks": np.empty_like(data[tag].freqs) * 0 }) if not tag in maskedlines: maskedlines[tag] = utils.AttrDict() datasymbols[tag] = utils.AttrDict() plot(tag) if progress.wasCanceled(): break progress.setValue(len(tagfns)) resfreqselect = pyqtgraph.LinearRegionItem([0, -1]) phasefreqselect = pyqtgraph.LinearRegionItem([0, -1]) resplotitem.addItem(resfreqselect) phaseplotitem.addItem(phasefreqselect) def res_region_moved(): phasefreqselect.setRegion(resfreqselect.getRegion()) def phase_region_moved(): resfreqselect.setRegion(phasefreqselect.getRegion()) resfreqselect.sigRegionChanged.connect(res_region_moved) phasefreqselect.sigRegionChanged.connect(phase_region_moved) def populate_tag_list(filter_sites=None): if filter_sites: tags = [ t for t in tag2fn.keys() if t.split("-")[0] in filter_sites ] else: tags = sorted(tag2fn.keys()) tags.sort() taglist.clear() for tag in tags: # print tag tagitem = QtGui.QListWidgetItem(taglist) tagitem.setText(tag) plot_per_tag_list() print def plot_per_tag_list(): tags = [t.text() for t in taglist.selectedItems()] if not tags: tags = [ t.text() for t in [taglist.item(i) for i in xrange(taglist.count())] ] for plotitemtag, tagitems in datasymbols.items(): if plotitemtag in tags: for item_name, item in tagitems.items(): item.setSymbol(plotsymbols[item_name[-2:]]) # item.setPen(None)#plotpens[item_name[-2:]]) else: for item in tagitems.values(): item.setSymbol(None) # item.setPen(None) for plotitemtag, tagitems in maskedlines.items(): if plotitemtag in tags: for item_name, item in tagitems.items(): item.setPen(plotpens[item_name[-2:]]) else: for item in tagitems.values(): item.setPen(None) def selected_site_names(): return [s.text() for s in sitelist.selectedItems()] def pick_site(): newsites = selected_site_names() populate_tag_list(newsites) # plot_per_tag_list() def toggle_selected_mask(value): tags = [str(t.text()) for t in taglist.selectedItems()] log_mask_range = resfreqselect.getRegion() fmin = 10**log_mask_range[0] fmax = 10**log_mask_range[1] for tag in tags: for i, freq in enumerate(maskedfreqs[tag]["freqs"]): if freq >= fmin and freq <= fmax: maskedfreqs[tag]["masks"][i] = value plot(tag) print log_mask_range, tags, "\n" disable = QtGui.QPushButton("&Delete selected frequencies") enable = QtGui.QPushButton("&Enable selected frequencies") sitelist_dock.addWidget(disable) sitelist_dock.addWidget(enable) disable.clicked.connect(lambda: toggle_selected_mask(1)) enable.clicked.connect(lambda: toggle_selected_mask(0)) # def generate_key_press_event_handler(self, vb, event): # vb.keyPressEvent(self, event) # if event.key() is Qt.Key_X: # toggle_selected_mask(mode="xy") # elif event.key() is Qt.Key_Y: # toggle_selected_mask(mode="yx") # resplotitem.vb.keyPressEvent = lambda populate_tag_list() sites = sorted(list(sites)) for site in sites: siteitem = QtGui.QListWidgetItem(sitelist) siteitem.setText(site) sitelist.itemSelectionChanged.connect(pick_site) taglist.itemSelectionChanged.connect(plot_per_tag_list) def cleanup(): with open(op.join(path, "maskedfreqs.json"), mode="w") as f: utils.write_json(maskedfreqs, f) win.showMaximized() app.aboutToQuit.connect(cleanup) app.exec_()