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