# HG changeset patch # User hegyi # Date 1136563628 0 # Node ID 0ace7edbb06fbf66323a726089edb3238e148e83 # Parent 7c2e71835de7cf38ccfdeb79200197c315bdc7a6 In algorithm window maps can be selected and reated through MapSelector widget. diff -r 7c2e71835de7 -r 0ace7edbb06f algobox.cc --- a/algobox.cc Fri Jan 06 14:44:04 2006 +0000 +++ b/algobox.cc Fri Jan 06 16:07:08 2006 +0000 @@ -73,11 +73,13 @@ } for(int i=0;i<(int)nodemapcbts.size();i++) { - update_cbt(nml, *(nodemapcbts[i])); + (nodemapcbts[i])->update_list(nml); + //update_cbt(nml, *(nodemapcbts[i])); } for(int i=0;i<(int)edgemapcbts.size();i++) { - update_cbt(eml, *(edgemapcbts[i])); + (edgemapcbts[i])->update_list(eml); + //update_cbt(eml, *(edgemapcbts[i])); } } @@ -106,7 +108,7 @@ { pack_start(*(new Gtk::HSeparator())); - label=new Gtk::Label("Specific part for each algorithm."); + Gtk::Label * label=new Gtk::Label("Specific part for each algorithm."); pack_start(*label); pack_start(*(new Gtk::HSeparator())); @@ -118,17 +120,15 @@ nodemapcbts.resize(NODE_INPUT_NUM); for(int i=0;i<(int)nodemapcbts.size();i++) { - Gtk::HBox * hbox=new Gtk::HBox(); + std::vector empty_vector; std::ostringstream o; o << "NodeInput " << i+1 << ":"; - label=new Gtk::Label(o.str()); - nodemapcbts[i]=new Gtk::ComboBoxText(); + nodemapcbts[i]=new MapSelector(empty_vector,"",o.str(),false, false); + nodemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - hbox->pack_start(*label); - hbox->pack_start(*(nodemapcbts[i])); - pack_start(*hbox); + pack_start(*(nodemapcbts[i])); } pack_start(*(new Gtk::HSeparator())); @@ -136,17 +136,15 @@ edgemapcbts.resize(EDGE_INPUT_NUM); for(int i=0;i<(int)edgemapcbts.size();i++) { - Gtk::HBox * hbox=new Gtk::HBox(); + std::vector empty_vector; std::ostringstream o; o << "EdgeInput " << i+1 << ":"; - label=new Gtk::Label(o.str()); - edgemapcbts[i]=new Gtk::ComboBoxText(); + edgemapcbts[i]=new MapSelector(empty_vector,"",o.str(),true, false); + edgemapcbts[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - hbox->pack_start(*label); - hbox->pack_start(*(edgemapcbts[i])); - pack_start(*hbox); + pack_start(*(edgemapcbts[i])); } pack_start(*(new Gtk::HSeparator())); @@ -170,3 +168,8 @@ update_maplist(NULL); } } + +void AlgoBox::emit_new_map_signal(bool itisedge) +{ + signal_newmapwin_need.emit(tabcbt.get_active_text(), itisedge); +} diff -r 7c2e71835de7 -r 0ace7edbb06f algobox.h --- a/algobox.h Fri Jan 06 14:44:04 2006 +0000 +++ b/algobox.h Fri Jan 06 16:07:08 2006 +0000 @@ -7,19 +7,19 @@ #include #include +#include #include #include class AlgoBox : public Gtk::VBox { sigc::signal signal_maplist_need; - - Gtk::ComboBoxText tabcbt; + sigc::signal signal_newmapwin_need; protected: - Gtk::Label * label; - std::vector nodemapcbts; - std::vector edgemapcbts; + Gtk::ComboBoxText tabcbt; + std::vector nodemapcbts; + std::vector edgemapcbts; MapStorage * mapstorage; @@ -30,6 +30,7 @@ virtual void init(std::vector); sigc::signal signal_maplist_needed(); + sigc::signal signal_newmapwin_needed(){return signal_newmapwin_need;}; void emit_tab_change(); void update_tablist( std::vector< std::string > tl ); @@ -43,5 +44,7 @@ virtual void run(); virtual void build_box(); + + virtual void emit_new_map_signal(bool); }; #endif //ALGOBOX_H diff -r 7c2e71835de7 -r 0ace7edbb06f algowin.cc --- a/algowin.cc Fri Jan 06 14:44:04 2006 +0000 +++ b/algowin.cc Fri Jan 06 16:07:08 2006 +0000 @@ -43,6 +43,7 @@ break; } ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change)); + ab->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_new_map_signal)); runbutton=new Gtk::Button("Run"); runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run)); diff -r 7c2e71835de7 -r 0ace7edbb06f algowin.h --- a/algowin.h Fri Jan 06 14:44:04 2006 +0000 +++ b/algowin.h Fri Jan 06 16:07:08 2006 +0000 @@ -25,14 +25,17 @@ protected: sigc::signal signal_closed; sigc::signal signal_maplist_need; + sigc::signal signal_newmapwin_need; public: bool closeIfEscapeIsPressed(GdkEventKey* e); sigc::signal signal_closing(); sigc::signal signal_maplist_needed(); + sigc::signal signal_newmapwin_needed(){return signal_newmapwin_need;}; void emit_tab_change(std::string); + void emit_new_map_signal(std::string tabname, bool itisedge){signal_newmapwin_need.emit(tabname, itisedge);}; AlgoWin(int, std::vector); diff -r 7c2e71835de7 -r 0ace7edbb06f kruskalbox.cc --- a/kruskalbox.cc Fri Jan 06 14:44:04 2006 +0000 +++ b/kruskalbox.cc Fri Jan 06 16:07:08 2006 +0000 @@ -9,62 +9,61 @@ void KruskalBox::run() { - Graph g=mapstorage->graph; - Graph::EdgeMap * inputmap= - ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]); - Graph::EdgeMap outputmap(g); - double res=kruskal(g, *inputmap, outputmap); + if( + tabcbt.get_active_text()!="" && + (edgemapcbts[INPUT])->get_active_text()!="" && + (edgemapcbts[OUTPUT])->get_active_text()!="" + ) + { - for (EdgeIt i(g); i!=INVALID; ++i) - { - if(outputmap[i]) - { - (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> - get_active_text()]))[i]=1; - } - else - { - (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> - get_active_text()]))[i]=0; - } - } + Graph g=mapstorage->graph; + Graph::EdgeMap * inputmap= + ((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]); + Graph::EdgeMap outputmap(g); + double res=kruskal(g, *inputmap, outputmap); - std::ostringstream o; - o << "Result: " << res; - resultlabel.set_text(o.str()); + for (EdgeIt i(g); i!=INVALID; ++i) + { + if(outputmap[i]) + { + (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> + get_active_text()]))[i]=1; + } + else + { + (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])-> + get_active_text()]))[i]=0; + } + } - mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text()); - // mapstorage->changeActiveMap(true, E_COLOR, - // (edgemapcbts[OUTPUT])->get_active_text()); - // mapstorage->changeActiveMap(true, E_TEXT, - // (edgemapcbts[INPUT])->get_active_text()); + std::ostringstream o; + o << "Result: " << res; + resultlabel.set_text(o.str()); + + mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text()); + // mapstorage->changeActiveMap(true, E_COLOR, + // (edgemapcbts[OUTPUT])->get_active_text()); + // mapstorage->changeActiveMap(true, E_TEXT, + // (edgemapcbts[INPUT])->get_active_text()); + } } void KruskalBox::build_box() { + std::vector empty_vector; + edgemapcbts.resize(MAP_NUM); - Gtk::HBox * hbox; - hbox=new Gtk::HBox(); + edgemapcbts[0]=new MapSelector(empty_vector,"","Edgecosts: ",true, false); + edgemapcbts[0]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - label=new Gtk::Label("Edgecosts: "); + pack_start(*(edgemapcbts[INPUT])); - edgemapcbts[0]=new Gtk::ComboBoxText(); + edgemapcbts[1]=new MapSelector(empty_vector,"","Edges of tree here: ",true, false); + edgemapcbts[1]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoBox::emit_new_map_signal)); - hbox->pack_start(*label); - hbox->pack_start(*(edgemapcbts[INPUT])); - pack_start(*hbox); - - hbox=new Gtk::HBox(); - - label=new Gtk::Label("Edges of tree here: "); - - edgemapcbts[1]=new Gtk::ComboBoxText(); - - hbox->pack_start(*label); - hbox->pack_start(*(edgemapcbts[OUTPUT])); - pack_start(*hbox); + pack_start(*(edgemapcbts[OUTPUT])); resultlabel.set_text("Result: algorithm is not run yet."); pack_start(resultlabel); diff -r 7c2e71835de7 -r 0ace7edbb06f main_win.cc --- a/main_win.cc Fri Jan 06 14:44:04 2006 +0000 +++ b/main_win.cc Fri Jan 06 16:07:08 2006 +0000 @@ -412,6 +412,7 @@ AlgoWin * aw=new AlgoWin(algoid, tabnames); aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps)); + aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString)); aws.insert(aw); aw->show(); } @@ -458,6 +459,15 @@ } } +void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge) +{ + int i=0; + for(;((i::iterator nbti=tabs.begin(); diff -r 7c2e71835de7 -r 0ace7edbb06f main_win.h --- a/main_win.h Fri Jan 06 14:44:04 2006 +0000 +++ b/main_win.h Fri Jan 06 16:07:08 2006 +0000 @@ -79,6 +79,7 @@ virtual void changeEditorialTool(int); virtual void createNewMapWinAfterSignal(NoteBookTab *, bool); + virtual void createNewMapWinTabString(std::string, bool); virtual void createNewMapWin(); //Notebook handlers diff -r 7c2e71835de7 -r 0ace7edbb06f map_win.cc --- a/map_win.cc Fri Jan 06 14:44:04 2006 +0000 +++ b/map_win.cc Fri Jan 06 16:07:08 2006 +0000 @@ -24,7 +24,7 @@ for(int i=0;i ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false) +MapSelector::MapSelector(std::vector ml, std::string act, std::string labeltext, bool edge, bool d):def(d),itisedge(edge),set_new_map(false) { update_list(ml); @@ -22,14 +22,7 @@ false ); - if(itisedge) - { - label=new Gtk::Label(edge_property_strings[id]); - } - else - { - label=new Gtk::Label(node_property_strings[id]); - } + label=new Gtk::Label(labeltext); label->set_width_chars(longest_property_string_length); @@ -71,7 +64,10 @@ { cbt.append_text(*emsi); } - cbt.prepend_text("Default values"); + if(def) + { + cbt.prepend_text("Default values"); + } if(prev_act!=-1) { cbt.set_active(prev_act); diff -r 7c2e71835de7 -r 0ace7edbb06f new_map_win.cc --- a/new_map_win.cc Fri Jan 06 14:44:04 2006 +0000 +++ b/new_map_win.cc Fri Jan 06 16:07:08 2006 +0000 @@ -114,13 +114,7 @@ } else { - char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())]; - for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++) - { - def_val_ch[j]=ch2var[ polishform[i] ][j]; - } - polishstack.push(atof(def_val_ch)); - delete def_val_ch; + polishstack.push(atof(ch2var[ polishform[i] ].c_str())); } operation=false; break; @@ -201,13 +195,7 @@ } else { - char * def_val_ch=new char [(int)(ch2var[ polishform[i] ].length())]; - for(int j=0;j<(int)(ch2var[ polishform[i] ].length());j++) - { - def_val_ch[j]=ch2var[ polishform[i] ][j]; - } - polishstack.push(atof(def_val_ch)); - delete def_val_ch; + polishstack.push(atof(ch2var[ polishform[i] ].c_str())); } operation=false; break;