COIN-OR::LEMON - Graph Library

source: glemon-0.x/main_win.cc @ 197:c1084e2bff10

Last change on this file since 197:c1084e2bff10 was 194:6b2b718420eb, checked in by Hegyi Péter, 13 years ago

Header reorganising

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