file_import_dialog.cc
changeset 1 67188bd752db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/file_import_dialog.cc	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -0,0 +1,928 @@
     1.4 +#include "file_import_dialog.h"
     1.5 +#include <gtkmm/dialog.h>
     1.6 +#include <gtkmm/stock.h>
     1.7 +#include <gtkmm/notebook.h>
     1.8 +#include <gtkmm/messagedialog.h>
     1.9 +#include <gtkmm/frame.h>
    1.10 +#include <iostream>
    1.11 +
    1.12 +FileImportDialog::FileImportDialog(ImportData* d) :
    1.13 +  p_data(d)
    1.14 +{
    1.15 +  add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    1.16 +  add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
    1.17 +
    1.18 +  Gtk::VBox* pVBox = get_vbox();
    1.19 +
    1.20 +  Gtk::Notebook* nb = Gtk::manage(new Gtk::Notebook);
    1.21 +  pVBox->pack_start(*nb, Gtk::PACK_EXPAND_WIDGET);
    1.22 +
    1.23 +  Gtk::VBox* vblueMaps = Gtk::manage(new Gtk::VBox(false, 18));
    1.24 +  vblueMaps->set_border_width(12);
    1.25 +
    1.26 +  Gtk::VBox* vbArcMaps = Gtk::manage(new Gtk::VBox(false, 18));
    1.27 +  vbArcMaps->set_border_width(12);
    1.28 +
    1.29 +  Gtk::VBox* vbSpecMaps = Gtk::manage(new Gtk::VBox(false, 18));
    1.30 +  vbSpecMaps->set_border_width(12);
    1.31 +
    1.32 +  nb->append_page(*vbSpecMaps, "Special Maps");
    1.33 +  nb->append_page(*vblueMaps, "Node Maps");
    1.34 +  nb->append_page(*vbArcMaps, "Arc Maps");
    1.35 +
    1.36 +  // child widgets of vbSpecMaps
    1.37 +  {
    1.38 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
    1.39 +    vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK);
    1.40 +
    1.41 +    {
    1.42 +      Gtk::Label* label1 =
    1.43 +        Gtk::manage(new Gtk::Label("<b>Node Coordinates</b>"));
    1.44 +      label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
    1.45 +      label1->set_use_markup();
    1.46 +      box1->pack_start(*label1);
    1.47 +
    1.48 +      Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
    1.49 +      box1->pack_start(*box2);
    1.50 +
    1.51 +      Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
    1.52 +      box2->pack_start(*fill1, Gtk::PACK_SHRINK);
    1.53 +
    1.54 +      Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
    1.55 +      box2->pack_start(*box3);
    1.56 +
    1.57 +      Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox);
    1.58 +      box3->pack_start(*box13);
    1.59 +
    1.60 +      rblueCoordNone.set_label("None");
    1.61 +      Gtk::RadioButtonGroup group = rblueCoordNone.get_group();
    1.62 +      box13->pack_start(rblueCoordNone);
    1.63 +
    1.64 +      Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox);
    1.65 +      box3->pack_start(*box4);
    1.66 +
    1.67 +      rblueCoordOneMap.set_label("One Map");
    1.68 +      rblueCoordOneMap.set_group(group);
    1.69 +      box4->pack_start(rblueCoordOneMap);
    1.70 +
    1.71 +      Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox);
    1.72 +      box4->pack_start(*box5);
    1.73 +
    1.74 +      Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
    1.75 +      box5->pack_start(*fill2, Gtk::PACK_SHRINK);
    1.76 +
    1.77 +      Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox);
    1.78 +      box5->pack_start(*box6);
    1.79 +
    1.80 +      Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox);
    1.81 +      box6->pack_start(*box7);
    1.82 +
    1.83 +      Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)"));
    1.84 +      box7->pack_start(*label2, Gtk::PACK_SHRINK, 4);
    1.85 +
    1.86 +      box7->pack_start(cblueCoordOneMap, Gtk::PACK_EXPAND_WIDGET);
    1.87 +
    1.88 +
    1.89 +      Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox);
    1.90 +      box3->pack_start(*box8);
    1.91 +
    1.92 +      rblueCoordTwoMaps.set_label("Two Maps");
    1.93 +      rblueCoordTwoMaps.set_group(group);
    1.94 +      box8->pack_start(rblueCoordTwoMaps);
    1.95 +
    1.96 +      Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox);
    1.97 +      box8->pack_start(*box9);
    1.98 +
    1.99 +      Gtk::Label* fill3 = Gtk::manage(new Gtk::Label("    "));
   1.100 +      box9->pack_start(*fill3, Gtk::PACK_SHRINK);
   1.101 +
   1.102 +      Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox);
   1.103 +      box9->pack_start(*box10);
   1.104 +
   1.105 +      Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox);
   1.106 +      box10->pack_start(*box11);
   1.107 +
   1.108 +      Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X"));
   1.109 +      box11->pack_start(*label3, Gtk::PACK_SHRINK, 4);
   1.110 +
   1.111 +      box11->pack_start(cblueCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET);
   1.112 +
   1.113 +      Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox);
   1.114 +      box10->pack_start(*box12);
   1.115 +
   1.116 +      Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y"));
   1.117 +      box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
   1.118 +
   1.119 +      box12->pack_start(cblueCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
   1.120 +
   1.121 +      cblueCoordOneMap.signal_changed().connect(
   1.122 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordOneMapChanged));
   1.123 +      cblueCoordTwoMaps1.signal_changed().connect(
   1.124 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps1Changed));
   1.125 +      cblueCoordTwoMaps2.signal_changed().connect(
   1.126 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps2Changed));
   1.127 +    }
   1.128 +
   1.129 +    {
   1.130 +      Gtk::Label* label1 =
   1.131 +        Gtk::manage(new Gtk::Label("<b>Arrow Coordinates</b>"));
   1.132 +      label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   1.133 +      label1->set_use_markup();
   1.134 +      box1->pack_start(*label1);
   1.135 +
   1.136 +      Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   1.137 +      box1->pack_start(*box2);
   1.138 +
   1.139 +      Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   1.140 +      box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   1.141 +
   1.142 +      Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
   1.143 +      box2->pack_start(*box3);
   1.144 +
   1.145 +      Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox);
   1.146 +      box3->pack_start(*box13);
   1.147 +
   1.148 +      rbArrowCoordNone.set_label("None");
   1.149 +      Gtk::RadioButtonGroup group = rbArrowCoordNone.get_group();
   1.150 +      box13->pack_start(rbArrowCoordNone);
   1.151 +
   1.152 +      Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox);
   1.153 +      box3->pack_start(*box4);
   1.154 +
   1.155 +      rbArrowCoordOneMap.set_label("One Map");
   1.156 +      rbArrowCoordOneMap.set_group(group);
   1.157 +      box4->pack_start(rbArrowCoordOneMap);
   1.158 +
   1.159 +      Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox);
   1.160 +      box4->pack_start(*box5);
   1.161 +
   1.162 +      Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
   1.163 +      box5->pack_start(*fill2, Gtk::PACK_SHRINK);
   1.164 +
   1.165 +      Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox);
   1.166 +      box5->pack_start(*box6);
   1.167 +
   1.168 +      Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox);
   1.169 +      box6->pack_start(*box7);
   1.170 +
   1.171 +      Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)"));
   1.172 +      box7->pack_start(*label2, Gtk::PACK_SHRINK, 4);
   1.173 +
   1.174 +      box7->pack_start(cbArrowCoordOneMap, Gtk::PACK_EXPAND_WIDGET);
   1.175 +
   1.176 +
   1.177 +      Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox);
   1.178 +      box3->pack_start(*box8);
   1.179 +
   1.180 +      rbArrowCoordTwoMaps.set_label("Two Maps");
   1.181 +      rbArrowCoordTwoMaps.set_group(group);
   1.182 +      box8->pack_start(rbArrowCoordTwoMaps);
   1.183 +
   1.184 +      Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox);
   1.185 +      box8->pack_start(*box9);
   1.186 +
   1.187 +      Gtk::Label* fill3 = Gtk::manage(new Gtk::Label("    "));
   1.188 +      box9->pack_start(*fill3, Gtk::PACK_SHRINK);
   1.189 +
   1.190 +      Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox);
   1.191 +      box9->pack_start(*box10);
   1.192 +
   1.193 +      Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox);
   1.194 +      box10->pack_start(*box11);
   1.195 +
   1.196 +      Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X"));
   1.197 +      box11->pack_start(*label3, Gtk::PACK_SHRINK, 4);
   1.198 +
   1.199 +      box11->pack_start(cbArrowCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET);
   1.200 +
   1.201 +      Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox);
   1.202 +      box10->pack_start(*box12);
   1.203 +
   1.204 +      Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y"));
   1.205 +      box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
   1.206 +
   1.207 +      box12->pack_start(cbArrowCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
   1.208 +
   1.209 +      cbArrowCoordOneMap.signal_changed().connect(
   1.210 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordOneMapChanged));
   1.211 +      cbArrowCoordTwoMaps1.signal_changed().connect(
   1.212 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps1Changed));
   1.213 +      cbArrowCoordTwoMaps2.signal_changed().connect(
   1.214 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps2Changed));
   1.215 +    }
   1.216 +  }
   1.217 +
   1.218 +  // child widgets of vblueMaps
   1.219 +  {
   1.220 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
   1.221 +    vblueMaps->pack_start(*box1, Gtk::PACK_SHRINK);
   1.222 +
   1.223 +    Gtk::Label* label1 =
   1.224 +      Gtk::manage(new Gtk::Label("<b>Element type</b>"));
   1.225 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   1.226 +    label1->set_use_markup();
   1.227 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
   1.228 +
   1.229 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   1.230 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
   1.231 +
   1.232 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   1.233 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   1.234 +
   1.235 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
   1.236 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
   1.237 +
   1.238 +    Gtk::ScrolledWindow* swNodeMaps = Gtk::manage(new Gtk::ScrolledWindow);
   1.239 +    frame->add(*swNodeMaps);
   1.240 +
   1.241 +    swNodeMaps->add(twNodeMaps);
   1.242 +
   1.243 +    refNodeMapStore = Gtk::ListStore::create(NodeMapColumns);
   1.244 +
   1.245 +    for (std::vector<std::string>::const_iterator it =
   1.246 +        p_data->node_map_names.begin(); it != p_data->node_map_names.end();
   1.247 +        ++it)
   1.248 +    {
   1.249 +      node_tree_view_records.push_back(
   1.250 +          tree_view_record(*it, false, false, true));
   1.251 +    }
   1.252 +
   1.253 +    twNodeMaps.set_model(refNodeMapStore);
   1.254 +    twNodeMaps.append_column("Name", NodeMapColumns.colName);
   1.255 +    {
   1.256 +      int col = twNodeMaps.append_column_editable("Numeric",
   1.257 +          NodeMapColumns.colReadAsNumeric);
   1.258 +      Gtk::CellRendererToggle* pRenderer =
   1.259 +        static_cast<Gtk::CellRendererToggle*>(
   1.260 +            twNodeMaps.get_column_cell_renderer(col-1));
   1.261 +      pRenderer->signal_toggled().connect(
   1.262 +          sigc::mem_fun(*this, &FileImportDialog::onNodeMapNumericToggled));
   1.263 +    }
   1.264 +    {
   1.265 +      int col = twNodeMaps.append_column_editable("String",
   1.266 +          NodeMapColumns.colReadAsString);
   1.267 +      Gtk::CellRendererToggle* pRenderer =
   1.268 +        static_cast<Gtk::CellRendererToggle*>(
   1.269 +            twNodeMaps.get_column_cell_renderer(col-1));
   1.270 +      pRenderer->signal_toggled().connect(
   1.271 +          sigc::mem_fun(*this, &FileImportDialog::onNodeMapStringToggled));
   1.272 +    }
   1.273 +
   1.274 +    swNodeMaps->set_size_request(-1, 200);
   1.275 +    swNodeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   1.276 +  }
   1.277 +
   1.278 +  // child widgets of vbArcMaps
   1.279 +  {
   1.280 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
   1.281 +    vbArcMaps->pack_start(*box1, Gtk::PACK_SHRINK);
   1.282 +
   1.283 +    Gtk::Label* label1 =
   1.284 +      Gtk::manage(new Gtk::Label("<b>Element type</b>"));
   1.285 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   1.286 +    label1->set_use_markup();
   1.287 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
   1.288 +
   1.289 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   1.290 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
   1.291 +
   1.292 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   1.293 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   1.294 +
   1.295 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
   1.296 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
   1.297 +
   1.298 +    Gtk::ScrolledWindow* swArcMaps = Gtk::manage(new Gtk::ScrolledWindow);
   1.299 +    frame->add(*swArcMaps);
   1.300 +
   1.301 +    swArcMaps->add(twArcMaps);
   1.302 +
   1.303 +    refArcMapStore = Gtk::ListStore::create(ArcMapColumns);
   1.304 +
   1.305 +    for (std::vector<std::string>::const_iterator it =
   1.306 +        p_data->arc_map_names.begin(); it != p_data->arc_map_names.end();
   1.307 +        ++it)
   1.308 +    {
   1.309 +      arc_tree_view_records.push_back(
   1.310 +          tree_view_record(*it, false, false, true));
   1.311 +    }
   1.312 +
   1.313 +    twArcMaps.set_model(refArcMapStore);
   1.314 +    twArcMaps.append_column("Name", ArcMapColumns.colName);
   1.315 +    {
   1.316 +      int col = twArcMaps.append_column_editable("Numeric",
   1.317 +          ArcMapColumns.colReadAsNumeric);
   1.318 +      Gtk::CellRendererToggle* pRenderer =
   1.319 +        static_cast<Gtk::CellRendererToggle*>(
   1.320 +            twArcMaps.get_column_cell_renderer(col-1));
   1.321 +      pRenderer->signal_toggled().connect(
   1.322 +          sigc::mem_fun(*this, &FileImportDialog::onArcMapNumericToggled));
   1.323 +    }
   1.324 +    {
   1.325 +      int col = twArcMaps.append_column_editable("String",
   1.326 +          ArcMapColumns.colReadAsString);
   1.327 +      Gtk::CellRendererToggle* pRenderer =
   1.328 +        static_cast<Gtk::CellRendererToggle*>(
   1.329 +            twArcMaps.get_column_cell_renderer(col-1));
   1.330 +      pRenderer->signal_toggled().connect(
   1.331 +          sigc::mem_fun(*this, &FileImportDialog::onArcMapStringToggled));
   1.332 +    }
   1.333 +
   1.334 +    swArcMaps->set_size_request(-1, 200);
   1.335 +    swArcMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   1.336 +  }
   1.337 +
   1.338 +  // fill in the ComboBoxes
   1.339 +  typedef std::vector<std::string> StrVec;
   1.340 +  for (StrVec::const_iterator it = p_data->node_map_names.begin();
   1.341 +      it != p_data->node_map_names.end(); ++it)
   1.342 +  {
   1.343 +    cblueCoordTwoMaps1.append_text(*it);
   1.344 +    cblueCoordTwoMaps2.append_text(*it);
   1.345 +  }
   1.346 +  for (StrVec::const_iterator it = p_data->arc_map_names.begin();
   1.347 +      it != p_data->arc_map_names.end(); ++it)
   1.348 +  {
   1.349 +    cbArrowCoordTwoMaps1.append_text(*it);
   1.350 +    cbArrowCoordTwoMaps2.append_text(*it);
   1.351 +  }
   1.352 +  for (StrVec::const_iterator it = p_data->xy_node_map_names.begin();
   1.353 +      it != p_data->xy_node_map_names.end(); ++it)
   1.354 +  {
   1.355 +    cblueCoordOneMap.append_text(*it);
   1.356 +  }
   1.357 +  for (StrVec::const_iterator it = p_data->xy_arc_map_names.begin();
   1.358 +      it != p_data->xy_arc_map_names.end(); ++it)
   1.359 +  {
   1.360 +    cbArrowCoordOneMap.append_text(*it);
   1.361 +  }
   1.362 +
   1.363 +  if (p_data->isXYNodeMap("coord"))
   1.364 +  {
   1.365 +    cblueCoordOneMap.set_active_text("coord");
   1.366 +  }
   1.367 +  else if (p_data->isXYNodeMap("coords"))
   1.368 +  {
   1.369 +    cblueCoordOneMap.set_active_text("coords");
   1.370 +  }
   1.371 +  else if (p_data->isNodeMap("coord_x") &&
   1.372 +           p_data->isNodeMap("coord_y"))
   1.373 +  {
   1.374 +    cblueCoordTwoMaps1.set_active_text("coord_x");
   1.375 +    cblueCoordTwoMaps2.set_active_text("coord_y");
   1.376 +  }
   1.377 +  else if (p_data->isNodeMap("coords_x") &&
   1.378 +           p_data->isNodeMap("coords_y"))
   1.379 +  {
   1.380 +    cblueCoordTwoMaps1.set_active_text("coords_x");
   1.381 +    cblueCoordTwoMaps2.set_active_text("coords_y");
   1.382 +  }
   1.383 +  else if (p_data->isNodeMap("x") &&
   1.384 +           p_data->isNodeMap("y"))
   1.385 +  {
   1.386 +    cblueCoordTwoMaps1.set_active_text("x");
   1.387 +    cblueCoordTwoMaps2.set_active_text("y");
   1.388 +  }
   1.389 +
   1.390 +  if (p_data->isXYArcMap("arrow"))
   1.391 +  {
   1.392 +    cbArrowCoordOneMap.set_active_text("arrow");
   1.393 +  }
   1.394 +  else if (p_data->isXYArcMap("arrows"))
   1.395 +  {
   1.396 +    cbArrowCoordOneMap.set_active_text("arrows");
   1.397 +  }
   1.398 +  else if (p_data->isXYArcMap("midpoint"))
   1.399 +  {
   1.400 +    cbArrowCoordOneMap.set_active_text("midpoint");
   1.401 +  }
   1.402 +  else if (p_data->isXYArcMap("midpoints"))
   1.403 +  {
   1.404 +    cbArrowCoordOneMap.set_active_text("midpoints");
   1.405 +  }
   1.406 +  else if (p_data->isXYArcMap("mid"))
   1.407 +  {
   1.408 +    cbArrowCoordOneMap.set_active_text("mid");
   1.409 +  }
   1.410 +  else if (p_data->isXYArcMap("mids"))
   1.411 +  {
   1.412 +    cbArrowCoordOneMap.set_active_text("mids");
   1.413 +  }
   1.414 +  else if (p_data->isArcMap("arrow_x") &&
   1.415 +           p_data->isArcMap("arrow_y"))
   1.416 +  {
   1.417 +    cbArrowCoordTwoMaps1.set_active_text("arrow_x");
   1.418 +    cbArrowCoordTwoMaps2.set_active_text("arrow_y");
   1.419 +  }
   1.420 +  else if (p_data->isArcMap("arrows_x") &&
   1.421 +           p_data->isArcMap("arrows_y"))
   1.422 +  {
   1.423 +    cbArrowCoordTwoMaps1.set_active_text("arrows_x");
   1.424 +    cbArrowCoordTwoMaps2.set_active_text("arrows_y");
   1.425 +  }
   1.426 +  else if (p_data->isArcMap("midpoint_x") &&
   1.427 +           p_data->isArcMap("midpoint_y"))
   1.428 +  {
   1.429 +    cbArrowCoordTwoMaps1.set_active_text("midpoint_x");
   1.430 +    cbArrowCoordTwoMaps2.set_active_text("midpoint_y");
   1.431 +  }
   1.432 +  else if (p_data->isArcMap("midpoints_x") &&
   1.433 +           p_data->isArcMap("midpoints_y"))
   1.434 +  {
   1.435 +    cbArrowCoordTwoMaps1.set_active_text("midpoints_x");
   1.436 +    cbArrowCoordTwoMaps2.set_active_text("midpoints_y");
   1.437 +  }
   1.438 +  else if (p_data->isArcMap("mid_x") &&
   1.439 +           p_data->isArcMap("mid_y"))
   1.440 +  {
   1.441 +    cbArrowCoordTwoMaps1.set_active_text("mid_x");
   1.442 +    cbArrowCoordTwoMaps2.set_active_text("mid_y");
   1.443 +  }
   1.444 +  else if (p_data->isArcMap("mids_x") &&
   1.445 +           p_data->isArcMap("mids_y"))
   1.446 +  {
   1.447 +    cbArrowCoordTwoMaps1.set_active_text("mids_x");
   1.448 +    cbArrowCoordTwoMaps2.set_active_text("mids_y");
   1.449 +  }
   1.450 +
   1.451 +  {
   1.452 +    if (cblueCoordOneMap.get_active_text() != "")
   1.453 +      rblueCoordOneMap.set_active();
   1.454 +    else if (cblueCoordTwoMaps1.get_active_text() != "")
   1.455 +      rblueCoordTwoMaps.set_active();
   1.456 +    else
   1.457 +      rblueCoordNone.set_active();
   1.458 +
   1.459 +    if (cbArrowCoordOneMap.get_active_text() != "")
   1.460 +      rbArrowCoordOneMap.set_active();
   1.461 +    else if (cbArrowCoordTwoMaps1.get_active_text() != "")
   1.462 +      rbArrowCoordTwoMaps.set_active();
   1.463 +    else
   1.464 +      rbArrowCoordNone.set_active();
   1.465 +
   1.466 +    onNodeCoordMapNumToggled();
   1.467 +    onArrowCoordMapNumToggled();
   1.468 +
   1.469 +    rblueCoordOneMap.signal_toggled().connect(
   1.470 +        sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled));
   1.471 +    rblueCoordTwoMaps.signal_toggled().connect(
   1.472 +        sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled));
   1.473 +    rbArrowCoordOneMap.signal_toggled().connect(
   1.474 +        sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled));
   1.475 +    rbArrowCoordTwoMaps.signal_toggled().connect(
   1.476 +        sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled));
   1.477 +  }
   1.478 +
   1.479 +  signal_response().connect(
   1.480 +      sigc::mem_fun(*this, &FileImportDialog::onResponse));
   1.481 +
   1.482 +  update_node_tree_view();
   1.483 +  update_arc_tree_view();
   1.484 +
   1.485 +  show_all_children();
   1.486 +}
   1.487 +
   1.488 +void FileImportDialog::onNodeCoordMapNumToggled()
   1.489 +{
   1.490 +  if (rblueCoordOneMap.get_active())
   1.491 +  {
   1.492 +    cblueCoordOneMap.get_parent()->set_sensitive(true);
   1.493 +    cblueCoordTwoMaps1.get_parent()->set_sensitive(false);
   1.494 +    cblueCoordTwoMaps2.get_parent()->set_sensitive(false);
   1.495 +
   1.496 +    p_data->node_coord_load_from = ImportData::ONE_MAP;
   1.497 +  }
   1.498 +  else if (rblueCoordTwoMaps.get_active())
   1.499 +  {
   1.500 +    cblueCoordOneMap.get_parent()->set_sensitive(false);
   1.501 +    cblueCoordTwoMaps1.get_parent()->set_sensitive(true);
   1.502 +    cblueCoordTwoMaps2.get_parent()->set_sensitive(true);
   1.503 +
   1.504 +    p_data->node_coord_load_from = ImportData::TWO_MAPS;
   1.505 +  }
   1.506 +  else if (rblueCoordNone.get_active())
   1.507 +  {
   1.508 +    cblueCoordOneMap.get_parent()->set_sensitive(false);
   1.509 +    cblueCoordTwoMaps1.get_parent()->set_sensitive(false);
   1.510 +    cblueCoordTwoMaps2.get_parent()->set_sensitive(false);
   1.511 +
   1.512 +    p_data->node_coord_load_from = ImportData::DONT_READ;
   1.513 +  }
   1.514 +  update_node_tree_view();
   1.515 +}
   1.516 +
   1.517 +void FileImportDialog::onArrowCoordMapNumToggled()
   1.518 +{
   1.519 +  if (rbArrowCoordOneMap.get_active())
   1.520 +  {
   1.521 +    cbArrowCoordOneMap.get_parent()->set_sensitive(true);
   1.522 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false);
   1.523 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false);
   1.524 +
   1.525 +    p_data->arrow_coord_load_from = ImportData::ONE_MAP;
   1.526 +  }
   1.527 +  else if (rbArrowCoordTwoMaps.get_active())
   1.528 +  {
   1.529 +    cbArrowCoordOneMap.get_parent()->set_sensitive(false);
   1.530 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(true);
   1.531 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(true);
   1.532 +
   1.533 +    p_data->arrow_coord_load_from = ImportData::TWO_MAPS;
   1.534 +  }
   1.535 +  else if (rbArrowCoordNone.get_active())
   1.536 +  {
   1.537 +    cbArrowCoordOneMap.get_parent()->set_sensitive(false);
   1.538 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false);
   1.539 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false);
   1.540 +
   1.541 +    p_data->arrow_coord_load_from = ImportData::DONT_READ;
   1.542 +  }
   1.543 +  update_arc_tree_view();
   1.544 +}
   1.545 +
   1.546 +FileImportDialog::~FileImportDialog()
   1.547 +{
   1.548 +}
   1.549 +
   1.550 +void FileImportDialog::onResponse(int id)
   1.551 +{
   1.552 +  if (id == Gtk::RESPONSE_OK)
   1.553 +  {
   1.554 +    if ((rblueCoordOneMap.get_active() &&
   1.555 +          cblueCoordOneMap.get_active_text() == "") ||
   1.556 +        (rblueCoordTwoMaps.get_active() &&
   1.557 +         (cblueCoordTwoMaps1.get_active_text() == "" ||
   1.558 +          cblueCoordTwoMaps2.get_active_text() == "")))
   1.559 +    {
   1.560 +      Gtk::MessageDialog mdialog("No node map selected.",
   1.561 +          false, Gtk::MESSAGE_ERROR);
   1.562 +      mdialog.run();
   1.563 +      return;
   1.564 +    }
   1.565 +    else if (rblueCoordTwoMaps.get_active() &&
   1.566 +             cblueCoordTwoMaps1.get_active_text() == 
   1.567 +             cblueCoordTwoMaps2.get_active_text())
   1.568 +    {
   1.569 +      Gtk::MessageDialog mdialog(
   1.570 +          "Same node map selected for both coordinates.",
   1.571 +          false, Gtk::MESSAGE_ERROR);
   1.572 +      mdialog.run();
   1.573 +      return;
   1.574 +    }
   1.575 +    if ((rbArrowCoordOneMap.get_active() &&
   1.576 +          cbArrowCoordOneMap.get_active_text() == "") ||
   1.577 +        (rbArrowCoordTwoMaps.get_active() &&
   1.578 +         (cbArrowCoordTwoMaps1.get_active_text() == "" ||
   1.579 +          cbArrowCoordTwoMaps2.get_active_text() == "")))
   1.580 +    {
   1.581 +      Gtk::MessageDialog mdialog("No arc map selected.",
   1.582 +          false, Gtk::MESSAGE_ERROR);
   1.583 +      mdialog.run();
   1.584 +      return;
   1.585 +    }
   1.586 +    else if (rbArrowCoordTwoMaps.get_active() &&
   1.587 +             cbArrowCoordTwoMaps1.get_active_text() == 
   1.588 +             cbArrowCoordTwoMaps2.get_active_text())
   1.589 +    {
   1.590 +      Gtk::MessageDialog mdialog(
   1.591 +          "Same arc map selected for both coordinates.",
   1.592 +          false, Gtk::MESSAGE_ERROR);
   1.593 +      mdialog.run();
   1.594 +      return;
   1.595 +    }
   1.596 +
   1.597 +    for (std::vector<tree_view_record>::const_iterator it =
   1.598 +        node_tree_view_records.begin(); it != node_tree_view_records.end();
   1.599 +        ++it)
   1.600 +    {
   1.601 +      if (it->visible)
   1.602 +      {
   1.603 +        if (it->numeric)
   1.604 +          p_data->numeric_node_map_names.push_back(it->name);
   1.605 +        if (it->string)
   1.606 +          p_data->string_node_map_names.push_back(it->name);
   1.607 +      }
   1.608 +    }
   1.609 +
   1.610 +    for (std::vector<tree_view_record>::const_iterator it =
   1.611 +        arc_tree_view_records.begin(); it != arc_tree_view_records.end();
   1.612 +        ++it)
   1.613 +    {
   1.614 +      if (it->visible)
   1.615 +      {
   1.616 +        if (it->numeric)
   1.617 +          p_data->numeric_arc_map_names.push_back(it->name);
   1.618 +        if (it->string)
   1.619 +          p_data->string_arc_map_names.push_back(it->name);
   1.620 +      }
   1.621 +    }
   1.622 +  }
   1.623 +}
   1.624 +
   1.625 +FileImportDialog::ImportData::ImportData(
   1.626 +    const std::vector<std::string>& _node_map_names,
   1.627 +    const std::vector<std::string>& _arc_map_names) :
   1.628 +  node_map_names(_node_map_names),
   1.629 +  arc_map_names(_arc_map_names)
   1.630 +{
   1.631 +  typedef std::vector<std::string> StrVec;
   1.632 +  {
   1.633 +    StrVec xMaps;
   1.634 +    StrVec yMaps;
   1.635 +    // collect map names ending with ":x" and ":y"
   1.636 +    for (StrVec::const_iterator it = node_map_names.begin();
   1.637 +        it != node_map_names.end(); ++it)
   1.638 +    {
   1.639 +      if ((it->length() >= 3) &&
   1.640 +          (it->substr(it->length()-2, it->length())  == ":x"))
   1.641 +      {
   1.642 +        xMaps.push_back(it->substr(0, it->length()-2));
   1.643 +      }
   1.644 +      if ((it->length() >= 3) &&
   1.645 +          (it->substr(it->length()-2, it->length())  == ":y"))
   1.646 +      {
   1.647 +        yMaps.push_back(it->substr(0, it->length()-2));
   1.648 +      }
   1.649 +    }
   1.650 +
   1.651 +    for (StrVec::const_iterator it1 = xMaps.begin();
   1.652 +        it1 != xMaps.end(); ++it1)
   1.653 +    {
   1.654 +      for (StrVec::const_iterator it2 = yMaps.begin();
   1.655 +          it2 != yMaps.end(); ++it2)
   1.656 +      {
   1.657 +        if (*it1 == *it2) xy_node_map_names.push_back(*it1);
   1.658 +      }
   1.659 +    }
   1.660 +  }
   1.661 +  {
   1.662 +    StrVec xMaps;
   1.663 +    StrVec yMaps;
   1.664 +    // collect map names ending with ":x" and ":y"
   1.665 +    for (StrVec::const_iterator it = arc_map_names.begin();
   1.666 +        it != arc_map_names.end(); ++it)
   1.667 +    {
   1.668 +      if ((it->length() >= 3) &&
   1.669 +          (it->substr(it->length()-2, it->length())  == ":x"))
   1.670 +      {
   1.671 +        xMaps.push_back(it->substr(0, it->length()-2));
   1.672 +      }
   1.673 +      if ((it->length() >= 3) &&
   1.674 +          (it->substr(it->length()-2, it->length())  == ":y"))
   1.675 +      {
   1.676 +        yMaps.push_back(it->substr(0, it->length()-2));
   1.677 +      }
   1.678 +    }
   1.679 +
   1.680 +    for (StrVec::const_iterator it1 = xMaps.begin();
   1.681 +        it1 != xMaps.end(); ++it1)
   1.682 +    {
   1.683 +      for (StrVec::const_iterator it2 = yMaps.begin();
   1.684 +          it2 != yMaps.end(); ++it2)
   1.685 +      {
   1.686 +        if (*it1 == *it2) xy_arc_map_names.push_back(*it1);
   1.687 +      }
   1.688 +    }
   1.689 +  }
   1.690 +}
   1.691 +
   1.692 +FileImportDialog::ImportData::~ImportData()
   1.693 +{
   1.694 +}
   1.695 +
   1.696 +bool FileImportDialog::ImportData::isXYNodeMap(const std::string& name)
   1.697 +{
   1.698 +  if (isNodeMap(name + ":x") && isNodeMap(name + ":y")) return true;
   1.699 +  return false;
   1.700 +}
   1.701 +
   1.702 +bool FileImportDialog::ImportData::isXYArcMap(const std::string& name)
   1.703 +{
   1.704 +  if (isArcMap(name + ":x") && isArcMap(name + ":y")) return true;
   1.705 +  return false;
   1.706 +}
   1.707 +
   1.708 +bool FileImportDialog::ImportData::isNodeMap(const std::string& name)
   1.709 +{
   1.710 +  if (contains(node_map_names, name)) return true;
   1.711 +  return false;
   1.712 +}
   1.713 +
   1.714 +bool FileImportDialog::ImportData::isArcMap(const std::string& name)
   1.715 +{
   1.716 +  if (contains(arc_map_names, name)) return true;
   1.717 +  return false;
   1.718 +}
   1.719 +
   1.720 +bool FileImportDialog::ImportData::contains(const std::vector<std::string>& vec,
   1.721 +    const std::string& str)
   1.722 +{
   1.723 +  for (std::vector<std::string>::const_iterator it = vec.begin();
   1.724 +      it != vec.end(); ++it)
   1.725 +  {
   1.726 +    if (*it == str) return true;
   1.727 +  }
   1.728 +  return false;
   1.729 +}
   1.730 +
   1.731 +void FileImportDialog::onNodeCoordOneMapChanged()
   1.732 +{
   1.733 +  p_data->node_coord_one_map_name = cblueCoordOneMap.get_active_text();
   1.734 +  update_node_tree_view();
   1.735 +}
   1.736 +
   1.737 +void FileImportDialog::onNodeCoordTwoMaps1Changed()
   1.738 +{
   1.739 +  p_data->node_coord_two_maps_1_name = cblueCoordTwoMaps1.get_active_text();
   1.740 +  update_node_tree_view();
   1.741 +}
   1.742 +
   1.743 +void FileImportDialog::onNodeCoordTwoMaps2Changed()
   1.744 +{
   1.745 +  p_data->node_coord_two_maps_2_name = cblueCoordTwoMaps2.get_active_text();
   1.746 +  update_node_tree_view();
   1.747 +}
   1.748 +
   1.749 +void FileImportDialog::onArrowCoordOneMapChanged()
   1.750 +{
   1.751 +  p_data->arrow_coord_one_map_name = cbArrowCoordOneMap.get_active_text();
   1.752 +  update_arc_tree_view();
   1.753 +}
   1.754 +
   1.755 +void FileImportDialog::onArrowCoordTwoMaps1Changed()
   1.756 +{
   1.757 +  p_data->arrow_coord_two_maps_1_name = cbArrowCoordTwoMaps1.get_active_text();
   1.758 +  update_arc_tree_view();
   1.759 +}
   1.760 +
   1.761 +void FileImportDialog::onArrowCoordTwoMaps2Changed()
   1.762 +{
   1.763 +  p_data->arrow_coord_two_maps_2_name = cbArrowCoordTwoMaps2.get_active_text();
   1.764 +  update_arc_tree_view();
   1.765 +}
   1.766 +
   1.767 +void FileImportDialog::onNodeMapNumericToggled(const Glib::ustring& path)
   1.768 +{
   1.769 +  Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter(
   1.770 +      Gtk::TreeModel::Path(path));
   1.771 +  Gtk::TreeModel::Row row = *iter;
   1.772 +  std::vector<tree_view_record>::iterator it;
   1.773 +  for (it = node_tree_view_records.begin();
   1.774 +      it != node_tree_view_records.end(); ++it)
   1.775 +  {
   1.776 +    if (it->name == row[NodeMapColumns.colName]) break;
   1.777 +  }
   1.778 +  if (row[NodeMapColumns.colReadAsNumeric])
   1.779 +  {
   1.780 +    row[NodeMapColumns.colReadAsString] = false;
   1.781 +    it->string = false;
   1.782 +    it->numeric = true;
   1.783 +  }
   1.784 +}
   1.785 +
   1.786 +void FileImportDialog::onNodeMapStringToggled(const Glib::ustring& path)
   1.787 +{
   1.788 +  Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter(
   1.789 +      Gtk::TreeModel::Path(path));
   1.790 +  Gtk::TreeModel::Row row = *iter;
   1.791 +  std::vector<tree_view_record>::iterator it;
   1.792 +  for (it = node_tree_view_records.begin();
   1.793 +      it != node_tree_view_records.end(); ++it)
   1.794 +  {
   1.795 +    if (it->name == row[NodeMapColumns.colName]) break;
   1.796 +  }
   1.797 +  if (row[NodeMapColumns.colReadAsString])
   1.798 +  {
   1.799 +    row[NodeMapColumns.colReadAsNumeric] = false;
   1.800 +    it->string = true;
   1.801 +    it->numeric = false;
   1.802 +  }
   1.803 +}
   1.804 +
   1.805 +void FileImportDialog::update_node_tree_view()
   1.806 +{
   1.807 +  for (std::vector<tree_view_record>::iterator it =
   1.808 +      node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it)
   1.809 +  {
   1.810 +    it->visible = true;
   1.811 +  }
   1.812 +  switch (p_data->node_coord_load_from)
   1.813 +  {
   1.814 +    case ImportData::ONE_MAP:
   1.815 +      for (std::vector<tree_view_record>::iterator it =
   1.816 +          node_tree_view_records.begin(); it !=
   1.817 +          node_tree_view_records.end(); ++it)
   1.818 +      {
   1.819 +        if (it->name == p_data->node_coord_one_map_name)
   1.820 +          it->visible = false;
   1.821 +      }
   1.822 +      break;
   1.823 +    case ImportData::TWO_MAPS:
   1.824 +      for (std::vector<tree_view_record>::iterator it =
   1.825 +          node_tree_view_records.begin(); it !=
   1.826 +          node_tree_view_records.end(); ++it)
   1.827 +      {
   1.828 +        if ((it->name == p_data->node_coord_two_maps_1_name) ||
   1.829 +            (it->name == p_data->node_coord_two_maps_2_name))
   1.830 +          it->visible = false;
   1.831 +      }
   1.832 +      break;
   1.833 +    case ImportData::DONT_READ:
   1.834 +      break;
   1.835 +  }
   1.836 +  refNodeMapStore->clear();
   1.837 +  for (std::vector<tree_view_record>::iterator it =
   1.838 +      node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it)
   1.839 +  {
   1.840 +    if (it->visible)
   1.841 +    {
   1.842 +      Gtk::TreeModel::Row row = *(refNodeMapStore->append());
   1.843 +      row[NodeMapColumns.colName] = it->name;
   1.844 +      row[NodeMapColumns.colReadAsNumeric] = it->numeric;
   1.845 +      row[NodeMapColumns.colReadAsString] = it->string;
   1.846 +    }
   1.847 +  }
   1.848 +}
   1.849 +
   1.850 +void FileImportDialog::onArcMapNumericToggled(const Glib::ustring& path)
   1.851 +{
   1.852 +  Gtk::TreeModel::iterator iter = refArcMapStore->get_iter(
   1.853 +      Gtk::TreeModel::Path(path));
   1.854 +  Gtk::TreeModel::Row row = *iter;
   1.855 +  std::vector<tree_view_record>::iterator it;
   1.856 +  for (it = arc_tree_view_records.begin();
   1.857 +      it != arc_tree_view_records.end(); ++it)
   1.858 +  {
   1.859 +    if (it->name == row[ArcMapColumns.colName]) break;
   1.860 +  }
   1.861 +  if (row[ArcMapColumns.colReadAsNumeric])
   1.862 +  {
   1.863 +    row[ArcMapColumns.colReadAsString] = false;
   1.864 +    it->string = false;
   1.865 +    it->numeric = true;
   1.866 +  }
   1.867 +}
   1.868 +
   1.869 +void FileImportDialog::onArcMapStringToggled(const Glib::ustring& path)
   1.870 +{
   1.871 +  Gtk::TreeModel::iterator iter = refArcMapStore->get_iter(
   1.872 +      Gtk::TreeModel::Path(path));
   1.873 +  Gtk::TreeModel::Row row = *iter;
   1.874 +  std::vector<tree_view_record>::iterator it;
   1.875 +  for (it = arc_tree_view_records.begin();
   1.876 +      it != arc_tree_view_records.end(); ++it)
   1.877 +  {
   1.878 +    if (it->name == row[ArcMapColumns.colName]) break;
   1.879 +  }
   1.880 +  if (row[ArcMapColumns.colReadAsString])
   1.881 +  {
   1.882 +    row[ArcMapColumns.colReadAsNumeric] = false;
   1.883 +    it->string = true;
   1.884 +    it->numeric = false;
   1.885 +  }
   1.886 +}
   1.887 +
   1.888 +void FileImportDialog::update_arc_tree_view()
   1.889 +{
   1.890 +  for (std::vector<tree_view_record>::iterator it =
   1.891 +      arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it)
   1.892 +  {
   1.893 +    it->visible = true;
   1.894 +  }
   1.895 +  switch (p_data->arrow_coord_load_from)
   1.896 +  {
   1.897 +    case ImportData::ONE_MAP:
   1.898 +      for (std::vector<tree_view_record>::iterator it =
   1.899 +          arc_tree_view_records.begin(); it !=
   1.900 +          arc_tree_view_records.end(); ++it)
   1.901 +      {
   1.902 +        if (it->name == p_data->arrow_coord_one_map_name)
   1.903 +          it->visible = false;
   1.904 +      }
   1.905 +      break;
   1.906 +    case ImportData::TWO_MAPS:
   1.907 +      for (std::vector<tree_view_record>::iterator it =
   1.908 +          arc_tree_view_records.begin(); it !=
   1.909 +          arc_tree_view_records.end(); ++it)
   1.910 +      {
   1.911 +        if ((it->name == p_data->arrow_coord_two_maps_1_name) ||
   1.912 +            (it->name == p_data->arrow_coord_two_maps_2_name))
   1.913 +          it->visible = false;
   1.914 +      }
   1.915 +      break;
   1.916 +    case ImportData::DONT_READ:
   1.917 +      break;
   1.918 +  }
   1.919 +  refArcMapStore->clear();
   1.920 +  for (std::vector<tree_view_record>::iterator it =
   1.921 +      arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it)
   1.922 +  {
   1.923 +    if (it->visible)
   1.924 +    {
   1.925 +      Gtk::TreeModel::Row row = *(refArcMapStore->append());
   1.926 +      row[ArcMapColumns.colName] = it->name;
   1.927 +      row[ArcMapColumns.colReadAsNumeric] = it->numeric;
   1.928 +      row[ArcMapColumns.colReadAsString] = it->string;
   1.929 +    }
   1.930 +  }
   1.931 +}