cout->cerr, node radius and edge width is now scaled, maps are editable by clicking on texts.
4 bool MapWin::closeIfEscapeIsPressed(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::closeIfEscapeIsPressed));
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++)
26 //filling in combo box with choices
27 std::list<Glib::ustring> listStrings;
29 listStrings.push_back("Default");
31 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
32 for(;emsi!=ms.endOfEdgeMaps();emsi++)
34 listStrings.push_back(emsi->first);
37 e_combo_array[i].set_popdown_strings(listStrings);
39 //Restrict it to these choices only:
40 e_combo_array[i].set_value_in_list();
42 //binding signal to the actual entry
43 e_combo_array[i].get_entry()->signal_changed().connect
47 sigc::mem_fun(*this, &MapWin::eComboChanged),
52 //placing actual entry in the right place
55 label->set_text(edge_property_strings[i]);
57 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
58 (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
63 vbox.pack_start(*(new Gtk::Label("Edge properties")));
65 vbox.pack_start(*table);
67 vbox.pack_start(*(new Gtk::HSeparator));
69 n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
71 table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
73 for(int i=0;i<NODE_PROPERTY_NUM;i++)
75 //filling in combo box with choices
76 std::list<Glib::ustring> listStrings;
78 listStrings.push_back("Default");
80 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
82 for(;emsi!=ms.endOfNodeMaps();emsi++)
84 listStrings.push_back(emsi->first);
87 n_combo_array[i].set_popdown_strings(listStrings);
89 //Restrict it to these choices only:
90 n_combo_array[i].set_value_in_list();
92 //binding signal to thew actual entry
93 n_combo_array[i].get_entry()->signal_changed().connect
97 sigc::mem_fun(*this, &MapWin::nComboChanged),
102 //placing actual entry in the right place
104 label=new Gtk::Label;
105 label->set_text(node_property_strings[i]);
107 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
108 (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
115 vbox.pack_start(*(new Gtk::Label("Node properties")));
117 vbox.pack_start(*table);
123 void MapWin::eComboChanged(int prop)
126 Gtk::Entry* entry = e_combo_array[prop].get_entry();
130 Glib::ustring mapname = entry->get_text();
131 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
133 if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
138 gdc.changeEdgeWidth(mapname);
141 gdc.changeEdgeColor(mapname);
144 gdc.changeEdgeText(mapname);
147 std::cerr<<"Error\n";
154 void MapWin::nComboChanged(int prop)
157 Gtk::Entry* entry = n_combo_array[prop].get_entry();
161 Glib::ustring mapname = entry->get_text();
162 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
164 if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
169 gdc.changeNodeRadius(mapname);
172 gdc.changeNodeColor(mapname);
175 gdc.changeNodeText(mapname);
178 std::cerr<<"Error\n";
185 void MapWin::updateNode(Graph::Node node)
187 for(int i=0;i<NODE_PROPERTY_NUM;i++)
189 Gtk::Entry* entry = n_combo_array[i].get_entry();
193 Glib::ustring mapname = entry->get_text();
194 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
196 if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
201 gdc.changeNodeRadius(mapname, node);
204 gdc.changeNodeColor(mapname, node);
207 gdc.changeNodeText(mapname, node);
210 std::cerr<<"Error\n";
218 void MapWin::updateEdge(Graph::Edge edge)
220 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
223 Gtk::Entry* entry = e_combo_array[i].get_entry();
227 Glib::ustring mapname = entry->get_text();
228 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
231 if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
236 gdc.changeEdgeWidth(mapname, edge);
239 gdc.changeEdgeColor(mapname, edge);
242 gdc.changeEdgeText(mapname, edge);
245 std::cerr<<"Error\n";
253 void MapWin::registerNewEdgeMap(std::string newmapname)
255 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
257 //filling in combo box with choices
258 std::list<Glib::ustring> listStrings=e_combo_array[i].get_popdown_strings();
259 listStrings.push_back(newmapname);
260 e_combo_array[i].set_popdown_strings(listStrings);
262 //setting text property for the new map
263 Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry();
264 entry->set_text((Glib::ustring)newmapname);
267 void MapWin::registerNewNodeMap(std::string newmapname)
269 for(int i=0;i<NODE_PROPERTY_NUM;i++)
271 //filling in combo box with choices
272 std::list<Glib::ustring> listStrings=n_combo_array[i].get_popdown_strings();
273 listStrings.push_back(newmapname);
274 n_combo_array[i].set_popdown_strings(listStrings);
276 //setting text property for the new map
277 Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry();
278 entry->set_text((Glib::ustring)newmapname);