# HG changeset patch # User hegyi # Date 1132596200 0 # Node ID e9f8f44f12a345714b9236d4f876f0eb10e39e42 # Parent 4042761b21e3e926d9f944420e664fad87ef3095 NewMapWin has become Dialog instead of Window. Therefore it is created dynamically, when there is need for it, instead of keeping one instance in memory. This solution is slower, but more correct than before. diff -r 4042761b21e3 -r e9f8f44f12a3 Doxyfile --- a/Doxyfile Mon Nov 21 12:07:05 2005 +0000 +++ b/Doxyfile Mon Nov 21 18:03:20 2005 +0000 @@ -25,7 +25,7 @@ ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES -STRIP_FROM_PATH = /home/alpar/projects/ETIK/hugo/gui/ +STRIP_FROM_PATH = . STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO @@ -82,7 +82,7 @@ #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = /home/alpar/projects/ETIK/hugo/gui +INPUT = . FILE_PATTERNS = *.c \ *.cc \ *.cxx \ diff -r 4042761b21e3 -r e9f8f44f12a3 main_win.cc --- a/main_win.cc Mon Nov 21 12:07:05 2005 +0000 +++ b/main_win.cc Mon Nov 21 18:03:20 2005 +0000 @@ -2,8 +2,7 @@ #include "icons/guipixbufs.h" MainWin::MainWin() : - newmapwin("Creating new map", gd_canvas), - mapwin("Map Setup", mapstorage, gd_canvas, newmapwin), + mapwin("Map Setup", mapstorage, gd_canvas), gd_canvas(mapstorage, mapwin, (Gtk::Window *)this) { set_title ("unsaved file - " + prog_name); @@ -121,7 +120,7 @@ sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) ); ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), - sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) ); + sigc::mem_fun (new NewMapWin("NewMapWin", gd_canvas), &NewMapWin::show ) ); uim=Gtk::UIManager::create(); uim->insert_action_group(ag); diff -r 4042761b21e3 -r e9f8f44f12a3 main_win.h --- a/main_win.h Mon Nov 21 12:07:05 2005 +0000 +++ b/main_win.h Mon Nov 21 18:03:20 2005 +0000 @@ -25,9 +25,6 @@ void readFile(const std::string &); protected: - ///We need to store newmapwin, to be able to set the appropriate values for properties of new map. - NewMapWin newmapwin; - ///Window of map-showing setup. Its type is \ref MapWin MapWin mapwin; diff -r 4042761b21e3 -r e9f8f44f12a3 map_win.cc --- a/map_win.cc Mon Nov 21 12:07:05 2005 +0000 +++ b/map_win.cc Mon Nov 21 18:03:20 2005 +0000 @@ -10,7 +10,7 @@ return true; } -MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc, NewMapWin & newmapwin):gdc(grdispc),ms(mapst), nmw(newmapwin) +MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) { set_title(title); set_default_size(200, 50); @@ -23,7 +23,7 @@ for(int i=0;irun(); } void MapWin::MapSelector::update_list() diff -r 4042761b21e3 -r e9f8f44f12a3 new_map_win.cc --- a/new_map_win.cc Mon Nov 21 12:07:05 2005 +0000 +++ b/new_map_win.cc Mon Nov 21 18:03:20 2005 +0000 @@ -9,13 +9,13 @@ return true; } -NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc):gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap") +NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap") { - set_title(title); set_default_size(200, 50); signal_key_press_event().connect(sigc::mem_fun(*this, &NewMapWin::closeIfEscapeIsPressed)); + Gtk::VBox * vbox=get_vbox(); //entries table=new Gtk::Table(3, 2, false); @@ -37,236 +37,229 @@ //node vs. edge map selector Gtk::RadioButton::Group group = node.get_group(); edge.set_group(group); + + if(edgenode) + { + (*table).attach(node,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3); + (*table).attach(edge,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3); + } + else + { + if(itisedge) + { + edge.set_active(); + } + else + { + node.set_active(); + } + } - (*table).attach(node,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3); - (*table).attach(edge,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3); - - vbox.pack_start(*table); + vbox->pack_start(*table); //OK button - button=new Gtk::Button("OK"); - - button->signal_clicked().connect - ( - sigc::mem_fun(*this, &NewMapWin::buttonPressed) - ); - - - vbox.pack_start(*button); - - add(vbox); + add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); show_all_children(); } -void NewMapWin::showByPreChoose(bool itisedge) +void NewMapWin::on_response(int response_id) { - if(itisedge) + if(response_id==Gtk::RESPONSE_OK) { - edge.set_active(); - } - else - { - node.set_active(); - } - node.hide(); - edge.hide(); - show(); -} + double def_val=0; -void NewMapWin::buttonPressed() -{ - double def_val=0; + //get and formulate text + std::string def_val_str=default_value.get_text(); + std::string polishform=string2Polishform(def_val_str,edge.get_active()); - //get and formulate text - std::string def_val_str=default_value.get_text(); - std::string polishform=string2Polishform(def_val_str,edge.get_active()); + //get name of text + std::string mapname=name.get_text(); - //get name of text - std::string mapname=name.get_text(); + if(!mapname.empty()&&!polishform.empty()) + { + int abortion=0; + if(edge.get_active()) + { + //create the new map + Graph::EdgeMap * emptr=new Graph::EdgeMap (gdc.mapstorage.graph); - if(!mapname.empty()&&!polishform.empty()) - { - int abortion=0; - if(edge.get_active()) - { - //create the new map - Graph::EdgeMap * emptr=new Graph::EdgeMap (gdc.mapstorage.graph); - - std::stack polishstack; + std::stack polishstack; - for(EdgeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) - { - for(int i=0;i<(int)polishform.size();i++) + for(EdgeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) { - double op1, op2; - bool operation=true; - switch(polishform[i]) + for(int i=0;i<(int)polishform.size();i++) { - case '+': - case '-': - case '/': - case '*': - op1=polishstack.top(); - polishstack.pop(); - op2=polishstack.top(); - polishstack.pop(); - break; - default: - //substitute variable - std::map< std::string,Graph::EdgeMap * > ems=gdc.mapstorage.edgemap_storage; - bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end()); - if(itisvar) - { - polishstack.push( (*(gdc.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]); - } - 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)); - } - operation=false; - break; - } - if(operation) - { - double res; + double op1, op2; + bool operation=true; switch(polishform[i]) { case '+': - res=op1+op2; - break; case '-': - res=op2-op1; - break; case '/': - res=op2/op1; - break; case '*': - res=op1*op2; + op1=polishstack.top(); + polishstack.pop(); + op2=polishstack.top(); + polishstack.pop(); break; default: - std::cout << "How could we get here?" << std::endl; + //substitute variable + std::map< std::string,Graph::EdgeMap * > ems=gdc.mapstorage.edgemap_storage; + bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end()); + if(itisvar) + { + polishstack.push( (*(gdc.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]); + } + 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)); + } + operation=false; break; } - polishstack.push(res); + if(operation) + { + double res; + switch(polishform[i]) + { + case '+': + res=op1+op2; + break; + case '-': + res=op2-op1; + break; + case '/': + res=op2/op1; + break; + case '*': + res=op1*op2; + break; + default: + std::cout << "How could we get here?" << std::endl; + break; + } + polishstack.push(res); + } } + (*emptr)[k]=polishstack.top(); } - (*emptr)[k]=polishstack.top(); + + //if addition was not successful addEdgeMap returns one. + //cause can be that there is already a map named like the new one + if(gdc.mapstorage.addEdgeMap(mapname, emptr, def_val)) + { + abortion=1; + } + + //add it to the list of the displayable maps + gdc.mapwin.registerNewEdgeMap(mapname); + + //display it + gdc.changeEdgeText(mapname); } + else //!edge.get_active() + { + //create the new map + Graph::NodeMap * emptr=new Graph::NodeMap (gdc.mapstorage.graph); - //if addition was not successful addEdgeMap returns one. - //cause can be that there is already a map named like the new one - if(gdc.mapstorage.addEdgeMap(mapname, emptr, def_val)) - { - abortion=1; - } - - //add it to the list of the displayable maps - gdc.mapwin.registerNewEdgeMap(mapname); - - //display it - gdc.changeEdgeText(mapname); - } - else //!edge.get_active() - { - //create the new map - Graph::NodeMap * emptr=new Graph::NodeMap (gdc.mapstorage.graph); - - std::stack polishstack; + std::stack polishstack; - for(NodeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) - { - for(int i=0;i<(int)polishform.size();i++) + for(NodeIt k(gdc.mapstorage.graph); k!=INVALID; ++k) { - double op1, op2; - bool operation=true; - switch(polishform[i]) + for(int i=0;i<(int)polishform.size();i++) { - case '+': - case '-': - case '/': - case '*': - op1=polishstack.top(); - polishstack.pop(); - op2=polishstack.top(); - polishstack.pop(); - break; - default: - std::map< std::string,Graph::NodeMap * > nms=gdc.mapstorage.nodemap_storage; - bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end()); - if(itisvar) - { - polishstack.push( (*(gdc.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]); - } - 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)); - } - operation=false; - break; - } - if(operation) - { - double res; + double op1, op2; + bool operation=true; switch(polishform[i]) { case '+': - res=op1+op2; - break; case '-': - res=op2-op1; - break; case '/': - res=op2/op1; - break; case '*': - res=op1*op2; + op1=polishstack.top(); + polishstack.pop(); + op2=polishstack.top(); + polishstack.pop(); break; default: - std::cout << "How could we get here?" << std::endl; + std::map< std::string,Graph::NodeMap * > nms=gdc.mapstorage.nodemap_storage; + bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end()); + if(itisvar) + { + polishstack.push( (*(gdc.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]); + } + 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)); + } + operation=false; break; } - polishstack.push(res); + if(operation) + { + double res; + switch(polishform[i]) + { + case '+': + res=op1+op2; + break; + case '-': + res=op2-op1; + break; + case '/': + res=op2/op1; + break; + case '*': + res=op1*op2; + break; + default: + std::cout << "How could we get here?" << std::endl; + break; + } + polishstack.push(res); + } } + (*emptr)[k]=polishstack.top(); } - (*emptr)[k]=polishstack.top(); + + //if addition was not successful addNodeMap returns one. + //cause can be that there is already a map named like the new one + if(gdc.mapstorage.addNodeMap(mapname,emptr, def_val)) + { + abortion=1; + } + + //add it to the list of the displayable maps + gdc.mapwin.registerNewNodeMap(mapname); + + //display it + //gdc.changeNodeText(mapname); } - - //if addition was not successful addNodeMap returns one. - //cause can be that there is already a map named like the new one - if(gdc.mapstorage.addNodeMap(mapname,emptr, def_val)) + if(!abortion) { - abortion=1; + name.set_text(""); + default_value.set_text("0"); + edge.show(); + node.show(); + hide(); } - - //add it to the list of the displayable maps - gdc.mapwin.registerNewNodeMap(mapname); - - //display it - gdc.changeNodeText(mapname); - } - if(!abortion) - { - name.set_text(""); - default_value.set_text("0"); - edge.show(); - node.show(); - hide(); } } } + std::string NewMapWin::string2Polishform(std::string rawcommand, bool itisedge) { bool valid_entry=true; diff -r 4042761b21e3 -r e9f8f44f12a3 new_map_win.h --- a/new_map_win.h Mon Nov 21 12:07:05 2005 +0000 +++ b/new_map_win.h Mon Nov 21 18:03:20 2005 +0000 @@ -14,7 +14,7 @@ ///This class is responsible for creating a window, ///on which the parameters of a new map can be set. -class NewMapWin : public Gtk::Window +class NewMapWin : public Gtk::Dialog { ///The \ref GraphDisplayerCanvas on which the graph will be drawn. ///It has to be known for this class, because @@ -31,16 +31,13 @@ }; ///Constructor of NewMapWin creates the widgets shown in NewMapWin. - NewMapWin(const std::string& title, GraphDisplayerCanvas &); - + NewMapWin(const std::string& title, GraphDisplayerCanvas &, bool itisedge=true, bool edgenode=true); ///Signal on button is connected to this function, ///Therefore this function determines whether to ///call the map/creatort function, and if yes, it //tells it the attributes.(name, default value) - virtual void buttonPressed(); - - virtual void showByPreChoose(bool); + virtual void on_response(int response_id); virtual bool closeIfEscapeIsPressed(GdkEventKey*); @@ -58,10 +55,6 @@ Gtk::Entry name, default_value; - Gtk::VBox vbox; - - Gtk::Button * button; - Gtk::Table * table; Gtk::Label * label;