gui/graph-displayer.cc
author athos
Fri, 10 Jun 2005 12:50:43 +0000
changeset 1473 876c7b7f4dae
parent 1435 8e85e6bbefdf
child 1503 97836166605d
permissions -rw-r--r--
Some tests have been developed, bugs got fixed.
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
{
hegyi@1440
    15
hegyi@1440
    16
  //initializing
hegyi@1440
    17
ladanyi@1412
    18
  property_strings=new std::string[PROPERTY_NUM];
ladanyi@1412
    19
  property_strings[WIDTH]="Width";
ladanyi@1412
    20
  property_strings[COLOR]="Color";
ladanyi@1412
    21
  property_strings[TEXT]="Text";
ladanyi@1412
    22
ladanyi@1412
    23
  property_defaults=new double[PROPERTY_NUM];
ladanyi@1412
    24
  property_defaults[WIDTH]=10.0;
ladanyi@1412
    25
  property_defaults[COLOR]=100;
ladanyi@1412
    26
  property_defaults[TEXT]=0;
ladanyi@1412
    27
ladanyi@1412
    28
  if(argc<2)
ladanyi@1412
    29
  {
ladanyi@1412
    30
      std::cerr << "USAGE: gd <input filename.lgf>" << std::endl;
ladanyi@1412
    31
      return 0;
ladanyi@1412
    32
  }
ladanyi@1412
    33
ladanyi@1412
    34
  Coordinates coosvector;
ladanyi@1412
    35
ladanyi@1412
    36
  Graph g;
ladanyi@1412
    37
ladanyi@1412
    38
  CoordinatesMap cm(g);
ladanyi@1412
    39
  Graph::EdgeMap<double> cap(g), map1(g), map2(g), map3(g), map4(g);
hegyi@1440
    40
  Graph::NodeMap<double> nodedata (g);
ladanyi@1412
    41
ladanyi@1412
    42
  //we create one object to read x coordinates
ladanyi@1412
    43
  //and one to read y coordinate of nodes and write them to cm NodeMap.
ladanyi@1412
    44
  XMap <CoordinatesMap> xreader (cm);
ladanyi@1412
    45
  YMap <CoordinatesMap> yreader (cm);
hegyi@1440
    46
hegyi@1440
    47
  //reading in graph and its maps
ladanyi@1412
    48
ladanyi@1412
    49
  std::ifstream is(argv[1]);
ladanyi@1412
    50
ladanyi@1412
    51
  GraphReader<Graph> reader(is, g);
ladanyi@1412
    52
  reader.readNodeMap("coordinates_x", xreader);
ladanyi@1412
    53
  reader.readNodeMap("coordinates_y", yreader);
ladanyi@1412
    54
  reader.readNodeMap("data", nodedata);
ladanyi@1412
    55
  reader.readEdgeMap("cap", cap);
ladanyi@1412
    56
  reader.readEdgeMap("map1", map1);
ladanyi@1412
    57
  reader.readEdgeMap("map2", map2);
ladanyi@1412
    58
  reader.readEdgeMap("map3", map3);
ladanyi@1412
    59
  reader.readEdgeMap("map4", map4);
ladanyi@1412
    60
  reader.run();
ladanyi@1412
    61
hegyi@1440
    62
  //initializing MapStorage with the read data
hegyi@1440
    63
ladanyi@1412
    64
  MapStorage ms(g);
ladanyi@1412
    65
  ms.addNodeMap("data",&nodedata);
ladanyi@1412
    66
  ms.addEdgeMap("cap",&cap);
ladanyi@1412
    67
  ms.addEdgeMap("map1",&map1);
ladanyi@1412
    68
  ms.addEdgeMap("map2",&map2);
ladanyi@1412
    69
  ms.addEdgeMap("map3",&map3);
ladanyi@1412
    70
  ms.addEdgeMap("map4",&map4);
ladanyi@1412
    71
hegyi@1440
    72
  //initializing GUI
hegyi@1440
    73
ladanyi@1412
    74
  Gnome::Canvas::init();
ladanyi@1412
    75
  Gtk::Main app(argc, argv);
ladanyi@1412
    76
ladanyi@1412
    77
  MainWin mainwin("Displayed Graph", g, cm, ms);
ladanyi@1412
    78
  app.run(mainwin);
ladanyi@1412
    79
ladanyi@1412
    80
  return 0;
ladanyi@1412
    81
}