00001 /****************************************************************************************************** 00002 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released * 00003 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file * 00004 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. * 00005 ******************************************************************************************************/ 00006 00007 #ifndef GRAPHICS_LINES_FOR_CURVE_H 00008 #define GRAPHICS_LINES_FOR_CURVE_H 00009 00010 #include "Point.h" 00011 #include "OrdinalToGraphicsPoint.h" 00012 #include <QGraphicsPathItem> 00013 00014 class CurveStyle; 00015 class GraphicsPoint; 00016 class GraphicsScene; 00017 class LineStyle; 00018 class PointStyle; 00019 class QTestStream; 00020 class Transformation; 00021 00024 class GraphicsLinesForCurve : public QGraphicsPathItem 00025 { 00026 public: 00028 GraphicsLinesForCurve(const QString &curveName); 00029 ~GraphicsLinesForCurve(); 00030 00035 void addPoint (const QString &pointIdentifier, 00036 double ordinal, 00037 GraphicsPoint &point); 00038 00040 double identifierToOrdinal (const QString &identifier) const; 00041 00043 void lineMembershipPurge (const LineStyle &lineStyle); 00044 00046 void lineMembershipReset (); 00047 00049 void printStream (QString indentation, 00050 QTextStream &str) const; 00051 00053 void removePoint (double ordinal); 00054 00057 void removeTemporaryPointIfExists (); 00058 00060 void updateAfterCommand (GraphicsScene &scene, 00061 const PointStyle &pointStyle, 00062 const Point &point); 00063 00065 void updateCurveStyle (const CurveStyle &curveStyle); 00066 00068 void updateGraphicsLinesToMatchGraphicsPoints (const LineStyle &lineStyle); 00069 00071 void updatePointOrdinalsAfterDrag (const LineStyle &lineStyle, 00072 const Transformation &transformation); 00073 00074 private: 00075 00076 QPainterPath drawLinesSmooth (); 00077 QPainterPath drawLinesStraight (); 00078 bool needOrdinalRenumbering () const; // True if m_graphicsPoints ordinal keys need renumbering 00079 void renumberOrdinals(); // Renumbers m_graphicsPoints ordinal keys 00080 00081 const QString m_curveName; 00082 OrdinalToGraphicsPoint m_graphicsPoints; 00083 }; 00084 00085 #endif // GRAPHICS_LINES_FOR_CURVE_H