COIN-OR::LEMON - Graph Library

source: glemon-0.x/main_win.cc @ 201:879e47e5b731

Last change on this file since 201:879e47e5b731 was 201:879e47e5b731, checked in by Akos Ladanyi, 17 years ago

Merge branches/akos to trunk.

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