eps_win.cc
author hegyi
Thu, 01 Mar 2007 16:28:13 +0000
changeset 198 d6cc0579b94b
parent 196 c220f9de6545
child 201 879e47e5b731
permissions -rw-r--r--
Shape feature of EPS can be used.
hegyi@192
     1
/* -*- C++ -*-
hegyi@192
     2
 *
hegyi@192
     3
 * This file is a part of LEMON, a generic C++ optimization library
hegyi@192
     4
 *
hegyi@192
     5
 * Copyright (C) 2003-2006
hegyi@192
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
hegyi@192
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
hegyi@192
     8
 *
hegyi@192
     9
 * Permission to use, modify and distribute this software is granted
hegyi@192
    10
 * provided that this copyright notice appears in all copies. For
hegyi@192
    11
 * precise terms see the accompanying LICENSE file.
hegyi@192
    12
 *
hegyi@192
    13
 * This software is provided "AS IS" with no warranty of any kind,
hegyi@192
    14
 * express or implied, and with no claim as to its suitability for any
hegyi@192
    15
 * purpose.
hegyi@192
    16
 *
hegyi@192
    17
 */
hegyi@192
    18
hegyi@194
    19
#include <eps_win.h>
hegyi@198
    20
hegyi@198
    21
#include <mapselector.h>
hegyi@198
    22
hegyi@192
    23
#include <set>
hegyi@192
    24
hegyi@192
    25
bool EpsWin::closeIfEscapeIsPressed(GdkEventKey* e)
hegyi@192
    26
{
hegyi@192
    27
  if(e->keyval==GDK_Escape)
hegyi@192
    28
  {
hegyi@192
    29
    hide();
hegyi@192
    30
  }
hegyi@192
    31
  return true;
hegyi@192
    32
}
hegyi@192
    33
hegyi@198
    34
EpsWin::EpsWin(const std::string& title, std::vector<std::string> nml):Gtk::Dialog(title, true, true)
hegyi@192
    35
{
hegyi@192
    36
  set_default_size(200, 50);
hegyi@192
    37
hegyi@192
    38
  set_resizable(false);
hegyi@192
    39
hegyi@192
    40
  signal_key_press_event().connect(sigc::mem_fun(*this, &EpsWin::closeIfEscapeIsPressed));
hegyi@192
    41
hegyi@192
    42
  table=new Gtk::Table(EPS_PROPERTY_NUM, 1, false);
hegyi@192
    43
hegyi@192
    44
  std::vector<std::string> labels;
hegyi@192
    45
  labels.resize(EPS_PROPERTY_NUM);
hegyi@192
    46
hegyi@192
    47
  labels[N_MAPS]="Dump visualized nodemaps";
hegyi@192
    48
  labels[E_MAPS]="Dump visualizes edgemaps";
hegyi@192
    49
  labels[ARROWS]="Show arrows in directed graphs";
hegyi@192
    50
  labels[PAR]="Indicate parallel edges";
hegyi@192
    51
hegyi@192
    52
  options.resize(EPS_PROPERTY_NUM);
hegyi@192
    53
hegyi@192
    54
  for(int i=0;i<EPS_PROPERTY_NUM;i++)
hegyi@192
    55
    {
hegyi@192
    56
      options[i]=new Gtk::CheckButton(labels[i]);
hegyi@192
    57
      (*table).attach(*(options[i]),0,1,i,i+1,Gtk::FILL,Gtk::SHRINK,10,3);
hegyi@192
    58
    }
hegyi@192
    59
hegyi@198
    60
  mapselector=new MapSelector(nml, "", "Nodeshapes", false);
hegyi@198
    61
  mapselector->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &EpsWin::newMapWinNeeded));
hegyi@198
    62
hegyi@192
    63
  hbox.pack_start(*(new Gtk::Label("Filename")));
hegyi@192
    64
  hbox.pack_start(name);
hegyi@192
    65
hegyi@192
    66
  Gtk::VBox * vbox=get_vbox();
hegyi@192
    67
hegyi@192
    68
  vbox->pack_start(*table);
hegyi@198
    69
  vbox->pack_start(*mapselector);
hegyi@192
    70
  vbox->pack_start(hbox);
hegyi@192
    71
hegyi@192
    72
  //OK button
hegyi@192
    73
  add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
hegyi@192
    74
  add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
hegyi@192
    75
hegyi@192
    76
  show_all_children();
hegyi@192
    77
hegyi@192
    78
}
hegyi@192
    79
hegyi@192
    80
bool EpsWin::on_delete_event(GdkEventAny * event)
hegyi@192
    81
{
hegyi@192
    82
  event=event;
hegyi@196
    83
  signal_eps_close.emit();
hegyi@192
    84
  return true;
hegyi@192
    85
}
hegyi@192
    86
hegyi@192
    87
void EpsWin::on_response(int response_id)
hegyi@192
    88
{
hegyi@192
    89
  if(response_id==Gtk::RESPONSE_OK)
hegyi@192
    90
    {
hegyi@192
    91
      std::vector <bool> values;
hegyi@192
    92
      values.resize(EPS_PROPERTY_NUM);
hegyi@192
    93
      for(int i=0;i<EPS_PROPERTY_NUM;i++)
hegyi@192
    94
	{
hegyi@192
    95
	  values[i]=options[i]->get_active();
hegyi@192
    96
	}
hegyi@198
    97
      signal_eps_details.emit(values, name.get_text(), mapselector->get_active_text());
hegyi@192
    98
    }
hegyi@192
    99
  on_delete_event(NULL);
hegyi@192
   100
}
hegyi@198
   101
hegyi@198
   102
void EpsWin::newMapWinNeeded(bool isitedge)
hegyi@198
   103
{
hegyi@198
   104
  signal_new_map.emit(false);
hegyi@198
   105
}
hegyi@198
   106
hegyi@198
   107
void EpsWin::registerNewNodeMap(std::string newmapname)
hegyi@198
   108
{
hegyi@198
   109
    mapselector->append_text((Glib::ustring)newmapname);
hegyi@198
   110
}