00001
00002
00003
00004
00005
00006
00007 #ifndef SEGMENT_FACTORY_H
00008 #define SEGMENT_FACTORY_H
00009
00010 #include <QList>
00011 #include <QPointF>
00012 #include <vector>
00013
00014 class ColorFilter;
00015 class DocumentModelSegments;
00016 class QGraphicsScene;
00017 class QImage;
00018 class Segment;
00019
00020 typedef std::vector<Segment*> SegmentVector;
00021
00027 class SegmentFactory
00028 {
00029 public:
00031 SegmentFactory(QGraphicsScene &scene,
00032 bool isGnuplot);
00033
00035 void clearSegments(QList<Segment*> &segments);
00036
00038 QList<QPoint> fillPoints(const DocumentModelSegments &modelSegments,
00039 QList<Segment*> segments);
00040
00042 void makeSegments (const QImage &imageFiltered,
00043 const DocumentModelSegments &modelSegments,
00044 QList<Segment*> &segments,
00045 bool useDlg = true);
00046
00047 private:
00048 SegmentFactory();
00049
00050
00051 int adjacentRuns(bool *columnBool,
00052 int yStart,
00053 int yStop,
00054 int height);
00055
00056
00057 Segment *adjacentSegment(SegmentVector &lastSegment,
00058 int yStart,
00059 int yStop,
00060 int height);
00061
00062
00063 int adjacentSegments(SegmentVector &lastSegment,
00064 int yStart,
00065 int yStop,
00066 int height);
00067
00068
00069
00070
00071 void finishRun(bool *lastBool,
00072 bool *nextBool,
00073 SegmentVector &lastSegment,
00074 SegmentVector &currSegment,
00075 int x,
00076 int yStart,
00077 int yStop,
00078 int height,
00079 const DocumentModelSegments &modelSegments,
00080 int* madeLines);
00081
00082
00083 void loadBool (const ColorFilter &filter,
00084 bool *columnBool,
00085 const QImage &image,
00086 int x);
00087
00088
00089 void loadSegment (SegmentVector &columnSegment,
00090 int height);
00091
00092
00093 void matchRunsToSegments (int x,
00094 int height,
00095 bool *lastBool,
00096 SegmentVector &lastSegment,
00097 bool *currBool,
00098 SegmentVector &currSegment,
00099 bool *nextBool,
00100 const DocumentModelSegments &modelSegments,
00101 int *madeLines,
00102 int *foldedLines,
00103 int *shortLine,
00104 QList<Segment*> &segments);
00105
00107 void removeEmptySegments (QList<Segment*> &segments) const;
00108
00109
00110
00111 void removeUnneededLines(SegmentVector &lastSegment,
00112 SegmentVector &currSegment,
00113 int height,
00114 int *foldedLines,
00115 int *shortLines,
00116 const DocumentModelSegments &modelSegments,
00117 QList<Segment*> &segments);
00118
00119
00120 void scrollBool(bool *left,
00121 bool *right,
00122 int height);
00123
00124
00125 void scrollSegment(SegmentVector &left,
00126 SegmentVector &right,
00127 int height);
00128
00129 QGraphicsScene &m_scene;
00130
00131 bool m_isGnuplot;
00132 };
00133
00134 #endif // SEGMENT_FACTORY_H