graph-displayer.cc
author Akos Ladanyi <ladanyi@tmit.bme.hu>
Thu, 10 Jul 2008 18:53:00 +0100
changeset 4 244d8c60b997
parent 1 67188bd752db
child 5 390d05b2d25c
permissions -rw-r--r--
Issue a custom error message when Lemon is not found.
hegyi@1
     1
/* -*- C++ -*-
hegyi@1
     2
 *
hegyi@1
     3
 * This file is a part of LEMON, a generic C++ optimization library
hegyi@1
     4
 *
hegyi@1
     5
 * Copyright (C) 2003-2006
hegyi@1
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
hegyi@1
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
hegyi@1
     8
 *
hegyi@1
     9
 * Permission to use, modify and distribute this software is granted
hegyi@1
    10
 * provided that this copyright notice appears in all copies. For
hegyi@1
    11
 * precise terms see the accompanying LICENSE file.
hegyi@1
    12
 *
hegyi@1
    13
 * This software is provided "AS IS" with no warranty of any kind,
hegyi@1
    14
 * express or implied, and with no claim as to its suitability for any
hegyi@1
    15
 * purpose.
hegyi@1
    16
 *
hegyi@1
    17
 */
hegyi@1
    18
hegyi@1
    19
#ifdef HAVE_CONFIG_H
hegyi@1
    20
#include <config.h>
hegyi@1
    21
#endif
hegyi@1
    22
hegyi@1
    23
#include "all_include.h"
hegyi@1
    24
#include "main_win.h"
hegyi@1
    25
#include <libgnomecanvasmm.h>
hegyi@1
    26
#include <libgnomecanvasmm/polygon.h>
hegyi@1
    27
ladanyi@2
    28
#include <libintl.h>
hegyi@1
    29
hegyi@1
    30
#define MAIN_PART
hegyi@1
    31
hegyi@1
    32
std::vector <std::string> arc_property_strings;
hegyi@1
    33
std::vector <double> arc_property_defaults;
hegyi@1
    34
std::vector <std::string> node_property_strings;
hegyi@1
    35
std::vector <double> node_property_defaults;
hegyi@1
    36
int longest_property_string_length;
hegyi@1
    37
hegyi@1
    38
int main(int argc, char *argv[])
hegyi@1
    39
{
hegyi@1
    40
  setlocale(LC_ALL, "");
hegyi@1
    41
  bindtextdomain(PACKAGE, LOCALEDIR);
hegyi@1
    42
  bind_textdomain_codeset(PACKAGE, "UTF-8");
hegyi@1
    43
  textdomain(PACKAGE);
hegyi@1
    44
hegyi@1
    45
  //initializing
hegyi@1
    46
hegyi@1
    47
  arc_property_strings.resize(EDGE_PROPERTY_NUM);
hegyi@1
    48
  arc_property_strings[E_WIDTH]="Arc Width";
hegyi@1
    49
  arc_property_strings[E_COLOR]="Arc Color";
hegyi@1
    50
  arc_property_strings[E_TEXT]="Arc Text";
hegyi@1
    51
hegyi@1
    52
  arc_property_defaults.resize(EDGE_PROPERTY_NUM);
hegyi@1
    53
  arc_property_defaults[E_WIDTH]=10.0;
hegyi@1
    54
  arc_property_defaults[E_COLOR]=100;
hegyi@1
    55
  arc_property_defaults[E_TEXT]=0;
hegyi@1
    56
hegyi@1
    57
  node_property_strings.resize(NODE_PROPERTY_NUM);
hegyi@1
    58
  node_property_strings[N_RADIUS]="Node Radius";
hegyi@1
    59
  node_property_strings[N_COLOR]="Node Color";
hegyi@1
    60
  node_property_strings[N_TEXT]="Node Text";
hegyi@1
    61
hegyi@1
    62
  node_property_defaults.resize(NODE_PROPERTY_NUM);
hegyi@1
    63
  node_property_defaults[N_RADIUS]=20.0;
hegyi@1
    64
  node_property_defaults[N_COLOR]=100;
hegyi@1
    65
  node_property_defaults[N_TEXT]=0;
hegyi@1
    66
hegyi@1
    67
  longest_property_string_length=0;
hegyi@1
    68
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@1
    69
    {
hegyi@1
    70
      int j=arc_property_strings[i].size();
hegyi@1
    71
      if(j>longest_property_string_length)
hegyi@1
    72
	{
hegyi@1
    73
	  longest_property_string_length=j;
hegyi@1
    74
	}
hegyi@1
    75
    }
hegyi@1
    76
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@1
    77
    {
hegyi@1
    78
      int j=node_property_strings[i].size();
hegyi@1
    79
      if(j>longest_property_string_length)
hegyi@1
    80
	{
hegyi@1
    81
	  longest_property_string_length=j;
hegyi@1
    82
	}
hegyi@1
    83
    }
hegyi@1
    84
hegyi@1
    85
hegyi@1
    86
  //initializing GUI
hegyi@1
    87
hegyi@1
    88
  Gnome::Canvas::init();
hegyi@1
    89
  Gtk::Main app(argc, argv);
hegyi@1
    90
hegyi@1
    91
  MainWin mytab;
hegyi@1
    92
hegyi@1
    93
//   if ((argc == 2) && (Glib::file_test(argv[1], Glib::FILE_TEST_IS_REGULAR)))
hegyi@1
    94
//     {
hegyi@1
    95
//       mytab.readFile(argv[1]);
hegyi@1
    96
//     }
hegyi@1
    97
  if(argc>=2)
hegyi@1
    98
  {
hegyi@1
    99
    for(int i=1;i<argc;i++)
hegyi@1
   100
    {
hegyi@1
   101
      if(Glib::file_test(argv[i], Glib::FILE_TEST_IS_REGULAR))
hegyi@1
   102
      {
hegyi@1
   103
        mytab.readFile(argv[i]);
hegyi@1
   104
      }
hegyi@1
   105
    }
hegyi@1
   106
  }
hegyi@1
   107
  else
hegyi@1
   108
    {
hegyi@1
   109
      mytab.newTab();
hegyi@1
   110
    }
hegyi@1
   111
  
hegyi@1
   112
  app.run(mytab);
hegyi@1
   113
hegyi@1
   114
  return 0;
hegyi@1
   115
}