00001
00002
00003
00004
00005
00006
00007 #ifndef SEGMENT_H
00008 #define SEGMENT_H
00009
00010 #include <QList>
00011 #include <QObject>
00012 #include <QPointF>
00013
00014 class DocumentModelSegments;
00015 class QGraphicsScene;
00016 class QTextStream;
00017 class SegmentLine;
00018
00021 class Segment : public QObject
00022 {
00023 Q_OBJECT;
00024
00025 public:
00027 Segment(QGraphicsScene &scene,
00028 int yLast,
00029 bool isGnuplot);
00030 ~Segment();
00031
00033 void appendColumn(int x, int y, const DocumentModelSegments &modelSegments);
00034
00036 QList<QPoint> fillPoints(const DocumentModelSegments &modelSegments);
00037
00040 QPointF firstPoint () const;
00041
00043 void forwardMousePress ();
00044
00046 double length() const;
00047
00049 int lineCount() const;
00050
00055 void removeUnneededLines(int *foldedLines);
00056
00058 void updateModelSegment(const DocumentModelSegments &modelSegments);
00059
00060 public slots:
00061
00063 void slotHover (bool hover);
00064
00065 signals:
00066
00068 void signalMouseClickOnSegment (QPointF posSegmentStart);
00069
00070 private:
00071 Segment();
00072
00073
00074
00075
00076
00077
00078
00079 void createAcceptablePoint(bool *pFirst,
00080 QList<QPoint> *pList,
00081 double *xPrev,
00082 double *yPrev,
00083 double x,
00084 double y);
00085
00092 void dumpToGnuplot (QTextStream &strDump,
00093 int xInt,
00094 int yInt,
00095 const SegmentLine *lineOld,
00096 const SegmentLine *lineNew) const;
00097
00098
00099
00100 QList<QPoint> fillPointsFillingCorners(const DocumentModelSegments &modelSegments);
00101
00102
00103 QList<QPoint> fillPointsWithoutFillingCorners(const DocumentModelSegments &modelSegments);
00104
00105
00106
00107 bool isCorner (double yLast,
00108 double yPrev,
00109 double yNext) const;
00110
00111
00112 bool pointIsCloseToLine(double xLeft, double yLeft, double xInt, double yInt,
00113 double xRight, double yRight);
00114
00115
00116 bool pointsAreCloseToLine(double xLeft, double yLeft, QList<QPoint> removedPoints,
00117 double xRight, double yRight);
00118
00119 QGraphicsScene &m_scene;
00120
00121
00122 int m_yLast;
00123
00124
00125 double m_length;
00126
00127
00128 QList<SegmentLine*> m_lines;
00129
00130
00131 bool m_isGnuplot;
00132 };
00133
00134 #endif // SEGMENT_H