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