Forgot the meat.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
22 NoteBookTab::NoteBookTab():mapwinexists(false), designwinexists(false), mapstorage(*this)
24 Gtk::ScrolledWindow *pScrolledWindow = manage(new Gtk::ScrolledWindow);
25 gd_canvas=new GraphDisplayerCanvas(*this);
26 pScrolledWindow->add(*gd_canvas);
27 add(*pScrolledWindow);
29 //connecting signals - controller character
30 mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
31 mapstorage.signal_node_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewNodeMap));
32 mapstorage.signal_edge_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewEdgeMap));
37 void NoteBookTab::readFile(const std::string &file)
39 mapstorage.readFromFile(file);
40 mapstorage.file_name = file;
41 mapstorage.modified = false;
42 gd_canvas->drawGraph();
45 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
47 signal_title.emit(Glib::filename_display_basename(file));
50 void NoteBookTab::newFile()
52 if (mapstorage.modified)
54 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
55 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
56 mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
57 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
58 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
59 switch (mdialog.run())
61 case Gtk::RESPONSE_CANCEL:
63 case Gtk::RESPONSE_REJECT:
65 case Gtk::RESPONSE_ACCEPT:
74 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
76 signal_title.emit("unsaved file");
79 void NoteBookTab::openFile()
81 if (mapstorage.modified)
83 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
84 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
85 mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
86 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
87 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
88 switch (mdialog.run())
90 case Gtk::RESPONSE_CANCEL:
92 case Gtk::RESPONSE_REJECT:
94 case Gtk::RESPONSE_ACCEPT:
99 Gtk::FileChooserDialog fcdialog("Open File");
100 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
101 fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
102 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
106 Glib::ustring filename = fcdialog.get_filename();
107 if (!mapstorage.readFromFile(filename))
109 mapstorage.file_name = filename;
110 mapstorage.modified = false;
111 gd_canvas->drawGraph();
114 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
116 signal_title.emit(Glib::filename_display_basename(filename));
121 void NoteBookTab::saveFile()
123 if (mapstorage.file_name == "") {
128 mapstorage.writeToFile(mapstorage.file_name);
129 mapstorage.modified = false;
130 signal_title.emit(Glib::filename_display_basename(mapstorage.file_name));
134 void NoteBookTab::saveFileAs()
136 Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE);
137 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
138 fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
139 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
141 Glib::ustring filename = fcdialog.get_filename();
142 mapstorage.file_name = filename;
143 mapstorage.writeToFile(filename);
144 mapstorage.modified = false;
145 signal_title.emit(Glib::filename_display_basename(filename));
149 void NoteBookTab::close()
151 if (mapstorage.modified)
153 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
154 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
155 mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
156 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
157 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
158 switch (mdialog.run())
160 case Gtk::RESPONSE_CANCEL:
162 case Gtk::RESPONSE_REJECT:
164 case Gtk::RESPONSE_ACCEPT:
173 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
175 signal_title.emit("unsaved file");
178 void NoteBookTab::propertyChange(bool itisedge, int prop, std::string mapname)
180 mapstorage.changeActiveMap(itisedge, prop, mapname);
183 sigc::signal<void, NoteBookTab *, bool> NoteBookTab::signal_newmap_needed()
185 return signal_newmap;
188 void NoteBookTab::popupNewMapWin(bool itisedge)
190 signal_newmap.emit(this, itisedge);
193 std::string NoteBookTab::getActiveEdgeMap(int prop)
195 return mapstorage.getActiveEdgeMap(prop);
198 std::string NoteBookTab::getActiveNodeMap(int prop)
200 return mapstorage.getActiveNodeMap(prop);
203 void NoteBookTab::registerNewEdgeMap(std::string mapname)
207 mapwin->registerNewEdgeMap(mapname);
211 void NoteBookTab::registerNewNodeMap(std::string mapname)
215 mapwin->registerNewNodeMap(mapname);
219 void NoteBookTab::createMapWin(std::string name)
223 mapwin=new MapWin("Map Setup - "+name, mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
224 mapst2mapwin=mapstorage.signal_map_win_ch().connect(sigc::mem_fun(*mapwin, &MapWin::changeEntry));
230 void NoteBookTab::createExportToEPSWin(std::string name)
234 epswin=new EpsWin("Export to EPS - "+name, *this);
241 void NoteBookTab::createDesignWin(std::string name)
245 double attraction, propulsation;
247 mapstorage.get_design_data(attraction, propulsation, iterations);
248 designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations, *this);
250 designwin->signal_attraction().connect(sigc::mem_fun(mapstorage, &MapStorage::set_attraction));
251 designwin->signal_propulsation().connect(sigc::mem_fun(mapstorage, &MapStorage::set_propulsation));
252 designwin->signal_iteration().connect(sigc::mem_fun(mapstorage, &MapStorage::set_iteration));
253 designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::reDesignGraph));
255 designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin));
257 mapst2designwin=mapstorage.signal_design_win_ch().connect(sigc::mem_fun(*designwin, &DesignWin::set_data));
260 designwinexists=true;
264 void NoteBookTab::closeMapWin()
266 mapst2mapwin.disconnect();
271 void NoteBookTab::closeEpsWin()
277 bool NoteBookTab::closeDesignWin(GdkEventAny * e)
279 if(e->type==GDK_DELETE)
281 designwinexists=false;
282 mapst2designwin.disconnect();
287 sigc::signal<void, std::string> NoteBookTab::signal_title_ch()
292 void NoteBookTab::setView(bool autoscale, bool zoomtrack, double width, double radius)
294 gd_canvas->setView(autoscale, zoomtrack, width, radius);
297 void NoteBookTab::getView(bool & autoscale, bool & zoomtrack, double& width, double& radius)
299 gd_canvas->getView(autoscale, zoomtrack, width, radius);
302 void NoteBookTab::reDesignGraph()
304 gd_canvas->reDesignGraph();
307 void NoteBookTab::active_maps_needed()
309 mapstorage.broadcastActiveMaps();
312 void NoteBookTab::exportGraphToEPS(std::vector<bool> options, std::string filename)
314 mapstorage.exportGraphToEPS(options, filename);