eps_win.cc
author Alpar Juttner <alpar@cs.elte.hu>
Fri, 10 Oct 2008 13:36:20 +0100
changeset 7 f227a74db59d
permissions -rw-r--r--
Update to compile with the latest LEMON (version 1.0 or [5e12d7734036])
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
#include <eps_win.h>
hegyi@1
    20
hegyi@1
    21
#include <mapselector.h>
hegyi@1
    22
hegyi@1
    23
#include <set>
hegyi@1
    24
hegyi@1
    25
bool EpsWin::closeIfEscapeIsPressed(GdkEventKey* e)
hegyi@1
    26
{
hegyi@1
    27
  if(e->keyval==GDK_Escape)
hegyi@1
    28
  {
hegyi@1
    29
    hide();
hegyi@1
    30
  }
hegyi@1
    31
  return true;
hegyi@1
    32
}
hegyi@1
    33
hegyi@1
    34
EpsWin::EpsWin(const std::string& title, std::vector<std::string> n_nml, std::vector<std::string> s_nml):Gtk::Dialog(title, true, true)
hegyi@1
    35
{
hegyi@1
    36
  set_default_size(200, 50);
hegyi@1
    37
hegyi@1
    38
  set_resizable(false);
hegyi@1
    39
hegyi@1
    40
  signal_key_press_event().connect(sigc::mem_fun(*this, &EpsWin::closeIfEscapeIsPressed));
hegyi@1
    41
hegyi@1
    42
  table=new Gtk::Table(EPS_PROPERTY_NUM, 1, false);
hegyi@1
    43
hegyi@1
    44
  std::vector<std::string> labels;
hegyi@1
    45
  labels.resize(EPS_PROPERTY_NUM);
hegyi@1
    46
hegyi@1
    47
  labels[N_MAPS]="Dump visualized nodemaps";
hegyi@1
    48
  labels[E_MAPS]="Dump visualizes arcmaps";
hegyi@1
    49
  labels[ARROWS]="Show arrows in directed digraphs";
hegyi@1
    50
  labels[PAR]="Indicate parallel arcs";
hegyi@1
    51
hegyi@1
    52
  options.resize(EPS_PROPERTY_NUM);
hegyi@1
    53
hegyi@1
    54
  for(int i=0;i<EPS_PROPERTY_NUM;i++)
hegyi@1
    55
    {
hegyi@1
    56
      options[i]=new Gtk::CheckButton(labels[i]);
hegyi@1
    57
      (*table).attach(*(options[i]),0,1,i,i+1,Gtk::FILL,Gtk::SHRINK,10,3);
hegyi@1
    58
    }
hegyi@1
    59
hegyi@1
    60
  mapselector=new MapSelector(n_nml, s_nml, "", "Nodeshapes", false, true, NUM);
hegyi@1
    61
  mapselector->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &EpsWin::newMapWinNeeded));
hegyi@1
    62
hegyi@1
    63
  hbox.pack_start(*(new Gtk::Label("Filename")));
hegyi@1
    64
  hbox.pack_start(name);
hegyi@1
    65
hegyi@1
    66
  Gtk::VBox * vbox=get_vbox();
hegyi@1
    67
hegyi@1
    68
  vbox->pack_start(*table);
hegyi@1
    69
  vbox->pack_start(*mapselector);
hegyi@1
    70
  vbox->pack_start(hbox);
hegyi@1
    71
hegyi@1
    72
  //OK button
hegyi@1
    73
  add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
hegyi@1
    74
  add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
hegyi@1
    75
hegyi@1
    76
  show_all_children();
hegyi@1
    77
hegyi@1
    78
}
hegyi@1
    79
hegyi@1
    80
bool EpsWin::on_delete_event(GdkEventAny * event)
hegyi@1
    81
{
hegyi@1
    82
  event=event;
hegyi@1
    83
  signal_eps_close.emit();
hegyi@1
    84
  return true;
hegyi@1
    85
}
hegyi@1
    86
hegyi@1
    87
void EpsWin::on_response(int response_id)
hegyi@1
    88
{
hegyi@1
    89
  if(response_id==Gtk::RESPONSE_OK)
hegyi@1
    90
    {
hegyi@1
    91
      std::vector <bool> values;
hegyi@1
    92
      values.resize(EPS_PROPERTY_NUM);
hegyi@1
    93
      for(int i=0;i<EPS_PROPERTY_NUM;i++)
hegyi@1
    94
	{
hegyi@1
    95
	  values[i]=options[i]->get_active();
hegyi@1
    96
	}
hegyi@1
    97
      signal_eps_details.emit(values, name.get_text(), mapselector->get_active_text());
hegyi@1
    98
    }
hegyi@1
    99
  on_delete_event(NULL);
hegyi@1
   100
}
hegyi@1
   101
hegyi@1
   102
void EpsWin::newMapWinNeeded(bool isitarc)
hegyi@1
   103
{
hegyi@1
   104
  signal_new_map.emit(false);
hegyi@1
   105
}
hegyi@1
   106
hegyi@1
   107
void EpsWin::registerNewNodeMap(std::string newmapname, MapValue::Type type)
hegyi@1
   108
{
hegyi@1
   109
    mapselector->append_text((Glib::ustring)newmapname, type);
hegyi@1
   110
}