[Lemon-commits] ladanyi: r3253 - glemon/branches/akos
Lemon SVN
svn at lemon.cs.elte.hu
Fri Apr 13 14:13:16 CEST 2007
Author: ladanyi
Date: Fri Apr 13 14:13:14 2007
New Revision: 3253
Added:
glemon/branches/akos/file_import_dialog.cc
glemon/branches/akos/file_import_dialog.glade
glemon/branches/akos/file_import_dialog.h
glemon/branches/akos/io_helper.h
Modified:
glemon/branches/akos/Makefile.am
glemon/branches/akos/configure.ac
glemon/branches/akos/dijkstrabox.cc
glemon/branches/akos/graph_displayer_canvas-edge.cc
glemon/branches/akos/graph_displayer_canvas-node.cc
glemon/branches/akos/gui_writer.cc
glemon/branches/akos/main_win.cc
glemon/branches/akos/main_win.h
glemon/branches/akos/map_value.cc
glemon/branches/akos/map_value.h
glemon/branches/akos/mapstorage.cc
glemon/branches/akos/mapstorage.h
glemon/branches/akos/nbtab.cc
glemon/branches/akos/nbtab.h
glemon/branches/akos/new_map_win.cc
glemon/branches/akos/save_details_widget.cc
Log:
- Added dialog for setting map types and coordinate maps (FileImportDialog).
- MapStorage interface changes wrt multiple map type support.
- Extensions for XmlIo to read/write node and edgemaps (io_helper.h).
- Work in progress...
Modified: glemon/branches/akos/Makefile.am
==============================================================================
--- glemon/branches/akos/Makefile.am (original)
+++ glemon/branches/akos/Makefile.am Fri Apr 13 14:13:14 2007
@@ -49,8 +49,8 @@
dijkstrabox.cc \
file_chooser_extra_widget.h \
file_chooser_extra_widget.cc \
- file_import_window.h \
- file_import_window.cc \
+ file_import_dialog.h \
+ file_import_dialog.cc \
map_value.h \
map_value.cc \
save_details_widget.h \
Modified: glemon/branches/akos/configure.ac
==============================================================================
--- glemon/branches/akos/configure.ac (original)
+++ glemon/branches/akos/configure.ac Fri Apr 13 14:13:14 2007
@@ -14,7 +14,7 @@
AM_GNU_GETTEXT([external])
dnl Checks for libraries.
-PKG_CHECK_MODULES([GTK], [libgnomecanvasmm-2.6 >= 2.6.0 gtkmm-2.4 >= 2.6])
+PKG_CHECK_MODULES([GTK], [libgnomecanvasmm-2.6 >= 2.6.0 gtkmm-2.4 >= 2.6 libglademm-2.4 >= 2.4])
AC_ARG_WITH([lemon-prefix],
AS_HELP_STRING([--with-lemon-prefix@<:@=PREFIX@:>@], [search for LEMON under PREFIX]), [], [with_lemon_prefix=no])
Modified: glemon/branches/akos/dijkstrabox.cc
==============================================================================
--- glemon/branches/akos/dijkstrabox.cc (original)
+++ glemon/branches/akos/dijkstrabox.cc Fri Apr 13 14:13:14 2007
@@ -16,7 +16,11 @@
*
*/
+#include <mapstorage.h>
+#include <mapselector.h>
+#include <algobox.h>
#include <dijkstrabox.h>
+
#include <lemon/dijkstra.h>
#include <lemon/suurballe.h>
#include <lemon/path.h>
@@ -27,147 +31,149 @@
{
init(t);
}
-
+
SuurballeBox::SuurballeBox(std::vector<std::string> t):DijkstraBox(t)
{
Gtk::Adjustment * adjustment=new Gtk::Adjustment(2, 1, 20, 1, 5);
num_set = new Gtk::SpinButton(*adjustment, 5,0);
Gtk::Label * label=new Gtk::Label("No. of paths to find: ");
- // hbox.pack_start(*label);
- // hbox.pack_start(*num_set);
- // hbox.show_all_children();
+// hbox.pack_start(*label);
+// hbox.pack_start(*num_set);
+// hbox.show_all_children();
table.attach(*label, 0,1,2,3);
table.attach(*num_set, 1,2,2,3);
- // pack_start(hbox);
+// pack_start(hbox);
}
-
+
void DijkstraBox::run()
{
if(
- tabcbt.get_active_text()!="" &&
- (edgemapcbts[INPUT])->get_active_text()!="" &&
- (edgemapcbts[OUTPUT])->get_active_text()!="" &&
- source.get_active_text()!="" &&
- target.get_active_text()!=""
- )
- {
- const Graph &g=mapstorage->graph;
- Node from, to;
-
- get_from_to(from, to, (Graph&)g);
+ tabcbt.get_active_text()!="" &&
+ (edgemapcbts[INPUT])->get_active_text()!="" &&
+ (edgemapcbts[OUTPUT])->get_active_text()!="" &&
+ source.get_active_text()!="" &&
+ target.get_active_text()!=""
+ )
+ {
+ const Graph &g=mapstorage->graph;
+ Node from, to;
- std::ostringstream o;
+ get_from_to(from, to, (Graph&)g);
- if(!(from==to))
- {
- Graph::EdgeMap<double>& inputmap = mapstorage->getEdgeMap(edgemapcbts[INPUT]->get_active_text());
- Graph::EdgeMap<double>& outputmap = mapstorage->getEdgeMap(edgemapcbts[OUTPUT]->get_active_text());
+ std::ostringstream o;
- //zero out output map
- for (EdgeIt i(g); i!=INVALID; ++i)
- {
- outputmap[i]=0;
- }
-
- Dijkstra<Graph, Graph::EdgeMap<double> > dijkstra(g, inputmap);
- dijkstra.run(from, to);
-
- if(dijkstra.reached(to))
- {
- Node n=to;
- int length=0;
- while (n!=INVALID && n!=from)
- {
- Edge e=dijkstra.predEdge(n);
- outputmap[e]=1;
- n=dijkstra.predNode(n);
- length++;
- }
- o << "Result: " << length << " long path, with cost " << dijkstra.dist(to);
- }
- else
- {
- o << "Result: failed to find shortest path between ";
- o << source.get_active_text() << " and " << target.get_active_text();
- }
- resultlabel.set_text(o.str());
-
- mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
- // mapstorage->changeActiveMap(true, E_COLOR,
- // (edgemapcbts[OUTPUT])->get_active_text());
- // mapstorage->changeActiveMap(true, E_TEXT,
- // (edgemapcbts[INPUT])->get_active_text());
+ if(!(from==to))
+ {
+ Graph::EdgeMap<double> inputmap=
+ mapstorage->getEdgeMap(edgemapcbts[INPUT]->get_active_text());
+ Graph::EdgeMap<double> outputmap=
+ mapstorage->getEdgeMap(edgemapcbts[OUTPUT]->get_active_text());
+
+ //zero out output map
+ for (EdgeIt i(g); i!=INVALID; ++i)
+ {
+ outputmap[i]=0;
+ }
+
+ Dijkstra<Graph, Graph::EdgeMap<double> > dijkstra(g, inputmap);
+ dijkstra.run(from, to);
+
+ if(dijkstra.reached(to))
+ {
+ Node n=to;
+ int length=0;
+ while (n!=INVALID && n!=from)
+ {
+ Edge e=dijkstra.predEdge(n);
+ outputmap[e]=1;
+ n=dijkstra.predNode(n);
+ length++;
+ }
+ o << "Result: " << length << " long path, with cost " << dijkstra.dist(to);
+ }
+ else
+ {
+ o << "Result: failed to find shortest path between ";
+ o << source.get_active_text() << " and " << target.get_active_text();
+ }
+ resultlabel.set_text(o.str());
+
+ mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
+ // mapstorage->changeActiveMap(true, E_COLOR,
+ // (edgemapcbts[OUTPUT])->get_active_text());
+ // mapstorage->changeActiveMap(true, E_TEXT,
+ // (edgemapcbts[INPUT])->get_active_text());
+ }
}
- }
}
void SuurballeBox::run()
{
if(
- tabcbt.get_active_text()!="" &&
- (edgemapcbts[INPUT])->get_active_text()!="" &&
- (edgemapcbts[OUTPUT])->get_active_text()!="" &&
- source.get_active_text()!="" &&
- target.get_active_text()!=""
- )
- {
- const Graph &g=mapstorage->graph;
- Node from, to;
-
- get_from_to(from, to, (Graph&)g);
+ tabcbt.get_active_text()!="" &&
+ (edgemapcbts[INPUT])->get_active_text()!="" &&
+ (edgemapcbts[OUTPUT])->get_active_text()!="" &&
+ source.get_active_text()!="" &&
+ target.get_active_text()!=""
+ )
+ {
+ const Graph &g=mapstorage->graph;
+ Node from, to;
- std::ostringstream o;
+ get_from_to(from, to, (Graph&)g);
- if(!(from==to))
- {
- Graph::EdgeMap<double>& inputmap = mapstorage->getEdgeMap(edgemapcbts[INPUT]->get_active_text());
- Graph::EdgeMap<double>& outputmap = mapstorage->getEdgeMap(edgemapcbts[OUTPUT]->get_active_text());
+ std::ostringstream o;
- //zero out output map
- for (EdgeIt i(g); i!=INVALID; ++i)
- {
- outputmap[i]=0;
- }
-
- Suurballe<Graph, Graph::EdgeMap<double> > sb((Graph&)g, inputmap, from, to);
-
- int found=sb.run(num_set->get_value_as_int());
- if(found)
- {
- for(int j=0;j<found;j++)
- {
- Path<Graph> path(g);
- sb.getPath(path, j);
- for(int k=0;k<path.length();k++)
- {
- Path<Graph>::EdgeIt ei;
- ei=path.nthEdge(k);
- outputmap[ei]=j+1;
- }
- }
- o << "Result: found " << found << " paths between ";
- o << source.get_active_text() << " and " << target.get_active_text();
- }
- else
- {
- o << "Result: failed to find shortest path between ";
- o << source.get_active_text() << " and " << target.get_active_text();
- }
- resultlabel.set_text(o.str());
-
- mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
- // mapstorage->changeActiveMap(true, E_COLOR,
- // (edgemapcbts[OUTPUT])->get_active_text());
- // mapstorage->changeActiveMap(true, E_TEXT,
- // (edgemapcbts[INPUT])->get_active_text());
+ if(!(from==to))
+ {
+ Graph::EdgeMap<double> inputmap=
+ mapstorage->getEdgeMap(edgemapcbts[INPUT]->get_active_text());
+ Graph::EdgeMap<double> outputmap=
+ mapstorage->getEdgeMap(edgemapcbts[OUTPUT]->get_active_text());
+
+ //zero out output map
+ for (EdgeIt i(g); i!=INVALID; ++i)
+ {
+ outputmap[i]=0;
+ }
+
+ Suurballe<Graph, Graph::EdgeMap<double> > sb((Graph&)g, inputmap, from, to);
+
+ int found=sb.run(num_set->get_value_as_int());
+ if(found)
+ {
+ for(int j=0;j<found;j++)
+ {
+ Path<Graph> path;
+ path=sb.path(j);
+ for(int k=0;k<path.length();k++)
+ {
+ outputmap[path.nth(k)]=j+1;
+ }
+ }
+ o << "Result: found " << found << " paths between ";
+ o << source.get_active_text() << " and " << target.get_active_text();
+ }
+ else
+ {
+ o << "Result: failed to find shortest path between ";
+ o << source.get_active_text() << " and " << target.get_active_text();
+ }
+ resultlabel.set_text(o.str());
+
+ mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
+ // mapstorage->changeActiveMap(true, E_COLOR,
+ // (edgemapcbts[OUTPUT])->get_active_text());
+ // mapstorage->changeActiveMap(true, E_TEXT,
+ // (edgemapcbts[INPUT])->get_active_text());
+ }
}
- }
}
-
+
void DijkstraBox::build_box()
{
//if active tab is changed, labels of graph nodes had to be loaded into comboboxes
@@ -199,36 +205,36 @@
void DijkstraBox::maplists_updated()
{
if(tabcbt.get_active_text()!="")
- {
- source.clear();
- target.clear();
- const Graph &g=mapstorage->graph;
- for (NodeIt i(g); i!=INVALID; ++i)
{
- std::ostringstream text;
- text << mapstorage->getLabel(i);
- source.prepend_text(text.str());
- target.prepend_text(text.str());
+ source.clear();
+ target.clear();
+ const Graph &g=mapstorage->graph;
+ for (NodeIt i(g); i!=INVALID; ++i)
+ {
+ std::ostringstream text;
+ text << mapstorage->getLabel(i);
+ source.prepend_text(text.str());
+ target.prepend_text(text.str());
+ }
}
- }
}
void DijkstraBox::get_from_to(Node & from, Node & to, Graph & g)
{
int assigned=0;
for (NodeIt i(g); (i!=INVALID) && (assigned<2); ++i)
- {
- std::ostringstream text;
- text << mapstorage->getLabel(i);
- if(!(text.str().compare(source.get_active_text())))
{
- from=i;
- assigned++;
- }
- if(!(text.str().compare(target.get_active_text())))
- {
- to=i;
- assigned++;
+ std::ostringstream text;
+ text << mapstorage->getLabel(i);
+ if(!(text.str().compare(source.get_active_text())))
+ {
+ from=i;
+ assigned++;
+ }
+ if(!(text.str().compare(target.get_active_text())))
+ {
+ to=i;
+ assigned++;
+ }
}
- }
}
Added: glemon/branches/akos/file_import_dialog.cc
==============================================================================
--- (empty file)
+++ glemon/branches/akos/file_import_dialog.cc Fri Apr 13 14:13:14 2007
@@ -0,0 +1,15 @@
+#include "file_import_dialog.h"
+#include <gtkmm/dialog.h>
+#include <gtkmm/stock.h>
+
+FileImportDialog::FileImportDialog()
+{
+ m_refXml = Gnome::Glade::Xml::create("file_import_dialog.glade");
+ m_refXml->reparent_widget("notebook1", *get_vbox());
+ add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
+}
+
+FileImportDialog::~FileImportDialog()
+{
+}
Added: glemon/branches/akos/file_import_dialog.glade
==============================================================================
--- (empty file)
+++ glemon/branches/akos/file_import_dialog.glade Fri Apr 13 14:13:14 2007
@@ -0,0 +1,506 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.2.0 on Fri Apr 6 17:40:32 2007 by akos at ragnarok-->
+<glade-interface>
+ <widget class="GtkWindow" id="window1">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>Node Position</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"> </property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox4">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">5</property>
+ <child>
+ <widget class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkRadioButton" id="radiobutton1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">one map</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radiobutton2</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"> </property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox5">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label14">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">(X, Y)</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox5">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="items" translatable="yes"></property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkRadioButton" id="radiobutton2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">two maps</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"> </property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">X</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Y</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>Arrow Position</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"> </property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox7">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">5</property>
+ <child>
+ <widget class="GtkVBox" id="vbox8">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkRadioButton" id="radiobutton3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">one map</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radiobutton4</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox7">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label16">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"> </property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox8">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label17">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">(X, Y)</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox9">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkRadioButton" id="radiobutton4">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">two maps</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes"> </property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">X</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Y</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox4">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="tab_expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Special maps</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTreeView" id="treeview1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="headers_clickable">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Node maps</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="position">1</property>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTreeView" id="treeview2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="headers_clickable">True</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Edge maps</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ <property name="position">2</property>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Added: glemon/branches/akos/file_import_dialog.h
==============================================================================
--- (empty file)
+++ glemon/branches/akos/file_import_dialog.h Fri Apr 13 14:13:14 2007
@@ -0,0 +1,16 @@
+#ifndef FILE_IMPORT_DIALOG
+#define FILE_IMPORT_DIALOG
+
+#include <libglademm/xml.h>
+#include <gtkmm/dialog.h>
+
+class FileImportDialog : public Gtk::Dialog
+{
+ private:
+ Glib::RefPtr<Gnome::Glade::Xml> m_refXml;
+ public:
+ FileImportDialog();
+ ~FileImportDialog();
+};
+
+#endif
Modified: glemon/branches/akos/graph_displayer_canvas-edge.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-edge.cc (original)
+++ glemon/branches/akos/graph_displayer_canvas-edge.cc Fri Apr 13 14:13:14 2007
@@ -67,8 +67,17 @@
{
double min, max;
- min=(mytab.mapstorage).minOfEdgeMap(mapname);
- max=(mytab.mapstorage).maxOfEdgeMap(mapname);
+ {
+ EdgeIt e(mytab.mapstorage.graph);
+ min = max = mytab.mapstorage.get(mapname, e);
+ for (; e != INVALID; ++e)
+ {
+ if (mytab.mapstorage.get(mapname, e) > MapValue(max))
+ max = mytab.mapstorage.get(mapname, e);
+ if (mytab.mapstorage.get(mapname, e) < MapValue(min))
+ min = mytab.mapstorage.get(mapname, e);
+ }
+ }
if(edge==INVALID)
{
@@ -131,8 +140,17 @@
double max, min;
- max=(mytab.mapstorage).maxOfEdgeMap(mapname);
- min=(mytab.mapstorage).minOfEdgeMap(mapname);
+ {
+ EdgeIt e(mytab.mapstorage.graph);
+ min = max = mytab.mapstorage.get(mapname, e);
+ for (; e != INVALID; ++e)
+ {
+ if (mytab.mapstorage.get(mapname, e) > MapValue(max))
+ max = mytab.mapstorage.get(mapname, e);
+ if (mytab.mapstorage.get(mapname, e) < MapValue(min))
+ min = mytab.mapstorage.get(mapname, e);
+ }
+ }
if(edge==INVALID)
{
Modified: glemon/branches/akos/graph_displayer_canvas-node.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-node.cc (original)
+++ glemon/branches/akos/graph_displayer_canvas-node.cc Fri Apr 13 14:13:14 2007
@@ -24,8 +24,18 @@
int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
{
double min, max;
- min=(mytab.mapstorage).minOfNodeMap(mapname);
- max=(mytab.mapstorage).maxOfNodeMap(mapname);
+
+ {
+ NodeIt n(mytab.mapstorage.graph);
+ min = max = mytab.mapstorage.get(mapname, n);
+ for (; n != INVALID; ++n)
+ {
+ if (mytab.mapstorage.get(mapname, n) > MapValue(max))
+ max = mytab.mapstorage.get(mapname, n);
+ if (mytab.mapstorage.get(mapname, n) < MapValue(min))
+ min = mytab.mapstorage.get(mapname, n);
+ }
+ }
if(node==INVALID)
{
@@ -166,8 +176,17 @@
double max, min;
- max=(mytab.mapstorage).maxOfNodeMap(mapname);
- min=(mytab.mapstorage).minOfNodeMap(mapname);
+ {
+ NodeIt n(mytab.mapstorage.graph);
+ min = max = mytab.mapstorage.get(mapname, n);
+ for (; n != INVALID; ++n)
+ {
+ if (mytab.mapstorage.get(mapname, n) > MapValue(max))
+ max = mytab.mapstorage.get(mapname, n);
+ if (mytab.mapstorage.get(mapname, n) < MapValue(min))
+ min = mytab.mapstorage.get(mapname, n);
+ }
+ }
if(node==INVALID)
{
Modified: glemon/branches/akos/gui_writer.cc
==============================================================================
--- glemon/branches/akos/gui_writer.cc (original)
+++ glemon/branches/akos/gui_writer.cc Fri Apr 13 14:13:14 2007
@@ -17,7 +17,7 @@
*/
#include "gui_writer.h"
-#include "xml.h"
+#include "io_helper.h"
#include "mapstorage.h"
#include <lemon/dim2.h>
#include <vector>
@@ -29,28 +29,175 @@
void GuiWriter::write(std::ostream& os)
{
+ using std::vector;
+ using std::string;
+
XmlIo x(os);
- std::map<int, XY > m;
- for (EdgeIt e(mapstorage->graph); e != INVALID; ++e)
+
+
+ vector<string> all_node_map_names = mapstorage->getNodeMapList();
+ vector<string> node_map_names; // name of the maps need to be saved
+
+ // collect the maps that need to be saved
+ for (vector<string>::const_iterator it = all_node_map_names.begin();
+ it != all_node_map_names.end(); ++it)
+ {
+ if (mapstorage->getNodeMapSaveDest() != MapStorage::DONT_SAVE)
+ node_map_names.push_back(*it);
+ }
+
+ // write node map names
+ { x("node_map_names" node_map_names); }
+
+ vector<MapStorage::MapElementType> node_map_types;
+ for (vector<string>::const_iterator it = node_map_names.begin();
+ it != node_map_names.end(); ++it)
+ {
+ node_map_types.push_back(mapstorage->getNodeMapElementType(*it));
+ }
+
+ // write node map types
+ { x("node_map_types" node_map_types); }
+
+
+ vector<string> all_edge_map_names = mapstorage->getEdgeMapList();
+ vector<string> edge_map_names; // name of the maps need to be saved
+
+ // collect the maps that need to be saved
+ for (vector<string>::const_iterator it = all_edge_map_names.begin();
+ it != all_edge_map_names.end(); ++it)
+ {
+ if (mapstorage->getEdgeMapSaveDest() != MapStorage::DONT_SAVE)
+ edge_map_names.push_back(*it);
+ }
+
+ // write edge map names
+ { x("edge_map_names" edge_map_names); }
+
+ vector<MapStorage::MapElementType> edge_map_types;
+ for (vector<string>::const_iterator it = edge_map_names.begin();
+ it != edge_map_names.end(); ++it)
+ {
+ edge_map_types.push_back(mapstorage->getEdgeMapElementType(*it));
+ }
+
+ // write edge map types
+ { x("edge_map_types" edge_map_types); }
+
+
+ // collect the names of the node maps that are saved to the gui section
+ vector<string> gui_node_map_names;
+ for (vector<string>::const_iterator it = all_node_map_names.begin();
+ it != all_node_map_names.end(); ++it)
+ {
+ if (mapstorage->getNodeMapSaveDest() == MapStorage::GUI_SECT)
+ gui_node_map_names.push_back(*it);
+ }
+
+ // write the names
+ { x("gui_node_map_names" gui_node_map_names); }
+
+ // write the maps
+ for (vector<string>::const_iterator it = gui_node_map_names.begin();
+ it != gui_node_map_names.end(); ++it)
+ {
+ MapStorage::ElementType type = mapstorage->getNodeMapElementType();
+ switch (type)
+ {
+ case MapStorage::INTEGER:
+ {
+ NodeData<int> data(
+ mapstorage->graph,
+ mapstorage->getNodeLabel(),
+ mapstorage->getIntegerNodeMap(*it));
+ { x(*it, data); }
+ }
+ break;
+ case MapStorage::SCALAR:
+ {
+ NodeData<double> data(
+ mapstorage->graph,
+ mapstorage->getNodeLabel(),
+ mapstorage->getScalarNodeMap(*it));
+ { x(*it, data); }
+ }
+ break;
+ case MapStorage::STRING:
+ {
+ NodeData<string> data(
+ mapstorage->graph,
+ mapstorage->getNodeLabel(),
+ mapstorage->getStringNodeMap(*it));
+ { x(*it, data); }
+ }
+ break;
+ }
+ }
+
+
+ // collect the names of the edge maps that are saved to the gui section
+ vector<string> gui_edge_map_names;
+ for (vector<string>::const_iterator it = all_edge_map_names.begin();
+ it != all_edge_map_names.end(); ++it)
+ {
+ if (mapstorage->getEdgeMapSaveDest() == MapStorage::GUI_SECT)
+ gui_edge_map_names.push_back(*it);
+ }
+
+ // write the names
+ { x("gui_edge_map_names" gui_edge_map_names); }
+
+ // write the maps
+ for (vector<string>::const_iterator it = gui_edge_map_names.begin();
+ it != gui_edge_map_names.end(); ++it)
{
- int edgeid = (int) mapstorage->getLabel(e);
- m[edgeid] = mapstorage->getArrowCoords(e);
+ MapStorage::ElementType type = mapstorage->getEdgeMapElementType();
+ switch (type)
+ {
+ case MapStorage::INTEGER:
+ {
+ EdgeData<int> data(
+ mapstorage->graph,
+ mapstorage->getEdgeLabel(),
+ mapstorage->getIntegerEdgeMap(*it));
+ { x(*it, data); }
+ }
+ break;
+ case MapStorage::SCALAR:
+ {
+ EdgeData<double> data(
+ mapstorage->graph,
+ mapstorage->getEdgeLabel(),
+ mapstorage->getScalarEdgeMap(*it));
+ { x(*it, data); }
+ }
+ break;
+ case MapStorage::STRING:
+ {
+ EdgeData<string> data(
+ mapstorage->graph,
+ mapstorage->getEdgeLabel(),
+ mapstorage->getStringEdgeMap(*it));
+ { x(*it, data); }
+ }
+ break;
+ }
}
- x("arrow_pos", m);
+
std::map<int, std::string> nm;
for(int i=0;i<NODE_PROPERTY_NUM;i++)
{
nm[i]=mapstorage->active_nodemaps[i];
}
- x("active_nodemaps", nm);
+ { x("active_nodemaps", nm); }
std::map<int, std::string> em;
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
{
em[i]=mapstorage->active_edgemaps[i];
}
- x("active_edgemaps", em);
+ { x("active_edgemaps", em); }
double attraction;
double propulsation;
@@ -58,9 +205,9 @@
mapstorage->get_design_data(attraction, propulsation, iteration);
- x("redesign-attraction", attraction);
- x("redesign-propulsation", propulsation);
- x("redesign-iteration", iteration);
+ { x("redesign-attraction", attraction); }
+ { x("redesign-propulsation", propulsation); }
+ { x("redesign-iteration", iteration); }
}
GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms)
Added: glemon/branches/akos/io_helper.h
==============================================================================
--- (empty file)
+++ glemon/branches/akos/io_helper.h Fri Apr 13 14:13:14 2007
@@ -0,0 +1,58 @@
+#ifndef IO_HELPER
+#define IO_HELPER
+
+#include "all_include.h"
+#include "xml.h"
+
+template<class T>
+struct NodeData
+{
+ const Graph& graph;
+ const Graph::NodeMap<std::string>& label;
+ const Graph::NodeMap<T>& map;
+ NodeData(const Graph& _graph, const Graph::NodeMap<std::int>& _label,
+ const Graph::NodeMap<T>& _map) :
+ graph(_graph),
+ label(_label),
+ map(_map)
+ {}
+};
+
+template<class T>
+struct EdgeData
+{
+ const Graph& graph;
+ const Graph::NodeMap<std::int>& label;
+ const Graph::EdgeMap<T>& map;
+ EdgeData(const Graph& _graph, const Graph::EdgeMap<std::int>& _label,
+ const Graph::EdgeMap<T>& _map) :
+ graph(_graph),
+ label(_label),
+ map(_map)
+ {}
+};
+
+namespace lemon {
+ template<class T>
+ void xml(XmlIo &x, NodeData<T> &v)
+ {
+ for (NodeIt n(v.graph); n != INVALID; ++n)
+ {
+ { XmlIo::LineTag t(x,"label"); x(v.label[n]); }
+ { XmlIo::ContTag t(x,"value"); x(v.map[n]); }
+ }
+ }
+
+ template<class T>
+ void xml(XmlIo &x, EdgeData<T> &v)
+ {
+ for (EdgeIt e(v.graph); e != INVALID; ++e)
+ {
+ { XmlIo::LineTag t(x,"from"); x(v.label[v.graph.source(e)]); }
+ { XmlIo::ContTag t(x,"to"); x(v.label[v.graph.target(e)]); }
+ { XmlIo::ContTag t(x,"value"); x(v.map[e]); }
+ }
+ }
+};
+
+#endif
Modified: glemon/branches/akos/main_win.cc
==============================================================================
--- glemon/branches/akos/main_win.cc (original)
+++ glemon/branches/akos/main_win.cc Fri Apr 13 14:13:14 2007
@@ -122,8 +122,6 @@
sigc::mem_fun(*this, &MainWin::createMapWin));
ag->add( Gtk::Action::create("ShowDesign", _("_Design")),
sigc::mem_fun(*this, &MainWin::createDesignWin));
- ag->add( Gtk::Action::create("ShowMapList", _("Map _List")),
- sigc::mem_fun(*this, &MainWin::createMapListWin));
ag->add( Gtk::Action::create("AlgoMenu", _("_Algorithms")) );
ag->add( Gtk::Action::create("AlgoGeneral", _("_General")),
@@ -183,7 +181,6 @@
" <menu action='ShowMenu'>"
" <menuitem action='ShowMaps'/>"
" <menuitem action='ShowDesign'/>"
- " <menuitem action='ShowMapList'/>"
" </menu>"
" <menu action='AlgoMenu'>"
" <menuitem action='AlgoGeneral'/>"
@@ -478,14 +475,6 @@
}
}
-void MainWin::createMapListWin()
-{
- if(active_tab!=-1)
- {
- tabs[active_tab]->createMapListWin(tabnames[active_tab]);
- }
-}
-
void MainWin::createMapWin()
{
if(active_tab!=-1)
Modified: glemon/branches/akos/main_win.h
==============================================================================
--- glemon/branches/akos/main_win.h (original)
+++ glemon/branches/akos/main_win.h Fri Apr 13 14:13:14 2007
@@ -155,8 +155,6 @@
///\ref GraphDisplayerCanvas
virtual void zoom100();
- virtual void createMapListWin();
-
///Callback for Show Maps menupoint.
///It calls the appropriate function in
Modified: glemon/branches/akos/map_value.cc
==============================================================================
--- glemon/branches/akos/map_value.cc (original)
+++ glemon/branches/akos/map_value.cc Fri Apr 13 14:13:14 2007
@@ -3,46 +3,36 @@
MapValue::MapValue(int i)
{
- value = i;
+ p_value = new int(i);
type = INTEGER;
}
MapValue::MapValue(double d)
{
- value = d;
+ p_value = new double(d);
type = SCALAR;
}
MapValue::MapValue(std::string str)
{
- value = str;
+ p_value = new std::string(str);
type = STRING;
}
MapValue::operator int()
{
- switch (type)
- {
- case INTEGER:
- return boost::any_cast<int>(value);
- case SCALAR:
- return (int) boost::any_cast<double>(value);
- case STRING:
- throw BadMapValueCast();
- }
+ if (type == INTEGER)
+ return *(static_cast<int*>(p_value));
+ else
+ throw IllegalOperation();
}
MapValue::operator double()
{
- switch (type)
- {
- case INTEGER:
- return (double) boost::any_cast<int>(value);
- case SCALAR:
- return boost::any_cast<double>(value);
- case STRING:
- throw BadMapValueCast();
- }
+ if (type == SCALAR)
+ return *(static_cast<double*>(p_value));
+ else
+ throw IllegalOperation();
}
MapValue::operator std::string()
@@ -52,7 +42,7 @@
{
case INTEGER:
{
- int i = boost::any_cast<int>(value);
+ int i = *(static_cast<int*>(p_value));
std::ostringstream ostr;
ostr << i;
ret = ostr.str();
@@ -60,15 +50,103 @@
break;
case SCALAR:
{
- double d = boost::any_cast<double>(value);
+ double d = *(static_cast<double*>(p_value));
std::ostringstream ostr;
ostr << d;
ret = ostr.str();
}
break;
case STRING:
- ret = boost::any_cast<std::string>(value);
+ ret = *(static_cast<std::string*>(p_value));
break;
}
return ret;
}
+
+MapValue::MapValue(const MapValue& v)
+{
+ type = v.type;
+ switch (v.type)
+ {
+ case INTEGER:
+ p_value = new int(static_cast<int>(v));
+ break;
+ case SCALAR:
+ p_value = new double(static_cast<double>(v));
+ break;
+ case STRING:
+ p_value = new std::string(static_cast<std::string>(v));
+ break;
+ }
+}
+
+MapValue& MapValue::operator=(const MapValue& v)
+{
+ if (&v != this)
+ {
+ switch (type)
+ {
+ case INTEGER:
+ delete static_cast<int*>(p_value);
+ break;
+ case SCALAR:
+ delete static_cast<double*>(p_value);
+ break;
+ case STRING:
+ delete static_cast<std::string*>(p_value);
+ break;
+ }
+ type = v.type;
+ switch (v.type)
+ {
+ case INTEGER:
+ p_value = new int(static_cast<int>(v));
+ break;
+ case SCALAR:
+ p_value = new double(static_cast<double>(v));
+ break;
+ case STRING:
+ p_value = new std::string(static_cast<std::string>(v));
+ break;
+ }
+ }
+ return *this;
+}
+
+MapValue::~MapValue()
+{
+ switch (type)
+ {
+ case INTEGER:
+ delete static_cast<int*>(p_value);
+ break;
+ case SCALAR:
+ delete static_cast<double*>(p_value);
+ break;
+ case STRING:
+ delete static_cast<std::string*>(p_value);
+ break;
+ }
+}
+
+bool MapValue::operator<(const MapValue& v)
+{
+ if (type == STRING || v.type == STRING)
+ throw IllegalOperation();
+
+ double lhs = static_cast<double>(*this);
+ double rhs = static_cast<double>(v);
+
+ return lhs < rhs;
+}
+
+bool MapValue::operator>(const MapValue& v)
+{
+ if (type == STRING || v.type == STRING)
+ throw IllegalOperation();
+
+ double lhs = static_cast<double>(*this);
+ double rhs = static_cast<double>(v);
+
+ return lhs > rhs;
+}
Modified: glemon/branches/akos/map_value.h
==============================================================================
--- glemon/branches/akos/map_value.h (original)
+++ glemon/branches/akos/map_value.h Fri Apr 13 14:13:14 2007
@@ -1,19 +1,18 @@
-#include <boost/any.hpp>
#include <exception>
class MapValue
{
public:
- class BadMapValueCast : public std::exception
+ class IllegalOperation : public std::exception
{
virtual const char* what() const throw()
{
- return "Bad MapValue cast.";
+ return "Illegal operation.";
}
};
typedef enum { INTEGER, SCALAR, STRING } Type;
private:
- boost::any value;
+ void* p_value;
MapValue::Type type;
public:
MapValue(int);
@@ -22,4 +21,6 @@
operator std::string();
operator int();
operator double();
+ bool operator<(const MapValue& v);
+ bool operator>(const MapValue& v);
};
Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc (original)
+++ glemon/branches/akos/mapstorage.cc Fri Apr 13 14:13:14 2007
@@ -7,7 +7,7 @@
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
- * provided that this copyright notice appears in all copies. For
+ * provided that this copyright notice appears in all cop ies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
@@ -27,12 +27,18 @@
#include <string>
#include <gtkmm.h>
#include <lemon/time_measure.h>
+#include "file_import_dialog.h"
const int i_d=20;
const double a_d=0.05;
const double p_d=40000;
-MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false), iterations(i_d), attraction(a_d), propulsation(p_d),
+MapStorage::MapStorage() :
+ modified(false),
+ file_name(""),
+ iterations(i_d),
+ attraction(a_d),
+ propulsation(p_d),
node_x_coord(graph),
node_y_coord(graph),
arrow_x_coord(graph),
@@ -40,30 +46,12 @@
node_label(graph),
edge_label(graph)
{
- //nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph);
- //coords.setXMap(*nodemap_storage["coordinates_x"]);
- //nodemap_storage["coordinates_y"] = new Graph::NodeMap<double>(graph);
- //coords.setYMap(*nodemap_storage["coordinates_y"]);
-
- //edgemap_storage["arrow_pos_x"] = new Graph::EdgeMap<double>(graph);
- //arrow_pos.setXMap(*edgemap_storage["arrow_pos_x"]);
- //edgemap_storage["arrow_pos_y"] = new Graph::EdgeMap<double>(graph);
- //arrow_pos.setYMap(*edgemap_storage["arrow_pos_y"]);
-
node_coords.setXMap(node_x_coord);
node_coords.setYMap(node_y_coord);
arrow_coords.setXMap(arrow_x_coord);
arrow_coords.setYMap(arrow_y_coord);
- /*
- nodemap_storage["label"] = new Graph::NodeMap<double>(graph);
- edgemap_storage["label"] = new Graph::EdgeMap<double>(graph);
-
- nodemap_default["label"] = 1.0;
- edgemap_default["label"] = 1.0;
- */
-
active_nodemaps.resize(NODE_PROPERTY_NUM);
for(int i=0;i<NODE_PROPERTY_NUM;i++)
{
@@ -91,19 +79,58 @@
}
}
-int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value)
+void MapStorage::createNodeMap(const std::string& name, MapValue::Type type,
+ MapValue def_val)
{
- if( nodemap_storage.find(name) == nodemap_storage.end() )
- {
- nodemap_storage[name]=nodemap;
- // set the maps default value
- nodemap_default[name] = default_value;
+ NodeMapStore::const_iterator it = nodemaps.find(name);
+ if (it != edgemaps.end())
+ throw MapAlreadyExists();
- //announce changement in maps
- signal_node_map.emit(name);
- return 0;
- }
- return 1;
+ switch (type)
+ {
+ case INTEGER:
+ nodemaps[name] = new IntegerNodeMapData(graph, def_val);
+ break;
+ case SCALAR:
+ nodemaps[name] = new ScalarNodeMapData(graph, def_val);
+ break;
+ case STRING:
+ nodemaps[name] = new StringNodeMapData(graph, def_val);
+ break;
+ }
+
+ nodemaps[name]->default_value = def_val;
+ nodemaps[name]->writeable = true;
+ nodemaps[name]->save_dest = GUI_SECT;
+
+ signal_node_map.emit(name);
+}
+
+void MapStorage::createEdgeMap(const std::string& name, MapValue::Type type,
+ MapValue def_val)
+{
+ EdgeMapStore::const_iterator it = edgemaps.find(name);
+ if (it != edgemaps.end())
+ throw MapAlreadyExists();
+
+ switch (type)
+ {
+ case INTEGER:
+ edgemaps[name] = new IntegerEdgeMapData(graph, def_val);
+ break;
+ case SCALAR:
+ edgemaps[name] = new ScalarEdgeMapData(graph, def_val);
+ break;
+ case STRING:
+ edgemaps[name] = new StringEdgeMapData(graph, def_val);
+ break;
+ }
+
+ edgemaps[name]->default_value = def_val;
+ edgemaps[name]->writeable = true;
+ edgemaps[name]->save_dest = GUI_SECT;
+
+ signal_edge_map.emit(name);
}
void MapStorage::changeActiveMap(bool itisedge, int prop, std::string mapname)
@@ -144,124 +171,35 @@
std::vector<std::string> MapStorage::getEdgeMapList()
{
- std::vector<std::string> eml;
- eml.resize(edgemap_storage.size());
- int i=0;
- std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=beginOfEdgeMaps();
- for(;emsi!=endOfEdgeMaps();emsi++)
- {
- eml[i]=(emsi->first);
- i++;
- }
- return eml;
-}
-
-std::vector<std::string> MapStorage::getNodeMapList()
-{
- std::vector<std::string> nml;
- nml.resize(nodemap_storage.size());
- int i=0;
- std::map< std::string,Graph::NodeMap<double> * >::iterator nmsi=beginOfNodeMaps();
- for(;nmsi!=endOfNodeMaps();nmsi++)
- {
- nml[i]=(nmsi->first);
- i++;
- }
- return nml;
-}
-
-sigc::signal<void, bool, int> MapStorage::signal_prop_ch()
-{
- return signal_prop;
-}
-
-int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value)
-{
- if( edgemap_storage.find(name) == edgemap_storage.end() )
- {
- edgemap_storage[name]=edgemap;
- // set the maps default value
- edgemap_default[name] = default_value;
-
- //announce changement in maps
- signal_edge_map.emit(name);
- return 0;
- }
- return 1;
-}
-
-double MapStorage::maxOfNodeMap(const std::string & name)
-{
- double max=0;
- for (NodeIt j(graph); j!=INVALID; ++j)
- {
- if( (*nodemap_storage[name])[j]>max )
- {
- max=(*nodemap_storage[name])[j];
- }
- }
- return max;
-}
-
-double MapStorage::maxOfEdgeMap(const std::string & name)
-{
- double max=0;
- for (EdgeIt j(graph); j!=INVALID; ++j)
+ std::vector<std::string> ret(edgemaps.size());
+ for (EdgeMapStore::const_iterator it = edgemaps.begin();
+ it != edgemaps.end(); ++it)
{
- if( (*edgemap_storage[name])[j]>max )
- {
- max=(*edgemap_storage[name])[j];
- }
+ ret.push_back(it->first);
}
- return max;
+ return ret;
}
-double MapStorage::minOfNodeMap(const std::string & name)
+std::vector<std::string> MapStorage::getNodeMapList()
{
- NodeIt j(graph);
- double min;
- if(j!=INVALID)
- {
- min=(*nodemap_storage[name])[j];
- }
- else
- {
- min=0;
- }
- for (; j!=INVALID; ++j)
+ std::vector<std::string> ret(nodemaps.size());
+ for (NodeMapStore::const_iterator it = nodemaps.begin();
+ it != nodemaps.end(); ++it)
{
- if( (*nodemap_storage[name])[j]<min )
- {
- min=(*nodemap_storage[name])[j];
- }
+ ret.push_back(it->first);
}
- return min;
+ return ret;
}
-double MapStorage::minOfEdgeMap(const std::string & name)
+sigc::signal<void, bool, int> MapStorage::signal_prop_ch()
{
- EdgeIt j(graph);
- double min;
- if(j!=INVALID)
- {
- min=(*edgemap_storage[name])[j];
- }
- else
- {
- min=0;
- }
- for (EdgeIt j(graph); j!=INVALID; ++j)
- {
- if( (*edgemap_storage[name])[j]<min )
- {
- min=(*edgemap_storage[name])[j];
- }
- }
- return min;
+ return signal_prop;
}
+//TODO
int MapStorage::readFromFile(const std::string &filename)
{
+ /*
std::cout << "MapStorage::readFromFile()" << std::endl;
lemon::Timer timer;
@@ -330,6 +268,15 @@
else
std::cout << "prefer gui section: no" << std::endl;
+ {
+ FileImportDialog fidialog;
+ fidialog.run();
+ }
+
+
+
+
+
bool read_x = false;
bool read_y = false;
bool read_edge_id = false;
@@ -438,7 +385,7 @@
else
{
EdgeIt e(graph);
- double max_edge_label = edge_label[e];
+ int max_edge_label = edge_label[e];
for (++e; e != INVALID; ++e)
{
if (edge_label[e] > max_edge_label)
@@ -450,7 +397,7 @@
{
NodeIt n(graph);
- double max_node_label = node_label[n];
+ int max_node_label = node_label[n];
for (++n; n != INVALID; ++n)
{
if (node_label[n] > max_node_label)
@@ -542,11 +489,14 @@
std::cout << "Reading finished" << std::endl;
std::cout << "Time elapsed: " << timer << std::endl;
+ */
return 0;
}
+//TODO
void MapStorage::writeToFile(const std::string &filename)
{
+ /*
GraphWriter<Graph> gwriter(filename, graph);
for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
@@ -567,10 +517,13 @@
GuiWriter gui_writer(gwriter, this);
gwriter.run();
+ */
}
+//TODO
void MapStorage::clear()
{
+ /*
for (std::map<std::string, Graph::NodeMap<double>*>::iterator it =
nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
{
@@ -628,11 +581,7 @@
iterations=i_d;
signal_design_win.emit(attraction, propulsation, iterations);
-}
-
-void MapStorage::ArrowPosReadOK()
-{
- arrow_pos_read_ok = true;
+ */
}
void MapStorage::mapChanged(bool itisedge, std::string mapname)
@@ -706,24 +655,28 @@
arrow_coords.set(e, c);
}
-double MapStorage::get(const std::string& map, Node n) const
+MapValue MapStorage::get(const std::string& name, Node node) const
{
- return nodemap_storage.find(map)->second->operator[](n);
+ NodeMapData* data = getNodeMapData(name);
+ return data->get(node);
}
-void MapStorage::set(const std::string& map, Node n, double val)
+void MapStorage::set(const std::string& name, Node node, MapValue val)
{
- nodemap_storage[map]->set(n, val);
+ NodeMapData* data = getNodeMapData(name);
+ data->set(node, val);
}
-double MapStorage::get(const std::string& map, Edge e) const
+MapValue MapStorage::get(const std::string& name, Edge edge) const
{
- return edgemap_storage.find(map)->second->operator[](e);
+ EdgeMapData* data = getEdgeMapData(name);
+ return data->get(edge);
}
-void MapStorage::set(const std::string& map, Edge e, double val)
+void MapStorage::set(const std::string& name, Edge edge, MapValue val)
{
- edgemap_storage[map]->set(e, val);
+ EdgeMapData* data = getEdgeMapData(name);
+ data->set(edge, val);
}
const std::string& MapStorage::getFileName() const
@@ -760,7 +713,8 @@
for (std::vector<std::string>::const_iterator it = node_maps.begin();
it != node_maps.end(); ++it)
{
- set(*it, node, nodemap_default[*it]);
+ NodeMapData* data = getNodeMapData(*it);
+ set(*it, node, data->default_value);
}
return node;
@@ -787,27 +741,144 @@
for (std::vector<std::string>::const_iterator it = edge_maps.begin();
it != edge_maps.end(); ++it)
{
- set(*it, edge, edgemap_default[*it]);
+ EdgeMapData* data = getEdgeMapData(*it);
+ set(*it, edge, data->default_value);
}
return edge;
}
-Graph::NodeMap<double>& MapStorage::getNodeMap(const std::string& name)
+IntegerNodeMap& MapStorage::getIntegerNodeMap(const std::string& name)
+{
+ NodeMapData* data = getNodeMapData(name);
+ if (data->type() != MapStorage::INTEGER) throw NonexistentMap();
+ return static_cast<IntegerNodeMapData*>(data)->map;
+}
+
+ScalarNodeMap& MapStorage::getScalarNodeMap(const std::string& name)
{
- return *nodemap_storage[name];
+ NodeMapData* data = getNodeMapData(name);
+ if (data->type() != MapStorage::SCALAR) throw NonexistentMap();
+ return static_cast<ScalarNodeMapData*>(data)->map;
}
-Graph::EdgeMap<double>& MapStorage::getEdgeMap(const std::string& name)
+StringNodeMap& MapStorage::getStringNodeMap(const std::string& name)
+{
+ NodeMapData* data = getNodeMapData(name);
+ if (data->type() != MapStorage::STRING) throw NonexistentMap();
+ return static_cast<StringNodeMapData*>(data)->map;
+}
+
+IntegerEdgeMap& MapStorage::getIntegerEdgeMap(const std::string& name)
+{
+ EdgeMapData* data = getEdgeMapData(name);
+ if (data->type() != MapStorage::INTEGER) throw NonexistentMap();
+ return static_cast<IntegerEdgeMapData*>(data)->map;
+}
+
+ScalarEdgeMap& MapStorage::getScalarEdgeMap(const std::string& name)
+{
+ EdgeMapData* data = getEdgeMapData(name);
+ if (data->type() != MapStorage::SCALAR) throw NonexistentMap();
+ return static_cast<ScalarEdgeMapData*>(data)->map;
+}
+
+StringEdgeMap& MapStorage::getStringEdgeMap(const std::string& name)
+{
+ EdgeMapData* data = getEdgeMapData(name);
+ if (data->type() != MapStorage::STRING) throw NonexistentMap();
+ return static_cast<StringEdgeMapData*>(data)->map;
+}
+
+const Graph::EdgeMap<double>& MapStorage::getEdgeMap(const std::string& name)
{
return *edgemap_storage[name];
}
-double MapStorage::getLabel(Node n) const
+int MapStorage::getLabel(Node n) const
{
return node_label[n];
}
-double MapStorage::getLabel(Edge e) const
+int MapStorage::getLabel(Edge e) const
{
return edge_label[e];
}
+
+MapStorage::GuiSectSaveDestination MapStorage::getGUIDataSaveLocation()
+{
+ return gui_sect_save_dest;
+}
+
+void MapStorage::setGUIDataSaveLocation(MapStorage::GuiSectSaveDestination dest)
+{
+ gui_sect_save_dest = dest;
+}
+
+MapStorage::MapSaveDestination MapStorage::getNodeMapSaveDest(std::string name) const
+{
+ NodeMapData *data = getNodeMapData(name);
+ return data->save_dest;
+}
+
+MapStorage::MapSaveDestination MapStorage::getEdgeMapSaveDest(std::string name) const
+{
+ EdgeMapData *data = getEdgeMapData(name);
+ return data->save_dest;
+}
+
+void MapStorage::setNodeMapSaveDest(std::string name, MapStorage::MapSaveDestination dest)
+{
+ NodeMapData *data = getNodeMapData(name);
+ data->save_dest = dest;
+}
+
+void MapStorage::setEdgeMapSaveDest(std::string name, MapStorage::MapSaveDestination dest)
+{
+ EdgeMapData *data = getEdgeMapData(name);
+ data->save_dest = dest;
+}
+
+MapStorage::EdgeMapData* MapStorage::getEdgeMapData(std::string name) const
+{
+ EdgeMapStore::const_iterator it = edgemaps.find(name);
+ if (it != edgemaps.end())
+ return it->second;
+ else
+ throw NonexistentMap();
+}
+
+MapStorage::NodeMapData* MapStorage::getNodeMapData(std::string name) const
+{
+ NodeMapStore::const_iterator it = nodemaps.find(name);
+ if (it != nodemaps.end())
+ return it->second;
+ else
+ throw NonexistentMap();
+}
+
+MapValue::Type MapStorage::getNodeMapElementType(std::string name) const
+{
+ NodeMapData *data = getNodeMapData(name);
+ return data->type();
+}
+
+MapValue::Type MapStorage::getEdgeMapElementType(std::string name) const
+{
+ EdgeMapData *data = getEdgeMapData(name);
+ return data->type();
+}
+
+const NodeLabelMap& MapStorage::getNodeLabelMap()
+{
+ return node_label;
+}
+
+const EdgeLabelMap& MapStorage::getEdgeLabelMap()
+{
+ return edge_label;
+}
+
+const Graph& MapStorage::getGraph()
+{
+ return graph;
+}
Modified: glemon/branches/akos/mapstorage.h
==============================================================================
--- glemon/branches/akos/mapstorage.h (original)
+++ glemon/branches/akos/mapstorage.h Fri Apr 13 14:13:14 2007
@@ -24,6 +24,7 @@
#include "all_include.h"
#include "xymap.h"
#include <libgnomecanvasmm.h>
+#include "map_value.h"
///class MapStorage handles NodeMaps and EdgeMaps.
@@ -38,45 +39,152 @@
///\todo too many things are public!!
class MapStorage
{
- /*
public:
- template <typename M>
- struct MapData
+ class NonexistentMap : public std::exception
{
- /// element type (INTEGER, SCALAR, STRING)
- /// the default value of the map
- typename M::Value default_value;
- /// save the map to the nodeset or edgeset section
- bool save_to_gui_sect;
- /// save the map to the nodeset or edgeset section
- bool save_to_main_part;
+ virtual const char* what() const throw()
+ {
+ return "Map does not exist.";
+ }
+ };
+
+ class MapAlreadyExists : public std::exception
+ {
+ virtual const char* what() const throw()
+ {
+ return "This map already exists.";
+ }
+ };
+
+ enum MapSaveDestination { GUI_SECT, NESET_SECT, DONT_SAVE };
+ typedef Graph::NodeMap<int> IntegerNodeMap;
+ typedef Graph::NodeMap<double> ScalarNodeMap;
+ typedef Graph::NodeMap<std::string> StringNodeMap;
+ typedef Graph::EdgeMap<int> IntegerEdgeMap;
+ typedef Graph::EdgeMap<double> ScalarEdgeMap;
+ typedef Graph::EdgeMap<std::string> StringEdgeMap;
+ struct EdgeMapData
+ {
+ /// where to save the map
+ MapSaveDestination save_dest;
+ /// read-only or read-write
+ bool writeable;
+ /// default value
+ MapValue default_value;
+ virtual MapValue::Type type() = 0;
+ virtual MapValue get(Edge e) = 0;
+ virtual void set(Edge e, MapValue v) = 0;
+ EdgeMapData(MapValue def_val) :
+ default_value(def_val)
+ {}
+ };
+ struct IntegerEdgeMapData : public EdgeMapData
+ {
+ IntegerEdgeMap map;
+ MapValue::Type type() { return MapValue::INTEGER; }
+ MapValue get(Edge e) { return MapValue(map[e]); }
+ void set(Edge e, MapValue v) { map.set(e, v); }
+ IntegerEdgeMapData(Graph& g, int def_val) :
+ EdgeMapData(MapValue(def_val)),
+ map(g)
+ {}
+ };
+ struct ScalarEdgeMapData : public EdgeMapData
+ {
+ ScalarEdgeMap map;
+ MapValue::Type type() { return MapValue::SCALAR; }
+ MapValue get(Edge e) { return MapValue(map[e]); }
+ void set(Edge e, MapValue v) { map.set(e, v); }
+ ScalarEdgeMapData(Graph& g, double def_val) :
+ EdgeMapData(MapValue(def_val)),
+ map(g)
+ {}
+ };
+ struct StringEdgeMapData : public EdgeMapData
+ {
+ StringEdgeMap map;
+ MapValue::Type type() { return MapValue::STRING; }
+ MapValue get(Edge e) { return MapValue(map[e]); }
+ void set(Edge e, MapValue v) { map.set(e, v); }
+ StringEdgeMapData(Graph& g, std::string def_val) :
+ EdgeMapData(MapValue(def_val)),
+ map(g)
+ {}
+ };
+ struct NodeMapData
+ {
+ /// where to save the map
+ MapSaveDestination save_dest;
/// read-only or read-write
bool writeable;
- /// the map
- M map;
- MapBase(Graph &g) :
- map(g) {}
+ /// default value
+ MapValue default_value;
+ virtual MapValue::Type type() = 0;
+ virtual MapValue get(Node e) = 0;
+ virtual void set(Node e, MapValue v) = 0;
+ NodeMapData(MapValue def_val) :
+ default_value(def_val)
+ {}
+ };
+ struct IntegerNodeMapData : public NodeMapData
+ {
+ IntegerNodeMap map;
+ MapValue::Type type() { return MapValue::INTEGER; }
+ MapValue get(Node e) { return MapValue(map[e]); }
+ void set(Node e, MapValue v) { map.set(e, v); }
+ IntegerNodeMapData(Graph& g, int def_val) :
+ NodeMapData(MapValue(def_val)),
+ map(g)
+ {}
};
- struct DoubleEdgeMapData : public MapBase<Graph::EdgeMap<double> >
+ struct ScalarNodeMapData : public NodeMapData
{
- DoubleEdgeMap(Graph& g) :
- MapData<Graph::EdgeMap<double> >(g)
+ ScalarNodeMap map;
+ MapValue::Type type() { return MapValue::SCALAR; }
+ MapValue get(Node e) { return MapValue(map[e]); }
+ void set(Node e, MapValue v) { map.set(e, v); }
+ ScalarNodeMapData(Graph& g, double def_val) :
+ NodeMapData(MapValue(def_val)),
+ map(g)
+ {}
};
- */
+ struct StringNodeMapData : public NodeMapData
+ {
+ StringNodeMap map;
+ MapValue::Type type() { return MapValue::STRING; }
+ MapValue get(Node e) { return MapValue(map[e]); }
+ void set(Node e, MapValue v) { map.set(e, v); }
+ StringNodeMapData(Graph& g, std::string def_val) :
+ NodeMapData(MapValue(def_val)),
+ map(g)
+ {}
+ };
+ enum GuiSectSaveDestination { LGF_FILE, CONF_FILE };
+
public:
///The graph for which the datas are stored.
Graph graph;
private:
+ const Graph& getGraph();
+
+ GuiSectSaveDestination gui_sect_save_dest;
+
+ typedef std::map<std::string, NodeMapData*> NodeMapStore;
+ NodeMapStore nodemaps;
+ typedef std::map<std::string, EdgeMapData*> EdgeMapStore;
+ EdgeMapStore edgemaps;
+
Graph::NodeMap<double> node_x_coord;
Graph::NodeMap<double> node_y_coord;
Graph::EdgeMap<double> arrow_x_coord;
Graph::EdgeMap<double> arrow_y_coord;
- Graph::NodeMap<double> node_label;
-
- Graph::EdgeMap<double> edge_label;
+ typedef Graph::NodeMap<int> NodeLabelMap;
+ NodeLabelMap node_label;
+ typedef Graph::EdgeMap<int> EdgeLabelMap;
+ EdgeLabelMap edge_label;
/// the coordinates of the nodes
XYMap<Graph::NodeMap<double> > node_coords;
@@ -84,12 +192,6 @@
/// the coordinates of the arrows on the edges
XYMap<Graph::EdgeMap<double> > arrow_coords;
- ///Stores double type EdgeMaps
- std::map< std::string,Graph::EdgeMap<double> * > edgemap_storage;
-
- ///Stores double type NodeMaps
- std::map< std::string,Graph::NodeMap<double> * > nodemap_storage;
-
///The content of the object has changed, update is needed.
bool modified;
@@ -97,10 +199,11 @@
std::string file_name;
// the largest node label
- double max_node_label;
+ int max_node_label;
// the largest edge label
- double max_edge_label;
+ int max_edge_label;
+
public:
///Stores the default values for the different visualization node attributes
std::vector<Graph::NodeMap<double> > default_nodemaps;
@@ -114,14 +217,6 @@
/// Stores the active maps for the different visualization edge attributes
std::vector< std::string > active_edgemaps;
- /// Default values for the maps
- std::map< std::string, double > nodemap_default;
-
- /// Default values for the maps
- std::map< std::string, double > edgemap_default;
-
- bool arrow_pos_read_ok;
-
protected:
/// Signal emitted on any change made on map values
@@ -218,82 +313,10 @@
///returns \ref signal_design_win to be able to connect functions to it
sigc::signal<void, double, double, int> signal_design_win_ch(){return signal_design_win;};
- ///Adds given map to storage.
-
- ///A name and the map itself has to be provided.
- ///\param mapname is the name of map
- ///\param nodemap is the pointer of the given nodemap
- ///\param def the default value of the map. If not given, it will be 0.
- ///If new edge is added to graph the value of it in the map will be this.
- ///\todo map should be given by reference!
- ///\todo why is default value stored?
- int addNodeMap(const std::string & mapname,Graph::NodeMap<double> * nodemap, double def=0.0);
-
- ///Adds given map to storage. A name and the map itself has to be provided.
-
- ///A name and the map itself has to be provided.
- ///\param mapname is the name of map
- ///\param edgemap is the pointer of the given edgemap
- ///\param def the default value of the map. If not given, it will be 0.
- ///If new edge is added to graph the value of it in the map will be this.
- ///\todo map should be given by reference!
- int addEdgeMap(const std::string & mapname,Graph::EdgeMap<double> * edgemap, double def=0.0);
-
- ///Returns how much nodemaps is stored in \ref MapStorage
- int numOfNodeMaps() {return nodemap_storage.size();};
-
- ///Returns how much edgemaps is stored in \ref MapStorage
- int numOfEdgeMaps() {return edgemap_storage.size();};
-
- ///Returns the maximum value of the given NodeMap.
-
- ///NodeMap has to be given by its name.
- ///\param name the name of map of which maximum is searched
- double maxOfNodeMap(const std::string & name);
-
- ///Returns the maximum value of the given EdgeMap.
-
- ///EdgeMap has to be given by its name.
- ///\param name the name of map of which maximum is searched
- double maxOfEdgeMap(const std::string & name);
-
- ///Returns the minimum value of the given NodeMap.
-
- ///NodeMap has to be given by its name.
- ///\param name the name of map of which minimum is searched
- double minOfNodeMap(const std::string & name);
-
- ///Returns the minimum value of the given EdgeMap.
-
- ///EdgeMap has to be given by its name.
- ///\param name the name of map of which minimum is searched
- double minOfEdgeMap(const std::string & name);
-
- ///Returns iterator pointing to the first NodeMap in storage.
-
- ///To be able to iterate through each maps this function
- ///returns an iterator pointing to the first nodemap in
- ///the storage.
- std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
-
- ///Returns iterator pointing to the first EdgeMap in storage.
-
- ///To be able to iterate through each maps this function
- ///returns an iterator pointing to the first edgemap in
- ///the storage.
- std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
-
- ///Returns iterator pointing after the last NodeMap in storage.
-
- ///To be able to iterate through each maps this function
- ///returns an iterator pointing to the last nodemap in the storage.
- std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
-
- ///Returns iterator pointing after the last EdgeMap in storage.
-
- ///To be able to iterate through each maps this function
- ///returns an iterator pointing to the last edgemap in the storage.
- std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
+ void createNodeMap(const std::string& name, MapValue::Type type,
+ MapValue def_val);
+ void createEdgeMap(const std::string& name, MapValue::Type type,
+ MapValue def_val);
///Emits \ref signal_prop if mapvalues have changed, and MapStorage gets to know it.
@@ -315,8 +338,6 @@
///Deletes all datastructures stored here.
void clear();
- void ArrowPosReadOK();
-
void get_design_data(double &, double &, int &);
void set_attraction(double);
void set_propulsation(double);
@@ -329,10 +350,10 @@
XY getArrowCoords(Edge e) const;
void setArrowCoords(Edge e, XY c);
- double get(const std::string& map, Node n) const;
- void set(const std::string& map, Node n, double val);
- double get(const std::string& map, Edge e) const;
- void set(const std::string& map, Edge e, double val);
+ MapValue get(const std::string& name, Node node) const;
+ void set(const std::string& name, Node node, MapValue val);
+ MapValue get(const std::string& name, Edge edge) const;
+ void set(const std::string& name, Edge edge, MapValue val);
const std::string& getFileName() const;
void setFileName(const std::string& fn);
@@ -343,11 +364,33 @@
Node addNode(XY);
Edge addEdge(Node, Node);
- Graph::NodeMap<double>& getNodeMap(const std::string&);
- Graph::EdgeMap<double>& getEdgeMap(const std::string&);
+ IntegerNodeMap& getIntegerNodeMap(const std::string& name);
+ ScalarNodeMap& getScalarNodeMap(const std::string& name);
+ StringNodeMap& getStringNodeMap(const std::string& name);
+ IntegerEdgeMap& getIntegerEdgeMap(const std::string& name);
+ ScalarEdgeMap& getScalarEdgeMap(const std::string& name);
+ StringEdgeMap& getStringEdgeMap(const std::string& name);
+
+ int getLabel(Node) const;
+ int getLabel(Edge) const;
+
+ GuiSectSaveDestination getGUIDataSaveLocation();
+ void setGUIDataSaveLocation(GuiSectSaveDestination dest);
+
+ MapSaveDestination getNodeMapSaveDest(std::string name) const;
+ MapSaveDestination getEdgeMapSaveDest(std::string name) const;
+ void setNodeMapSaveDest(std::string name, MapSaveDestination dest);
+ void setEdgeMapSaveDest(std::string name, MapSaveDestination dest);
- double getLabel(Node) const;
- double getLabel(Edge) const;
+ MapValue::Type getNodeMapElementType(std::string name) const;
+ MapValue::Type getEdgeMapElementType(std::string name) const;
+
+ const NodeLabelMap& getNodeLabelMap();
+ const EdgeLabelMap& getEdgeLabelMap();
+
+private:
+ EdgeMapData* getEdgeMapData(std::string name) const;
+ NodeMapData* getNodeMapData(std::string name) const;
};
#endif //MAPSTORAGE_H
Modified: glemon/branches/akos/nbtab.cc
==============================================================================
--- glemon/branches/akos/nbtab.cc (original)
+++ glemon/branches/akos/nbtab.cc Fri Apr 13 14:13:14 2007
@@ -218,16 +218,6 @@
}
}
-void NoteBookTab::createMapListWin(std::string name)
-{
- if (!maplistwinexists)
- {
- maplistwin = new FileImportWindow(&mapstorage);
- maplistwin->show();
- maplistwinexists = true;
- }
-}
-
void NoteBookTab::createMapWin(std::string name)
{
if(!mapwinexists)
Modified: glemon/branches/akos/nbtab.h
==============================================================================
--- glemon/branches/akos/nbtab.h (original)
+++ glemon/branches/akos/nbtab.h Fri Apr 13 14:13:14 2007
@@ -23,7 +23,6 @@
#include "mapstorage.h"
#include "map_win.h"
-#include "file_import_window.h"
#include "design_win.h"
#include "graph_displayer_canvas.h"
#include <libgnomecanvasmm.h>
@@ -92,15 +91,12 @@
///The graph will be drawn on this \ref GraphDisplayerCanvas
GraphDisplayerCanvas * gd_canvas;
- bool maplistwinexists;
-
///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
bool mapwinexists;
///Indicates whether the \ref DesignWin is opened or not. See \ref designwin.
bool designwinexists;
- FileImportWindow* maplistwin;
///Address of the only \ref MapWin that the \ref NoteBookTab can open.
///Only one of this window can be opened at the same time (\ref mapwinexists),
@@ -177,8 +173,6 @@
///\param mapname name of new map
void registerNewNodeMap(std::string mapname);
- void createMapListWin(std::string);
-
///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
///See also
Modified: glemon/branches/akos/new_map_win.cc
==============================================================================
--- glemon/branches/akos/new_map_win.cc (original)
+++ glemon/branches/akos/new_map_win.cc Fri Apr 13 14:13:14 2007
@@ -272,6 +272,20 @@
{
abortion=1;
}
+ /*
+ try
+ {
+ mytab.mapstorage.createNodeMap(mapname, MapStorage::SCALAR,
+ MapValue(def_val));
+ for ()
+ {
+ }
+ }
+ catch (MapStorage::MapAlreadyExists& e)
+ {
+ abortion=1;
+ }
+ */
//add it to the list of the displayable maps
//furthermore it is done by signals
Modified: glemon/branches/akos/save_details_widget.cc
==============================================================================
--- glemon/branches/akos/save_details_widget.cc (original)
+++ glemon/branches/akos/save_details_widget.cc Fri Apr 13 14:13:14 2007
@@ -18,15 +18,15 @@
nbMaps.set_tab_pos(Gtk::POS_BOTTOM);
- /*
switch (pMapStorage->getGUIDataSaveLocation())
{
- case GUI_SECTION:
+ case MapStorage::LGF_FILE:
+ rbLgfFile.set_active();
break;
- case CONF_FILE:
+ case MapStorage::CONF_FILE:
+ rbConfFile.set_active();
break;
}
- */
pack_start(lblGuiSectionSave, Gtk::PACK_SHRINK);
pack_start(box, Gtk::PACK_SHRINK);
@@ -127,10 +127,12 @@
void SaveDetailsWidget::onRbToggled()
{
- std::cout << "SaveDetailsWidget::onRbToggled()" << std::endl;
+ if (rbLgfFile.get_active())
+ pMapStorage->setGUIDataSaveLocation(MapStorage::LGF_FILE);
+ else if (rbConfFile.get_active())
+ pMapStorage->setGUIDataSaveLocation(MapStorage::CONF_FILE);
}
SaveDetailsWidget::~SaveDetailsWidget()
{
- std::cout << "SaveDetailsWidget::~SaveDetailsWidget()" << std::endl;
}
More information about the Lemon-commits
mailing list