19#include <QGraphicsItem>
21#include <QPainterPath>
35 m_curveName (curveName)
41 QVariant (m_curveName));
46 OrdinalToGraphicsPoint::iterator itr;
47 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
52 m_graphicsPoints.clear();
60 <<
" curve=" << m_curveName.toLatin1().data()
61 <<
" identifier=" << pointIdentifier.toLatin1().data()
62 <<
" ordinal=" << ordinal
64 <<
" newPointCount=" << (m_graphicsPoints.count() + 1);
66 m_graphicsPoints [ordinal] = &graphicsPoint;
69QPainterPath GraphicsLinesForCurve::drawLinesSmooth (
const LineStyle &lineStyle,
71 QPainterPath &pathMultiValued,
75 <<
" curve=" << m_curveName.toLatin1().data();
81 vector<SplinePair> xy;
82 OrdinalToGraphicsPoint::const_iterator itr;
83 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
85 double ordinal = itr.key();
88 t.push_back (ordinal);
97 Spline spline (t, xy);
100 m_graphicsPoints.count(),
106 OrdinalToGraphicsPoint::const_iterator itr = m_graphicsPoints.begin();
108 const GraphicsPoint *point = itr.value();
109 path.moveTo (point->
pos ());
110 pathMultiValued.moveTo (point->
pos ());
114 itr != m_graphicsPoints.end();
117 const GraphicsPoint *point = itr.value();
121 QPointF p1 (spline.p1 (unsigned (segment)).x(),
122 spline.p1 (unsigned (segment)).y());
123 QPointF p2 (spline.p2 (unsigned (segment)).x(),
124 spline.p2 (unsigned (segment)).y());
139 path.moveTo (point->
pos ());
142 OrdinalToGraphicsPoint::const_iterator itrBefore = itr - 1;
143 const GraphicsPoint *pointBefore = itrBefore.value();
144 pathMultiValued.moveTo (pointBefore->
pos ());
145 pathMultiValued.cubicTo (p1,
148 lineMultiValued = lineStyle;
154 pathMultiValued.moveTo (point->
pos ());
161QPainterPath GraphicsLinesForCurve::drawLinesStraight (QPainterPath & )
164 <<
" curve=" << m_curveName.toLatin1().data();
170 OrdinalToGraphicsPoint::const_iterator itr;
171 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
173 const GraphicsPoint *point = itr.value();
177 path.moveTo (point->
pos ());
179 path.lineTo (point->
pos ());
189 <<
" identifier=" << identifier.toLatin1().data();
191 OrdinalToGraphicsPoint::const_iterator itr;
192 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
208 QPainterPath &pathMultiValued,
212 <<
" curve=" << m_curveName.toLatin1().data();
214 OrdinalToGraphicsPoint::iterator itr, itrNext;
215 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr = itrNext) {
224 double ordinal = itr.key ();
227 m_graphicsPoints.remove (ordinal);
235 pen = QPen (Qt::NoPen);
255 <<
" curve=" << m_curveName.toLatin1().data();
257 OrdinalToGraphicsPoint::iterator itr;
258 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
266bool GraphicsLinesForCurve::needOrdinalRenumbering ()
const
269 bool needRenumbering =
false;
270 for (
int ordinalKeyWanted = 0; ordinalKeyWanted < m_graphicsPoints.count(); ordinalKeyWanted++) {
272 double ordinalKeyGot = m_graphicsPoints.keys().at (ordinalKeyWanted);
277 if (ordinalKeyWanted != ordinalKeyGot) {
278 needRenumbering =
true;
283 return needRenumbering;
287 QTextStream &str)
const
291 str << indentation <<
"GraphicsLinesForCurve=" << m_curveName
297 OrdinalToGraphicsPoint::const_iterator itr;
298 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
300 double ordinalKey = itr.key();
312 <<
" point=" << ordinal
313 <<
" pointCount=" << m_graphicsPoints.count();
318 m_graphicsPoints.remove (ordinal);
320 delete graphicsPoint;
329 OrdinalToGraphicsPoint::iterator itr;
330 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
334 m_graphicsPoints.remove (itr.key());
336 delete graphicsPoint;
342void GraphicsLinesForCurve::renumberOrdinals ()
346 int ordinalKeyWanted;
350 QList<GraphicsPoint*> points;
351 for (ordinalKeyWanted = 0; ordinalKeyWanted < m_graphicsPoints.count(); ordinalKeyWanted++) {
353 GraphicsPoint *graphicsPoint = m_graphicsPoints.values().at (ordinalKeyWanted);
354 points << graphicsPoint;
357 m_graphicsPoints.clear ();
359 for (ordinalKeyWanted = 0; ordinalKeyWanted < points.count(); ordinalKeyWanted++) {
361 GraphicsPoint *graphicsPoint = points.at (ordinalKeyWanted);
362 m_graphicsPoints [ordinalKeyWanted] = graphicsPoint;
372 <<
" curve=" << m_curveName.toLatin1().
data()
373 <<
" pointCount=" << m_graphicsPoints.count();
376 if (m_graphicsPoints.contains (point.
ordinal())) {
378 graphicsPoint = m_graphicsPoints [point.
ordinal()];
394 m_graphicsPoints [point.
ordinal ()] = graphicsPoint;
407 OrdinalToGraphicsPoint::const_iterator itr;
408 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
418 <<
" curve=" << m_curveName.toLatin1().data()
419 <<
" highlightOpacity=" << highlightOpacity;
421 OrdinalToGraphicsPoint::const_iterator itr;
422 for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {
431 QPainterPath &pathMultiValued,
436 bool needRenumbering = needOrdinalRenumbering ();
437 if (needRenumbering) {
444 <<
" numberPoints=" << m_graphicsPoints.count()
445 <<
" ordinalRenumbering=" << (needRenumbering ?
"true" :
"false");
454 m_graphicsPoints.count () < 3) {
456 path = drawLinesStraight (pathMultiValued);
458 path = drawLinesSmooth (lineStyle,
474 <<
" curve=" << m_curveName.toLatin1().data()
484 OrdinalToGraphicsPoint::iterator itrP;
485 for (itrP = m_graphicsPoints.begin(); itrP != m_graphicsPoints.end(); itrP++) {
487 double ordinal = itrP.key();
495 xOrThetaToOrdinal [pointGraph.x()] = ordinal;
501 XOrThetaToOrdinal::const_iterator itrX;
502 for (itrX = xOrThetaToOrdinal.begin(); itrX != xOrThetaToOrdinal.end(); itrX++) {
504 double ordinalOld = *itrX;
507 temporaryList [ordinalNew++] = point;
511 m_graphicsPoints.clear();
512 for (itrP = temporaryList.begin(); itrP != temporaryList.end(); itrP++) {
514 double ordinal = itrP.key();
517 m_graphicsPoints [ordinal] = point;
@ COLOR_PALETTE_TRANSPARENT
QString curveConnectAsToString(CurveConnectAs curveConnectAs)
@ CONNECT_AS_FUNCTION_STRAIGHT
@ CONNECT_AS_RELATION_STRAIGHT
@ CONNECT_SKIP_FOR_AXIS_CURVE
@ CONNECT_AS_FUNCTION_SMOOTH
QString dataKeyToString(DataKey dataKey)
DataKey
Index values for storing item details in QGraphicsItem using setData/data.
@ DATA_KEY_GRAPHICS_ITEM_TYPE
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.
QColor ColorPaletteToQColor(ColorPalette color)
@ GRAPHICS_ITEM_TYPE_LINE
QMap< double, double > XOrThetaToOrdinal
log4cpp::Category * mainCat
const QString INDENTATION_DELTA
QMap< double, GraphicsPoint * > OrdinalToGraphicsPoint
QString QPointFToString(const QPointF &pos)
@ SPLINE_DRAWER_ENUM_INVISIBLE_MOVE
@ SPLINE_DRAWER_ENUM_VISIBLE_DRAW
Container for LineStyle and PointStyle for one Curve.
Window that displays the geometry information, as a table, for the current curve.
double identifierToOrdinal(const QString &identifier) const
Get ordinal for specified identifier.
void updateAfterCommand(GraphicsScene &scene, const PointStyle &pointStyle, const Point &point, GeometryWindow *geometryWindow)
Update the GraphicsScene with the specified Point from the Document. If it does not exist yet in the ...
void updateCurveStyle(const CurveStyle &curveStyle)
Update the curve style for this curve.
void lineMembershipPurge(const LineStyle &lineStyle, SplineDrawer &splineDrawer, QPainterPath &pathMultiValued, LineStyle &lineMultiValued)
Mark the end of addPoint calls. Remove stale lines, insert missing lines, and draw the graphics lines...
void updateHighlightOpacity(double highlightOpacity)
Update the highlight opacity value. This may or may not affect the current display immediately depend...
void removePoint(double ordinal)
Remove the specified point. The act of deleting it will automatically remove it from the GraphicsScen...
void addPoint(const QString &pointIdentifier, double ordinal, GraphicsPoint &point)
Add new line.
void lineMembershipReset()
Mark points as unwanted. Afterwards, lineMembershipPurge gets called.
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
void updatePointOrdinalsAfterDrag(const LineStyle &lineStyle, const Transformation &transformation)
See GraphicsScene::updateOrdinalsAfterDrag. Pretty much the same steps as Curve::updatePointOrdinals.
GraphicsLinesForCurve(const QString &curveName)
Single constructor.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void updateGraphicsLinesToMatchGraphicsPoints(const LineStyle &lineStyle, SplineDrawer &splineDrawer, QPainterPath &pathMultiValued, LineStyle &lineMultiValued)
Calls to moveLinesWithDraggedPoint have finished so update the lines correspondingly.
Graphics item for drawing a circular or polygonal Point.
QPointF pos() const
Proxy method for QGraphicsItem::pos.
void setWanted()
Mark point as wanted. Marking as unwanted is done by the reset function.
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
void updateCurveStyle(const CurveStyle &curveStyle)
Update point and line styles that comprise the curve style.
void reset()
Mark point as unwanted, and unbind any bound lines.
bool wanted() const
Identify point as wanted//unwanted.
void printStream(QString indentation, QTextStream &str, double ordinalKey) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setHighlightOpacity(double highlightOpacity)
Set method for highlight opacity.
void setPos(const QPointF pos)
Update the position.
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
Add point and line handling to generic QGraphicsScene.
GraphicsPoint * createPoint(const QString &identifier, const PointStyle &pointStyle, const QPointF &posScreen, GeometryWindow *geometryWindow)
Create one QGraphicsItem-based object that represents one Point. It is NOT added to m_graphicsLinesFo...
Details for a specific Line.
CurveConnectAs curveConnectAs() const
Get method for connect type.
unsigned int width() const
Width of line.
ColorPalette paletteColor() const
Line color.
Details for a specific Point.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
QString identifier() const
Unique identifier for a specific Point.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
static double UNDEFINED_ORDINAL()
Get method for undefined ordinal constant.
This class takes the output from Spline and uses that to draw the curve in the graphics window,...
void bindToSpline(const LineStyle &lineStyle, int numSegments, const Spline &spline)
Analyze each segment in the Spline.
SplineDrawerOperation segmentOperation(int segment) const
Indicate if, and how, segment is to be drawn.
Single X/Y pair for cubic spline interpolation initialization and calculations.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)