コード例 #1
0
    def initScale(self, align):
        self.__data = QwtScaleWidget_PrivateData()
        self.__data.layoutFlags = 0
        if align == QwtScaleDraw.RightScale:
            self.__data.layoutFlags |= self.TitleInverted

        self.__data.borderDist = [0, 0]
        self.__data.minBorderDist = [0, 0]
        self.__data.margin = 4
        self.__data.titleOffset = 0
        self.__data.spacing = 2

        self.__data.scaleDraw = QwtScaleDraw()
        self.__data.scaleDraw.setAlignment(align)
        self.__data.scaleDraw.setLength(10)

        self.__data.scaleDraw.setScaleDiv(QwtLinearScaleEngine().divideScale(
            0.0, 100.0, 10, 5))

        self.__data.colorBar.colorMap = QwtLinearColorMap()
        self.__data.colorBar.isEnabled = False
        self.__data.colorBar.width = 10

        flags = Qt.AlignmentFlag(Qt.AlignHCenter | Qt.TextExpandTabs
                                 | Qt.TextWordWrap)
        self.__data.title.setRenderFlags(flags)
        self.__data.title.setFont(self.font())

        policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
        if self.__data.scaleDraw.orientation() == Qt.Vertical:
            policy.transpose()

        self.setSizePolicy(policy)

        self.setAttribute(Qt.WA_WState_OwnSizePolicy, False)
コード例 #2
0
    def initAxesData(self):
        self.__axisData = [AxisData() for axisId in range(self.axisCnt)]
        
        self.__axisData[self.yLeft].scaleWidget = \
            QwtScaleWidget(QwtScaleDraw.LeftScale, self)
        self.__axisData[self.yRight].scaleWidget = \
            QwtScaleWidget(QwtScaleDraw.RightScale, self)
        self.__axisData[self.xTop].scaleWidget = \
            QwtScaleWidget(QwtScaleDraw.TopScale, self)
        self.__axisData[self.xBottom].scaleWidget = \
            QwtScaleWidget(QwtScaleDraw.BottomScale, self)

        self.__axisData[self.yLeft
                        ].scaleWidget.setObjectName("QwtPlotAxisYLeft")
        self.__axisData[self.yRight
                        ].scaleWidget.setObjectName("QwtPlotAxisYRight")
        self.__axisData[self.xTop
                        ].scaleWidget.setObjectName("QwtPlotAxisXTop")
        self.__axisData[self.xBottom
                        ].scaleWidget.setObjectName("QwtPlotAxisXBottom")

        fscl = QFont(self.fontInfo().family(), 10)
        fttl = QFont(self.fontInfo().family(), 12, QFont.Bold)
        
        for axisId in range(self.axisCnt):
            d = self.__axisData[axisId]

            d.scaleEngine = QwtLinearScaleEngine()

            d.scaleWidget.setTransformation(d.scaleEngine.transformation())
            d.scaleWidget.setFont(fscl)
            d.scaleWidget.setMargin(2)

            text = d.scaleWidget.title()
            text.setFont(fttl)
            d.scaleWidget.setTitle(text)
            
            d.doAutoScale = True
            d.minValue = 0.0
            d.maxValue = 1000.0
            d.stepSize = 0.0            
            d.maxMinor = 5
            d.maxMajor = 8
            d.isValid = False
            
        self.__axisData[self.yLeft].isEnabled = True
        self.__axisData[self.yRight].isEnabled = False
        self.__axisData[self.xBottom].isEnabled = True
        self.__axisData[self.xTop].isEnabled = False