COIN-OR::LEMON - Graph Library

source: glemon-0.x/map_win.cc @ 173:8339178ae43d

Last change on this file since 173:8339178ae43d was 172:fc1e478697d3, checked in by Hegyi Péter, 14 years ago

Currently visualized map can be saved and loaded from file.

File size: 3.3 KB
Line 
1#include "map_win.h"
2#include <set>
3
4bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
5{
6  if(e->keyval==GDK_Escape)
7  {
8    mytab.closeMapWin();
9    //    hide();
10  }
11  return true;
12}
13
14MapWin::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  mytab.signal_title_ch().connect(sigc::mem_fun(*this, &MapWin::set_title));
24
25  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
26
27  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
28
29  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
30  {
31    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
32
33    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
34
35    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
36    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
37  }
38
39  vbox.pack_start(*(new Gtk::Label("Edge properties")));
40
41  vbox.pack_start(*table);
42
43  vbox.pack_start(*(new Gtk::HSeparator));
44
45  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
46
47  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
48
49  for(int i=0;i<NODE_PROPERTY_NUM;i++)
50  {
51    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false);
52
53    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
54
55    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
56    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
57  }
58
59  add(vbox);
60
61  vbox.pack_start(*(new Gtk::Label("Node properties")));
62
63  vbox.pack_start(*table);
64
65  show_all_children();
66
67}
68
69void MapWin::nodeMapChanged(std::string mapname, int prop)
70{
71  mytab.propertyChange(false, prop, mapname);
72}
73
74void MapWin::edgeMapChanged(std::string mapname, int prop)
75{
76  mytab.propertyChange(true, prop, mapname);
77}
78
79void MapWin::newMapWinNeeded(bool itisedge)
80{
81  mytab.popupNewMapWin(itisedge);
82}
83
84void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
85{
86  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
87  {
88    e_combo_array[i]->update_list(eml);
89  }
90
91  for(int i=0;i<NODE_PROPERTY_NUM;i++)
92  {
93    n_combo_array[i]->update_list(nml);
94  }
95
96  mytab.active_maps_needed();
97}
98
99void MapWin::registerNewEdgeMap(std::string newmapname)
100{
101  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
102  {
103    //filling in combo box with choices
104    e_combo_array[i]->append_text((Glib::ustring)newmapname);
105  }
106}
107
108void MapWin::registerNewNodeMap(std::string newmapname)
109{
110  for(int i=0;i<NODE_PROPERTY_NUM;i++)
111  {
112    //filling in combo box with choices
113    n_combo_array[i]->append_text((Glib::ustring)newmapname);
114  }
115}
116
117bool MapWin::on_delete_event(GdkEventAny * event)
118{
119  event=event;
120  mytab.closeMapWin();
121  return true;
122}
123
124void MapWin::changeEntry(bool isitedge, int prop, std::string mapname)
125{
126  if(isitedge)
127    {
128      e_combo_array[prop]->set_active_text(mapname);
129    }
130  else
131    {
132      n_combo_array[prop]->set_active_text(mapname);
133    }
134}
135
136void MapWin::set_title(std::string tabname)
137{
138  Gtk::Window::set_title("Map Setup - "+tabname);
139}
Note: See TracBrowser for help on using the repository browser.