void Grid::load(const QStringList& grid)
{
    Plot *d_plot = (Plot *)plot();
    if (!d_plot)
        return;

    bool majorOnX = grid[1].toInt();
    bool minorOnX = grid[2].toInt();
    bool majorOnY = grid[3].toInt();
    bool minorOnY = grid[4].toInt();
    bool xZeroOn = false;
    bool yZeroOn = false;
    int xAxis = QwtPlot::xBottom;
    int yAxis = QwtPlot::yLeft;

    QPen majPenX, minPenX, majPenY, minPenY;
    if (grid.count() >= 21) { // since 0.9 final
        majPenX = QPen(QColor(grid[5]), grid[7].toDouble(), Graph::getPenStyle(grid[6].toInt()));
        minPenX = QPen(QColor(grid[8]), grid[10].toDouble(), Graph::getPenStyle(grid[9].toInt()));
        majPenY = QPen(QColor(grid[11]), grid[13].toDouble(), Graph::getPenStyle(grid[12].toInt()));
        minPenY = QPen(QColor(grid[14]), grid[16].toDouble(), Graph::getPenStyle(grid[15].toInt()));

        xZeroOn = grid[17].toInt();
        yZeroOn = grid[18].toInt();
        xAxis = grid[19].toInt();
        yAxis = grid[20].toInt();
        if (grid.count() >= 22)
            setRenderHint(QwtPlotItem::RenderAntialiased, grid[21].toInt());

    } else { // older versions of QtiPlot (<= 0.9rc3)
        majPenX = QPen(ColorBox::color(grid[5].toInt()), grid[7].toDouble(), Graph::getPenStyle(grid[6].toInt()));
        minPenX = QPen(ColorBox::color(grid[8].toInt()), grid[10].toDouble(), Graph::getPenStyle(grid[9].toInt()));
        majPenY = majPenX;
        minPenY = minPenX;

        xZeroOn = grid[11].toInt();
        yZeroOn = grid[12].toInt();

        if (grid.count() == 15) {
            xAxis = grid[13].toInt();
            yAxis = grid[14].toInt();
        }
    }

    setMajPenX(majPenX);
    setMinPenX(minPenX);
    setMajPenY(majPenY);
    setMinPenY(minPenY);

    enableX(majorOnX);
    enableXMin(minorOnX);
    enableY(majorOnY);
    enableYMin(minorOnY);

    setAxis(xAxis, yAxis);

    enableZeroLineX(xZeroOn);
    enableZeroLineY(yZeroOn);
}
Exemple #2
0
Grid::Grid()
    : QObject(), QwtPlotGrid(), d_maj_pen_y(QPen(Qt::blue, 0.5, Qt::SolidLine)),
      d_min_pen_y(QPen(Qt::gray, 0.4, Qt::DotLine)), mrkX(-1), mrkY(-1) {
  setMajPen(QPen(Qt::blue, 0.5, Qt::SolidLine));
  setMinPen(QPen(Qt::gray, 0.4, Qt::DotLine));
  enableX(false);
  enableY(false);
  setRenderHint(QwtPlotItem::RenderAntialiased, false);
}
Exemple #3
0
void Grid::copy(Grid *grid) {
  if (!grid)
    return;

  setMajPenX(grid->majPenX());
  setMinPenX(grid->minPenX());
  setMajPenY(grid->majPenY());
  setMinPenY(grid->minPenY());

  enableX(grid->xEnabled());
  enableXMin(grid->xMinEnabled());
  enableY(grid->yEnabled());
  enableYMin(grid->yMinEnabled());

  setAxis(grid->xAxis(), grid->yAxis());

  enableZeroLineX(grid->xZeroLineEnabled());
  enableZeroLineY(grid->yZeroLineEnabled());
  setRenderHint(QwtPlotItem::RenderAntialiased,
                grid->testRenderHint(QwtPlotItem::RenderAntialiased));
}