gui/graph-displayer.cc
author ladanyi
Tue, 14 Jun 2005 22:51:22 +0000
changeset 1490 fa2b73784343
parent 1435 8e85e6bbefdf
child 1503 97836166605d
permissions -rw-r--r--
Added support for building deb packages.
     1 #include <all_include.h>
     2 #include <mapstorage.h>
     3 #include <main_win.h>
     4 #include <libgnomecanvasmm.h>
     5 #include <libgnomecanvasmm/polygon.h>
     6 
     7 #define MAIN_PART
     8 
     9 std::string * property_strings;
    10 double * property_defaults;
    11 
    12 
    13 int main(int argc, char *argv[])
    14 {
    15 
    16   //initializing
    17 
    18   property_strings=new std::string[PROPERTY_NUM];
    19   property_strings[WIDTH]="Width";
    20   property_strings[COLOR]="Color";
    21   property_strings[TEXT]="Text";
    22 
    23   property_defaults=new double[PROPERTY_NUM];
    24   property_defaults[WIDTH]=10.0;
    25   property_defaults[COLOR]=100;
    26   property_defaults[TEXT]=0;
    27 
    28   if(argc<2)
    29   {
    30       std::cerr << "USAGE: gd <input filename.lgf>" << std::endl;
    31       return 0;
    32   }
    33 
    34   Coordinates coosvector;
    35 
    36   Graph g;
    37 
    38   CoordinatesMap cm(g);
    39   Graph::EdgeMap<double> cap(g), map1(g), map2(g), map3(g), map4(g);
    40   Graph::NodeMap<double> nodedata (g);
    41 
    42   //we create one object to read x coordinates
    43   //and one to read y coordinate of nodes and write them to cm NodeMap.
    44   XMap <CoordinatesMap> xreader (cm);
    45   YMap <CoordinatesMap> yreader (cm);
    46 
    47   //reading in graph and its maps
    48 
    49   std::ifstream is(argv[1]);
    50 
    51   GraphReader<Graph> reader(is, g);
    52   reader.readNodeMap("coordinates_x", xreader);
    53   reader.readNodeMap("coordinates_y", yreader);
    54   reader.readNodeMap("data", nodedata);
    55   reader.readEdgeMap("cap", cap);
    56   reader.readEdgeMap("map1", map1);
    57   reader.readEdgeMap("map2", map2);
    58   reader.readEdgeMap("map3", map3);
    59   reader.readEdgeMap("map4", map4);
    60   reader.run();
    61 
    62   //initializing MapStorage with the read data
    63 
    64   MapStorage ms(g);
    65   ms.addNodeMap("data",&nodedata);
    66   ms.addEdgeMap("cap",&cap);
    67   ms.addEdgeMap("map1",&map1);
    68   ms.addEdgeMap("map2",&map2);
    69   ms.addEdgeMap("map3",&map3);
    70   ms.addEdgeMap("map4",&map4);
    71 
    72   //initializing GUI
    73 
    74   Gnome::Canvas::init();
    75   Gtk::Main app(argc, argv);
    76 
    77   MainWin mainwin("Displayed Graph", g, cm, ms);
    78   app.run(mainwin);
    79 
    80   return 0;
    81 }