[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)); |
---|
[6] | 102 | |
---|
[130] | 103 | ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) ); |
---|
| 104 | ag->add( Gtk::Action::create("AlgoGeneral", _("_General")), |
---|
[103] | 105 | sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) ); |
---|
[130] | 106 | ag->add( Gtk::Action::create("AlgoKruskal", _("_Kruskal")), |
---|
[106] | 107 | sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 1) ); |
---|
[103] | 108 | |
---|
[53] | 109 | Gtk::RadioAction::Group tool_group; |
---|
[130] | 110 | ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), _("Move")), |
---|
[96] | 111 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); |
---|
[130] | 112 | ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), _("Create node")), |
---|
[96] | 113 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) ); |
---|
[130] | 114 | ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), _("Create edge")), |
---|
[96] | 115 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) ); |
---|
[130] | 116 | ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), _("Delete")), |
---|
[96] | 117 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) ); |
---|
[60] | 118 | |
---|
[130] | 119 | ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), _("Edit edge map")), |
---|
[96] | 120 | sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) ); |
---|
[60] | 121 | |
---|
| 122 | ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")), |
---|
[96] | 123 | sigc::mem_fun ( *this , &MainWin::createNewMapWin ) ); |
---|
[22] | 124 | |
---|
[6] | 125 | uim=Gtk::UIManager::create(); |
---|
| 126 | uim->insert_action_group(ag); |
---|
| 127 | add_accel_group(uim->get_accel_group()); |
---|
| 128 | |
---|
| 129 | try |
---|
| 130 | { |
---|
| 131 | |
---|
| 132 | Glib::ustring ui_info = |
---|
| 133 | "<ui>" |
---|
| 134 | " <menubar name='MenuBar'>" |
---|
| 135 | " <menu action='FileMenu'>" |
---|
| 136 | " <menuitem action='FileNew'/>" |
---|
| 137 | " <menuitem action='FileOpen'/>" |
---|
[102] | 138 | " <menuitem action='FileClearTab'/>" |
---|
[6] | 139 | " <menuitem action='FileSave'/>" |
---|
| 140 | " <menuitem action='FileSaveAs'/>" |
---|
[53] | 141 | " <menuitem action='Close'/>" |
---|
| 142 | " <menuitem action='Quit'/>" |
---|
[6] | 143 | " </menu>" |
---|
| 144 | " <menu action='ViewMenu'>" |
---|
| 145 | " <menuitem action='ViewZoomIn' />" |
---|
| 146 | " <menuitem action='ViewZoomOut' />" |
---|
| 147 | " <menuitem action='ViewZoom100' />" |
---|
[87] | 148 | " <menuitem action='ViewZoomFit' />" |
---|
[6] | 149 | " </menu>" |
---|
| 150 | " <menu action='ShowMenu'>" |
---|
| 151 | " <menuitem action='ShowMaps'/>" |
---|
| 152 | " </menu>" |
---|
[103] | 153 | " <menu action='AlgoMenu'>" |
---|
| 154 | " <menuitem action='AlgoGeneral'/>" |
---|
[106] | 155 | " <menuitem action='AlgoKruskal'/>" |
---|
[103] | 156 | " </menu>" |
---|
[6] | 157 | " </menubar>" |
---|
| 158 | " <toolbar name='ToolBar'>" |
---|
| 159 | " <toolitem action='FileNew' />" |
---|
| 160 | " <toolitem action='FileOpen' />" |
---|
| 161 | " <toolitem action='FileSave' />" |
---|
[53] | 162 | " <toolitem action='Close' />" |
---|
[6] | 163 | " <separator />" |
---|
| 164 | " <toolitem action='ViewZoomIn' />" |
---|
| 165 | " <toolitem action='ViewZoomOut' />" |
---|
| 166 | " <toolitem action='ViewZoom100' />" |
---|
[87] | 167 | " <toolitem action='ViewZoomFit' />" |
---|
[22] | 168 | " <separator />" |
---|
[53] | 169 | " <toolitem action='MoveItem' />" |
---|
[22] | 170 | " <toolitem action='CreateNode' />" |
---|
| 171 | " <toolitem action='CreateEdge' />" |
---|
| 172 | " <toolitem action='EraseItem' />" |
---|
[32] | 173 | " <toolitem action='EditEdgeMap' />" |
---|
[60] | 174 | " <separator />" |
---|
[41] | 175 | " <toolitem action='AddMap' />" |
---|
[6] | 176 | " </toolbar>" |
---|
| 177 | "</ui>"; |
---|
| 178 | |
---|
| 179 | uim->add_ui_from_string(ui_info); |
---|
| 180 | |
---|
| 181 | } |
---|
| 182 | catch(const Glib::Error& ex) |
---|
| 183 | { |
---|
| 184 | std::cerr << "building menus failed: " << ex.what(); |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | Gtk::Widget* menubar = uim->get_widget("/MenuBar"); |
---|
| 188 | if (menubar){ |
---|
[154] | 189 | //vbox.pack_start(*menubar, Gtk::PACK_SHRINK); |
---|
| 190 | table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); |
---|
[6] | 191 | } |
---|
| 192 | |
---|
| 193 | Gtk::Widget* toolbar = uim->get_widget("/ToolBar"); |
---|
| 194 | if (toolbar) |
---|
| 195 | { |
---|
| 196 | static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS); |
---|
[154] | 197 | //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET); |
---|
| 198 | |
---|
| 199 | table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); |
---|
| 200 | |
---|
[6] | 201 | } |
---|
[156] | 202 | |
---|
[154] | 203 | table2.set_row_spacings(10); |
---|
| 204 | table2.set_col_spacings(5); |
---|
| 205 | |
---|
[156] | 206 | auto_scale = new Gtk::CheckButton("Autoscale"); |
---|
| 207 | auto_scale->set_active(false); |
---|
| 208 | auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
[154] | 209 | table2.attach(*auto_scale, 0,2,0,1); |
---|
[156] | 210 | |
---|
[154] | 211 | Gtk::Label * unit_label= new Gtk::Label("Unit:"); |
---|
[155] | 212 | // table2.attach(*unit_label, 2,3,0,1); |
---|
[154] | 213 | |
---|
| 214 | Gtk::Adjustment * adjustment_unit=new Gtk::Adjustment(20, 5, 200, 5, 10); |
---|
| 215 | |
---|
| 216 | radius_unit = new Gtk::SpinButton(*adjustment_unit, 5,0); |
---|
| 217 | radius_unit->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
[155] | 218 | // table2.attach(*radius_unit, 3,4,0,1); |
---|
[154] | 219 | |
---|
| 220 | Gtk::Label * min_label= new Gtk::Label("Min:"); |
---|
[155] | 221 | // table2.attach(*min_label, 0,1,1,2); |
---|
[154] | 222 | |
---|
| 223 | Gtk::Adjustment * adjustment_min=new Gtk::Adjustment(20, 5, 200, 5, 10); |
---|
| 224 | |
---|
| 225 | radius_min = new Gtk::SpinButton(*adjustment_min, 5,0); |
---|
| 226 | radius_min->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
[155] | 227 | // table2.attach(*radius_min, 1,2,1,2); |
---|
[154] | 228 | |
---|
[155] | 229 | Gtk::Label * max_label= new Gtk::Label("Size:"); |
---|
[154] | 230 | table2.attach(*max_label, 2,3,1,2); |
---|
| 231 | |
---|
[155] | 232 | Gtk::Adjustment * adjustment_max=new Gtk::Adjustment(20, 0, 200, 5, 10); |
---|
[154] | 233 | |
---|
| 234 | radius_max = new Gtk::SpinButton(*adjustment_max, 5,0); |
---|
| 235 | radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
| 236 | table2.attach(*radius_max, 3,4,1,2); |
---|
| 237 | |
---|
[156] | 238 | zoom_track = new Gtk::CheckButton("Zoom tracking"); |
---|
| 239 | zoom_track->set_active(false); |
---|
| 240 | zoom_track->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged)); |
---|
| 241 | table2.attach(*zoom_track, 2,4,0,1); |
---|
| 242 | |
---|
| 243 | |
---|
[154] | 244 | //vbox.pack_start(hbox, Gtk::PACK_SHRINK); |
---|
| 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 | //vbox.pack_start(notebook); |
---|
| 256 | table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); |
---|
[96] | 257 | |
---|
[6] | 258 | show_all_children(); |
---|
| 259 | } |
---|
| 260 | |
---|
[96] | 261 | void MainWin::set_tabtitle(std::string name) |
---|
[57] | 262 | { |
---|
[104] | 263 | if(strinst.find(name)==strinst.end()) |
---|
| 264 | { |
---|
| 265 | tabnames[active_tab]=name; |
---|
| 266 | strinst[name]=1; |
---|
| 267 | } |
---|
| 268 | else |
---|
| 269 | { |
---|
| 270 | strinst[name]++; |
---|
| 271 | std::ostringstream o; |
---|
| 272 | o << strinst[name]; |
---|
| 273 | tabnames[active_tab]=name+" - "+o.str(); |
---|
| 274 | } |
---|
[96] | 275 | set_title(tabnames[active_tab] + " - " + prog_name); |
---|
| 276 | notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); |
---|
[106] | 277 | updateAlgoWinTabs(); |
---|
[96] | 278 | } |
---|
| 279 | |
---|
| 280 | void MainWin::readFile(const std::string & filename) |
---|
| 281 | { |
---|
| 282 | newTab(); |
---|
| 283 | tabs[active_tab]->readFile(filename); |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | void MainWin::newTab() |
---|
| 287 | { |
---|
| 288 | int size=tabs.size(); |
---|
| 289 | tabs.resize(size+1); |
---|
| 290 | tabnames.resize(size+1); |
---|
| 291 | active_tab=size; |
---|
| 292 | tabs[active_tab]=new NoteBookTab(); |
---|
| 293 | tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle)); |
---|
| 294 | tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal)); |
---|
| 295 | tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
---|
| 296 | notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); |
---|
| 297 | notebook.set_current_page(size); |
---|
[130] | 298 | set_tabtitle(_("unsaved file")); |
---|
[106] | 299 | updateAlgoWinTabs(); |
---|
[96] | 300 | } |
---|
| 301 | |
---|
[97] | 302 | void MainWin::closeTab() |
---|
| 303 | { |
---|
| 304 | if(active_tab!=-1) |
---|
| 305 | { |
---|
[102] | 306 | if (tabs[active_tab]->mapstorage.modified) |
---|
| 307 | { |
---|
[130] | 308 | Gtk::MessageDialog mdialog(_("<b>Save changes before closing?</b>"), true, |
---|
[102] | 309 | Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE); |
---|
[130] | 310 | mdialog.add_button(_("Close file _without Saving"), Gtk::RESPONSE_REJECT); |
---|
[102] | 311 | mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
---|
| 312 | mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); |
---|
| 313 | switch (mdialog.run()) |
---|
| 314 | { |
---|
| 315 | case Gtk::RESPONSE_CANCEL: |
---|
| 316 | return; |
---|
| 317 | case Gtk::RESPONSE_REJECT: |
---|
| 318 | break; |
---|
| 319 | case Gtk::RESPONSE_ACCEPT: |
---|
| 320 | tabs[active_tab]->saveFile(); |
---|
| 321 | break; |
---|
| 322 | } |
---|
| 323 | } |
---|
[97] | 324 | //tabs vector will be decreased with the deleted value |
---|
| 325 | int size=tabs.size(); |
---|
| 326 | if(size>1) |
---|
| 327 | { |
---|
| 328 | for(int i=active_tab+1;i<size;i++) |
---|
| 329 | { |
---|
[103] | 330 | tabnames[i-1]=tabnames[i]; |
---|
[97] | 331 | tabs[i-1]=tabs[i]; |
---|
| 332 | } |
---|
| 333 | } |
---|
| 334 | //if size==1 resize will delete the only element |
---|
| 335 | tabs.resize(size-1); |
---|
[103] | 336 | tabnames.resize(size-1); |
---|
[97] | 337 | |
---|
| 338 | int old_active_tab=active_tab; |
---|
| 339 | notebook.remove_page(active_tab); |
---|
| 340 | |
---|
| 341 | //If the first tab was active, upon delete notebook |
---|
| 342 | //will first switch one tab upper and not lower like |
---|
| 343 | //in the case, when not the first tab was active. |
---|
| 344 | //But after deletion it will become the first tab, |
---|
| 345 | //and this should be registrated in tabs vector, |
---|
| 346 | //as well. |
---|
[103] | 347 | if((old_active_tab==0)&&(size!=1)) |
---|
[97] | 348 | { |
---|
| 349 | onChangeTab(NULL,0); |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | //if this was the last page in notebook, there is |
---|
| 353 | //no active_tab now |
---|
| 354 | if(size==1) |
---|
| 355 | { |
---|
| 356 | active_tab=-1; |
---|
| 357 | } |
---|
[103] | 358 | |
---|
[106] | 359 | updateAlgoWinTabs(); |
---|
[97] | 360 | } |
---|
| 361 | } |
---|
| 362 | |
---|
[96] | 363 | void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num) |
---|
| 364 | { |
---|
| 365 | page=page; |
---|
| 366 | active_tab=page_num; |
---|
| 367 | tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool); |
---|
| 368 | set_title(tabnames[active_tab]); |
---|
[154] | 369 | bool autoscale; |
---|
[156] | 370 | bool zoomtrack; |
---|
[154] | 371 | double min; |
---|
| 372 | double max; |
---|
| 373 | double unit; |
---|
[156] | 374 | tabs[active_tab]->getNodeView(autoscale, zoomtrack, min, max, unit); |
---|
[154] | 375 | radius_min->set_value(min); |
---|
| 376 | radius_max->set_value(max); |
---|
| 377 | radius_unit->set_value(unit); |
---|
[156] | 378 | zoom_track->set_active(zoomtrack); |
---|
[154] | 379 | auto_scale->set_active(autoscale); |
---|
| 380 | |
---|
[96] | 381 | } |
---|
| 382 | |
---|
[6] | 383 | void MainWin::newFile() |
---|
| 384 | { |
---|
[96] | 385 | if(active_tab!=-1) |
---|
[53] | 386 | { |
---|
[96] | 387 | tabs[active_tab]->newFile(); |
---|
[53] | 388 | } |
---|
[6] | 389 | } |
---|
[96] | 390 | |
---|
[6] | 391 | void MainWin::openFile() |
---|
| 392 | { |
---|
[140] | 393 | if(active_tab==-1) |
---|
[53] | 394 | { |
---|
[140] | 395 | newTab(); |
---|
[53] | 396 | } |
---|
[140] | 397 | tabs[active_tab]->openFile(); |
---|
[6] | 398 | } |
---|
[96] | 399 | |
---|
[6] | 400 | void MainWin::saveFile() |
---|
| 401 | { |
---|
[96] | 402 | if(active_tab!=-1) |
---|
| 403 | { |
---|
| 404 | tabs[active_tab]->saveFile(); |
---|
| 405 | } |
---|
[6] | 406 | } |
---|
[96] | 407 | |
---|
[6] | 408 | void MainWin::saveFileAs() |
---|
| 409 | { |
---|
[96] | 410 | if(active_tab!=-1) |
---|
| 411 | { |
---|
| 412 | tabs[active_tab]->saveFileAs(); |
---|
| 413 | } |
---|
[6] | 414 | } |
---|
[96] | 415 | |
---|
[53] | 416 | void MainWin::close() |
---|
| 417 | { |
---|
[96] | 418 | if(active_tab!=-1) |
---|
[53] | 419 | { |
---|
[96] | 420 | tabs[active_tab]->close(); |
---|
[95] | 421 | } |
---|
[94] | 422 | } |
---|
| 423 | |
---|
[96] | 424 | void MainWin::zoomIn() |
---|
[94] | 425 | { |
---|
[96] | 426 | if(active_tab!=-1) |
---|
[95] | 427 | { |
---|
[96] | 428 | tabs[active_tab]->gd_canvas->zoomIn(); |
---|
| 429 | } |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | void MainWin::zoomOut() |
---|
| 433 | { |
---|
| 434 | if(active_tab!=-1) |
---|
| 435 | { |
---|
| 436 | tabs[active_tab]->gd_canvas->zoomOut(); |
---|
| 437 | } |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | void MainWin::zoomFit() |
---|
| 441 | { |
---|
| 442 | if(active_tab!=-1) |
---|
| 443 | { |
---|
| 444 | tabs[active_tab]->gd_canvas->zoomFit(); |
---|
| 445 | } |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | void MainWin::zoom100() |
---|
| 449 | { |
---|
| 450 | if(active_tab!=-1) |
---|
| 451 | { |
---|
| 452 | tabs[active_tab]->gd_canvas->zoom100(); |
---|
[95] | 453 | } |
---|
[94] | 454 | } |
---|
[95] | 455 | |
---|
| 456 | void MainWin::createMapWin() |
---|
| 457 | { |
---|
[96] | 458 | if(active_tab!=-1) |
---|
[95] | 459 | { |
---|
[96] | 460 | tabs[active_tab]->createMapWin(tabnames[active_tab]); |
---|
[95] | 461 | } |
---|
| 462 | } |
---|
| 463 | |
---|
[103] | 464 | void MainWin::createAlgoWin(int algoid) |
---|
| 465 | { |
---|
[108] | 466 | AlgoWin * aw=new AlgoWin(algoid, tabnames); |
---|
[103] | 467 | aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); |
---|
[106] | 468 | aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps)); |
---|
[114] | 469 | aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString)); |
---|
[103] | 470 | aws.insert(aw); |
---|
| 471 | aw->show(); |
---|
| 472 | } |
---|
| 473 | |
---|
[106] | 474 | void MainWin::updateAlgoWinTabs() |
---|
[103] | 475 | { |
---|
| 476 | std::set< AlgoWin* >::iterator awsi=aws.begin(); |
---|
| 477 | for(;awsi!=aws.end();awsi++) |
---|
| 478 | { |
---|
| 479 | (*awsi)->update_tablist(tabnames); |
---|
| 480 | } |
---|
| 481 | } |
---|
| 482 | |
---|
[108] | 483 | void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname) |
---|
| 484 | { |
---|
| 485 | int i=0; |
---|
| 486 | for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++) |
---|
| 487 | { |
---|
| 488 | } |
---|
| 489 | awp->update_maplist(&(tabs[i]->mapstorage)); |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | void MainWin::deRegisterAlgoWin(AlgoWin * awp) |
---|
| 493 | { |
---|
| 494 | aws.erase(awp); |
---|
| 495 | } |
---|
| 496 | |
---|
[96] | 497 | void MainWin::changeEditorialTool(int tool) |
---|
[95] | 498 | { |
---|
[96] | 499 | active_tool=tool; |
---|
| 500 | if(active_tab!=-1) |
---|
| 501 | { |
---|
| 502 | tabs[active_tab]->gd_canvas->changeEditorialTool(tool); |
---|
| 503 | } |
---|
[95] | 504 | } |
---|
[96] | 505 | |
---|
| 506 | void MainWin::createNewMapWin() |
---|
| 507 | { |
---|
| 508 | if(active_tab!=-1) |
---|
| 509 | { |
---|
[130] | 510 | NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[active_tab], *(tabs[active_tab])); |
---|
[96] | 511 | nmw->show(); |
---|
| 512 | } |
---|
| 513 | } |
---|
| 514 | |
---|
[114] | 515 | void MainWin::createNewMapWinTabString(std::string tabname, bool itisedge) |
---|
| 516 | { |
---|
| 517 | int i=0; |
---|
[120] | 518 | for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++) |
---|
[114] | 519 | { |
---|
| 520 | } |
---|
| 521 | createNewMapWinAfterSignal(tabs[i], itisedge); |
---|
| 522 | } |
---|
| 523 | |
---|
[96] | 524 | void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge) |
---|
| 525 | { |
---|
| 526 | std::vector<NoteBookTab*>::iterator nbti=tabs.begin(); |
---|
| 527 | int i=0; |
---|
| 528 | for(;nbti!=tabs.end();nbti++) |
---|
| 529 | { |
---|
| 530 | if(*nbti!=nbt) |
---|
| 531 | { |
---|
| 532 | i++; |
---|
| 533 | } |
---|
| 534 | else |
---|
| 535 | { |
---|
| 536 | continue; |
---|
| 537 | } |
---|
| 538 | } |
---|
[130] | 539 | NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false); |
---|
[96] | 540 | nmw->run(); |
---|
| 541 | } |
---|
[154] | 542 | |
---|
| 543 | |
---|
| 544 | void MainWin::nodeViewChanged() |
---|
| 545 | { |
---|
| 546 | double min=radius_min->get_value(); |
---|
| 547 | double max=radius_max->get_value(); |
---|
| 548 | double unit=radius_unit->get_value(); |
---|
[156] | 549 | bool zoomtrack=zoom_track->get_active(); |
---|
[154] | 550 | bool autoscale=auto_scale->get_active(); |
---|
[156] | 551 | tabs[active_tab]->setNodeView(autoscale, zoomtrack, min, max, unit); |
---|
[154] | 552 | } |
---|