alpar@174: /* -*- C++ -*- alpar@174: * alpar@174: * This file is a part of LEMON, a generic C++ optimization library alpar@174: * alpar@174: * Copyright (C) 2003-2006 alpar@174: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@174: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@174: * alpar@174: * Permission to use, modify and distribute this software is granted alpar@174: * provided that this copyright notice appears in all copies. For alpar@174: * precise terms see the accompanying LICENSE file. alpar@174: * alpar@174: * This software is provided "AS IS" with no warranty of any kind, alpar@174: * express or implied, and with no claim as to its suitability for any alpar@174: * purpose. alpar@174: * alpar@174: */ alpar@174: ladanyi@130: #ifdef HAVE_CONFIG_H ladanyi@130: #include ladanyi@130: #endif ladanyi@130: hegyi@194: #include hegyi@194: #include hegyi@194: #include hegyi@194: hegyi@194: #include hegyi@194: #include hegyi@194: #include hegyi@194: #include hegyi@194: #include ladanyi@6: ladanyi@133: #include "i18n.h" ladanyi@130: hegyi@96: MainWin::MainWin() ladanyi@6: { hegyi@96: set_title ("no file"); ladanyi@6: set_default_size(WIN_WIDTH,WIN_HEIGHT); hegyi@154: //add(vbox); hegyi@154: add(table); ladanyi@6: ladanyi@60: // custom icons for the toolbar ladanyi@60: Glib::RefPtr p_icon_factory = Gtk::IconFactory::create(); ladanyi@60: ladanyi@61: Glib::RefPtr p_move_pixbuf = Gdk::Pixbuf::create_from_inline( ladanyi@61: 2328, gui_icons_move); ladanyi@61: Glib::RefPtr p_addnode_pixbuf = Gdk::Pixbuf::create_from_inline( ladanyi@61: 2328, gui_icons_addnode); ladanyi@61: Glib::RefPtr p_addlink_pixbuf = Gdk::Pixbuf::create_from_inline( ladanyi@61: 2328, gui_icons_addlink); ladanyi@61: Glib::RefPtr p_delete_pixbuf = Gdk::Pixbuf::create_from_inline( ladanyi@61: 2328, gui_icons_delete); ladanyi@61: Glib::RefPtr p_editlink_pixbuf = Gdk::Pixbuf::create_from_inline( ladanyi@61: 2328, gui_icons_editlink); ladanyi@61: Glib::RefPtr p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline( ladanyi@61: 2328, gui_icons_newmap); hegyi@191: Glib::RefPtr p_eps_pixbuf = Gdk::Pixbuf::create_from_inline( hegyi@191: 2328, gui_icons_eps); ladanyi@60: ladanyi@60: Gtk::IconSource move_icon_source; ladanyi@61: move_icon_source.set_pixbuf(p_move_pixbuf); ladanyi@60: Gtk::IconSet move_icon_set; ladanyi@60: move_icon_set.add_source(move_icon_source); ladanyi@60: p_icon_factory->add(Gtk::StockID("gd-move"), move_icon_set); ladanyi@60: ladanyi@60: Gtk::IconSource addnode_icon_source; ladanyi@61: addnode_icon_source.set_pixbuf(p_addnode_pixbuf); ladanyi@60: Gtk::IconSet addnode_icon_set; ladanyi@60: addnode_icon_set.add_source(addnode_icon_source); ladanyi@60: p_icon_factory->add(Gtk::StockID("gd-addnode"), addnode_icon_set); ladanyi@60: ladanyi@60: Gtk::IconSource addlink_icon_source; ladanyi@61: addlink_icon_source.set_pixbuf(p_addlink_pixbuf); ladanyi@60: Gtk::IconSet addlink_icon_set; ladanyi@60: addlink_icon_set.add_source(addlink_icon_source); ladanyi@60: p_icon_factory->add(Gtk::StockID("gd-addlink"), addlink_icon_set); ladanyi@60: ladanyi@60: Gtk::IconSource delete_icon_source; ladanyi@61: delete_icon_source.set_pixbuf(p_delete_pixbuf); ladanyi@60: Gtk::IconSet delete_icon_set; ladanyi@60: delete_icon_set.add_source(delete_icon_source); ladanyi@60: p_icon_factory->add(Gtk::StockID("gd-delete"), delete_icon_set); ladanyi@60: ladanyi@60: Gtk::IconSource editlink_icon_source; ladanyi@61: editlink_icon_source.set_pixbuf(p_editlink_pixbuf); ladanyi@60: Gtk::IconSet editlink_icon_set; ladanyi@60: editlink_icon_set.add_source(editlink_icon_source); ladanyi@60: p_icon_factory->add(Gtk::StockID("gd-editlink"), editlink_icon_set); ladanyi@60: ladanyi@60: Gtk::IconSource newmap_icon_source; ladanyi@61: newmap_icon_source.set_pixbuf(p_newmap_pixbuf); ladanyi@60: Gtk::IconSet newmap_icon_set; ladanyi@60: newmap_icon_set.add_source(newmap_icon_source); ladanyi@60: p_icon_factory->add(Gtk::StockID("gd-newmap"), newmap_icon_set); ladanyi@60: hegyi@191: Gtk::IconSource eps_icon_source; hegyi@191: eps_icon_source.set_pixbuf(p_eps_pixbuf); hegyi@191: Gtk::IconSet eps_icon_set; hegyi@191: eps_icon_set.add_source(eps_icon_source); hegyi@191: p_icon_factory->add(Gtk::StockID("gd-eps"), eps_icon_set); hegyi@191: ladanyi@60: p_icon_factory->add_default(); ladanyi@60: ladanyi@6: ag=Gtk::ActionGroup::create(); ladanyi@6: ladanyi@130: ag->add( Gtk::Action::create("FileMenu", _("_File")) ); hegyi@102: ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW), hegyi@96: sigc::mem_fun(*this, &MainWin::newTab)); ladanyi@6: ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN), ladanyi@6: sigc::mem_fun(*this, &MainWin::openFile)); ladanyi@130: ag->add( Gtk::Action::create("FileClearTab", _("Clear Tab")), hegyi@102: sigc::mem_fun(*this, &MainWin::newFile)); ladanyi@6: ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE), ladanyi@6: sigc::mem_fun(*this, &MainWin::saveFile)); ladanyi@6: ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS), ladanyi@6: sigc::mem_fun(*this, &MainWin::saveFileAs)); ladanyi@53: ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE), hegyi@102: sigc::mem_fun(*this, &MainWin::closeTab)); ladanyi@53: ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT), hegyi@47: sigc::mem_fun(*this, &MainWin::hide)); ladanyi@6: ladanyi@130: ag->add( Gtk::Action::create("ViewMenu", _("_View")) ); ladanyi@6: ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN), hegyi@96: sigc::mem_fun(*this, &MainWin::zoomIn)); ladanyi@6: ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT), hegyi@96: sigc::mem_fun(*this, &MainWin::zoomOut)); ladanyi@6: ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT), hegyi@96: sigc::mem_fun(*this, &MainWin::zoomFit)); ladanyi@6: ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), hegyi@96: sigc::mem_fun(*this, &MainWin::zoom100)); ladanyi@184: ag->add( Gtk::Action::create("SetBackground", _("Set Background...")), ladanyi@184: sigc::mem_fun(*this, &MainWin::createBackgroundChooser)); ladanyi@6: ladanyi@130: ag->add( Gtk::Action::create("ShowMenu", _("_Show")) ); ladanyi@130: ag->add( Gtk::Action::create("ShowMaps", _("_Maps")), hegyi@95: sigc::mem_fun(*this, &MainWin::createMapWin)); hegyi@160: ag->add( Gtk::Action::create("ShowDesign", _("_Design")), hegyi@160: sigc::mem_fun(*this, &MainWin::createDesignWin)); ladanyi@6: ladanyi@130: ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) ); ladanyi@130: ag->add( Gtk::Action::create("AlgoGeneral", _("_General")), hegyi@103: sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) ); ladanyi@130: ag->add( Gtk::Action::create("AlgoKruskal", _("_Kruskal")), hegyi@106: sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 1) ); hegyi@162: ag->add( Gtk::Action::create("AlgoDijkstra", _("_Dijkstra")), hegyi@162: sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 2) ); hegyi@165: ag->add( Gtk::Action::create("AlgoSuurballe", _("_Suurballe")), hegyi@165: sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 3) ); hegyi@103: ladanyi@53: Gtk::RadioAction::Group tool_group; ladanyi@130: ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), _("Move")), hegyi@96: sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); ladanyi@130: ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), _("Create node")), hegyi@96: sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) ); ladanyi@130: ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), _("Create edge")), hegyi@96: sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) ); ladanyi@130: ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), _("Delete")), hegyi@96: sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) ); ladanyi@60: ladanyi@130: ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), _("Edit edge map")), hegyi@96: sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) ); ladanyi@60: ladanyi@60: ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), hegyi@96: sigc::mem_fun ( *this , &MainWin::createNewMapWin ) ); hegyi@22: hegyi@160: ag->add( Gtk::Action::create("DesignGraph", Gtk::Stock::REFRESH), hegyi@160: sigc::mem_fun ( *this , &MainWin::reDesignGraph ) ); hegyi@160: hegyi@191: ag->add( Gtk::Action::create("Eps", Gtk::StockID("gd-eps")), hegyi@191: sigc::mem_fun ( *this , &MainWin::exportToEPS ) ); hegyi@191: ladanyi@6: uim=Gtk::UIManager::create(); ladanyi@6: uim->insert_action_group(ag); ladanyi@6: add_accel_group(uim->get_accel_group()); ladanyi@6: ladanyi@6: try ladanyi@6: { ladanyi@6: ladanyi@6: Glib::ustring ui_info = ladanyi@6: "" ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " hegyi@102: " " ladanyi@6: " " ladanyi@6: " " ladanyi@53: " " ladanyi@53: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@87: " " ladanyi@184: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " hegyi@160: " " ladanyi@6: " " hegyi@103: " " hegyi@103: " " hegyi@106: " " hegyi@162: " " hegyi@165: " " hegyi@103: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@53: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@6: " " ladanyi@87: " " hegyi@22: " " ladanyi@53: " " hegyi@22: " " hegyi@22: " " hegyi@22: " " hegyi@32: " " ladanyi@60: " " hegyi@41: " " hegyi@160: " " hegyi@191: " " ladanyi@6: " " ladanyi@6: ""; ladanyi@6: ladanyi@6: uim->add_ui_from_string(ui_info); ladanyi@6: ladanyi@6: } ladanyi@6: catch(const Glib::Error& ex) ladanyi@6: { ladanyi@6: std::cerr << "building menus failed: " << ex.what(); ladanyi@6: } ladanyi@6: ladanyi@6: Gtk::Widget* menubar = uim->get_widget("/MenuBar"); ladanyi@6: if (menubar){ hegyi@154: //vbox.pack_start(*menubar, Gtk::PACK_SHRINK); hegyi@154: table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); ladanyi@6: } ladanyi@6: ladanyi@6: Gtk::Widget* toolbar = uim->get_widget("/ToolBar"); ladanyi@6: if (toolbar) ladanyi@6: { ladanyi@6: static_cast(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); hegyi@190: static_cast(toolbar)->set_tooltips(true); hegyi@154: //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET); hegyi@154: hegyi@154: table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); hegyi@154: ladanyi@6: } hegyi@156: hegyi@154: table2.set_row_spacings(10); hegyi@154: table2.set_col_spacings(5); hegyi@154: hegyi@156: auto_scale = new Gtk::CheckButton("Autoscale"); hegyi@156: auto_scale->set_active(false); hegyi@156: auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); hegyi@154: table2.attach(*auto_scale, 0,2,0,1); hegyi@156: hegyi@157: Gtk::Label * width_label= new Gtk::Label("Edge Width:"); hegyi@157: table2.attach(*width_label, 0,1,1,2); hegyi@154: hegyi@157: Gtk::Adjustment * adjustment_width=new Gtk::Adjustment(20, 1, 200, 5, 10); hegyi@157: hegyi@157: edge_width = new Gtk::SpinButton(*adjustment_width, 5,0); hegyi@157: edge_width->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); hegyi@157: table2.attach(*edge_width, 1,2,1,2); hegyi@154: hegyi@157: Gtk::Label * radius_label= new Gtk::Label("Node Radius:"); hegyi@157: table2.attach(*radius_label, 2,3,1,2); hegyi@157: hegyi@157: Gtk::Adjustment * adjustment_radius=new Gtk::Adjustment(20, 0, 500, 5, 10); hegyi@154: hegyi@157: radius_size = new Gtk::SpinButton(*adjustment_radius, 5,0); hegyi@157: radius_size->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); hegyi@157: table2.attach(*radius_size, 3,4,1,2); hegyi@154: hegyi@156: zoom_track = new Gtk::CheckButton("Zoom tracking"); hegyi@156: zoom_track->set_active(false); hegyi@156: zoom_track->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); hegyi@156: table2.attach(*zoom_track, 2,4,0,1); hegyi@156: hegyi@156: hegyi@154: table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK); hegyi@154: hegyi@190: tooltips=Gtk::manage(new Gtk::Tooltips()); hegyi@190: if(tooltips) hegyi@190: { hegyi@190: tooltips->set_tip(*zoom_track, "If on, edge widths and node radiuses are constant, independent from zooming"); hegyi@190: tooltips->set_tip(*auto_scale, "If on, glemon automatically determines the size of edges and nodes"); hegyi@190: tooltips->set_tip(*radius_size, "Sets maximum node radius, if auto-scale is off"); hegyi@190: tooltips->set_tip(*edge_width, "Sets maximum edge width, if auto-scale is off"); hegyi@190: hegyi@190: static_cast(uim->get_widget("/ToolBar/FileNew"))->set_tooltip(*tooltips, "Inserts new tab"); hegyi@190: static_cast(uim->get_widget("/ToolBar/FileOpen"))->set_tooltip(*tooltips, "Lets you open a file"); hegyi@190: static_cast(uim->get_widget("/ToolBar/FileSave"))->set_tooltip(*tooltips, "Saves the graph on the active tab"); hegyi@190: static_cast(uim->get_widget("/ToolBar/Close"))->set_tooltip(*tooltips, "Closes the active tab"); hegyi@190: static_cast(uim->get_widget("/ToolBar/ViewZoomIn"))->set_tooltip(*tooltips, "Zoom in the graph"); hegyi@190: static_cast(uim->get_widget("/ToolBar/ViewZoomOut"))->set_tooltip(*tooltips, "Zoom out the graph"); hegyi@190: static_cast(uim->get_widget("/ToolBar/ViewZoom100"))->set_tooltip(*tooltips, "Shows actual size of graph"); hegyi@190: static_cast(uim->get_widget("/ToolBar/ViewZoomFit"))->set_tooltip(*tooltips, "Fits graph into window"); hegyi@190: static_cast(uim->get_widget("/ToolBar/MoveItem"))->set_tooltip(*tooltips, "Moves the clicked item (edge/node)"); hegyi@190: static_cast(uim->get_widget("/ToolBar/CreateNode"))->set_tooltip(*tooltips, "Adds new node"); hegyi@190: static_cast(uim->get_widget("/ToolBar/CreateEdge"))->set_tooltip(*tooltips, "Lets you create new edge"); hegyi@190: static_cast(uim->get_widget("/ToolBar/EraseItem"))->set_tooltip(*tooltips, "Erases the clicked item (edge/node)"); hegyi@190: static_cast(uim->get_widget("/ToolBar/EditEdgeMap"))->set_tooltip(*tooltips, "Lets you edit the values written on the items"); hegyi@190: static_cast(uim->get_widget("/ToolBar/AddMap"))->set_tooltip(*tooltips, "Adds edge/nodemap"); hegyi@190: static_cast(uim->get_widget("/ToolBar/DesignGraph"))->set_tooltip(*tooltips, "Redesigns your graph, supposing elastic edges and propulsation of nodes."); hegyi@190: hegyi@190: tooltips->enable(); hegyi@190: } ladanyi@6: hegyi@96: active_tab=-1; hegyi@96: notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab)); hegyi@96: ladanyi@107: active_tool = MOVE; ladanyi@107: hegyi@154: table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); hegyi@96: ladanyi@6: show_all_children(); ladanyi@6: } ladanyi@6: hegyi@96: void MainWin::set_tabtitle(std::string name) ladanyi@57: { hegyi@104: if(strinst.find(name)==strinst.end()) hegyi@104: { hegyi@104: tabnames[active_tab]=name; hegyi@104: strinst[name]=1; hegyi@104: } hegyi@104: else hegyi@104: { hegyi@104: strinst[name]++; hegyi@104: std::ostringstream o; hegyi@104: o << strinst[name]; hegyi@104: tabnames[active_tab]=name+" - "+o.str(); hegyi@104: } hegyi@96: set_title(tabnames[active_tab] + " - " + prog_name); hegyi@96: notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); hegyi@106: updateAlgoWinTabs(); hegyi@96: } hegyi@96: hegyi@96: void MainWin::readFile(const std::string & filename) hegyi@96: { hegyi@96: newTab(); hegyi@96: tabs[active_tab]->readFile(filename); hegyi@96: } hegyi@96: hegyi@96: void MainWin::newTab() hegyi@96: { hegyi@96: int size=tabs.size(); hegyi@96: tabs.resize(size+1); hegyi@96: tabnames.resize(size+1); hegyi@96: active_tab=size; hegyi@96: tabs[active_tab]=new NoteBookTab(); hegyi@96: tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle)); hegyi@96: tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal)); hegyi@96: tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); hegyi@96: notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); hegyi@96: notebook.set_current_page(size); ladanyi@130: set_tabtitle(_("unsaved file")); hegyi@106: updateAlgoWinTabs(); hegyi@96: } hegyi@96: hegyi@97: void MainWin::closeTab() hegyi@97: { hegyi@97: if(active_tab!=-1) hegyi@97: { hegyi@194: if (tabs[active_tab]->mapstorage->modified) hegyi@102: { ladanyi@130: Gtk::MessageDialog mdialog(_("Save changes before closing?"), true, hegyi@102: Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); ladanyi@130: mdialog.add_button(_("Close file _without Saving"), Gtk::RESPONSE_REJECT); hegyi@102: mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); hegyi@102: mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); hegyi@102: switch (mdialog.run()) hegyi@102: { hegyi@102: case Gtk::RESPONSE_CANCEL: hegyi@102: return; hegyi@102: case Gtk::RESPONSE_REJECT: hegyi@102: break; hegyi@102: case Gtk::RESPONSE_ACCEPT: hegyi@102: tabs[active_tab]->saveFile(); hegyi@102: break; hegyi@102: } hegyi@102: } hegyi@97: //tabs vector will be decreased with the deleted value hegyi@97: int size=tabs.size(); hegyi@97: if(size>1) hegyi@97: { hegyi@97: for(int i=active_tab+1;igd_canvas->changeEditorialTool(active_tool); hegyi@96: set_title(tabnames[active_tab]); hegyi@154: bool autoscale; hegyi@156: bool zoomtrack; hegyi@157: double width; hegyi@157: double radius; hegyi@157: tabs[active_tab]->getView(autoscale, zoomtrack, width, radius); hegyi@157: edge_width->set_value(width); hegyi@157: radius_size->set_value(radius); hegyi@156: zoom_track->set_active(zoomtrack); hegyi@154: auto_scale->set_active(autoscale); hegyi@154: hegyi@96: } hegyi@96: ladanyi@6: void MainWin::newFile() ladanyi@6: { hegyi@96: if(active_tab!=-1) ladanyi@53: { hegyi@96: tabs[active_tab]->newFile(); ladanyi@53: } ladanyi@6: } hegyi@96: ladanyi@6: void MainWin::openFile() ladanyi@6: { ladanyi@140: if(active_tab==-1) ladanyi@53: { ladanyi@140: newTab(); ladanyi@53: } ladanyi@140: tabs[active_tab]->openFile(); ladanyi@6: } hegyi@96: ladanyi@6: void MainWin::saveFile() ladanyi@6: { hegyi@96: if(active_tab!=-1) hegyi@96: { hegyi@96: tabs[active_tab]->saveFile(); hegyi@96: } ladanyi@6: } hegyi@96: ladanyi@6: void MainWin::saveFileAs() ladanyi@6: { hegyi@96: if(active_tab!=-1) hegyi@96: { hegyi@96: tabs[active_tab]->saveFileAs(); hegyi@96: } ladanyi@6: } hegyi@96: ladanyi@53: void MainWin::close() ladanyi@53: { hegyi@96: if(active_tab!=-1) ladanyi@53: { hegyi@96: tabs[active_tab]->close(); hegyi@95: } hegyi@94: } hegyi@94: hegyi@96: void MainWin::zoomIn() hegyi@94: { hegyi@96: if(active_tab!=-1) hegyi@95: { hegyi@96: tabs[active_tab]->gd_canvas->zoomIn(); hegyi@96: } hegyi@96: } hegyi@96: hegyi@96: void MainWin::zoomOut() hegyi@96: { hegyi@96: if(active_tab!=-1) hegyi@96: { hegyi@96: tabs[active_tab]->gd_canvas->zoomOut(); hegyi@96: } hegyi@96: } hegyi@96: hegyi@96: void MainWin::zoomFit() hegyi@96: { hegyi@96: if(active_tab!=-1) hegyi@96: { hegyi@96: tabs[active_tab]->gd_canvas->zoomFit(); hegyi@96: } hegyi@96: } hegyi@96: hegyi@96: void MainWin::zoom100() hegyi@96: { hegyi@96: if(active_tab!=-1) hegyi@96: { hegyi@96: tabs[active_tab]->gd_canvas->zoom100(); hegyi@95: } hegyi@94: } hegyi@95: hegyi@95: void MainWin::createMapWin() hegyi@95: { hegyi@96: if(active_tab!=-1) hegyi@95: { hegyi@96: tabs[active_tab]->createMapWin(tabnames[active_tab]); hegyi@95: } hegyi@95: } hegyi@95: hegyi@160: void MainWin::createDesignWin() hegyi@160: { hegyi@160: if(active_tab!=-1) hegyi@160: { hegyi@160: tabs[active_tab]->createDesignWin(tabnames[active_tab]); hegyi@160: } hegyi@160: } hegyi@160: hegyi@103: void MainWin::createAlgoWin(int algoid) hegyi@103: { hegyi@108: AlgoWin * aw=new AlgoWin(algoid, tabnames); hegyi@103: aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); hegyi@106: aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps)); hegyi@114: aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString)); hegyi@103: aws.insert(aw); hegyi@103: aw->show(); hegyi@103: } hegyi@103: hegyi@106: void MainWin::updateAlgoWinTabs() hegyi@103: { hegyi@103: std::set< AlgoWin* >::iterator awsi=aws.begin(); hegyi@103: for(;awsi!=aws.end();awsi++) hegyi@103: { hegyi@103: (*awsi)->update_tablist(tabnames); hegyi@103: } hegyi@103: } hegyi@103: hegyi@108: void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname) hegyi@108: { hegyi@108: int i=0; hegyi@108: for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++) hegyi@108: { hegyi@108: } hegyi@194: awp->update_maplist(tabs[i]->mapstorage); hegyi@108: } hegyi@108: hegyi@108: void MainWin::deRegisterAlgoWin(AlgoWin * awp) hegyi@108: { hegyi@108: aws.erase(awp); hegyi@108: } hegyi@108: hegyi@96: void MainWin::changeEditorialTool(int tool) hegyi@95: { hegyi@96: active_tool=tool; hegyi@96: if(active_tab!=-1) hegyi@96: { hegyi@96: tabs[active_tab]->gd_canvas->changeEditorialTool(tool); hegyi@96: } hegyi@95: } hegyi@96: hegyi@96: void MainWin::createNewMapWin() hegyi@96: { hegyi@96: if(active_tab!=-1) hegyi@96: { ladanyi@130: NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[active_tab], *(tabs[active_tab])); hegyi@96: nmw->show(); hegyi@96: } hegyi@96: } hegyi@96: hegyi@114: void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge) hegyi@114: { hegyi@114: int i=0; hegyi@120: for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++) hegyi@114: { hegyi@114: } hegyi@114: createNewMapWinAfterSignal(tabs[i], itisedge); hegyi@114: } hegyi@114: hegyi@96: void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge) hegyi@96: { hegyi@96: std::vector::iterator nbti=tabs.begin(); hegyi@96: int i=0; hegyi@96: for(;nbti!=tabs.end();nbti++) hegyi@96: { hegyi@96: if(*nbti!=nbt) hegyi@96: { hegyi@96: i++; hegyi@96: } hegyi@96: else hegyi@96: { hegyi@96: continue; hegyi@96: } hegyi@96: } ladanyi@130: NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false); hegyi@96: nmw->run(); hegyi@96: } hegyi@154: hegyi@154: hegyi@154: void MainWin::nodeViewChanged() hegyi@154: { hegyi@157: double width=edge_width->get_value(); hegyi@157: double radius=radius_size->get_value(); hegyi@156: bool zoomtrack=zoom_track->get_active(); hegyi@154: bool autoscale=auto_scale->get_active(); hegyi@157: tabs[active_tab]->setView(autoscale, zoomtrack, width, radius); hegyi@154: } hegyi@160: hegyi@160: void MainWin::reDesignGraph() hegyi@160: { hegyi@160: tabs[active_tab]->reDesignGraph(); hegyi@160: } ladanyi@184: hegyi@191: void MainWin::exportToEPS() hegyi@191: { hegyi@191: if(active_tab!=-1) hegyi@191: { hegyi@191: tabs[active_tab]->createExportToEPSWin(tabnames[active_tab]); hegyi@191: } hegyi@191: } hegyi@191: ladanyi@184: void MainWin::createBackgroundChooser() ladanyi@184: { hegyi@194: BackgroundChooserDialog dialog(tabs[active_tab]->mapstorage); ladanyi@184: dialog.run(); ladanyi@184: }