graph-displayer.cc
changeset 1 67188bd752db
child 2 fdb8a163000f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/graph-displayer.cc	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -0,0 +1,115 @@
     1.4 +/* -*- C++ -*-
     1.5 + *
     1.6 + * This file is a part of LEMON, a generic C++ optimization library
     1.7 + *
     1.8 + * Copyright (C) 2003-2006
     1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 + *
    1.12 + * Permission to use, modify and distribute this software is granted
    1.13 + * provided that this copyright notice appears in all copies. For
    1.14 + * precise terms see the accompanying LICENSE file.
    1.15 + *
    1.16 + * This software is provided "AS IS" with no warranty of any kind,
    1.17 + * express or implied, and with no claim as to its suitability for any
    1.18 + * purpose.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +#ifdef HAVE_CONFIG_H
    1.23 +#include <config.h>
    1.24 +#endif
    1.25 +
    1.26 +#include "all_include.h"
    1.27 +#include "main_win.h"
    1.28 +#include <libgnomecanvasmm.h>
    1.29 +#include <libgnomecanvasmm/polygon.h>
    1.30 +
    1.31 +#include <locale.h>
    1.32 +
    1.33 +#define MAIN_PART
    1.34 +
    1.35 +std::vector <std::string> arc_property_strings;
    1.36 +std::vector <double> arc_property_defaults;
    1.37 +std::vector <std::string> node_property_strings;
    1.38 +std::vector <double> node_property_defaults;
    1.39 +int longest_property_string_length;
    1.40 +
    1.41 +int main(int argc, char *argv[])
    1.42 +{
    1.43 +  setlocale(LC_ALL, "");
    1.44 +  bindtextdomain(PACKAGE, LOCALEDIR);
    1.45 +  bind_textdomain_codeset(PACKAGE, "UTF-8");
    1.46 +  textdomain(PACKAGE);
    1.47 +
    1.48 +  //initializing
    1.49 +
    1.50 +  arc_property_strings.resize(EDGE_PROPERTY_NUM);
    1.51 +  arc_property_strings[E_WIDTH]="Arc Width";
    1.52 +  arc_property_strings[E_COLOR]="Arc Color";
    1.53 +  arc_property_strings[E_TEXT]="Arc Text";
    1.54 +
    1.55 +  arc_property_defaults.resize(EDGE_PROPERTY_NUM);
    1.56 +  arc_property_defaults[E_WIDTH]=10.0;
    1.57 +  arc_property_defaults[E_COLOR]=100;
    1.58 +  arc_property_defaults[E_TEXT]=0;
    1.59 +
    1.60 +  node_property_strings.resize(NODE_PROPERTY_NUM);
    1.61 +  node_property_strings[N_RADIUS]="Node Radius";
    1.62 +  node_property_strings[N_COLOR]="Node Color";
    1.63 +  node_property_strings[N_TEXT]="Node Text";
    1.64 +
    1.65 +  node_property_defaults.resize(NODE_PROPERTY_NUM);
    1.66 +  node_property_defaults[N_RADIUS]=20.0;
    1.67 +  node_property_defaults[N_COLOR]=100;
    1.68 +  node_property_defaults[N_TEXT]=0;
    1.69 +
    1.70 +  longest_property_string_length=0;
    1.71 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    1.72 +    {
    1.73 +      int j=arc_property_strings[i].size();
    1.74 +      if(j>longest_property_string_length)
    1.75 +	{
    1.76 +	  longest_property_string_length=j;
    1.77 +	}
    1.78 +    }
    1.79 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    1.80 +    {
    1.81 +      int j=node_property_strings[i].size();
    1.82 +      if(j>longest_property_string_length)
    1.83 +	{
    1.84 +	  longest_property_string_length=j;
    1.85 +	}
    1.86 +    }
    1.87 +
    1.88 +
    1.89 +  //initializing GUI
    1.90 +
    1.91 +  Gnome::Canvas::init();
    1.92 +  Gtk::Main app(argc, argv);
    1.93 +
    1.94 +  MainWin mytab;
    1.95 +
    1.96 +//   if ((argc == 2) && (Glib::file_test(argv[1], Glib::FILE_TEST_IS_REGULAR)))
    1.97 +//     {
    1.98 +//       mytab.readFile(argv[1]);
    1.99 +//     }
   1.100 +  if(argc>=2)
   1.101 +  {
   1.102 +    for(int i=1;i<argc;i++)
   1.103 +    {
   1.104 +      if(Glib::file_test(argv[i], Glib::FILE_TEST_IS_REGULAR))
   1.105 +      {
   1.106 +        mytab.readFile(argv[i]);
   1.107 +      }
   1.108 +    }
   1.109 +  }
   1.110 +  else
   1.111 +    {
   1.112 +      mytab.newTab();
   1.113 +    }
   1.114 +  
   1.115 +  app.run(mytab);
   1.116 +
   1.117 +  return 0;
   1.118 +}