Exemplo n.º 1
0
void Checker::prepareForDisplay (const QList<Point> &points,
                                 int pointRadius,
                                 const DocumentModelAxesChecker &modelAxesChecker,
                                 const DocumentModelCoords &modelCoords,
                                 const Transformation &transformation)
{
  LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay "
                              << " transformation=" << transformation;

  ENGAUGE_ASSERT (points.count () == NUM_AXES_POINTS);

  // Remove previous lines
  deleteSide (m_sideLeft);
  deleteSide (m_sideTop);
  deleteSide (m_sideRight);
  deleteSide (m_sideBottom);

  // Get the min and max of x and y
  double xFrom, xTo, yFrom, yTo;
  int i;
  for (i = 0; i < NUM_AXES_POINTS; i++) {
    if (i == 0) {
      xFrom = points.at(i).posGraph().x();
      xTo   = points.at(i).posGraph().x();
      yFrom = points.at(i).posGraph().y();
      yTo   = points.at(i).posGraph().y();
    }
    xFrom = qMin (xFrom, points.at(i).posGraph().x());
    xTo   = qMax (xTo  , points.at(i).posGraph().x());
    yFrom = qMin (yFrom, points.at(i).posGraph().y());
    yTo   = qMax (yTo  , points.at(i).posGraph().y());
  }

  // Min and max of angles needs special processing since periodicity introduces some ambiguity. This is a noop for rectangular coordinates
  // and for polar coordinates when periodicity is not an issue
  adjustPolarAngleRanges (modelCoords,
                          transformation,
                          points,
                          xFrom,
                          xTo,
                          yFrom);

  // Draw the bounding box as four sides. In polar plots the bottom side is zero-length, with pie shape resulting
  createSide (pointRadius, points, modelCoords, xFrom, yFrom, xFrom, yTo  , transformation, m_sideLeft);
  createSide (pointRadius, points, modelCoords, xFrom, yTo  , xTo  , yTo  , transformation, m_sideTop);
  createSide (pointRadius, points, modelCoords, xTo  , yTo  , xTo  , yFrom, transformation, m_sideRight);
  createSide (pointRadius, points, modelCoords, xTo  , yFrom, xFrom, yFrom, transformation, m_sideBottom);

  updateModelAxesChecker (modelAxesChecker);
}
Exemplo n.º 2
0
void Checker::prepareForDisplay (const QList<Point> &points,
                                 int pointRadius,
                                 const DocumentModelAxesChecker &modelAxesChecker,
                                 const DocumentModelCoords &modelCoords,
                                 const Transformation &transformation,
                                 DocumentAxesPointsRequired documentAxesPointsRequired)
{
    LOG4CPP_INFO_S ((*mainCat)) << "Checker::prepareForDisplay "
                                << " transformation=" << transformation;

    ENGAUGE_ASSERT ((points.count () == NUM_AXES_POINTS_3) ||
                    (points.count () == NUM_AXES_POINTS_4));

    // Remove previous lines
    m_gridLines.clear ();

    bool fourPoints = (documentAxesPointsRequired == DOCUMENT_AXES_POINTS_REQUIRED_4);

    // Get the min and max of x and y. We initialize yTo to prevent compiler warning
    double xFrom = 0, xTo = 0, yFrom = 0, yTo = 0;
    int i;
    bool firstX = true;
    bool firstY = true;
    for (i = 0; i < points.count(); i++) {
        if (!fourPoints || (points.at(i).isXOnly() && fourPoints)) {

            // X coordinate is defined
            if (firstX) {
                xFrom = points.at(i).posGraph().x();
                xTo   = points.at(i).posGraph().x();
                firstX = false;
            } else {
                xFrom = qMin (xFrom, points.at(i).posGraph().x());
                xTo   = qMax (xTo  , points.at(i).posGraph().x());
            }
        }

        if (!fourPoints || (!points.at(i).isXOnly() && fourPoints)) {

            // Y coordinate is defined
            if (firstY) {
                yFrom = points.at(i).posGraph().y();
                yTo   = points.at(i).posGraph().y();
                firstY = false;
            } else {
                yFrom = qMin (yFrom, points.at(i).posGraph().y());
                yTo   = qMax (yTo  , points.at(i).posGraph().y());
            }
        }
    }

    // Min and max of angles needs special processing since periodicity introduces some ambiguity. This is a noop for rectangular coordinates
    // and for polar coordinates when periodicity is not an issue
    adjustPolarAngleRanges (modelCoords,
                            transformation,
                            points,
                            xFrom,
                            xTo,
                            yFrom);

    // Draw the bounding box as four sides. In polar plots the bottom side is zero-length, with pie shape resulting
    GridLineFactory factory (m_scene,
                             pointRadius,
                             points,
                             modelCoords);
    m_gridLines.add (factory.createGridLine (xFrom, yFrom, xFrom, yTo  , transformation));
    m_gridLines.add (factory.createGridLine (xFrom, yTo  , xTo  , yTo  , transformation));
    m_gridLines.add (factory.createGridLine (xTo  , yTo  , xTo  , yFrom, transformation));
    m_gridLines.add (factory.createGridLine (xTo  , yFrom, xFrom, yFrom, transformation));

    updateModelAxesChecker (modelAxesChecker);
}