[1] | 1 | #include "file_import_dialog.h" |
---|
| 2 | #include <gtkmm/dialog.h> |
---|
| 3 | #include <gtkmm/stock.h> |
---|
| 4 | #include <gtkmm/notebook.h> |
---|
| 5 | #include <gtkmm/messagedialog.h> |
---|
| 6 | #include <gtkmm/frame.h> |
---|
| 7 | #include <iostream> |
---|
| 8 | |
---|
| 9 | FileImportDialog::FileImportDialog(ImportData* d) : |
---|
| 10 | p_data(d) |
---|
| 11 | { |
---|
| 12 | add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
---|
| 13 | add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); |
---|
| 14 | |
---|
| 15 | Gtk::VBox* pVBox = get_vbox(); |
---|
| 16 | |
---|
| 17 | Gtk::Notebook* nb = Gtk::manage(new Gtk::Notebook); |
---|
| 18 | pVBox->pack_start(*nb, Gtk::PACK_EXPAND_WIDGET); |
---|
| 19 | |
---|
| 20 | Gtk::VBox* vblueMaps = Gtk::manage(new Gtk::VBox(false, 18)); |
---|
| 21 | vblueMaps->set_border_width(12); |
---|
| 22 | |
---|
| 23 | Gtk::VBox* vbArcMaps = Gtk::manage(new Gtk::VBox(false, 18)); |
---|
| 24 | vbArcMaps->set_border_width(12); |
---|
| 25 | |
---|
| 26 | Gtk::VBox* vbSpecMaps = Gtk::manage(new Gtk::VBox(false, 18)); |
---|
| 27 | vbSpecMaps->set_border_width(12); |
---|
| 28 | |
---|
| 29 | nb->append_page(*vbSpecMaps, "Special Maps"); |
---|
| 30 | nb->append_page(*vblueMaps, "Node Maps"); |
---|
| 31 | nb->append_page(*vbArcMaps, "Arc Maps"); |
---|
| 32 | |
---|
| 33 | // child widgets of vbSpecMaps |
---|
| 34 | { |
---|
| 35 | Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6)); |
---|
| 36 | vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK); |
---|
| 37 | |
---|
| 38 | { |
---|
| 39 | Gtk::Label* label1 = |
---|
| 40 | Gtk::manage(new Gtk::Label("<b>Node Coordinates</b>")); |
---|
| 41 | label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); |
---|
| 42 | label1->set_use_markup(); |
---|
| 43 | box1->pack_start(*label1); |
---|
| 44 | |
---|
| 45 | Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); |
---|
| 46 | box1->pack_start(*box2); |
---|
| 47 | |
---|
| 48 | Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 49 | box2->pack_start(*fill1, Gtk::PACK_SHRINK); |
---|
| 50 | |
---|
| 51 | Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox); |
---|
| 52 | box2->pack_start(*box3); |
---|
| 53 | |
---|
| 54 | Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox); |
---|
| 55 | box3->pack_start(*box13); |
---|
| 56 | |
---|
| 57 | rblueCoordNone.set_label("None"); |
---|
| 58 | Gtk::RadioButtonGroup group = rblueCoordNone.get_group(); |
---|
| 59 | box13->pack_start(rblueCoordNone); |
---|
| 60 | |
---|
| 61 | Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox); |
---|
| 62 | box3->pack_start(*box4); |
---|
| 63 | |
---|
| 64 | rblueCoordOneMap.set_label("One Map"); |
---|
| 65 | rblueCoordOneMap.set_group(group); |
---|
| 66 | box4->pack_start(rblueCoordOneMap); |
---|
| 67 | |
---|
| 68 | Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox); |
---|
| 69 | box4->pack_start(*box5); |
---|
| 70 | |
---|
| 71 | Gtk::Label* fill2 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 72 | box5->pack_start(*fill2, Gtk::PACK_SHRINK); |
---|
| 73 | |
---|
| 74 | Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox); |
---|
| 75 | box5->pack_start(*box6); |
---|
| 76 | |
---|
| 77 | Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox); |
---|
| 78 | box6->pack_start(*box7); |
---|
| 79 | |
---|
| 80 | Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)")); |
---|
| 81 | box7->pack_start(*label2, Gtk::PACK_SHRINK, 4); |
---|
| 82 | |
---|
| 83 | box7->pack_start(cblueCoordOneMap, Gtk::PACK_EXPAND_WIDGET); |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox); |
---|
| 87 | box3->pack_start(*box8); |
---|
| 88 | |
---|
| 89 | rblueCoordTwoMaps.set_label("Two Maps"); |
---|
| 90 | rblueCoordTwoMaps.set_group(group); |
---|
| 91 | box8->pack_start(rblueCoordTwoMaps); |
---|
| 92 | |
---|
| 93 | Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox); |
---|
| 94 | box8->pack_start(*box9); |
---|
| 95 | |
---|
| 96 | Gtk::Label* fill3 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 97 | box9->pack_start(*fill3, Gtk::PACK_SHRINK); |
---|
| 98 | |
---|
| 99 | Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox); |
---|
| 100 | box9->pack_start(*box10); |
---|
| 101 | |
---|
| 102 | Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox); |
---|
| 103 | box10->pack_start(*box11); |
---|
| 104 | |
---|
| 105 | Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X")); |
---|
| 106 | box11->pack_start(*label3, Gtk::PACK_SHRINK, 4); |
---|
| 107 | |
---|
| 108 | box11->pack_start(cblueCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET); |
---|
| 109 | |
---|
| 110 | Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox); |
---|
| 111 | box10->pack_start(*box12); |
---|
| 112 | |
---|
| 113 | Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y")); |
---|
| 114 | box12->pack_start(*label4, Gtk::PACK_SHRINK, 4); |
---|
| 115 | |
---|
| 116 | box12->pack_start(cblueCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET); |
---|
| 117 | |
---|
| 118 | cblueCoordOneMap.signal_changed().connect( |
---|
| 119 | sigc::mem_fun(*this, &FileImportDialog::onNodeCoordOneMapChanged)); |
---|
| 120 | cblueCoordTwoMaps1.signal_changed().connect( |
---|
| 121 | sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps1Changed)); |
---|
| 122 | cblueCoordTwoMaps2.signal_changed().connect( |
---|
| 123 | sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps2Changed)); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | { |
---|
| 127 | Gtk::Label* label1 = |
---|
| 128 | Gtk::manage(new Gtk::Label("<b>Arrow Coordinates</b>")); |
---|
| 129 | label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); |
---|
| 130 | label1->set_use_markup(); |
---|
| 131 | box1->pack_start(*label1); |
---|
| 132 | |
---|
| 133 | Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); |
---|
| 134 | box1->pack_start(*box2); |
---|
| 135 | |
---|
| 136 | Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 137 | box2->pack_start(*fill1, Gtk::PACK_SHRINK); |
---|
| 138 | |
---|
| 139 | Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox); |
---|
| 140 | box2->pack_start(*box3); |
---|
| 141 | |
---|
| 142 | Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox); |
---|
| 143 | box3->pack_start(*box13); |
---|
| 144 | |
---|
| 145 | rbArrowCoordNone.set_label("None"); |
---|
| 146 | Gtk::RadioButtonGroup group = rbArrowCoordNone.get_group(); |
---|
| 147 | box13->pack_start(rbArrowCoordNone); |
---|
| 148 | |
---|
| 149 | Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox); |
---|
| 150 | box3->pack_start(*box4); |
---|
| 151 | |
---|
| 152 | rbArrowCoordOneMap.set_label("One Map"); |
---|
| 153 | rbArrowCoordOneMap.set_group(group); |
---|
| 154 | box4->pack_start(rbArrowCoordOneMap); |
---|
| 155 | |
---|
| 156 | Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox); |
---|
| 157 | box4->pack_start(*box5); |
---|
| 158 | |
---|
| 159 | Gtk::Label* fill2 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 160 | box5->pack_start(*fill2, Gtk::PACK_SHRINK); |
---|
| 161 | |
---|
| 162 | Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox); |
---|
| 163 | box5->pack_start(*box6); |
---|
| 164 | |
---|
| 165 | Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox); |
---|
| 166 | box6->pack_start(*box7); |
---|
| 167 | |
---|
| 168 | Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)")); |
---|
| 169 | box7->pack_start(*label2, Gtk::PACK_SHRINK, 4); |
---|
| 170 | |
---|
| 171 | box7->pack_start(cbArrowCoordOneMap, Gtk::PACK_EXPAND_WIDGET); |
---|
| 172 | |
---|
| 173 | |
---|
| 174 | Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox); |
---|
| 175 | box3->pack_start(*box8); |
---|
| 176 | |
---|
| 177 | rbArrowCoordTwoMaps.set_label("Two Maps"); |
---|
| 178 | rbArrowCoordTwoMaps.set_group(group); |
---|
| 179 | box8->pack_start(rbArrowCoordTwoMaps); |
---|
| 180 | |
---|
| 181 | Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox); |
---|
| 182 | box8->pack_start(*box9); |
---|
| 183 | |
---|
| 184 | Gtk::Label* fill3 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 185 | box9->pack_start(*fill3, Gtk::PACK_SHRINK); |
---|
| 186 | |
---|
| 187 | Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox); |
---|
| 188 | box9->pack_start(*box10); |
---|
| 189 | |
---|
| 190 | Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox); |
---|
| 191 | box10->pack_start(*box11); |
---|
| 192 | |
---|
| 193 | Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X")); |
---|
| 194 | box11->pack_start(*label3, Gtk::PACK_SHRINK, 4); |
---|
| 195 | |
---|
| 196 | box11->pack_start(cbArrowCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET); |
---|
| 197 | |
---|
| 198 | Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox); |
---|
| 199 | box10->pack_start(*box12); |
---|
| 200 | |
---|
| 201 | Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y")); |
---|
| 202 | box12->pack_start(*label4, Gtk::PACK_SHRINK, 4); |
---|
| 203 | |
---|
| 204 | box12->pack_start(cbArrowCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET); |
---|
| 205 | |
---|
| 206 | cbArrowCoordOneMap.signal_changed().connect( |
---|
| 207 | sigc::mem_fun(*this, &FileImportDialog::onArrowCoordOneMapChanged)); |
---|
| 208 | cbArrowCoordTwoMaps1.signal_changed().connect( |
---|
| 209 | sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps1Changed)); |
---|
| 210 | cbArrowCoordTwoMaps2.signal_changed().connect( |
---|
| 211 | sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps2Changed)); |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | // child widgets of vblueMaps |
---|
| 216 | { |
---|
| 217 | Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6)); |
---|
| 218 | vblueMaps->pack_start(*box1, Gtk::PACK_SHRINK); |
---|
| 219 | |
---|
| 220 | Gtk::Label* label1 = |
---|
| 221 | Gtk::manage(new Gtk::Label("<b>Element type</b>")); |
---|
| 222 | label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); |
---|
| 223 | label1->set_use_markup(); |
---|
| 224 | box1->pack_start(*label1, Gtk::PACK_SHRINK); |
---|
| 225 | |
---|
| 226 | Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); |
---|
| 227 | box1->pack_start(*box2, Gtk::PACK_SHRINK); |
---|
| 228 | |
---|
| 229 | Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 230 | box2->pack_start(*fill1, Gtk::PACK_SHRINK); |
---|
| 231 | |
---|
| 232 | Gtk::Frame* frame = Gtk::manage(new Gtk::Frame); |
---|
| 233 | box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET); |
---|
| 234 | |
---|
| 235 | Gtk::ScrolledWindow* swNodeMaps = Gtk::manage(new Gtk::ScrolledWindow); |
---|
| 236 | frame->add(*swNodeMaps); |
---|
| 237 | |
---|
| 238 | swNodeMaps->add(twNodeMaps); |
---|
| 239 | |
---|
| 240 | refNodeMapStore = Gtk::ListStore::create(NodeMapColumns); |
---|
| 241 | |
---|
| 242 | for (std::vector<std::string>::const_iterator it = |
---|
| 243 | p_data->node_map_names.begin(); it != p_data->node_map_names.end(); |
---|
| 244 | ++it) |
---|
| 245 | { |
---|
| 246 | node_tree_view_records.push_back( |
---|
| 247 | tree_view_record(*it, false, false, true)); |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | twNodeMaps.set_model(refNodeMapStore); |
---|
| 251 | twNodeMaps.append_column("Name", NodeMapColumns.colName); |
---|
| 252 | { |
---|
| 253 | int col = twNodeMaps.append_column_editable("Numeric", |
---|
| 254 | NodeMapColumns.colReadAsNumeric); |
---|
| 255 | Gtk::CellRendererToggle* pRenderer = |
---|
| 256 | static_cast<Gtk::CellRendererToggle*>( |
---|
| 257 | twNodeMaps.get_column_cell_renderer(col-1)); |
---|
| 258 | pRenderer->signal_toggled().connect( |
---|
| 259 | sigc::mem_fun(*this, &FileImportDialog::onNodeMapNumericToggled)); |
---|
| 260 | } |
---|
| 261 | { |
---|
| 262 | int col = twNodeMaps.append_column_editable("String", |
---|
| 263 | NodeMapColumns.colReadAsString); |
---|
| 264 | Gtk::CellRendererToggle* pRenderer = |
---|
| 265 | static_cast<Gtk::CellRendererToggle*>( |
---|
| 266 | twNodeMaps.get_column_cell_renderer(col-1)); |
---|
| 267 | pRenderer->signal_toggled().connect( |
---|
| 268 | sigc::mem_fun(*this, &FileImportDialog::onNodeMapStringToggled)); |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | swNodeMaps->set_size_request(-1, 200); |
---|
| 272 | swNodeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | // child widgets of vbArcMaps |
---|
| 276 | { |
---|
| 277 | Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6)); |
---|
| 278 | vbArcMaps->pack_start(*box1, Gtk::PACK_SHRINK); |
---|
| 279 | |
---|
| 280 | Gtk::Label* label1 = |
---|
| 281 | Gtk::manage(new Gtk::Label("<b>Element type</b>")); |
---|
| 282 | label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); |
---|
| 283 | label1->set_use_markup(); |
---|
| 284 | box1->pack_start(*label1, Gtk::PACK_SHRINK); |
---|
| 285 | |
---|
| 286 | Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); |
---|
| 287 | box1->pack_start(*box2, Gtk::PACK_SHRINK); |
---|
| 288 | |
---|
| 289 | Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); |
---|
| 290 | box2->pack_start(*fill1, Gtk::PACK_SHRINK); |
---|
| 291 | |
---|
| 292 | Gtk::Frame* frame = Gtk::manage(new Gtk::Frame); |
---|
| 293 | box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET); |
---|
| 294 | |
---|
| 295 | Gtk::ScrolledWindow* swArcMaps = Gtk::manage(new Gtk::ScrolledWindow); |
---|
| 296 | frame->add(*swArcMaps); |
---|
| 297 | |
---|
| 298 | swArcMaps->add(twArcMaps); |
---|
| 299 | |
---|
| 300 | refArcMapStore = Gtk::ListStore::create(ArcMapColumns); |
---|
| 301 | |
---|
| 302 | for (std::vector<std::string>::const_iterator it = |
---|
| 303 | p_data->arc_map_names.begin(); it != p_data->arc_map_names.end(); |
---|
| 304 | ++it) |
---|
| 305 | { |
---|
| 306 | arc_tree_view_records.push_back( |
---|
| 307 | tree_view_record(*it, false, false, true)); |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | twArcMaps.set_model(refArcMapStore); |
---|
| 311 | twArcMaps.append_column("Name", ArcMapColumns.colName); |
---|
| 312 | { |
---|
| 313 | int col = twArcMaps.append_column_editable("Numeric", |
---|
| 314 | ArcMapColumns.colReadAsNumeric); |
---|
| 315 | Gtk::CellRendererToggle* pRenderer = |
---|
| 316 | static_cast<Gtk::CellRendererToggle*>( |
---|
| 317 | twArcMaps.get_column_cell_renderer(col-1)); |
---|
| 318 | pRenderer->signal_toggled().connect( |
---|
| 319 | sigc::mem_fun(*this, &FileImportDialog::onArcMapNumericToggled)); |
---|
| 320 | } |
---|
| 321 | { |
---|
| 322 | int col = twArcMaps.append_column_editable("String", |
---|
| 323 | ArcMapColumns.colReadAsString); |
---|
| 324 | Gtk::CellRendererToggle* pRenderer = |
---|
| 325 | static_cast<Gtk::CellRendererToggle*>( |
---|
| 326 | twArcMaps.get_column_cell_renderer(col-1)); |
---|
| 327 | pRenderer->signal_toggled().connect( |
---|
| 328 | sigc::mem_fun(*this, &FileImportDialog::onArcMapStringToggled)); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | swArcMaps->set_size_request(-1, 200); |
---|
| 332 | swArcMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | // fill in the ComboBoxes |
---|
| 336 | typedef std::vector<std::string> StrVec; |
---|
| 337 | for (StrVec::const_iterator it = p_data->node_map_names.begin(); |
---|
| 338 | it != p_data->node_map_names.end(); ++it) |
---|
| 339 | { |
---|
| 340 | cblueCoordTwoMaps1.append_text(*it); |
---|
| 341 | cblueCoordTwoMaps2.append_text(*it); |
---|
| 342 | } |
---|
| 343 | for (StrVec::const_iterator it = p_data->arc_map_names.begin(); |
---|
| 344 | it != p_data->arc_map_names.end(); ++it) |
---|
| 345 | { |
---|
| 346 | cbArrowCoordTwoMaps1.append_text(*it); |
---|
| 347 | cbArrowCoordTwoMaps2.append_text(*it); |
---|
| 348 | } |
---|
| 349 | for (StrVec::const_iterator it = p_data->xy_node_map_names.begin(); |
---|
| 350 | it != p_data->xy_node_map_names.end(); ++it) |
---|
| 351 | { |
---|
| 352 | cblueCoordOneMap.append_text(*it); |
---|
| 353 | } |
---|
| 354 | for (StrVec::const_iterator it = p_data->xy_arc_map_names.begin(); |
---|
| 355 | it != p_data->xy_arc_map_names.end(); ++it) |
---|
| 356 | { |
---|
| 357 | cbArrowCoordOneMap.append_text(*it); |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | if (p_data->isXYNodeMap("coord")) |
---|
| 361 | { |
---|
| 362 | cblueCoordOneMap.set_active_text("coord"); |
---|
| 363 | } |
---|
| 364 | else if (p_data->isXYNodeMap("coords")) |
---|
| 365 | { |
---|
| 366 | cblueCoordOneMap.set_active_text("coords"); |
---|
| 367 | } |
---|
| 368 | else if (p_data->isNodeMap("coord_x") && |
---|
| 369 | p_data->isNodeMap("coord_y")) |
---|
| 370 | { |
---|
| 371 | cblueCoordTwoMaps1.set_active_text("coord_x"); |
---|
| 372 | cblueCoordTwoMaps2.set_active_text("coord_y"); |
---|
| 373 | } |
---|
| 374 | else if (p_data->isNodeMap("coords_x") && |
---|
| 375 | p_data->isNodeMap("coords_y")) |
---|
| 376 | { |
---|
| 377 | cblueCoordTwoMaps1.set_active_text("coords_x"); |
---|
| 378 | cblueCoordTwoMaps2.set_active_text("coords_y"); |
---|
| 379 | } |
---|
| 380 | else if (p_data->isNodeMap("x") && |
---|
| 381 | p_data->isNodeMap("y")) |
---|
| 382 | { |
---|
| 383 | cblueCoordTwoMaps1.set_active_text("x"); |
---|
| 384 | cblueCoordTwoMaps2.set_active_text("y"); |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | if (p_data->isXYArcMap("arrow")) |
---|
| 388 | { |
---|
| 389 | cbArrowCoordOneMap.set_active_text("arrow"); |
---|
| 390 | } |
---|
| 391 | else if (p_data->isXYArcMap("arrows")) |
---|
| 392 | { |
---|
| 393 | cbArrowCoordOneMap.set_active_text("arrows"); |
---|
| 394 | } |
---|
| 395 | else if (p_data->isXYArcMap("midpoint")) |
---|
| 396 | { |
---|
| 397 | cbArrowCoordOneMap.set_active_text("midpoint"); |
---|
| 398 | } |
---|
| 399 | else if (p_data->isXYArcMap("midpoints")) |
---|
| 400 | { |
---|
| 401 | cbArrowCoordOneMap.set_active_text("midpoints"); |
---|
| 402 | } |
---|
| 403 | else if (p_data->isXYArcMap("mid")) |
---|
| 404 | { |
---|
| 405 | cbArrowCoordOneMap.set_active_text("mid"); |
---|
| 406 | } |
---|
| 407 | else if (p_data->isXYArcMap("mids")) |
---|
| 408 | { |
---|
| 409 | cbArrowCoordOneMap.set_active_text("mids"); |
---|
| 410 | } |
---|
| 411 | else if (p_data->isArcMap("arrow_x") && |
---|
| 412 | p_data->isArcMap("arrow_y")) |
---|
| 413 | { |
---|
| 414 | cbArrowCoordTwoMaps1.set_active_text("arrow_x"); |
---|
| 415 | cbArrowCoordTwoMaps2.set_active_text("arrow_y"); |
---|
| 416 | } |
---|
| 417 | else if (p_data->isArcMap("arrows_x") && |
---|
| 418 | p_data->isArcMap("arrows_y")) |
---|
| 419 | { |
---|
| 420 | cbArrowCoordTwoMaps1.set_active_text("arrows_x"); |
---|
| 421 | cbArrowCoordTwoMaps2.set_active_text("arrows_y"); |
---|
| 422 | } |
---|
| 423 | else if (p_data->isArcMap("midpoint_x") && |
---|
| 424 | p_data->isArcMap("midpoint_y")) |
---|
| 425 | { |
---|
| 426 | cbArrowCoordTwoMaps1.set_active_text("midpoint_x"); |
---|
| 427 | cbArrowCoordTwoMaps2.set_active_text("midpoint_y"); |
---|
| 428 | } |
---|
| 429 | else if (p_data->isArcMap("midpoints_x") && |
---|
| 430 | p_data->isArcMap("midpoints_y")) |
---|
| 431 | { |
---|
| 432 | cbArrowCoordTwoMaps1.set_active_text("midpoints_x"); |
---|
| 433 | cbArrowCoordTwoMaps2.set_active_text("midpoints_y"); |
---|
| 434 | } |
---|
| 435 | else if (p_data->isArcMap("mid_x") && |
---|
| 436 | p_data->isArcMap("mid_y")) |
---|
| 437 | { |
---|
| 438 | cbArrowCoordTwoMaps1.set_active_text("mid_x"); |
---|
| 439 | cbArrowCoordTwoMaps2.set_active_text("mid_y"); |
---|
| 440 | } |
---|
| 441 | else if (p_data->isArcMap("mids_x") && |
---|
| 442 | p_data->isArcMap("mids_y")) |
---|
| 443 | { |
---|
| 444 | cbArrowCoordTwoMaps1.set_active_text("mids_x"); |
---|
| 445 | cbArrowCoordTwoMaps2.set_active_text("mids_y"); |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | { |
---|
| 449 | if (cblueCoordOneMap.get_active_text() != "") |
---|
| 450 | rblueCoordOneMap.set_active(); |
---|
| 451 | else if (cblueCoordTwoMaps1.get_active_text() != "") |
---|
| 452 | rblueCoordTwoMaps.set_active(); |
---|
| 453 | else |
---|
| 454 | rblueCoordNone.set_active(); |
---|
| 455 | |
---|
| 456 | if (cbArrowCoordOneMap.get_active_text() != "") |
---|
| 457 | rbArrowCoordOneMap.set_active(); |
---|
| 458 | else if (cbArrowCoordTwoMaps1.get_active_text() != "") |
---|
| 459 | rbArrowCoordTwoMaps.set_active(); |
---|
| 460 | else |
---|
| 461 | rbArrowCoordNone.set_active(); |
---|
| 462 | |
---|
| 463 | onNodeCoordMapNumToggled(); |
---|
| 464 | onArrowCoordMapNumToggled(); |
---|
| 465 | |
---|
| 466 | rblueCoordOneMap.signal_toggled().connect( |
---|
| 467 | sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled)); |
---|
| 468 | rblueCoordTwoMaps.signal_toggled().connect( |
---|
| 469 | sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled)); |
---|
| 470 | rbArrowCoordOneMap.signal_toggled().connect( |
---|
| 471 | sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled)); |
---|
| 472 | rbArrowCoordTwoMaps.signal_toggled().connect( |
---|
| 473 | sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled)); |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | signal_response().connect( |
---|
| 477 | sigc::mem_fun(*this, &FileImportDialog::onResponse)); |
---|
| 478 | |
---|
| 479 | update_node_tree_view(); |
---|
| 480 | update_arc_tree_view(); |
---|
| 481 | |
---|
| 482 | show_all_children(); |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | void FileImportDialog::onNodeCoordMapNumToggled() |
---|
| 486 | { |
---|
| 487 | if (rblueCoordOneMap.get_active()) |
---|
| 488 | { |
---|
| 489 | cblueCoordOneMap.get_parent()->set_sensitive(true); |
---|
| 490 | cblueCoordTwoMaps1.get_parent()->set_sensitive(false); |
---|
| 491 | cblueCoordTwoMaps2.get_parent()->set_sensitive(false); |
---|
| 492 | |
---|
| 493 | p_data->node_coord_load_from = ImportData::ONE_MAP; |
---|
| 494 | } |
---|
| 495 | else if (rblueCoordTwoMaps.get_active()) |
---|
| 496 | { |
---|
| 497 | cblueCoordOneMap.get_parent()->set_sensitive(false); |
---|
| 498 | cblueCoordTwoMaps1.get_parent()->set_sensitive(true); |
---|
| 499 | cblueCoordTwoMaps2.get_parent()->set_sensitive(true); |
---|
| 500 | |
---|
| 501 | p_data->node_coord_load_from = ImportData::TWO_MAPS; |
---|
| 502 | } |
---|
| 503 | else if (rblueCoordNone.get_active()) |
---|
| 504 | { |
---|
| 505 | cblueCoordOneMap.get_parent()->set_sensitive(false); |
---|
| 506 | cblueCoordTwoMaps1.get_parent()->set_sensitive(false); |
---|
| 507 | cblueCoordTwoMaps2.get_parent()->set_sensitive(false); |
---|
| 508 | |
---|
| 509 | p_data->node_coord_load_from = ImportData::DONT_READ; |
---|
| 510 | } |
---|
| 511 | update_node_tree_view(); |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | void FileImportDialog::onArrowCoordMapNumToggled() |
---|
| 515 | { |
---|
| 516 | if (rbArrowCoordOneMap.get_active()) |
---|
| 517 | { |
---|
| 518 | cbArrowCoordOneMap.get_parent()->set_sensitive(true); |
---|
| 519 | cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false); |
---|
| 520 | cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false); |
---|
| 521 | |
---|
| 522 | p_data->arrow_coord_load_from = ImportData::ONE_MAP; |
---|
| 523 | } |
---|
| 524 | else if (rbArrowCoordTwoMaps.get_active()) |
---|
| 525 | { |
---|
| 526 | cbArrowCoordOneMap.get_parent()->set_sensitive(false); |
---|
| 527 | cbArrowCoordTwoMaps1.get_parent()->set_sensitive(true); |
---|
| 528 | cbArrowCoordTwoMaps2.get_parent()->set_sensitive(true); |
---|
| 529 | |
---|
| 530 | p_data->arrow_coord_load_from = ImportData::TWO_MAPS; |
---|
| 531 | } |
---|
| 532 | else if (rbArrowCoordNone.get_active()) |
---|
| 533 | { |
---|
| 534 | cbArrowCoordOneMap.get_parent()->set_sensitive(false); |
---|
| 535 | cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false); |
---|
| 536 | cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false); |
---|
| 537 | |
---|
| 538 | p_data->arrow_coord_load_from = ImportData::DONT_READ; |
---|
| 539 | } |
---|
| 540 | update_arc_tree_view(); |
---|
| 541 | } |
---|
| 542 | |
---|
| 543 | FileImportDialog::~FileImportDialog() |
---|
| 544 | { |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | void FileImportDialog::onResponse(int id) |
---|
| 548 | { |
---|
| 549 | if (id == Gtk::RESPONSE_OK) |
---|
| 550 | { |
---|
| 551 | if ((rblueCoordOneMap.get_active() && |
---|
| 552 | cblueCoordOneMap.get_active_text() == "") || |
---|
| 553 | (rblueCoordTwoMaps.get_active() && |
---|
| 554 | (cblueCoordTwoMaps1.get_active_text() == "" || |
---|
| 555 | cblueCoordTwoMaps2.get_active_text() == ""))) |
---|
| 556 | { |
---|
| 557 | Gtk::MessageDialog mdialog("No node map selected.", |
---|
| 558 | false, Gtk::MESSAGE_ERROR); |
---|
| 559 | mdialog.run(); |
---|
| 560 | return; |
---|
| 561 | } |
---|
| 562 | else if (rblueCoordTwoMaps.get_active() && |
---|
| 563 | cblueCoordTwoMaps1.get_active_text() == |
---|
| 564 | cblueCoordTwoMaps2.get_active_text()) |
---|
| 565 | { |
---|
| 566 | Gtk::MessageDialog mdialog( |
---|
| 567 | "Same node map selected for both coordinates.", |
---|
| 568 | false, Gtk::MESSAGE_ERROR); |
---|
| 569 | mdialog.run(); |
---|
| 570 | return; |
---|
| 571 | } |
---|
| 572 | if ((rbArrowCoordOneMap.get_active() && |
---|
| 573 | cbArrowCoordOneMap.get_active_text() == "") || |
---|
| 574 | (rbArrowCoordTwoMaps.get_active() && |
---|
| 575 | (cbArrowCoordTwoMaps1.get_active_text() == "" || |
---|
| 576 | cbArrowCoordTwoMaps2.get_active_text() == ""))) |
---|
| 577 | { |
---|
| 578 | Gtk::MessageDialog mdialog("No arc map selected.", |
---|
| 579 | false, Gtk::MESSAGE_ERROR); |
---|
| 580 | mdialog.run(); |
---|
| 581 | return; |
---|
| 582 | } |
---|
| 583 | else if (rbArrowCoordTwoMaps.get_active() && |
---|
| 584 | cbArrowCoordTwoMaps1.get_active_text() == |
---|
| 585 | cbArrowCoordTwoMaps2.get_active_text()) |
---|
| 586 | { |
---|
| 587 | Gtk::MessageDialog mdialog( |
---|
| 588 | "Same arc map selected for both coordinates.", |
---|
| 589 | false, Gtk::MESSAGE_ERROR); |
---|
| 590 | mdialog.run(); |
---|
| 591 | return; |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | for (std::vector<tree_view_record>::const_iterator it = |
---|
| 595 | node_tree_view_records.begin(); it != node_tree_view_records.end(); |
---|
| 596 | ++it) |
---|
| 597 | { |
---|
| 598 | if (it->visible) |
---|
| 599 | { |
---|
| 600 | if (it->numeric) |
---|
| 601 | p_data->numeric_node_map_names.push_back(it->name); |
---|
| 602 | if (it->string) |
---|
| 603 | p_data->string_node_map_names.push_back(it->name); |
---|
| 604 | } |
---|
| 605 | } |
---|
| 606 | |
---|
| 607 | for (std::vector<tree_view_record>::const_iterator it = |
---|
| 608 | arc_tree_view_records.begin(); it != arc_tree_view_records.end(); |
---|
| 609 | ++it) |
---|
| 610 | { |
---|
| 611 | if (it->visible) |
---|
| 612 | { |
---|
| 613 | if (it->numeric) |
---|
| 614 | p_data->numeric_arc_map_names.push_back(it->name); |
---|
| 615 | if (it->string) |
---|
| 616 | p_data->string_arc_map_names.push_back(it->name); |
---|
| 617 | } |
---|
| 618 | } |
---|
| 619 | } |
---|
| 620 | } |
---|
| 621 | |
---|
| 622 | FileImportDialog::ImportData::ImportData( |
---|
| 623 | const std::vector<std::string>& _node_map_names, |
---|
| 624 | const std::vector<std::string>& _arc_map_names) : |
---|
| 625 | node_map_names(_node_map_names), |
---|
| 626 | arc_map_names(_arc_map_names) |
---|
| 627 | { |
---|
| 628 | typedef std::vector<std::string> StrVec; |
---|
| 629 | { |
---|
| 630 | StrVec xMaps; |
---|
| 631 | StrVec yMaps; |
---|
| 632 | // collect map names ending with ":x" and ":y" |
---|
| 633 | for (StrVec::const_iterator it = node_map_names.begin(); |
---|
| 634 | it != node_map_names.end(); ++it) |
---|
| 635 | { |
---|
| 636 | if ((it->length() >= 3) && |
---|
| 637 | (it->substr(it->length()-2, it->length()) == ":x")) |
---|
| 638 | { |
---|
| 639 | xMaps.push_back(it->substr(0, it->length()-2)); |
---|
| 640 | } |
---|
| 641 | if ((it->length() >= 3) && |
---|
| 642 | (it->substr(it->length()-2, it->length()) == ":y")) |
---|
| 643 | { |
---|
| 644 | yMaps.push_back(it->substr(0, it->length()-2)); |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | |
---|
| 648 | for (StrVec::const_iterator it1 = xMaps.begin(); |
---|
| 649 | it1 != xMaps.end(); ++it1) |
---|
| 650 | { |
---|
| 651 | for (StrVec::const_iterator it2 = yMaps.begin(); |
---|
| 652 | it2 != yMaps.end(); ++it2) |
---|
| 653 | { |
---|
| 654 | if (*it1 == *it2) xy_node_map_names.push_back(*it1); |
---|
| 655 | } |
---|
| 656 | } |
---|
| 657 | } |
---|
| 658 | { |
---|
| 659 | StrVec xMaps; |
---|
| 660 | StrVec yMaps; |
---|
| 661 | // collect map names ending with ":x" and ":y" |
---|
| 662 | for (StrVec::const_iterator it = arc_map_names.begin(); |
---|
| 663 | it != arc_map_names.end(); ++it) |
---|
| 664 | { |
---|
| 665 | if ((it->length() >= 3) && |
---|
| 666 | (it->substr(it->length()-2, it->length()) == ":x")) |
---|
| 667 | { |
---|
| 668 | xMaps.push_back(it->substr(0, it->length()-2)); |
---|
| 669 | } |
---|
| 670 | if ((it->length() >= 3) && |
---|
| 671 | (it->substr(it->length()-2, it->length()) == ":y")) |
---|
| 672 | { |
---|
| 673 | yMaps.push_back(it->substr(0, it->length()-2)); |
---|
| 674 | } |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | for (StrVec::const_iterator it1 = xMaps.begin(); |
---|
| 678 | it1 != xMaps.end(); ++it1) |
---|
| 679 | { |
---|
| 680 | for (StrVec::const_iterator it2 = yMaps.begin(); |
---|
| 681 | it2 != yMaps.end(); ++it2) |
---|
| 682 | { |
---|
| 683 | if (*it1 == *it2) xy_arc_map_names.push_back(*it1); |
---|
| 684 | } |
---|
| 685 | } |
---|
| 686 | } |
---|
| 687 | } |
---|
| 688 | |
---|
| 689 | FileImportDialog::ImportData::~ImportData() |
---|
| 690 | { |
---|
| 691 | } |
---|
| 692 | |
---|
| 693 | bool FileImportDialog::ImportData::isXYNodeMap(const std::string& name) |
---|
| 694 | { |
---|
| 695 | if (isNodeMap(name + ":x") && isNodeMap(name + ":y")) return true; |
---|
| 696 | return false; |
---|
| 697 | } |
---|
| 698 | |
---|
| 699 | bool FileImportDialog::ImportData::isXYArcMap(const std::string& name) |
---|
| 700 | { |
---|
| 701 | if (isArcMap(name + ":x") && isArcMap(name + ":y")) return true; |
---|
| 702 | return false; |
---|
| 703 | } |
---|
| 704 | |
---|
| 705 | bool FileImportDialog::ImportData::isNodeMap(const std::string& name) |
---|
| 706 | { |
---|
| 707 | if (contains(node_map_names, name)) return true; |
---|
| 708 | return false; |
---|
| 709 | } |
---|
| 710 | |
---|
| 711 | bool FileImportDialog::ImportData::isArcMap(const std::string& name) |
---|
| 712 | { |
---|
| 713 | if (contains(arc_map_names, name)) return true; |
---|
| 714 | return false; |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | bool FileImportDialog::ImportData::contains(const std::vector<std::string>& vec, |
---|
| 718 | const std::string& str) |
---|
| 719 | { |
---|
| 720 | for (std::vector<std::string>::const_iterator it = vec.begin(); |
---|
| 721 | it != vec.end(); ++it) |
---|
| 722 | { |
---|
| 723 | if (*it == str) return true; |
---|
| 724 | } |
---|
| 725 | return false; |
---|
| 726 | } |
---|
| 727 | |
---|
| 728 | void FileImportDialog::onNodeCoordOneMapChanged() |
---|
| 729 | { |
---|
| 730 | p_data->node_coord_one_map_name = cblueCoordOneMap.get_active_text(); |
---|
| 731 | update_node_tree_view(); |
---|
| 732 | } |
---|
| 733 | |
---|
| 734 | void FileImportDialog::onNodeCoordTwoMaps1Changed() |
---|
| 735 | { |
---|
| 736 | p_data->node_coord_two_maps_1_name = cblueCoordTwoMaps1.get_active_text(); |
---|
| 737 | update_node_tree_view(); |
---|
| 738 | } |
---|
| 739 | |
---|
| 740 | void FileImportDialog::onNodeCoordTwoMaps2Changed() |
---|
| 741 | { |
---|
| 742 | p_data->node_coord_two_maps_2_name = cblueCoordTwoMaps2.get_active_text(); |
---|
| 743 | update_node_tree_view(); |
---|
| 744 | } |
---|
| 745 | |
---|
| 746 | void FileImportDialog::onArrowCoordOneMapChanged() |
---|
| 747 | { |
---|
| 748 | p_data->arrow_coord_one_map_name = cbArrowCoordOneMap.get_active_text(); |
---|
| 749 | update_arc_tree_view(); |
---|
| 750 | } |
---|
| 751 | |
---|
| 752 | void FileImportDialog::onArrowCoordTwoMaps1Changed() |
---|
| 753 | { |
---|
| 754 | p_data->arrow_coord_two_maps_1_name = cbArrowCoordTwoMaps1.get_active_text(); |
---|
| 755 | update_arc_tree_view(); |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | void FileImportDialog::onArrowCoordTwoMaps2Changed() |
---|
| 759 | { |
---|
| 760 | p_data->arrow_coord_two_maps_2_name = cbArrowCoordTwoMaps2.get_active_text(); |
---|
| 761 | update_arc_tree_view(); |
---|
| 762 | } |
---|
| 763 | |
---|
| 764 | void FileImportDialog::onNodeMapNumericToggled(const Glib::ustring& path) |
---|
| 765 | { |
---|
| 766 | Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter( |
---|
| 767 | Gtk::TreeModel::Path(path)); |
---|
| 768 | Gtk::TreeModel::Row row = *iter; |
---|
| 769 | std::vector<tree_view_record>::iterator it; |
---|
| 770 | for (it = node_tree_view_records.begin(); |
---|
| 771 | it != node_tree_view_records.end(); ++it) |
---|
| 772 | { |
---|
| 773 | if (it->name == row[NodeMapColumns.colName]) break; |
---|
| 774 | } |
---|
| 775 | if (row[NodeMapColumns.colReadAsNumeric]) |
---|
| 776 | { |
---|
| 777 | row[NodeMapColumns.colReadAsString] = false; |
---|
| 778 | it->string = false; |
---|
| 779 | it->numeric = true; |
---|
| 780 | } |
---|
| 781 | } |
---|
| 782 | |
---|
| 783 | void FileImportDialog::onNodeMapStringToggled(const Glib::ustring& path) |
---|
| 784 | { |
---|
| 785 | Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter( |
---|
| 786 | Gtk::TreeModel::Path(path)); |
---|
| 787 | Gtk::TreeModel::Row row = *iter; |
---|
| 788 | std::vector<tree_view_record>::iterator it; |
---|
| 789 | for (it = node_tree_view_records.begin(); |
---|
| 790 | it != node_tree_view_records.end(); ++it) |
---|
| 791 | { |
---|
| 792 | if (it->name == row[NodeMapColumns.colName]) break; |
---|
| 793 | } |
---|
| 794 | if (row[NodeMapColumns.colReadAsString]) |
---|
| 795 | { |
---|
| 796 | row[NodeMapColumns.colReadAsNumeric] = false; |
---|
| 797 | it->string = true; |
---|
| 798 | it->numeric = false; |
---|
| 799 | } |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | void FileImportDialog::update_node_tree_view() |
---|
| 803 | { |
---|
| 804 | for (std::vector<tree_view_record>::iterator it = |
---|
| 805 | node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it) |
---|
| 806 | { |
---|
| 807 | it->visible = true; |
---|
| 808 | } |
---|
| 809 | switch (p_data->node_coord_load_from) |
---|
| 810 | { |
---|
| 811 | case ImportData::ONE_MAP: |
---|
| 812 | for (std::vector<tree_view_record>::iterator it = |
---|
| 813 | node_tree_view_records.begin(); it != |
---|
| 814 | node_tree_view_records.end(); ++it) |
---|
| 815 | { |
---|
| 816 | if (it->name == p_data->node_coord_one_map_name) |
---|
| 817 | it->visible = false; |
---|
| 818 | } |
---|
| 819 | break; |
---|
| 820 | case ImportData::TWO_MAPS: |
---|
| 821 | for (std::vector<tree_view_record>::iterator it = |
---|
| 822 | node_tree_view_records.begin(); it != |
---|
| 823 | node_tree_view_records.end(); ++it) |
---|
| 824 | { |
---|
| 825 | if ((it->name == p_data->node_coord_two_maps_1_name) || |
---|
| 826 | (it->name == p_data->node_coord_two_maps_2_name)) |
---|
| 827 | it->visible = false; |
---|
| 828 | } |
---|
| 829 | break; |
---|
| 830 | case ImportData::DONT_READ: |
---|
| 831 | break; |
---|
| 832 | } |
---|
| 833 | refNodeMapStore->clear(); |
---|
| 834 | for (std::vector<tree_view_record>::iterator it = |
---|
| 835 | node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it) |
---|
| 836 | { |
---|
| 837 | if (it->visible) |
---|
| 838 | { |
---|
| 839 | Gtk::TreeModel::Row row = *(refNodeMapStore->append()); |
---|
| 840 | row[NodeMapColumns.colName] = it->name; |
---|
| 841 | row[NodeMapColumns.colReadAsNumeric] = it->numeric; |
---|
| 842 | row[NodeMapColumns.colReadAsString] = it->string; |
---|
| 843 | } |
---|
| 844 | } |
---|
| 845 | } |
---|
| 846 | |
---|
| 847 | void FileImportDialog::onArcMapNumericToggled(const Glib::ustring& path) |
---|
| 848 | { |
---|
| 849 | Gtk::TreeModel::iterator iter = refArcMapStore->get_iter( |
---|
| 850 | Gtk::TreeModel::Path(path)); |
---|
| 851 | Gtk::TreeModel::Row row = *iter; |
---|
| 852 | std::vector<tree_view_record>::iterator it; |
---|
| 853 | for (it = arc_tree_view_records.begin(); |
---|
| 854 | it != arc_tree_view_records.end(); ++it) |
---|
| 855 | { |
---|
| 856 | if (it->name == row[ArcMapColumns.colName]) break; |
---|
| 857 | } |
---|
| 858 | if (row[ArcMapColumns.colReadAsNumeric]) |
---|
| 859 | { |
---|
| 860 | row[ArcMapColumns.colReadAsString] = false; |
---|
| 861 | it->string = false; |
---|
| 862 | it->numeric = true; |
---|
| 863 | } |
---|
| 864 | } |
---|
| 865 | |
---|
| 866 | void FileImportDialog::onArcMapStringToggled(const Glib::ustring& path) |
---|
| 867 | { |
---|
| 868 | Gtk::TreeModel::iterator iter = refArcMapStore->get_iter( |
---|
| 869 | Gtk::TreeModel::Path(path)); |
---|
| 870 | Gtk::TreeModel::Row row = *iter; |
---|
| 871 | std::vector<tree_view_record>::iterator it; |
---|
| 872 | for (it = arc_tree_view_records.begin(); |
---|
| 873 | it != arc_tree_view_records.end(); ++it) |
---|
| 874 | { |
---|
| 875 | if (it->name == row[ArcMapColumns.colName]) break; |
---|
| 876 | } |
---|
| 877 | if (row[ArcMapColumns.colReadAsString]) |
---|
| 878 | { |
---|
| 879 | row[ArcMapColumns.colReadAsNumeric] = false; |
---|
| 880 | it->string = true; |
---|
| 881 | it->numeric = false; |
---|
| 882 | } |
---|
| 883 | } |
---|
| 884 | |
---|
| 885 | void FileImportDialog::update_arc_tree_view() |
---|
| 886 | { |
---|
| 887 | for (std::vector<tree_view_record>::iterator it = |
---|
| 888 | arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it) |
---|
| 889 | { |
---|
| 890 | it->visible = true; |
---|
| 891 | } |
---|
| 892 | switch (p_data->arrow_coord_load_from) |
---|
| 893 | { |
---|
| 894 | case ImportData::ONE_MAP: |
---|
| 895 | for (std::vector<tree_view_record>::iterator it = |
---|
| 896 | arc_tree_view_records.begin(); it != |
---|
| 897 | arc_tree_view_records.end(); ++it) |
---|
| 898 | { |
---|
| 899 | if (it->name == p_data->arrow_coord_one_map_name) |
---|
| 900 | it->visible = false; |
---|
| 901 | } |
---|
| 902 | break; |
---|
| 903 | case ImportData::TWO_MAPS: |
---|
| 904 | for (std::vector<tree_view_record>::iterator it = |
---|
| 905 | arc_tree_view_records.begin(); it != |
---|
| 906 | arc_tree_view_records.end(); ++it) |
---|
| 907 | { |
---|
| 908 | if ((it->name == p_data->arrow_coord_two_maps_1_name) || |
---|
| 909 | (it->name == p_data->arrow_coord_two_maps_2_name)) |
---|
| 910 | it->visible = false; |
---|
| 911 | } |
---|
| 912 | break; |
---|
| 913 | case ImportData::DONT_READ: |
---|
| 914 | break; |
---|
| 915 | } |
---|
| 916 | refArcMapStore->clear(); |
---|
| 917 | for (std::vector<tree_view_record>::iterator it = |
---|
| 918 | arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it) |
---|
| 919 | { |
---|
| 920 | if (it->visible) |
---|
| 921 | { |
---|
| 922 | Gtk::TreeModel::Row row = *(refArcMapStore->append()); |
---|
| 923 | row[ArcMapColumns.colName] = it->name; |
---|
| 924 | row[ArcMapColumns.colReadAsNumeric] = it->numeric; |
---|
| 925 | row[ArcMapColumns.colReadAsString] = it->string; |
---|
| 926 | } |
---|
| 927 | } |
---|
| 928 | } |
---|