4 bool MapWin::close_if_escape_is_pressed(GdkEventKey* e)
6 if(e->keyval==GDK_Escape)
13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
16 set_default_size(200, 50);
18 signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed));
20 e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM];
22 table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false);
24 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
27 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
32 //here we find out, which map is the default in MapStorage for this property, which are not
33 for(int j=0;j<ms.numOfEdgeMaps();j++)
35 //this is the default value for this property
36 if(emsi->second==&(ms.default_edgemaps[i]))
40 //these are the maps NOT to show for this property
41 for(int k=0;k<EDGE_PROPERTY_NUM;k++)
43 if(emsi->second==&(ms.default_edgemaps[k]))
51 //filling in combo box with choices
52 std::list<Glib::ustring> listStrings;
54 listStrings.push_back("Default");
56 emsi=ms.beginOfEdgeMaps();
58 for(int j=0;j<ms.numOfEdgeMaps();j++)
60 if( ( props.find(j) )==( props.end() ) )
62 listStrings.push_back(emsi->first);
67 e_combo_array[i].set_popdown_strings(listStrings);
69 //Restrict it to these choices only:
70 e_combo_array[i].set_value_in_list();
72 //binding signal to the actual entry
73 e_combo_array[i].get_entry()->signal_changed().connect
77 sigc::mem_fun(*this, &MapWin::e_combo_changed),
82 //placing actual entry in the right place
85 label->set_text(edge_property_strings[i]);
87 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
88 (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
93 vbox.pack_start(*(new Gtk::Label("Edge properties")));
95 vbox.pack_start(*table);
97 vbox.pack_start(*(new Gtk::HSeparator));
99 n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
101 table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
103 for(int i=0;i<NODE_PROPERTY_NUM;i++)
106 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
111 //here we find out, which map is the default in MapStorage for this property, which are not
112 for(int j=0;j<ms.numOfNodeMaps();j++)
114 //these are the maps NOT to show for this property
115 if(emsi->second==&(ms.default_nodemaps[i]))
119 //this is the other maps to show for this property
120 for(int k=0;k<NODE_PROPERTY_NUM;k++)
122 if(emsi->second==&(ms.default_nodemaps[k]))
130 //filling in combo box with choices
131 std::list<Glib::ustring> listStrings;
133 listStrings.push_back("Default");
135 emsi=ms.beginOfNodeMaps();
137 for(int j=0;j<ms.numOfNodeMaps();j++)
139 if( ( props.find(j) )==( props.end() ) )
141 listStrings.push_back(emsi->first);
146 n_combo_array[i].set_popdown_strings(listStrings);
148 //Restrict it to these choices only:
149 n_combo_array[i].set_value_in_list();
151 //binding signal to thew actual entry
152 n_combo_array[i].get_entry()->signal_changed().connect
156 sigc::mem_fun(*this, &MapWin::n_combo_changed),
161 //placing actual entry in the right place
163 label=new Gtk::Label;
164 label->set_text(node_property_strings[i]);
166 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
167 (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
174 vbox.pack_start(*(new Gtk::Label("Node properties")));
176 vbox.pack_start(*table);
182 void MapWin::e_combo_changed(int prop)
184 Gtk::Entry* entry = e_combo_array[prop].get_entry();
188 Glib::ustring mapname = entry->get_text();
189 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
191 if(mapname=="Default")
193 mapname=edge_property_strings[prop];
196 if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() )
201 gdc.changeEdgeWidth(mapname);
204 gdc.changeEdgeColor(mapname);
207 gdc.changeEdgeText(mapname);
210 std::cout<<"Error\n";
217 void MapWin::n_combo_changed(int prop)
220 Gtk::Entry* entry = n_combo_array[prop].get_entry();
224 Glib::ustring mapname = entry->get_text();
225 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
227 if(mapname=="Default")
229 mapname=node_property_strings[prop];
232 if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() )
237 gdc.changeNodeRadius(mapname);
240 gdc.changeNodeColor(mapname);
243 gdc.changeNodeText(mapname);
246 std::cout<<"Error\n";
253 void MapWin::update_node(Graph::Node node)
255 for(int i=0;i<NODE_PROPERTY_NUM;i++)
257 Gtk::Entry* entry = n_combo_array[i].get_entry();
261 Glib::ustring mapname = entry->get_text();
262 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
264 if(mapname=="Default")
266 mapname=node_property_strings[i];
269 if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() )
274 //gdc.changeNodeRadius(mapname, node);
275 std::cout << "If default map-value problem is solved, uncomment line in MapWin::node_update!" << std::endl;
278 gdc.changeNodeColor(mapname, node);
281 gdc.changeNodeText(mapname, node);
284 std::cout<<"Error\n";
292 void MapWin::update_edge(Graph::Edge edge)
294 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
297 Gtk::Entry* entry = e_combo_array[i].get_entry();
301 Glib::ustring mapname = entry->get_text();
302 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
304 if(mapname=="Default")
306 mapname=edge_property_strings[i];
309 if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() )
314 //gdc.changeEdgeWidth(mapname, edge);
315 std::cout << "If default map-value problem is solved, uncomment line in MapWin::edge_update!" << std::endl;
318 gdc.changeEdgeColor(mapname, edge);
321 gdc.changeEdgeText(mapname, edge);
324 std::cout<<"Error\n";