X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/70084b679b2a4a3be3f7cc6ef80cef7c7ccf8bed..aa158a0284c1bc32a979d50275aa1b24438d46ef:/viewer/view_properties.cpp diff --git a/viewer/view_properties.cpp b/viewer/view_properties.cpp index cd48676..0e789df 100644 --- a/viewer/view_properties.cpp +++ b/viewer/view_properties.cpp @@ -3,36 +3,138 @@ ViewProperties::ViewProperties ():Frame () { - vbox.pack_start (node_num, false, false, 5); - vbox.pack_start (node_level, false, false, 5); - vbox.pack_start (node_items, false, false, 5); - vbox.pack_start (node_freespace, false, false, 5); - - vbox.pack_start (data_type, false, false, 5); - vbox.pack_start (data_key, false, false, 5); - vbox.pack_start (data_child, false, false, 5); + lnode_num.set_use_markup (true); + lnode_level.set_use_markup (true); + lnode_items.set_use_markup (true); + lnode_freespace.set_use_markup (true); + ldata_type.set_use_markup (true); + ldata_key.set_use_markup (true); + ldata_child.set_use_markup (true); + + lnode_num.set_label ("Nodo :"); + lnode_level.set_label ("Nivel : "); + lnode_items.set_label ("Items :"); + lnode_freespace.set_label ("Libre :"); + ldata_type.set_label ("Tipo :"); + ldata_key.set_label ("Clave : "); + ldata_child.set_label ("Hijo : "); + + lnode_num.set_alignment(Gtk::JUSTIFY_LEFT); + lnode_level.set_alignment(Gtk::JUSTIFY_LEFT); + lnode_items.set_alignment(Gtk::JUSTIFY_LEFT); + lnode_freespace.set_alignment(Gtk::JUSTIFY_LEFT); + ldata_type.set_alignment(Gtk::JUSTIFY_LEFT); + ldata_key.set_alignment(Gtk::JUSTIFY_LEFT); + ldata_child.set_alignment(Gtk::JUSTIFY_LEFT); + + table.attach (lnode_num, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (lnode_level, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (lnode_items, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (lnode_freespace, 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (ldata_type, 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (ldata_key, 0, 1, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (ldata_child, 0, 1, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + + table.attach (node_num, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (node_level, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (node_items, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (node_freespace, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (data_type, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (data_key, 1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + table.attach (data_child, 1, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); + + table.property_column_spacing () = 8; + table.property_row_spacing () = 8; - add (vbox); + hbox.pack_start (table, false, true, 8); + hbox.pack_start (raw_view, true, true, 8); + + table.set_size_request (250, 0); + + add (hbox); + property_label_xalign () = 0; set_label ("Propiedades"); set_shadow_type(Gtk::SHADOW_NONE); + set_size_request (200, 0); } -void ViewProperties::ShowItem (BTreeData *, BTreeNodeHeader &header) +void ViewProperties::ShowItem (BTreeData *data, BTreeNodeHeader &header) { std::string s1, s2, s3; std::stringstream ss1, ss2, ss3; + node_num.set_label ("TODO"); + ss1 << header.level; ss1 >> s1; - node_level.set_label ("Nivel : " + s1); + node_level.set_label (s1); ss2 << header.item_count; ss2 >> s2; - node_items.set_label ("Items : " + s2); + node_items.set_label (s2); ss3 << header.free_space; ss3 >> s3; - node_freespace.set_label ("Libre : " + s3); + node_freespace.set_label (s3); + + raw_view.get_buffer ()->assign (ToRaw (data)); + + if (dynamic_cast(data)) { + data_type.set_label ("BTreeChildData"); + data_key.set_label ("N/C"); + + std::string s4; + std::stringstream ss4; + ss4 << data->GetChild (); + ss4 >> s4; + data_child.set_label (s4); + } else if (dynamic_cast(data)) { + data_type.set_label ("BTreeLeafData"); + data_child.set_label ("N/C"); + + std::string s4 = *(data->GetKey ()); + std::cout << "----> " << s4 << std::endl; + data_key.set_label (s4); + } else { + data_type.set_label ("BTreeData"); + + std::string s4; + std::stringstream ss4; + ss4 << data->GetChild (); + ss4 >> s4; + data_child.set_label (s4); + + std::string s5 = *(data->GetKey ()); + data_key.set_label (s5); + } +} + +std::string ViewProperties::ToRaw (BTreeData *p) +{ + std::stringstream ss; + uint size = 0, i; + uchar *arr = NULL; + if (p->GetKey ()) { + arr = p->GetKey ()->ToRaw (size); + } + + for (i=0; i < size; i++) { + if (isalnum (arr[i]) || (arr[i] == ']') || (arr[i] == '|') || + (arr[i] == '[') || (arr[i] == '-')) + ss << arr[i]; + else + ss << "."; + } + + if (p->GetChild () != 0) { + ss << "("; + ss << p->GetChild (); + ss << ")"; + } + + if (arr) + delete [] arr; + return ss.str (); }