graph_displayer_canvas-edge.cc
changeset 196 c220f9de6545
parent 179 1f436ea3ef4f
child 201 879e47e5b731
equal deleted inserted replaced
25:b44d8b3e680c 26:a7ee51c142a4
    14  * express or implied, and with no claim as to its suitability for any
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    15  * purpose.
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 #include "graph_displayer_canvas.h"
    19 #include <graph_displayer_canvas.h>
       
    20 #include <mapstorage.h>
       
    21 #include <nbtab.h>
    20 #include <cmath>
    22 #include <cmath>
    21 
    23 
    22 const int minimum_edge_width=0;
    24 const int minimum_edge_width=0;
    23 
    25 
    24 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
    26 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
    25 {
    27 {
    26   double min, max;
    28   double min, max;
    27 
    29 
    28   min=edge_property_defaults[E_WIDTH];
    30   min=edge_property_defaults[E_WIDTH];
    29   max=edge_property_defaults[E_WIDTH];
    31   max=edge_property_defaults[E_WIDTH];
    30   Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_WIDTH]);
    32   Graph::EdgeMap<double> actual_map((mytab.mapstorage)->graph,edge_property_defaults[E_WIDTH]);
    31   
    33   
    32   if(edge==INVALID)
    34   if(edge==INVALID)
    33     {
    35     {
    34       for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    36       for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
    35 	{
    37 	{
    36 	  double v=fabs(actual_map[i]);
    38 	  double v=fabs(actual_map[i]);
    37 	  int w;
    39 	  int w;
    38 	  if(min==max)
    40 	  if(min==max)
    39 	    {
    41 	    {
    66 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
    68 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
    67 {
    69 {
    68   Graph::EdgeMap<double> * actual_map;
    70   Graph::EdgeMap<double> * actual_map;
    69   double min, max;
    71   double min, max;
    70 
    72 
    71   min=(mytab.mapstorage).minOfEdgeMap(mapname);
    73   min=(mytab.mapstorage)->minOfEdgeMap(mapname);
    72   max=(mytab.mapstorage).maxOfEdgeMap(mapname);
    74   max=(mytab.mapstorage)->maxOfEdgeMap(mapname);
    73   actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
    75   actual_map=((mytab.mapstorage)->edgemap_storage)[mapname];
    74 
    76 
    75   if(edge==INVALID)
    77   if(edge==INVALID)
    76     {
    78     {
    77       for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    79       for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
    78 	{
    80 	{
    79 	  double v=(*actual_map)[i];
    81 	  double v=(*actual_map)[i];
    80 	  int w;
    82 	  int w;
    81 	  if(autoscale)
    83 	  if(autoscale)
    82 	    {
    84 	    {
   129 
   131 
   130   //function maps the range of the maximum and
   132   //function maps the range of the maximum and
   131   //the minimum of the nodemap to the range of
   133   //the minimum of the nodemap to the range of
   132   //green in RGB
   134   //green in RGB
   133   Graph::EdgeMap<double> * actual_map;
   135   Graph::EdgeMap<double> * actual_map;
   134   actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
   136   actual_map=((mytab.mapstorage)->edgemap_storage)[mapname];
   135 
   137 
   136   double max, min;
   138   double max, min;
   137 
   139 
   138   max=(mytab.mapstorage).maxOfEdgeMap(mapname);
   140   max=(mytab.mapstorage)->maxOfEdgeMap(mapname);
   139   min=(mytab.mapstorage).minOfEdgeMap(mapname);
   141   min=(mytab.mapstorage)->minOfEdgeMap(mapname);
   140 
   142 
   141   if(edge==INVALID)
   143   if(edge==INVALID)
   142     {
   144     {
   143       for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   145       for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   144 	{
   146 	{
   145 	  double w=(*actual_map)[i];
   147 	  double w=(*actual_map)[i];
   146 
   148 
   147 	  Gdk::Color color;
   149 	  Gdk::Color color;
   148 	  if(max!=min)
   150 	  if(max!=min)
   180 {  
   182 {  
   181 
   183 
   182   //function maps the range of the maximum and
   184   //function maps the range of the maximum and
   183   //the minimum of the nodemap to the range of
   185   //the minimum of the nodemap to the range of
   184   //green in RGB
   186   //green in RGB
   185   Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_COLOR]);
   187   Graph::EdgeMap<double> actual_map((mytab.mapstorage)->graph,edge_property_defaults[E_COLOR]);
   186 
   188 
   187   double max, min;
   189   double max, min;
   188 
   190 
   189   max=edge_property_defaults[E_COLOR];
   191   max=edge_property_defaults[E_COLOR];
   190   min=edge_property_defaults[E_COLOR];
   192   min=edge_property_defaults[E_COLOR];
   191 
   193 
   192   if(edge==INVALID)
   194   if(edge==INVALID)
   193     {
   195     {
   194       for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   196       for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   195 	{
   197 	{
   196 	  double w=actual_map[i];
   198 	  double w=actual_map[i];
   197 
   199 
   198 	  Gdk::Color color;
   200 	  Gdk::Color color;
   199 	  if(max!=min)
   201 	  if(max!=min)
   234   //in that case empty string will be written, because
   236   //in that case empty string will be written, because
   235   //that is the deleter map
   237   //that is the deleter map
   236   
   238   
   237   if(edge==INVALID)
   239   if(edge==INVALID)
   238     {
   240     {
   239       for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   241       for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   240 	{
   242 	{
   241 	  edgemap_to_edit=mapname;
   243 	  edgemap_to_edit=mapname;
   242 	  double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[i];
   244 	  double number=(*((mytab.mapstorage)->edgemap_storage)[mapname])[i];
   243 	  
   245 	  
   244 	  std::ostringstream ostr;
   246 	  std::ostringstream ostr;
   245 	  ostr << number;
   247 	  ostr << number;
   246 	  
   248 	  
   247 	  edgetextmap[i]->property_text().set_value(ostr.str());
   249 	  edgetextmap[i]->property_text().set_value(ostr.str());
   248 	}
   250 	}
   249 
   251 
   250     }
   252     }
   251   else
   253   else
   252     {
   254     {
   253 	  double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[edge];
   255 	  double number=(*((mytab.mapstorage)->edgemap_storage)[mapname])[edge];
   254 
   256 
   255 	  std::ostringstream ostr;
   257 	  std::ostringstream ostr;
   256 	  ostr << number;
   258 	  ostr << number;
   257 	  
   259 	  
   258 	  edgetextmap[edge]->property_text().set_value(ostr.str());
   260 	  edgetextmap[edge]->property_text().set_value(ostr.str());
   269   //in that case empty string will be written, because
   271   //in that case empty string will be written, because
   270   //that is the deleter map
   272   //that is the deleter map
   271   
   273   
   272   if(edge==INVALID)
   274   if(edge==INVALID)
   273     {
   275     {
   274       for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   276       for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   275 	{
   277 	{
   276 	  edgemap_to_edit="";
   278 	  edgemap_to_edit="";
   277 	  edgetextmap[i]->property_text().set_value("");
   279 	  edgetextmap[i]->property_text().set_value("");
   278 	}
   280 	}
   279 
   281