hegyi@1: #include "file_import_dialog.h" hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: #include hegyi@1: hegyi@1: FileImportDialog::FileImportDialog(ImportData* d) : hegyi@1: p_data(d) hegyi@1: { hegyi@1: add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); hegyi@1: add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); hegyi@1: hegyi@1: Gtk::VBox* pVBox = get_vbox(); hegyi@1: hegyi@1: Gtk::Notebook* nb = Gtk::manage(new Gtk::Notebook); hegyi@1: pVBox->pack_start(*nb, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: Gtk::VBox* vblueMaps = Gtk::manage(new Gtk::VBox(false, 18)); hegyi@1: vblueMaps->set_border_width(12); hegyi@1: hegyi@1: Gtk::VBox* vbArcMaps = Gtk::manage(new Gtk::VBox(false, 18)); hegyi@1: vbArcMaps->set_border_width(12); hegyi@1: hegyi@1: Gtk::VBox* vbSpecMaps = Gtk::manage(new Gtk::VBox(false, 18)); hegyi@1: vbSpecMaps->set_border_width(12); hegyi@1: hegyi@1: nb->append_page(*vbSpecMaps, "Special Maps"); hegyi@1: nb->append_page(*vblueMaps, "Node Maps"); hegyi@1: nb->append_page(*vbArcMaps, "Arc Maps"); hegyi@1: hegyi@1: // child widgets of vbSpecMaps hegyi@1: { hegyi@1: Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6)); hegyi@1: vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: { hegyi@1: Gtk::Label* label1 = hegyi@1: Gtk::manage(new Gtk::Label("Node Coordinates")); hegyi@1: label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); hegyi@1: label1->set_use_markup(); hegyi@1: box1->pack_start(*label1); hegyi@1: hegyi@1: Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); hegyi@1: box1->pack_start(*box2); hegyi@1: hegyi@1: Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box2->pack_start(*fill1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox); hegyi@1: box2->pack_start(*box3); hegyi@1: hegyi@1: Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox); hegyi@1: box3->pack_start(*box13); hegyi@1: hegyi@1: rblueCoordNone.set_label("None"); hegyi@1: Gtk::RadioButtonGroup group = rblueCoordNone.get_group(); hegyi@1: box13->pack_start(rblueCoordNone); hegyi@1: hegyi@1: Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox); hegyi@1: box3->pack_start(*box4); hegyi@1: hegyi@1: rblueCoordOneMap.set_label("One Map"); hegyi@1: rblueCoordOneMap.set_group(group); hegyi@1: box4->pack_start(rblueCoordOneMap); hegyi@1: hegyi@1: Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox); hegyi@1: box4->pack_start(*box5); hegyi@1: hegyi@1: Gtk::Label* fill2 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box5->pack_start(*fill2, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox); hegyi@1: box5->pack_start(*box6); hegyi@1: hegyi@1: Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox); hegyi@1: box6->pack_start(*box7); hegyi@1: hegyi@1: Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)")); hegyi@1: box7->pack_start(*label2, Gtk::PACK_SHRINK, 4); hegyi@1: hegyi@1: box7->pack_start(cblueCoordOneMap, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: hegyi@1: Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox); hegyi@1: box3->pack_start(*box8); hegyi@1: hegyi@1: rblueCoordTwoMaps.set_label("Two Maps"); hegyi@1: rblueCoordTwoMaps.set_group(group); hegyi@1: box8->pack_start(rblueCoordTwoMaps); hegyi@1: hegyi@1: Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox); hegyi@1: box8->pack_start(*box9); hegyi@1: hegyi@1: Gtk::Label* fill3 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box9->pack_start(*fill3, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox); hegyi@1: box9->pack_start(*box10); hegyi@1: hegyi@1: Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox); hegyi@1: box10->pack_start(*box11); hegyi@1: hegyi@1: Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X")); hegyi@1: box11->pack_start(*label3, Gtk::PACK_SHRINK, 4); hegyi@1: hegyi@1: box11->pack_start(cblueCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox); hegyi@1: box10->pack_start(*box12); hegyi@1: hegyi@1: Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y")); hegyi@1: box12->pack_start(*label4, Gtk::PACK_SHRINK, 4); hegyi@1: hegyi@1: box12->pack_start(cblueCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: cblueCoordOneMap.signal_changed().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onNodeCoordOneMapChanged)); hegyi@1: cblueCoordTwoMaps1.signal_changed().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps1Changed)); hegyi@1: cblueCoordTwoMaps2.signal_changed().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps2Changed)); hegyi@1: } hegyi@1: hegyi@1: { hegyi@1: Gtk::Label* label1 = hegyi@1: Gtk::manage(new Gtk::Label("Arrow Coordinates")); hegyi@1: label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); hegyi@1: label1->set_use_markup(); hegyi@1: box1->pack_start(*label1); hegyi@1: hegyi@1: Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); hegyi@1: box1->pack_start(*box2); hegyi@1: hegyi@1: Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box2->pack_start(*fill1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox); hegyi@1: box2->pack_start(*box3); hegyi@1: hegyi@1: Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox); hegyi@1: box3->pack_start(*box13); hegyi@1: hegyi@1: rbArrowCoordNone.set_label("None"); hegyi@1: Gtk::RadioButtonGroup group = rbArrowCoordNone.get_group(); hegyi@1: box13->pack_start(rbArrowCoordNone); hegyi@1: hegyi@1: Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox); hegyi@1: box3->pack_start(*box4); hegyi@1: hegyi@1: rbArrowCoordOneMap.set_label("One Map"); hegyi@1: rbArrowCoordOneMap.set_group(group); hegyi@1: box4->pack_start(rbArrowCoordOneMap); hegyi@1: hegyi@1: Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox); hegyi@1: box4->pack_start(*box5); hegyi@1: hegyi@1: Gtk::Label* fill2 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box5->pack_start(*fill2, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox); hegyi@1: box5->pack_start(*box6); hegyi@1: hegyi@1: Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox); hegyi@1: box6->pack_start(*box7); hegyi@1: hegyi@1: Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)")); hegyi@1: box7->pack_start(*label2, Gtk::PACK_SHRINK, 4); hegyi@1: hegyi@1: box7->pack_start(cbArrowCoordOneMap, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: hegyi@1: Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox); hegyi@1: box3->pack_start(*box8); hegyi@1: hegyi@1: rbArrowCoordTwoMaps.set_label("Two Maps"); hegyi@1: rbArrowCoordTwoMaps.set_group(group); hegyi@1: box8->pack_start(rbArrowCoordTwoMaps); hegyi@1: hegyi@1: Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox); hegyi@1: box8->pack_start(*box9); hegyi@1: hegyi@1: Gtk::Label* fill3 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box9->pack_start(*fill3, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox); hegyi@1: box9->pack_start(*box10); hegyi@1: hegyi@1: Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox); hegyi@1: box10->pack_start(*box11); hegyi@1: hegyi@1: Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X")); hegyi@1: box11->pack_start(*label3, Gtk::PACK_SHRINK, 4); hegyi@1: hegyi@1: box11->pack_start(cbArrowCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox); hegyi@1: box10->pack_start(*box12); hegyi@1: hegyi@1: Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y")); hegyi@1: box12->pack_start(*label4, Gtk::PACK_SHRINK, 4); hegyi@1: hegyi@1: box12->pack_start(cbArrowCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: cbArrowCoordOneMap.signal_changed().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onArrowCoordOneMapChanged)); hegyi@1: cbArrowCoordTwoMaps1.signal_changed().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps1Changed)); hegyi@1: cbArrowCoordTwoMaps2.signal_changed().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps2Changed)); hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: // child widgets of vblueMaps hegyi@1: { hegyi@1: Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6)); hegyi@1: vblueMaps->pack_start(*box1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::Label* label1 = hegyi@1: Gtk::manage(new Gtk::Label("Element type")); hegyi@1: label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); hegyi@1: label1->set_use_markup(); hegyi@1: box1->pack_start(*label1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); hegyi@1: box1->pack_start(*box2, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box2->pack_start(*fill1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::Frame* frame = Gtk::manage(new Gtk::Frame); hegyi@1: box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: Gtk::ScrolledWindow* swNodeMaps = Gtk::manage(new Gtk::ScrolledWindow); hegyi@1: frame->add(*swNodeMaps); hegyi@1: hegyi@1: swNodeMaps->add(twNodeMaps); hegyi@1: hegyi@1: refNodeMapStore = Gtk::ListStore::create(NodeMapColumns); hegyi@1: hegyi@1: for (std::vector::const_iterator it = hegyi@1: p_data->node_map_names.begin(); it != p_data->node_map_names.end(); hegyi@1: ++it) hegyi@1: { hegyi@1: node_tree_view_records.push_back( hegyi@1: tree_view_record(*it, false, false, true)); hegyi@1: } hegyi@1: hegyi@1: twNodeMaps.set_model(refNodeMapStore); hegyi@1: twNodeMaps.append_column("Name", NodeMapColumns.colName); hegyi@1: { hegyi@1: int col = twNodeMaps.append_column_editable("Numeric", hegyi@1: NodeMapColumns.colReadAsNumeric); hegyi@1: Gtk::CellRendererToggle* pRenderer = hegyi@1: static_cast( hegyi@1: twNodeMaps.get_column_cell_renderer(col-1)); hegyi@1: pRenderer->signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onNodeMapNumericToggled)); hegyi@1: } hegyi@1: { hegyi@1: int col = twNodeMaps.append_column_editable("String", hegyi@1: NodeMapColumns.colReadAsString); hegyi@1: Gtk::CellRendererToggle* pRenderer = hegyi@1: static_cast( hegyi@1: twNodeMaps.get_column_cell_renderer(col-1)); hegyi@1: pRenderer->signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onNodeMapStringToggled)); hegyi@1: } hegyi@1: hegyi@1: swNodeMaps->set_size_request(-1, 200); hegyi@1: swNodeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); hegyi@1: } hegyi@1: hegyi@1: // child widgets of vbArcMaps hegyi@1: { hegyi@1: Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6)); hegyi@1: vbArcMaps->pack_start(*box1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::Label* label1 = hegyi@1: Gtk::manage(new Gtk::Label("Element type")); hegyi@1: label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); hegyi@1: label1->set_use_markup(); hegyi@1: box1->pack_start(*label1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox); hegyi@1: box1->pack_start(*box2, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::Label* fill1 = Gtk::manage(new Gtk::Label(" ")); hegyi@1: box2->pack_start(*fill1, Gtk::PACK_SHRINK); hegyi@1: hegyi@1: Gtk::Frame* frame = Gtk::manage(new Gtk::Frame); hegyi@1: box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET); hegyi@1: hegyi@1: Gtk::ScrolledWindow* swArcMaps = Gtk::manage(new Gtk::ScrolledWindow); hegyi@1: frame->add(*swArcMaps); hegyi@1: hegyi@1: swArcMaps->add(twArcMaps); hegyi@1: hegyi@1: refArcMapStore = Gtk::ListStore::create(ArcMapColumns); hegyi@1: hegyi@1: for (std::vector::const_iterator it = hegyi@1: p_data->arc_map_names.begin(); it != p_data->arc_map_names.end(); hegyi@1: ++it) hegyi@1: { hegyi@1: arc_tree_view_records.push_back( hegyi@1: tree_view_record(*it, false, false, true)); hegyi@1: } hegyi@1: hegyi@1: twArcMaps.set_model(refArcMapStore); hegyi@1: twArcMaps.append_column("Name", ArcMapColumns.colName); hegyi@1: { hegyi@1: int col = twArcMaps.append_column_editable("Numeric", hegyi@1: ArcMapColumns.colReadAsNumeric); hegyi@1: Gtk::CellRendererToggle* pRenderer = hegyi@1: static_cast( hegyi@1: twArcMaps.get_column_cell_renderer(col-1)); hegyi@1: pRenderer->signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onArcMapNumericToggled)); hegyi@1: } hegyi@1: { hegyi@1: int col = twArcMaps.append_column_editable("String", hegyi@1: ArcMapColumns.colReadAsString); hegyi@1: Gtk::CellRendererToggle* pRenderer = hegyi@1: static_cast( hegyi@1: twArcMaps.get_column_cell_renderer(col-1)); hegyi@1: pRenderer->signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onArcMapStringToggled)); hegyi@1: } hegyi@1: hegyi@1: swArcMaps->set_size_request(-1, 200); hegyi@1: swArcMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); hegyi@1: } hegyi@1: hegyi@1: // fill in the ComboBoxes hegyi@1: typedef std::vector StrVec; hegyi@1: for (StrVec::const_iterator it = p_data->node_map_names.begin(); hegyi@1: it != p_data->node_map_names.end(); ++it) hegyi@1: { hegyi@1: cblueCoordTwoMaps1.append_text(*it); hegyi@1: cblueCoordTwoMaps2.append_text(*it); hegyi@1: } hegyi@1: for (StrVec::const_iterator it = p_data->arc_map_names.begin(); hegyi@1: it != p_data->arc_map_names.end(); ++it) hegyi@1: { hegyi@1: cbArrowCoordTwoMaps1.append_text(*it); hegyi@1: cbArrowCoordTwoMaps2.append_text(*it); hegyi@1: } hegyi@1: for (StrVec::const_iterator it = p_data->xy_node_map_names.begin(); hegyi@1: it != p_data->xy_node_map_names.end(); ++it) hegyi@1: { hegyi@1: cblueCoordOneMap.append_text(*it); hegyi@1: } hegyi@1: for (StrVec::const_iterator it = p_data->xy_arc_map_names.begin(); hegyi@1: it != p_data->xy_arc_map_names.end(); ++it) hegyi@1: { hegyi@1: cbArrowCoordOneMap.append_text(*it); hegyi@1: } hegyi@1: hegyi@1: if (p_data->isXYNodeMap("coord")) hegyi@1: { hegyi@1: cblueCoordOneMap.set_active_text("coord"); hegyi@1: } hegyi@1: else if (p_data->isXYNodeMap("coords")) hegyi@1: { hegyi@1: cblueCoordOneMap.set_active_text("coords"); hegyi@1: } hegyi@1: else if (p_data->isNodeMap("coord_x") && hegyi@1: p_data->isNodeMap("coord_y")) hegyi@1: { hegyi@1: cblueCoordTwoMaps1.set_active_text("coord_x"); hegyi@1: cblueCoordTwoMaps2.set_active_text("coord_y"); hegyi@1: } hegyi@1: else if (p_data->isNodeMap("coords_x") && hegyi@1: p_data->isNodeMap("coords_y")) hegyi@1: { hegyi@1: cblueCoordTwoMaps1.set_active_text("coords_x"); hegyi@1: cblueCoordTwoMaps2.set_active_text("coords_y"); hegyi@1: } hegyi@1: else if (p_data->isNodeMap("x") && hegyi@1: p_data->isNodeMap("y")) hegyi@1: { hegyi@1: cblueCoordTwoMaps1.set_active_text("x"); hegyi@1: cblueCoordTwoMaps2.set_active_text("y"); hegyi@1: } hegyi@1: hegyi@1: if (p_data->isXYArcMap("arrow")) hegyi@1: { hegyi@1: cbArrowCoordOneMap.set_active_text("arrow"); hegyi@1: } hegyi@1: else if (p_data->isXYArcMap("arrows")) hegyi@1: { hegyi@1: cbArrowCoordOneMap.set_active_text("arrows"); hegyi@1: } hegyi@1: else if (p_data->isXYArcMap("midpoint")) hegyi@1: { hegyi@1: cbArrowCoordOneMap.set_active_text("midpoint"); hegyi@1: } hegyi@1: else if (p_data->isXYArcMap("midpoints")) hegyi@1: { hegyi@1: cbArrowCoordOneMap.set_active_text("midpoints"); hegyi@1: } hegyi@1: else if (p_data->isXYArcMap("mid")) hegyi@1: { hegyi@1: cbArrowCoordOneMap.set_active_text("mid"); hegyi@1: } hegyi@1: else if (p_data->isXYArcMap("mids")) hegyi@1: { hegyi@1: cbArrowCoordOneMap.set_active_text("mids"); hegyi@1: } hegyi@1: else if (p_data->isArcMap("arrow_x") && hegyi@1: p_data->isArcMap("arrow_y")) hegyi@1: { hegyi@1: cbArrowCoordTwoMaps1.set_active_text("arrow_x"); hegyi@1: cbArrowCoordTwoMaps2.set_active_text("arrow_y"); hegyi@1: } hegyi@1: else if (p_data->isArcMap("arrows_x") && hegyi@1: p_data->isArcMap("arrows_y")) hegyi@1: { hegyi@1: cbArrowCoordTwoMaps1.set_active_text("arrows_x"); hegyi@1: cbArrowCoordTwoMaps2.set_active_text("arrows_y"); hegyi@1: } hegyi@1: else if (p_data->isArcMap("midpoint_x") && hegyi@1: p_data->isArcMap("midpoint_y")) hegyi@1: { hegyi@1: cbArrowCoordTwoMaps1.set_active_text("midpoint_x"); hegyi@1: cbArrowCoordTwoMaps2.set_active_text("midpoint_y"); hegyi@1: } hegyi@1: else if (p_data->isArcMap("midpoints_x") && hegyi@1: p_data->isArcMap("midpoints_y")) hegyi@1: { hegyi@1: cbArrowCoordTwoMaps1.set_active_text("midpoints_x"); hegyi@1: cbArrowCoordTwoMaps2.set_active_text("midpoints_y"); hegyi@1: } hegyi@1: else if (p_data->isArcMap("mid_x") && hegyi@1: p_data->isArcMap("mid_y")) hegyi@1: { hegyi@1: cbArrowCoordTwoMaps1.set_active_text("mid_x"); hegyi@1: cbArrowCoordTwoMaps2.set_active_text("mid_y"); hegyi@1: } hegyi@1: else if (p_data->isArcMap("mids_x") && hegyi@1: p_data->isArcMap("mids_y")) hegyi@1: { hegyi@1: cbArrowCoordTwoMaps1.set_active_text("mids_x"); hegyi@1: cbArrowCoordTwoMaps2.set_active_text("mids_y"); hegyi@1: } hegyi@1: hegyi@1: { hegyi@1: if (cblueCoordOneMap.get_active_text() != "") hegyi@1: rblueCoordOneMap.set_active(); hegyi@1: else if (cblueCoordTwoMaps1.get_active_text() != "") hegyi@1: rblueCoordTwoMaps.set_active(); hegyi@1: else hegyi@1: rblueCoordNone.set_active(); hegyi@1: hegyi@1: if (cbArrowCoordOneMap.get_active_text() != "") hegyi@1: rbArrowCoordOneMap.set_active(); hegyi@1: else if (cbArrowCoordTwoMaps1.get_active_text() != "") hegyi@1: rbArrowCoordTwoMaps.set_active(); hegyi@1: else hegyi@1: rbArrowCoordNone.set_active(); hegyi@1: hegyi@1: onNodeCoordMapNumToggled(); hegyi@1: onArrowCoordMapNumToggled(); hegyi@1: hegyi@1: rblueCoordOneMap.signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled)); hegyi@1: rblueCoordTwoMaps.signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled)); hegyi@1: rbArrowCoordOneMap.signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled)); hegyi@1: rbArrowCoordTwoMaps.signal_toggled().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled)); hegyi@1: } hegyi@1: hegyi@1: signal_response().connect( hegyi@1: sigc::mem_fun(*this, &FileImportDialog::onResponse)); hegyi@1: hegyi@1: update_node_tree_view(); hegyi@1: update_arc_tree_view(); hegyi@1: hegyi@1: show_all_children(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onNodeCoordMapNumToggled() hegyi@1: { hegyi@1: if (rblueCoordOneMap.get_active()) hegyi@1: { hegyi@1: cblueCoordOneMap.get_parent()->set_sensitive(true); hegyi@1: cblueCoordTwoMaps1.get_parent()->set_sensitive(false); hegyi@1: cblueCoordTwoMaps2.get_parent()->set_sensitive(false); hegyi@1: hegyi@1: p_data->node_coord_load_from = ImportData::ONE_MAP; hegyi@1: } hegyi@1: else if (rblueCoordTwoMaps.get_active()) hegyi@1: { hegyi@1: cblueCoordOneMap.get_parent()->set_sensitive(false); hegyi@1: cblueCoordTwoMaps1.get_parent()->set_sensitive(true); hegyi@1: cblueCoordTwoMaps2.get_parent()->set_sensitive(true); hegyi@1: hegyi@1: p_data->node_coord_load_from = ImportData::TWO_MAPS; hegyi@1: } hegyi@1: else if (rblueCoordNone.get_active()) hegyi@1: { hegyi@1: cblueCoordOneMap.get_parent()->set_sensitive(false); hegyi@1: cblueCoordTwoMaps1.get_parent()->set_sensitive(false); hegyi@1: cblueCoordTwoMaps2.get_parent()->set_sensitive(false); hegyi@1: hegyi@1: p_data->node_coord_load_from = ImportData::DONT_READ; hegyi@1: } hegyi@1: update_node_tree_view(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onArrowCoordMapNumToggled() hegyi@1: { hegyi@1: if (rbArrowCoordOneMap.get_active()) hegyi@1: { hegyi@1: cbArrowCoordOneMap.get_parent()->set_sensitive(true); hegyi@1: cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false); hegyi@1: cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false); hegyi@1: hegyi@1: p_data->arrow_coord_load_from = ImportData::ONE_MAP; hegyi@1: } hegyi@1: else if (rbArrowCoordTwoMaps.get_active()) hegyi@1: { hegyi@1: cbArrowCoordOneMap.get_parent()->set_sensitive(false); hegyi@1: cbArrowCoordTwoMaps1.get_parent()->set_sensitive(true); hegyi@1: cbArrowCoordTwoMaps2.get_parent()->set_sensitive(true); hegyi@1: hegyi@1: p_data->arrow_coord_load_from = ImportData::TWO_MAPS; hegyi@1: } hegyi@1: else if (rbArrowCoordNone.get_active()) hegyi@1: { hegyi@1: cbArrowCoordOneMap.get_parent()->set_sensitive(false); hegyi@1: cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false); hegyi@1: cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false); hegyi@1: hegyi@1: p_data->arrow_coord_load_from = ImportData::DONT_READ; hegyi@1: } hegyi@1: update_arc_tree_view(); hegyi@1: } hegyi@1: hegyi@1: FileImportDialog::~FileImportDialog() hegyi@1: { hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onResponse(int id) hegyi@1: { hegyi@1: if (id == Gtk::RESPONSE_OK) hegyi@1: { hegyi@1: if ((rblueCoordOneMap.get_active() && hegyi@1: cblueCoordOneMap.get_active_text() == "") || hegyi@1: (rblueCoordTwoMaps.get_active() && hegyi@1: (cblueCoordTwoMaps1.get_active_text() == "" || hegyi@1: cblueCoordTwoMaps2.get_active_text() == ""))) hegyi@1: { hegyi@1: Gtk::MessageDialog mdialog("No node map selected.", hegyi@1: false, Gtk::MESSAGE_ERROR); hegyi@1: mdialog.run(); hegyi@1: return; hegyi@1: } hegyi@1: else if (rblueCoordTwoMaps.get_active() && hegyi@1: cblueCoordTwoMaps1.get_active_text() == hegyi@1: cblueCoordTwoMaps2.get_active_text()) hegyi@1: { hegyi@1: Gtk::MessageDialog mdialog( hegyi@1: "Same node map selected for both coordinates.", hegyi@1: false, Gtk::MESSAGE_ERROR); hegyi@1: mdialog.run(); hegyi@1: return; hegyi@1: } hegyi@1: if ((rbArrowCoordOneMap.get_active() && hegyi@1: cbArrowCoordOneMap.get_active_text() == "") || hegyi@1: (rbArrowCoordTwoMaps.get_active() && hegyi@1: (cbArrowCoordTwoMaps1.get_active_text() == "" || hegyi@1: cbArrowCoordTwoMaps2.get_active_text() == ""))) hegyi@1: { hegyi@1: Gtk::MessageDialog mdialog("No arc map selected.", hegyi@1: false, Gtk::MESSAGE_ERROR); hegyi@1: mdialog.run(); hegyi@1: return; hegyi@1: } hegyi@1: else if (rbArrowCoordTwoMaps.get_active() && hegyi@1: cbArrowCoordTwoMaps1.get_active_text() == hegyi@1: cbArrowCoordTwoMaps2.get_active_text()) hegyi@1: { hegyi@1: Gtk::MessageDialog mdialog( hegyi@1: "Same arc map selected for both coordinates.", hegyi@1: false, Gtk::MESSAGE_ERROR); hegyi@1: mdialog.run(); hegyi@1: return; hegyi@1: } hegyi@1: hegyi@1: for (std::vector::const_iterator it = hegyi@1: node_tree_view_records.begin(); it != node_tree_view_records.end(); hegyi@1: ++it) hegyi@1: { hegyi@1: if (it->visible) hegyi@1: { hegyi@1: if (it->numeric) hegyi@1: p_data->numeric_node_map_names.push_back(it->name); hegyi@1: if (it->string) hegyi@1: p_data->string_node_map_names.push_back(it->name); hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: for (std::vector::const_iterator it = hegyi@1: arc_tree_view_records.begin(); it != arc_tree_view_records.end(); hegyi@1: ++it) hegyi@1: { hegyi@1: if (it->visible) hegyi@1: { hegyi@1: if (it->numeric) hegyi@1: p_data->numeric_arc_map_names.push_back(it->name); hegyi@1: if (it->string) hegyi@1: p_data->string_arc_map_names.push_back(it->name); hegyi@1: } hegyi@1: } hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: FileImportDialog::ImportData::ImportData( hegyi@1: const std::vector& _node_map_names, hegyi@1: const std::vector& _arc_map_names) : hegyi@1: node_map_names(_node_map_names), hegyi@1: arc_map_names(_arc_map_names) hegyi@1: { hegyi@1: typedef std::vector StrVec; hegyi@1: { hegyi@1: StrVec xMaps; hegyi@1: StrVec yMaps; hegyi@1: // collect map names ending with ":x" and ":y" hegyi@1: for (StrVec::const_iterator it = node_map_names.begin(); hegyi@1: it != node_map_names.end(); ++it) hegyi@1: { hegyi@1: if ((it->length() >= 3) && hegyi@1: (it->substr(it->length()-2, it->length()) == ":x")) hegyi@1: { hegyi@1: xMaps.push_back(it->substr(0, it->length()-2)); hegyi@1: } hegyi@1: if ((it->length() >= 3) && hegyi@1: (it->substr(it->length()-2, it->length()) == ":y")) hegyi@1: { hegyi@1: yMaps.push_back(it->substr(0, it->length()-2)); hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: for (StrVec::const_iterator it1 = xMaps.begin(); hegyi@1: it1 != xMaps.end(); ++it1) hegyi@1: { hegyi@1: for (StrVec::const_iterator it2 = yMaps.begin(); hegyi@1: it2 != yMaps.end(); ++it2) hegyi@1: { hegyi@1: if (*it1 == *it2) xy_node_map_names.push_back(*it1); hegyi@1: } hegyi@1: } hegyi@1: } hegyi@1: { hegyi@1: StrVec xMaps; hegyi@1: StrVec yMaps; hegyi@1: // collect map names ending with ":x" and ":y" hegyi@1: for (StrVec::const_iterator it = arc_map_names.begin(); hegyi@1: it != arc_map_names.end(); ++it) hegyi@1: { hegyi@1: if ((it->length() >= 3) && hegyi@1: (it->substr(it->length()-2, it->length()) == ":x")) hegyi@1: { hegyi@1: xMaps.push_back(it->substr(0, it->length()-2)); hegyi@1: } hegyi@1: if ((it->length() >= 3) && hegyi@1: (it->substr(it->length()-2, it->length()) == ":y")) hegyi@1: { hegyi@1: yMaps.push_back(it->substr(0, it->length()-2)); hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: for (StrVec::const_iterator it1 = xMaps.begin(); hegyi@1: it1 != xMaps.end(); ++it1) hegyi@1: { hegyi@1: for (StrVec::const_iterator it2 = yMaps.begin(); hegyi@1: it2 != yMaps.end(); ++it2) hegyi@1: { hegyi@1: if (*it1 == *it2) xy_arc_map_names.push_back(*it1); hegyi@1: } hegyi@1: } hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: FileImportDialog::ImportData::~ImportData() hegyi@1: { hegyi@1: } hegyi@1: hegyi@1: bool FileImportDialog::ImportData::isXYNodeMap(const std::string& name) hegyi@1: { hegyi@1: if (isNodeMap(name + ":x") && isNodeMap(name + ":y")) return true; hegyi@1: return false; hegyi@1: } hegyi@1: hegyi@1: bool FileImportDialog::ImportData::isXYArcMap(const std::string& name) hegyi@1: { hegyi@1: if (isArcMap(name + ":x") && isArcMap(name + ":y")) return true; hegyi@1: return false; hegyi@1: } hegyi@1: hegyi@1: bool FileImportDialog::ImportData::isNodeMap(const std::string& name) hegyi@1: { hegyi@1: if (contains(node_map_names, name)) return true; hegyi@1: return false; hegyi@1: } hegyi@1: hegyi@1: bool FileImportDialog::ImportData::isArcMap(const std::string& name) hegyi@1: { hegyi@1: if (contains(arc_map_names, name)) return true; hegyi@1: return false; hegyi@1: } hegyi@1: hegyi@1: bool FileImportDialog::ImportData::contains(const std::vector& vec, hegyi@1: const std::string& str) hegyi@1: { hegyi@1: for (std::vector::const_iterator it = vec.begin(); hegyi@1: it != vec.end(); ++it) hegyi@1: { hegyi@1: if (*it == str) return true; hegyi@1: } hegyi@1: return false; hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onNodeCoordOneMapChanged() hegyi@1: { hegyi@1: p_data->node_coord_one_map_name = cblueCoordOneMap.get_active_text(); hegyi@1: update_node_tree_view(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onNodeCoordTwoMaps1Changed() hegyi@1: { hegyi@1: p_data->node_coord_two_maps_1_name = cblueCoordTwoMaps1.get_active_text(); hegyi@1: update_node_tree_view(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onNodeCoordTwoMaps2Changed() hegyi@1: { hegyi@1: p_data->node_coord_two_maps_2_name = cblueCoordTwoMaps2.get_active_text(); hegyi@1: update_node_tree_view(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onArrowCoordOneMapChanged() hegyi@1: { hegyi@1: p_data->arrow_coord_one_map_name = cbArrowCoordOneMap.get_active_text(); hegyi@1: update_arc_tree_view(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onArrowCoordTwoMaps1Changed() hegyi@1: { hegyi@1: p_data->arrow_coord_two_maps_1_name = cbArrowCoordTwoMaps1.get_active_text(); hegyi@1: update_arc_tree_view(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onArrowCoordTwoMaps2Changed() hegyi@1: { hegyi@1: p_data->arrow_coord_two_maps_2_name = cbArrowCoordTwoMaps2.get_active_text(); hegyi@1: update_arc_tree_view(); hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onNodeMapNumericToggled(const Glib::ustring& path) hegyi@1: { hegyi@1: Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter( hegyi@1: Gtk::TreeModel::Path(path)); hegyi@1: Gtk::TreeModel::Row row = *iter; hegyi@1: std::vector::iterator it; hegyi@1: for (it = node_tree_view_records.begin(); hegyi@1: it != node_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->name == row[NodeMapColumns.colName]) break; hegyi@1: } hegyi@1: if (row[NodeMapColumns.colReadAsNumeric]) hegyi@1: { hegyi@1: row[NodeMapColumns.colReadAsString] = false; hegyi@1: it->string = false; hegyi@1: it->numeric = true; hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onNodeMapStringToggled(const Glib::ustring& path) hegyi@1: { hegyi@1: Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter( hegyi@1: Gtk::TreeModel::Path(path)); hegyi@1: Gtk::TreeModel::Row row = *iter; hegyi@1: std::vector::iterator it; hegyi@1: for (it = node_tree_view_records.begin(); hegyi@1: it != node_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->name == row[NodeMapColumns.colName]) break; hegyi@1: } hegyi@1: if (row[NodeMapColumns.colReadAsString]) hegyi@1: { hegyi@1: row[NodeMapColumns.colReadAsNumeric] = false; hegyi@1: it->string = true; hegyi@1: it->numeric = false; hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::update_node_tree_view() hegyi@1: { hegyi@1: for (std::vector::iterator it = hegyi@1: node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: it->visible = true; hegyi@1: } hegyi@1: switch (p_data->node_coord_load_from) hegyi@1: { hegyi@1: case ImportData::ONE_MAP: hegyi@1: for (std::vector::iterator it = hegyi@1: node_tree_view_records.begin(); it != hegyi@1: node_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->name == p_data->node_coord_one_map_name) hegyi@1: it->visible = false; hegyi@1: } hegyi@1: break; hegyi@1: case ImportData::TWO_MAPS: hegyi@1: for (std::vector::iterator it = hegyi@1: node_tree_view_records.begin(); it != hegyi@1: node_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if ((it->name == p_data->node_coord_two_maps_1_name) || hegyi@1: (it->name == p_data->node_coord_two_maps_2_name)) hegyi@1: it->visible = false; hegyi@1: } hegyi@1: break; hegyi@1: case ImportData::DONT_READ: hegyi@1: break; hegyi@1: } hegyi@1: refNodeMapStore->clear(); hegyi@1: for (std::vector::iterator it = hegyi@1: node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->visible) hegyi@1: { hegyi@1: Gtk::TreeModel::Row row = *(refNodeMapStore->append()); hegyi@1: row[NodeMapColumns.colName] = it->name; hegyi@1: row[NodeMapColumns.colReadAsNumeric] = it->numeric; hegyi@1: row[NodeMapColumns.colReadAsString] = it->string; hegyi@1: } hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onArcMapNumericToggled(const Glib::ustring& path) hegyi@1: { hegyi@1: Gtk::TreeModel::iterator iter = refArcMapStore->get_iter( hegyi@1: Gtk::TreeModel::Path(path)); hegyi@1: Gtk::TreeModel::Row row = *iter; hegyi@1: std::vector::iterator it; hegyi@1: for (it = arc_tree_view_records.begin(); hegyi@1: it != arc_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->name == row[ArcMapColumns.colName]) break; hegyi@1: } hegyi@1: if (row[ArcMapColumns.colReadAsNumeric]) hegyi@1: { hegyi@1: row[ArcMapColumns.colReadAsString] = false; hegyi@1: it->string = false; hegyi@1: it->numeric = true; hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::onArcMapStringToggled(const Glib::ustring& path) hegyi@1: { hegyi@1: Gtk::TreeModel::iterator iter = refArcMapStore->get_iter( hegyi@1: Gtk::TreeModel::Path(path)); hegyi@1: Gtk::TreeModel::Row row = *iter; hegyi@1: std::vector::iterator it; hegyi@1: for (it = arc_tree_view_records.begin(); hegyi@1: it != arc_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->name == row[ArcMapColumns.colName]) break; hegyi@1: } hegyi@1: if (row[ArcMapColumns.colReadAsString]) hegyi@1: { hegyi@1: row[ArcMapColumns.colReadAsNumeric] = false; hegyi@1: it->string = true; hegyi@1: it->numeric = false; hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: void FileImportDialog::update_arc_tree_view() hegyi@1: { hegyi@1: for (std::vector::iterator it = hegyi@1: arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: it->visible = true; hegyi@1: } hegyi@1: switch (p_data->arrow_coord_load_from) hegyi@1: { hegyi@1: case ImportData::ONE_MAP: hegyi@1: for (std::vector::iterator it = hegyi@1: arc_tree_view_records.begin(); it != hegyi@1: arc_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->name == p_data->arrow_coord_one_map_name) hegyi@1: it->visible = false; hegyi@1: } hegyi@1: break; hegyi@1: case ImportData::TWO_MAPS: hegyi@1: for (std::vector::iterator it = hegyi@1: arc_tree_view_records.begin(); it != hegyi@1: arc_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if ((it->name == p_data->arrow_coord_two_maps_1_name) || hegyi@1: (it->name == p_data->arrow_coord_two_maps_2_name)) hegyi@1: it->visible = false; hegyi@1: } hegyi@1: break; hegyi@1: case ImportData::DONT_READ: hegyi@1: break; hegyi@1: } hegyi@1: refArcMapStore->clear(); hegyi@1: for (std::vector::iterator it = hegyi@1: arc_tree_view_records.begin(); it != arc_tree_view_records.end(); ++it) hegyi@1: { hegyi@1: if (it->visible) hegyi@1: { hegyi@1: Gtk::TreeModel::Row row = *(refArcMapStore->append()); hegyi@1: row[ArcMapColumns.colName] = it->name; hegyi@1: row[ArcMapColumns.colReadAsNumeric] = it->numeric; hegyi@1: row[ArcMapColumns.colReadAsString] = it->string; hegyi@1: } hegyi@1: } hegyi@1: }