Go to the documentation of this file.
19 #include <QGraphicsItem>
21 #include <QPainterPath>
23 #include <QTextStream>
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;
69 QPainterPath 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);
100 m_graphicsPoints.count(),
106 OrdinalToGraphicsPoint::const_iterator itr = m_graphicsPoints.begin();
109 path.moveTo (point->
pos ());
110 pathMultiValued.moveTo (point->
pos ());
114 itr != m_graphicsPoints.end();
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;
144 pathMultiValued.moveTo (pointBefore->
pos ());
145 pathMultiValued.cubicTo (p1,
148 lineMultiValued = lineStyle;
154 pathMultiValued.moveTo (point->
pos ());
161 QPainterPath 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++) {
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++) {
266 bool 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;
342 void 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++) {
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;
void setWanted()
Mark point as wanted. Marking as unwanted is done by the reset function.
QVariant data(int key) const
Proxy method for QGraphicsItem::data.
void addPoint(const QString &pointIdentifier, double ordinal, GraphicsPoint &point)
Add new line.
GraphicsLinesForCurve(const QString &curveName)
Single constructor.
Cubic interpolation given independent and dependent value vectors.
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...
@ CONNECT_AS_FUNCTION_SMOOTH
@ DATA_KEY_GRAPHICS_ITEM_TYPE
Unique identifier for QGraphicsItem object
@ SPLINE_DRAWER_ENUM_INVISIBLE_MOVE
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(...
Single X/Y pair for cubic spline interpolation initialization and calculations.
unsigned int width() const
Width of line.
@ CONNECT_SKIP_FOR_AXIS_CURVE
QString dataKeyToString(DataKey dataKey)
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
DataKey
Index values for storing item details in QGraphicsItem using setData/data.
bool wanted() const
Identify point as wanted//unwanted.
@ GRAPHICS_ITEM_TYPE_LINE
void updatePointOrdinalsAfterDrag(const LineStyle &lineStyle, const Transformation &transformation)
See GraphicsScene::updateOrdinalsAfterDrag. Pretty much the same steps as Curve::updatePointOrdinals.
QMap< double, GraphicsPoint * > OrdinalToGraphicsPoint
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.
Container for LineStyle and PointStyle for one Curve.
@ CONNECT_AS_FUNCTION_STRAIGHT
#define ENGAUGE_CHECK_PTR(ptr)
#endif
@ CONNECT_AS_RELATION_STRAIGHT
SplineDrawerOperation segmentOperation(int segment) const
Indicate if, and how, segment is to be drawn.
QPointF posScreen() const
Accessor for screen position.
Details for a specific Line.
void updateHighlightOpacity(double highlightOpacity)
Update the highlight opacity value. This may or may not affect the current display immediately depend...
ColorPalette paletteColor() const
Line color.
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 setPos(const QPointF pos)
Update the position.
#define LOG4CPP_INFO_S(logger)
Add point and line handling to generic QGraphicsScene.
void updateCurveStyle(const CurveStyle &curveStyle)
Update the curve style for this curve.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
QString identifier() const
Unique identifier for a specific Point.
QPointF pos() const
Proxy method for QGraphicsItem::pos.
log4cpp::Category * mainCat
This class takes the output from Spline and uses that to draw the curve in the graphics window,...
QColor ColorPaletteToQColor(ColorPalette color)
Details for a specific Point.
QMap< double, double > XOrThetaToOrdinal
const QString INDENTATION_DELTA
Graphics item for drawing a circular or polygonal Point.
void setData(int key, const QVariant &data)
Proxy method for QGraphicsItem::setData.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
#define LOG4CPP_DEBUG_S(logger)
void setHighlightOpacity(double highlightOpacity)
Set method for highlight opacity.
void lineMembershipReset()
Mark points as unwanted. Afterwards, lineMembershipPurge gets called.
void removePoint(double ordinal)
Remove the specified point. The act of deleting it will automatically remove it from the GraphicsScen...
void bindToSpline(const LineStyle &lineStyle, int numSegments, const Spline &spline)
Analyze each segment in the Spline.
void updateGraphicsLinesToMatchGraphicsPoints(const LineStyle &lineStyle, SplineDrawer &splineDrawer, QPainterPath &pathMultiValued, LineStyle &lineMultiValued)
Calls to moveLinesWithDraggedPoint have finished so update the lines correspondingly.
Window that displays the geometry information, as a table, for the current 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...
CurveConnectAs curveConnectAs() const
Get method for connect type.
double identifierToOrdinal(const QString &identifier) const
Get ordinal for specified identifier.
QString curveConnectAsToString(CurveConnectAs curveConnectAs)
QString QPointFToString(const QPointF &pos)
void updateCurveStyle(const CurveStyle &curveStyle)
Update point and line styles that comprise the curve style.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
@ COLOR_PALETTE_TRANSPARENT
@ SPLINE_DRAWER_ENUM_VISIBLE_DRAW
void reset()
Mark point as unwanted, and unbind any bound lines.