COIN-OR::LEMON - Graph Library

source: glemon/main_win.cc @ 1:67188bd752db

Last change on this file since 1:67188bd752db was 1:67188bd752db, checked in by Peter Hegyi <hegyi@…>, 13 years ago

SVN revision 3500 made compilable with Lemon 1.0.

File size: 21.0 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, "CreateArc", Gtk::StockID("gd-addlink"), _("Create arc")),
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, "EditArcMap", Gtk::StockID("gd-editlink"), _("Edit arc 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("DesignDigraph", Gtk::Stock::REFRESH),
170      sigc::mem_fun ( *this , &MainWin::reDesignDigraph ) );
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='CreateArc' />"
227      "    <toolitem action='EraseItem' />"
228      "    <toolitem action='EditArcMap' />"
229      "    <separator />"
230      "    <toolitem action='AddMap' />"
231      "    <toolitem action='DesignDigraph' />"
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 = Gtk::manage(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=Gtk::manage(new Gtk::Label("Arc Width:"));
270  table2.attach(*width_label, 0,1,1,2);
271 
272  Gtk::Adjustment * adjustment_width=Gtk::manage(new Gtk::Adjustment(20, 1, 200, 5, 10));
273 
274  arc_width = Gtk::manage(new Gtk::SpinButton(*adjustment_width, 5,0));
275  arc_width->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
276  table2.attach(*arc_width, 1,2,1,2);
277
278  Gtk::Label * radius_label= Gtk::manage(new Gtk::Label("Node Radius:"));
279  table2.attach(*radius_label, 2,3,1,2);
280 
281  Gtk::Adjustment * adjustment_radius=Gtk::manage(new Gtk::Adjustment(20, 0, 500, 5, 10));
282
283  radius_size = Gtk::manage(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 = Gtk::manage(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, arc widths and node radiuses are constant, independent from zooming");
299      tooltips->set_tip(*auto_scale, "If on, glemon automatically determines the size of arcs and nodes");
300      tooltips->set_tip(*radius_size, "Sets maximum node radius, if auto-scale is off");
301      tooltips->set_tip(*arc_width, "Sets maximum arc 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 digraph 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 digraph");
308      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomOut"))->set_tooltip(*tooltips, "Zoom out the digraph");
309      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoom100"))->set_tooltip(*tooltips, "Shows actual size of digraph");
310      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/ViewZoomFit"))->set_tooltip(*tooltips, "Fits digraph into window");
311      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/MoveItem"))->set_tooltip(*tooltips, "Moves the clicked item (arc/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/CreateArc"))->set_tooltip(*tooltips, "Lets you create new arc");
314      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EraseItem"))->set_tooltip(*tooltips, "Erases the clicked item (arc/node)");
315      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/EditArcMap"))->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 arc/nodemap");
317      static_cast<Gtk::ToolItem*>(uim->get_widget("/ToolBar/DesignDigraph"))->set_tooltip(*tooltips, "Redesigns your digraph, supposing elastic arcs 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
332MainWin::~MainWin()
333{
334}
335
336void MainWin::set_tabtitle(std::string name)
337{
338  if(strinst.find(name)==strinst.end())
339    {
340      tabnames[active_tab]=name;
341      strinst[name]=1;
342    }
343  else
344    {
345      strinst[name]++;
346      std::ostringstream o;
347      o << strinst[name];
348      tabnames[active_tab]=name+" - "+o.str();
349    }
350  set_title(tabnames[active_tab] + " - " + prog_name);
351  notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]);
352  updateAlgoWinTabs();
353}
354
355void MainWin::readFile(const std::string & filename)
356{
357  newTab();
358  tabs[active_tab]->readFile(filename);
359}
360
361void MainWin::newTab()
362{
363  int size=tabs.size();
364  tabs.resize(size+1);
365  tabnames.resize(size+1);
366  active_tab=size;
367  tabs[active_tab]=Gtk::manage(new NoteBookTab());
368  tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle));
369  tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal));
370  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
371  notebook.append_page((Gtk::Widget&)(*(tabs[active_tab])));
372  notebook.set_current_page(size);
373  set_tabtitle(_("unsaved file"));
374  updateAlgoWinTabs();
375}
376
377void MainWin::closeTab()
378{
379  if(active_tab!=-1)
380    {
381      if (tabs[active_tab]->mapstorage->getModified())
382        {
383          Gtk::MessageDialog mdialog(_("<b>Save changes before closing?</b>"), true,
384                                     Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
385          mdialog.add_button(_("Close file _without Saving"), Gtk::RESPONSE_REJECT);
386          mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
387          mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
388          switch (mdialog.run())
389            {
390            case Gtk::RESPONSE_CANCEL:
391              return;
392            case Gtk::RESPONSE_REJECT:
393              break;
394            case Gtk::RESPONSE_ACCEPT:
395              tabs[active_tab]->saveFile();
396              break;
397            }
398        }
399      //tabs vector will be decreased with the deleted value
400      int size=tabs.size();
401      if(size>1)
402        {
403          for(int i=active_tab+1;i<size;i++)
404            {
405              tabnames[i-1]=tabnames[i];
406              tabs[i-1]=tabs[i];
407            }
408        }
409      //if size==1 resize will delete the only element
410      tabs.resize(size-1);
411      tabnames.resize(size-1);
412
413      int old_active_tab=active_tab;
414      notebook.remove_page(active_tab);
415
416      //If the first tab was active, upon delete notebook
417      //will first switch one tab upper and not lower like
418      //in the case, when not the first tab was active.
419      //But after deletion it will become the first tab,
420      //and this should be registrated in tabs vector,
421      //as well.
422      if((old_active_tab==0)&&(size!=1))
423        {
424          onChangeTab(NULL,0);
425        }
426
427      //if this was the last page in notebook, there is
428      //no active_tab now
429      if(size==1)
430        {
431          active_tab=-1;
432        }
433
434      updateAlgoWinTabs();
435    }
436}
437
438void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num)
439{
440  page=page;
441  active_tab=page_num;
442  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
443  set_title(tabnames[active_tab]);
444  bool autoscale;
445  bool zoomtrack;
446  double width;
447  double radius;
448  tabs[active_tab]->getView(autoscale, zoomtrack, width, radius);
449  arc_width->set_value(width);
450  radius_size->set_value(radius);
451  zoom_track->set_active(zoomtrack);
452  auto_scale->set_active(autoscale);
453
454}
455
456void MainWin::newFile()
457{
458  if(active_tab!=-1)
459    {
460      tabs[active_tab]->newFile();
461    }
462}
463 
464void MainWin::openFile()
465{
466  if(active_tab==-1)
467    {
468      newTab();
469    }
470  tabs[active_tab]->openFile();
471}
472 
473void MainWin::saveFile()
474{
475  if(active_tab!=-1)
476    {
477      tabs[active_tab]->saveFile();
478    }
479}
480 
481void MainWin::saveFileAs()
482{
483  if(active_tab!=-1)
484    {
485      tabs[active_tab]->saveFileAs();
486    }
487}
488 
489void MainWin::close()
490{
491  if(active_tab!=-1)
492    {
493      tabs[active_tab]->close();
494    }
495}
496
497void MainWin::zoomIn()
498{
499  if(active_tab!=-1)
500    {
501      tabs[active_tab]->gd_canvas->zoomIn();
502    }
503}
504
505void MainWin::zoomOut()
506{
507  if(active_tab!=-1)
508    {
509      tabs[active_tab]->gd_canvas->zoomOut();
510    }
511}
512
513void MainWin::zoomFit()
514{
515  if(active_tab!=-1)
516    {
517      tabs[active_tab]->gd_canvas->zoomFit();
518    }
519}
520
521void MainWin::zoom100()
522{
523  if(active_tab!=-1)
524    {
525      tabs[active_tab]->gd_canvas->zoom100();
526    }
527}
528
529void MainWin::createMapWin()
530{
531  if(active_tab!=-1)
532    {
533      tabs[active_tab]->createMapWin(tabnames[active_tab]);
534    }
535}
536
537void MainWin::createDesignWin()
538{
539  if(active_tab!=-1)
540    {
541      tabs[active_tab]->createDesignWin(tabnames[active_tab]);
542    }
543}
544
545void MainWin::createAlgoWin(int algoid)
546{
547  AlgoWin * aw=Gtk::manage(new AlgoWin(algoid, tabnames));
548  aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
549  aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
550  aw->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinTabString));
551  aws.insert(aw);
552  aw->show();
553}
554
555void MainWin::updateAlgoWinTabs()
556{
557  std::set< AlgoWin* >::iterator awsi=aws.begin();
558  for(;awsi!=aws.end();awsi++)
559    {
560      (*awsi)->update_tablist(tabnames);
561    }
562}
563
564void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
565{
566  int i=0;
567  for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++)
568    {
569    }
570  awp->update_maplist(tabs[i]->mapstorage);
571}
572
573void MainWin::deRegisterAlgoWin(AlgoWin * awp)
574{
575  aws.erase(awp);
576}
577
578void MainWin::changeEditorialTool(int tool)
579{
580  active_tool=tool;
581  if(active_tab!=-1)
582    {
583      tabs[active_tab]->gd_canvas->changeEditorialTool(tool);
584    }
585}
586
587void MainWin::createNewMapWin()
588{
589  if(active_tab!=-1)
590    {
591      NewMapWin * nmw=Gtk::manage(new NewMapWin(_("Create New Map - ")+tabnames[active_tab], *(tabs[active_tab])));
592      nmw->show();
593    }
594}
595
596void MainWin::createNewMapWinTabString(std::string tabname, bool itisarc)
597{
598  int i=0;
599  for(;((i<(int)tabnames.size())&&(tabnames[i]!=tabname));i++)
600    {
601    }
602  createNewMapWinAfterSignal(tabs[i], itisarc);
603}
604
605void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisarc)
606{
607  std::vector<NoteBookTab*>::iterator nbti=tabs.begin();
608  int i=0;
609  for(;nbti!=tabs.end();nbti++)
610    {
611      if(*nbti!=nbt)
612        {
613          i++;
614        }
615      else
616        {
617          continue;
618        }
619    }
620  NewMapWin * nmw=Gtk::manage(new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisarc, false));
621  nmw->run();
622}
623
624
625void MainWin::nodeViewChanged()
626{
627  double width=arc_width->get_value();
628  double radius=radius_size->get_value();
629  bool zoomtrack=zoom_track->get_active();
630  bool autoscale=auto_scale->get_active();
631  tabs[active_tab]->setView(autoscale, zoomtrack, width, radius);
632}
633
634void MainWin::reDesignDigraph()
635{
636  tabs[active_tab]->reDesignDigraph();
637}
638
639void MainWin::createSaveDetailsDialog()
640{
641  SaveDetailsDialog dialog(tabs[active_tab]->mapstorage);
642  dialog.run();
643}
644
645void MainWin::exportToEPS()
646{
647  if(active_tab!=-1)
648    {
649      tabs[active_tab]->createExportToEPSWin(tabnames[active_tab]);
650    }
651}
652
653void MainWin::createBackgroundChooser()
654{
655  BackgroundChooserDialog dialog(tabs[active_tab]->mapstorage);
656  dialog.run();
657}
Note: See TracBrowser for help on using the repository browser.