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