Exemple #1
0
QString PlotCurve::saveCurveLayout()
{
  Plot *plot = static_cast<Plot *>(this->plot());
  Graph *g = static_cast<Graph *>(plot->parent());

  int index = g->curveIndex(static_cast<QwtPlotCurve *>(this));
  int style = g->curveType(index);
  QString s = "<Style>" + QString::number(style) + "</Style>\n";

  if (style == Graph::Spline)
    s += "<LineStyle>5</LineStyle>\n";
  else if (style == Graph::VerticalSteps)
    s += "<LineStyle>6</LineStyle>\n";
  else
    s += "<LineStyle>" + QString::number(this->style()) + "</LineStyle>\n";

  QPen pen = this->pen();
  if (pen.style() != Qt::NoPen){
    s += "<Pen>\n";
    s += "\t<Color>" + pen.color().name() + "</Color>\n";
    s += "\t<Style>" + QString::number(pen.style()-1) + "</Style>\n";
    s += "\t<Width>" + QString::number(pen.widthF()) + "</Width>\n";
    s += "</Pen>\n";
  }

  QBrush brush = this->brush();
  if (brush.style() != Qt::NoBrush){
    s += "<Brush>\n";
    s += "\t<Color>" + brush.color().name() + "</Color>\n";
    s += "\t<Style>" + QString::number(PatternBox::patternIndex(brush.style())) + "</Style>\n";
    s += "</Brush>\n";
  }

  const QwtSymbol symbol = this->symbol();
  if (symbol.style() != QwtSymbol::NoSymbol){
    s += "<Symbol>\n";
    s += "\t<Style>" + QString::number(SymbolBox::symbolIndex(symbol.style())) + "</Style>\n";
    s += "\t<Size>" + QString::number(symbol.size().width()) + "</Size>\n";

    s += "\t<SymbolPen>\n";
    s += "\t\t<Color>" + symbol.pen().color().name() + "</Color>\n";
    s += "\t\t<Width>" + QString::number(symbol.pen().widthF()) + "</Width>\n";
    s += "\t</SymbolPen>\n";

    brush = this->brush();
    if (brush.style() != Qt::NoBrush){
      s += "\t<SymbolBrush>\n";
      s += "\t\t<Color>" + symbol.brush().color().name() + "</Color>\n";
      s += "\t\t<Style>" + QString::number(PatternBox::patternIndex(symbol.brush().style())) + "</Style>\n";
      s += "\t</SymbolBrush>\n";
    }
    s += "</Symbol>\n";
  }
  s += "<xAxis>" + QString::number(xAxis()) + "</xAxis>\n";
  s += "<yAxis>" + QString::number(yAxis()) + "</yAxis>\n";
  s += "<Visible>" + QString::number(isVisible()) + "</Visible>\n";
  return s;
}
void QwtErrorPlotCurve::drawErrorBars(QPainter *painter,
		const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
{
    int sh = 0, sw =0;
    const QwtSymbol symbol = d_master_curve->symbol();
    if (symbol.style() != QwtSymbol::NoSymbol){
        sh = symbol.size().height();
        sw = symbol.size().width();
    }

	double d_xOffset = 0.0;
	double d_yOffset = 0.0;
	if (d_master_curve->type() == Graph::VerticalBars)
		d_xOffset = ((QwtBarCurve *)d_master_curve)->dataOffset();
	else if (d_master_curve->type() == Graph::HorizontalBars)
		d_yOffset = ((QwtBarCurve *)d_master_curve)->dataOffset();

	ScaleEngine *yScaleEngine = (ScaleEngine *)plot()->axisScaleEngine(yAxis());
	bool logYScale = (yScaleEngine->type() == QwtScaleTransformation::Log10) ? true : false;
	
	for (int i = from; i <= to; i++){
		const int xi = xMap.transform(x(i) + d_xOffset);
		const int yi = yMap.transform(y(i) + d_yOffset);

		if (type == Vertical){
			const int yh = yMap.transform(y(i) + err[i]);
			const int yl = yMap.transform(y(i) - err[i]);
			const int yhl = yi - sh/2;
			const int ylh = yi + sh/2;

			if (plus){
				QwtPainter::drawLine(painter, xi, yhl, xi, yh);
				QwtPainter::drawLine(painter, xi - cap/2, yh, xi + cap/2, yh);
			}
			if (minus && (!logYScale || (logYScale && yl > 0))){
				QwtPainter::drawLine(painter, xi, ylh, xi, yl);
				QwtPainter::drawLine(painter, xi - cap/2, yl, xi + cap/2, yl);
			}
			if (through)
				QwtPainter::drawLine(painter, xi, yhl, xi, ylh);
		} else if (type == Horizontal) {
			const int xp = xMap.transform(x(i) + err[i]);
			const int xm = xMap.transform(x(i) - err[i]);
  			const int xpm = xi + sw/2;
  	        const int xmp = xi - sw/2;

			if (plus){
				QwtPainter::drawLine(painter, xp, yi, xpm, yi);
				QwtPainter::drawLine(painter, xp, yi - cap/2, xp, yi + cap/2);
			}
			if (minus){
				QwtPainter::drawLine(painter, xm, yi, xmp, yi);
				QwtPainter::drawLine(painter, xm, yi - cap/2, xm, yi + cap/2);
			}
			if (through)
				QwtPainter::drawLine(painter, xmp, yi, xpm, yi);
		}
	}
}
void SAQwtPlotCurveItemSetWidget::onSymbolSetMenuHide()
{
    if(m_symbolSetWidget)
    {
        const QwtSymbol& s = m_symbolSetWidget->getSymbol();
        QwtSymbol* symbol = new QwtSymbol(s.style(),s.brush(),s.pen(),s.size());
        m_curveItem->setSymbol(symbol);
        m_symbolComboBox->setStyle(symbol->style());
    }
}
void PlotPropertiesGUI::consistCurveTab(const QString &name)
{
    QwtPlotCurve *plotCurve = internalCurves.value(name)->plotCurve;

    QwtSymbol symbol = plotCurve->symbol();
    ui->symbolSizeSpinBox->setValue( symbol.size().width() );
    ui->curveSymbolCombo->setCurrentIndex( (int)symbol.style() + 1); // Starts in -1
    // Fixes bug built when used 'plotCurve->symbol()'
    plotCurve->setSymbol(symbol);

    ui->curveWidthSpinBox->setValue( plotCurve->pen().width() );
    ui->curveStyleCombo->setCurrentIndex( (int)plotCurve->style() );
    ui->lineStylecombo->setCurrentIndex( (int)plotCurve->pen().style() );

    ui->curveColorButton->setStyleSheet(QString("  border-radius: 4px; "
            "border: 1px solid rgb(0, 0, 0); background-color: %1")
            .arg(plotCurve->pen().color().name()));
}
//! == operator
bool QwtSymbol::operator==(const QwtSymbol &other) const
{
    return brush() == other.brush() && pen() == other.pen()
            && style() == other.style() && size() == other.size();
}
Exemple #6
0
QString PlotCurve::saveCurveLayout()
{
    QString s = "<Style>" + QString::number(d_plot_style) + "</Style>\n";
    if (d_plot_style == Graph::Spline)
        s += "<LineStyle>5</LineStyle>\n";
    else if (d_plot_style == Graph::VerticalSteps)
        s += "<LineStyle>6</LineStyle>\n";
    else
        s += "<LineStyle>" + QString::number(this->style()) + "</LineStyle>\n";

    QPen pen = this->pen();
    if (pen.style() != Qt::NoPen) {
        s += "<Pen>\n";
        s += "\t<Color>" + pen.color().name() + "</Color>\n";
        if (pen.color().alpha() != 255)
            s += "\t<Alpha>" + QString::number(pen.color().alpha()) + "</Alpha>\n";
        s += "\t<Style>" + QString::number(pen.style()-1) + "</Style>\n";
        s += "\t<Width>" + QString::number(pen.widthF()) + "</Width>\n";
        s += "</Pen>\n";
    }

    QBrush brush = this->brush();
    if (brush.style() != Qt::NoBrush) {
        s += "<Brush>\n";
        s += "\t<Color>" + brush.color().name() + "</Color>\n";
        if (brush.color().alpha() != 255)
            s += "\t<Alpha>" + QString::number(brush.color().alpha()) + "</Alpha>\n";
        s += "\t<Style>" + QString::number(PatternBox::patternIndex(brush.style())) + "</Style>\n";
        s += "</Brush>\n";
    }

    const QwtSymbol symbol = this->symbol();
    if (symbol.style() != QwtSymbol::NoSymbol) {
        s += "<Symbol>\n";
        s += "\t<Style>" + QString::number(SymbolBox::symbolIndex(symbol.style())) + "</Style>\n";
        s += "\t<Size>" + QString::number(symbol.size().width()) + "</Size>\n";

        s += "\t<SymbolPen>\n";
        s += "\t\t<Color>" + symbol.pen().color().name() + "</Color>\n";
        if (symbol.pen().color().alpha() != 255)
            s += "\t<Alpha>" + QString::number(symbol.pen().color().alpha()) + "</Alpha>\n";
        s += "\t\t<Width>" + QString::number(symbol.pen().widthF()) + "</Width>\n";
        s += "\t</SymbolPen>\n";

        brush = this->brush();
        if (brush.style() != Qt::NoBrush) {
            s += "\t<SymbolBrush>\n";
            s += "\t\t<Color>" + symbol.brush().color().name() + "</Color>\n";
            if (symbol.brush().color().alpha() != 255)
                s += "\t<Alpha>" + QString::number(symbol.brush().color().alpha()) + "</Alpha>\n";
            s += "\t\t<Style>" + QString::number(PatternBox::patternIndex(symbol.brush().style())) + "</Style>\n";
            s += "\t</SymbolBrush>\n";
        }
        s += "</Symbol>\n";
    }
    s += "<xAxis>" + QString::number(xAxis()) + "</xAxis>\n";
    s += "<yAxis>" + QString::number(yAxis()) + "</yAxis>\n";
    s += "<CurveType>" + QString::number(curveType()) + "</CurveType>\n";
    s += "<Visible>" + QString::number(isVisible()) + "</Visible>\n";
    return s;
}
/*!
  \brief Copy constructor

  \param other Symbol
*/
QwtSymbol::QwtSymbol( const QwtSymbol &other )
{
    d_data = new PrivateData( other.style(), other.brush(),
                              other.pen(), other.size() );
};