gui/graph-displayer.cc
author ladanyi
Tue, 12 Jul 2005 13:36:01 +0000
changeset 1545 e8378402f97e
parent 1504 4b14c60ecb2b
child 1606 dc4ea2010dee
permissions -rw-r--r--
Added the individual png files to EXTRA_DIST instead of the icons directory. This way the .svn directories do not get in the tarball. An alternative solution would be to delete these in a dist-hook target.
ladanyi@1412
     1
#include <all_include.h>
ladanyi@1412
     2
#include <mapstorage.h>
ladanyi@1412
     3
#include <main_win.h>
ladanyi@1412
     4
#include <libgnomecanvasmm.h>
ladanyi@1412
     5
#include <libgnomecanvasmm/polygon.h>
ladanyi@1412
     6
ladanyi@1412
     7
#define MAIN_PART
ladanyi@1412
     8
hegyi@1512
     9
std::vector <std::string> edge_property_strings;
hegyi@1512
    10
std::vector <double> edge_property_defaults;
hegyi@1512
    11
std::vector <std::string> node_property_strings;
hegyi@1512
    12
std::vector <double> node_property_defaults;
ladanyi@1412
    13
ladanyi@1412
    14
ladanyi@1412
    15
int main(int argc, char *argv[])
ladanyi@1412
    16
{
hegyi@1440
    17
hegyi@1440
    18
  //initializing
hegyi@1440
    19
hegyi@1512
    20
  edge_property_strings.resize(EDGE_PROPERTY_NUM);
hegyi@1512
    21
  edge_property_strings[E_WIDTH]="Edge Width";
hegyi@1512
    22
  edge_property_strings[E_COLOR]="Edge Color";
hegyi@1512
    23
  edge_property_strings[E_TEXT]="Edge Text";
ladanyi@1412
    24
hegyi@1512
    25
  edge_property_defaults.resize(EDGE_PROPERTY_NUM);
hegyi@1512
    26
  edge_property_defaults[E_WIDTH]=10.0;
hegyi@1512
    27
  edge_property_defaults[E_COLOR]=100;
hegyi@1512
    28
  edge_property_defaults[E_TEXT]=0;
hegyi@1512
    29
hegyi@1512
    30
  node_property_strings.resize(NODE_PROPERTY_NUM);
hegyi@1512
    31
  node_property_strings[N_RADIUS]="Node Radius";
hegyi@1512
    32
  node_property_strings[N_COLOR]="Node Color";
hegyi@1512
    33
  node_property_strings[N_TEXT]="Node Text";
hegyi@1512
    34
hegyi@1512
    35
  node_property_defaults.resize(NODE_PROPERTY_NUM);
hegyi@1512
    36
  node_property_defaults[N_RADIUS]=20.0;
hegyi@1512
    37
  node_property_defaults[N_COLOR]=100;
hegyi@1512
    38
  node_property_defaults[N_TEXT]=0;
ladanyi@1412
    39
ladanyi@1412
    40
  if(argc<2)
ladanyi@1412
    41
  {
ladanyi@1412
    42
      std::cerr << "USAGE: gd <input filename.lgf>" << std::endl;
ladanyi@1412
    43
      return 0;
ladanyi@1412
    44
  }
ladanyi@1412
    45
ladanyi@1412
    46
  Coordinates coosvector;
ladanyi@1412
    47
ladanyi@1412
    48
  Graph g;
ladanyi@1412
    49
ladanyi@1412
    50
  CoordinatesMap cm(g);
ladanyi@1412
    51
  Graph::EdgeMap<double> cap(g), map1(g), map2(g), map3(g), map4(g);
hegyi@1440
    52
  Graph::NodeMap<double> nodedata (g);
ladanyi@1412
    53
ladanyi@1412
    54
  //we create one object to read x coordinates
ladanyi@1412
    55
  //and one to read y coordinate of nodes and write them to cm NodeMap.
ladanyi@1412
    56
  XMap <CoordinatesMap> xreader (cm);
ladanyi@1412
    57
  YMap <CoordinatesMap> yreader (cm);
hegyi@1440
    58
hegyi@1440
    59
  //reading in graph and its maps
ladanyi@1412
    60
ladanyi@1412
    61
  std::ifstream is(argv[1]);
ladanyi@1412
    62
ladanyi@1412
    63
  GraphReader<Graph> reader(is, g);
ladanyi@1412
    64
  reader.readNodeMap("coordinates_x", xreader);
ladanyi@1412
    65
  reader.readNodeMap("coordinates_y", yreader);
ladanyi@1412
    66
  reader.readNodeMap("data", nodedata);
ladanyi@1412
    67
  reader.readEdgeMap("cap", cap);
ladanyi@1412
    68
  reader.readEdgeMap("map1", map1);
ladanyi@1412
    69
  reader.readEdgeMap("map2", map2);
ladanyi@1412
    70
  reader.readEdgeMap("map3", map3);
ladanyi@1412
    71
  reader.readEdgeMap("map4", map4);
ladanyi@1412
    72
  reader.run();
ladanyi@1412
    73
hegyi@1440
    74
  //initializing MapStorage with the read data
hegyi@1440
    75
ladanyi@1412
    76
  MapStorage ms(g);
ladanyi@1412
    77
  ms.addNodeMap("data",&nodedata);
ladanyi@1412
    78
  ms.addEdgeMap("cap",&cap);
ladanyi@1412
    79
  ms.addEdgeMap("map1",&map1);
ladanyi@1412
    80
  ms.addEdgeMap("map2",&map2);
ladanyi@1412
    81
  ms.addEdgeMap("map3",&map3);
ladanyi@1412
    82
  ms.addEdgeMap("map4",&map4);
ladanyi@1412
    83
hegyi@1440
    84
  //initializing GUI
hegyi@1440
    85
ladanyi@1412
    86
  Gnome::Canvas::init();
ladanyi@1412
    87
  Gtk::Main app(argc, argv);
ladanyi@1412
    88
ladanyi@1412
    89
  MainWin mainwin("Displayed Graph", g, cm, ms);
ladanyi@1412
    90
  app.run(mainwin);
ladanyi@1412
    91
ladanyi@1412
    92
  return 0;
ladanyi@1412
    93
}