COIN-OR::LEMON - Graph Library

source: glemon-0.x/map_win.cc

Last change on this file was 174:95872af46fc4, checked in by Alpar Juttner, 14 years ago

Add copyright headers

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