COIN-OR::LEMON - Graph Library

Changeset 28:fa28f1071bd6 in glemon-0.x for map_win.cc


Ignore:
Timestamp:
06/24/05 20:16:12 (19 years ago)
Author:
Hegyi Péter
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@1996
Message:

NodeMap? values are now visualizable. Todo: default map-values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • map_win.cc

    r8 r28  
    1111}
    1212
    13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false)
     13MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
    1414{
    1515  set_title(title);
     
    1818  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed));
    1919
    20   combo_array=new Gtk::Combo [PROPERTY_NUM];
    21 
    22   for(int i=0;i<PROPERTY_NUM;i++)
     20  e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM];
     21
     22  table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false);
     23
     24  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    2325  {
    2426
     
    3638        actprop=j;
    3739      }
    38       //this is the other maps to show for this property
    39       for(int k=0;k<PROPERTY_NUM;k++)
     40      //these are the maps NOT to show for this property
     41      for(int k=0;k<EDGE_PROPERTY_NUM;k++)
    4042      {
    4143        if(emsi->second==&(ms.default_edgemaps[k]))
     
    4648      emsi++;
    4749    }
    48 
    49     //combo_array[i].set_group(group);
    5050
    5151    //filling in combo box with choices
     
    6565    }
    6666
    67     combo_array[i].set_popdown_strings(listStrings);
     67    e_combo_array[i].set_popdown_strings(listStrings);
    6868
    6969    //Restrict it to these choices only:
    70     combo_array[i].set_value_in_list();
    71 
    72     //binding signal to thew actual entry
    73     combo_array[i].get_entry()->signal_changed().connect
     70    e_combo_array[i].set_value_in_list();
     71
     72    //binding signal to the actual entry
     73    e_combo_array[i].get_entry()->signal_changed().connect
    7474    (
    7575     sigc::bind
    7676     (
    77       sigc::mem_fun(*this, &MapWin::combo_changed),
     77      sigc::mem_fun(*this, &MapWin::e_combo_changed),
    7878      i
    7979     )
     
    8383
    8484    label=new Gtk::Label;
    85     label->set_text(property_strings[i]);
    86 
    87     //    labelpluscombo=new Gtk::HBox;
    88     //    labelpluscombo->pack_start(*label);
    89     //    labelpluscombo->pack_start(combo_array[i]);
     85    label->set_text(edge_property_strings[i]);
    9086       
    91     table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    92     table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    93 
    94     /*
    95     if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2)
    96     {
    97       vbox_r1.pack_start(*labelpluscombo);
    98     }
    99     else
    100     {
    101       vbox_r2.pack_start(*labelpluscombo);
    102     }
    103     actpos++;
    104     //*/
    105 
    106   }
    107 
    108   combos.pack_start(vbox_r1);
    109   combos.pack_start(vbox_r2);
    110 
    111   //add(combos);
    112   add(table);
     87    (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     88    (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     89
     90
     91  }
     92
     93  vbox.pack_start(*(new Gtk::Label("Edge properties")));
     94
     95  vbox.pack_start(*table);
     96
     97  vbox.pack_start(*(new Gtk::HSeparator));
     98
     99  n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
     100
     101  table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
     102
     103  for(int i=0;i<NODE_PROPERTY_NUM;i++)
     104  {
     105
     106    std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
     107    std::set<int> props;
     108
     109    int actprop;
     110
     111    //here we find out, which map is the default in MapStorage for this property, which are not
     112    for(int j=0;j<ms.numOfNodeMaps();j++)
     113    {
     114      //these are the maps NOT to show for this property
     115      if(emsi->second==&(ms.default_nodemaps[i]))
     116      {
     117        actprop=j;
     118      }
     119      //this is the other maps to show for this property
     120      for(int k=0;k<NODE_PROPERTY_NUM;k++)
     121      {
     122        if(emsi->second==&(ms.default_nodemaps[k]))
     123        {
     124          props.insert(j);
     125        }
     126      }
     127      emsi++;
     128    }
     129
     130    //filling in combo box with choices
     131    std::list<Glib::ustring> listStrings;
     132
     133    listStrings.push_back("Default");
     134
     135    emsi=ms.beginOfNodeMaps();
     136
     137    for(int j=0;j<ms.numOfNodeMaps();j++)
     138    {
     139      if( ( props.find(j) )==( props.end() ) )
     140      {
     141        listStrings.push_back(emsi->first);
     142      }
     143      emsi++;
     144    }
     145
     146    n_combo_array[i].set_popdown_strings(listStrings);
     147
     148    //Restrict it to these choices only:
     149    n_combo_array[i].set_value_in_list();
     150
     151    //binding signal to thew actual entry
     152    n_combo_array[i].get_entry()->signal_changed().connect
     153    (
     154     sigc::bind
     155     (
     156      sigc::mem_fun(*this, &MapWin::n_combo_changed),
     157      i
     158     )
     159    );
     160
     161    //placing actual entry in the right place
     162
     163    label=new Gtk::Label;
     164    label->set_text(node_property_strings[i]);
     165       
     166    (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     167    (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     168
     169
     170  }
     171
     172  add(vbox);
     173
     174  vbox.pack_start(*(new Gtk::Label("Node properties")));
     175
     176  vbox.pack_start(*table);
    113177
    114178  show_all_children();
     
    116180}
    117181
    118 void MapWin::combo_changed(int prop)
    119 {
    120 
    121   //most nem kommentezem fel, mert ugyis valtozik
    122   Gtk::Entry* entry = combo_array[prop].get_entry();
     182void MapWin::e_combo_changed(int prop)
     183{
     184  Gtk::Entry* entry = e_combo_array[prop].get_entry();
    123185
    124186  if(entry)
     
    129191      if(mapname=="Default")
    130192      {
    131         mapname=property_strings[prop];
     193        mapname=edge_property_strings[prop];
    132194      }
    133195
     
    136198        switch(prop)
    137199        {
    138           case WIDTH:
    139             gdc.changeLineWidth(mapname);
    140             break;
    141           case COLOR:
    142             gdc.changeColor(mapname);
    143             break;
    144           case TEXT:
    145             gdc.changeText(mapname);
     200          case E_WIDTH:
     201            gdc.changeEdgeWidth(mapname);
     202            break;
     203          case E_COLOR:
     204            gdc.changeEdgeColor(mapname);
     205            break;
     206          case E_TEXT:
     207            gdc.changeEdgeText(mapname);
    146208            break;
    147209          default:
     
    152214  }
    153215};
     216
     217void MapWin::n_combo_changed(int prop)
     218{
     219
     220  Gtk::Entry* entry = n_combo_array[prop].get_entry();
     221
     222  if(entry)
     223  {
     224    Glib::ustring mapname = entry->get_text();
     225    if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
     226    {
     227      if(mapname=="Default")
     228      {
     229        mapname=node_property_strings[prop];
     230      }
     231
     232      if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() )
     233      {
     234        switch(prop)
     235        {
     236          case N_RADIUS:
     237            gdc.changeNodeRadius(mapname);
     238            break;
     239          case N_COLOR:
     240            gdc.changeNodeColor(mapname);
     241            break;
     242          case N_TEXT:
     243            gdc.changeNodeText(mapname);
     244            break;
     245          default:
     246            std::cout<<"Error\n";
     247        }
     248      }
     249    }
     250  }
     251};
     252
     253void MapWin::update_node(Graph::Node node)
     254{
     255  for(int i=0;i<NODE_PROPERTY_NUM;i++)
     256    {
     257      Gtk::Entry* entry = n_combo_array[i].get_entry();
     258
     259      if(entry)
     260        {
     261          Glib::ustring mapname = entry->get_text();
     262          if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
     263            {
     264              if(mapname=="Default")
     265                {
     266                  mapname=node_property_strings[i];
     267                }
     268
     269              if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() )
     270                {
     271                  switch(i)
     272                    {
     273                    case N_RADIUS:
     274                      //gdc.changeNodeRadius(mapname, node);
     275                      std::cout << "If default map-value problem is solved, uncomment line in MapWin::node_update!" << std::endl;
     276                      break;
     277                    case N_COLOR:
     278                      gdc.changeNodeColor(mapname, node);
     279                      break;
     280                    case N_TEXT:
     281                      gdc.changeNodeText(mapname, node);
     282                      break;
     283                    default:
     284                      std::cout<<"Error\n";
     285                    }
     286                }
     287            }
     288        }
     289    }
     290}
     291
     292void MapWin::update_edge(Graph::Edge edge)
     293{
     294  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
     295    {
     296
     297      Gtk::Entry* entry = e_combo_array[i].get_entry();
     298
     299      if(entry)
     300        {
     301          Glib::ustring mapname = entry->get_text();
     302          if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
     303            {
     304              if(mapname=="Default")
     305                {
     306                  mapname=edge_property_strings[i];
     307                }
     308
     309              if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() )
     310                {
     311                  switch(i)
     312                    {
     313                    case E_WIDTH:
     314                      //gdc.changeEdgeWidth(mapname, edge);
     315                      std::cout << "If default map-value problem is solved, uncomment line in MapWin::edge_update!" << std::endl;
     316                      break;
     317                    case E_COLOR:
     318                      gdc.changeEdgeColor(mapname, edge);
     319                      break;
     320                    case E_TEXT:
     321                      gdc.changeEdgeText(mapname, edge);
     322                      break;
     323                    default:
     324                      std::cout<<"Error\n";
     325                    }
     326                }
     327            }
     328        }
     329    }
     330}
Note: See TracChangeset for help on using the changeset viewer.