示例#1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateCurveAppearance()
{
    CVF_ASSERT(m_qwtPlotCurve);

    QColor curveColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte());    
    QwtSymbol* symbol = nullptr;

    if (m_pointSymbol() != RiuQwtSymbol::SYMBOL_NONE)
    {
        // QwtPlotCurve will take ownership of the symbol
        symbol = new RiuQwtSymbol(m_pointSymbol(), m_symbolLabel, m_symbolLabelPosition);
        symbol->setSize(m_symbolSize, m_symbolSize);
        symbol->setColor(curveColor);

        QColor symbolEdgeColor(m_symbolEdgeColor.value().rByte(), m_symbolEdgeColor.value().gByte(), m_symbolEdgeColor.value().bByte());

        symbol->setPen(symbolEdgeColor);
    }

    m_qwtPlotCurve->setAppearance(m_lineStyle(), m_curveInterpolation(), m_curveThickness(), curveColor);
    m_qwtPlotCurve->setSymbol(symbol);
    m_qwtPlotCurve->setSymbolSkipPixelDistance(m_symbolSkipPixelDistance());

    m_qwtPlotCurve->setErrorBarsColor(curveColor);

    // Make sure the legend lines are long enough to distinguish between line types.
    // Standard width in Qwt is 8 which is too short.
    // Use 10 and scale this by curve thickness + add space for displaying symbol.
    if (m_lineStyle() != RiuQwtPlotCurve::STYLE_NONE)
    {
        QSize legendIconSize = m_qwtPlotCurve->legendIconSize();

        int symbolWidth = 0;
        if (symbol)
        {
            symbolWidth = symbol->boundingRect().size().width() + 2;
        }

        int width = std::max(10 * m_curveThickness, (symbolWidth * 3) / 2);

        legendIconSize.setWidth(width);
        m_qwtPlotCurve->setLegendIconSize(legendIconSize);
    }
}