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 (); }
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; }