[Lemon-commits] ladanyi: r3364 - glemon/branches/akos
Lemon SVN
svn at lemon.cs.elte.hu
Thu Nov 8 15:31:25 CET 2007
Author: ladanyi
Date: Thu Nov 8 15:31:24 2007
New Revision: 3364
Modified:
glemon/branches/akos/file_import_dialog.cc
glemon/branches/akos/file_import_dialog.h
glemon/branches/akos/mapstorage.cc
glemon/branches/akos/mapstorage.h
Log:
Generate edge labels in case they are missing from the file. Bugfix in
FileImportDialog.
Modified: glemon/branches/akos/file_import_dialog.cc
==============================================================================
--- glemon/branches/akos/file_import_dialog.cc (original)
+++ glemon/branches/akos/file_import_dialog.cc Thu Nov 8 15:31:24 2007
@@ -113,6 +113,13 @@
box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
box12->pack_start(cbNodeCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
+
+ cbNodeCoordOneMap.signal_changed().connect(
+ sigc::mem_fun(*this, &FileImportDialog::onNodeCoordOneMapChanged));
+ cbNodeCoordTwoMaps1.signal_changed().connect(
+ sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps1Changed));
+ cbNodeCoordTwoMaps2.signal_changed().connect(
+ sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps2Changed));
}
{
@@ -194,6 +201,13 @@
box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
box12->pack_start(cbArrowCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
+
+ cbArrowCoordOneMap.signal_changed().connect(
+ sigc::mem_fun(*this, &FileImportDialog::onArrowCoordOneMapChanged));
+ cbArrowCoordTwoMaps1.signal_changed().connect(
+ sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps1Changed));
+ cbArrowCoordTwoMaps2.signal_changed().connect(
+ sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps2Changed));
}
}
@@ -361,7 +375,6 @@
cbNodeCoordTwoMaps2.get_parent()->set_sensitive(false);
p_data->node_coord_load_from = ImportData::ONE_MAP;
- p_data->node_coord_one_map_name = cbNodeCoordOneMap.get_active_text();
}
else if (rbNodeCoordTwoMaps.get_active())
{
@@ -370,8 +383,6 @@
cbNodeCoordTwoMaps2.get_parent()->set_sensitive(true);
p_data->node_coord_load_from = ImportData::TWO_MAPS;
- p_data->node_coord_two_maps_1_name = cbNodeCoordTwoMaps1.get_active_text();
- p_data->node_coord_two_maps_2_name = cbNodeCoordTwoMaps2.get_active_text();
}
else if (rbNodeCoordNone.get_active())
{
@@ -392,7 +403,6 @@
cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false);
p_data->arrow_coord_load_from = ImportData::ONE_MAP;
- p_data->arrow_coord_one_map_name = cbArrowCoordOneMap.get_active_text();
}
else if (rbArrowCoordTwoMaps.get_active())
{
@@ -401,10 +411,6 @@
cbArrowCoordTwoMaps2.get_parent()->set_sensitive(true);
p_data->arrow_coord_load_from = ImportData::TWO_MAPS;
- p_data->arrow_coord_two_maps_1_name =
- cbArrowCoordTwoMaps1.get_active_text();
- p_data->arrow_coord_two_maps_2_name =
- cbArrowCoordTwoMaps2.get_active_text();
}
else if (rbArrowCoordNone.get_active())
{
@@ -574,3 +580,33 @@
}
return false;
}
+
+void FileImportDialog::onNodeCoordOneMapChanged()
+{
+ p_data->node_coord_one_map_name = cbNodeCoordOneMap.get_active_text();
+}
+
+void FileImportDialog::onNodeCoordTwoMaps1Changed()
+{
+ p_data->node_coord_two_maps_1_name = cbNodeCoordTwoMaps1.get_active_text();
+}
+
+void FileImportDialog::onNodeCoordTwoMaps2Changed()
+{
+ p_data->node_coord_two_maps_2_name = cbNodeCoordTwoMaps2.get_active_text();
+}
+
+void FileImportDialog::onArrowCoordOneMapChanged()
+{
+ p_data->arrow_coord_one_map_name = cbArrowCoordOneMap.get_active_text();
+}
+
+void FileImportDialog::onArrowCoordTwoMaps1Changed()
+{
+ p_data->arrow_coord_two_maps_1_name = cbArrowCoordTwoMaps1.get_active_text();
+}
+
+void FileImportDialog::onArrowCoordTwoMaps2Changed()
+{
+ p_data->arrow_coord_two_maps_2_name = cbArrowCoordTwoMaps2.get_active_text();
+}
Modified: glemon/branches/akos/file_import_dialog.h
==============================================================================
--- glemon/branches/akos/file_import_dialog.h (original)
+++ glemon/branches/akos/file_import_dialog.h Thu Nov 8 15:31:24 2007
@@ -66,6 +66,15 @@
void onArrowCoordMapNumToggled();
void onResponse(int id);
+
+ void onNodeCoordOneMapChanged();
+ void onNodeCoordTwoMaps1Changed();
+ void onNodeCoordTwoMaps2Changed();
+
+ void onArrowCoordOneMapChanged();
+ void onArrowCoordTwoMaps1Changed();
+ void onArrowCoordTwoMaps2Changed();
+
public:
FileImportDialog(ImportData* d);
~FileImportDialog();
Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc (original)
+++ glemon/branches/akos/mapstorage.cc Thu Nov 8 15:31:24 2007
@@ -25,6 +25,7 @@
#include <iostream>
#include <fstream>
#include <string>
+#include <algorithm>
#include <gtkmm.h>
#include "file_import_dialog.h"
@@ -371,7 +372,7 @@
arrow_coords_save_dest = gui_data.arrow_coords_save_dest;
arrow_coords_save_map_num = gui_data.arrow_coords_save_map_num;
}
- readLGF(filename,
+ readLGF(filename, true,
gui_data.main_node_map_names, gui_data.main_edge_map_names,
gui_data.node_map_types, gui_data.edge_map_types,
node_coord_xmap_name, node_coord_ymap_name,
@@ -504,8 +505,23 @@
return 1;
}
- const std::vector<std::string>& nodeMapNames = content.nodeSetMaps(0);
- const std::vector<std::string>& edgeMapNames = content.edgeSetMaps(0);
+ std::vector<std::string> nodeMapNames = content.nodeSetMaps(0);
+ std::vector<std::string> edgeMapNames = content.edgeSetMaps(0);
+
+ bool read_edge_label = true;
+ if (std::find(edgeMapNames.begin(), edgeMapNames.end(), "label") ==
+ edgeMapNames.end())
+ {
+ read_edge_label = false;
+ }
+
+ nodeMapNames.erase(
+ std::remove(nodeMapNames.begin(), nodeMapNames.end(), "label"),
+ nodeMapNames.end());
+
+ edgeMapNames.erase(
+ std::remove(edgeMapNames.begin(), edgeMapNames.end(), "label"),
+ edgeMapNames.end());
FileImportDialog::ImportData data(nodeMapNames, edgeMapNames);
FileImportDialog fidialog(&data);
@@ -577,13 +593,23 @@
// TODO
// read edge and node maps
- readLGF(filename,
+ readLGF(filename, read_edge_label,
std::vector<std::string>(), std::vector<std::string>(),
std::map<std::string, MapValue::Type>(),
std::map<std::string, MapValue::Type>(),
node_coord_xmap_name, node_coord_ymap_name,
arrow_coord_xmap_name, arrow_coord_ymap_name);
+ // generate edge labels
+ if (!read_edge_label)
+ {
+ int l = 0;
+ for (EdgeIt e(graph); e != INVALID; ++e)
+ {
+ edge_label[e] = l++;
+ }
+ }
+
if (gen_node_coords)
{
// generate node coordinates
@@ -1212,6 +1238,16 @@
}
cout << endl;
}
+ cout << "Node cooridnates:" << endl;
+ for (NodeIt it(graph); it != INVALID; ++it)
+ {
+ cout << node_label[it] << node_coords[it] << endl;
+ }
+ cout << "Arrow cooridnates:" << endl;
+ for (EdgeIt it(graph); it != INVALID; ++it)
+ {
+ cout << edge_label[it] << arrow_coords[it] << endl;
+ }
}
std::vector<std::string> MapStorage::getEdgeMaps(MapType type)
@@ -1344,6 +1380,7 @@
void MapStorage::readLGF(
const std::string& filename,
+ bool read_edge_label,
const std::vector<std::string>& node_map_names,
const std::vector<std::string>& edge_map_names,
const std::map<std::string, MapValue::Type>& node_map_types,
@@ -1361,7 +1398,8 @@
// read the label maps
greader.readNodeMap("label", node_label);
- greader.readEdgeMap("label", edge_label);
+ if (read_edge_label)
+ greader.readEdgeMap("label", edge_label);
// read the node maps
for (vector<string>::const_iterator
Modified: glemon/branches/akos/mapstorage.h
==============================================================================
--- glemon/branches/akos/mapstorage.h (original)
+++ glemon/branches/akos/mapstorage.h Thu Nov 8 15:31:24 2007
@@ -510,6 +510,7 @@
NodeMapData* getNodeMapData(std::string name) const;
void readLGF(
const std::string& filename,
+ bool read_edge_label,
const std::vector<std::string>& node_map_names,
const std::vector<std::string>& edge_map_names,
const std::map<std::string, MapValue::Type>& node_map_types,
More information about the Lemon-commits
mailing list