file_import_dialog.h
changeset 1 67188bd752db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/file_import_dialog.h	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -0,0 +1,137 @@
     1.4 +#ifndef FILE_IMPORT_DIALOG
     1.5 +#define FILE_IMPORT_DIALOG
     1.6 +
     1.7 +#include <gtkmm/dialog.h>
     1.8 +#include <gtkmm/radiobutton.h>
     1.9 +#include <gtkmm/comboboxtext.h>
    1.10 +#include <gtkmm/sizegroup.h>
    1.11 +#include <gtkmm/treemodel.h>
    1.12 +#include <gtkmm/liststore.h>
    1.13 +#include <gtkmm/treeview.h>
    1.14 +#include <gtkmm/scrolledwindow.h>
    1.15 +
    1.16 +class FileImportDialog : public Gtk::Dialog
    1.17 +{
    1.18 +  public:
    1.19 +    struct ImportData
    1.20 +    {
    1.21 +        ImportData(
    1.22 +            const std::vector<std::string>& _node_map_names,
    1.23 +            const std::vector<std::string>& _arc_map_names);
    1.24 +
    1.25 +        ~ImportData();
    1.26 +
    1.27 +        std::vector<std::string> node_map_names;
    1.28 +        std::vector<std::string> arc_map_names;
    1.29 +
    1.30 +        std::vector<std::string> xy_node_map_names;
    1.31 +        std::vector<std::string> xy_arc_map_names;
    1.32 +
    1.33 +        bool contains(
    1.34 +            const std::vector<std::string>& vec,
    1.35 +            const std::string& str);
    1.36 +
    1.37 +        std::string node_coord_one_map_name;
    1.38 +        std::string node_coord_two_maps_1_name;
    1.39 +        std::string node_coord_two_maps_2_name;
    1.40 +        std::string arrow_coord_one_map_name;
    1.41 +        std::string arrow_coord_two_maps_1_name;
    1.42 +        std::string arrow_coord_two_maps_2_name;
    1.43 +
    1.44 +        enum ReadOpts { ONE_MAP, TWO_MAPS, DONT_READ };
    1.45 +        ReadOpts node_coord_load_from;
    1.46 +        ReadOpts arrow_coord_load_from;
    1.47 +
    1.48 +        bool isXYNodeMap(const std::string& name);
    1.49 +        bool isXYArcMap(const std::string& name);
    1.50 +        bool isNodeMap(const std::string& name);
    1.51 +        bool isArcMap(const std::string& name);
    1.52 +
    1.53 +        std::vector<std::string> numeric_node_map_names;
    1.54 +        std::vector<std::string> string_node_map_names;
    1.55 +        std::vector<std::string> numeric_arc_map_names;
    1.56 +        std::vector<std::string> string_arc_map_names;
    1.57 +    };
    1.58 +
    1.59 +    ImportData* p_data;
    1.60 +
    1.61 +    Gtk::RadioButton rblueCoordNone;
    1.62 +    Gtk::RadioButton rblueCoordOneMap;
    1.63 +    Gtk::RadioButton rblueCoordTwoMaps;
    1.64 +
    1.65 +    Gtk::RadioButton rbArrowCoordNone;
    1.66 +    Gtk::RadioButton rbArrowCoordOneMap;
    1.67 +    Gtk::RadioButton rbArrowCoordTwoMaps;
    1.68 +
    1.69 +    Gtk::ComboBoxText cblueCoordOneMap;
    1.70 +    Gtk::ComboBoxText cblueCoordTwoMaps1;
    1.71 +    Gtk::ComboBoxText cblueCoordTwoMaps2;
    1.72 +
    1.73 +    Gtk::ComboBoxText cbArrowCoordOneMap;
    1.74 +    Gtk::ComboBoxText cbArrowCoordTwoMaps1;
    1.75 +    Gtk::ComboBoxText cbArrowCoordTwoMaps2;
    1.76 +
    1.77 +    void onNodeCoordMapNumToggled();
    1.78 +    void onArrowCoordMapNumToggled();
    1.79 +
    1.80 +    void onResponse(int id);
    1.81 +
    1.82 +    void onNodeCoordOneMapChanged();
    1.83 +    void onNodeCoordTwoMaps1Changed();
    1.84 +    void onNodeCoordTwoMaps2Changed();
    1.85 +
    1.86 +    void onArrowCoordOneMapChanged();
    1.87 +    void onArrowCoordTwoMaps1Changed();
    1.88 +    void onArrowCoordTwoMaps2Changed();
    1.89 +
    1.90 +    struct MapModelColumns : public Gtk::TreeModel::ColumnRecord
    1.91 +    {
    1.92 +      MapModelColumns()
    1.93 +      {
    1.94 +        add(colName);
    1.95 +        add(colReadAsNumeric);
    1.96 +        add(colReadAsString);
    1.97 +      }
    1.98 +      Gtk::TreeModelColumn<Glib::ustring> colName;
    1.99 +      Gtk::TreeModelColumn<bool> colReadAsNumeric;
   1.100 +      Gtk::TreeModelColumn<bool> colReadAsString;
   1.101 +    };
   1.102 +
   1.103 +    Gtk::TreeView twNodeMaps;
   1.104 +    MapModelColumns NodeMapColumns;
   1.105 +    Glib::RefPtr<Gtk::ListStore> refNodeMapStore;
   1.106 +    void onNodeMapNumericToggled(const Glib::ustring& path);
   1.107 +    void onNodeMapStringToggled(const Glib::ustring& path);
   1.108 +
   1.109 +    Gtk::TreeView twArcMaps;
   1.110 +    MapModelColumns ArcMapColumns;
   1.111 +    Glib::RefPtr<Gtk::ListStore> refArcMapStore;
   1.112 +    void onArcMapNumericToggled(const Glib::ustring& path);
   1.113 +    void onArcMapStringToggled(const Glib::ustring& path);
   1.114 +
   1.115 +    struct tree_view_record
   1.116 +    {
   1.117 +      tree_view_record(const std::string& _name, bool _numeric, bool _string,
   1.118 +          bool _visible) :
   1.119 +        name(_name),
   1.120 +        numeric(_numeric),
   1.121 +        string(_string),
   1.122 +        visible(_visible) {}
   1.123 +      std::string name;
   1.124 +      bool numeric;
   1.125 +      bool string;
   1.126 +      bool visible;
   1.127 +    };
   1.128 +
   1.129 +    std::vector<tree_view_record> node_tree_view_records;
   1.130 +    void update_node_tree_view();
   1.131 +
   1.132 +    std::vector<tree_view_record> arc_tree_view_records;
   1.133 +    void update_arc_tree_view();
   1.134 +
   1.135 +  public:
   1.136 +    FileImportDialog(ImportData* d);
   1.137 +    ~FileImportDialog();
   1.138 +};
   1.139 +
   1.140 +#endif