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