- Add missing repository files (AUTHORS COPYING NEWS README). They need to
be filled with info.
- RPM support
1 #include <dijkstrabox.h>
3 enum {INPUT, OUTPUT, MAP_NUM};
5 DijkstraBox::DijkstraBox(std::vector<std::string> t):AlgoBox()
10 void DijkstraBox::run()
13 tabcbt.get_active_text()!="" &&
14 (edgemapcbts[INPUT])->get_active_text()!="" &&
15 (edgemapcbts[OUTPUT])->get_active_text()!="" &&
16 source.get_active_text()!="" &&
17 target.get_active_text()!=""
20 const Graph &g=mapstorage->graph;
22 Graph::EdgeMap<double> * inputmap=
23 (mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()];
24 Graph::EdgeMap<double> * outputmap=
25 (mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()];
32 for (EdgeIt i(g); i!=INVALID; ++i)
37 for (NodeIt i(g); (i!=INVALID) && (assigned<2); ++i)
39 std::ostringstream text;
40 text << (*((mapstorage->nodemap_storage)["label"]))[i];
41 if(!(text.str().compare(source.get_active_text())))
46 if(!(text.str().compare(target.get_active_text())))
54 Dijkstra<Graph, Graph::EdgeMap<double> > dijkstra(g, *inputmap);
55 dijkstra.run(from, to);
57 if(dijkstra.reached(to))
61 while (n!=INVALID && n!=from)
63 Edge e=dijkstra.predEdge(n);
65 n=dijkstra.predNode(n);
68 o << "Result: " << length << " long path, with cost " << dijkstra.dist(to);
72 o << "Result: failed to find shortest path between ";
73 o << source.get_active_text() << " and " << target.get_active_text();
75 resultlabel.set_text(o.str());
77 mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
79 // mapstorage->changeActiveMap(true, E_COLOR,
80 // (edgemapcbts[OUTPUT])->get_active_text());
81 // mapstorage->changeActiveMap(true, E_TEXT,
82 // (edgemapcbts[INPUT])->get_active_text());
86 void DijkstraBox::build_box()
88 //if active tab is changed, labels of graph nodes had to be loaded into comboboxes
89 //this can be done after the maps are loaded into ComboBoxes
90 signal_upon_maplist_updated().connect(sigc::mem_fun(*this, &DijkstraBox::maplists_updated));
92 addMapSelector("Cost map: ", true);
93 addMapSelector("Edges of path here: ", true);
95 Gtk::Label * source_label=new Gtk::Label("Source: ");
96 Gtk::Label * target_label=new Gtk::Label("Target: ");
98 table.attach(*source_label, 0,1,0,1);
99 table.attach(*target_label, 0,1,1,2);
100 table.attach(source, 1,2,0,1);
101 table.attach(target, 1,2,1,2);
106 resultlabel.set_text("Result: algorithm is not run yet.");
107 pack_start(resultlabel);
110 void DijkstraBox::maplists_updated()
112 if(tabcbt.get_active_text()!="")
116 const Graph &g=mapstorage->graph;
117 for (NodeIt i(g); i!=INVALID; ++i)
119 std::ostringstream text;
120 text << (*((mapstorage->nodemap_storage)["label"]))[i];
121 source.prepend_text(text.str());
122 target.prepend_text(text.str());