graph_displayer_canvas-node.cc
changeset 201 879e47e5b731
parent 194 6b2b718420eb
     1.1 --- a/graph_displayer_canvas-node.cc	Wed May 02 20:33:58 2007 +0000
     1.2 +++ b/graph_displayer_canvas-node.cc	Wed Jan 02 21:03:09 2008 +0000
     1.3 @@ -25,17 +25,27 @@
     1.4  
     1.5  int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
     1.6  {
     1.7 -  Graph::NodeMap<double> * actual_map;
     1.8 +  MapStorage& ms = *mytab.mapstorage;
     1.9 +
    1.10    double min, max;
    1.11 -  min=(mytab.mapstorage)->minOfNodeMap(mapname);
    1.12 -  max=(mytab.mapstorage)->maxOfNodeMap(mapname);
    1.13 -  actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
    1.14 +
    1.15 +  {
    1.16 +    NodeIt n(ms.graph);
    1.17 +    min = max = ms.get(mapname, n);
    1.18 +    for (; n != INVALID; ++n)
    1.19 +    {
    1.20 +      if (static_cast<double>(ms.get(mapname, n)) > max)
    1.21 +        max = ms.get(mapname, n);
    1.22 +      if (static_cast<double>(ms.get(mapname, n)) < min)
    1.23 +        min = ms.get(mapname, n);
    1.24 +    }
    1.25 +  }
    1.26  
    1.27    if(node==INVALID)
    1.28      {
    1.29 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
    1.30 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    1.31  	{
    1.32 -	  double v=fabs((*actual_map)[i]);
    1.33 +	  double v=fabs(ms.get(mapname,i));
    1.34  	  int w;
    1.35  	  if(autoscale)
    1.36  	    {
    1.37 @@ -102,14 +112,16 @@
    1.38  
    1.39  int GraphDisplayerCanvas::resetNodeRadius (Node node)
    1.40  {
    1.41 +  MapStorage& ms = *mytab.mapstorage;
    1.42 +
    1.43    double min, max;
    1.44    min=node_property_defaults[N_RADIUS];
    1.45    max=node_property_defaults[N_RADIUS];
    1.46 -  Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_RADIUS]);
    1.47 +  Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_RADIUS]);
    1.48    
    1.49    if(node==INVALID)
    1.50      {
    1.51 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
    1.52 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    1.53  	{
    1.54  	  double v=fabs(actual_map[i]);
    1.55  	  int w;
    1.56 @@ -163,27 +175,34 @@
    1.57  
    1.58  int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
    1.59  {  
    1.60 +  MapStorage& ms = *mytab.mapstorage;
    1.61  
    1.62    //function maps the range of the maximum and
    1.63    //the minimum of the nodemap to the range of
    1.64    //green in RGB
    1.65  
    1.66 -  Graph::NodeMap<double> * actual_map;
    1.67 -  actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
    1.68 -
    1.69    double max, min;
    1.70  
    1.71 -  max=(mytab.mapstorage)->maxOfNodeMap(mapname);
    1.72 -  min=(mytab.mapstorage)->minOfNodeMap(mapname);
    1.73 +  {
    1.74 +    NodeIt n(ms.graph);
    1.75 +    min = max = ms.get(mapname, n);
    1.76 +    for (; n != INVALID; ++n)
    1.77 +    {
    1.78 +      if (static_cast<double>(ms.get(mapname, n)) > max)
    1.79 +        max = ms.get(mapname, n);
    1.80 +      if (static_cast<double>(ms.get(mapname, n)) < min)
    1.81 +        min = ms.get(mapname, n);
    1.82 +    }
    1.83 +  }
    1.84  
    1.85    if(node==INVALID)
    1.86      {
    1.87  
    1.88 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
    1.89 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    1.90  	{
    1.91  	  Gdk::Color color;
    1.92  
    1.93 -	  double w=(*actual_map)[i];
    1.94 +	  double w=ms.get(mapname, i);
    1.95  
    1.96  	  if(max!=min)
    1.97  	    {
    1.98 @@ -201,7 +220,7 @@
    1.99      {
   1.100        Gdk::Color color;
   1.101  
   1.102 -      double w=(*actual_map)[node];
   1.103 +      double w=ms.get(mapname, node);
   1.104  
   1.105        if(max!=min)
   1.106  	{
   1.107 @@ -219,12 +238,13 @@
   1.108  
   1.109  int GraphDisplayerCanvas::resetNodeColor (Node node)
   1.110  {  
   1.111 +  MapStorage& ms = *mytab.mapstorage;
   1.112  
   1.113    //function maps the range of the maximum and
   1.114    //the minimum of the nodemap to the range of
   1.115    //green in RGB
   1.116  
   1.117 -  Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_COLOR]);
   1.118 +  Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_COLOR]);
   1.119  
   1.120    double max, min;
   1.121  
   1.122 @@ -234,7 +254,7 @@
   1.123    if(node==INVALID)
   1.124      {
   1.125  
   1.126 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   1.127 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
   1.128  	{
   1.129  	  Gdk::Color color;
   1.130  
   1.131 @@ -274,42 +294,7 @@
   1.132  
   1.133  int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
   1.134  {
   1.135 -
   1.136 -  //the number in the map will be written on the node
   1.137 -  //EXCEPT when the name of the map is Text, because
   1.138 -  //in that case empty string will be written, because
   1.139 -  //that is the deleter map
   1.140 -
   1.141 -  Graph::NodeMap<double> * actual_map=NULL;
   1.142 -  actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
   1.143 -
   1.144 -  if(node==INVALID)
   1.145 -    {
   1.146 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   1.147 -	{
   1.148 -	  nodemap_to_edit=mapname;
   1.149 -	  double number=(*actual_map)[i];
   1.150 -
   1.151 -	  std::ostringstream ostr;
   1.152 -	  ostr << number;
   1.153 -	      
   1.154 -	  nodetextmap[i]->property_text().set_value(ostr.str());
   1.155 -	}
   1.156 -    }
   1.157 -  else
   1.158 -    {
   1.159 -      double number=(*actual_map)[node];
   1.160 -
   1.161 -      std::ostringstream ostr;
   1.162 -      ostr << number;
   1.163 -	      
   1.164 -      nodetextmap[node]->property_text().set_value(ostr.str());
   1.165 -    }
   1.166 -  return 0;
   1.167 -};
   1.168 -
   1.169 -int GraphDisplayerCanvas::resetNodeText (Node node)
   1.170 -{
   1.171 +  MapStorage& ms = *mytab.mapstorage;
   1.172  
   1.173    //the number in the map will be written on the node
   1.174    //EXCEPT when the name of the map is Text, because
   1.175 @@ -318,7 +303,34 @@
   1.176  
   1.177    if(node==INVALID)
   1.178      {
   1.179 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   1.180 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
   1.181 +	{
   1.182 +	  nodemap_to_edit=mapname;
   1.183 +
   1.184 +	  nodetextmap[i]->property_text().set_value(
   1.185 +              static_cast<std::string>(ms.get(mapname, i)));
   1.186 +	}
   1.187 +    }
   1.188 +  else
   1.189 +    {
   1.190 +      nodetextmap[node]->property_text().set_value(
   1.191 +          static_cast<std::string>(ms.get(mapname, node)));
   1.192 +    }
   1.193 +  return 0;
   1.194 +};
   1.195 +
   1.196 +int GraphDisplayerCanvas::resetNodeText (Node node)
   1.197 +{
   1.198 +  MapStorage& ms = *mytab.mapstorage;
   1.199 +
   1.200 +  //the number in the map will be written on the node
   1.201 +  //EXCEPT when the name of the map is Text, because
   1.202 +  //in that case empty string will be written, because
   1.203 +  //that is the deleter map
   1.204 +
   1.205 +  if(node==INVALID)
   1.206 +    {
   1.207 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
   1.208  	{
   1.209  	  nodemap_to_edit="";
   1.210  	  nodetextmap[i]->property_text().set_value("");