Exemplo n.º 1
0
const Style *DefaultStyleEngine::applyObjectStyle(const Style *baseStyle, StyleEngine::ElementType elementType,
                                                  const ObjectVisuals &objectVisuals,
                                                  const StyleEngine::Parameters *parameters)
{
    ObjectStyleKey key(elementType, objectVisuals);
    const Style *derivedStyle = m_objectStyleMap.value(key);
    if (!derivedStyle) {
        int lineWidth = 1;

        QColor fillColor = DefaultStyleEngine::fillColor(elementType, objectVisuals);
        QColor lineColor = DefaultStyleEngine::lineColor(elementType, objectVisuals);
        QColor textColor = DefaultStyleEngine::textColor(elementType, objectVisuals);

        QFont normalFont = baseStyle->normalFont();
        QFont headerFont = baseStyle->normalFont();
        if (objectVisuals.isEmphasized()) {
            lineWidth = 2;
            headerFont.setBold(true);
        }

        auto style = new Style(baseStyle->type());
        QPen linePen = baseStyle->linePen();
        linePen.setColor(lineColor);
        linePen.setWidth(lineWidth);
        style->setLinePen(linePen);
        style->setInnerLinePen(linePen);
        style->setOuterLinePen(linePen);
        style->setExtraLinePen(linePen);
        style->setTextBrush(QBrush(textColor));
        if (objectVisuals.visualSecondaryRole() == DObject::SecondaryRoleOutline) {
            style->setFillBrush(QBrush(Qt::white));
        } else {
            if (!parameters->suppressGradients()) {
                QLinearGradient fillGradient(0.0, 0.0, 0.0, 1.0);
                fillGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
                fillGradient.setColorAt(0.0, fillColor.lighter(110));
                fillGradient.setColorAt(1.0, fillColor.darker(110));
                style->setFillBrush(QBrush(fillGradient));
            } else {
                style->setFillBrush(QBrush(fillColor));
            }
        }
        if (objectVisuals.visualSecondaryRole() == DObject::SecondaryRoleOutline)
            style->setExtraFillBrush(QBrush(Qt::white));
        else
            style->setExtraFillBrush(QBrush(fillColor.darker(120)));
        style->setNormalFont(normalFont);
        style->setSmallFont(baseStyle->smallFont());
        style->setHeaderFont(headerFont);
        m_objectStyleMap.insert(key, style);
        derivedStyle = style;
    }

    return derivedStyle;
}
Exemplo n.º 2
0
void LinearGauge::loadSettings( QSettings& pSettings )
{
	// Scale
	Qt::Orientation orientation = (Qt::Orientation) pSettings.value("orientation", Qt::Vertical).toInt();
	QwtThermo::ScalePos scalePosition = (QwtThermo::ScalePos) pSettings.value("scalePosition", QwtThermo::LeftScale).toInt();
	setOrientation( orientation, scalePosition );
	setMinValue( pSettings.value("minValue", 0).toDouble() );
	setMaxValue( pSettings.value("maxValue", 10).toDouble() );

	// Ticks
	setScaleMaxMinor( pSettings.value("scaleMaxMinor", 4).toInt() );
	setScaleMaxMajor( pSettings.value("scaleMaxMajor", 12).toInt() );
	scaleDraw()->enableComponent( QwtAbstractScaleDraw::Labels, pSettings.value("labels", true).toBool() );
	setFont( QFont(	pSettings.value("font").toString(), pSettings.value("fontSize", 8).toDouble()) );

	// Pipe
	setValue( pSettings.value("value", 8).toDouble() );
	setPipeWidth( pSettings.value("pipeWidth", 10).toInt() );
	setFillBrush( QBrush( pSettings.value("pipeColor").toUInt() ) );

	// Alarm
	setAlarmLevel( pSettings.value("alarmLevel", 7).toDouble() );
	setAlarmBrush( QBrush( pSettings.value("alarmBrush").toUInt() ) );
	setAlarmEnabled( pSettings.value("alarmEnabled").toBool() );	

	// Color
	setTextColor( pSettings.value("textColor").toUInt() );
	setBackgroundColor( pSettings.value("backgroundColor").toUInt() );

	AbstractGauge::loadSettings( pSettings );
}
Exemplo n.º 3
0
LinearGauge::LinearGauge(QWidget *pParent)
	: QwtThermo(pParent)
{
	setOrientation( Qt::Vertical, QwtThermo::LeftScale );
	setRange( 0, 10 );
	setFillBrush( Qt::green );
	setAlarmBrush( Qt::red );
	setAlarmLevel( 7.0 );
	setAlarmEnabled( true );
	setValue( 8.0 );
}