Chris@44
|
1 #ifndef GRAPHER_H
|
Chris@44
|
2 #define GRAPHER_H
|
Chris@44
|
3
|
Chris@44
|
4 #include "changeset.h"
|
Chris@44
|
5 #include "changesetitem.h"
|
Chris@44
|
6
|
cannam@45
|
7 #include <QSet>
|
cannam@45
|
8 #include <QMap>
|
Chris@46
|
9 #include <QPair>
|
cannam@45
|
10
|
cannam@45
|
11 #include <exception>
|
Chris@44
|
12
|
Chris@44
|
13 class Grapher
|
Chris@44
|
14 {
|
Chris@44
|
15 public:
|
cannam@45
|
16 Grapher(QGraphicsScene *scene) { m_scene = scene; }
|
cannam@45
|
17
|
cannam@45
|
18 void layout(Changesets csets);
|
cannam@45
|
19
|
cannam@45
|
20 class LayoutException : public std::exception {
|
cannam@45
|
21 public:
|
cannam@45
|
22 LayoutException(QString message) throw() : m_message(message) { }
|
cannam@45
|
23 virtual ~LayoutException() throw() { }
|
cannam@45
|
24 virtual const char *what() const throw() {
|
cannam@45
|
25 return m_message.toLocal8Bit().data();
|
cannam@45
|
26 }
|
cannam@45
|
27 protected:
|
cannam@45
|
28 QString m_message;
|
cannam@45
|
29 };
|
cannam@45
|
30
|
cannam@45
|
31 private:
|
cannam@45
|
32 QGraphicsScene *m_scene;
|
cannam@45
|
33
|
cannam@45
|
34 typedef QMap<QString, Changeset *> IdChangesetMap;
|
Chris@46
|
35 IdChangesetMap m_changesets;
|
cannam@45
|
36
|
cannam@45
|
37 typedef QMap<QString, ChangesetItem *> IdItemMap;
|
cannam@45
|
38 IdItemMap m_items;
|
cannam@45
|
39
|
cannam@45
|
40 typedef QSet<int> ColumnSet;
|
cannam@45
|
41 typedef QMap<int, ColumnSet> GridAlloc;
|
cannam@45
|
42 GridAlloc m_alloc;
|
cannam@45
|
43
|
Chris@46
|
44 typedef QPair<int, int> Range;
|
Chris@46
|
45 typedef QMap<QString, Range> BranchRangeMap;
|
Chris@46
|
46 BranchRangeMap m_branchRanges;
|
Chris@46
|
47
|
Chris@46
|
48 typedef QMap<QString, int> BranchColumnMap;
|
Chris@46
|
49 BranchColumnMap m_branchHomes;
|
Chris@46
|
50
|
cannam@45
|
51 typedef QSet<QString> IdSet;
|
cannam@45
|
52 IdSet m_handled;
|
Chris@46
|
53
|
Chris@51
|
54 typedef QMap<int, QString> RowDateMap;
|
Chris@51
|
55 RowDateMap m_rowDates;
|
Chris@51
|
56
|
Chris@46
|
57 void layoutRow(QString id);
|
Chris@46
|
58 void layoutCol(QString id);
|
Chris@46
|
59 void allocateBranchHomes(Changesets csets);
|
Chris@46
|
60 bool rangesConflict(const Range &r1, const Range &r2);
|
Chris@46
|
61 int findAvailableColumn(int row, int parent, bool preferParentCol);
|
Chris@44
|
62 };
|
Chris@44
|
63
|
Chris@44
|
64 #endif
|