def init(self, plot, rect): """Extract all layout relevant data from the plot components""" # legend if plot.legend(): self.legend.frameWidth = plot.legend().frameWidth() self.legend.hScrollExtent = plot.legend().scrollExtent(Qt.Horizontal) self.legend.vScrollExtent = plot.legend().scrollExtent(Qt.Vertical) hint = plot.legend().sizeHint() w = min([hint.width(), np.floor(rect.width())]) h = plot.legend().heightForWidth(w) if h <= 0: h = hint.height() if h > rect.height(): w += self.legend.hScrollExtent self.legend.hint = QSize(w, h) # title self.title.frameWidth = 0 self.title.text = QwtText() if plot.titleLabel(): label = plot.titleLabel() self.title.text = label.text() if not self.title.text.testPaintAttribute(QwtText.PaintUsingTextFont): self.title.text.setFont(label.font()) self.title.frameWidth = plot.titleLabel().frameWidth() # footer self.footer.frameWidth = 0 self.footer.text = QwtText() if plot.footerLabel(): label = plot.footerLabel() self.footer.text = label.text() if not self.footer.text.testPaintAttribute(QwtText.PaintUsingTextFont): self.footer.text.setFont(label.font()) self.footer.frameWidth = plot.footerLabel().frameWidth() # scales for axis in QwtPlot.validAxes: if plot.axisEnabled(axis): scaleWidget = plot.axisWidget(axis) self.scale[axis].isEnabled = True self.scale[axis].scaleWidget = scaleWidget self.scale[axis].scaleFont = scaleWidget.font() self.scale[axis].start = scaleWidget.startBorderDist() self.scale[axis].end = scaleWidget.endBorderDist() self.scale[axis].baseLineOffset = scaleWidget.margin() self.scale[axis].tickOffset = scaleWidget.margin() if scaleWidget.scaleDraw().hasComponent(QwtAbstractScaleDraw.Ticks): self.scale[axis].tickOffset += scaleWidget.scaleDraw().maxTickLength() self.scale[axis].dimWithoutTitle = scaleWidget.dimForLength( QWIDGETSIZE_MAX, self.scale[axis].scaleFont) if not scaleWidget.title().isEmpty(): self.scale[axis].dimWithoutTitle -= \ scaleWidget.titleHeightForWidth(QWIDGETSIZE_MAX) else: self.scale[axis].isEnabled = False self.scale[axis].start = 0 self.scale[axis].end = 0 self.scale[axis].baseLineOffset = 0 self.scale[axis].tickOffset = 0. self.scale[axis].dimWithoutTitle = 0 self.canvas.contentsMargins = plot.canvas().getContentsMargins()
def __init__(self, title=None): """title: QwtText""" if title is None: title = QwtText("") if hasattr(title, 'capitalize'): # avoids dealing with Py3K compat. title = QwtText(title) assert isinstance(title, QwtText) self.__data = QwtPlotItem_PrivateData() self.__data.title = title
def __init__(self, title=None): if title is None: title = QwtText("") if not isinstance(title, QwtText): title = QwtText(title) self.__data = None QwtPlotSeriesItem.__init__(self, title) QwtSeriesStore.__init__(self) self.init()
def tickLabel(self, font, value): lbl = self.__data.labelCache.get(value) if lbl is None: lbl = QwtText(self.label(value)) lbl.setRenderFlags(0) lbl.setLayoutAttribute(QwtText.MinimumLayout) lbl.textSize(font) self.__data.labelCache[value] = lbl return lbl
def __init__(self, title=None): if title is None: title = "" if not isinstance(title, QwtText): title = QwtText(title) QwtPlotItem.__init__(self, title) self.__data = QwtPlotMarker_PrivateData() self.setZ(30.)
def title(self): """ :return: Value of the TitleRole attribute """ titleValue = self.value(QwtLegendData.TitleRole) if isinstance(titleValue, QwtText): text = titleValue else: text = QwtText(titleValue) return text
def __init__(self): self.labelAlignment = Qt.AlignCenter self.labelOrientation = Qt.Horizontal self.spacing = 2 self.symbol = None self.style = QwtPlotMarker.NoLine self.xValue = 0. self.yValue = 0. self.label = QwtText() self.pen = QPen()
def __init__(self): self.scaleDraw = None self.borderDist = [None] * 2 self.minBorderDist = [None] * 2 self.scaleLength = None self.margin = None self.titleOffset = None self.spacing = None self.title = QwtText() self.layoutFlags = None self.colorBar = ColorBar()
def setLabel(self, label): """ Set the label :param label: Label text :type label: qwt.text.QwtText or str .. seealso:: :py:meth:`label()` """ if not isinstance(label, QwtText): label = QwtText(label) if label != self.__data.label: self.__data.label = label self.itemChanged()
def tickLabel(self, font, value): """ Convert a value into its representing label and cache it. The conversion between value and label is called very often in the layout and painting code. Unfortunately the calculation of the label sizes might be slow (really slow for rich text in Qt4), so it's necessary to cache the labels. :param QFont font: Font :param float value: Value :return: Tick label """ lbl = self.__data.labelCache.get(value) if lbl is None: lbl = QwtText(self.label(value)) lbl.setRenderFlags(0) lbl.setLayoutAttribute(QwtText.MinimumLayout) lbl.textSize(font) self.__data.labelCache[value] = lbl return lbl
def __init__(self): self.text = QwtText() self.frameWidth = None
def axisTitle(self, axisId): if self.axisValid(axisId): return self.axisWidget(axisId).title() else: return QwtText()
def setTitle(self, title): if not isinstance(title, QwtText): title = QwtText(title) if self.__data.title != title: self.__data.title = title self.legendChanged()
def __init__(self): QwtPlotItem.__init__(self, QwtText("Grid")) self.__data = QwtPlotGrid_PrivateData() self.setItemInterest(QwtPlotItem.ScaleInterest, True) self.setZ(10.)
def __init__(self, *args): if len(args) == 0: title, parent = "", None elif len(args) == 1: if isinstance(args[0], QWidget) or args[0] is None: title = "" parent, = args else: title, = args parent = None elif len(args) == 2: title, parent = args else: raise TypeError("%s() takes 0, 1 or 2 argument(s) (%s given)"\ % (self.__class__.__name__, len(args))) QwtPlotDict.__init__(self) QFrame.__init__(self, parent) self.__layout_state = None self.__data = QwtPlot_PrivateData() from qwt.plot_layout import QwtPlotLayout self.__data.layout = QwtPlotLayout() self.__data.autoReplot = False self.setAutoReplot(True) # self.setPlotLayout(self.__data.layout) # title self.__data.titleLabel = QwtTextLabel(self) self.__data.titleLabel.setObjectName("QwtPlotTitle") self.__data.titleLabel.setFont(QFont(self.fontInfo().family(), 14, QFont.Bold)) text = QwtText(title) text.setRenderFlags(Qt.AlignCenter|Qt.TextWordWrap) self.__data.titleLabel.setText(text) # footer self.__data.footerLabel = QwtTextLabel(self) self.__data.footerLabel.setObjectName("QwtPlotFooter") footer = QwtText() footer.setRenderFlags(Qt.AlignCenter|Qt.TextWordWrap) self.__data.footerLabel.setText(footer) # legend self.__data.legend = None # axis self.__axisData = [] self.initAxesData() # canvas self.__data.canvas = QwtPlotCanvas(self) self.__data.canvas.setObjectName("QwtPlotCanvas") self.__data.canvas.installEventFilter(self) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.resize(200, 200) focusChain = [self, self.__data.titleLabel, self.axisWidget(self.xTop), self.axisWidget(self.yLeft), self.__data.canvas, self.axisWidget(self.yRight), self.axisWidget(self.xBottom), self.__data.footerLabel] for idx in range(len(focusChain)-1): qwtSetTabOrder(focusChain[idx], focusChain[idx+1], False) qwtEnableLegendItems(self, True)
def __init__(self, title): if not isinstance(title, QwtText): title = QwtText(title) QwtPlotItem.__init__(self, title) self.__data = QwtPlotSeriesItem_PrivateData() self.setItemInterest(QwtPlotItem.ScaleInterest, True)
def __init__(self, title): QwtAbstractSeriesStore.__init__(self) if not isinstance(title, QwtText): title = QwtText(title) QwtPlotItem.__init__(self, title) self.__data = QwtPlotSeriesItem_PrivateData()