Changeset 1849:a4d1362397fe in lemon-0.x for gui
- Timestamp:
- 12/06/05 11:53:38 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2414
- Location:
- gui
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/Makefile.am
r1819 r1849 9 9 glemon_SOURCES = \ 10 10 all_include.h \ 11 gdc-broken_edge.cc \ 11 12 graph_displayer_canvas.cc \ 13 graph_displayer_canvas.h \ 12 14 graph_displayer_canvas-edge.cc \ 15 graph_displayer_canvas-event.cc \ 13 16 graph_displayer_canvas-node.cc \ 14 graph_displayer_canvas-event.cc \15 17 graph_displayer_canvas-zoom.cc \ 16 graph_displayer_canvas.h \17 18 graph-displayer.cc \ 18 gdc-broken_edge.cc \19 19 main_win.cc \ 20 20 main_win.h \ … … 24 24 map_win.h \ 25 25 mw-mapselector.cc \ 26 nbtab.h \ 27 nbtab.cc \ 26 28 new_map_win.cc \ 27 29 new_map_win.h \ -
gui/graph-displayer.cc
r1731 r1849 62 62 Gtk::Main app(argc, argv); 63 63 64 MainWin m ainwin;64 MainWin mytab; 65 65 66 66 if ((argc == 2) && (Glib::file_test(argv[1], Glib::FILE_TEST_IS_REGULAR))) 67 {68 mainwin.readFile(argv[1]);69 }67 { 68 mytab.readFile(argv[1]); 69 } 70 70 71 app.run(m ainwin);71 app.run(mytab); 72 72 73 73 return 0; -
gui/graph_displayer_canvas-edge.cc
r1837 r1849 9 9 min=edge_property_defaults[E_WIDTH]; 10 10 max=edge_property_defaults[E_WIDTH]; 11 Graph::EdgeMap<double> actual_map((m ainwin.mapstorage).graph,edge_property_defaults[E_WIDTH]);11 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_WIDTH]); 12 12 13 13 if(edge==INVALID) 14 14 { 15 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)15 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 16 16 { 17 17 double v=fabs(actual_map[i]); … … 45 45 double min, max; 46 46 47 min=(m ainwin.mapstorage).minOfEdgeMap(mapname);48 max=(m ainwin.mapstorage).maxOfEdgeMap(mapname);49 actual_map=((m ainwin.mapstorage).edgemap_storage)[mapname];50 51 if(edge==INVALID) 52 { 53 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)47 min=(mytab.mapstorage).minOfEdgeMap(mapname); 48 max=(mytab.mapstorage).maxOfEdgeMap(mapname); 49 actual_map=((mytab.mapstorage).edgemap_storage)[mapname]; 50 51 if(edge==INVALID) 52 { 53 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 54 54 { 55 55 double v=fabs((*actual_map)[i]); … … 84 84 //green in RGB 85 85 Graph::EdgeMap<double> * actual_map; 86 actual_map=((m ainwin.mapstorage).edgemap_storage)[mapname];86 actual_map=((mytab.mapstorage).edgemap_storage)[mapname]; 87 87 88 88 double max, min; 89 89 90 max=(m ainwin.mapstorage).maxOfEdgeMap(mapname);91 min=(m ainwin.mapstorage).minOfEdgeMap(mapname);92 93 if(edge==INVALID) 94 { 95 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)90 max=(mytab.mapstorage).maxOfEdgeMap(mapname); 91 min=(mytab.mapstorage).minOfEdgeMap(mapname); 92 93 if(edge==INVALID) 94 { 95 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 96 96 { 97 97 double w=(*actual_map)[i]; … … 135 135 //the minimum of the nodemap to the range of 136 136 //green in RGB 137 Graph::EdgeMap<double> actual_map((m ainwin.mapstorage).graph,edge_property_defaults[E_COLOR]);137 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_COLOR]); 138 138 139 139 double max, min; … … 144 144 if(edge==INVALID) 145 145 { 146 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)146 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 147 147 { 148 148 double w=actual_map[i]; … … 189 189 if(edge==INVALID) 190 190 { 191 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)191 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 192 192 { 193 193 edgemap_to_edit=mapname; 194 double number=(*((m ainwin.mapstorage).edgemap_storage)[mapname])[i];194 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[i]; 195 195 196 196 std::ostringstream ostr; … … 203 203 else 204 204 { 205 double number=(*((m ainwin.mapstorage).edgemap_storage)[mapname])[edge];205 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[edge]; 206 206 207 207 std::ostringstream ostr; … … 224 224 if(edge==INVALID) 225 225 { 226 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)226 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 227 227 { 228 228 edgemap_to_edit=""; -
gui/graph_displayer_canvas-event.cc
r1837 r1849 95 95 active_item=(get_item_at(clicked_x, clicked_y)); 96 96 active_node=INVALID; 97 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)97 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 98 98 { 99 99 if(nodesmap[i]==active_item) … … 126 126 if(active_node!=INVALID) 127 127 { 128 (m ainwin.mapstorage).modified = true;128 (mytab.mapstorage).modified = true; 129 129 130 130 //new coordinates will be the old values, … … 145 145 146 146 // the new coordinates of the centre of the node 147 double coord_x = new_x - (clicked_x - (m ainwin.mapstorage).coords[active_node].x);148 double coord_y = new_y - (clicked_y - (m ainwin.mapstorage).coords[active_node].y);147 double coord_x = new_x - (clicked_x - (mytab.mapstorage).coords[active_node].x); 148 double coord_y = new_y - (clicked_y - (mytab.mapstorage).coords[active_node].y); 149 149 150 150 clicked_x=new_x; … … 152 152 153 153 // write back the new coordinates to the coords map 154 (m ainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));154 (mytab.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y)); 155 155 156 156 // reposition the coordinates text 157 157 std::ostringstream ostr; 158 158 ostr << "(" << 159 (m ainwin.mapstorage).coords[active_node].x << ", " <<160 (m ainwin.mapstorage).coords[active_node].y << ")";159 (mytab.mapstorage).coords[active_node].x << ", " << 160 (mytab.mapstorage).coords[active_node].y << ")"; 161 161 double radius = 162 162 (nodesmap[active_node]->property_x2().get_value() - … … 165 165 { 166 166 coord_text->property_text().set_value(ostr.str()); 167 coord_text->property_x().set_value((m ainwin.mapstorage).coords[active_node].x +167 coord_text->property_x().set_value((mytab.mapstorage).coords[active_node].x + 168 168 radius); 169 coord_text->property_y().set_value((m ainwin.mapstorage).coords[active_node].y -169 coord_text->property_y().set_value((mytab.mapstorage).coords[active_node].y - 170 170 radius); 171 171 } … … 174 174 coord_text = new Gnome::Canvas::Text( 175 175 displayed_graph, 176 (m ainwin.mapstorage).coords[active_node].x + radius,177 (m ainwin.mapstorage).coords[active_node].y - radius,176 (mytab.mapstorage).coords[active_node].x + radius, 177 (mytab.mapstorage).coords[active_node].y - radius, 178 178 ostr.str()); 179 179 coord_text->property_fill_color().set_value("black"); … … 182 182 183 183 //all the edges connected to the moved point has to be redrawn 184 for(OutEdgeIt ei((m ainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)184 for(OutEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei) 185 185 { 186 186 Gnome::Canvas::Points coos; 187 187 double x1, x2, y1, y2; 188 188 189 nodesmap[(m ainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);189 nodesmap[(mytab.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2); 190 190 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 191 191 192 nodesmap[(m ainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);192 nodesmap[(mytab.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2); 193 193 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 194 194 … … 209 209 } 210 210 211 for(InEdgeIt ei((m ainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)211 for(InEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei) 212 212 { 213 213 Gnome::Canvas::Points coos; 214 214 double x1, x2, y1, y2; 215 215 216 nodesmap[(m ainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);216 nodesmap[(mytab.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2); 217 217 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 218 218 219 nodesmap[(m ainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);219 nodesmap[(mytab.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2); 220 220 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 221 221 … … 257 257 258 258 case GDK_BUTTON_RELEASE: 259 (m ainwin.mapstorage).modified = true;259 (mytab.mapstorage).modified = true; 260 260 261 261 isbutton=1; 262 262 263 active_node=(m ainwin.mapstorage).graph.addNode();263 active_node=(mytab.mapstorage).graph.addNode(); 264 264 265 265 //initiating values corresponding to new node in maps … … 268 268 269 269 // update coordinates 270 (m ainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));270 (mytab.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y)); 271 271 272 272 // update all other maps 273 273 for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it = 274 (m ainwin.mapstorage).nodemap_storage.begin(); it !=275 (m ainwin.mapstorage).nodemap_storage.end(); ++it)274 (mytab.mapstorage).nodemap_storage.begin(); it != 275 (mytab.mapstorage).nodemap_storage.end(); ++it) 276 276 { 277 277 if ((it->first != "coordinates_x") && … … 279 279 { 280 280 (*(it->second))[active_node] = 281 (m ainwin.mapstorage).nodemap_default[it->first];281 (mytab.mapstorage).nodemap_default[it->first]; 282 282 } 283 283 } 284 284 // increment the id map's default value 285 (m ainwin.mapstorage).nodemap_default["id"] += 1.0;285 (mytab.mapstorage).nodemap_default["id"] += 1.0; 286 286 287 287 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, … … 333 333 active_item=(get_item_at(clicked_x, clicked_y)); 334 334 active_node=INVALID; 335 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)335 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 336 336 { 337 337 if(nodesmap[i]==active_item) … … 362 362 target_item=(get_item_at(clicked_x, clicked_y)); 363 363 Node target_node=INVALID; 364 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)364 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 365 365 { 366 366 if(nodesmap[i]==target_item) … … 374 374 if(target_node!=active_node) 375 375 { 376 (m ainwin.mapstorage).modified = true;376 (mytab.mapstorage).modified = true; 377 377 378 378 *(nodesmap[target_node]) << … … 380 380 381 381 //creating new edge 382 active_edge=(m ainwin.mapstorage).graph.addEdge(active_node,382 active_edge=(mytab.mapstorage).graph.addEdge(active_node, 383 383 target_node); 384 384 … … 386 386 for (std::map<std::string, 387 387 Graph::EdgeMap<double>*>::const_iterator it = 388 (m ainwin.mapstorage).edgemap_storage.begin(); it !=389 (m ainwin.mapstorage).edgemap_storage.end(); ++it)388 (mytab.mapstorage).edgemap_storage.begin(); it != 389 (mytab.mapstorage).edgemap_storage.end(); ++it) 390 390 { 391 391 (*(it->second))[active_edge] = 392 (m ainwin.mapstorage).edgemap_default[it->first];392 (mytab.mapstorage).edgemap_default[it->first]; 393 393 } 394 394 // increment the id map's default value 395 (m ainwin.mapstorage).edgemap_default["id"] += 1.0;395 (mytab.mapstorage).edgemap_default["id"] += 1.0; 396 396 397 397 //calculating coordinates of new edge … … 481 481 active_edge=INVALID; 482 482 //was it a node? 483 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)483 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 484 484 { 485 485 if(nodesmap[i]==active_item) … … 491 491 if(active_node==INVALID) 492 492 { 493 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)493 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 494 494 { 495 495 if(edgesmap[i]==active_item) … … 517 517 if(active_node!=INVALID) 518 518 { 519 (m ainwin.mapstorage).modified = true;519 (mytab.mapstorage).modified = true; 520 520 521 521 std::set<Graph::Edge> edges_to_delete; 522 522 523 for(OutEdgeIt e((m ainwin.mapstorage).graph,active_node);e!=INVALID;++e)523 for(OutEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e) 524 524 { 525 525 edges_to_delete.insert(e); 526 526 } 527 527 528 for(InEdgeIt e((m ainwin.mapstorage).graph,active_node);e!=INVALID;++e)528 for(InEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e) 529 529 { 530 530 edges_to_delete.insert(e); … … 590 590 591 591 //find the activated item between texts 592 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)592 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 593 593 { 594 594 //at the same time only one can be active … … 602 602 if(clicked_edge==INVALID) 603 603 { 604 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)604 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 605 605 { 606 606 //at the same time only one can be active … … 625 625 626 626 //create a dialog 627 Gtk::Dialog dialog("Edit value", mainwin,true);627 Gtk::Dialog dialog("Edit value", true); 628 628 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 629 629 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); … … 642 642 case Gtk::RESPONSE_ACCEPT: 643 643 double new_value = spin.get_value(); 644 (*(m ainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =644 (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] = 645 645 new_value; 646 646 std::ostringstream ostr; … … 678 678 679 679 //find the activated item between texts 680 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)680 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 681 681 { 682 682 //at the same time only one can be active … … 690 690 if(clicked_node==INVALID) 691 691 { 692 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)692 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 693 693 { 694 694 //at the same time only one can be active … … 713 713 714 714 //create a dialog 715 Gtk::Dialog dialog("Edit value", mainwin,true);715 Gtk::Dialog dialog("Edit value", true); 716 716 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 717 717 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); … … 730 730 case Gtk::RESPONSE_ACCEPT: 731 731 double new_value = spin.get_value(); 732 (*(m ainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =732 (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] = 733 733 new_value; 734 734 std::ostringstream ostr; … … 755 755 delete(nodetextmap[node_to_delete]); 756 756 delete(nodesmap[node_to_delete]); 757 (m ainwin.mapstorage).graph.erase(node_to_delete);757 (mytab.mapstorage).graph.erase(node_to_delete); 758 758 } 759 759 … … 762 762 delete(edgetextmap[edge_to_delete]); 763 763 delete(edgesmap[edge_to_delete]); 764 (m ainwin.mapstorage).graph.erase(edge_to_delete);764 (mytab.mapstorage).graph.erase(edge_to_delete); 765 765 } 766 766 … … 782 782 else 783 783 { 784 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)784 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 785 785 { 786 786 if(edgesmap[i]==active_bre) … … 808 808 { 809 809 //create the new map 810 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((m ainwin.mapstorage).graph, default_value);810 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mytab.mapstorage).graph, default_value); 811 811 812 812 //if addition was not successful addEdgeMap returns one. 813 813 //cause can be that there is already a map named like the new one 814 if((m ainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))814 if((mytab.mapstorage).addEdgeMap(mapname,emptr, default_value)) 815 815 { 816 816 return 1; … … 819 819 820 820 //add it to the list of the displayable maps 821 m ainwin.registerNewEdgeMap(mapname);821 mytab.registerNewEdgeMap(mapname); 822 822 823 823 //display it … … 830 830 { 831 831 //create the new map 832 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((m ainwin.mapstorage).graph,default_value);832 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mytab.mapstorage).graph,default_value); 833 833 834 834 //if addition was not successful addNodeMap returns one. 835 835 //cause can be that there is already a map named like the new one 836 if((m ainwin.mapstorage).addNodeMap(mapname,emptr, default_value))836 if((mytab.mapstorage).addNodeMap(mapname,emptr, default_value)) 837 837 { 838 838 return 1; … … 840 840 841 841 //add it to the list of the displayable maps 842 m ainwin.registerNewNodeMap(mapname);842 mytab.registerNewNodeMap(mapname); 843 843 844 844 //display it -
gui/graph_displayer_canvas-node.cc
r1837 r1849 7 7 Graph::NodeMap<double> * actual_map; 8 8 double min, max; 9 min=(m ainwin.mapstorage).minOfNodeMap(mapname);10 max=(m ainwin.mapstorage).maxOfNodeMap(mapname);11 actual_map=((m ainwin.mapstorage).nodemap_storage)[mapname];12 13 if(node==INVALID) 14 { 15 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)9 min=(mytab.mapstorage).minOfNodeMap(mapname); 10 max=(mytab.mapstorage).maxOfNodeMap(mapname); 11 actual_map=((mytab.mapstorage).nodemap_storage)[mapname]; 12 13 if(node==INVALID) 14 { 15 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 16 16 { 17 17 double v=fabs((*actual_map)[i]); … … 65 65 min=node_property_defaults[N_RADIUS]; 66 66 max=node_property_defaults[N_RADIUS]; 67 Graph::NodeMap<double> actual_map((m ainwin.mapstorage).graph,node_property_defaults[N_RADIUS]);67 Graph::NodeMap<double> actual_map((mytab.mapstorage).graph,node_property_defaults[N_RADIUS]); 68 68 69 69 if(node==INVALID) 70 70 { 71 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)71 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 72 72 { 73 73 double v=fabs(actual_map[i]); … … 124 124 125 125 Graph::NodeMap<double> * actual_map; 126 actual_map=((m ainwin.mapstorage).nodemap_storage)[mapname];126 actual_map=((mytab.mapstorage).nodemap_storage)[mapname]; 127 127 128 128 double max, min; 129 129 130 max=(m ainwin.mapstorage).maxOfNodeMap(mapname);131 min=(m ainwin.mapstorage).minOfNodeMap(mapname);132 133 if(node==INVALID) 134 { 135 136 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)130 max=(mytab.mapstorage).maxOfNodeMap(mapname); 131 min=(mytab.mapstorage).minOfNodeMap(mapname); 132 133 if(node==INVALID) 134 { 135 136 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 137 137 { 138 138 Gdk::Color color; … … 179 179 //green in RGB 180 180 181 Graph::NodeMap<double> actual_map((m ainwin.mapstorage).graph,node_property_defaults[N_COLOR]);181 Graph::NodeMap<double> actual_map((mytab.mapstorage).graph,node_property_defaults[N_COLOR]); 182 182 183 183 double max, min; … … 189 189 { 190 190 191 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)191 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 192 192 { 193 193 Gdk::Color color; … … 236 236 237 237 Graph::NodeMap<double> * actual_map=NULL; 238 actual_map=((m ainwin.mapstorage).nodemap_storage)[mapname];239 240 if(node==INVALID) 241 { 242 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)238 actual_map=((mytab.mapstorage).nodemap_storage)[mapname]; 239 240 if(node==INVALID) 241 { 242 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 243 243 { 244 244 nodemap_to_edit=mapname; … … 273 273 if(node==INVALID) 274 274 { 275 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)275 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 276 276 { 277 277 nodemap_to_edit=""; -
gui/graph_displayer_canvas.cc
r1837 r1849 2 2 #include <cmath> 3 3 4 GraphDisplayerCanvas::GraphDisplayerCanvas( MainWin& mainw) :4 GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) : 5 5 nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph), 6 6 nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0), 7 7 isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""), 8 edgemap_to_edit(""), m ainwin(mainw)8 edgemap_to_edit(""), mytab(mainw) 9 9 { 10 10 //base event handler is move tool … … 19 19 GraphDisplayerCanvas::~GraphDisplayerCanvas() 20 20 { 21 for (NodeIt n((m ainwin.mapstorage).graph); n != INVALID; ++n)21 for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n) 22 22 { 23 23 delete nodesmap[n]; … … 25 25 } 26 26 27 for (EdgeIt e((m ainwin.mapstorage).graph); e != INVALID; ++e)27 for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e) 28 28 { 29 29 delete edgesmap[e]; … … 64 64 dummy=dummy; 65 65 66 std::string mapname=m ainwin.getActiveNodeMap(prop);66 std::string mapname=mytab.getActiveNodeMap(prop); 67 67 68 68 if(mapname!="") 69 69 { 70 if( ( ((m ainwin.mapstorage).nodemap_storage).find(mapname) != ((mainwin.mapstorage).nodemap_storage).end() ) )70 if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) ) 71 71 { 72 72 switch(prop) … … 111 111 dummy=dummy; 112 112 113 std::string mapname=m ainwin.getActiveEdgeMap(prop);113 std::string mapname=mytab.getActiveEdgeMap(prop); 114 114 115 115 if(mapname!="") 116 116 { 117 if( ( ((m ainwin.mapstorage).edgemap_storage).find(mapname) != ((mainwin.mapstorage).edgemap_storage).end() ) )117 if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) ) 118 118 { 119 119 switch(prop) … … 156 156 //first edges are drawn, to hide joining with nodes later 157 157 158 for (EdgeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)158 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 159 159 { 160 160 … … 163 163 Gnome::Canvas::Points coos; 164 164 coos.push_back(Gnome::Art::Point( 165 (m ainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].x,166 (m ainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].y));165 (mytab.mapstorage).coords[(mytab.mapstorage).graph.source(i)].x, 166 (mytab.mapstorage).coords[(mytab.mapstorage).graph.source(i)].y)); 167 167 coos.push_back(Gnome::Art::Point( 168 (m ainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].x,169 (m ainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].y));168 (mytab.mapstorage).coords[(mytab.mapstorage).graph.target(i)].x, 169 (mytab.mapstorage).coords[(mytab.mapstorage).graph.target(i)].y)); 170 170 171 171 edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this); … … 187 187 //afterwards nodes come to be drawn 188 188 189 for (NodeIt i((m ainwin.mapstorage).graph); i!=INVALID; ++i)189 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) 190 190 { 191 191 //drawing bule nodes, with black line around them … … 193 193 nodesmap[i]=new Gnome::Canvas::Ellipse( 194 194 displayed_graph, 195 (m ainwin.mapstorage).coords[i].x-20,196 (m ainwin.mapstorage).coords[i].y-20,197 (m ainwin.mapstorage).coords[i].x+20,198 (m ainwin.mapstorage).coords[i].y+20);195 (mytab.mapstorage).coords[i].x-20, 196 (mytab.mapstorage).coords[i].y-20, 197 (mytab.mapstorage).coords[i].x+20, 198 (mytab.mapstorage).coords[i].y+20); 199 199 *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue"); 200 200 *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black"); … … 204 204 205 205 xy<double> text_pos( 206 ((m ainwin.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5),207 ((m ainwin.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5));206 ((mytab.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5), 207 ((mytab.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5)); 208 208 209 209 nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph, … … 223 223 forming_edge=INVALID; 224 224 225 for (NodeIt n((m ainwin.mapstorage).graph); n != INVALID; ++n)225 for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n) 226 226 { 227 227 delete nodesmap[n]; … … 229 229 } 230 230 231 for (EdgeIt e((m ainwin.mapstorage).graph); e != INVALID; ++e)231 for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e) 232 232 { 233 233 delete edgesmap[e]; -
gui/graph_displayer_canvas.h
r1837 r1849 7 7 8 8 #include "all_include.h" 9 #include " main_win.h"9 #include "nbtab.h" 10 10 #include <libgnomecanvasmm.h> 11 11 #include <libgnomecanvasmm/polygon.h> … … 40 40 41 41 public: 42 GraphDisplayerCanvas( MainWin&);42 GraphDisplayerCanvas(NoteBookTab &); 43 43 virtual ~GraphDisplayerCanvas(); 44 44 … … 199 199 200 200 ///reference to the parent window 201 MainWin & mainwin;201 NoteBookTab & mytab; 202 202 203 203 }; -
gui/main_win.cc
r1838 r1849 2 2 #include "icons/guipixbufs.h" 3 3 4 MainWin::MainWin():mapwinexists(false) 5 { 6 gd_canvas=new GraphDisplayerCanvas(*this); 7 8 set_title ("unsaved file - " + prog_name); 4 MainWin::MainWin() 5 { 6 set_title ("no file"); 9 7 set_default_size(WIN_WIDTH,WIN_HEIGHT); 10 8 add(vbox); 11 9 12 //connecting signals - controller character13 mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));14 15 10 // custom icons for the toolbar 16 17 11 Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create(); 18 12 … … 76 70 p_icon_factory->add_default(); 77 71 78 79 72 ag=Gtk::ActionGroup::create(); 80 73 81 74 ag->add( Gtk::Action::create("FileMenu", "_File") ); 75 ag->add( Gtk::Action::create("FileNewTab", "New _Tab"), 76 sigc::mem_fun(*this, &MainWin::newTab)); 82 77 ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW), 83 78 sigc::mem_fun(*this, &MainWin::newFile)); … … 95 90 ag->add( Gtk::Action::create("ViewMenu", "_View") ); 96 91 ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN), 97 sigc::mem_fun(* (this->gd_canvas), &GraphDisplayerCanvas::zoomIn));92 sigc::mem_fun(*this, &MainWin::zoomIn)); 98 93 ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT), 99 sigc::mem_fun(* (this->gd_canvas), &GraphDisplayerCanvas::zoomOut));94 sigc::mem_fun(*this, &MainWin::zoomOut)); 100 95 ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT), 101 sigc::mem_fun(* (this->gd_canvas), &GraphDisplayerCanvas::zoomFit));96 sigc::mem_fun(*this, &MainWin::zoomFit)); 102 97 ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), 103 sigc::mem_fun(* (this->gd_canvas), &GraphDisplayerCanvas::zoom100));98 sigc::mem_fun(*this, &MainWin::zoom100)); 104 99 105 100 ag->add( Gtk::Action::create("ShowMenu", "_Show") ); … … 109 104 Gtk::RadioAction::Group tool_group; 110 105 ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), 111 sigc::bind( sigc::mem_fun ( * (this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) );106 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); 112 107 ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"), 113 sigc::bind( sigc::mem_fun ( * (this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 1) );108 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) ); 114 109 ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), "Create edge"), 115 sigc::bind( sigc::mem_fun ( * (this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 2) );110 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) ); 116 111 ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), "Delete"), 117 sigc::bind( sigc::mem_fun ( * (this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 3) );112 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) ); 118 113 119 114 ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), "Edit edge map"), 120 sigc::bind( sigc::mem_fun ( * (this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 4) );115 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) ); 121 116 ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), "Edit node map"), 122 sigc::bind( sigc::mem_fun ( * (this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 5) );117 sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 5) ); 123 118 124 119 ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), 125 sigc::mem_fun ( new NewMapWin("NewMapWin", *this), &NewMapWin::show) );120 sigc::mem_fun ( *this , &MainWin::createNewMapWin ) ); 126 121 127 122 uim=Gtk::UIManager::create(); … … 136 131 " <menubar name='MenuBar'>" 137 132 " <menu action='FileMenu'>" 133 " <menuitem action='FileNewTab'/>" 138 134 " <menuitem action='FileNew'/>" 139 135 " <menuitem action='FileOpen'/>" … … 195 191 } 196 192 197 Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());198 pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN);199 pScrolledWindow->add(*gd_canvas);200 vbox.pack_start(*pScrolledWindow);201 202 193 tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node"); 203 194 tooltips.enable(); 204 195 196 active_tab=-1; 197 notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab)); 198 199 vbox.pack_start(notebook); 200 205 201 show_all_children(); 206 202 } 207 203 208 void MainWin::readFile(const std::string &file) 209 { 210 mapstorage.readFromFile(file); 211 mapstorage.file_name = file; 212 mapstorage.modified = false; 213 gd_canvas->drawGraph(); 214 if(mapwinexists) 215 { 216 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); 217 } 218 set_title(Glib::filename_display_basename(file) + " - " + prog_name); 204 void MainWin::set_tabtitle(std::string name) 205 { 206 tabnames[active_tab]=name; 207 set_title(tabnames[active_tab] + " - " + prog_name); 208 notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); 209 } 210 211 void MainWin::readFile(const std::string & filename) 212 { 213 newTab(); 214 tabs[active_tab]->readFile(filename); 215 } 216 217 void MainWin::newTab() 218 { 219 int size=tabs.size(); 220 tabs.resize(size+1); 221 tabnames.resize(size+1); 222 active_tab=size; 223 tabs[active_tab]=new NoteBookTab(); 224 tabnames[active_tab]="unsaved file"; 225 tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle)); 226 tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal)); 227 tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); 228 notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); 229 notebook.set_current_page(size); 230 set_tabtitle(tabnames[active_tab]); 231 } 232 233 void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num) 234 { 235 page=page; 236 active_tab=page_num; 237 tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); 238 set_title(tabnames[active_tab]); 239 } 240 241 void MainWin::onCloseTab() 242 { 219 243 } 220 244 221 245 void MainWin::newFile() 222 246 { 223 if (mapstorage.modified) 224 { 225 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 226 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); 227 mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT); 228 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 229 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); 230 switch (mdialog.run()) 231 { 232 case Gtk::RESPONSE_CANCEL: 233 return; 234 case Gtk::RESPONSE_REJECT: 235 break; 236 case Gtk::RESPONSE_ACCEPT: 237 saveFile(); 238 break; 239 } 240 } 241 gd_canvas->clear(); 242 mapstorage.clear(); 243 if(mapwinexists) 244 { 245 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); 246 } 247 set_title("unsaved file - " + prog_name); 248 } 249 247 if(active_tab!=-1) 248 { 249 tabs[active_tab]->newFile(); 250 } 251 } 252 250 253 void MainWin::openFile() 251 254 { 252 if (mapstorage.modified) 253 { 254 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 255 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); 256 mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT); 257 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 258 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); 259 switch (mdialog.run()) 260 { 261 case Gtk::RESPONSE_CANCEL: 262 return; 263 case Gtk::RESPONSE_REJECT: 264 break; 265 case Gtk::RESPONSE_ACCEPT: 266 saveFile(); 267 break; 268 } 269 } 270 Gtk::FileChooserDialog fcdialog("Open File"); 271 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 272 fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT); 273 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT) 274 { 275 gd_canvas->clear(); 276 mapstorage.clear(); 277 Glib::ustring filename = fcdialog.get_filename(); 278 if (!mapstorage.readFromFile(filename)) 279 { 280 mapstorage.file_name = filename; 281 mapstorage.modified = false; 282 gd_canvas->drawGraph(); 283 if(mapwinexists) 255 if(active_tab!=-1) 256 { 257 tabs[active_tab]->openFile(); 258 } 259 } 260 261 void MainWin::saveFile() 262 { 263 if(active_tab!=-1) 264 { 265 tabs[active_tab]->saveFile(); 266 } 267 } 268 269 void MainWin::saveFileAs() 270 { 271 if(active_tab!=-1) 272 { 273 tabs[active_tab]->saveFileAs(); 274 } 275 } 276 277 void MainWin::close() 278 { 279 if(active_tab!=-1) 280 { 281 tabs[active_tab]->close(); 282 } 283 } 284 285 void MainWin::zoomIn() 286 { 287 if(active_tab!=-1) 288 { 289 tabs[active_tab]->gd_canvas->zoomIn(); 290 } 291 } 292 293 void MainWin::zoomOut() 294 { 295 if(active_tab!=-1) 296 { 297 tabs[active_tab]->gd_canvas->zoomOut(); 298 } 299 } 300 301 void MainWin::zoomFit() 302 { 303 if(active_tab!=-1) 304 { 305 tabs[active_tab]->gd_canvas->zoomFit(); 306 } 307 } 308 309 void MainWin::zoom100() 310 { 311 if(active_tab!=-1) 312 { 313 tabs[active_tab]->gd_canvas->zoom100(); 314 } 315 } 316 317 void MainWin::createMapWin() 318 { 319 if(active_tab!=-1) 320 { 321 tabs[active_tab]->createMapWin(tabnames[active_tab]); 322 } 323 } 324 325 void MainWin::changeEditorialTool(int tool) 326 { 327 active_tool=tool; 328 if(active_tab!=-1) 329 { 330 tabs[active_tab]->gd_canvas->changeEditorialTool(tool); 331 } 332 } 333 334 void MainWin::createNewMapWin() 335 { 336 if(active_tab!=-1) 337 { 338 NewMapWin * nmw=new NewMapWin("Create New Map - "+tabnames[active_tab], *(tabs[active_tab])); 339 nmw->show(); 340 } 341 } 342 343 void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge) 344 { 345 std::vector<NoteBookTab*>::iterator nbti=tabs.begin(); 346 int i=0; 347 for(;nbti!=tabs.end();nbti++) 348 { 349 if(*nbti!=nbt) 284 350 { 285 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());351 i++; 286 352 } 287 set_title(Glib::filename_display_basename(filename) + " - " + prog_name); 288 } 289 } 290 } 291 292 void MainWin::saveFile() 293 { 294 if (mapstorage.file_name == "") { 295 saveFileAs(); 296 } 297 else 298 { 299 mapstorage.writeToFile(mapstorage.file_name); 300 mapstorage.modified = false; 301 set_title(Glib::filename_display_basename(mapstorage.file_name) + " - " + 302 prog_name); 303 } 304 } 305 306 void MainWin::saveFileAs() 307 { 308 Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE); 309 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 310 fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); 311 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT) 312 { 313 Glib::ustring filename = fcdialog.get_filename(); 314 mapstorage.file_name = filename; 315 mapstorage.writeToFile(filename); 316 mapstorage.modified = false; 317 set_title(Glib::filename_display_basename(filename) + " - " + prog_name); 318 } 319 } 320 321 void MainWin::close() 322 { 323 if (mapstorage.modified) 324 { 325 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 326 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); 327 mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT); 328 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 329 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); 330 switch (mdialog.run()) 331 { 332 case Gtk::RESPONSE_CANCEL: 333 return; 334 case Gtk::RESPONSE_REJECT: 335 break; 336 case Gtk::RESPONSE_ACCEPT: 337 saveFile(); 338 break; 339 } 340 } 341 gd_canvas->clear(); 342 mapstorage.clear(); 343 if(mapwinexists) 344 { 345 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); 346 } 347 set_title("unsaved file - " + prog_name); 348 } 349 350 void MainWin::propertyChange(bool itisedge, int prop, std::string mapname) 351 { 352 mapstorage.changeActiveMap(itisedge, prop, mapname); 353 } 354 355 void MainWin::popupNewMapWin(bool itisedge, int prop) 356 { 357 prop=prop; 358 (new NewMapWin("NewMapWin", *this, itisedge, false))->run(); 359 } 360 361 std::string MainWin::getActiveEdgeMap(int prop) 362 { 363 return mapstorage.getActiveEdgeMap(prop); 364 } 365 366 std::string MainWin::getActiveNodeMap(int prop) 367 { 368 return mapstorage.getActiveNodeMap(prop); 369 } 370 371 void MainWin::registerNewEdgeMap(std::string mapname) 372 { 373 if(mapwinexists) 374 { 375 mapwin->registerNewEdgeMap(mapname); 376 } 377 } 378 379 void MainWin::registerNewNodeMap(std::string mapname) 380 { 381 if(mapwinexists) 382 { 383 mapwin->registerNewNodeMap(mapname); 384 } 385 } 386 387 void MainWin::createMapWin() 388 { 389 if(!mapwinexists) 390 { 391 mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); 392 mapwin->show(); 393 mapwinexists=true; 394 } 395 } 396 397 void MainWin::closeMapWin() 398 { 399 mapwinexists=false; 400 delete mapwin; 401 } 353 else 354 { 355 continue; 356 } 357 } 358 NewMapWin * nmw=new NewMapWin("Create New Map - "+tabnames[i], *nbt, itisedge, false); 359 nmw->run(); 360 } -
gui/main_win.h
r1838 r1849 4 4 #define MAIN_WIN_H 5 5 6 class MainWin;7 8 6 #include "all_include.h" 9 #include "mapstorage.h"10 7 #include "map_win.h" 11 8 #include "new_map_win.h" 12 #include " graph_displayer_canvas.h"9 #include "nbtab.h" 13 10 #include <libgnomecanvasmm.h> 14 11 #include <libgnomecanvasmm/polygon.h> 12 15 13 16 14 ///This class is the main window of GUI. … … 18 16 class MainWin : public Gtk::Window 19 17 { 18 ///Container 19 Gtk::VBox vbox; 20 21 Gtk::Notebook notebook; 22 23 int active_tool; 24 25 int active_tab; 26 std::vector<NoteBookTab *> tabs; 27 std::vector<std::string> tabnames; 28 20 29 public: 21 ///Constructor of the \ref MainWin. It creates the menu and the \ref GraphDisplayerCanvas on which the graph will be drawn. 30 31 ///Constructor of the \ref NoteBookTab. It creates the menu and the \ref GraphDisplayerCanvas on which the graph will be drawn. 22 32 ///\param title is the title of the window 23 33 MainWin(); 24 34 25 MapStorage mapstorage; 26 27 void readFile(const std::string &); 28 29 protected: 30 MapWin * mapwin; 31 bool mapwinexists; 32 33 ///The graph will be drawn on this \ref GraphDisplayerCanvas 34 GraphDisplayerCanvas * gd_canvas; 35 void set_tabtitle(std::string); 35 36 36 37 ///ActionGroup for menu … … 40 41 Glib::RefPtr<Gtk::UIManager> uim; 41 42 42 ///Container 43 Gtk::VBox vbox; 43 void readFile(const std::string &); 44 44 45 45 ///Tooltips 46 46 Gtk::Tooltips tooltips; 47 48 //Call-backs of buttons 47 49 48 50 ///Callback for 'FileNew' action. … … 57 59 virtual void close(); 58 60 59 public: 60 void propertyChange(bool, int, std::string); 61 void popupNewMapWin(bool, int); 61 //Toolbar 62 virtual void zoomIn(); 63 virtual void zoomOut(); 64 virtual void zoomFit(); 65 virtual void zoom100(); 62 66 63 std::string getActiveEdgeMap(int); 64 std::string getActiveNodeMap(int); 67 virtual void createMapWin(); 65 68 66 void registerNewEdgeMap(std::string); 67 void registerNewNodeMap(std::string); 69 virtual void changeEditorialTool(int); 68 70 69 void createMapWin(); 70 void closeMapWin(); 71 virtual void createNewMapWinAfterSignal(NoteBookTab *, bool); 72 virtual void createNewMapWin(); 73 74 //Notebook handlers 75 ///Callback for 'FileNewTab' action. 76 virtual void newTab(); 77 virtual void onChangeTab(GtkNotebookPage*, guint); 78 virtual void onCloseTab(); 79 80 71 81 }; 72 82 -
gui/map_win.cc
r1838 r1849 6 6 if(e->keyval==GDK_Escape) 7 7 { 8 m ainwin.closeMapWin();8 mytab.closeMapWin(); 9 9 // hide(); 10 10 } … … 12 12 } 13 13 14 MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, MainWin & mw):mainwin(mw)14 MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw) 15 15 { 16 16 set_title(title); … … 25 25 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 26 26 { 27 e_combo_array[i]=new MapSelector(eml, m ainwin.getActiveEdgeMap(i), i, true);27 e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), i, true); 28 28 29 29 (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); … … 45 45 for(int i=0;i<NODE_PROPERTY_NUM;i++) 46 46 { 47 n_combo_array[i]=new MapSelector(nml, m ainwin.getActiveNodeMap(i), i, false);47 n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), i, false); 48 48 49 49 (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); … … 69 69 void MapWin::nodeMapChanged(std::string mapname, int prop) 70 70 { 71 m ainwin.propertyChange(false, prop, mapname);71 mytab.propertyChange(false, prop, mapname); 72 72 } 73 73 74 74 void MapWin::edgeMapChanged(std::string mapname, int prop) 75 75 { 76 m ainwin.propertyChange(true, prop, mapname);76 mytab.propertyChange(true, prop, mapname); 77 77 } 78 78 79 79 void MapWin::newMapWinNeeded(bool itisedge, int prop) 80 80 { 81 m ainwin.popupNewMapWin(itisedge, prop);81 mytab.popupNewMapWin(itisedge, prop); 82 82 } 83 83 … … 116 116 { 117 117 event=event; 118 m ainwin.closeMapWin();118 mytab.closeMapWin(); 119 119 return true; 120 120 } -
gui/map_win.h
r1838 r1849 7 7 8 8 #include <all_include.h> 9 #include < main_win.h>9 #include <nbtab.h> 10 10 #include <libgnomecanvasmm.h> 11 11 #include <libgnomecanvasmm/polygon.h> … … 66 66 67 67 protected: 68 MainWin & mainwin;68 NoteBookTab & mytab; 69 69 70 70 Gtk::Table * table; … … 78 78 public: 79 79 ///Constructor of MapWin creates the widgets shown in MapWin. 80 MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, MainWin& mw);80 MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, NoteBookTab & mw); 81 81 82 82 ~MapWin(); -
gui/new_map_win.cc
r1837 r1849 10 10 } 11 11 12 NewMapWin::NewMapWin(const std::string& title, MainWin & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mainwin(mw),node("Create NodeMap"),edge("Create EdgeMap")12 NewMapWin::NewMapWin(const std::string& title, NoteBookTab & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mytab(mw),node("Create NodeMap"),edge("Create EdgeMap") 13 13 { 14 14 set_default_size(200, 50); … … 84 84 { 85 85 //create the new map 86 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (m ainwin.mapstorage.graph);86 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mytab.mapstorage.graph); 87 87 88 88 std::stack<double> polishstack; 89 89 90 for(EdgeIt k(m ainwin.mapstorage.graph); k!=INVALID; ++k)90 for(EdgeIt k(mytab.mapstorage.graph); k!=INVALID; ++k) 91 91 { 92 92 for(int i=0;i<(int)polishform.size();i++) … … 107 107 default: 108 108 //substitute variable 109 std::map< std::string,Graph::EdgeMap<double> * > ems=m ainwin.mapstorage.edgemap_storage;109 std::map< std::string,Graph::EdgeMap<double> * > ems=mytab.mapstorage.edgemap_storage; 110 110 bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end()); 111 111 if(itisvar) 112 112 { 113 polishstack.push( (*(m ainwin.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);113 polishstack.push( (*(mytab.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]); 114 114 } 115 115 else … … 154 154 //if addition was not successful addEdgeMap returns one. 155 155 //cause can be that there is already a map named like the new one 156 if(m ainwin.mapstorage.addEdgeMap(mapname, emptr, def_val))156 if(mytab.mapstorage.addEdgeMap(mapname, emptr, def_val)) 157 157 { 158 158 abortion=1; … … 160 160 161 161 //add it to the list of the displayable maps 162 m ainwin.registerNewEdgeMap(mapname);162 mytab.registerNewEdgeMap(mapname); 163 163 164 164 //display it … … 168 168 { 169 169 //create the new map 170 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (m ainwin.mapstorage.graph);170 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mytab.mapstorage.graph); 171 171 172 172 std::stack<double> polishstack; 173 173 174 for(NodeIt k(m ainwin.mapstorage.graph); k!=INVALID; ++k)174 for(NodeIt k(mytab.mapstorage.graph); k!=INVALID; ++k) 175 175 { 176 176 for(int i=0;i<(int)polishform.size();i++) … … 190 190 break; 191 191 default: 192 std::map< std::string,Graph::NodeMap<double> * > nms=m ainwin.mapstorage.nodemap_storage;192 std::map< std::string,Graph::NodeMap<double> * > nms=mytab.mapstorage.nodemap_storage; 193 193 bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end()); 194 194 if(itisvar) 195 195 { 196 polishstack.push( (*(m ainwin.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);196 polishstack.push( (*(mytab.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]); 197 197 } 198 198 else … … 237 237 //if addition was not successful addNodeMap returns one. 238 238 //cause can be that there is already a map named like the new one 239 if(m ainwin.mapstorage.addNodeMap(mapname,emptr, def_val))239 if(mytab.mapstorage.addNodeMap(mapname,emptr, def_val)) 240 240 { 241 241 abortion=1; … … 243 243 244 244 //add it to the list of the displayable maps 245 m ainwin.registerNewNodeMap(mapname);245 mytab.registerNewNodeMap(mapname); 246 246 247 247 //display it … … 432 432 if(itisedge) 433 433 { 434 cancel=(m ainwin.mapstorage.edgemap_storage.find(variable)==mainwin.mapstorage.edgemap_storage.end());434 cancel=(mytab.mapstorage.edgemap_storage.find(variable)==mytab.mapstorage.edgemap_storage.end()); 435 435 } 436 436 else 437 437 { 438 cancel=(m ainwin.mapstorage.nodemap_storage.find(variable)==mainwin.mapstorage.nodemap_storage.end());438 cancel=(mytab.mapstorage.nodemap_storage.find(variable)==mytab.mapstorage.nodemap_storage.end()); 439 439 } 440 440 //maybe it is number -
gui/new_map_win.h
r1837 r1849 7 7 8 8 #include <all_include.h> 9 #include < main_win.h>9 #include <nbtab.h> 10 10 #include <libgnomecanvasmm.h> 11 11 #include <libgnomecanvasmm/polygon.h> … … 17 17 class NewMapWin : public Gtk::Dialog 18 18 { 19 MainWin & mainwin;19 NoteBookTab & mytab; 20 20 21 21 public: … … 28 28 29 29 ///Constructor of NewMapWin creates the widgets shown in NewMapWin. 30 NewMapWin(const std::string& title, MainWin&, bool itisedge=true, bool edgenode=true);30 NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true); 31 31 32 32 ///Signal on button is connected to this function,
Note: See TracChangeset
for help on using the changeset viewer.