In algorithm window maps can be selected and reated through MapSelector widget.
1.1 --- a/gui/algobox.cc Fri Jan 06 14:44:04 2006 +0000
1.2 +++ b/gui/algobox.cc Fri Jan 06 16:07:08 2006 +0000
1.3 @@ -73,11 +73,13 @@
1.4 }
1.5 for(int i=0;i<(int)nodemapcbts.size();i++)
1.6 {
1.7 - update_cbt(nml, *(nodemapcbts[i]));
1.8 + (nodemapcbts[i])->update_list(nml);
1.9 + //update_cbt(nml, *(nodemapcbts[i]));
1.10 }
1.11 for(int i=0;i<(int)edgemapcbts.size();i++)
1.12 {
1.13 - update_cbt(eml, *(edgemapcbts[i]));
1.14 + (edgemapcbts[i])->update_list(eml);
1.15 + //update_cbt(eml, *(edgemapcbts[i]));
1.16 }
1.17 }
1.18
1.19 @@ -106,7 +108,7 @@
1.20 {
1.21 pack_start(*(new Gtk::HSeparator()));
1.22
1.23 - label=new Gtk::Label("Specific part for each algorithm.");
1.24 + Gtk::Label * label=new Gtk::Label("Specific part for each algorithm.");
1.25
1.26 pack_start(*label);
1.27 pack_start(*(new Gtk::HSeparator()));
1.28 @@ -118,17 +120,15 @@
1.29 nodemapcbts.resize(NODE_INPUT_NUM);
1.30 for(int i=0;i<(int)nodemapcbts.size();i++)
1.31 {
1.32 - Gtk::HBox * hbox=new Gtk::HBox();
1.33 + std::vector<std::string> empty_vector;
1.34
1.35 std::ostringstream o;
1.36 o << "NodeInput " << i+1 << ":";
1.37 - label=new Gtk::Label(o.str());
1.38
1.39 - nodemapcbts[i]=new Gtk::ComboBoxText();
1.40 + nodemapcbts[i]=new MapSelector(empty_vector,"",o.str(),false, false);
1.41 + nodemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
1.42
1.43 - hbox->pack_start(*label);
1.44 - hbox->pack_start(*(nodemapcbts[i]));
1.45 - pack_start(*hbox);
1.46 + pack_start(*(nodemapcbts[i]));
1.47 }
1.48
1.49 pack_start(*(new Gtk::HSeparator()));
1.50 @@ -136,17 +136,15 @@
1.51 edgemapcbts.resize(EDGE_INPUT_NUM);
1.52 for(int i=0;i<(int)edgemapcbts.size();i++)
1.53 {
1.54 - Gtk::HBox * hbox=new Gtk::HBox();
1.55 + std::vector<std::string> empty_vector;
1.56
1.57 std::ostringstream o;
1.58 o << "EdgeInput " << i+1 << ":";
1.59 - label=new Gtk::Label(o.str());
1.60
1.61 - edgemapcbts[i]=new Gtk::ComboBoxText();
1.62 + edgemapcbts[i]=new MapSelector(empty_vector,"",o.str(),true, false);
1.63 + edgemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
1.64
1.65 - hbox->pack_start(*label);
1.66 - hbox->pack_start(*(edgemapcbts[i]));
1.67 - pack_start(*hbox);
1.68 + pack_start(*(edgemapcbts[i]));
1.69 }
1.70
1.71 pack_start(*(new Gtk::HSeparator()));
1.72 @@ -170,3 +168,8 @@
1.73 update_maplist(NULL);
1.74 }
1.75 }
1.76 +
1.77 +void AlgoBox::emit_new_map_signal(bool itisedge)
1.78 +{
1.79 + signal_newmapwin_need.emit(tabcbt.get_active_text(), itisedge);
1.80 +}
2.1 --- a/gui/algobox.h Fri Jan 06 14:44:04 2006 +0000
2.2 +++ b/gui/algobox.h Fri Jan 06 16:07:08 2006 +0000
2.3 @@ -7,19 +7,19 @@
2.4
2.5 #include <all_include.h>
2.6 #include <mapstorage.h>
2.7 +#include <mapselector.h>
2.8 #include <libgnomecanvasmm.h>
2.9 #include <libgnomecanvasmm/polygon.h>
2.10
2.11 class AlgoBox : public Gtk::VBox
2.12 {
2.13 sigc::signal<void, std::string> signal_maplist_need;
2.14 -
2.15 - Gtk::ComboBoxText tabcbt;
2.16 + sigc::signal<void, std::string, bool> signal_newmapwin_need;
2.17
2.18 protected:
2.19 - Gtk::Label * label;
2.20 - std::vector<Gtk::ComboBoxText *> nodemapcbts;
2.21 - std::vector<Gtk::ComboBoxText *> edgemapcbts;
2.22 + Gtk::ComboBoxText tabcbt;
2.23 + std::vector<MapSelector *> nodemapcbts;
2.24 + std::vector<MapSelector *> edgemapcbts;
2.25
2.26 MapStorage * mapstorage;
2.27
2.28 @@ -30,6 +30,7 @@
2.29 virtual void init(std::vector<std::string>);
2.30
2.31 sigc::signal<void, std::string> signal_maplist_needed();
2.32 + sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
2.33 void emit_tab_change();
2.34
2.35 void update_tablist( std::vector< std::string > tl );
2.36 @@ -43,5 +44,7 @@
2.37 virtual void run();
2.38
2.39 virtual void build_box();
2.40 +
2.41 + virtual void emit_new_map_signal(bool);
2.42 };
2.43 #endif //ALGOBOX_H
3.1 --- a/gui/algowin.cc Fri Jan 06 14:44:04 2006 +0000
3.2 +++ b/gui/algowin.cc Fri Jan 06 16:07:08 2006 +0000
3.3 @@ -43,6 +43,7 @@
3.4 break;
3.5 }
3.6 ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change));
3.7 + ab->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_new_map_signal));
3.8
3.9 runbutton=new Gtk::Button("Run");
3.10 runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run));
4.1 --- a/gui/algowin.h Fri Jan 06 14:44:04 2006 +0000
4.2 +++ b/gui/algowin.h Fri Jan 06 16:07:08 2006 +0000
4.3 @@ -25,14 +25,17 @@
4.4 protected:
4.5 sigc::signal<void, AlgoWin *> signal_closed;
4.6 sigc::signal<void, AlgoWin *, std::string> signal_maplist_need;
4.7 + sigc::signal<void, std::string, bool> signal_newmapwin_need;
4.8
4.9 public:
4.10 bool closeIfEscapeIsPressed(GdkEventKey* e);
4.11
4.12 sigc::signal<void, AlgoWin *> signal_closing();
4.13 sigc::signal<void, AlgoWin *, std::string> signal_maplist_needed();
4.14 + sigc::signal<void, std::string, bool> signal_newmapwin_needed(){return signal_newmapwin_need;};
4.15
4.16 void emit_tab_change(std::string);
4.17 + void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);};
4.18
4.19 AlgoWin(int, std::vector<std::string>);
4.20
5.1 --- a/gui/kruskalbox.cc Fri Jan 06 14:44:04 2006 +0000
5.2 +++ b/gui/kruskalbox.cc Fri Jan 06 16:07:08 2006 +0000
5.3 @@ -9,62 +9,61 @@
5.4
5.5 void KruskalBox::run()
5.6 {
5.7 - Graph g=mapstorage->graph;
5.8 - Graph::EdgeMap<double> * inputmap=
5.9 - ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
5.10 - Graph::EdgeMap<bool> outputmap(g);
5.11 - double res=kruskal(g, *inputmap, outputmap);
5.12 + if(
5.13 + tabcbt.get_active_text()!="" &&
5.14 + (edgemapcbts[INPUT])->get_active_text()!="" &&
5.15 + (edgemapcbts[OUTPUT])->get_active_text()!=""
5.16 + )
5.17 + {
5.18
5.19 - for (EdgeIt i(g); i!=INVALID; ++i)
5.20 - {
5.21 - if(outputmap[i])
5.22 - {
5.23 - (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
5.24 - get_active_text()]))[i]=1;
5.25 - }
5.26 - else
5.27 - {
5.28 - (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
5.29 - get_active_text()]))[i]=0;
5.30 - }
5.31 - }
5.32 + Graph g=mapstorage->graph;
5.33 + Graph::EdgeMap<double> * inputmap=
5.34 + ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
5.35 + Graph::EdgeMap<bool> outputmap(g);
5.36 + double res=kruskal(g, *inputmap, outputmap);
5.37
5.38 - std::ostringstream o;
5.39 - o << "Result: " << res;
5.40 - resultlabel.set_text(o.str());
5.41 + for (EdgeIt i(g); i!=INVALID; ++i)
5.42 + {
5.43 + if(outputmap[i])
5.44 + {
5.45 + (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
5.46 + get_active_text()]))[i]=1;
5.47 + }
5.48 + else
5.49 + {
5.50 + (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
5.51 + get_active_text()]))[i]=0;
5.52 + }
5.53 + }
5.54
5.55 - mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
5.56 - // mapstorage->changeActiveMap(true, E_COLOR,
5.57 - // (edgemapcbts[OUTPUT])->get_active_text());
5.58 - // mapstorage->changeActiveMap(true, E_TEXT,
5.59 - // (edgemapcbts[INPUT])->get_active_text());
5.60 + std::ostringstream o;
5.61 + o << "Result: " << res;
5.62 + resultlabel.set_text(o.str());
5.63 +
5.64 + mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
5.65 + // mapstorage->changeActiveMap(true, E_COLOR,
5.66 + // (edgemapcbts[OUTPUT])->get_active_text());
5.67 + // mapstorage->changeActiveMap(true, E_TEXT,
5.68 + // (edgemapcbts[INPUT])->get_active_text());
5.69
5.70 + }
5.71 }
5.72
5.73 void KruskalBox::build_box()
5.74 {
5.75 + std::vector<std::string> empty_vector;
5.76 +
5.77 edgemapcbts.resize(MAP_NUM);
5.78 - Gtk::HBox * hbox;
5.79
5.80 - hbox=new Gtk::HBox();
5.81 + edgemapcbts[0]=new MapSelector(empty_vector,"","Edgecosts: ",true, false);
5.82 + edgemapcbts[0]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
5.83
5.84 - label=new Gtk::Label("Edgecosts: ");
5.85 + pack_start(*(edgemapcbts[INPUT]));
5.86
5.87 - edgemapcbts[0]=new Gtk::ComboBoxText();
5.88 + edgemapcbts[1]=new MapSelector(empty_vector,"","Edges of tree here: ",true, false);
5.89 + edgemapcbts[1]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal));
5.90
5.91 - hbox->pack_start(*label);
5.92 - hbox->pack_start(*(edgemapcbts[INPUT]));
5.93 - pack_start(*hbox);
5.94 -
5.95 - hbox=new Gtk::HBox();
5.96 -
5.97 - label=new Gtk::Label("Edges of tree here: ");
5.98 -
5.99 - edgemapcbts[1]=new Gtk::ComboBoxText();
5.100 -
5.101 - hbox->pack_start(*label);
5.102 - hbox->pack_start(*(edgemapcbts[OUTPUT]));
5.103 - pack_start(*hbox);
5.104 + pack_start(*(edgemapcbts[OUTPUT]));
5.105
5.106 resultlabel.set_text("Result: algorithm is not run yet.");
5.107 pack_start(resultlabel);
6.1 --- a/gui/main_win.cc Fri Jan 06 14:44:04 2006 +0000
6.2 +++ b/gui/main_win.cc Fri Jan 06 16:07:08 2006 +0000
6.3 @@ -412,6 +412,7 @@
6.4 AlgoWin * aw=new AlgoWin(algoid, tabnames);
6.5 aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
6.6 aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
6.7 + aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString));
6.8 aws.insert(aw);
6.9 aw->show();
6.10 }
6.11 @@ -458,6 +459,15 @@
6.12 }
6.13 }
6.14
6.15 +void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge)
6.16 +{
6.17 + int i=0;
6.18 + for(;((i<tabnames.size())&&(tabnames[i]!=tabname));i++)
6.19 + {
6.20 + }
6.21 + createNewMapWinAfterSignal(tabs[i], itisedge);
6.22 +}
6.23 +
6.24 void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge)
6.25 {
6.26 std::vector<NoteBookTab*>::iterator nbti=tabs.begin();
7.1 --- a/gui/main_win.h Fri Jan 06 14:44:04 2006 +0000
7.2 +++ b/gui/main_win.h Fri Jan 06 16:07:08 2006 +0000
7.3 @@ -79,6 +79,7 @@
7.4 virtual void changeEditorialTool(int);
7.5
7.6 virtual void createNewMapWinAfterSignal(NoteBookTab *, bool);
7.7 + virtual void createNewMapWinTabString(std::string, bool);
7.8 virtual void createNewMapWin();
7.9
7.10 //Notebook handlers
8.1 --- a/gui/map_win.cc Fri Jan 06 14:44:04 2006 +0000
8.2 +++ b/gui/map_win.cc Fri Jan 06 16:07:08 2006 +0000
8.3 @@ -24,7 +24,7 @@
8.4
8.5 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
8.6 {
8.7 - e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), i, true);
8.8 + e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
8.9
8.10 (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
8.11
8.12 @@ -44,7 +44,7 @@
8.13
8.14 for(int i=0;i<NODE_PROPERTY_NUM;i++)
8.15 {
8.16 - n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), i, false);
8.17 + n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false);
8.18
8.19 (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
8.20
9.1 --- a/gui/mapselector.cc Fri Jan 06 14:44:04 2006 +0000
9.2 +++ b/gui/mapselector.cc Fri Jan 06 16:07:08 2006 +0000
9.3 @@ -1,6 +1,6 @@
9.4 #include "mapselector.h"
9.5
9.6 -MapSelector::MapSelector(std::vector<std::string> ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false)
9.7 +MapSelector::MapSelector(std::vector<std::string> ml, std::string act, std::string labeltext, bool edge, bool d):def(d),itisedge(edge),set_new_map(false)
9.8 {
9.9 update_list(ml);
9.10
9.11 @@ -22,14 +22,7 @@
9.12 false
9.13 );
9.14
9.15 - if(itisedge)
9.16 - {
9.17 - label=new Gtk::Label(edge_property_strings[id]);
9.18 - }
9.19 - else
9.20 - {
9.21 - label=new Gtk::Label(node_property_strings[id]);
9.22 - }
9.23 + label=new Gtk::Label(labeltext);
9.24
9.25 label->set_width_chars(longest_property_string_length);
9.26
9.27 @@ -71,7 +64,10 @@
9.28 {
9.29 cbt.append_text(*emsi);
9.30 }
9.31 - cbt.prepend_text("Default values");
9.32 + if(def)
9.33 + {
9.34 + cbt.prepend_text("Default values");
9.35 + }
9.36 if(prev_act!=-1)
9.37 {
9.38 cbt.set_active(prev_act);
10.1 --- a/gui/new_map_win.cc Fri Jan 06 14:44:04 2006 +0000
10.2 +++ b/gui/new_map_win.cc Fri Jan 06 16:07:08 2006 +0000
10.3 @@ -114,13 +114,7 @@
10.4 }
10.5 else
10.6 {
10.7 - char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())];
10.8 - for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++)
10.9 - {
10.10 - def_val_ch[j]=ch2var[ polishform[i] ][j];
10.11 - }
10.12 - polishstack.push(atof(def_val_ch));
10.13 - delete def_val_ch;
10.14 + polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
10.15 }
10.16 operation=false;
10.17 break;
10.18 @@ -201,13 +195,7 @@
10.19 }
10.20 else
10.21 {
10.22 - char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())];
10.23 - for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++)
10.24 - {
10.25 - def_val_ch[j]=ch2var[ polishform[i] ][j];
10.26 - }
10.27 - polishstack.push(atof(def_val_ch));
10.28 - delete def_val_ch;
10.29 + polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
10.30 }
10.31 operation=false;
10.32 break;