mapstorage.h
author ladanyi
Wed, 02 Jan 2008 21:03:09 +0000
changeset 201 879e47e5b731
parent 198 d6cc0579b94b
permissions -rw-r--r--
Merge branches/akos to trunk.
alpar@174
     1
/* -*- C++ -*-
alpar@174
     2
 *
alpar@174
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@174
     4
 *
alpar@174
     5
 * Copyright (C) 2003-2006
alpar@174
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@174
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@174
     8
 *
alpar@174
     9
 * Permission to use, modify and distribute this software is granted
alpar@174
    10
 * provided that this copyright notice appears in all copies. For
alpar@174
    11
 * precise terms see the accompanying LICENSE file.
alpar@174
    12
 *
alpar@174
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@174
    14
 * express or implied, and with no claim as to its suitability for any
alpar@174
    15
 * purpose.
alpar@174
    16
 *
alpar@174
    17
 */
ladanyi@6
    18
ladanyi@6
    19
#ifndef MAPSTORAGE_H
ladanyi@6
    20
#define MAPSTORAGE_H
ladanyi@6
    21
ladanyi@201
    22
class Mapstorage;
ladanyi@201
    23
ladanyi@201
    24
#include <vector>
ladanyi@201
    25
#include <map>
ladanyi@201
    26
#include <string>
ladanyi@201
    27
#include "all_include.h"
ladanyi@201
    28
#include "xymap.h"
hegyi@94
    29
#include <libgnomecanvasmm.h>
ladanyi@201
    30
#include "map_value.h"
ladanyi@201
    31
#include "map_value_map.h"
ladanyi@6
    32
hegyi@118
    33
///class MapStorage handles NodeMaps and EdgeMaps.
hegyi@118
    34
ladanyi@6
    35
///Class MapStorage is responsible for storing
ladanyi@6
    36
///NodeMaps and EdgeMaps that can be shown later
ladanyi@6
    37
///on GUI. Therefore maps can be added to it,
ladanyi@6
    38
///and datas over the added maps can be queried.
ladanyi@6
    39
///The maps will be stored in an std::map,
ladanyi@6
    40
///referenced with their names. Unfortunately at
ladanyi@6
    41
///the moment it works only with double type maps
ladanyi@6
    42
///
ladanyi@6
    43
///\todo too many things are public!!
ladanyi@6
    44
