void GraphicsLinesForCurve::updateAfterCommand (GraphicsScene &scene,
                                                const PointStyle &pointStyle,
                                                const Point &point)
{
  LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsLinesForCurve::updateAfterCommand"
                               << " curve=" << m_curveName.toLatin1().data()
                               << " pointCount=" << m_graphicsPoints.count();

  GraphicsPoint *graphicsPoint = 0;
  if (m_graphicsPoints.contains (point.ordinal())) {

    graphicsPoint = m_graphicsPoints [point.ordinal()];

    // Due to ordinal renumbering, the coordinates may belong to some other point so we override
    // them for consistent ordinal-position mapping. Updating the identifier also was added for
    // better logging (i.e. consistency between Document and GraphicsScene dumps), but happened
    // to fix a bug with the wrong set of points getting deleted from Cut and Delete
    graphicsPoint->setPos (point.posScreen());
    graphicsPoint->setData (DATA_KEY_IDENTIFIER, point.identifier());

  } else {

    // Point does not exist in scene so create it
    graphicsPoint = scene.createPoint (point.identifier (),
                                       pointStyle,
                                       point.posScreen());
    m_graphicsPoints [point.ordinal ()] = graphicsPoint;

  }

  // Mark point as wanted
  ENGAUGE_CHECK_PTR (graphicsPoint);
  graphicsPoint->setWanted ();
}
void GraphicsLinesForCurve::updateCurveStyle (const CurveStyle &curveStyle)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::updateCurveStyle";

  OrdinalToGraphicsPoint::const_iterator itr;
  for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {

     GraphicsPoint *point = itr.value();
     point->updateCurveStyle (curveStyle);
  }
}
void GraphicsLinesForCurve::lineMembershipReset ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::lineMembershipReset"
                              << " curve=" << m_curveName.toLatin1().data();

  OrdinalToGraphicsPoint::iterator itr;
  for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {

    GraphicsPoint *point = itr.value();

    point->reset ();
  }
}
void GraphicsLinesForCurve::savePoint (const QString &pointIdentifier,
                                       double ordinal,
                                       GraphicsPoint &graphicsPoint)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::savePoint"
                              << " curve=" << m_curveName.toLatin1().data()
                              << " identifier=" << pointIdentifier.toLatin1().data()
                              << " ordinal=" << ordinal
                              << " pos=" << QPointFToString (graphicsPoint.pos()).toLatin1().data()
                              << " newPointCount=" << (m_graphicsPoints.count() + 1);

  // Replace existing entry if there is one, with a proxy Point for the one in the Document
  Point point (pointIdentifier,
               ordinal,
               graphicsPoint.pos());

  m_graphicsPoints [pointIdentifier] = point;
}
Example #5
0
void DlgSettingsCurveProperties::drawPoints (const PointStyle &pointStyle)
{
  const QString NULL_IDENTIFIER;
  GeometryWindow *NULL_GEOMETRY_WINDOW = 0;

  GraphicsPointFactory pointFactory;

  // Left point
  GraphicsPoint *pointLeft = pointFactory.createPoint (*m_scenePreview,
                                                       NULL_IDENTIFIER,
                                                       POS_LEFT,
                                                       pointStyle,
                                                       NULL_GEOMETRY_WINDOW);
  pointLeft->setPointStyle (pointStyle);

  // Center point
  GraphicsPoint *pointCenter = pointFactory.createPoint (*m_scenePreview,
                                                         NULL_IDENTIFIER,
                                                         POS_CENTER,
                                                         pointStyle,
                                                         NULL_GEOMETRY_WINDOW);
  pointCenter->setPointStyle (pointStyle);

  // Right point
  GraphicsPoint *pointRight = pointFactory.createPoint (*m_scenePreview,
                                                        NULL_IDENTIFIER,
                                                        POS_RIGHT,
                                                        pointStyle,
                                                        NULL_GEOMETRY_WINDOW);
  pointRight->setPointStyle (pointStyle);
}
void GraphicsLinesForCurve::addPoint (const QString &pointIdentifier,
                                      double ordinal,
                                      GraphicsPoint &graphicsPoint)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::addPoint"
                              << " curve=" << m_curveName.toLatin1().data()
                              << " identifier=" << pointIdentifier.toLatin1().data()
                              << " ordinal=" << ordinal
                              << " pos=" << QPointFToString (graphicsPoint.pos()).toLatin1().data()
                              << " newPointCount=" << (m_graphicsPoints.count() + 1);

  m_graphicsPoints [ordinal] = &graphicsPoint;
}
void GraphicsLinesForCurve::lineMembershipPurge (const LineStyle &lineStyle)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::lineMembershipPurge"
                              << " curve=" << m_curveName.toLatin1().data();

  OrdinalToGraphicsPoint::iterator itr, itrNext;
  for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr = itrNext) {

    itrNext = itr;
    ++itrNext;

    GraphicsPoint *point = *itr;

    if (!point->wanted ()) {

      double ordinal = itr.key ();

      delete point;
      m_graphicsPoints.remove (ordinal);
    }
  }

  // Apply line style
  QPen pen;
  if (lineStyle.paletteColor() == COLOR_PALETTE_TRANSPARENT) {

    pen = QPen (Qt::NoPen);

  } else {

    pen = QPen (QBrush (ColorPaletteToQColor (lineStyle.paletteColor())),
                lineStyle.width());

  }

  setPen (pen);

  updateGraphicsLinesToMatchGraphicsPoints (lineStyle);
}
GraphicsPoint *GraphicsScene::createPoint (const QString &identifier,
                                           const PointStyle &pointStyle,
                                           const QPointF &posScreen)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsScene::createPoint"
                              << " identifier=" << identifier.toLatin1().data();

  // Ordinal value is initially computed as one plus the max ordinal seen so far. This initial ordinal value will be overridden if the
  // cordinates determine the ordinal values.
  //
  // This is an N-squared algorithm and may be worth replacing later
  GraphicsPointFactory pointFactory;
  GraphicsPoint *point = pointFactory.createPoint (*this,
                                                   identifier,
                                                   posScreen,
                                                   pointStyle);

  point->setToolTip (identifier);
  point->setData (DATA_KEY_GRAPHICS_ITEM_TYPE, GRAPHICS_ITEM_TYPE_POINT);

  return point;
}
void GraphicsLinesForCurves::addPoint (const QString &curveName,
                                       const QString &pointIdentifier,
                                       double ordinal,
                                       GraphicsPoint &point)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurves::addPoint"
                              << " curve=" << curveName.toLatin1().data()
                              << " identifier=" << pointIdentifier.toLatin1().data()
                              << " ordinal=" << ordinal
                              << " pos=" << QPointFToString (point.pos()).toLatin1().data();

  m_graphicsLinesForCurve [curveName]->addPoint (pointIdentifier,
                                                 ordinal,
                                                 point);
}