annotate grapher.h @ 45:4286836bb3c9

* Some more work on graph layout; ensure LANG is set for parseable UTF8 output when running Hg
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 10 Nov 2010 12:44:11 +0000
parents bed7ab59f62e
children bd3accba9b3f
rev   line source
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>
cannam@45 9
cannam@45 10 #include <exception>
Chris@44 11
Chris@44 12 class Grapher
Chris@44 13 {
Chris@44 14 public:
cannam@45 15 Grapher(QGraphicsScene *scene) { m_scene = scene; }
cannam@45 16
cannam@45 17 void layout(Changesets csets);
cannam@45 18
cannam@45 19 class LayoutException : public std::exception {
cannam@45 20 public:
cannam@45 21 LayoutException(QString message) throw() : m_message(message) { }
cannam@45 22 virtual ~LayoutException() throw() { }
cannam@45 23 virtual const char *what() const throw() {
cannam@45 24 return m_message.toLocal8Bit().data();
cannam@45 25 }
cannam@45 26 protected:
cannam@45 27 QString m_message;
cannam@45 28 };
cannam@45 29
cannam@45 30 private:
cannam@45 31 void layoutRow(QString id);
cannam@45 32 void layoutCol(QString id);
cannam@45 33 int findAvailableColumn(int row, int parent, bool preferParentCol);
cannam@45 34
cannam@45 35 QGraphicsScene *m_scene;
cannam@45 36
cannam@45 37 typedef QMap<QString, Changeset *> IdChangesetMap;
cannam@45 38 IdChangesetMap m_idCsetMap;
cannam@45 39
cannam@45 40 typedef QMap<QString, ChangesetItem *> IdItemMap;
cannam@45 41 IdItemMap m_items;
cannam@45 42
cannam@45 43 typedef QSet<int> ColumnSet;
cannam@45 44 typedef QMap<int, ColumnSet> GridAlloc;
cannam@45 45 GridAlloc m_alloc;
cannam@45 46
cannam@45 47 typedef QSet<QString> IdSet;
cannam@45 48 IdSet m_handled;
Chris@44 49 };
Chris@44 50
Chris@44 51 #endif