COIN-OR::LEMON - Graph Library

Changeset 1731:616bc933c2bc in lemon-0.x


Ignore:
Timestamp:
10/20/05 17:50:23 (19 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2258
Message:

Mapselector widget reached its first release, but there are still work to do on it, I know...

Location:
gui
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • gui/Makefile.am

    r1659 r1731  
    2727        new_map_win.h \
    2828        xymap.h \
    29         icons/guipixbufs.h
     29        icons/guipixbufs.h\
     30        mapselector.h\
     31        mapselector.cc
     32
    3033
    3134glemon_CXXFLAGS = $(GTK_CFLAGS)
  • gui/all_include.h

    r1651 r1731  
    3333extern std::vector <std::string> node_property_strings;
    3434extern std::vector <double> node_property_defaults;
     35extern int longest_property_string_length;
    3536#endif //MAIN_PART
    3637
  • gui/graph-displayer.cc

    r1650 r1731  
    1111std::vector <std::string> node_property_strings;
    1212std::vector <double> node_property_defaults;
    13 
     13int longest_property_string_length;
    1414
    1515int main(int argc, char *argv[])
     
    3838  node_property_defaults[N_TEXT]=0;
    3939
     40  longest_property_string_length=0;
     41  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
     42    {
     43      int j=edge_property_strings[i].size();
     44      if(j>longest_property_string_length)
     45        {
     46          longest_property_string_length=j;
     47        }
     48    }
     49  for(int i=0;i<NODE_PROPERTY_NUM;i++)
     50    {
     51      int j=node_property_strings[i].size();
     52      if(j>longest_property_string_length)
     53        {
     54          longest_property_string_length=j;
     55        }
     56    }
     57
     58
    4059  //initializing GUI
    4160
  • gui/graph_displayer_canvas-edge.cc

    r1645 r1731  
    44
    55
    6 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
     6int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
    77{
    88  Graph::EdgeMap<double> * actual_map;
    99  double min, max;
    1010
    11   if(mapname=="Default")
    12     {
    13       min=edge_property_defaults[E_WIDTH];
    14       max=edge_property_defaults[E_WIDTH];
    15       actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
    16     }
    17   else
    18     {
    19       min=mapstorage.minOfEdgeMap(mapname);
    20       max=mapstorage.maxOfEdgeMap(mapname);
    21       actual_map=(mapstorage.edgemap_storage)[mapname];
    22     }
    23 
     11  min=edge_property_defaults[E_WIDTH];
     12  max=edge_property_defaults[E_WIDTH];
     13  actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
     14 
    2415  if(edge==INVALID)
    2516    {
     
    4839    }
    4940  return 0;
     41}
     42
     43
     44int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
     45{
     46  Graph::EdgeMap<double> * actual_map;
     47  double min, max;
     48
     49  min=mapstorage.minOfEdgeMap(mapname);
     50  max=mapstorage.maxOfEdgeMap(mapname);
     51  actual_map=(mapstorage.edgemap_storage)[mapname];
     52
     53  if(edge==INVALID)
     54    {
     55      for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     56        {
     57          double v=fabs((*actual_map)[i]);
     58          int w;
     59          if(min==max)
     60            {
     61              w=(int)(edge_property_defaults[E_WIDTH]);
     62            }
     63          else
     64            {
     65              w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
     66            }
     67          edgesmap[i]->property_width_units().set_value(w);
     68        }
     69    }
     70  else
     71    {
     72      int w=(int)(*actual_map)[edge];
     73      if(w>=0)
     74        {
     75          edgesmap[edge]->property_width_units().set_value(w);
     76        }
     77    }
     78  return 0;
    5079};
    5180
     
    5786  //green in RGB
    5887  Graph::EdgeMap<double> * actual_map;
    59   if(mapname=="Default")
    60     {
    61       actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
    62     }
    63   else
    64     {
    65       actual_map=(mapstorage.edgemap_storage)[mapname];
    66     }
     88  actual_map=(mapstorage.edgemap_storage)[mapname];
    6789
    6890  double max, min;
    6991
    70   if(mapname!="Default")
    71     {
    72       max=mapstorage.maxOfEdgeMap(mapname);
    73       min=mapstorage.minOfEdgeMap(mapname);
    74     }
    75   else
    76     {
    77       max=edge_property_defaults[E_COLOR];
    78       min=edge_property_defaults[E_COLOR];
    79     }
     92  max=mapstorage.maxOfEdgeMap(mapname);
     93  min=mapstorage.minOfEdgeMap(mapname);
     94
     95  if(edge==INVALID)
     96    {
     97      for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     98        {
     99          double w=(*actual_map)[i];
     100
     101          Gdk::Color color;
     102          if(max!=min)
     103            {
     104              color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
     105            }
     106          else
     107            {
     108              color.set_rgb_p (0, 100, 0);
     109            }
     110          edgesmap[i]->property_fill_color_gdk().set_value(color);
     111        }
     112    }
     113  else
     114    {
     115      Gdk::Color color;
     116
     117      double w=(*actual_map)[edge];
     118
     119      if(max!=min)
     120        {
     121          color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
     122        }
     123      else
     124        {
     125          color.set_rgb_p (0, 100, 0);
     126        }
     127
     128      edgesmap[edge]->property_fill_color_gdk().set_value(color);
     129    }
     130  return 0;
     131};
     132
     133int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
     134
     135
     136  //function maps the range of the maximum and
     137  //the minimum of the nodemap to the range of
     138  //green in RGB
     139  Graph::EdgeMap<double> * actual_map;
     140  actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
     141
     142  double max, min;
     143
     144  max=edge_property_defaults[E_COLOR];
     145  min=edge_property_defaults[E_COLOR];
    80146
    81147  if(edge==INVALID)
     
    128194      for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
    129195        {
    130           if(mapname!="Default")
    131             {
    132               edgemap_to_edit=mapname;
    133               double number=(*(mapstorage.edgemap_storage)[mapname])[i];
    134 
    135               std::ostringstream ostr;
    136               ostr << number;
    137              
    138               edgetextmap[i]->property_text().set_value(ostr.str());
    139             }
    140           else
    141             {
    142               edgemap_to_edit="";
    143               edgetextmap[i]->property_text().set_value("");
    144             }
    145         }
    146 
    147     }
    148   else
    149     {
    150       if(mapname!="Default")
    151         {
     196          edgemap_to_edit=mapname;
     197          double number=(*(mapstorage.edgemap_storage)[mapname])[i];
     198         
     199          std::ostringstream ostr;
     200          ostr << number;
     201         
     202          edgetextmap[i]->property_text().set_value(ostr.str());
     203        }
     204
     205    }
     206  else
     207    {
    152208          double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
    153209
     
    156212         
    157213          edgetextmap[edge]->property_text().set_value(ostr.str());
    158         }
    159       else
    160         {
    161           edgetextmap[edge]->property_text().set_value("");
    162         }
    163          
    164     }
    165 
    166   return 0;
    167 
    168 };
     214    }
     215
     216  return 0;
     217
     218};
     219
     220int GraphDisplayerCanvas::resetEdgeText (Edge edge)
     221{
     222  //the number in the map will be written on the edge
     223  //EXCEPT when the name of the map is Default, because
     224  //in that case empty string will be written, because
     225  //that is the deleter map
     226 
     227  if(edge==INVALID)
     228    {
     229      for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     230        {
     231          edgemap_to_edit="";
     232          edgetextmap[i]->property_text().set_value("");
     233        }
     234
     235    }
     236  else
     237    {
     238      edgetextmap[edge]->property_text().set_value("");
     239    }
     240
     241  return 0;
     242
     243};
  • gui/graph_displayer_canvas-node.cc

    r1643 r1731  
    88  Graph::NodeMap<double> * actual_map;
    99  double min, max;
    10   if(mapname=="Default")
    11     {
    12       min=node_property_defaults[N_RADIUS];
    13       max=node_property_defaults[N_RADIUS];
    14       actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]);
    15     }
    16   else
    17     {
    18       min=mapstorage.minOfNodeMap(mapname);
    19       max=mapstorage.maxOfNodeMap(mapname);
    20       actual_map=(mapstorage.nodemap_storage)[mapname];
    21     }
     10  min=mapstorage.minOfNodeMap(mapname);
     11  max=mapstorage.maxOfNodeMap(mapname);
     12  actual_map=(mapstorage.nodemap_storage)[mapname];
    2213
    2314  if(node==INVALID)
     
    7061};
    7162
     63int GraphDisplayerCanvas::resetNodeRadius (Node node)
     64{
     65  Graph::NodeMap<double> * actual_map;
     66  double min, max;
     67  min=node_property_defaults[N_RADIUS];
     68  max=node_property_defaults[N_RADIUS];
     69  actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]);
     70 
     71  if(node==INVALID)
     72    {
     73      for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     74        {
     75          double v=fabs((*actual_map)[i]);
     76          int w;
     77          if(min==max)
     78            {
     79              w=(int)(node_property_defaults[N_RADIUS]);
     80            }
     81          else
     82            {
     83              w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
     84            }
     85          if(w>=0)
     86            {
     87              double x1, y1, x2, y2;
     88              x1=nodesmap[i]->property_x1().get_value();
     89              x2=nodesmap[i]->property_x2().get_value();
     90              y1=nodesmap[i]->property_y1().get_value();
     91              y2=nodesmap[i]->property_y2().get_value();
     92              nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
     93              nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
     94              nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
     95              nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
     96            }
     97        }
     98    }
     99  else
     100    {
     101      //I think only new nodes use this case
     102//       int w=(int)(*actual_map)[node];
     103      int w=(int)(node_property_defaults[N_RADIUS]);
     104      if(w>=0)
     105        {
     106          double x1, y1, x2, y2;
     107          x1=nodesmap[node]->property_x1().get_value();
     108          x2=nodesmap[node]->property_x2().get_value();
     109          y1=nodesmap[node]->property_y1().get_value();
     110          y2=nodesmap[node]->property_y2().get_value();
     111          nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
     112          nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
     113          nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
     114          nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
     115        }
     116    }
     117  return 0;
     118};
     119
    72120int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
    73121
     
    78126
    79127  Graph::NodeMap<double> * actual_map;
    80   if(mapname=="Default")
    81     {
    82       actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]);
    83     }
    84   else
    85     {
    86       actual_map=(mapstorage.nodemap_storage)[mapname];
    87     }
     128  actual_map=(mapstorage.nodemap_storage)[mapname];
    88129
    89130  double max, min;
    90131
    91   if(mapname!="Default")
    92     {
    93       max=mapstorage.maxOfNodeMap(mapname);
    94       min=mapstorage.minOfNodeMap(mapname);
    95     }
    96   else
    97     {
    98       max=node_property_defaults[N_COLOR];
    99       min=node_property_defaults[N_COLOR];
    100     }
    101 
     132  max=mapstorage.maxOfNodeMap(mapname);
     133  min=mapstorage.minOfNodeMap(mapname);
     134
     135  if(node==INVALID)
     136    {
     137
     138      for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     139        {
     140          Gdk::Color color;
     141
     142          double w=(*actual_map)[i];
     143
     144          if(max!=min)
     145            {
     146              color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
     147            }
     148          else
     149            {
     150              color.set_rgb_p (0, 0, 100);
     151            }
     152
     153          nodesmap[i]->property_fill_color_gdk().set_value(color);
     154        }
     155    }
     156  else
     157    {
     158      Gdk::Color color;
     159
     160      double w=(*actual_map)[node];
     161
     162      if(max!=min)
     163        {
     164          color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
     165        }
     166      else
     167        {
     168          color.set_rgb_p (0, 0, 100);
     169        }
     170
     171      nodesmap[node]->property_fill_color_gdk().set_value(color);
     172    }
     173  return 0;
     174};
     175
     176int GraphDisplayerCanvas::resetNodeColor (Node node)
     177
     178
     179  //function maps the range of the maximum and
     180  //the minimum of the nodemap to the range of
     181  //green in RGB
     182
     183  Graph::NodeMap<double> * actual_map;
     184  actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]);
     185
     186  double max, min;
     187
     188  max=node_property_defaults[N_COLOR];
     189  min=node_property_defaults[N_COLOR];
    102190
    103191  if(node==INVALID)
     
    151239
    152240  Graph::NodeMap<double> * actual_map=NULL;
    153   if(mapname!="Default")
    154     {
    155       actual_map=(mapstorage.nodemap_storage)[mapname];
    156     }
    157 
    158   if(node==INVALID)
    159     {
    160       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
    161         {
    162           if(mapname!="Default")
    163             {
    164               nodemap_to_edit=mapname;
    165               double number=(*actual_map)[i];
    166 
    167               std::ostringstream ostr;
    168               ostr << number;
    169              
    170               nodetextmap[i]->property_text().set_value(ostr.str());
    171             }
    172           else
    173             {
    174               nodemap_to_edit="";
    175               nodetextmap[i]->property_text().set_value("");
    176             }
    177         }
    178     }
    179   else
    180     {
    181       if(mapname!="Default")
    182         {
    183           double number=(*actual_map)[node];
     241  actual_map=(mapstorage.nodemap_storage)[mapname];
     242
     243  if(node==INVALID)
     244    {
     245      for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     246        {
     247          nodemap_to_edit=mapname;
     248          double number=(*actual_map)[i];
    184249
    185250          std::ostringstream ostr;
    186251          ostr << number;
    187252             
    188           nodetextmap[node]->property_text().set_value(ostr.str());
    189         }
    190       else
    191         {
    192           nodetextmap[node]->property_text().set_value("");
    193         }
    194     }
    195   return 0;
    196 };
     253          nodetextmap[i]->property_text().set_value(ostr.str());
     254        }
     255    }
     256  else
     257    {
     258      double number=(*actual_map)[node];
     259
     260      std::ostringstream ostr;
     261      ostr << number;
     262             
     263      nodetextmap[node]->property_text().set_value(ostr.str());
     264    }
     265  return 0;
     266};
     267
     268int GraphDisplayerCanvas::resetNodeText (Node node)
     269{
     270
     271  //the number in the map will be written on the node
     272  //EXCEPT when the name of the map is Text, because
     273  //in that case empty string will be written, because
     274  //that is the deleter map
     275
     276  if(node==INVALID)
     277    {
     278      for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     279        {
     280          nodemap_to_edit="";
     281          nodetextmap[i]->property_text().set_value("");
     282        }
     283    }
     284  else
     285    {
     286      nodetextmap[node]->property_text().set_value("");
     287    }
     288  return 0;
     289};
  • gui/graph_displayer_canvas.h

    r1648 r1731  
    2525  ///\param mapname is the name of the map which contains the new values
    2626  int changeEdgeWidth (std::string mapname, Edge new_item=INVALID);
     27  int resetEdgeWidth (Edge new_item=INVALID);
    2728
    2829  ///Changes the linecolor attribute according to the given map.
    2930  ///\param mapname is the name of the map which contains the new values
    3031  int changeEdgeColor (std::string mapname, Edge new_item=INVALID);
     32  int resetEdgeColor (Edge new_item=INVALID);
    3133
    3234  ///Changes the text of line attribute according to the given map.
    3335  ///\param mapname is the name of the map which contains the new values
    3436  int changeEdgeText (std::string mapname, Edge new_item=INVALID);
     37  int resetEdgeText (Edge new_item=INVALID);
    3538
    3639  ///Changes the linewidth attribute according to the given map.
    3740  ///\param mapname is the name of the map which contains the new values
    3841  int changeNodeRadius (std::string mapname, Node new_item=INVALID);
     42  int resetNodeRadius (Node new_item=INVALID);
    3943
    4044  ///Changes the linecolor attribute according to the given map.
    4145  ///\param mapname is the name of the map which contains the new values
    4246  int changeNodeColor (std::string mapname, Node new_item=INVALID);
     47  int resetNodeColor (Node new_item=INVALID);
    4348
    4449  ///Changes the text of line attribute according to the given map.
    4550  ///\param mapname is the name of the map which contains the new values
    4651  int changeNodeText (std::string mapname, Node new_item=INVALID);
     52  int resetNodeText (Node new_item=INVALID);
    4753
    4854  ///Callback for 'ViewZoomIn' action.
  • gui/map_win.cc

    r1648 r1731  
    1818  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
    1919
    20   e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM];
     20  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
    2121
    22   table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false);
     22  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
    2323
    2424  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    2525  {
    26     //filling in combo box with choices
    27     std::list<Glib::ustring> listStrings;
     26    e_combo_array[i]=new MapSelector(gdc, ms, *this, i, true);
    2827
    29     listStrings.push_back("Default");
    30 
    31     std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
    32     for(;emsi!=ms.endOfEdgeMaps();emsi++)
    33     {
    34         listStrings.push_back(emsi->first);
    35     }
    36 
    37     e_combo_array[i].set_popdown_strings(listStrings);
    38 
    39     //Restrict it to these choices only:
    40     e_combo_array[i].set_value_in_list();
    41 
    42     //binding signal to the actual entry
    43     e_combo_array[i].get_entry()->signal_changed().connect
    44     (
    45      sigc::bind
    46      (
    47       sigc::mem_fun(*this, &MapWin::eComboChanged),
    48       i
    49      )
    50     );
    51 
    52     //placing actual entry in the right place
    53 
    54     label=new Gtk::Label;
    55     label->set_text(edge_property_strings[i]);
    56        
    57     (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    58     (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    59 
    60 
     28    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    6129  }
    6230
     
    6735  vbox.pack_start(*(new Gtk::HSeparator));
    6836
    69   n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
     37  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
    7038
    71   table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
     39  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
    7240
    7341  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    7442  {
    75     //filling in combo box with choices
    76     std::list<Glib::ustring> listStrings;
     43    n_combo_array[i]=new MapSelector(gdc, ms, *this, i, false);
    7744
    78     listStrings.push_back("Default");
    79 
    80     std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
    81 
    82     for(;emsi!=ms.endOfNodeMaps();emsi++)
    83     {
    84       if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y"))
    85       {
    86         listStrings.push_back(emsi->first);
    87       }
    88     }
    89 
    90     n_combo_array[i].set_popdown_strings(listStrings);
    91 
    92     //Restrict it to these choices only:
    93     n_combo_array[i].set_value_in_list();
    94 
    95     //binding signal to thew actual entry
    96     n_combo_array[i].get_entry()->signal_changed().connect
    97     (
    98      sigc::bind
    99      (
    100       sigc::mem_fun(*this, &MapWin::nComboChanged),
    101       i
    102      )
    103     );
    104 
    105     //placing actual entry in the right place
    106 
    107     label=new Gtk::Label;
    108     label->set_text(node_property_strings[i]);
    109        
    110     (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    111     (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    112 
    113 
     45    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    11446  }
    11547
     
    12860  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    12961  {
    130     //filling in combo box with choices
    131     std::list<Glib::ustring> listStrings;
     62    e_combo_array[i]->update_list();
     63  }
    13264
    133     listStrings.push_back("Default");
    134 
    135     std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
    136     for(;emsi!=ms.endOfEdgeMaps();emsi++)
    137     {
    138       listStrings.push_back(emsi->first);
    139     }
    140 
    141     e_combo_array[i].set_popdown_strings(listStrings);
    142   }
    14365  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    14466  {
    145     //filling in combo box with choices
    146     std::list<Glib::ustring> listStrings;
    147 
    148     listStrings.push_back("Default");
    149 
    150     std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
    151 
    152     for(;emsi!=ms.endOfNodeMaps();emsi++)
    153     {
    154       if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y"))
    155       {
    156         listStrings.push_back(emsi->first);
    157       }
    158     }
    159 
    160     n_combo_array[i].set_popdown_strings(listStrings);
     67    n_combo_array[i]->update_list();
    16168  }
    16269}
    16370
    164 void MapWin::eComboChanged(int prop)
    165 {
    166 
    167   Gtk::Entry* entry = e_combo_array[prop].get_entry();
    168 
    169   if(entry)
    170   {
    171     Glib::ustring mapname = entry->get_text();
    172     if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
    173     {
    174       if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
    175       {
    176         switch(prop)
    177         {
    178           case E_WIDTH:
    179             gdc.changeEdgeWidth(mapname);
    180             break;
    181           case E_COLOR:
    182             gdc.changeEdgeColor(mapname);
    183             break;
    184           case E_TEXT:
    185             gdc.changeEdgeText(mapname);
    186             break;
    187           default:
    188             std::cerr<<"Error\n";
    189         }
    190       }
    191     }
    192   }
    193 };
    194 
    195 void MapWin::nComboChanged(int prop)
    196 {
    197 
    198   Gtk::Entry* entry = n_combo_array[prop].get_entry();
    199 
    200   if(entry)
    201   {
    202     Glib::ustring mapname = entry->get_text();
    203     if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
    204     {
    205       if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
    206       {
    207         switch(prop)
    208         {
    209           case N_RADIUS:
    210             gdc.changeNodeRadius(mapname);
    211             break;
    212           case N_COLOR:
    213             gdc.changeNodeColor(mapname);
    214             break;
    215           case N_TEXT:
    216             gdc.changeNodeText(mapname);
    217             break;
    218           default:
    219             std::cerr<<"Error\n";
    220         }
    221       }
    222     }
    223   }
    224 };
    22571
    22672void MapWin::updateNode(Node node)
     
    22874  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    22975    {
    230       Gtk::Entry* entry = n_combo_array[i].get_entry();
    231 
    232       if(entry)
    233         {
    234           Glib::ustring mapname = entry->get_text();
    235           if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
    236             {
    237               if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
    238                 {
    239                   switch(i)
    240                     {
    241                     case N_RADIUS:
    242                       gdc.changeNodeRadius(mapname, node);
    243                       break;
    244                     case N_COLOR:
    245                       gdc.changeNodeColor(mapname, node);
    246                       break;
    247                     case N_TEXT:
    248                       gdc.changeNodeText(mapname, node);
    249                       break;
    250                     default:
    251                       std::cerr<<"Error\n";
    252                     }
    253                 }
    254             }
    255         }
     76      n_combo_array[i]->update(node);
    25677    }
    25778}
     
    26182  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    26283    {
    263 
    264       Gtk::Entry* entry = e_combo_array[i].get_entry();
    265 
    266       if(entry)
    267         {
    268           Glib::ustring mapname = entry->get_text();
    269           if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
    270             {
    271 
    272               if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
    273                 {
    274                   switch(i)
    275                     {
    276                     case E_WIDTH:
    277                       gdc.changeEdgeWidth(mapname, edge);
    278                       break;
    279                     case E_COLOR:
    280                       gdc.changeEdgeColor(mapname, edge);
    281                       break;
    282                     case E_TEXT:
    283                       gdc.changeEdgeText(mapname, edge);
    284                       break;
    285                     default:
    286                       std::cerr<<"Error\n";
    287                     }
    288                 }
    289             }
    290         }
     84      e_combo_array[i]->update(edge);
    29185    }
    29286}
     
    29791  {
    29892    //filling in combo box with choices
    299     std::list<Glib::ustring> listStrings=e_combo_array[i].get_popdown_strings();
    300     listStrings.push_back(newmapname);
    301     e_combo_array[i].set_popdown_strings(listStrings);
     93    e_combo_array[i]->append_text((Glib::ustring)newmapname);
    30294  }
    30395  //setting text property for the new map
    304   Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry();
    305   entry->set_text((Glib::ustring)newmapname);
     96  e_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
    30697}
    30798
     
    311102  {
    312103    //filling in combo box with choices
    313     std::list<Glib::ustring> listStrings=n_combo_array[i].get_popdown_strings();
    314     listStrings.push_back(newmapname);
    315     n_combo_array[i].set_popdown_strings(listStrings);
     104    e_combo_array[i]->append_text((Glib::ustring)newmapname);
    316105  }
    317106  //setting text property for the new map
    318   Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry();
    319   entry->set_text((Glib::ustring)newmapname);
     107  n_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
    320108}
  • gui/map_win.h

    r1606 r1731  
    99#include "graph_displayer_canvas.h"
    1010#include "mapstorage.h"
     11#include "mapselector.h"
    1112#include <libgnomecanvasmm.h>
    1213#include <libgnomecanvasmm/polygon.h>
     
    2930  Gtk::Table * table;
    3031 
    31   Gtk::Combo * e_combo_array, * n_combo_array;
     32  MapSelector ** e_combo_array, ** n_combo_array;
    3233
    3334  Gtk::Label * label;
     
    3839  ///Constructor of MapWin creates the widgets shown in MapWin.
    3940  MapWin(const std::string& title, MapStorage &, GraphDisplayerCanvas &);
    40 
    41   ///If a radiobutton is clicked, this function determines
    42   ///which button was that and after that calls the
    43   ///appropriate function of the \ref GraphDisplayerCanvas
    44   ///to change the visible values of that attribute.
    45   virtual void eComboChanged(int);
    46   ///If a radiobutton is clicked, this function determines
    47   ///which button was that and after that calls the
    48   ///appropriate function of the \ref GraphDisplayerCanvas
    49   ///to change the visible values of that attribute.
    50   virtual void nComboChanged(int);
    5141
    5242  ///This function is created to set the appropriate maps on the newly created node
Note: See TracChangeset for help on using the changeset viewer.