class MapStorage
ladanyi@6
    45
{
ladanyi@184
    46
private:
ladanyi@184
    47
  std::string background_file_name;
ladanyi@184
    48
  bool background_set;
ladanyi@184
    49
  double background_scaling;
ladanyi@6
    50
public:
ladanyi@201
    51
  class Error : public std::exception
ladanyi@201
    52
  {
ladanyi@201
    53
    private:
ladanyi@201
    54
      std::string message;
ladanyi@201
    55
    public:
ladanyi@201
    56
      Error(const std::string& msg) : message(msg) {}
ladanyi@201
    57
      virtual const char* what() const throw()
ladanyi@201
    58
      {
ladanyi@201
    59
        return message.c_str();
ladanyi@201
    60
      }
ladanyi@201
    61
      ~Error() throw() {}
ladanyi@201
    62
  };
ladanyi@201
    63
ladanyi@184
    64
  void setBackground(const std::string& file_name);
ladanyi@184
    65
  const std::string& getBackgroundFilename();
ladanyi@184
    66
  bool isBackgroundSet();
ladanyi@184
    67
  double getBackgroundScaling();
ladanyi@184
    68
  void setBackgroundScaling(double scaling);
ladanyi@201
    69
ladanyi@201
    70
  enum MapSaveDest { GUI_SECT, NESET_SECT, DONT_SAVE };
ladanyi@201
    71
  enum GuiSectSaveDest { LGF_FILE, CONF_FILE };
ladanyi@201
    72
  struct SpecMapSaveOpts
ladanyi@201
    73
  {
ladanyi@201
    74
    enum Dest { GUI_SECT, NESET_SECT };
ladanyi@201
    75
    enum MapNum { ONE_MAP, TWO_MAPS };
ladanyi@201
    76
  };
ladanyi@201
    77
ladanyi@201
    78
  typedef Graph::NodeMap<double> NumericNodeMap;
ladanyi@201
    79
  typedef Graph::NodeMap<std::string> StringNodeMap;
ladanyi@201
    80
  typedef Graph::EdgeMap<double> NumericEdgeMap;
ladanyi@201
    81
  typedef Graph::EdgeMap<std::string> StringEdgeMap;
ladanyi@201
    82
  typedef Graph::NodeMap<int> NodeLabelMap;
ladanyi@201
    83
  typedef Graph::EdgeMap<int> EdgeLabelMap;
ladanyi@201
    84
  typedef XYMap<Graph::NodeMap<double> > NodeCoordMap;
ladanyi@201
    85
  typedef XYMap<Graph::EdgeMap<double> > ArrowCoordMap;
ladanyi@201
    86
ladanyi@201
    87
  struct EdgeMapData
ladanyi@201
    88
  {
ladanyi@201
    89
    /// where to save the map
ladanyi@201
    90
    MapSaveDest save_dest;
ladanyi@201
    91
    /// read-only or read-write
ladanyi@201
    92
    bool writeable;
ladanyi@201
    93
    /// default value
ladanyi@201
    94
    MapValue default_value;
ladanyi@201
    95
    virtual MapValue::Type type() = 0;
ladanyi@201
    96
    virtual MapValue get(Edge e) = 0;
ladanyi@201
    97
    virtual void set(Edge e, MapValue v) = 0;
ladanyi@201
    98
    EdgeMapData(MapValue def_val) :
ladanyi@201
    99
      save_dest(GUI_SECT),
ladanyi@201
   100
      writeable(true),
ladanyi@201
   101
      default_value(def_val)
ladanyi@201
   102
    {}
ladanyi@201
   103
  };
ladanyi@201
   104
ladanyi@201
   105
  struct NumericEdgeMapData : public EdgeMapData
ladanyi@201
   106
  {
ladanyi@201
   107
    NumericEdgeMap map;
ladanyi@201
   108
    MapValue::Type type() { return MapValue::NUMERIC; }
ladanyi@201
   109
    MapValue get(Edge e) { return MapValue(map[e]); }
ladanyi@201
   110
    void set(Edge e, MapValue v) { map.set(e, static_cast<double>(v)); }
ladanyi@201
   111
    NumericEdgeMapData(Graph& g, double def_val) :
ladanyi@201
   112
      EdgeMapData(MapValue(def_val)),
ladanyi@201
   113
      map(g, def_val)
ladanyi@201
   114
    {}
ladanyi@201
   115
  };
ladanyi@201
   116
ladanyi@201
   117
  struct StringEdgeMapData : public EdgeMapData
ladanyi@201
   118
  {
ladanyi@201
   119
    StringEdgeMap map;
ladanyi@201
   120
    MapValue::Type type() { return MapValue::STRING; }
ladanyi@201
   121
    MapValue get(Edge e) { return MapValue(map[e]); }
ladanyi@201
   122
    void set(Edge e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
ladanyi@201
   123
    StringEdgeMapData(Graph& g, std::string def_val) :
ladanyi@201
   124
      EdgeMapData(MapValue(def_val)),
ladanyi@201
   125
      map(g, def_val)
ladanyi@201
   126
    {}
ladanyi@201
   127
  };
ladanyi@201
   128
ladanyi@201
   129
  struct NodeMapData
ladanyi@201
   130
  {
ladanyi@201
   131
    /// where to save the map
ladanyi@201
   132
    MapSaveDest save_dest;
ladanyi@201
   133
    /// read-only or read-write
ladanyi@201
   134
    bool writeable;
ladanyi@201
   135
    /// default value
ladanyi@201
   136
    MapValue default_value;
ladanyi@201
   137
    virtual MapValue::Type type() = 0;
ladanyi@201
   138
    virtual MapValue get(Node e) = 0;
ladanyi@201
   139
    virtual void set(Node e, MapValue v) = 0;
ladanyi@201
   140
    NodeMapData(MapValue def_val) :
ladanyi@201
   141
      save_dest(GUI_SECT),
ladanyi@201
   142
      writeable(true),
ladanyi@201
   143
      default_value(def_val)
ladanyi@201
   144
    {}
ladanyi@201
   145
  };
ladanyi@201
   146
ladanyi@201
   147
  struct NumericNodeMapData : public NodeMapData
ladanyi@201
   148
  {
ladanyi@201
   149
    NumericNodeMap map;
ladanyi@201
   150
    MapValue::Type type() { return MapValue::NUMERIC; }
ladanyi@201
   151
    MapValue get(Node e) { return MapValue(map[e]); }
ladanyi@201
   152
    void set(Node e, MapValue v) { map.set(e, static_cast<double>(v)); }
ladanyi@201
   153
    NumericNodeMapData(Graph& g, double def_val) :
ladanyi@201
   154
      NodeMapData(MapValue(def_val)),
ladanyi@201
   155
      map(g, def_val)
ladanyi@201
   156
    {}
ladanyi@201
   157
  };
ladanyi@201
   158
ladanyi@201
   159
  struct StringNodeMapData : public NodeMapData
ladanyi@201
   160
  {
ladanyi@201
   161
    StringNodeMap map;
ladanyi@201
   162
    MapValue::Type type() { return MapValue::STRING; }
ladanyi@201
   163
    MapValue get(Node e) { return MapValue(map[e]); }
ladanyi@201
   164
    void set(Node e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
ladanyi@201
   165
    StringNodeMapData(Graph& g, std::string def_val) :
ladanyi@201
   166
      NodeMapData(MapValue(def_val)),
ladanyi@201
   167
      map(g, def_val)
ladanyi@201
   168
    {}
ladanyi@201
   169
  };
ladanyi@201
   170
ladanyi@201
   171
  typedef std::map<std::string, NodeMapData*> NodeMapStore;
ladanyi@201
   172
  typedef std::map<std::string, EdgeMapData*> EdgeMapStore;
ladanyi@201
   173
ladanyi@201
   174
  struct GUISectData
ladanyi@201
   175
  {
ladanyi@201
   176
    std::vector<std::string> main_node_map_names;
ladanyi@201
   177
    std::vector<std::string> main_edge_map_names;
ladanyi@201
   178
ladanyi@201
   179
    std::vector<std::string> gui_node_map_names;
ladanyi@201
   180
    std::vector<std::string> gui_edge_map_names;
ladanyi@201
   181
ladanyi@201
   182
    std::map<std::string, MapValue::Type> node_map_types;
ladanyi@201
   183
    std::map<std::string, MapValue::Type> edge_map_types;
ladanyi@201
   184
ladanyi@201
   185
    std::map<std::string, std::map<int, double>* > numeric_node_maps;
ladanyi@201
   186
    std::map<std::string, std::map<int, std::string>* > string_node_maps;
ladanyi@201
   187
ladanyi@201
   188
    std::map<std::string, std::map<int, double>* > numeric_edge_maps;
ladanyi@201
   189
    std::map<std::string, std::map<int, std::string>* > string_edge_maps;
ladanyi@201
   190
ladanyi@201
   191
    std::map<int, XY> node_coord_map;
ladanyi@201
   192
    std::map<int, XY> arrow_coord_map;
ladanyi@201
   193
ladanyi@201
   194
    SpecMapSaveOpts::Dest node_coords_save_dest;
ladanyi@201
   195
    SpecMapSaveOpts::MapNum node_coords_save_map_num;
ladanyi@201
   196
    std::string node_coords_one_map_name;
ladanyi@201
   197
    std::string node_coords_two_maps_1_name;
ladanyi@201
   198
    std::string node_coords_two_maps_2_name;
ladanyi@201
   199
ladanyi@201
   200
    SpecMapSaveOpts::Dest arrow_coords_save_dest;
ladanyi@201
   201
    SpecMapSaveOpts::MapNum arrow_coords_save_map_num;
ladanyi@201
   202
    std::string arrow_coords_one_map_name;
ladanyi@201
   203
    std::string arrow_coords_two_maps_1_name;
ladanyi@201
   204
    std::string arrow_coords_two_maps_2_name;
ladanyi@201
   205
ladanyi@201
   206
    ~GUISectData()
ladanyi@201
   207
    {
ladanyi@201
   208
      using std::map;
ladanyi@201
   209
      using std::vector;
ladanyi@201
   210
      using std::pair;
ladanyi@201
   211
      using std::string;
ladanyi@201
   212
ladanyi@201
   213
      for (map<string, map<int, double>* >::iterator it =
ladanyi@201
   214
          numeric_node_maps.begin(); it != numeric_node_maps.end(); ++it)
ladanyi@201
   215
      {
ladanyi@201
   216
        delete it->second;
ladanyi@201
   217
      }
ladanyi@201
   218
      for (map<string, map<int, string>* >::iterator it =
ladanyi@201
   219
          string_node_maps.begin(); it != string_node_maps.end(); ++it)
ladanyi@201
   220
      {
ladanyi@201
   221
        delete it->second;
ladanyi@201
   222
      }
ladanyi@201
   223
      for (map<string, map<int, double>* >::iterator it =
ladanyi@201
   224
          numeric_edge_maps.begin(); it != numeric_edge_maps.end(); ++it)
ladanyi@201
   225
      {
ladanyi@201
   226
        delete it->second;
ladanyi@201
   227
      }
ladanyi@201
   228
      for (map<string, map<int, string>* >::iterator it =
ladanyi@201
   229
          string_edge_maps.begin(); it != string_edge_maps.end(); ++it)
ladanyi@201
   230
      {
ladanyi@201
   231
        delete it->second;
ladanyi@201
   232
      }
ladanyi@201
   233
    }
ladanyi@201
   234
  };
ladanyi@201
   235
public:
hegyi@118
   236
  ///The graph for which the datas are stored.
ladanyi@53
   237
  Graph graph;
ladanyi@201
   238
  const Graph& getGraph();
ladanyi@201
   239
ladanyi@201
   240
private:
ladanyi@201
   241
  GuiSectSaveDest gui_sect_save_dest;
ladanyi@201
   242
ladanyi@201
   243
  SpecMapSaveOpts::Dest node_coords_save_dest;
ladanyi@201
   244
  SpecMapSaveOpts::MapNum node_coords_save_map_num;
ladanyi@201
   245
  SpecMapSaveOpts::Dest arrow_coords_save_dest;
ladanyi@201
   246
  SpecMapSaveOpts::MapNum arrow_coords_save_map_num;
ladanyi@201
   247
ladanyi@201
   248
  NodeMapStore nodemaps;
ladanyi@201
   249
  EdgeMapStore edgemaps;
ladanyi@201
   250
ladanyi@201
   251
  NodeLabelMap node_label;
ladanyi@201
   252
  EdgeLabelMap edge_label;
ladanyi@201
   253
ladanyi@98
   254
  /// the coordinates of the nodes
ladanyi@201
   255
  NodeCoordMap node_coords;
ladanyi@201
   256
  Graph::NodeMap<double> node_coords_x;
ladanyi@201
   257
  Graph::NodeMap<double> node_coords_y;
ladanyi@201
   258
ladanyi@98
   259
  /// the coordinates of the arrows on the edges
ladanyi@201
   260
  ArrowCoordMap arrow_coords;
ladanyi@201
   261
  Graph::EdgeMap<double> arrow_coords_x;
ladanyi@201
   262
  Graph::EdgeMap<double> arrow_coords_y;
ladanyi@53
   263
hegyi@118
   264
  ///The content of the object has changed, update is needed.
ladanyi@53
   265
  bool modified;
hegyi@118
   266
hegyi@118
   267
  ///Name of file loaded in object.
ladanyi@53
   268
  std::string file_name;
ladanyi@6
   269
ladanyi@201
   270
  // the largest node label
ladanyi@201
   271
  int max_node_label;
ladanyi@6
   272
ladanyi@201
   273
  // the largest edge label
ladanyi@201
   274
  int max_edge_label;
ladanyi@6
   275
ladanyi@201
   276
  std::string node_coords_one_map_name;
ladanyi@201
   277
  std::string node_coords_two_maps_1_name;
ladanyi@201
   278
  std::string node_coords_two_maps_2_name;
ladanyi@201
   279
ladanyi@201
   280
  std::string arrow_coords_one_map_name;
ladanyi@201
   281
  std::string arrow_coords_two_maps_1_name;
ladanyi@201
   282
  std::string arrow_coords_two_maps_2_name;
ladanyi@201
   283
ladanyi@201
   284
public:
hegyi@118
   285
  ///Stores the default values for the different visualization node attributes
ladanyi@6
   286
  std::vector<Graph::NodeMap<double> > default_nodemaps;
ladanyi@6
   287
hegyi@118
   288
  ///Stores the default values for the different visualization edge attributes
ladanyi@6
   289
  std::vector<Graph::EdgeMap<double> > default_edgemaps;
ladanyi@6
   290
hegyi@118
   291
  ///Stores the active maps for the different visualization node attributes
hegyi@94
   292
  std::vector< std::string > active_nodemaps;
hegyi@94
   293
hegyi@118
   294
  /// Stores the active maps for the different visualization edge attributes
hegyi@94
   295
  std::vector< std::string > active_edgemaps;
hegyi@94
   296
hegyi@94
   297
protected:
hegyi@118
   298
hegyi@177
   299
  /// Signal emitted on any change made on map values
hegyi@177
   300
hegyi@177
   301
  /// Signal emitted if the visualization of the maps might have to be updated.
hegyi@118
   302
  /// bool shows us whether the changed map is edge or nodemap.
hegyi@118
   303
  /// int tells us the refreshed property
hegyi@177
   304
  sigc::signal<void, bool, int> signal_prop;
hegyi@118
   305
hegyi@118
   306
  /// Signal emitted in the case of nodemap addition
hegyi@118
   307
hegyi@118
   308
  /// std::string is the
hegyi@118
   309
  ///name of the new map
ladanyi@201
   310
  sigc::signal<void, std::string, MapValue::Type> signal_node_map;
hegyi@118
   311
hegyi@118
   312
  /// Signal emitted in the case of edgemap addition
hegyi@118
   313
hegyi@118
   314
  /// std::string is the
hegyi@118
   315
  ///name of the new map
ladanyi@201
   316
  sigc::signal<void, std::string, MapValue::Type> signal_edge_map;
hegyi@94
   317
hegyi@172
   318
  /// Signal emitted, when entry in \ref MapWin should be changed.
hegyi@172
   319
  sigc::signal<void, bool, int, std::string> signal_map_win;
hegyi@172
   320
hegyi@177
   321
  /// Signal emitted, when entry in \ref DesignWin should be changed.
hegyi@177
   322
  sigc::signal<void, double, double, int> signal_design_win;
hegyi@177
   323
hegyi@195
   324
  ///Signal emitted when background should be set by \ref NoteBookTab
hegyi@195
   325
  sigc::signal<void> signal_background;
hegyi@195
   326
hegyi@177
   327
  ///Iteration number during graph design
hegyi@177
   328
  int iterations;
hegyi@177
   329
hegyi@177
   330
  ///Attraction factor during graph design
hegyi@177
   331
  double attraction;
hegyi@177
   332
hegyi@177
   333
  ///Propulsation factor during graph design
hegyi@177
   334
  double propulsation;
hegyi@177
   335
ladanyi@6
   336
public:
hegyi@118
   337
  ///Constructor of MapStorage.
hegyi@118
   338
ladanyi@6
   339
  ///Its all activity is initializing default values
hegyi@118
   340
  ///for different visualization attributes.
hegyi@195
   341
  MapStorage();
ladanyi@53
   342
hegyi@118
   343
  ///Destructor of MapStorage
hegyi@118
   344
hegyi@118
   345
  ///Maps stored here are created with new. Destructor
hegyi@118
   346
  ///deletes them to free up the reserved memory.
ladanyi@53
   347
  ~MapStorage();
ladanyi@6
   348
hegyi@118
   349
  /// Registrates if the shown map by any attribute has changed to another.
hegyi@94
   350
hegyi@118
   351
  ///It handles the \ref active_edgemaps and
hegyi@118
   352
  ///\ref active_nodemaps vectors. It also emits \ref signal_prop signal to let
hegyi@118
   353
  ///know the interested objects that the visible map of a certain
hegyi@118
   354
  ///attribute has changed.
hegyi@118
   355
  ///\param itisedge edgemap or nodemap has changed
hegyi@118
   356
  ///\param prop the property of which the map is changed
hegyi@118
   357
  ///\param mapname the visible map
hegyi@118
   358
  void changeActiveMap(bool itisedge , int prop , std::string mapname);
hegyi@94
   359
hegyi@172
   360
  ///Emits signals that let change the active maps in \ref MapWin.
hegyi@172
   361
  void broadcastActiveMaps();
hegyi@172
   362
hegyi@118
   363
  /// Returns the active edgemap shown by a visualization property.
hegyi@118
   364
hegyi@118
   365
  /// \param prop is the property
hegyi@118
   366
  ///that shows the requested map.
hegyi@118
   367
  std::string getActiveEdgeMap(int prop);
hegyi@118
   368
hegyi@118
   369
  /// Returns the active nodemap shown by a visualization property.
hegyi@118
   370
hegyi@118
   371
  /// \param prop is the property
hegyi@118
   372
  ///that shows the requested map.
hegyi@118
   373
  std::string getActiveNodeMap(int prop);
hegyi@118
   374
hegyi@118
   375
  /// Returns the names of the edgemaps stored here.
ladanyi@201
   376
  std::vector<std::string> getEdgeMapList(MapType type = ALL);
hegyi@118
   377
hegyi@118
   378
  /// Returns the names of the nodemaps stored here.
ladanyi@201
   379
  std::vector<std::string> getNodeMapList(MapType type = ALL);
hegyi@94
   380
hegyi@118
   381
  ///returns \ref signal_prop to be able to connect functions to it
hegyi@177
   382
  sigc::signal<void, bool, int> signal_prop_ch();
hegyi@94
   383
hegyi@118
   384
  ///returns \ref signal_node_map to be able to connect functions to it
ladanyi@201
   385
  sigc::signal<void, std::string, MapValue::Type> signal_node_map_ch(){return signal_node_map;};
hegyi@118
   386
hegyi@118
   387
  ///returns \ref signal_edge_map to be able to connect functions to it
ladanyi@201
   388
  sigc::signal<void, std::string, MapValue::Type> signal_edge_map_ch(){return signal_edge_map;};
hegyi@108
   389
hegyi@172
   390
  ///returns \ref signal_map_win to be able to connect functions to it
hegyi@172
   391
  sigc::signal<void, bool, int, std::string> signal_map_win_ch(){return signal_map_win;};
hegyi@172
   392
hegyi@177
   393
  ///returns \ref signal_design_win to be able to connect functions to it
hegyi@177
   394
  sigc::signal<void, double, double, int> signal_design_win_ch(){return signal_design_win;};
hegyi@177
   395
ladanyi@201
   396
  void createNodeMap(const std::string& name, MapValue::Type type,
ladanyi@201
   397
    MapValue def_val);
ladanyi@201
   398
  void createEdgeMap(const std::string& name, MapValue::Type type,
ladanyi@201
   399
    MapValue def_val);
ladanyi@201
   400
hegyi@195
   401
  ///returns \ref signal_background to be able to connect functions to it
hegyi@195
   402
  sigc::signal<void> signal_background_ch(){return signal_background;};
hegyi@195
   403
hegyi@195
   404
hegyi@118
   405
  ///Adds given map to storage.
hegyi@118
   406
hegyi@118
   407
  ///Emits \ref signal_prop if mapvalues have changed, and MapStorage gets to know it.
hegyi@111
   408
hegyi@118
   409
  ///If values in a map have changed, this function checks, whether it is displayed.
hegyi@118
   410
  ///This check means searching the given mapname between active maps
hegyi@118
   411
  ///(\ref active_nodemaps, \ref active_edgemaps). If it is there at a certain property,
hegyi@118
   412
  ///it emits a signal with the property, where the gotten mapname was found. One signal
hegyi@118
   413
  ///is emitted for each property displaying the given map.
hegyi@118
   414
  ///\param itisedge whether the map an edgemap or nodemap
hegyi@118
   415
  ///\param mapname name of map to visualize
hegyi@118
   416
  void mapChanged(bool itisedge, std::string mapname);
hegyi@118
   417
hegyi@118
   418
  ///Read datas from the given filename.
ladanyi@63
   419
  int readFromFile(const std::string &);
hegyi@118
   420
hegyi@118
   421
  ///Save datas to the given filename.
ladanyi@53
   422
  void writeToFile(const std::string &);
ladanyi@53
   423
hegyi@118
   424
  ///Deletes all datastructures stored here.
ladanyi@53
   425
  void clear();
ladanyi@98
   426
hegyi@177
   427
  void get_design_data(double &, double &, int &);
hegyi@177
   428
  void set_attraction(double);
hegyi@177
   429
  void set_propulsation(double);
hegyi@177
   430
  void set_iteration(int);
hegyi@177
   431
hegyi@177
   432
  void redesign_data_changed();
hegyi@191
   433
ladanyi@201
   434
  XY getNodeCoords(Node n) const;
ladanyi@201
   435
  void setNodeCoords(Node n, XY c);
ladanyi@201
   436
  XY getArrowCoords(Edge e) const;
ladanyi@201
   437
  void setArrowCoords(Edge e, XY c);
ladanyi@201
   438
ladanyi@201
   439
  MapValue get(const std::string& name, Node node) const;
ladanyi@201
   440
  void set(const std::string& name, Node node, MapValue val);
ladanyi@201
   441
  MapValue get(const std::string& name, Edge edge) const;
ladanyi@201
   442
  void set(const std::string& name, Edge edge, MapValue val);
ladanyi@201
   443
ladanyi@201
   444
  const std::string& getFileName() const;
ladanyi@201
   445
  void setFileName(const std::string& fn);
ladanyi@201
   446
ladanyi@201
   447
  bool getModified() const;
ladanyi@201
   448
  void setModified(bool m = true);
ladanyi@201
   449
ladanyi@201
   450
  Node addNode(XY);
ladanyi@201
   451
  Edge addEdge(Node, Node);
ladanyi@201
   452
ladanyi@201
   453
  NumericNodeMap& getNumericNodeMap(const std::string& name);
ladanyi@201
   454
  StringNodeMap& getStringNodeMap(const std::string& name);
ladanyi@201
   455
  NumericEdgeMap& getNumericEdgeMap(const std::string& name);
ladanyi@201
   456
  StringEdgeMap& getStringEdgeMap(const std::string& name);
ladanyi@201
   457
ladanyi@201
   458
  MapValueEdgeMap getEdgeMap(const std::string& name);
ladanyi@201
   459
  MapValueNodeMap getNodeMap(const std::string& name);
ladanyi@201
   460
ladanyi@201
   461
  int getLabel(Node) const;
ladanyi@201
   462
  int getLabel(Edge) const;
ladanyi@201
   463
ladanyi@201
   464
  GuiSectSaveDest getGUIDataSaveLocation();
ladanyi@201
   465
  void setGUIDataSaveLocation(GuiSectSaveDest dest);
ladanyi@201
   466
ladanyi@201
   467
  MapSaveDest getNodeMapSaveDest(std::string name) const;
ladanyi@201
   468
  MapSaveDest getEdgeMapSaveDest(std::string name) const;
ladanyi@201
   469
  void setNodeMapSaveDest(std::string name, MapSaveDest dest);
ladanyi@201
   470
  void setEdgeMapSaveDest(std::string name, MapSaveDest dest);
ladanyi@201
   471
ladanyi@201
   472
  SpecMapSaveOpts::Dest getNodeCoordsSaveDest();
ladanyi@201
   473
  SpecMapSaveOpts::Dest getArrowCoordsSaveDest();
ladanyi@201
   474
  void setNodeCoordsSaveDest(SpecMapSaveOpts::Dest dest);
ladanyi@201
   475
  void setArrowCoordsSaveDest(SpecMapSaveOpts::Dest dest);
ladanyi@201
   476
ladanyi@201
   477
  SpecMapSaveOpts::MapNum getNodeCoordsSaveMapNum();
ladanyi@201
   478
  SpecMapSaveOpts::MapNum getArrowCoordsSaveMapNum();
ladanyi@201
   479
  void setNodeCoordsSaveMapNum(SpecMapSaveOpts::MapNum num);
ladanyi@201
   480
  void setArrowCoordsSaveMapNum(SpecMapSaveOpts::MapNum num);
ladanyi@201
   481
ladanyi@201
   482
  MapValue::Type getNodeMapElementType(std::string name) const;
ladanyi@201
   483
  MapValue::Type getEdgeMapElementType(std::string name) const;
ladanyi@201
   484
ladanyi@201
   485
  const NodeLabelMap& getNodeLabelMap();
ladanyi@201
   486
  const EdgeLabelMap& getEdgeLabelMap();
ladanyi@201
   487
ladanyi@201
   488
  bool nodeMapExists(std::string name);
ladanyi@201
   489
  bool edgeMapExists(std::string name);
ladanyi@201
   490
ladanyi@201
   491
  std::vector<std::string> getEdgeMaps(MapType type = ALL);
ladanyi@201
   492
  std::vector<std::string> getNodeMaps(MapType type = ALL);
ladanyi@201
   493
ladanyi@201
   494
  NodeCoordMap& getNodeCoordMap();
ladanyi@201
   495
  ArrowCoordMap& getArrowCoordMap();
ladanyi@201
   496
ladanyi@201
   497
  const std::string& getNodeCoordsOneMapName();
ladanyi@201
   498
  const std::string& getNodeCoordsTwoMaps1Name();
ladanyi@201
   499
  const std::string& getNodeCoordsTwoMaps2Name();
ladanyi@201
   500
  void setNodeCoordsOneMapName(const std::string& name);
ladanyi@201
   501
  void setNodeCoordsTwoMaps1Name(const std::string& name);
ladanyi@201
   502
  void setNodeCoordsTwoMaps2Name(const std::string& name);
ladanyi@201
   503
ladanyi@201
   504
  const std::string& getArrowCoordsOneMapName();
ladanyi@201
   505
  const std::string& getArrowCoordsTwoMaps1Name();
ladanyi@201
   506
  const std::string& getArrowCoordsTwoMaps2Name();
ladanyi@201
   507
  void setArrowCoordsOneMapName(const std::string& name);
ladanyi@201
   508
  void setArrowCoordsTwoMaps1Name(const std::string& name);
ladanyi@201
   509
  void setArrowCoordsTwoMaps2Name(const std::string& name);
ladanyi@201
   510
ladanyi@201
   511
private:
ladanyi@201
   512
  EdgeMapData* getEdgeMapData(std::string name) const;
ladanyi@201
   513
  NodeMapData* getNodeMapData(std::string name) const;
ladanyi@201
   514
  void readLGF(
ladanyi@201
   515
      const std::string& filename,
ladanyi@201
   516
      bool read_edge_label,
ladanyi@201
   517
      const std::vector<std::string>& node_map_names,
ladanyi@201
   518
      const std::vector<std::string>& edge_map_names,
ladanyi@201
   519
      const std::map<std::string, MapValue::Type>& node_map_types,
ladanyi@201
   520
      const std::map<std::string, MapValue::Type>& edge_map_types,
ladanyi@201
   521
      const std::string& node_coord_xmap_name,
ladanyi@201
   522
      const std::string& node_coord_ymap_name,
ladanyi@201
   523
      const std::string& arrow_coord_xmap_name,
ladanyi@201
   524
      const std::string& arrow_coord_ymap_name);
ladanyi@201
   525
ladanyi@201
   526
public:
hegyi@198
   527
  void exportGraphToEPS(std::vector<bool>, std::string, std::string);
ladanyi@6
   528
};
ladanyi@6
   529
ladanyi@6
   530
#endif //MAPSTORAGE_H