EdgeMap and NodeMap creation is done, at last. Bach 4ever.
1.1 --- a/gui/Makefile.am Tue Jul 26 20:14:03 2005 +0000
1.2 +++ b/gui/Makefile.am Tue Jul 26 21:19:41 2005 +0000
1.3 @@ -21,8 +21,9 @@
1.4 edit_win.cc \
1.5 edit_win.h \
1.6 broken_edge.cc \
1.7 - broken_edge.h
1.8 -
1.9 + broken_edge.h \
1.10 + new_map_win.cc \
1.11 + new_map_win.h
1.12
1.13 gd_CXXFLAGS = $(GTK_CFLAGS)
1.14 gd_LDFLAGS = $(GTK_LIBS)
2.1 --- a/gui/graph_displayer_canvas-event.cc Tue Jul 26 20:14:03 2005 +0000
2.2 +++ b/gui/graph_displayer_canvas-event.cc Tue Jul 26 21:19:41 2005 +0000
2.3 @@ -670,57 +670,78 @@
2.4 case GDK_KP_Enter:
2.5 case GDK_Return:
2.6 {
2.7 - Glib::ustring mapvalue = entrywidget.get_text();
2.8 + bool valid_double=true;
2.9 + int point_num=0;
2.10 + Glib::ustring mapvalue_str = entrywidget.get_text();
2.11
2.12 - double double_map_fract_value=0;
2.13 - double double_map_value=0;
2.14 - int offset=0;
2.15 - int found_letter=0;
2.16 - //converting text to double
2.17 - for(int i=0;i<(int)(mapvalue.length());i++)
2.18 + char * mapvalue_ch=new char [mapvalue_str.length()];
2.19 + for(int i=0;i<(int)(mapvalue_str.length());i++)
2.20 {
2.21 - if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.'))
2.22 + if(((mapvalue_str[i]<'0')||(mapvalue_str[i]>'9'))&&(mapvalue_str[i]!='.'))
2.23 {
2.24 - if(mapvalue[i]=='.')
2.25 - {
2.26 - //for calculating non-integer part of double we step backward from the end
2.27 - //after each step the number will be divided by ten, and the new value will be added
2.28 - //to step backward from the end until the point the actual character of the string is the following:
2.29 - // mapvalue.length()-(i-position_of_point)
2.30 - //if i was the number of the first character after the decimal point the selected character will be the last
2.31 - //if i was the number of the last character, the selected character will be the first after the decimal point
2.32 - offset=mapvalue.length()+i;
2.33 - }
2.34 - else
2.35 - {
2.36 - if(!offset)
2.37 - {
2.38 - double_map_value=10*double_map_value+mapvalue[i]-'0';
2.39 - }
2.40 - else
2.41 - {
2.42 - double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10;
2.43 - }
2.44 - }
2.45 + valid_double=false;
2.46 }
2.47 else
2.48 {
2.49 - found_letter++;
2.50 - continue;
2.51 + if(mapvalue_str[i]=='.')
2.52 + {
2.53 + point_num++;
2.54 + }
2.55 }
2.56 + mapvalue_ch[i]=mapvalue_str[i];
2.57 }
2.58 +
2.59 + double mapvalue_d=atof(mapvalue_ch);
2.60
2.61 - if(!found_letter)
2.62 +// double double_map_fract_value=0;
2.63 +// double double_map_value=0;
2.64 +// int offset=0;
2.65 +// int found_letter=0;
2.66 + //converting text to double
2.67 +// for(int i=0;i<(int)(mapvalue.length());i++)
2.68 +// {
2.69 +// if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.'))
2.70 +// {
2.71 +// if(mapvalue[i]=='.')
2.72 +// {
2.73 +// //for calculating non-integer part of double we step backward from the end
2.74 +// //after each step the number will be divided by ten, and the new value will be added
2.75 +// //to step backward from the end until the point the actual character of the string is the following:
2.76 +// // mapvalue.length()-(i-position_of_point)
2.77 +// //if i was the number of the first character after the decimal point the selected character will be the last
2.78 +// //if i was the number of the last character, the selected character will be the first after the decimal point
2.79 +// offset=mapvalue.length()+i;
2.80 +// }
2.81 +// else
2.82 +// {
2.83 +// if(!offset)
2.84 +// {
2.85 +// double_map_value=10*double_map_value+mapvalue[i]-'0';
2.86 +// }
2.87 +// else
2.88 +// {
2.89 +// double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10;
2.90 +// }
2.91 +// }
2.92 +// }
2.93 +// else
2.94 +// {
2.95 +// found_letter++;
2.96 +// continue;
2.97 +// }
2.98 +// }
2.99 +
2.100 + if((point_num<=1)&&(valid_double))
2.101 {
2.102 switch(actual_tool)
2.103 {
2.104 case EDGE_MAP_EDIT:
2.105 - edgetextmap[active_edge]->property_text().set_value(mapvalue);
2.106 - (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=double_map_value+double_map_fract_value;
2.107 + edgetextmap[active_edge]->property_text().set_value(mapvalue_str);
2.108 + (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d;
2.109 break;
2.110 case NODE_MAP_EDIT:
2.111 - nodetextmap[active_node]->property_text().set_value(mapvalue);
2.112 - (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=double_map_value+double_map_fract_value;
2.113 + nodetextmap[active_node]->property_text().set_value(mapvalue_str);
2.114 + (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d;
2.115 break;
2.116 default:
2.117 break;
2.118 @@ -803,16 +824,19 @@
2.119
2.120 }
2.121
2.122 -void GraphDisplayerCanvas::addNewEdgeMap()
2.123 +void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
2.124 {
2.125 - Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,20);
2.126 - mapstorage.addEdgeMap("NewEdgeMap",emptr);
2.127 - mapwin->registerNewEdgeMap("NewEdgeMap");
2.128 - changeEdgeText("NewEdgeMap");
2.129 + Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,default_value);
2.130 + mapstorage.addEdgeMap(mapname,emptr);
2.131 + mapwin->registerNewEdgeMap(mapname);
2.132 + changeEdgeText(mapname);
2.133 }
2.134
2.135 -void GraphDisplayerCanvas::addNewNodeMap()
2.136 +void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
2.137 {
2.138 - std::cout << "Add New NodeMap is not yet implemented." << std::endl;
2.139 + Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (g,default_value);
2.140 + mapstorage.addNodeMap(mapname,emptr);
2.141 + mapwin->registerNewNodeMap(mapname);
2.142 + changeNodeText(mapname);
2.143 }
2.144
3.1 --- a/gui/graph_displayer_canvas.cc Tue Jul 26 20:14:03 2005 +0000
3.2 +++ b/gui/graph_displayer_canvas.cc Tue Jul 26 21:19:41 2005 +0000
3.3 @@ -5,7 +5,7 @@
3.4 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)
3.5 {
3.6
3.7 -
3.8 + //Initializing values.
3.9 active_node=INVALID;
3.10 active_edge=INVALID;
3.11 forming_edge=INVALID;
4.1 --- a/gui/graph_displayer_canvas.h Tue Jul 26 20:14:03 2005 +0000
4.2 +++ b/gui/graph_displayer_canvas.h Tue Jul 26 21:19:41 2005 +0000
4.3 @@ -110,9 +110,9 @@
4.4 int getActualTool();
4.5
4.6 ///creates a new Nodemap
4.7 - void addNewNodeMap();
4.8 + void addNewNodeMap(double,std::string);
4.9 ///creates a new Edgemap
4.10 - void addNewEdgeMap();
4.11 + void addNewEdgeMap(double,std::string);
4.12
4.13 private:
4.14 ///Deletes the given element.
5.1 --- a/gui/main_win.cc Tue Jul 26 20:14:03 2005 +0000
5.2 +++ b/gui/main_win.cc Tue Jul 26 21:19:41 2005 +0000
5.3 @@ -1,8 +1,12 @@
5.4 #include <main_win.h>
5.5
5.6 MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm,
5.7 - MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),gd_canvas(graph, cm, ms, &mapwin)
5.8 + 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)
5.9 {
5.10 + //Creating a window for setting new maps.
5.11 +// newmapwin=new NewMapWi("Creating new map",*this);
5.12 +
5.13 +
5.14 set_title (title);
5.15 set_default_size(WIN_WIDTH,WIN_HEIGHT);
5.16 add(vbox);
5.17 @@ -49,10 +53,8 @@
5.18 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
5.19 ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES),
5.20 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
5.21 - ag->add( Gtk::Action::create("AddEdgeMap", Gtk::Stock::NEW),
5.22 - sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewEdgeMap ) );
5.23 - ag->add( Gtk::Action::create("AddNodeMap", Gtk::Stock::NEW),
5.24 - sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewNodeMap ) );
5.25 + ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW),
5.26 + sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) );
5.27
5.28 uim=Gtk::UIManager::create();
5.29 uim->insert_action_group(ag);
5.30 @@ -98,8 +100,7 @@
5.31 " <toolitem action='MoveItem' />"
5.32 " <toolitem action='EditEdgeMap' />"
5.33 " <toolitem action='EditNodeMap' />"
5.34 - " <toolitem action='AddEdgeMap' />"
5.35 - " <toolitem action='AddNodeMap' />"
5.36 + " <toolitem action='AddMap' />"
5.37 " </toolbar>"
5.38 "</ui>";
5.39
6.1 --- a/gui/main_win.h Tue Jul 26 20:14:03 2005 +0000
6.2 +++ b/gui/main_win.h Tue Jul 26 21:19:41 2005 +0000
6.3 @@ -6,6 +6,7 @@
6.4 #include <all_include.h>
6.5 #include <mapstorage.h>
6.6 #include <map_win.h>
6.7 +#include <new_map_win.h>
6.8 #include <edit_win.h>
6.9 #include <libgnomecanvasmm.h>
6.10 #include <libgnomecanvasmm/polygon.h>
6.11 @@ -29,6 +30,9 @@
6.12 ///Window of editorial tools. Its type is \ref EditWin
6.13 EditWin editwin;
6.14
6.15 + ///We need to store newmapwin, to be able to set the appropriate values for properties of new map.
6.16 + NewMapWin newmapwin;
6.17 +
6.18 ///The graph will be drawn on this \ref GraphDisplayerCanvas
6.19 GraphDisplayerCanvas gd_canvas;
6.20
7.1 --- a/gui/map_win.cc Tue Jul 26 20:14:03 2005 +0000
7.2 +++ b/gui/map_win.cc Tue Jul 26 21:19:41 2005 +0000
7.3 @@ -265,11 +265,13 @@
7.4
7.5 void MapWin::registerNewNodeMap(std::string newmapname)
7.6 {
7.7 - for(int i=0;i<EDGE_PROPERTY_NUM;i++)
7.8 + for(int i=0;i<NODE_PROPERTY_NUM;i++)
7.9 {
7.10 //filling in combo box with choices
7.11 std::list<Glib::ustring> listStrings=n_combo_array[i].get_popdown_strings();
7.12 listStrings.push_back(newmapname);
7.13 n_combo_array[i].set_popdown_strings(listStrings);
7.14 }
7.15 + Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry();
7.16 + entry->set_text((Glib::ustring)newmapname);
7.17 }