2 #include "view_btree.h"
3 #include "view_btree_data.h"
4 #include <sigc++/slot.h>
6 double ViewBTree::byte_to_pixels = 0;
8 ViewBTree::ViewBTree (Canvas::Group *parent, std::string filename):Canvas::Group (*parent, 0, 0),
11 /* TODO : hace que el arbol se abra de un archivo ya creado o que se
14 for (int i=0; i<=64; i++) {
20 byte_to_pixels = NODE_WIDTH/64; // TODO : 64 == BlockSize
25 void ViewBTree::AddNode (uint num)
27 if (node_placed[num]) {
28 std::cout << "WARNING : Tratando de agregar de nuevo el nodo " << num << std::endl;
32 node_placed[num] = true;
35 uchar *node = ReadBlock (num);
37 BTreeNodeHeader node_h;
38 ReadNodoHeader (node, &node_h);
41 max_level = node_h.level;
43 y = (max_level - node_h.level)*(NODE_HEIGHT+10);
46 std::list<BTreeData *> keys = ReadKeys (node, node_h);
48 ViewNode *vnode = new ViewNode (this, num, node_h, keys);
49 vnode->property_y () = y;
50 vnode->property_x () = pos_x[node_h.level];
51 pos_x[node_h.level] += NODE_WIDTH+10;
52 vnode->signal_selected().connect ( sigc::mem_fun (*this, &ViewBTree::on_item_selected) );
54 std::list<uint> childs = vnode->getChilds ();
55 std::list<uint>::iterator hit = childs.begin ();
56 while (hit != childs.end ()) {
58 std::cout << "WARNING : Referencia a 0 encontrada!!" << std::endl;
67 void ViewBTree::on_item_selected (BTreeData *data, uint num)
69 BTreeNodeHeader node_h;
72 node = ReadBlock (num);
73 ReadNodoHeader (node, &node_h);
76 std::cout << "Emit SignalSelected" << std::endl;
77 m_signal_selected (data, node_h);
80 ViewBTree::type_signal_selected ViewBTree::signal_selected ()
82 return m_signal_selected;