1 #include <algobox.h> |
1 #include <algobox.h> |
2 |
2 |
3 enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes; |
3 enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes; |
4 enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges; |
4 enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges; |
5 |
5 |
6 AlgoBox::AlgoBox(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames) |
6 AlgoBox::AlgoBox(std::vector<std::string> tabnames) |
7 { |
7 { |
8 init(tabnames, nodemapnames, edgemapnames); |
8 init(tabnames); |
9 } |
9 } |
10 |
10 |
11 void AlgoBox::init(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames) |
11 void AlgoBox::init(std::vector<std::string> tabnames) |
12 { |
12 { |
13 set_spacing(5); |
13 set_spacing(5); |
14 |
14 |
15 update_tablist(tabnames); |
15 update_tablist(tabnames); |
16 |
16 |
17 //if active tab is changed, the map names in cbt/s have to be updated |
17 //if active tab is changed, the map names in cbt/s have to be updated |
18 tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change)); |
18 tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change)); |
19 |
19 |
20 pack_start(tabcbt); |
20 pack_start(tabcbt); |
21 |
|
22 build_box(); |
21 build_box(); |
23 |
|
24 update_maplist(nodemapnames, edgemapnames); |
|
25 |
22 |
26 show_all_children(); |
23 show_all_children(); |
27 }; |
24 }; |
28 |
25 |
29 void AlgoBox::update_cbt(std::vector< std::string > stringlist, Gtk::ComboBoxText & cbt) |
26 void AlgoBox::update_cbt(std::vector< std::string > stringlist, Gtk::ComboBoxText & cbt) |
50 { |
47 { |
51 cbt.set_active(prev_act); |
48 cbt.set_active(prev_act); |
52 } |
49 } |
53 else if(actptr>0) //so there is item in the list |
50 else if(actptr>0) //so there is item in the list |
54 { |
51 { |
55 cbt.set_active(0); |
52 //cbt.set_active(0); |
56 } |
53 } |
57 } |
54 } |
58 |
55 |
59 void AlgoBox::update_tablist( std::vector< std::string > tl ) |
56 void AlgoBox::update_tablist( std::vector< std::string > tl ) |
60 { |
57 { |
61 update_cbt(tl, tabcbt); |
58 update_cbt(tl, tabcbt); |
62 emit_tab_change(); |
59 emit_tab_change(); |
63 } |
60 } |
64 |
61 |
65 void AlgoBox::update_maplist( std::vector< std::string > nml, std::vector< std::string > eml ) |
62 void AlgoBox::update_maplist( void * ms) |
66 { |
63 { |
|
64 mapstorage=(MapStorage *)ms; |
|
65 std::vector<std::string> nml; |
|
66 std::vector<std::string> eml; |
|
67 if(mapstorage!=NULL) |
|
68 { |
|
69 mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed)); |
|
70 mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed)); |
|
71 nml=mapstorage->getNodeMapList(); |
|
72 eml=mapstorage->getNodeMapList(); |
|
73 } |
67 for(int i=0;i<(int)nodemapcbts.size();i++) |
74 for(int i=0;i<(int)nodemapcbts.size();i++) |
68 { |
75 { |
69 update_cbt(nml, *(nodemapcbts[i])); |
76 update_cbt(nml, *(nodemapcbts[i])); |
70 } |
77 } |
71 for(int i=0;i<(int)edgemapcbts.size();i++) |
78 for(int i=0;i<(int)edgemapcbts.size();i++) |
72 { |
79 { |
73 update_cbt(eml, *(edgemapcbts[i])); |
80 update_cbt(eml, *(edgemapcbts[i])); |
|
81 } |
|
82 } |
|
83 |
|
84 void AlgoBox::nodemaplist_changed(std::string newmap) |
|
85 { |
|
86 for(int i=0;i<(int)nodemapcbts.size();i++) |
|
87 { |
|
88 (nodemapcbts[i])->append_text(newmap); |
|
89 } |
|
90 } |
|
91 |
|
92 void AlgoBox::edgemaplist_changed(std::string newmap) |
|
93 { |
|
94 for(int i=0;i<(int)edgemapcbts.size();i++) |
|
95 { |
|
96 (edgemapcbts[i])->append_text(newmap); |
74 } |
97 } |
75 } |
98 } |
76 |
99 |
77 void AlgoBox::run() |
100 void AlgoBox::run() |
78 { |
101 { |