plotting
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index 483f1f6..2d2f631 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -6,6 +6,7 @@
 #include <vector>
 #include <iostream>
 #include <assert.h>
+#include <boost/lexical_cast.hpp>
 
 static const double Pi = 3.14159265358979323846264338327950288419717;
 
@@ -15,86 +16,176 @@
 }
 
 void
-DigestTreeScene::plot() {
+DigestTreeScene::processUpdate(std::vector<Sync::MissingDataInfo> &v, QString digest)
+{
+  int n = v.size();
+  bool rePlot = false; 
+  for (int i = 0; i < n; i++) 
+  {
+    Roster_iterator it = m_roster.find(v[i].prefix.c_str());
+    if (it == m_roster.end()) {
+      rePlot = true; 
+      DisplayUserPtr p(new DisplayUser());
+      p->setPrefix(v[i].prefix.c_str());
+      p->setSeq(v[i].high);
+      m_roster.insert(p->getPrefix(), p);
+    }
+  }
+
+  if (rePlot) 
+  {
+    plot(digest);
+  }
+  else 
+  {
+    for (int i = 0; i < n; i++) 
+    {
+      Roster_iterator it = m_roster.find(v[i].prefix.c_str());
+      if (it != m_roster.end()) {
+        DisplayUserPtr p = it.value();
+        QGraphicsTextItem *item = p->getSeqTextItem();
+        std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
+        item->setPlainText(s.c_str());
+      }
+    }
+    m_rootDigest->setPlainText(digest);
+  }
+}
+
+void
+DigestTreeScene::msgReceived(QString prefix, QString nick)
+{
+  Roster_iterator it = m_roster.find(prefix);
+  if (it != m_roster.end()) 
+  {
+    DisplayUserPtr p = it.value();
+    if (nick != p->getNick()) {
+      p->setNick(nick);
+      QGraphicsTextItem *nickItem = p->getNickTextItem();
+      nickItem->setPlainText(p->getNick());
+    }
+    QGraphicsRectItem *rimItem = p->getRimRectItem();
+    rimItem->setBrush(QBrush(Qt::red));
+  }
+}
+
+void
+DigestTreeScene::plot(QString digest)
+{
   clear();
   m_graph.clear();
-  std::vector<ogdf::node> v(5);
-  for (int i = 0; i < 5; i++)
-    v[i] = m_graph.newNode();
-
-  m_graph.newEdge(v[0], v[1]);
-  m_graph.newEdge(v[0], v[2]);
-  m_graph.newEdge(v[0], v[3]);
-  m_graph.newEdge(v[0], v[4]);
-
+  int n = m_roster.size();
+  ogdf::node root = m_graph.newNode();
+  int rootIndex = root->index();
+  for (int i = 0; i < n; i++) {
+     ogdf::node leaf = m_graph.newNode();
+     m_graph.newEdge(root, leaf);
+  }
   ogdf::GraphAttributes GA(m_graph);
-  GA.initAttributes(ogdf::GraphAttributes::nodeLabel);
-  int nodeWidth = 30, nodeHeight = 30, siblingDistance = 60;
+
+  int nodeSize = 50;
+  int siblingDistance = 100, levelDistance = 100;
   ogdf::TreeLayout layout;
   layout.siblingDistance(siblingDistance);
-  layout.rootSelection(ogdf::TreeLayout::rootIsSource);
-  //layout.call(GA);
+  layout.levelDistance(levelDistance);
   layout.callSortByPositions(GA, m_graph);
 
   int width = GA.boundingBox().width();
-  std::cout << "GA width " << width << std::endl;
   int height = GA.boundingBox().height();
-  std::cout << "GA height " << height << std::endl;
-  setSceneRect(QRect(0, 0, width + nodeWidth, height + nodeHeight));
-  GA.setAllWidth(nodeWidth);
-  GA.setAllHeight(nodeHeight);
+  setSceneRect(QRect(- (width + nodeSize) / 2, - 40, width + nodeSize, height + nodeSize));
+  GA.setAllWidth(nodeSize);
+  GA.setAllHeight(nodeSize);
 
+  plotEdge(GA);
+  plotNode(GA, rootIndex, digest);
+
+}
+
+void
+DigestTreeScene::plotEdge(ogdf::GraphAttributes &GA)
+{
   ogdf::edge e;
   forall_edges(e, m_graph) {
     ogdf::node source = e->source();
     ogdf::node target = e->target();
+    int nodeSize = GA.width(target);
     int x1 = GA.x(source), y1 = -GA.y(source);
     int x2 = GA.x(target), y2 = -GA.y(target);
-  //  QPainterPath p;
-    QPointF src(x1 + nodeWidth/2, y1 + nodeHeight/2);
-    QPointF dest(x2 + nodeWidth/2, y2 + nodeHeight/2);
+    QPointF src(x1 + nodeSize/2, y1 + nodeSize/2);
+    QPointF dest(x2 + nodeSize/2, y2 + nodeSize/2);
     QLineF line(src, dest);
-    //p.moveTo(x1 + nodeWidth/2, y1 + nodeHeight/2);
-    //p.lineTo(x2 + nodeWidth/2, y2 + nodeHeight/2);
-    //addPath(p, QPen(Qt::black), QBrush(Qt::black));
-    addLine(line, QPen(Qt::black));
-    
     double angle = ::acos(line.dx() / line.length());
 
     double arrowSize = 10;
-
-   QPointF sourceArrowP0 = src + QPointF(nodeWidth/2 * line.dx() / line.length(),  nodeHeight/2 * line.dy() / line.length());
-   //QPointF sourceArrowP0 = src + QPointF(cos(angle) * nodeHeight/2, sin(angle) * nodeHeight/2);
-
-   std::cout << "src " << src.x() << ", " << src.y() << std::endl;
-   std::cout << "dest " << dest.x() << ", " << dest.y() << std::endl;
-   std::cout << "line dx " << line.dx() << ", dy " << line.dy() << ", lenght << " << line.length() << std::endl;
-   std::cout << "sap " << sourceArrowP0.x() << ", " << sourceArrowP0.y() << std::endl;
-
-   QPointF sourceArrowP1 = sourceArrowP0 + QPointF(cos(angle + Pi / 3 - Pi/2) * arrowSize,
+    QPointF sourceArrowP0 = src + QPointF((nodeSize/2 + 10) * line.dx() / line.length(),  (nodeSize/2 +10) * line.dy() / line.length());
+    QPointF sourceArrowP1 = sourceArrowP0 + QPointF(cos(angle + Pi / 3 - Pi/2) * arrowSize,
                                                     sin(angle + Pi / 3 - Pi/2) * arrowSize);
-      QPointF sourceArrowP2 = sourceArrowP0 + QPointF(cos(angle + Pi - Pi / 3 - Pi/2) * arrowSize,
+    QPointF sourceArrowP2 = sourceArrowP0 + QPointF(cos(angle + Pi - Pi / 3 - Pi/2) * arrowSize,
                                                          sin(angle + Pi - Pi / 3 - Pi/2) * arrowSize);
-    QLineF line1(sourceArrowP1, sourceArrowP2);
-    addLine(line1, QPen(Qt::black));
-     
-     addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
-  }
 
+    addLine(QLineF(sourceArrowP0, dest), QPen(Qt::black));
+    addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
+  }
+}
+
+void
+DigestTreeScene::plotNode(ogdf::GraphAttributes &GA, int rootIndex, QString digest)
+{
   ogdf::node n;
-  int i = 0;
-  std::string s[5] = {"A", "B", "C", "D", "E"};
+  RosterIterator it(m_roster);
   forall_nodes(n, m_graph) {
     double x = GA.x(n);
-
     double y = -GA.y(n);
     double w = GA.width(n);
     double h = GA.height(n);
+    int rim = 3;
     QRectF boundingRect(x, y, w, h);
-    addEllipse(boundingRect, QPen(Qt::black), QBrush(Qt::green));
-    QGraphicsTextItem *text = addText(s[i].c_str());
-    text->setPos(x + 5, y + 5);
-    i++; 
+    QRectF innerBoundingRect(x + rim, y + rim, w - rim * 2, h - rim * 2);
+    addRect(innerBoundingRect, QPen(Qt::black), QBrush(Qt::lightGray));
+
+    if (n->index() == rootIndex) 
+    {
+      addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkRed));
+
+      QRectF digestRect(x - w / 2, y - h - 5, 2 * w, 30);
+      addRect(digestRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
+      QGraphicsTextItem *digestItem = addText(digest);
+      QRectF digestBoundingRect = digestItem->boundingRect();
+      digestItem->setDefaultTextColor(Qt::white);
+      digestItem->setFont(QFont("Cursive", 12, QFont::Bold));
+      digestItem->setPos(x + w / 2 - digestBoundingRect.width() / 2, y - h - 15);
+      m_rootDigest = digestItem;
+    }
+    else
+    {
+      if (it.hasNext()) 
+      {
+        it.next();
+      }
+      else 
+      {
+        abort();
+      }
+      DisplayUserPtr p = it.value();
+      QGraphicsRectItem *rectItem = addRect(boundingRect, QPen(Qt::black), QBrush(Qt::darkBlue));
+      p->setRimRectItem(rectItem);
+
+      std::string s = boost::lexical_cast<std::string>(p->getSeqNo().getSeq());
+      QGraphicsTextItem *seqItem = addText(s.c_str());
+      seqItem->setFont(QFont("Cursive", 12, QFont::Bold));
+      QRectF seqBoundingRect = seqItem->boundingRect(); 
+      seqItem->setPos(x + w / 2 - seqBoundingRect.width() / 2, y + h / 2 - seqBoundingRect.height() / 2);
+      p->setSeqTextItem(seqItem);
+
+      QRectF textRect(x - w / 2, y + h + 10, 2 * w, 30);
+      addRect(textRect, QPen(Qt::darkCyan), QBrush(Qt::darkCyan));
+      QGraphicsTextItem *nickItem = addText(p->getNick());
+      QRectF textBoundingRect = nickItem->boundingRect();
+      nickItem->setDefaultTextColor(Qt::white);
+      nickItem->setFont(QFont("Cursive", 12, QFont::Bold));
+      nickItem->setPos(x + w / 2 - textBoundingRect.width() / 2, y + h + 15);
+      p->setNickTextItem(nickItem);
+    }
   }
 }