# HG changeset patch # User hegyi # Date 1122412781 0 # Node ID 4708b716d2f47f3aff89efafc1ae645616974061 # Parent 03aa0a6c8dca7532516d32d5f8e7db4984079cbd EdgeMap and NodeMap creation is done, at last. Bach 4ever. diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/Makefile.am --- a/gui/Makefile.am Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/Makefile.am Tue Jul 26 21:19:41 2005 +0000 @@ -21,8 +21,9 @@ edit_win.cc \ edit_win.h \ broken_edge.cc \ - broken_edge.h - + broken_edge.h \ + new_map_win.cc \ + new_map_win.h gd_CXXFLAGS = $(GTK_CFLAGS) gd_LDFLAGS = $(GTK_LIBS) diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/graph_displayer_canvas-event.cc --- a/gui/graph_displayer_canvas-event.cc Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/graph_displayer_canvas-event.cc Tue Jul 26 21:19:41 2005 +0000 @@ -670,57 +670,78 @@ case GDK_KP_Enter: case GDK_Return: { - Glib::ustring mapvalue = entrywidget.get_text(); + bool valid_double=true; + int point_num=0; + Glib::ustring mapvalue_str = entrywidget.get_text(); - double double_map_fract_value=0; - double double_map_value=0; - int offset=0; - int found_letter=0; - //converting text to double - for(int i=0;i<(int)(mapvalue.length());i++) + char * mapvalue_ch=new char [mapvalue_str.length()]; + for(int i=0;i<(int)(mapvalue_str.length());i++) { - if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.')) + if(((mapvalue_str[i]<'0')||(mapvalue_str[i]>'9'))&&(mapvalue_str[i]!='.')) { - if(mapvalue[i]=='.') - { - //for calculating non-integer part of double we step backward from the end - //after each step the number will be divided by ten, and the new value will be added - //to step backward from the end until the point the actual character of the string is the following: - // mapvalue.length()-(i-position_of_point) - //if i was the number of the first character after the decimal point the selected character will be the last - //if i was the number of the last character, the selected character will be the first after the decimal point - offset=mapvalue.length()+i; - } - else - { - if(!offset) - { - double_map_value=10*double_map_value+mapvalue[i]-'0'; - } - else - { - double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10; - } - } + valid_double=false; } else { - found_letter++; - continue; + if(mapvalue_str[i]=='.') + { + point_num++; + } } + mapvalue_ch[i]=mapvalue_str[i]; } + + double mapvalue_d=atof(mapvalue_ch); - if(!found_letter) +// double double_map_fract_value=0; +// double double_map_value=0; +// int offset=0; +// int found_letter=0; + //converting text to double +// for(int i=0;i<(int)(mapvalue.length());i++) +// { +// if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.')) +// { +// if(mapvalue[i]=='.') +// { +// //for calculating non-integer part of double we step backward from the end +// //after each step the number will be divided by ten, and the new value will be added +// //to step backward from the end until the point the actual character of the string is the following: +// // mapvalue.length()-(i-position_of_point) +// //if i was the number of the first character after the decimal point the selected character will be the last +// //if i was the number of the last character, the selected character will be the first after the decimal point +// offset=mapvalue.length()+i; +// } +// else +// { +// if(!offset) +// { +// double_map_value=10*double_map_value+mapvalue[i]-'0'; +// } +// else +// { +// double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10; +// } +// } +// } +// else +// { +// found_letter++; +// continue; +// } +// } + + if((point_num<=1)&&(valid_double)) { switch(actual_tool) { case EDGE_MAP_EDIT: - edgetextmap[active_edge]->property_text().set_value(mapvalue); - (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=double_map_value+double_map_fract_value; + edgetextmap[active_edge]->property_text().set_value(mapvalue_str); + (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d; break; case NODE_MAP_EDIT: - nodetextmap[active_node]->property_text().set_value(mapvalue); - (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=double_map_value+double_map_fract_value; + nodetextmap[active_node]->property_text().set_value(mapvalue_str); + (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d; break; default: break; @@ -803,16 +824,19 @@ } -void GraphDisplayerCanvas::addNewEdgeMap() +void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname) { - Graph::EdgeMap * emptr=new Graph::EdgeMap (g,20); - mapstorage.addEdgeMap("NewEdgeMap",emptr); - mapwin->registerNewEdgeMap("NewEdgeMap"); - changeEdgeText("NewEdgeMap"); + Graph::EdgeMap * emptr=new Graph::EdgeMap (g,default_value); + mapstorage.addEdgeMap(mapname,emptr); + mapwin->registerNewEdgeMap(mapname); + changeEdgeText(mapname); } -void GraphDisplayerCanvas::addNewNodeMap() +void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname) { - std::cout << "Add New NodeMap is not yet implemented." << std::endl; + Graph::NodeMap * emptr=new Graph::NodeMap (g,default_value); + mapstorage.addNodeMap(mapname,emptr); + mapwin->registerNewNodeMap(mapname); + changeNodeText(mapname); } diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/graph_displayer_canvas.cc --- a/gui/graph_displayer_canvas.cc Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/graph_displayer_canvas.cc Tue Jul 26 21:19:41 2005 +0000 @@ -5,7 +5,7 @@ GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms, MapWin * mw):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),nodetextmap(g),displayed_graph(*(root()), 0, 0),canvasentrywidget(NULL),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL),nodemap_to_edit(""),edgemap_to_edit(""),mapwin(mw) { - + //Initializing values. active_node=INVALID; active_edge=INVALID; forming_edge=INVALID; diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/graph_displayer_canvas.h --- a/gui/graph_displayer_canvas.h Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/graph_displayer_canvas.h Tue Jul 26 21:19:41 2005 +0000 @@ -110,9 +110,9 @@ int getActualTool(); ///creates a new Nodemap - void addNewNodeMap(); + void addNewNodeMap(double,std::string); ///creates a new Edgemap - void addNewEdgeMap(); + void addNewEdgeMap(double,std::string); private: ///Deletes the given element. diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/main_win.cc --- a/gui/main_win.cc Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/main_win.cc Tue Jul 26 21:19:41 2005 +0000 @@ -1,8 +1,12 @@ #include MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, - MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),gd_canvas(graph, cm, ms, &mapwin) + MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),newmapwin("Creating new map",gd_canvas),gd_canvas(graph, cm, ms, &mapwin) { + //Creating a window for setting new maps. +// newmapwin=new NewMapWi("Creating new map",*this); + + set_title (title); set_default_size(WIN_WIDTH,WIN_HEIGHT); add(vbox); @@ -49,10 +53,8 @@ sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) ); ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES), sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) ); - ag->add( Gtk::Action::create("AddEdgeMap", Gtk::Stock::NEW), - sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewEdgeMap ) ); - ag->add( Gtk::Action::create("AddNodeMap", Gtk::Stock::NEW), - sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewNodeMap ) ); + ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW), + sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) ); uim=Gtk::UIManager::create(); uim->insert_action_group(ag); @@ -98,8 +100,7 @@ " " " " " " - " " - " " + " " " " ""; diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/main_win.h --- a/gui/main_win.h Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/main_win.h Tue Jul 26 21:19:41 2005 +0000 @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,9 @@ ///Window of editorial tools. Its type is \ref EditWin EditWin editwin; + ///We need to store newmapwin, to be able to set the appropriate values for properties of new map. + NewMapWin newmapwin; + ///The graph will be drawn on this \ref GraphDisplayerCanvas GraphDisplayerCanvas gd_canvas; diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/map_win.cc --- a/gui/map_win.cc Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/map_win.cc Tue Jul 26 21:19:41 2005 +0000 @@ -265,11 +265,13 @@ void MapWin::registerNewNodeMap(std::string newmapname) { - for(int i=0;i listStrings=n_combo_array[i].get_popdown_strings(); listStrings.push_back(newmapname); n_combo_array[i].set_popdown_strings(listStrings); } + Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry(); + entry->set_text((Glib::ustring)newmapname); }