map_win.cc
author hegyi
Thu, 12 Oct 2006 11:39:29 +0000
changeset 160 14a76109b561
parent 123 a3781bff1032
child 172 fc1e478697d3
permissions -rw-r--r--
Node antigravity and edge elasticity based graph layout redesigner.
     1 #include "map_win.h"
     2 #include <set>
     3 
     4 bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
     5 {
     6   if(e->keyval==GDK_Escape)
     7   {
     8     mytab.closeMapWin();
     9     //    hide();
    10   }
    11   return true;
    12 }
    13 
    14 MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw)
    15 {
    16   set_title(title);
    17   set_default_size(200, 50);
    18 
    19   set_resizable(false);
    20 
    21   signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
    22 
    23   e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
    24 
    25   table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
    26 
    27   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    28   {
    29     e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
    30 
    31     (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    32 
    33     e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
    34     e_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
    35   }
    36 
    37   vbox.pack_start(*(new Gtk::Label("Edge properties")));
    38 
    39   vbox.pack_start(*table);
    40 
    41   vbox.pack_start(*(new Gtk::HSeparator));
    42 
    43   n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
    44 
    45   table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
    46 
    47   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    48   {
    49     n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false);
    50 
    51     (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    52 
    53     n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
    54     n_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
    55   }
    56 
    57   add(vbox);
    58 
    59   vbox.pack_start(*(new Gtk::Label("Node properties")));
    60 
    61   vbox.pack_start(*table);
    62 
    63   show_all_children();
    64 
    65 }
    66 
    67 void MapWin::nodeMapChanged(std::string mapname, int prop)
    68 {
    69   mytab.propertyChange(false, prop, mapname);
    70 }
    71 
    72 void MapWin::edgeMapChanged(std::string mapname, int prop)
    73 {
    74   mytab.propertyChange(true, prop, mapname);
    75 }
    76 
    77 void MapWin::newMapWinNeeded(bool itisedge)
    78 {
    79   mytab.popupNewMapWin(itisedge);
    80 }
    81 
    82 void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
    83 {
    84   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    85   {
    86     e_combo_array[i]->update_list(eml);
    87   }
    88 
    89   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    90   {
    91     n_combo_array[i]->update_list(nml);
    92   }
    93 }
    94 
    95 void MapWin::registerNewEdgeMap(std::string newmapname)
    96 {
    97   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    98   {
    99     //filling in combo box with choices
   100     e_combo_array[i]->append_text((Glib::ustring)newmapname);
   101   }
   102 }
   103 
   104 void MapWin::registerNewNodeMap(std::string newmapname)
   105 {
   106   for(int i=0;i<NODE_PROPERTY_NUM;i++)
   107   {
   108     //filling in combo box with choices
   109     n_combo_array[i]->append_text((Glib::ustring)newmapname);
   110   }
   111 }
   112 
   113 bool MapWin::on_delete_event(GdkEventAny * event)
   114 {
   115   event=event;
   116   mytab.closeMapWin();
   117   return true;
   118 }