Add autopackage specfile (not yet working).
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
20 #include "file_chooser_extra_widget.h"
22 NoteBookTab::NoteBookTab():mapwinexists(false), designwinexists(false)
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 FileChooserExtraWidget w(&mapstorage);
140 fcdialog.set_extra_widget(w);
141 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
143 Glib::ustring filename = fcdialog.get_filename();
144 mapstorage.file_name = filename;
145 mapstorage.writeToFile(filename);
146 mapstorage.modified = false;
147 signal_title.emit(Glib::filename_display_basename(filename));
151 void NoteBookTab::close()
153 if (mapstorage.modified)
155 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
156 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
157 mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
158 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
159 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
160 switch (mdialog.run())
162 case Gtk::RESPONSE_CANCEL:
164 case Gtk::RESPONSE_REJECT:
166 case Gtk::RESPONSE_ACCEPT:
175 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
177 signal_title.emit("unsaved file");
180 void NoteBookTab::propertyChange(bool itisedge, int prop, std::string mapname)
182 mapstorage.changeActiveMap(itisedge, prop, mapname);
185 sigc::signal<void, NoteBookTab *, bool> NoteBookTab::signal_newmap_needed()
187 return signal_newmap;
190 void NoteBookTab::popupNewMapWin(bool itisedge)
192 signal_newmap.emit(this, itisedge);
195 std::string NoteBookTab::getActiveEdgeMap(int prop)
197 return mapstorage.getActiveEdgeMap(prop);
200 std::string NoteBookTab::getActiveNodeMap(int prop)
202 return mapstorage.getActiveNodeMap(prop);
205 void NoteBookTab::registerNewEdgeMap(std::string mapname)
209 mapwin->registerNewEdgeMap(mapname);
213 void NoteBookTab::registerNewNodeMap(std::string mapname)
217 mapwin->registerNewNodeMap(mapname);
221 void NoteBookTab::createMapWin(std::string name)
225 mapwin=new MapWin("Map Setup - "+name, mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
226 mapst2mapwin=mapstorage.signal_map_win_ch().connect(sigc::mem_fun(*mapwin, &MapWin::changeEntry));
232 void NoteBookTab::createDesignWin(std::string name)
236 double attraction, propulsation;
238 gd_canvas->get_design_data(attraction, propulsation, iterations);
239 designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations, *this);
241 designwin->signal_attraction().connect(sigc::mem_fun(*this, &NoteBookTab::attraction_ch));
242 designwin->signal_propulsation().connect(sigc::mem_fun(*this, &NoteBookTab::propulsation_ch));
243 designwin->signal_iteration().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::set_iteration));
244 designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::reDesignGraph));
246 designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin));
249 designwinexists=true;
253 void NoteBookTab::closeMapWin()
255 mapst2mapwin.disconnect();
260 bool NoteBookTab::closeDesignWin(GdkEventAny * e)
262 if(e->type==GDK_DELETE)
264 designwinexists=false;
269 sigc::signal<void, std::string> NoteBookTab::signal_title_ch()
274 void NoteBookTab::setView(bool autoscale, bool zoomtrack, double width, double radius)
276 gd_canvas->setView(autoscale, zoomtrack, width, radius);
279 void NoteBookTab::getView(bool & autoscale, bool & zoomtrack, double& width, double& radius)
281 gd_canvas->getView(autoscale, zoomtrack, width, radius);
284 void NoteBookTab::reDesignGraph()
286 gd_canvas->reDesignGraph();
289 void NoteBookTab::attraction_ch(double v)
291 gd_canvas->set_attraction(v);
294 void NoteBookTab::propulsation_ch(double v)
296 gd_canvas->set_propulsation(v);
299 void NoteBookTab::iteration_ch(int v)
301 gd_canvas->set_iteration(v);
304 void NoteBookTab::active_maps_needed()
306 mapstorage.broadcastActiveMaps();