2 #include "view_btree.h"
3 #include "view_btree_data.h"
5 ViewBTree::ViewBTree (Canvas::Group *parent, std::string filename):Canvas::Group (*parent, 0, 0),
8 /* TODO : hace que el arbol se abra de un archivo ya creado o que se
11 for (int i=0; i<=64; i++) {
17 Canvas::Rect *rect = new Canvas::Rect (*this, 0, 0, NODE_WIDTH, NODE_HEIGHT);
18 rect->property_fill_color() = "gray";
20 byte_to_pixels = NODE_WIDTH/64; // TODO : 64 == BlockSize
25 void ViewBTree::AddNode (uint num)
29 uchar *node = ReadBlock (num);
31 BTreeNodeHeader node_h;
32 ReadNodoHeader (node, &node_h);
35 max_level = node_h.level;
37 y = (max_level - node_h.level)*(NODE_HEIGHT+10);
40 std::list<BTreeData *> keys = ReadKeys (node, node_h);
42 double header_w = byte_to_pixels * sizeof (BTreeNodeHeader);
45 Canvas::Rect *view_header = new Canvas::Rect (*this, x, y, x+header_w, y+NODE_HEIGHT);
46 view_header->property_fill_color() = "blue";
53 new Canvas::Text (*this, header_w/2, y+NODE_HEIGHT/2, node_num);
57 /* Cuento los hijos para saber como centrarlos más adelante */
58 std::list<uint> hijos;
60 std::list<BTreeData *>::iterator it = keys.begin ();
61 while (it != keys.end ()) {
62 BTreeData *data = (*it);
63 double w = byte_to_pixels * data->Size ();
65 ViewBTreeData *v = ViewBTreeData::Create (data, this, x, y, w+x, y+NODE_HEIGHT);
70 if (dynamic_cast<BTreeChildData *>(data)) {
71 BTreeChildData *child = dynamic_cast<BTreeChildData *>(data);
72 hijos.push_back (child->getChild ());
77 std::list<uint>::iterator hit = hijos.begin ();
78 while (hit != hijos.end ()) {