map_win.cc
author hegyi
Thu, 01 Mar 2007 16:28:13 +0000
changeset 198 d6cc0579b94b
parent 174 95872af46fc4
child 201 879e47e5b731
permissions -rw-r--r--
Shape feature of EPS can be used.
alpar@174
     1
/* -*- C++ -*-
alpar@174
     2
 *
alpar@174
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@174
     4
 *
alpar@174
     5
 * Copyright (C) 2003-2006
alpar@174
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@174
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@174
     8
 *
alpar@174
     9
 * Permission to use, modify and distribute this software is granted
alpar@174
    10
 * provided that this copyright notice appears in all copies. For
alpar@174
    11
 * precise terms see the accompanying LICENSE file.
alpar@174
    12
 *
alpar@174
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@174
    14
 * express or implied, and with no claim as to its suitability for any
alpar@174
    15
 * purpose.
alpar@174
    16
 *
alpar@174
    17
 */
alpar@174
    18
hegyi@194
    19
#include <map_win.h>
hegyi@194
    20
#include <nbtab.h>
hegyi@194
    21
#include <mapselector.h>
ladanyi@6
    22
#include <set>
ladanyi@6
    23
hegyi@30
    24
bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
ladanyi@6
    25
{
hegyi@8
    26
  if(e->keyval==GDK_Escape)
hegyi@8
    27
  {
hegyi@96
    28
    mytab.closeMapWin();
hegyi@95
    29
    //    hide();
hegyi@8
    30
  }
hegyi@8
    31
  return true;
hegyi@8
    32
}
ladanyi@6
    33
hegyi@96
    34
MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw)
hegyi@8
    35
{
hegyi@8
    36
  set_title(title);
hegyi@8
    37
  set_default_size(200, 50);
ladanyi@6
    38
hegyi@146
    39
  set_resizable(false);
hegyi@146
    40
hegyi@30
    41
  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
ladanyi@6
    42
hegyi@172
    43
  mytab.signal_title_ch().connect(sigc::mem_fun(*this, &MapWin::set_title));
hegyi@172
    44
hegyi@81
    45
  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
hegyi@8
    46
hegyi@81
    47
  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
hegyi@28
    48
hegyi@28
    49
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@6
    50
  {
hegyi@114
    51
    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
hegyi@8
    52
hegyi@81
    53
    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@94
    54
hegyi@94
    55
    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
hegyi@121
    56
    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
ladanyi@6
    57
  }
ladanyi@6
    58
hegyi@28
    59
  vbox.pack_start(*(new Gtk::Label("Edge properties")));
hegyi@8
    60
hegyi@28
    61
  vbox.pack_start(*table);
hegyi@28
    62
hegyi@28
    63
  vbox.pack_start(*(new Gtk::HSeparator));
hegyi@28
    64
hegyi@81
    65
  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
hegyi@28
    66
hegyi@81
    67
  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
hegyi@28
    68
hegyi@28
    69
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@28
    70
  {
hegyi@114
    71
    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false);
hegyi@28
    72
hegyi@81
    73
    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
hegyi@94
    74
hegyi@94
    75
    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
hegyi@121
    76
    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &MapWin::newMapWinNeeded));
hegyi@28
    77
  }
hegyi@28
    78
hegyi@28
    79
  add(vbox);
hegyi@28
    80
hegyi@28
    81
  vbox.pack_start(*(new Gtk::Label("Node properties")));
hegyi@28
    82
hegyi@28
    83
  vbox.pack_start(*table);
ladanyi@6
    84
ladanyi@6
    85
  show_all_children();
ladanyi@6
    86
ladanyi@6
    87
}
ladanyi@6
    88
hegyi@94
    89
void MapWin::nodeMapChanged(std::string mapname, int prop)
hegyi@94
    90
{
hegyi@96
    91
  mytab.propertyChange(false, prop, mapname);
hegyi@94
    92
}
hegyi@94
    93
hegyi@94
    94
void MapWin::edgeMapChanged(std::string mapname, int prop)
hegyi@94
    95
{
hegyi@96
    96
  mytab.propertyChange(true, prop, mapname);
hegyi@94
    97
}
hegyi@94
    98
hegyi@121
    99
void MapWin::newMapWinNeeded(bool itisedge)
hegyi@94
   100
{
hegyi@121
   101
  mytab.popupNewMapWin(itisedge);
hegyi@94
   102
}
hegyi@94
   103
hegyi@94
   104
void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
ladanyi@53
   105
{
ladanyi@53
   106
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
ladanyi@53
   107
  {
hegyi@94
   108
    e_combo_array[i]->update_list(eml);
hegyi@81
   109
  }
ladanyi@53
   110
ladanyi@53
   111
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
ladanyi@53
   112
  {
hegyi@94
   113
    n_combo_array[i]->update_list(nml);
ladanyi@53
   114
  }
hegyi@172
   115
hegyi@172
   116
  mytab.active_maps_needed();
ladanyi@53
   117
}
ladanyi@53
   118
hegyi@40
   119
void MapWin::registerNewEdgeMap(std::string newmapname)
hegyi@38
   120
{
hegyi@40
   121
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@40
   122
  {
hegyi@40
   123
    //filling in combo box with choices
hegyi@81
   124
    e_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
   125
  }
hegyi@38
   126
}
hegyi@38
   127
hegyi@40
   128
void MapWin::registerNewNodeMap(std::string newmapname)
hegyi@38
   129
{
hegyi@41
   130
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@40
   131
  {
hegyi@40
   132
    //filling in combo box with choices
hegyi@82
   133
    n_combo_array[i]->append_text((Glib::ustring)newmapname);
hegyi@40
   134
  }
hegyi@38
   135
}
hegyi@95
   136
hegyi@95
   137
bool MapWin::on_delete_event(GdkEventAny * event)
hegyi@95
   138
{
hegyi@95
   139
  event=event;
hegyi@96
   140
  mytab.closeMapWin();
hegyi@95
   141
  return true;
hegyi@95
   142
}
hegyi@172
   143
hegyi@172
   144
void MapWin::changeEntry(bool isitedge, int prop, std::string mapname)
hegyi@172
   145
{
hegyi@172
   146
  if(isitedge)
hegyi@172
   147
    {
hegyi@172
   148
      e_combo_array[prop]->set_active_text(mapname);
hegyi@172
   149
    }
hegyi@172
   150
  else
hegyi@172
   151
    {
hegyi@172
   152
      n_combo_array[prop]->set_active_text(mapname);
hegyi@172
   153
    }
hegyi@172
   154
}
hegyi@172
   155
hegyi@172
   156
void MapWin::set_title(std::string tabname)
hegyi@172
   157
{
hegyi@172
   158
  Gtk::Window::set_title("Map Setup - "+tabname);
hegyi@172
   159
}