def addItem(self, item, name): """ Add a new entry to the legend. ============== ======================================================== **Arguments:** item A PlotDataItem from which the line and point style of the item will be determined or an instance of ItemSample (or a subclass), allowing the item display to be customized. title The title to display for this item. Simple HTML allowed. ============== ======================================================== """ label = LabelItem(name, color=self.opts['labelTextColor'], justify='left') if isinstance(item, MySampleItem): sample = item else: sample = MySampleItem(item) row = self.layout.rowCount() self.items.append((sample, label)) self.layout.addItem(sample, row, 0) self.layout.addItem(label, row, 1) height = max(sample.minimumHeight(), label.minimumHeight()) self.layout.setRowMaximumHeight(row, height) self.layout.setColumnSpacing(0, 10) self.updateSize()
def _set_pyqtgraph_title(layout): """ Private function to add a title to the first row of the window. Returns True if a Title is set. Else, returns False. """ title_set = False if 'title_size' in pytplot.tplot_opt_glob: size = pytplot.tplot_opt_glob['title_size'] if 'title_text' in pytplot.tplot_opt_glob: title_set = True if pytplot.tplot_opt_glob[ 'title_text'] != '' and pytplot.tplot_opt_glob[ 'black_background']: layout.addItem(LabelItem(pytplot.tplot_opt_glob['title_text'], size=size, color='w'), row=0, col=0) else: layout.addItem(LabelItem(pytplot.tplot_opt_glob['title_text'], size=size, color='k'), row=0, col=0) return title_set
def addItem(self, item, name): """ Add a new entry to the legend. ============== ======================================================== **Arguments:** item A PlotDataItem from which the line and point style of the item will be determined or an instance of ItemSample (or a subclass), allowing the item display to be customized. title The title to display for this item. Simple HTML allowed. ============== ======================================================== """ label = LabelItem(name, color=(255, 255, 255)) if isinstance(item, ItemSample): sample = item else: sample = ItemSample(item) row = self.layout.rowCount() self.items.append((sample, label)) self.layout.addItem(sample, row, 0) self.layout.addItem(label, row, 1) if self.size is not None: return height = 0 width = 0 for sample, label in self.items: height += max(sample.height(), label.height()) + 3 width = max(width, sample.width() + label.width()) self.setGeometry(0, 0, width + 25, height)
def addItem(self, name1, name2): label1 = LabelItem(name1) label2 = LabelItem(name2) row = self.layout.rowCount() self.items.append((label1, label2)) self.layout.addItem(label1, row, 0) self.layout.addItem(label2, row, 1) self.updateSize()
def addItem(self, item, name): legendLabelStyle = {'size': '14pt', 'bold': True} label = LabelItem(name) label.setText(name, **legendLabelStyle) if isinstance(item, MyItem): sample = item else: sample = MyItem(item) row = self.layout.rowCount() self.items.append((sample, label)) self.layout.addItem(sample, row, 0) self.layout.addItem(label, row, 1) self.updateSize()
def __init__(self, parent): super().__init__(parent) self.parent = parent self.projection, self.projection_vb, self.projection_hist = self.image_in_vb( "Projection") self.sinogram, self.sinogram_vb, self.sinogram_hist = self.image_in_vb( "Sinogram") self.recon, self.recon_vb, self.recon_hist = self.image_in_vb("Recon") self.slice_line = InfiniteLine(pos=1024, angle=0, bounds=[0, self.projection.width()], movable=True) self.projection_vb.addItem(self.slice_line) self.tilt_line = InfiniteLine(pos=1024, angle=90, pen=(255, 0, 0, 255), movable=True) image_layout = self.addLayout(colspan=4) image_layout.addItem(self.projection_vb, 0, 0) image_layout.addItem(self.projection_hist, 0, 1) image_layout.addItem(self.recon_vb, 0, 2, rowspan=3) image_layout.addItem(self.recon_hist, 0, 3, rowspan=3) projection_details = LabelItem("Value") image_layout.addItem(projection_details, 1, 0, 1, 2) image_layout.addItem(self.sinogram_vb, 2, 0) image_layout.addItem(self.sinogram_hist, 2, 1) sino_details = LabelItem("Value") image_layout.addItem(sino_details, 3, 0, 1, 2) recon_details = LabelItem("Value") image_layout.addItem(recon_details, 3, 2, 1, 2) msg_format = "Value: {:.6f}" self.display_formatted_detail = { self.projection: lambda val: projection_details.setText(msg_format.format(val)), self.sinogram: lambda val: sino_details.setText(msg_format.format(val)), self.recon: lambda val: recon_details.setText(msg_format.format(val)) } self.projection.hoverEvent = lambda ev: self.mouse_over( ev, self.projection) self.projection.mouseClickEvent = lambda ev: self.mouse_click( ev, self.slice_line) self.slice_line.sigPositionChangeFinished.connect( self.slice_line_moved) self.sinogram.hoverEvent = lambda ev: self.mouse_over( ev, self.sinogram) self.recon.hoverEvent = lambda ev: self.mouse_over(ev, self.recon)
def __init__(self, parent): super().__init__(parent) self.parent = parent self.projection, self.projection_vb, self.projection_hist = self.image_in_vb("Projection") self.sinogram, self.sinogram_vb, self.sinogram_hist = self.image_in_vb("Sinogram") self.recon, self.recon_vb, self.recon_hist = self.image_in_vb("Recon") self.slice_line = InfiniteLine(pos=1024, angle=0, bounds=[0, self.projection.width()], movable=True) self.projection_vb.addItem(self.slice_line) self.tilt_line = InfiniteLine(pos=1024, angle=90, pen=(255, 0, 0, 255), movable=True) image_layout = self.addLayout(colspan=4) image_layout.addItem(self.projection_vb, 0, 0) image_layout.addItem(self.projection_hist, 0, 1) image_layout.addItem(self.recon_vb, 0, 2, rowspan=3) image_layout.addItem(self.recon_hist, 0, 3, rowspan=3) projection_details = LabelItem("Value") image_layout.addItem(projection_details, 1, 0, 1, 2) image_layout.addItem(self.sinogram_vb, 2, 0) image_layout.addItem(self.sinogram_hist, 2, 1) sino_details = LabelItem("Value") image_layout.addItem(sino_details, 3, 0, 1, 2) recon_details = LabelItem("Value") image_layout.addItem(recon_details, 3, 2, 1, 2) msg_format = "Value: {:.6f}" self.display_formatted_detail = { self.projection: lambda val: projection_details.setText(msg_format.format(val)), self.sinogram: lambda val: sino_details.setText(msg_format.format(val)), self.recon: lambda val: recon_details.setText(msg_format.format(val)) } self.projection.hoverEvent = lambda ev: self.mouse_over(ev, self.projection) self.projection.mouseClickEvent = lambda ev: self.mouse_click(ev, self.slice_line) self.slice_line.sigPositionChangeFinished.connect(self.slice_line_moved) self.sinogram.hoverEvent = lambda ev: self.mouse_over(ev, self.sinogram) self.recon.hoverEvent = lambda ev: self.mouse_over(ev, self.recon) # Work around for https://github.com/mantidproject/mantidimaging/issues/565 for scene in [ self.projection.scene(), self.projection_hist.scene(), self.sinogram.scene(), self.sinogram_hist.scene(), self.recon.scene(), self.recon_hist.scene(), ]: scene.contextMenu = [item for item in scene.contextMenu if "export" not in item.text().lower()]
def __init__(self, *args, text="", offset=None): GraphicsWidget.__init__(self) GraphicsWidgetAnchor.__init__(self) self.setFlag(self.ItemIgnoresTransformations) self.layout = QtGui.QGraphicsGridLayout() self.setLayout(self.layout) self.item_anchor = (0, 0) self.object_anchor = (0, 0) if offset is None: self.offset = (0, 0) else: self.offset = offset self.label_item = LabelItem() self.label_item.setText(text) self.layout.addItem(self.label_item, 0, 0) self.pen = mkPen(255, 255, 255, 100) self.brush = mkBrush(100, 100, 100, 50) self.updateSize()
def _set_pyqtgraph_title(layout): """ Private function to add a title to the first row of the window. Returns True if a Title is set. Else, returns False. """ if 'title_size' in pytplot.tplot_opt_glob: size = pytplot.tplot_opt_glob['title_size'] if 'title_text' in pytplot.tplot_opt_glob: if pytplot.tplot_opt_glob['title_text'] != '': layout.addItem(LabelItem(pytplot.tplot_opt_glob['title_text'], size=size, color='k'), row=0, col=0) return True return False
def addItem(self, item, name): """ Add a new entry to the legend. ============== ======================================================== **Arguments:** item A PlotDataItem from which the line and point style of the item will be determined or an instance of ItemSample (or a subclass), allowing the item display to be customized. title The title to display for this item. Simple HTML allowed. ============== ======================================================== """ label = LabelItem(name, color=(0, 0, 0)) if isinstance(item, ItemSample): sample = item else: sample = ItemSample(item) row = self.layout.rowCount() self.items.append((sample, label)) self.layout.addItem(sample, row, 0) self.layout.addItem(label, row, 1) self.updateSize()
def __init__(self): super(NeuropilMaskFig, self).__init__() self.setWindowTitle('Neuropil Mask') self.setGeometry(QRect(686, 33, 296, 296)) label = LabelItem(justify='right') self.addItem(label)
def __init__(self, parent=None, image_channel=None, xaxis_channel=None, yaxis_channel=None, roioffsetx_channel=None, roioffsety_channel=None, roiwidth_channel=None, roiheight_channel=None, title='', background='w', image_width=0, image_height=0): """Initialize widget.""" GraphicsLayoutWidget.__init__(self, parent) PyDMWidget.__init__(self) self.thread = None self._imagechannel = None self._xaxischannel = None self._yaxischannel = None self._roioffsetxchannel = None self._roioffsetychannel = None self._roiwidthchannel = None self._roiheightchannel = None self._channels = 7 * [ None, ] self.image_waveform = np.zeros(0) self._image_width = image_width if not xaxis_channel else 0 self._image_height = image_height if not yaxis_channel else 0 self._roi_offsetx = 0 self._roi_offsety = 0 self._roi_width = 0 self._roi_height = 0 self._normalize_data = False self._auto_downsample = True self._last_yaxis_data = None self._last_xaxis_data = None self._auto_colorbar_lims = True self.format_tooltip = '{0:.4g}, {1:.4g}' # ViewBox and imageItem. self._view = ViewBox() self._image_item = ImageItem() self._view.addItem(self._image_item) # ROI self.ROICurve = PlotCurveItem([0, 0, 0, 0, 0], [0, 0, 0, 0, 0]) self.ROIColor = QColor('red') pen = mkPen() pen.setColor(QColor('transparent')) pen.setWidth(1) self.ROICurve.setPen(pen) self._view.addItem(self.ROICurve) # Axis. self.xaxis = AxisItem('bottom') self.xaxis.setPen(QColor(0, 0, 0)) if not xaxis_channel: self.xaxis.setVisible(False) self.yaxis = AxisItem('left') self.yaxis.setPen(QColor(0, 0, 0)) if not yaxis_channel: self.yaxis.setVisible(False) # Colorbar legend. self.colorbar = _GradientLegend() # Title. start_row = 0 if title: self.title = LabelItem(text=title, color='#000000') self.addItem(self.title, 0, 0, 1, 3) start_row = 1 # Set layout. self.addItem(self._view, start_row, 1) self.addItem(self.yaxis, start_row, 0) self.addItem(self.colorbar, start_row, 2) self.addItem(self.xaxis, start_row + 1, 1) self.setBackground(background) self.ci.layout.setColumnSpacing(0, 0) self.ci.layout.setRowSpacing(start_row, 0) # Set color map limits. self.cm_min = 0.0 self.cm_max = 255.0 # Set default reading order of numpy array data to Clike. self._reading_order = ReadingOrder.Clike # Make a right-click menu for changing the color map. self.cm_group = QActionGroup(self) self.cmap_for_action = {} for cm in self.color_maps: action = self.cm_group.addAction(cmap_names[cm]) action.setCheckable(True) self.cmap_for_action[action] = cm # Set the default colormap. self._cm_colors = None self.colorMap = PyDMColorMap.Inferno # Setup the redraw timer. self.needs_redraw = False self.redraw_timer = QTimer(self) self.redraw_timer.timeout.connect(self.redrawImage) self._redraw_rate = 30 self.maxRedrawRate = self._redraw_rate self.newImageSignal = self._image_item.sigImageChanged # Set Channels. self.imageChannel = image_channel self.xAxisChannel = xaxis_channel self.yAxisChannel = yaxis_channel self.ROIOffsetXChannel = roioffsetx_channel self.ROIOffsetYChannel = roioffsety_channel self.ROIWidthChannel = roiwidth_channel self.ROIHeightChannel = roiheight_channel
class DraggableTextItem(GraphicsWidget, GraphicsWidgetAnchor): def __init__(self, *args, text="", offset=None): GraphicsWidget.__init__(self) GraphicsWidgetAnchor.__init__(self) self.setFlag(self.ItemIgnoresTransformations) self.layout = QtGui.QGraphicsGridLayout() self.setLayout(self.layout) self.item_anchor = (0, 0) self.object_anchor = (0, 0) if offset is None: self.offset = (0, 0) else: self.offset = offset self.label_item = LabelItem() self.label_item.setText(text) self.layout.addItem(self.label_item, 0, 0) self.pen = mkPen(255, 255, 255, 100) self.brush = mkBrush(100, 100, 100, 50) self.updateSize() def setParentItem(self, parent): ret = GraphicsWidget.setParentItem(self, parent) if self.offset is not None: offset = Point(self.offset) anchorx = 1 if offset[0] <= 0 else 0 anchory = 1 if offset[1] <= 0 else 0 anchor = (anchorx, anchory) self.anchor(itemPos=anchor, parentPos=anchor, offset=offset) parent.items.append(self) return ret def paint(self, p, _options, _widget): p.setPen(self.pen) p.setBrush(self.brush) p.drawRect(self.boundingRect()) def anchor(self, itemPos, parentPos, offset=(0, 0)): super().anchor(itemPos, parentPos, offset) self.item_anchor = itemPos self.object_anchor = parentPos self.offset = offset def getOffset(self): return self.offset def setOffset(self, offs): if not isinstance(offs, tuple) or len(offs) != 2: raise ValueError("Must be a tuple (x, y)") self.anchor(self.item_anchor, self.object_anchor, offs) def updateSize(self): self.setGeometry(0, 0, self.label_item.width()+10, self.label_item.height()) def boundingRect(self): return QtCore.QRectF(0, 0, self.width(), self.height()) def hoverEvent(self, ev): ev.acceptDrags(QtCore.Qt.LeftButton) def mouseDragEvent(self, ev): if ev.button() == QtCore.Qt.LeftButton: dpos = ev.pos() - ev.lastPos() self.autoAnchor(self.pos() + dpos) def setText(self, text): self.label_item.setText(str(text)) self.updateSize() def getText(self): return self.label_item.text
def __init__(self, parent: 'CORInspectionDialogView'): super().__init__(parent) self.parent = parent self.less_img, self.less_img_vb, self.less_hist = self.image_in_vb( "less") self.current_img, self.current_img_vb, self.current_hist = self.image_in_vb( "current") self.more_img, self.more_img_vb, self.more_hist = self.image_in_vb( "more") def on_level_change(): levels: Tuple[float, float] = self.current_hist.getLevels() self.less_hist.setLevels(*levels) self.more_hist.setLevels(*levels) self.current_hist.sigLevelsChanged.connect(on_level_change) for view, view2 in zip([self.less_img_vb, self.current_img_vb], [self.current_img_vb, self.more_img_vb]): view.linkView(ViewBox.XAxis, view2) view.linkView(ViewBox.YAxis, view2) image_layout = self.addLayout(colspan=6) self.less_label = LabelItem("") image_layout.addItem(self.less_label, 0, 0, 1, 2) self.current_label = LabelItem("") image_layout.addItem(self.current_label, 0, 2, 1, 2) self.more_label = LabelItem("Value") image_layout.addItem(self.more_label, 0, 4, 1, 2) image_layout.addItem(self.less_img_vb, 1, 0) image_layout.addItem(self.less_hist, 1, 1) image_layout.addItem(self.current_img_vb, 1, 2) image_layout.addItem(self.current_hist, 1, 3) image_layout.addItem(self.more_img_vb, 1, 4) image_layout.addItem(self.more_hist, 1, 5) less_pixel = LabelItem("Value") image_layout.addItem(less_pixel, 2, 0, 1, 2) current_pixel = LabelItem("Value") image_layout.addItem(current_pixel, 2, 2, 1, 2) more_pixel = LabelItem("Value") image_layout.addItem(more_pixel, 2, 4, 1, 2) less_sumsq = LabelItem("Value") image_layout.addItem(less_sumsq, 3, 0, 1, 2) current_sumsq = LabelItem("Value") image_layout.addItem(current_sumsq, 3, 2, 1, 2) more_sumsq = LabelItem("Value") image_layout.addItem(more_sumsq, 3, 4, 1, 2) def update_text(val: float, sqsum: float, pixel_label: LabelItem, sqsum_label: LabelItem): pixel_label.setText(f"Value: {val:.6f}") sqsum_label.setText(f"Sum of SQ: {sqsum:.6f}") self.display_formatted_detail = { # '' if val < 0 else ' ' pads out the line self.less_img: lambda val, sumsq: update_text(val, sumsq, less_pixel, less_sumsq), self.current_img: lambda val, sumsq: update_text(val, sumsq, current_pixel, current_sumsq), self.more_img: lambda val, sumsq: update_text(val, sumsq, more_pixel, more_sumsq), } for img in self.less_img, self.current_img, self.more_img: img.hoverEvent = lambda ev: self.mouse_over(ev)
class CompareSlicesView(GraphicsLayoutWidget): less_img: ImageItem current_img: ImageItem more_img: ImageItem lessButton: QPushButton currentButton: QPushButton moreButton: QPushButton def __init__(self, parent: 'CORInspectionDialogView'): super().__init__(parent) self.parent = parent self.less_img, self.less_img_vb, self.less_hist = self.image_in_vb( "less") self.current_img, self.current_img_vb, self.current_hist = self.image_in_vb( "current") self.more_img, self.more_img_vb, self.more_hist = self.image_in_vb( "more") def on_level_change(): levels: Tuple[float, float] = self.current_hist.getLevels() self.less_hist.setLevels(*levels) self.more_hist.setLevels(*levels) self.current_hist.sigLevelsChanged.connect(on_level_change) for view, view2 in zip([self.less_img_vb, self.current_img_vb], [self.current_img_vb, self.more_img_vb]): view.linkView(ViewBox.XAxis, view2) view.linkView(ViewBox.YAxis, view2) image_layout = self.addLayout(colspan=6) self.less_label = LabelItem("") image_layout.addItem(self.less_label, 0, 0, 1, 2) self.current_label = LabelItem("") image_layout.addItem(self.current_label, 0, 2, 1, 2) self.more_label = LabelItem("Value") image_layout.addItem(self.more_label, 0, 4, 1, 2) image_layout.addItem(self.less_img_vb, 1, 0) image_layout.addItem(self.less_hist, 1, 1) image_layout.addItem(self.current_img_vb, 1, 2) image_layout.addItem(self.current_hist, 1, 3) image_layout.addItem(self.more_img_vb, 1, 4) image_layout.addItem(self.more_hist, 1, 5) less_pixel = LabelItem("Value") image_layout.addItem(less_pixel, 2, 0, 1, 2) current_pixel = LabelItem("Value") image_layout.addItem(current_pixel, 2, 2, 1, 2) more_pixel = LabelItem("Value") image_layout.addItem(more_pixel, 2, 4, 1, 2) less_sumsq = LabelItem("Value") image_layout.addItem(less_sumsq, 3, 0, 1, 2) current_sumsq = LabelItem("Value") image_layout.addItem(current_sumsq, 3, 2, 1, 2) more_sumsq = LabelItem("Value") image_layout.addItem(more_sumsq, 3, 4, 1, 2) def update_text(val: float, sqsum: float, pixel_label: LabelItem, sqsum_label: LabelItem): pixel_label.setText(f"Value: {val:.6f}") sqsum_label.setText(f"Sum of SQ: {sqsum:.6f}") self.display_formatted_detail = { # '' if val < 0 else ' ' pads out the line self.less_img: lambda val, sumsq: update_text(val, sumsq, less_pixel, less_sumsq), self.current_img: lambda val, sumsq: update_text(val, sumsq, current_pixel, current_sumsq), self.more_img: lambda val, sumsq: update_text(val, sumsq, more_pixel, more_sumsq), } for img in self.less_img, self.current_img, self.more_img: img.hoverEvent = lambda ev: self.mouse_over(ev) def mouse_over(self, ev): # Ignore events triggered by leaving window or right clicking if ev.exit: return pos = CloseEnoughPoint(ev.pos()) self._refresh_value_labels(pos) def _refresh_value_labels(self, pos: CloseEnoughPoint): diffs = [] for img in self.less_img, self.current_img, self.more_img: if img.image is not None and pos.x < img.image.shape[ 0] and pos.y < img.image.shape[1]: pixel_value = img.image[pos.y, pos.x] diff = np.sum(img.image**2) self.display_formatted_detail[img](pixel_value, diff) diffs.append(diff) return diffs @staticmethod def image_in_vb(name=None) -> Tuple[ImageItem, ViewBox, HistogramLUTItem]: im = ImageItem() vb = ViewBox(invertY=True, lockAspect=True, name=name) vb.addItem(im) hist = HistogramLUTItem(im) return im, vb, hist def set_image(self, image_type: ImageType, recon_data: np.ndarray, title: str): if image_type == ImageType.LESS: self.less_img.clear() self.less_img.setImage(recon_data) self.less_label.setText(title) elif image_type == ImageType.CURRENT: self.current_img.clear() self.current_img.setImage(recon_data, autoLevels=False) self.current_label.setText(title) elif image_type == ImageType.MORE: self.more_img.clear() self.more_img.setImage(recon_data) self.more_label.setText(title) self.less_hist.imageChanged(True, True) self.more_hist.imageChanged(True, True) self.current_hist.sigLevelsChanged.emit(self.current_hist) diffs = self._refresh_value_labels(CloseEnoughPoint([0, 0])) self.parent.mark_best_recon(diffs)
def init_plt( self ) : # Initialize the "GraphicsLayoutWidget" for this widget. This # will allow a grid of "GraphicsItem" objects, which will # include the plots themselves, the axes, and the axis labels. # Note. The "QGridLayout" object given to this widget as its # layout is essentially a dummy. I tried to just having # this widget be an extention of "GraphicsLayoutWidget" # (i.e., having it inheret that type), but I couldn't get # it to display anything at all. self.setLayout( QGridLayout( ) ) self.grd = GraphicsLayoutWidget( ) self.grd.setBackground( 'w' ) self.layout( ).addWidget( self.grd ) self.layout().setContentsMargins( 0, 0, 0, 0 ) # Initialize the text for the x- and y-axis labels. Then, # create the labels themselves and add them to the grid. self.txt_axs_x = 'Projected Proton Inflow Velocity [km/s]' self.txt_axs_y = 'Current [pA]' if ( self.core.app.res_lo ) : size = '8pt' else : size = '10pt' self.lab_axs_x = LabelItem( self.txt_axs_x, angle=0 , color='b', size=size ) self.lab_axs_y = LabelItem( self.txt_axs_y, angle=270, color='b', size=size ) self.grd.addItem( self.lab_axs_x, self.n_plt_y + 1, 2, 1, self.n_plt_x ) self.grd.addItem( self.lab_axs_y, 0, 0, self.n_plt_y, 1 ) # Initialize the arrays that will contain the individual axes, # plots, and plot elements (i.e., the histograms, fit curves, # labels, and selection points). self.plt = tile( None, [ self.n_plt_y, self.n_plt_x ] ) self.axs_x = tile( None, self.n_plt_x ) self.axs_y = tile( None, self.n_plt_y ) self.hst = tile( None, [ self.n_plt_y, self.n_plt_x ] ) self.lbl = tile( None, [ self.n_plt_y, self.n_plt_x ] ) self.crv = tile( None, [ self.n_plt_y, self.n_plt_x ] ) self.crv_ion = tile( None, [ self.n_plt_y, self.n_plt_x, self.n_ion ] ) self.pnt = tile( None, [ self.n_plt_y, self.n_plt_x, self.n_k ] ) # Initialize the scale-type for each axis, then generate the # (default) axis-limits and adjusted axis-limits. self.log_x = False self.log_y = True self.make_lim( ) # Create, store, and add to the grid the individual axes: first # the horizontal and then the vertical. for i in range( self.n_plt_x ) : self.axs_x[i] = AxisItem( 'bottom', maxTickLength=5 ) self.axs_x[i].setLogMode( self.log_x ) self.axs_x[i].setRange( self.alm_x[0], self.alm_x[1] ) self.axs_x[i].setTickFont( self.fnt ) if ( self.core.app.res_lo ) : self.axs_x[i].setHeight( 10 ) else : self.axs_x[i].setHeight( 20 ) self.grd.addItem( self.axs_x[i], self.n_plt_y, i + 2 ) for j in range( self.n_plt_y ) : self.axs_y[j] = AxisItem( 'left', maxTickLength=5 ) self.axs_y[j].setLogMode( self.log_y ) self.axs_y[j].setRange( self.alm_y[0], self.alm_y[1] ) self.axs_y[j].setTickFont( self.fnt ) if ( self.core.app.res_lo ) : self.axs_y[j].setWidth( 32 ) else : self.axs_y[j].setWidth( 40 ) self.grd.addItem( self.axs_y[j], j, 1 ) # Create, store, and add to the grid the individual plots. # Likewise, create, store, and add to each plot a label. for j in range( self.n_plt_y ) : for i in range( self.n_plt_x ) : # Compute the plot number of this plot. d = self.calc_ind_d( j, i ) # If creating this plot would exceed the # specified number of plots, don't create it. if ( d >= self.n_plt ) : continue # Create and store this plot, adjust its limits, # and add it to the grid. self.plt[j,i] = event_ViewBox( self, border=self.pen_plt, enableMouse=False, enableMenu=False ) self.plt[j,i].setRange( xRange=self.alm_x, yRange=self.alm_y, padding=0. ) self.grd.addItem( self.plt[j,i], j, i + 2 ) # Create and store an (empty) label and add it # to this plot. self.lbl[j,i] = TextItem( anchor=(1,0) ) self.lbl[j,i].setFont( self.fnt ) self.plt[j,i].addItem( self.lbl[j,i] )
def update_plot_title_text(title_item: pg.LabelItem, text: str): title_item.text = text title_item.setVisible(bool(text)) title_item.item.setPlainText(text) Updater.plot_title_resize(title_item)
def update_text(val: float, sqsum: float, pixel_label: LabelItem, sqsum_label: LabelItem): pixel_label.setText(f"Value: {val:.6f}") sqsum_label.setText(f"Sum of SQ: {sqsum:.6f}")