Exemplo n.º 1
0
void Plot2DProfile::drawSymbol( QPainter* painter, const QwtScaleMap & xMap,
        const QwtScaleMap & yMap, const QRectF & canvasRect, int from, int to ) const{
    QPen curvePen( m_defaultColor );
    QBrush brush( m_defaultColor );
    QSize symbolSize( 10, 10 );
    QwtSymbol symbol ( QwtSymbol::Diamond, brush, curvePen, symbolSize );
    drawSymbols( painter, symbol, xMap, yMap, canvasRect, from, to );
}
Exemplo n.º 2
0
void Plot2DProfile::drawSteps (QPainter *painter, const QwtScaleMap &xMap,
        const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const {
    QPen curvePen( m_defaultColor );
    curvePen.setStyle( m_penStyle );
    painter->setPen( curvePen );
    if ( from != to ){
        QwtPlotCurve::drawSteps( painter, xMap, yMap, canvasRect, from, to );
    }
    else {
        drawSymbol( painter, xMap, yMap, canvasRect, from, to );
    }
}
void StochasticProcessWidget::updateColors() {
	int distCount = process->getNumStates();
	QColor weakestDistColor;
	QColor weakDistColor;
	QColor avgDistColor;
	QColor strongDistColor;

	for (int i = 0; i < distCount; i++) {
		int hueValue = (int)round(255.0
				/ ((double)distCount / (double)i));
		weakDistColor.setHsv(hueValue, 40, 245);
		weakestDistColor.setHsv(hueValue, 15, 245);
		avgDistColor.setHsv(hueValue, 100, 255);
		strongDistColor.setHsv(hueValue, 150, 255);

		QPen curvePen(QBrush(strongDistColor), 3.0,
				Qt::SolidLine);
		infCurves[i]->setPen(curvePen);
		supCurves[i]->setPen(curvePen);

		QPen avgPen(QBrush(avgDistColor), 3.0,
				Qt::DashLine);
		avgMarkers[i]->setLinePen(avgPen);

		QPen stdDevPen(QBrush(avgDistColor), 3.0,
				Qt::DotLine);
		stdDevMarkers[i].first->setLinePen(stdDevPen);
		stdDevMarkers[i].second->setLinePen(stdDevPen);

		for (int j = 0; j <= 4; j++) {
			distGraphTable->item(j, i)->setBackgroundColor(weakDistColor);
		}

		for (int j = 0; j < distTable->rowCount(); j++) {
			QTableWidgetItem *item = distTable->item(j,
					i);
			if (item) {
				if (item->text() == "0\n0") {
					item->setBackgroundColor(weakestDistColor);
				} else {
					item->setBackgroundColor(weakDistColor);
				}
			}
		}
	}

	distGraph->replot();
}
Exemplo n.º 4
0
void Plot::addSignal(SignalData* signalData, QColor color)
{
  QwtPlotCurve* d_curve = new QwtPlotCurve();
  d_curve->setStyle(DEFAULT_CURVE_STYLE);

  QPen curvePen(color);
  curvePen.setWidth(0);

  d_curve->setPen(curvePen);

#if 1
  d_curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
#endif
#if 1
  d_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, false);
#endif
  d_curve->setData(new CurveData(signalData));
  d_curve->attach(this);

  mSignals[signalData] = d_curve;
}
Exemplo n.º 5
0
void LinePlot::linePlotData(LinePlotData::Ptr data,  const std::string& name, QColor color, double offset )
{
  if (!data) return;


  // set based on data - record overall min and max
  if ( (data->minX() < m_xAxisMin) || (data->maxX() > m_xAxisMax) )
  {
    if  (data->minX() < m_xAxisMin) m_xAxisMin = data->minX();
    if  (data->maxX() > m_xAxisMax) m_xAxisMax = data->maxX();
  }
  if (numberOfCurves() == 0)
  {
    m_lineThickness = 10;
  }


  /// todo - curve collection - shared pointers
  QwtPlotCurve * curve = new QwtPlotCurve(toQString(name));
  if (color == Qt::color0) 
  { // generate new color from color map
    color = curveColor(m_lastColor);
    m_lastColor = color;
  }
  curve->setPen(curvePen(color));
  curve->attach(m_qwtPlot);
  curve->setData(*data);

  // check for number of different units (std::string  based)
  QString curveUnits = toQString(data->units());
  if (m_leftAxisUnits == "NONE SPECIFIED")
  {
    m_leftAxisUnits = curveUnits;
    this->leftAxisTitleFromUnits(toString(m_leftAxisUnits));
    curve->setYAxis(QwtPlot::yLeft);
    m_qwtPlot->enableAxis(QwtPlot::yRight, false);
  }
  else if (m_leftAxisUnits.toUpper() == curveUnits.toUpper())
  {
    curve->setYAxis(QwtPlot::yLeft);
    m_qwtPlot->enableAxis(QwtPlot::yRight, false);
  }
  else if (m_rightAxisUnits == "NONE SPECIFIED")
  {
    m_rightAxisUnits = curveUnits;
    this->rightAxisTitleFromUnits(toString(m_rightAxisUnits));
    curve->setYAxis(QwtPlot::yRight);
    m_qwtPlot->enableAxis(QwtPlot::yRight, true);
  }
  else if (m_rightAxisUnits.toUpper() == curveUnits.toUpper())
  {
    curve->setYAxis(QwtPlot::yRight);
    m_qwtPlot->enableAxis(QwtPlot::yRight, true);
  }
  else // more than 2 units - scale all curves
  {
    scaleCurves(curve);
    m_qwtPlot->enableAxis(QwtPlot::yRight, false);
    this->leftAxisTitle("Scaled");
  }



/// update legend and replot
  showCurve(curve, true);

//  initZoomer();

}
Exemplo n.º 6
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() != SYMBOL_NONE)
    {
        QwtSymbol::Style style = QwtSymbol::NoSymbol;

        switch (m_pointSymbol())
        {
            case SYMBOL_ELLIPSE:
            style = QwtSymbol::Ellipse;
            break;
            case SYMBOL_RECT:
            style = QwtSymbol::Rect;
            break;
            case SYMBOL_DIAMOND:
            style = QwtSymbol::Diamond;
            break;
            case SYMBOL_TRIANGLE:
            style = QwtSymbol::Triangle;
            break;
            case SYMBOL_CROSS:
            style = QwtSymbol::Cross;
            break;
            case SYMBOL_XCROSS:
            style = QwtSymbol::XCross;
            break;

            default:
            break;
        }

        // QwtPlotCurve will take ownership of the symbol
        symbol = new QwtSymbol(style);

        symbol->setSize(6, 6);
        symbol->setColor(curveColor);
    }

    QwtPlotCurve::CurveStyle curveStyle = QwtPlotCurve::NoCurve;
    Qt::PenStyle penStyle = Qt::SolidLine;

    if (m_lineStyle() != STYLE_NONE)
    {
        switch (m_curveInterpolation())
        {
        case INTERPOLATION_STEP_LEFT:
            curveStyle = QwtPlotCurve::Steps;
            m_qwtPlotCurve->setCurveAttribute(QwtPlotCurve::Inverted, false);
            break;
        case INTERPOLATION_POINT_TO_POINT: // Fall through
        default:
            curveStyle = QwtPlotCurve::Lines;
            break;
        }

        switch (m_lineStyle())
        {
            case STYLE_SOLID:
            penStyle = Qt::SolidLine;
            break;
            case STYLE_DASH:
            penStyle = Qt::DashLine;
            break;
            case STYLE_DOT:
            penStyle = Qt::DotLine;
            break;
            case STYLE_DASH_DOT:
            penStyle = Qt::DashDotLine;
            break;

            default:
            break;
        }
    }
    QPen curvePen(curveColor);
    curvePen.setWidth(m_curveThickness);
    curvePen.setStyle(penStyle);

    m_qwtPlotCurve->setPen(curvePen);
    m_qwtPlotCurve->setStyle(curveStyle);
    m_qwtPlotCurve->setSymbol(symbol);
    m_qwtPlotCurve->setSymbolSkipPixelDistance(m_symbolSkipPixelDistance());
}