Пример #1
0
void QwtPlotPropertySetDialog::updateAxisValue(QwtPlot::Axis axis)
{
    QwtInterval inv= m_plot->axisInterval(axis);
    //QwtScaleWidget* scaleWidget = m_plot->axisWidget(axis);
    QwtScaleDraw *scaleDraw = m_plot->axisScaleDraw(axis);
    QwtDateScaleDraw* dateScale = dynamic_cast<QwtDateScaleDraw*>(scaleDraw);
    m_property_id.setVarPropertyData(axisPropertyID(axis,4)
                                     ,QPointF(inv.minValue(),inv.maxValue()));
    m_property_id.setVarPropertyData(axisPropertyID(axis,1)
                                     ,m_plot->axisTitle(axis).text());
    ScaleDraw sd = NormalScale;
    sd = ((dateScale == nullptr) ? NormalScale : DateScale);
    m_property_id.setVarPropertyData(axisPropertyID(axis,2),int(sd));
    m_property_id.setVarPropertyData(axisPropertyID(axis,5),scaleDraw->labelRotation());
}
Пример #2
0
void QwtPlotPropertySetDialog::addAxisSet(QtProperty* parentGroup, ChartWave_qwt* plot,QwtPlot::Axis axis)
{
    m_enableSet = false;
    QtVariantProperty *pro = nullptr;
    //QwtScaleWidget* scaleWidget = plot->axisWidget(axis);
    QwtScaleDraw *scaleDraw = plot->axisScaleDraw(axis);
    QwtDateScaleDraw* dateScale = dynamic_cast<QwtDateScaleDraw*>(scaleDraw);
    //轴详细设置
    QtProperty *childGroup = m_property_id.addGroupInGroup(m_variantManager,parentGroup
                                                           ,QStringLiteral("%1轴设置").arg(axisString(axis))
                                                           ,axisPropertyID(axis,0));
    childGroup->setEnabled(plot->axisEnabled(axis));//在轴允许时才让设置

    QwtInterval inv= plot->axisInterval(axis);

    m_property_id.addVariantPropertyInGroup(m_variantManager,QVariant::PointF
                                            ,childGroup
                                            ,QStringLiteral("坐标范围")
                                            ,axisPropertyID(axis,4)
                                            ,QPointF(inv.minValue(),inv.maxValue()));

    m_property_id.addVariantPropertyInGroup(m_variantManager,QVariant::String
                                            ,childGroup,QStringLiteral("标题")
                                            ,axisPropertyID(axis,1)
                                            ,m_plot->axisTitle(axis).text());
    //
    m_property_id.addVariantPropertyInGroup(m_variantManager,QVariant::Double
                                            ,childGroup,QStringLiteral("刻度文字角度")
                                            ,axisPropertyID(axis,5)
                                            ,scaleDraw->labelRotation());
    pro = m_property_id.addVariantPropertyInGroup(m_variantManager,QtVariantPropertyManager::enumTypeId()
                                                  ,childGroup
                                                  ,QStringLiteral("%1轴样式").arg(axisString(axis))
                                                  ,axisPropertyID(axis,2)
                                                  ,0);
    pro->setAttribute(QLatin1String("enumNames"),QStringList()
                      <<QStringLiteral("正常坐标轴")
                      <<QStringLiteral("时间坐标轴")
                      );
    ScaleDraw sd = NormalScale;
    sd = ((dateScale == nullptr) ? NormalScale : DateScale);
    pro->setValue(int(sd));

    pro = m_property_id.addVariantPropertyInGroup(m_variantManager,QtVariantPropertyManager::enumTypeId()
                                                  ,childGroup
                                                  ,QStringLiteral("时间格式")
                                                  ,axisPropertyID(axis,3)
                                                  ,int(ChartWave_qwt::hh_mm_ss));
    pro->setAttribute(QLatin1String("enumNames"), QStringList()
                      <<QStringLiteral("h_m")
                      <<QStringLiteral("hh_mm")
                      <<QStringLiteral("h_m_s")
                      <<QStringLiteral("hh_mm_ss")
                      <<QStringLiteral("yyyy_M_d")
                      <<QStringLiteral("yyyy_M_d_h_m")
                      <<QStringLiteral("yyyy_M_d_h_m_s")
                      <<QStringLiteral("yyyy_MM_dd")
                      <<QStringLiteral("yyyy_MM_dd_hh_mm")
                      <<QStringLiteral("yyyy_MM_dd_hh_mm_ss")
                      );//在setAttribute过程中会触发onPropertyValueChanged,而onPropertyValueChanged的值是0,需要使用m_enableAxisEnableSet来抑制
    pro->setValue(int(ChartWave_qwt::hh_mm_ss));
    pro->setEnabled(sd == DateScale);

    m_enableSet = true;
}