Ejemplo n.º 1
0
void tst_QBrush::gradientStops()
{
    QLinearGradient gradient;
    gradient.setColorAt(0, Qt::red);
    gradient.setColorAt(1, Qt::blue);

    QCOMPARE(gradient.stops().size(), 2);

    QCOMPARE(gradient.stops().at(0), QGradientStop(0, QColor(Qt::red)));
    QCOMPARE(gradient.stops().at(1), QGradientStop(1, QColor(Qt::blue)));

    gradient.setColorAt(0, Qt::blue);
    gradient.setColorAt(1, Qt::red);

    QCOMPARE(gradient.stops().size(), 2);

    QCOMPARE(gradient.stops().at(0), QGradientStop(0, QColor(Qt::blue)));
    QCOMPARE(gradient.stops().at(1), QGradientStop(1, QColor(Qt::red)));

    gradient.setColorAt(0.5, Qt::green);

    QCOMPARE(gradient.stops().size(), 3);
    QCOMPARE(gradient.stops().at(1), QGradientStop(0.5, QColor(Qt::green)));

    // A hack in parseStopNode() in qsvghandler.cpp depends on inserting stops at NaN.
    gradient.setStops(QGradientStops() << QGradientStop(qQNaN(), QColor()));
    QCOMPARE(gradient.stops().size(), 1);
    QVERIFY(qIsNaN(gradient.stops().at(0).first));
    QCOMPARE(gradient.stops().at(0).second, QColor());
}
Ejemplo n.º 2
0
void tMercuryControlSeparator::UpdateGradient()
{
    tMercuryStyle* style = GetMercuryStyle();
    if( style == 0 || !GetVisibility() )
    {
        return;
    }

    m_Gradient.setStops(QGradientStops());

    QColor color = style->GetColor(tMercuryStyle::eColorRoleSelectionHighlight);
    color.setAlphaF(m_Alpha);

    m_Gradient.setStart(0, 0);
    if( m_IsVertical )
    {
        m_Gradient.setFinalStop(0, height());
    }
    else
    {
        m_Gradient.setFinalStop(width(), 0);
    }

    m_Gradient.setColorAt(0.5, color);
    color.setAlpha(0);
    m_Gradient.setColorAt(0, color);
    m_Gradient.setColorAt(1, color);
}
void VesselConnectionView::paint(QPainter *painter,
                                 const QStyleOptionGraphicsItem *option,
                                 QWidget *widget)
{
	Q_UNUSED(widget);

	double lod = option->levelOfDetailFromTransform(painter->transform());
	if (lod < minLOD())
		return;

	QColor fill_color = baseColor(option);
	QColor dark_fill_color = fill_color.dark();

	QGradientStops stops;
	stops << QGradientStop(0.038, dark_fill_color)
	      << QGradientStop(0.128, fill_color)
	      << QGradientStop(0.174, fill_color)
	      << QGradientStop(0.174+0.125-0.03, dark_fill_color)
	      << QGradientStop(0.45, fill_color)
	      << QGradientStop(0.55, fill_color)

	      << QGradientStop(1-(0.174+0.125-0.03), dark_fill_color)
	      << QGradientStop(1-0.174, fill_color)
	      << QGradientStop(1-0.128, fill_color)
	      << QGradientStop(1-0.038, dark_fill_color);
	const QRectF &br = boundingRect();
	QLinearGradient gradient(QLineF(br.topLeft(), br.topRight()).pointAt(0.5),
	                         QLineF(br.bottomRight(), br.bottomLeft()).pointAt(0.5));
	gradient.setStops(stops);

	QLinearGradient gradient2(QLineF(br.topLeft(), br.bottomLeft()).pointAt(0.5),
	                          QLineF(br.topRight(), br.bottomRight()).pointAt(0.5));
	QColor transparent_color(fill_color), semi_transparent_color(fill_color);
	transparent_color.setAlpha(0);
	semi_transparent_color.setAlpha(200);

	gradient2.setStops(QGradientStops()
	                   << QGradientStop(0, transparent_color)
	                   << QGradientStop(0.45, semi_transparent_color)
	                   << QGradientStop(0.55, semi_transparent_color)
	                   << QGradientStop(1, transparent_color));

	painter->setPen(QPen(penColor(option), 32/2, Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin));
	painter->drawPath(path);

	if (isClearBg()) {
		painter->fillPath(fill, Qt::white);
	}
	else {
		painter->fillPath(fill, gradient);
		painter->fillPath(fill, gradient2);
	}
}
Ejemplo n.º 4
0
QBrush QSvgGradientStyle::brush(QPainter *, QSvgExtraStates &)
{
    if (!m_link.isEmpty()) {
        resolveStops();
    }

    // If the gradient is marked as empty, insert transparent black
    if (!m_gradientStopsSet) {
        m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0)));
        m_gradientStopsSet = true;
    }

    QBrush b(*m_gradient);

    if (!m_matrix.isIdentity())
        b.setMatrix(m_matrix);

    return b;
}
Ejemplo n.º 5
0
void tMercuryControlTank::UpdateGradients()
{
    if( m_InnerCount > 0 )
    {
        return;
    }
    tMercuryStyle* style = GetMercuryStyle();
    if( style == 0 )
    {
        return;
    }

    float valueHeight = float(m_InnerRect.height()) * m_Value;
    m_InnerGradient.setStops(QGradientStops());
    m_InnerGradient.setStart(0, m_InnerRect.bottom() - valueHeight);
    m_InnerGradient.setFinalStop(0, m_InnerRect.bottom());

    m_InnerGradient.setColorAt(0, style->GetColor(tMercuryStyle::eColorRoleGaugeMax));
    m_InnerGradient.setColorAt(1, style->GetColor(tMercuryStyle::eColorRoleGaugeMin));
}
Ejemplo n.º 6
0
void
SplineEditorWidget::setTransferFunction(SplineTransferFunction *stf)
{
  if (stf == NULL)
    {
      m_vol1->setText("V1");
      m_vol2->setText("V2");
      m_vol3->setText("V3");
      m_vol4->setText("V4");


      m_vol1->hide();
      m_vol2->hide();
      m_vol3->hide();
      m_vol4->hide();

      if (Global::volumeType() == Global::DoubleVolume)
	{
	  m_vol1->show();
	  m_vol1->setChecked(true);
	  m_vol2->show();
	  m_vol3->hide();
	  m_vol4->hide();
	}
      else if (Global::volumeType() == Global::TripleVolume)
	{
	  m_vol1->show();
	  m_vol1->setChecked(true);
	  m_vol2->show();
	  m_vol3->show();
	  m_vol4->hide();
	}
      else if (Global::volumeType() == Global::QuadVolume)
	{
	  m_vol1->show();
	  m_vol1->setChecked(true);
	  m_vol2->show();
	  m_vol3->show();
	  m_vol4->show();
	}
      else if (Global::volumeType() == Global::RGBVolume ||
	       Global::volumeType() == Global::RGBAVolume)
	{
	  m_vol1->setText("R-G");
	  m_vol2->setText("G-B");
	  m_vol3->setText("B-R");

	  m_vol1->show();
	  m_vol1->setChecked(true);
	  m_vol2->show();
	  m_vol3->show();
	  m_vol4->hide();

	  if (Global::volumeType() == Global::RGBAVolume)
	    {
	     m_vol4->setText("A-max(RGB)");
	     m_vol4->show();
	    }
	  else
	    m_vol4->hide();
	}
    }

  if (stf != NULL)
    {
      int top, bot;
      stf->gradLimits(bot, top);
      m_gbotSlider->setValue(bot);
      m_gtopSlider->setValue(top);

      float topop, botop;
      stf->opMod(botop, topop);
      m_gbotValue->setText(QString("%1").arg(botop));
      m_gtopValue->setText(QString("%1").arg(topop));
    }
  else
    {
      m_gbotSlider->setValue(0);
      m_gtopSlider->setValue(255);
      m_gbotValue->setText("1.0");
      m_gtopValue->setText("1.0");
    }

  m_splineEditor->setTransferFunction(stf);

  if (Global::pvlVoxelType() > 0)
    {
      if (stf != NULL)
	{
	  float tmin, tmax;
	  tmin = (stf->leftNormalAt(0)).x();
	  tmax = (stf->rightNormalAt(0)).x();
	  m_16bitEditor->setMapping(tmin, tmax);
	  m_16bitEditor->setGradientStops(stf->gradientStops());
	}
      else
	m_16bitEditor->setGradientStops(QGradientStops());
    }
}
Ejemplo n.º 7
0
QGradientStops Fort14::GetGradientOutlineColors()
{
	if (gradientOutline)
		return gradientOutline->GetGradientStops();
	return QGradientStops();
}
Ejemplo n.º 8
0
QGradientStops Fort14::GetGradientFillColors()
{
	if (gradientFill)
		return gradientFill->GetGradientStops();
	return QGradientStops();
}
Ejemplo n.º 9
0
QGradientStops Fort14::GetGradientBoundaryColors()
{
	if (gradientBoundary)
		return gradientBoundary->GetGradientStops();
	return QGradientStops();
}