gui/map_win.cc
changeset 1512 e54392395480
parent 1446 320f73c5cfc1
child 1524 587a823bcdd0
     1.1 --- a/gui/map_win.cc	Fri Jun 24 08:44:54 2005 +0000
     1.2 +++ b/gui/map_win.cc	Fri Jun 24 18:16:12 2005 +0000
     1.3 @@ -10,16 +10,18 @@
     1.4    return true;
     1.5  }
     1.6  
     1.7 -MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false)
     1.8 +MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
     1.9  {
    1.10    set_title(title);
    1.11    set_default_size(200, 50);
    1.12  
    1.13    signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed));
    1.14  
    1.15 -  combo_array=new Gtk::Combo [PROPERTY_NUM];
    1.16 +  e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM];
    1.17  
    1.18 -  for(int i=0;i<PROPERTY_NUM;i++)
    1.19 +  table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false);
    1.20 +
    1.21 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    1.22    {
    1.23  
    1.24      std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
    1.25 @@ -35,8 +37,8 @@
    1.26        {
    1.27  	actprop=j;
    1.28        }
    1.29 -      //this is the other maps to show for this property
    1.30 -      for(int k=0;k<PROPERTY_NUM;k++)
    1.31 +      //these are the maps NOT to show for this property
    1.32 +      for(int k=0;k<EDGE_PROPERTY_NUM;k++)
    1.33        {
    1.34  	if(emsi->second==&(ms.default_edgemaps[k]))
    1.35  	{
    1.36 @@ -46,8 +48,6 @@
    1.37        emsi++;
    1.38      }
    1.39  
    1.40 -    //combo_array[i].set_group(group);
    1.41 -
    1.42      //filling in combo box with choices
    1.43      std::list<Glib::ustring> listStrings;
    1.44  
    1.45 @@ -64,17 +64,17 @@
    1.46        emsi++;
    1.47      }
    1.48  
    1.49 -    combo_array[i].set_popdown_strings(listStrings);
    1.50 +    e_combo_array[i].set_popdown_strings(listStrings);
    1.51  
    1.52      //Restrict it to these choices only:
    1.53 -    combo_array[i].set_value_in_list();
    1.54 +    e_combo_array[i].set_value_in_list();
    1.55  
    1.56 -    //binding signal to thew actual entry
    1.57 -    combo_array[i].get_entry()->signal_changed().connect
    1.58 +    //binding signal to the actual entry
    1.59 +    e_combo_array[i].get_entry()->signal_changed().connect
    1.60      (
    1.61       sigc::bind
    1.62       (
    1.63 -      sigc::mem_fun(*this, &MapWin::combo_changed),
    1.64 +      sigc::mem_fun(*this, &MapWin::e_combo_changed),
    1.65        i
    1.66       )
    1.67      );
    1.68 @@ -82,44 +82,106 @@
    1.69      //placing actual entry in the right place
    1.70  
    1.71      label=new Gtk::Label;
    1.72 -    label->set_text(property_strings[i]);
    1.73 +    label->set_text(edge_property_strings[i]);
    1.74 +        
    1.75 +    (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    1.76 +    (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    1.77  
    1.78 -    //    labelpluscombo=new Gtk::HBox;
    1.79 -    //    labelpluscombo->pack_start(*label);
    1.80 -    //    labelpluscombo->pack_start(combo_array[i]);
    1.81 -        
    1.82 -    table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    1.83 -    table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    1.84 -
    1.85 -    /*
    1.86 -    if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2)
    1.87 -    {
    1.88 -      vbox_r1.pack_start(*labelpluscombo);
    1.89 -    }
    1.90 -    else
    1.91 -    {
    1.92 -      vbox_r2.pack_start(*labelpluscombo);
    1.93 -    }
    1.94 -    actpos++;
    1.95 -    //*/
    1.96  
    1.97    }
    1.98  
    1.99 -  combos.pack_start(vbox_r1);
   1.100 -  combos.pack_start(vbox_r2);
   1.101 +  vbox.pack_start(*(new Gtk::Label("Edge properties")));
   1.102  
   1.103 -  //add(combos);
   1.104 -  add(table);
   1.105 +  vbox.pack_start(*table);
   1.106 +
   1.107 +  vbox.pack_start(*(new Gtk::HSeparator));
   1.108 +
   1.109 +  n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
   1.110 +
   1.111 +  table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
   1.112 +
   1.113 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
   1.114 +  {
   1.115 +
   1.116 +    std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
   1.117 +    std::set<int> props;
   1.118 +
   1.119 +    int actprop;
   1.120 +
   1.121 +    //here we find out, which map is the default in MapStorage for this property, which are not
   1.122 +    for(int j=0;j<ms.numOfNodeMaps();j++)
   1.123 +    {
   1.124 +      //these are the maps NOT to show for this property
   1.125 +      if(emsi->second==&(ms.default_nodemaps[i]))
   1.126 +      {
   1.127 +	actprop=j;
   1.128 +      }
   1.129 +      //this is the other maps to show for this property
   1.130 +      for(int k=0;k<NODE_PROPERTY_NUM;k++)
   1.131 +      {
   1.132 +	if(emsi->second==&(ms.default_nodemaps[k]))
   1.133 +	{
   1.134 +	  props.insert(j);
   1.135 +	}
   1.136 +      }
   1.137 +      emsi++;
   1.138 +    }
   1.139 +
   1.140 +    //filling in combo box with choices
   1.141 +    std::list<Glib::ustring> listStrings;
   1.142 +
   1.143 +    listStrings.push_back("Default");
   1.144 +
   1.145 +    emsi=ms.beginOfNodeMaps();
   1.146 +
   1.147 +    for(int j=0;j<ms.numOfNodeMaps();j++)
   1.148 +    {
   1.149 +      if( ( props.find(j) )==( props.end() ) )
   1.150 +      {
   1.151 +	listStrings.push_back(emsi->first);
   1.152 +      }
   1.153 +      emsi++;
   1.154 +    }
   1.155 +
   1.156 +    n_combo_array[i].set_popdown_strings(listStrings);
   1.157 +
   1.158 +    //Restrict it to these choices only:
   1.159 +    n_combo_array[i].set_value_in_list();
   1.160 +
   1.161 +    //binding signal to thew actual entry
   1.162 +    n_combo_array[i].get_entry()->signal_changed().connect
   1.163 +    (
   1.164 +     sigc::bind
   1.165 +     (
   1.166 +      sigc::mem_fun(*this, &MapWin::n_combo_changed),
   1.167 +      i
   1.168 +     )
   1.169 +    );
   1.170 +
   1.171 +    //placing actual entry in the right place
   1.172 +
   1.173 +    label=new Gtk::Label;
   1.174 +    label->set_text(node_property_strings[i]);
   1.175 +        
   1.176 +    (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   1.177 +    (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   1.178 +
   1.179 +
   1.180 +  }
   1.181 +
   1.182 +  add(vbox);
   1.183 +
   1.184 +  vbox.pack_start(*(new Gtk::Label("Node properties")));
   1.185 +
   1.186 +  vbox.pack_start(*table);
   1.187  
   1.188    show_all_children();
   1.189  
   1.190  }
   1.191  
   1.192 -void MapWin::combo_changed(int prop)
   1.193 +void MapWin::e_combo_changed(int prop)
   1.194  {
   1.195 -
   1.196 -  //most nem kommentezem fel, mert ugyis valtozik
   1.197 -  Gtk::Entry* entry = combo_array[prop].get_entry();
   1.198 +  Gtk::Entry* entry = e_combo_array[prop].get_entry();
   1.199  
   1.200    if(entry)
   1.201    {
   1.202 @@ -128,21 +190,21 @@
   1.203      {
   1.204        if(mapname=="Default")
   1.205        {
   1.206 -	mapname=property_strings[prop];
   1.207 +	mapname=edge_property_strings[prop];
   1.208        }
   1.209  
   1.210        if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() )
   1.211        {
   1.212  	switch(prop)
   1.213  	{
   1.214 -          case WIDTH:
   1.215 -	    gdc.changeLineWidth(mapname);
   1.216 +          case E_WIDTH:
   1.217 +	    gdc.changeEdgeWidth(mapname);
   1.218  	    break;
   1.219 -          case COLOR:
   1.220 -	    gdc.changeColor(mapname);
   1.221 +          case E_COLOR:
   1.222 +	    gdc.changeEdgeColor(mapname);
   1.223  	    break;
   1.224 -          case TEXT:
   1.225 -	    gdc.changeText(mapname);
   1.226 +          case E_TEXT:
   1.227 +	    gdc.changeEdgeText(mapname);
   1.228  	    break;
   1.229            default:
   1.230  	    std::cout<<"Error\n";
   1.231 @@ -151,3 +213,118 @@
   1.232      }
   1.233    }
   1.234  };
   1.235 +
   1.236 +void MapWin::n_combo_changed(int prop)
   1.237 +{
   1.238 +
   1.239 +  Gtk::Entry* entry = n_combo_array[prop].get_entry();
   1.240 +
   1.241 +  if(entry)
   1.242 +  {
   1.243 +    Glib::ustring mapname = entry->get_text();
   1.244 +    if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
   1.245 +    {
   1.246 +      if(mapname=="Default")
   1.247 +      {
   1.248 +	mapname=node_property_strings[prop];
   1.249 +      }
   1.250 +
   1.251 +      if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() )
   1.252 +      {
   1.253 +	switch(prop)
   1.254 +	{
   1.255 +          case N_RADIUS:
   1.256 +	    gdc.changeNodeRadius(mapname);
   1.257 +	    break;
   1.258 +          case N_COLOR:
   1.259 +	    gdc.changeNodeColor(mapname);
   1.260 +	    break;
   1.261 +          case N_TEXT:
   1.262 +	    gdc.changeNodeText(mapname);
   1.263 +	    break;
   1.264 +          default:
   1.265 +	    std::cout<<"Error\n";
   1.266 +	}
   1.267 +      }
   1.268 +    }
   1.269 +  }
   1.270 +};
   1.271 +
   1.272 +void MapWin::update_node(Graph::Node node)
   1.273 +{
   1.274 +  for(int i=0;i<NODE_PROPERTY_NUM;i++)
   1.275 +    {
   1.276 +      Gtk::Entry* entry = n_combo_array[i].get_entry();
   1.277 +
   1.278 +      if(entry)
   1.279 +	{
   1.280 +	  Glib::ustring mapname = entry->get_text();
   1.281 +	  if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
   1.282 +	    {
   1.283 +	      if(mapname=="Default")
   1.284 +		{
   1.285 +		  mapname=node_property_strings[i];
   1.286 +		}
   1.287 +
   1.288 +	      if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() )
   1.289 +		{
   1.290 +		  switch(i)
   1.291 +		    {
   1.292 +		    case N_RADIUS:
   1.293 +		      //gdc.changeNodeRadius(mapname, node);
   1.294 +		      std::cout << "If default map-value problem is solved, uncomment line in MapWin::node_update!" << std::endl;
   1.295 +		      break;
   1.296 +		    case N_COLOR:
   1.297 +		      gdc.changeNodeColor(mapname, node);
   1.298 +		      break;
   1.299 +		    case N_TEXT:
   1.300 +		      gdc.changeNodeText(mapname, node);
   1.301 +		      break;
   1.302 +		    default:
   1.303 +		      std::cout<<"Error\n";
   1.304 +		    }
   1.305 +		}
   1.306 +	    }
   1.307 +	}
   1.308 +    }
   1.309 +}
   1.310 +
   1.311 +void MapWin::update_edge(Graph::Edge edge)
   1.312 +{
   1.313 +  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   1.314 +    {
   1.315 +
   1.316 +      Gtk::Entry* entry = e_combo_array[i].get_entry();
   1.317 +
   1.318 +      if(entry)
   1.319 +	{
   1.320 +	  Glib::ustring mapname = entry->get_text();
   1.321 +	  if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
   1.322 +	    {
   1.323 +	      if(mapname=="Default")
   1.324 +		{
   1.325 +		  mapname=edge_property_strings[i];
   1.326 +		}
   1.327 +
   1.328 +	      if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() )
   1.329 +		{
   1.330 +		  switch(i)
   1.331 +		    {
   1.332 +		    case E_WIDTH:
   1.333 +		      //gdc.changeEdgeWidth(mapname, edge);
   1.334 +		      std::cout << "If default map-value problem is solved, uncomment line in MapWin::edge_update!" << std::endl;
   1.335 +		      break;
   1.336 +		    case E_COLOR:
   1.337 +		      gdc.changeEdgeColor(mapname, edge);
   1.338 +		      break;
   1.339 +		    case E_TEXT:
   1.340 +		      gdc.changeEdgeText(mapname, edge);
   1.341 +		      break;
   1.342 +		    default:
   1.343 +		      std::cout<<"Error\n";
   1.344 +		    }
   1.345 +		}
   1.346 +	    }
   1.347 +	}
   1.348 +    }
   1.349 +}