src/gui/graph-displayer.cc
author alpar
Thu, 19 May 2005 11:46:42 +0000
changeset 1428 9ba88ddc629c
permissions -rw-r--r--
A very simple xml parser
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
ladanyi@1412
     9
std::string * property_strings;
ladanyi@1412
    10
double * property_defaults;
ladanyi@1412
    11
ladanyi@1412
    12
ladanyi@1412
    13
int main(int argc, char *argv[])
ladanyi@1412
    14
{
ladanyi@1412
    15
  property_strings=new std::string[PROPERTY_NUM];
ladanyi@1412
    16
  property_strings[WIDTH]="Width";
ladanyi@1412
    17
  property_strings[COLOR]="Color";
ladanyi@1412
    18
  property_strings[TEXT]="Text";
ladanyi@1412
    19
ladanyi@1412
    20
  property_defaults=new double[PROPERTY_NUM];
ladanyi@1412
    21
  property_defaults[WIDTH]=10.0;
ladanyi@1412
    22
  property_defaults[COLOR]=100;
ladanyi@1412
    23
  property_defaults[TEXT]=0;
ladanyi@1412
    24
ladanyi@1412
    25
  if(argc<2)
ladanyi@1412
    26
  {
ladanyi@1412
    27
      std::cerr << "USAGE: gd <input filename.lgf>" << std::endl;
ladanyi@1412
    28
      return 0;
ladanyi@1412
    29
  }
ladanyi@1412
    30
ladanyi@1412
    31
  Coordinates coosvector;
ladanyi@1412
    32
ladanyi@1412
    33
  Graph g;
ladanyi@1412
    34
ladanyi@1412
    35
  CoordinatesMap cm(g);
ladanyi@1412
    36
  Graph::EdgeMap<double> cap(g), map1(g), map2(g), map3(g), map4(g);
ladanyi@1412
    37
ladanyi@1412
    38
  //we create one object to read x coordinates
ladanyi@1412
    39
  //and one to read y coordinate of nodes and write them to cm NodeMap.
ladanyi@1412
    40
ladanyi@1412
    41
  XMap <CoordinatesMap> xreader (cm);
ladanyi@1412
    42
  YMap <CoordinatesMap> yreader (cm);
ladanyi@1412
    43
  Graph::NodeMap<double> nodedata (g);
ladanyi@1412
    44
ladanyi@1412
    45
  std::ifstream is(argv[1]);
ladanyi@1412
    46
ladanyi@1412
    47
  GraphReader<Graph> reader(is, g);
ladanyi@1412
    48
  reader.readNodeMap("coordinates_x", xreader);
ladanyi@1412
    49
  reader.readNodeMap("coordinates_y", yreader);
ladanyi@1412
    50
  reader.readNodeMap("data", nodedata);
ladanyi@1412
    51
  reader.readEdgeMap("cap", cap);
ladanyi@1412
    52
  reader.readEdgeMap("map1", map1);
ladanyi@1412
    53
  reader.readEdgeMap("map2", map2);
ladanyi@1412
    54
  reader.readEdgeMap("map3", map3);
ladanyi@1412
    55
  reader.readEdgeMap("map4", map4);
ladanyi@1412
    56
  reader.run();
ladanyi@1412
    57
ladanyi@1412
    58
  MapStorage ms(g);
ladanyi@1412
    59
  ms.addNodeMap("data",&nodedata);
ladanyi@1412
    60
  ms.addEdgeMap("cap",&cap);
ladanyi@1412
    61
  ms.addEdgeMap("map1",&map1);
ladanyi@1412
    62
  ms.addEdgeMap("map2",&map2);
ladanyi@1412
    63
  ms.addEdgeMap("map3",&map3);
ladanyi@1412
    64
  ms.addEdgeMap("map4",&map4);
ladanyi@1412
    65
ladanyi@1412
    66
  Gnome::Canvas::init();
ladanyi@1412
    67
  Gtk::Main app(argc, argv);
ladanyi@1412
    68
ladanyi@1412
    69
  MainWin mainwin("Displayed Graph", g, cm, ms);
ladanyi@1412
    70
  app.run(mainwin);
ladanyi@1412
    71
ladanyi@1412
    72
  return 0;
ladanyi@1412
    73
}