[130] | 1 | #ifdef HAVE_CONFIG_H |
---|
| 2 | #include <config.h> |
---|
| 3 | #endif |
---|
| 4 | |
---|
[53] | 5 | #include "main_win.h" |
---|
[100] | 6 | #include "guipixbufs.h" |
---|
[6] | 7 | |
---|
[133] | 8 | #include "i18n.h" |
---|
[130] | 9 | |
---|
[96] | 10 | MainWin::MainWin() |
---|
[6] | 11 | { |
---|
[96] | 12 | set_title ("no file"); |
---|
[6] | 13 | set_default_size(WIN_WIDTH,WIN_HEIGHT); |
---|
[154] | 14 | //add(vbox); |
---|
| 15 | add(table); |
---|
[6] | 16 | |
---|
[60] | 17 | // custom icons for the toolbar |
---|
| 18 | Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create(); |
---|
| 19 | |
---|
[61] | 20 | Glib::RefPtr<Gdk::Pixbuf> p_move_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 21 | 2328, gui_icons_move); |
---|
| 22 | Glib::RefPtr<Gdk::Pixbuf> p_addnode_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 23 | 2328, gui_icons_addnode); |
---|
| 24 | Glib::RefPtr<Gdk::Pixbuf> p_addlink_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 25 | 2328, gui_icons_addlink); |
---|
| 26 | Glib::RefPtr<Gdk::Pixbuf> p_delete_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 27 | 2328, gui_icons_delete); |
---|
| 28 | Glib::RefPtr<Gdk::Pixbuf> p_editlink_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 29 | 2328, gui_icons_editlink); |
---|
| 30 | Glib::RefPtr<Gdk::Pixbuf> p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline( |
---|
| 31 | 2328, gui_icons_newmap); |
---|
[60] | 32 | |
---|
| 33 | Gtk::IconSource move_icon_source; |
---|
[61] | 34 | move_icon_source.set_pixbuf(p_move_pixbuf); |
---|
[60] | 35 | Gtk::IconSet move_icon_set; |
---|
| 36 | move_icon_set.add_source(move_icon_source); |
---|
| 37 | p_icon_factory->add(Gtk::StockID("gd-move"), move_icon_set); |
---|
| 38 | |
---|
| 39 | Gtk::IconSource addnode_icon_source; |
---|
[61] | 40 | addnode_icon_source.set_pixbuf(p_addnode_pixbuf); |
---|
[60] | 41 | Gtk::IconSet addnode_icon_set; |
---|
| 42 | addnode_icon_set.add_source(addnode_icon_source); |
---|
| 43 | p_icon_factory->add(Gtk::StockID("gd-addnode"), addnode_icon_set); |
---|
| 44 | |
---|
| 45 | Gtk::IconSource addlink_icon_source; |
---|
[61] | 46 | addlink_icon_source.set_pixbuf(p_addlink_pixbuf); |
---|
[60] | 47 | Gtk::IconSet addlink_icon_set; |
---|
| 48 | addlink_icon_set.add_source(addlink_icon_source); |
---|
| 49 | p_icon_factory->add(Gtk::StockID("gd-addlink"), addlink_icon_set); |
---|
| 50 | |
---|
| 51 | Gtk::IconSource delete_icon_source; |
---|
[61] | 52 | delete_icon_source.set_pixbuf(p_delete_pixbuf); |
---|
[60] | 53 | Gtk::IconSet delete_icon_set; |
---|
| 54 | delete_icon_set.add_source(delete_icon_source); |
---|
| 55 | p_icon_factory->add(Gtk::StockID("gd-delete"), delete_icon_set); |
---|
| 56 | |
---|
| 57 | Gtk::IconSource editlink_icon_source; |
---|
[61] | 58 | editlink_icon_source.set_pixbuf(p_editlink_pixbuf); |
---|
[60] | 59 | Gtk::IconSet editlink_icon_set; |
---|
| 60 | editlink_icon_set.add_source(editlink_icon_source); |
---|
| 61 | p_icon_factory->add(Gtk::StockID("gd-editlink"), editlink_icon_set); |
---|
| 62 | |
---|
| 63 | Gtk::IconSource newmap_icon_source; |
---|
[61] | 64 | newmap_icon_source.set_pixbuf(p_newmap_pixbuf); |
---|
[60] | 65 | Gtk::IconSet newmap_icon_set; |
---|
| 66 | newmap_icon_set.add_source(newmap_icon_source); |
---|
| 67 | p_icon_factory->add(Gtk::StockID("gd-newmap"), newmap_icon_set); |
---|
| 68 | |
---|
| 69 | p_icon_factory->add_default(); |
---|
| 70 | |
---|
[6] | 71 | ag=Gtk::ActionGroup::create(); |
---|
| 72 | |
---|
[130] | 73 | ag->add( Gtk::Action::create("FileMenu", _("_File")) ); |
---|
[102] | 74 | ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW), |
---|
[96] | 75 | sigc::mem_fun(*this, &MainWin::newTab)); |
---|
[6] | 76 | ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN), |
---|
| 77 | sigc::mem_fun(*this, &MainWin::openFile)); |
---|
[130] | 78 | ag->add( Gtk::Action::create("FileClearTab", _("Clear Tab")), |
---|
[102] | 79 | sigc::mem_fun(*this, &MainWin::newFile)); |
---|
[6] | 80 | ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE), |
---|
| 81 | sigc::mem_fun(*this, &MainWin::saveFile)); |
---|
| 82 | ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS), |
---|
| 83 | sigc::mem_fun(*this, &MainWin::saveFileAs)); |
---|
[53] | 84 | ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE), |
---|
[102] | 85 | sigc::mem_fun(*this, &MainWin::closeTab)); |
---|
[53] | 86 | ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT), |
---|
[47] | 87 | sigc::mem_fun(*this, &MainWin::hide)); |
---|
[6] | 88 | |
---|
[130] | 89 | ag->add( Gtk::Action::create("ViewMenu", _("_View")) ); |
---|
[6] | 90 | ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN), |
---|
[96] | 91 | sigc::mem_fun(*this, &MainWin::zoomIn)); |
---|
[6] | 92 | ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT), |
---|
[96] | 93 | sigc::mem_fun(*this, &MainWin::zoomOut)); |
---|
[6] | 94 | ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT), |
---|
[96] | 95 | sigc::mem_fun(*this, &MainWin::zoomFit)); |
---|
[6] | 96 | ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100), |
---|
[96] | 97 | sigc::mem_fun(*this, &MainWin::zoom100)); |
---|
[6] | 98 | |
---|
[130] | 99 | ag->add( Gtk::Action::create("ShowMenu", _("_Show")) ); |
---|
| 100 | ag->add( Gtk::Action::create("ShowMaps", _("_Maps")), |
---|
[95] | 101 | sigc::mem_fun(*this, &MainWin::createMapWin)); |
---|
[160] | 102 | ag->add( Gtk::Action::create("ShowDesign", _("_Design")), |
---|
| 103 | sigc::mem_fun(*this, &MainWin::createDesignWin)); |
---|
[6] | 104 | |
---|
[130] | 105 | ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) ); |
---|
| 106 | ag->add( Gtk::Action::create("AlgoGeneral", _("_General")), |
---|
[103] | 107 | sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) ); |
---|
[130] | 108 | ag->add( Gtk::Action::create("AlgoKruskal", _("_Kruskal")), |
---|
[106] | 109 | sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 1) ); |
---|
[162] | 110 | ag->add( Gtk::Action::create("AlgoDijkstra", _("_Dijkstra")), |
---|
| 111 | sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 2) ); |
---|
[103] | 112 | |
---|
[53] | 113 | Gtk::RadioAction::Group tool_group; |
---|
[130] | 114 | ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), _("Move")), |
---|
[96] | 115 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); |
---|
[130] | 116 | ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), _("Create node")), |
---|
[96] | 117 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) ); |
---|
[130] | 118 | ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), _("Create edge")), |
---|
[96] | 119 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) ); |
---|
[130] | 120 | ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), _("Delete")), |
---|
[96] | 121 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) ); |
---|
[60] | 122 | |
---|
[130] | 123 | ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), _("Edit edge map")), |
---|
[96] | 124 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) ); |
---|
[60] | 125 | |
---|
| 126 | ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), |
---|
[96] | 127 | sigc::mem_fun ( *this , &MainWin::createNewMapWin ) ); |
---|
[22] | 128 | |
---|
[160] | 129 | ag->add( Gtk::Action::create("DesignGraph", Gtk::Stock::REFRESH), |
---|
| 130 | sigc::mem_fun ( *this , &MainWin::reDesignGraph ) ); |
---|
| 131 | |
---|
[6] | 132 | uim=Gtk::UIManager::create(); |
---|
| 133 | uim->insert_action_group(ag); |
---|
| 134 | add_accel_group(uim->get_accel_group()); |
---|
| 135 | |
---|
| 136 | try |
---|
| 137 | { |
---|
| 138 | |
---|
| 139 | Glib::ustring ui_info = |
---|
| 140 | "<ui>" |
---|
| 141 | " <menubar name='MenuBar'>" |
---|
| 142 | " <menu action='FileMenu'>" |
---|
| 143 | " <menuitem action='FileNew'/>" |
---|
| 144 | " <menuitem action='FileOpen'/>" |
---|
[102] | 145 | " <menuitem action='FileClearTab'/>" |
---|
[6] | 146 | " <menuitem action='FileSave'/>" |
---|
| 147 | " <menuitem action='FileSaveAs'/>" |
---|
[53] | 148 | " <menuitem action='Close'/>" |
---|
| 149 | " <menuitem action='Quit'/>" |
---|
[6] | 150 | " </menu>" |
---|
| 151 | " <menu action='ViewMenu'>" |
---|
| 152 | " <menuitem action='ViewZoomIn' />" |
---|
| 153 | " <menuitem action='ViewZoomOut' />" |
---|
| 154 | " <menuitem action='ViewZoom100' />" |
---|
[87] | 155 | " <menuitem action='ViewZoomFit' />" |
---|
[6] | 156 | " </menu>" |
---|
| 157 | " <menu action='ShowMenu'>" |
---|
| 158 | " <menuitem action='ShowMaps'/>" |
---|
[160] | 159 | " <menuitem action='ShowDesign'/>" |
---|
[6] | 160 | " </menu>" |
---|
[103] | 161 | " <menu action='AlgoMenu'>" |
---|
| 162 | " <menuitem action='AlgoGeneral'/>" |
---|
[106] | 163 | " <menuitem action='AlgoKruskal'/>" |
---|
[162] | 164 | " <menuitem action='AlgoDijkstra'/>" |
---|
[103] | 165 | " </menu>" |
---|
[6] | 166 | " </menubar>" |
---|
| 167 | " <toolbar name='ToolBar'>" |
---|
| 168 | " <toolitem action='FileNew' />" |
---|
| 169 | " <toolitem action='FileOpen' />" |
---|
| 170 | " <toolitem action='FileSave' />" |
---|
[53] | 171 | " <toolitem action='Close' />" |
---|
[6] | 172 | " <separator />" |
---|
| 173 | " <toolitem action='ViewZoomIn' />" |
---|
| 174 | " <toolitem action='ViewZoomOut' />" |
---|
| 175 | " <toolitem action='ViewZoom100' />" |
---|
[87] | 176 | " <toolitem action='ViewZoomFit' />" |
---|
[22] | 177 | " <separator />" |
---|
[53] | 178 | " <toolitem action='MoveItem' />" |
---|
[22] | 179 | " <toolitem action='CreateNode' />" |
---|
| 180 | " <toolitem action='CreateEdge' />" |
---|
| 181 | " <toolitem action='EraseItem' />" |
---|
[32] | 182 | " <toolitem action='EditEdgeMap' />" |
---|
[60] | 183 | " <separator />" |
---|
[41] | 184 | " <toolitem action='AddMap' />" |
---|
[160] | 185 | " <toolitem action='DesignGraph' />" |
---|
[6] | 186 | " </toolbar>" |
---|
| 187 | "</ui>"; |
---|
| 188 | |
---|
| 189 | uim->add_ui_from_string(ui_info); |
---|
| 190 | |
---|
| 191 | } |
---|
| 192 | catch(const Glib::Error& ex) |
---|
| 193 | { |
---|
| 194 | std::cerr << "building menus failed: " << ex.what(); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | Gtk::Widget* menubar = uim->get_widget("/MenuBar"); |
---|
| 198 | if (menubar){ |
---|
[154] | 199 | //vbox.pack_start(*menubar, Gtk::PACK_SHRINK); |
---|
| 200 | table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); |
---|
[6] | 201 | } |
---|
| 202 | |
---|
| 203 | Gtk::Widget* toolbar = uim->get_widget("/ToolBar"); |
---|
| 204 | if (toolbar) |
---|
| 205 | { |
---|
| 206 | static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); |
---|
[154] | 207 | //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET); |
---|
| 208 | |
---|
| 209 | table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); |
---|
| 210 | |
---|
[6] | 211 | } |
---|
[156] | 212 | |
---|
[154] | 213 | table2.set_row_spacings(10); |
---|
| 214 | table2.set_col_spacings(5); |
---|
| 215 | |
---|
[156] | 216 | auto_scale = new Gtk::CheckButton("Autoscale"); |
---|
| 217 | auto_scale->set_active(false); |
---|
| 218 | auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
[154] | 219 | table2.attach(*auto_scale, 0,2,0,1); |
---|
[156] | 220 | |
---|
[157] | 221 | Gtk::Label * width_label= new Gtk::Label("Edge Width:"); |
---|
| 222 | table2.attach(*width_label, 0,1,1,2); |
---|
[154] | 223 | |
---|
[157] | 224 | Gtk::Adjustment * adjustment_width=new Gtk::Adjustment(20, 1, 200, 5, 10); |
---|
| 225 | |
---|
| 226 | edge_width = new Gtk::SpinButton(*adjustment_width, 5,0); |
---|
| 227 | edge_width->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
| 228 | table2.attach(*edge_width, 1,2,1,2); |
---|
[154] | 229 | |
---|
[157] | 230 | Gtk::Label * radius_label= new Gtk::Label("Node Radius:"); |
---|
| 231 | table2.attach(*radius_label, 2,3,1,2); |
---|
| 232 | |
---|
| 233 | Gtk::Adjustment * adjustment_radius=new Gtk::Adjustment(20, 0, 500, 5, 10); |
---|
[154] | 234 | |
---|
[157] | 235 | radius_size = new Gtk::SpinButton(*adjustment_radius, 5,0); |
---|
| 236 | radius_size->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
| 237 | table2.attach(*radius_size, 3,4,1,2); |
---|
[154] | 238 | |
---|
[156] | 239 | zoom_track = new Gtk::CheckButton("Zoom tracking"); |
---|
| 240 | zoom_track->set_active(false); |
---|
| 241 | zoom_track->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
| 242 | table2.attach(*zoom_track, 2,4,0,1); |
---|
| 243 | |
---|
| 244 | |
---|
[154] | 245 | table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK); |
---|
| 246 | |
---|
[50] | 247 | tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node"); |
---|
| 248 | tooltips.enable(); |
---|
[6] | 249 | |
---|
[96] | 250 | active_tab=-1; |
---|
| 251 | notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab)); |
---|
| 252 | |
---|
[107] | 253 | active_tool = MOVE; |
---|
| 254 | |
---|
[154] | 255 | table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); |
---|
[96] | 256 | |
---|
[6] | 257 | show_all_children(); |
---|
| 258 | } |
---|
| 259 | |
---|
[96] | 260 | void MainWin::set_tabtitle(std::string name) |
---|
[57] | 261 | { |
---|
[104] | 262 | if(strinst.find(name)==strinst.end()) |
---|
| 263 | { |
---|
| 264 | tabnames[active_tab]=name; |
---|
| 265 | strinst[name]=1; |
---|
| 266 | } |
---|
| 267 | else |
---|
| 268 | { |
---|
| 269 | strinst[name]++; |
---|
| 270 | std::ostringstream o; |
---|
| 271 | o << strinst[name]; |
---|
| 272 | tabnames[active_tab]=name+" - "+o.str(); |
---|
| 273 | } |
---|
[96] | 274 | set_title(tabnames[active_tab] + " - " + prog_name); |
---|
| 275 | notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); |
---|
[106] | 276 | updateAlgoWinTabs(); |
---|
[96] | 277 | } |
---|
| 278 | |
---|
| 279 | void MainWin::readFile(const std::string & filename) |
---|
| 280 | { |
---|
| 281 | newTab(); |
---|
| 282 | tabs[active_tab]->readFile(filename); |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | void MainWin::newTab() |
---|
| 286 | { |
---|
| 287 | int size=tabs.size(); |
---|
| 288 | tabs.resize(size+1); |
---|
| 289 | tabnames.resize(size+1); |
---|
| 290 | active_tab=size; |
---|
| 291 | tabs[active_tab]=new NoteBookTab(); |
---|
| 292 | tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle)); |
---|
| 293 | tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal)); |
---|
| 294 | tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
---|
| 295 | notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); |
---|
| 296 | notebook.set_current_page(size); |
---|
[130] | 297 | set_tabtitle(_("unsaved file")); |
---|
[106] | 298 | updateAlgoWinTabs(); |
---|
[96] | 299 | } |
---|
| 300 | |
---|
[97] | 301 | void MainWin::closeTab() |
---|
| 302 | { |
---|
| 303 | if(active_tab!=-1) |
---|
| 304 | { |
---|
[102] | 305 | if (tabs[active_tab]->mapstorage.modified) |
---|
| 306 | { |
---|
[130] | 307 | Gtk::MessageDialog mdialog(_("<b>Save changes before closing?</b>"), true, |
---|
[102] | 308 | Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
---|
[130] | 309 | mdialog.add_button(_("Close file _without Saving"), Gtk::RESPONSE_REJECT); |
---|
[102] | 310 | mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
---|
| 311 | mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); |
---|
| 312 | switch (mdialog.run()) |
---|
| 313 | { |
---|
| 314 | case Gtk::RESPONSE_CANCEL: |
---|
| 315 | return; |
---|
| 316 | case Gtk::RESPONSE_REJECT: |
---|
| 317 | break; |
---|
| 318 | case Gtk::RESPONSE_ACCEPT: |
---|
| 319 | tabs[active_tab]->saveFile(); |
---|
| 320 | break; |
---|
| 321 | } |
---|
| 322 | } |
---|
[97] | 323 | //tabs vector will be decreased with the deleted value |
---|
| 324 | int size=tabs.size(); |
---|
| 325 | if(size>1) |
---|
| 326 | { |
---|
| 327 | for(int i=active_tab+1;i<size;i++) |
---|
| 328 | { |
---|
[103] | 329 | tabnames[i-1]=tabnames[i]; |
---|
[97] | 330 | tabs[i-1]=tabs[i]; |
---|
| 331 | } |
---|
| 332 | } |
---|
| 333 | //if size==1 resize will delete the only element |
---|
| 334 | tabs.resize(size-1); |
---|
[103] | 335 | tabnames.resize(size-1); |
---|
[97] | 336 | |
---|
| 337 | int old_active_tab=active_tab; |
---|
| 338 | notebook.remove_page(active_tab); |
---|
| 339 | |
---|
| 340 | //If the first tab was active, upon delete notebook |
---|
| 341 | //will first switch one tab upper and not lower like |
---|
| 342 | //in the case, when not the first tab was active. |
---|
| 343 | //But after deletion it will become the first tab, |
---|
| 344 | //and this should be registrated in tabs vector, |
---|
| 345 | //as well. |
---|
[103] | 346 | if((old_active_tab==0)&&(size!=1)) |
---|
[97] | 347 | { |
---|
| 348 | onChangeTab(NULL,0); |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | //if this was the last page in notebook, there is |
---|
| 352 | //no active_tab now |
---|
| 353 | if(size==1) |
---|
| 354 | { |
---|
| 355 | active_tab=-1; |
---|
| 356 | } |
---|
[103] | 357 | |
---|
[106] | 358 | updateAlgoWinTabs(); |
---|
[97] | 359 | } |
---|
| 360 | } |
---|
| 361 | |
---|
[96] | 362 | void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num) |
---|
| 363 | { |
---|
| 364 | page=page; |
---|
| 365 | active_tab=page_num; |
---|
| 366 | tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
---|
| 367 | set_title(tabnames[active_tab]); |
---|
[154] | 368 | bool autoscale; |
---|
[156] | 369 | bool zoomtrack; |
---|
[157] | 370 | double width; |
---|
| 371 | double radius; |
---|
| 372 | tabs[active_tab]->getView(autoscale, zoomtrack, width, radius); |
---|
| 373 | edge_width->set_value(width); |
---|
| 374 | radius_size->set_value(radius); |
---|
[156] | 375 | zoom_track->set_active(zoomtrack); |
---|
[154] | 376 | auto_scale->set_active(autoscale); |
---|
| 377 | |
---|
[96] | 378 | } |
---|
| 379 | |
---|
[6] | 380 | void MainWin::newFile() |
---|
| 381 | { |
---|
[96] | 382 | if(active_tab!=-1) |
---|
[53] | 383 | { |
---|
[96] | 384 | tabs[active_tab]->newFile(); |
---|
[53] | 385 | } |
---|
[6] | 386 | } |
---|
[96] | 387 | |
---|
[6] | 388 | void MainWin::openFile() |
---|
| 389 | { |
---|
[140] | 390 | if(active_tab==-1) |
---|
[53] | 391 | { |
---|
[140] | 392 | newTab(); |
---|
[53] | 393 | } |
---|
[140] | 394 | tabs[active_tab]->openFile(); |
---|
[6] | 395 | } |
---|
[96] | 396 | |
---|
[6] | 397 | void MainWin::saveFile() |
---|
| 398 | { |
---|
[96] | 399 | if(active_tab!=-1) |
---|
| 400 | { |
---|
| 401 | tabs[active_tab]->saveFile(); |
---|
| 402 | } |
---|
[6] | 403 | } |
---|
[96] | 404 | |
---|
[6] | 405 | void MainWin::saveFileAs() |
---|
| 406 | { |
---|
[96] | 407 | if(active_tab!=-1) |
---|
| 408 | { |
---|
| 409 | tabs[active_tab]->saveFileAs(); |
---|
| 410 | } |
---|
[6] | 411 | } |
---|
[96] | 412 | |
---|
[53] | 413 | void MainWin::close() |
---|
| 414 | { |
---|
[96] | 415 | if(active_tab!=-1) |
---|
[53] | 416 | { |
---|
[96] | 417 | tabs[active_tab]->close(); |
---|
[95] | 418 | } |
---|
[94] | 419 | } |
---|
| 420 | |
---|
[96] | 421 | void MainWin::zoomIn() |
---|
[94] | 422 | { |
---|
[96] | 423 | if(active_tab!=-1) |
---|
[95] | 424 | { |
---|
[96] | 425 | tabs[active_tab]->gd_canvas->zoomIn(); |
---|
| 426 | } |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | void MainWin::zoomOut() |
---|
| 430 | { |
---|
| 431 | if(active_tab!=-1) |
---|
| 432 | { |
---|
| 433 | tabs[active_tab]->gd_canvas->zoomOut(); |
---|
| 434 | } |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | void MainWin::zoomFit() |
---|
| 438 | { |
---|
| 439 | if(active_tab!=-1) |
---|
| 440 | { |
---|
| 441 | tabs[active_tab]->gd_canvas->zoomFit(); |
---|
| 442 | } |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | void MainWin::zoom100() |
---|
| 446 | { |
---|
| 447 | if(active_tab!=-1) |
---|
| 448 | { |
---|
| 449 | tabs[active_tab]->gd_canvas->zoom100(); |
---|
[95] | 450 | } |
---|
[94] | 451 | } |
---|
[95] | 452 | |
---|
| 453 | void MainWin::createMapWin() |
---|
| 454 | { |
---|
[96] | 455 | if(active_tab!=-1) |
---|
[95] | 456 | { |
---|
[96] | 457 | tabs[active_tab]->createMapWin(tabnames[active_tab]); |
---|
[95] | 458 | } |
---|
| 459 | } |
---|
| 460 | |
---|
[160] | 461 | void MainWin::createDesignWin() |
---|
| 462 | { |
---|
| 463 | if(active_tab!=-1) |
---|
| 464 | { |
---|
| 465 | tabs[active_tab]->createDesignWin(tabnames[active_tab]); |
---|
| 466 | } |
---|
| 467 | } |
---|
| 468 | |
---|
[103] | 469 | void MainWin::createAlgoWin(int algoid) |
---|
| 470 | { |
---|
[108] | 471 | AlgoWin * aw=new AlgoWin(algoid, tabnames); |
---|
[103] | 472 | aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); |
---|
[106] | 473 | aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps)); |
---|
[114] | 474 | aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString)); |
---|
[103] | 475 | aws.insert(aw); |
---|
| 476 | aw->show(); |
---|
| 477 | } |
---|
| 478 | |
---|
[106] | 479 | void MainWin::updateAlgoWinTabs() |
---|
[103] | 480 | { |
---|
| 481 | std::set< AlgoWin* >::iterator awsi=aws.begin(); |
---|
| 482 | for(;awsi!=aws.end();awsi++) |
---|
| 483 | { |
---|
| 484 | (*awsi)->update_tablist(tabnames); |
---|
| 485 | } |
---|
| 486 | } |
---|
| 487 | |
---|
[108] | 488 | void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname) |
---|
| 489 | { |
---|
| 490 | int i=0; |
---|
| 491 | for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++) |
---|
| 492 | { |
---|
| 493 | } |
---|
| 494 | awp->update_maplist(&(tabs[i]->mapstorage)); |
---|
| 495 | } |
---|
| 496 | |
---|
| 497 | void MainWin::deRegisterAlgoWin(AlgoWin * awp) |
---|
| 498 | { |
---|
| 499 | aws.erase(awp); |
---|
| 500 | } |
---|
| 501 | |
---|
[96] | 502 | void MainWin::changeEditorialTool(int tool) |
---|
[95] | 503 | { |
---|
[96] | 504 | active_tool=tool; |
---|
| 505 | if(active_tab!=-1) |
---|
| 506 | { |
---|
| 507 | tabs[active_tab]->gd_canvas->changeEditorialTool(tool); |
---|
| 508 | } |
---|
[95] | 509 | } |
---|
[96] | 510 | |
---|
| 511 | void MainWin::createNewMapWin() |
---|
| 512 | { |
---|
| 513 | if(active_tab!=-1) |
---|
| 514 | { |
---|
[130] | 515 | NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[active_tab], *(tabs[active_tab])); |
---|
[96] | 516 | nmw->show(); |
---|
| 517 | } |
---|
| 518 | } |
---|
| 519 | |
---|
[114] | 520 | void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge) |
---|
| 521 | { |
---|
| 522 | int i=0; |
---|
[120] | 523 | for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++) |
---|
[114] | 524 | { |
---|
| 525 | } |
---|
| 526 | createNewMapWinAfterSignal(tabs[i], itisedge); |
---|
| 527 | } |
---|
| 528 | |
---|
[96] | 529 | void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge) |
---|
| 530 | { |
---|
| 531 | std::vector<NoteBookTab*>::iterator nbti=tabs.begin(); |
---|
| 532 | int i=0; |
---|
| 533 | for(;nbti!=tabs.end();nbti++) |
---|
| 534 | { |
---|
| 535 | if(*nbti!=nbt) |
---|
| 536 | { |
---|
| 537 | i++; |
---|
| 538 | } |
---|
| 539 | else |
---|
| 540 | { |
---|
| 541 | continue; |
---|
| 542 | } |
---|
| 543 | } |
---|
[130] | 544 | NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false); |
---|
[96] | 545 | nmw->run(); |
---|
| 546 | } |
---|
[154] | 547 | |
---|
| 548 | |
---|
| 549 | void MainWin::nodeViewChanged() |
---|
| 550 | { |
---|
[157] | 551 | double width=edge_width->get_value(); |
---|
| 552 | double radius=radius_size->get_value(); |
---|
[156] | 553 | bool zoomtrack=zoom_track->get_active(); |
---|
[154] | 554 | bool autoscale=auto_scale->get_active(); |
---|
[157] | 555 | tabs[active_tab]->setView(autoscale, zoomtrack, width, radius); |
---|
[154] | 556 | } |
---|
[160] | 557 | |
---|
| 558 | void MainWin::reDesignGraph() |
---|
| 559 | { |
---|
| 560 | tabs[active_tab]->reDesignGraph(); |
---|
| 561 | } |
---|