COIN-OR::LEMON - Graph Library

Changeset 1837:8dd6160ff699 in lemon-0.x


Ignore:
Timestamp:
11/29/05 20:31:58 (18 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2389
Message:

Structure of GUI is now more clear-cut than before.

Location:
gui
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • gui/graph_displayer_canvas-edge.cc

    r1825 r1837  
    99  min=edge_property_defaults[E_WIDTH];
    1010  max=edge_property_defaults[E_WIDTH];
    11   Graph::EdgeMap<double> actual_map(mapstorage.graph,edge_property_defaults[E_WIDTH]);
     11  Graph::EdgeMap<double> actual_map((mainwin.mapstorage).graph,edge_property_defaults[E_WIDTH]);
    1212 
    1313  if(edge==INVALID)
    1414    {
    15       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     15      for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    1616        {
    1717          double v=fabs(actual_map[i]);
     
    4545  double min, max;
    4646
    47   min=mapstorage.minOfEdgeMap(mapname);
    48   max=mapstorage.maxOfEdgeMap(mapname);
    49   actual_map=(mapstorage.edgemap_storage)[mapname];
    50 
    51   if(edge==INVALID)
    52     {
    53       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     47  min=(mainwin.mapstorage).minOfEdgeMap(mapname);
     48  max=(mainwin.mapstorage).maxOfEdgeMap(mapname);
     49  actual_map=((mainwin.mapstorage).edgemap_storage)[mapname];
     50
     51  if(edge==INVALID)
     52    {
     53      for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    5454        {
    5555          double v=fabs((*actual_map)[i]);
     
    8484  //green in RGB
    8585  Graph::EdgeMap<double> * actual_map;
    86   actual_map=(mapstorage.edgemap_storage)[mapname];
     86  actual_map=((mainwin.mapstorage).edgemap_storage)[mapname];
    8787
    8888  double max, min;
    8989
    90   max=mapstorage.maxOfEdgeMap(mapname);
    91   min=mapstorage.minOfEdgeMap(mapname);
    92 
    93   if(edge==INVALID)
    94     {
    95       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     90  max=(mainwin.mapstorage).maxOfEdgeMap(mapname);
     91  min=(mainwin.mapstorage).minOfEdgeMap(mapname);
     92
     93  if(edge==INVALID)
     94    {
     95      for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    9696        {
    9797          double w=(*actual_map)[i];
     
    135135  //the minimum of the nodemap to the range of
    136136  //green in RGB
    137   Graph::EdgeMap<double> actual_map(mapstorage.graph,edge_property_defaults[E_COLOR]);
     137  Graph::EdgeMap<double> actual_map((mainwin.mapstorage).graph,edge_property_defaults[E_COLOR]);
    138138
    139139  double max, min;
     
    144144  if(edge==INVALID)
    145145    {
    146       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     146      for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    147147        {
    148148          double w=actual_map[i];
     
    189189  if(edge==INVALID)
    190190    {
    191       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     191      for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    192192        {
    193193          edgemap_to_edit=mapname;
    194           double number=(*(mapstorage.edgemap_storage)[mapname])[i];
     194          double number=(*((mainwin.mapstorage).edgemap_storage)[mapname])[i];
    195195         
    196196          std::ostringstream ostr;
     
    203203  else
    204204    {
    205           double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
     205          double number=(*((mainwin.mapstorage).edgemap_storage)[mapname])[edge];
    206206
    207207          std::ostringstream ostr;
     
    224224  if(edge==INVALID)
    225225    {
    226       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     226      for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    227227        {
    228228          edgemap_to_edit="";
  • gui/graph_displayer_canvas-event.cc

    r1826 r1837  
    9595      active_item=(get_item_at(clicked_x, clicked_y));
    9696      active_node=INVALID;
    97       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     97      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    9898        {
    9999          if(nodesmap[i]==active_item)
     
    126126      if(active_node!=INVALID)
    127127      {
    128         mapstorage.modified = true;
     128        (mainwin.mapstorage).modified = true;
    129129
    130130        //new coordinates will be the old values,
     
    145145
    146146        // the new coordinates of the centre of the node
    147         double coord_x = new_x - (clicked_x - mapstorage.coords[active_node].x);
    148         double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y);
     147        double coord_x = new_x - (clicked_x - (mainwin.mapstorage).coords[active_node].x);
     148        double coord_y = new_y - (clicked_y - (mainwin.mapstorage).coords[active_node].y);
    149149
    150150        clicked_x=new_x;
     
    152152
    153153        // write back the new coordinates to the coords map
    154         mapstorage.coords.set(active_node, xy<double>(coord_x, coord_y));
     154        (mainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
    155155
    156156        // reposition the coordinates text
    157157        std::ostringstream ostr;
    158158        ostr << "(" <<
    159           mapstorage.coords[active_node].x << ", " <<
    160           mapstorage.coords[active_node].y << ")";
     159          (mainwin.mapstorage).coords[active_node].x << ", " <<
     160          (mainwin.mapstorage).coords[active_node].y << ")";
    161161        double radius =
    162162          (nodesmap[active_node]->property_x2().get_value() -
     
    165165        {
    166166          coord_text->property_text().set_value(ostr.str());
    167           coord_text->property_x().set_value(mapstorage.coords[active_node].x +
     167          coord_text->property_x().set_value((mainwin.mapstorage).coords[active_node].x +
    168168              radius);
    169           coord_text->property_y().set_value(mapstorage.coords[active_node].y -
     169          coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y -
    170170              radius);
    171171        }
     
    174174          coord_text = new Gnome::Canvas::Text(
    175175              displayed_graph,
    176               mapstorage.coords[active_node].x + radius,
    177               mapstorage.coords[active_node].y - radius,
     176              (mainwin.mapstorage).coords[active_node].x + radius,
     177              (mainwin.mapstorage).coords[active_node].y - radius,
    178178              ostr.str());
    179179          coord_text->property_fill_color().set_value("black");
     
    182182
    183183        //all the edges connected to the moved point has to be redrawn
    184         for(OutEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
     184        for(OutEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
    185185        {
    186186            Gnome::Canvas::Points coos;
    187187            double x1, x2, y1, y2;
    188188
    189             nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
     189            nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
    190190            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    191191
    192             nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
     192            nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
    193193            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    194194
     
    209209        }
    210210
    211         for(InEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
     211        for(InEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
    212212        {
    213213            Gnome::Canvas::Points coos;
    214214            double x1, x2, y1, y2;
    215215
    216             nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
     216            nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
    217217            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    218218
    219             nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
     219            nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
    220220            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    221221
     
    257257
    258258    case GDK_BUTTON_RELEASE:
    259       mapstorage.modified = true;
     259      (mainwin.mapstorage).modified = true;
    260260
    261261      isbutton=1;
    262262
    263       active_node=mapstorage.graph.addNode();
     263      active_node=(mainwin.mapstorage).graph.addNode();
    264264
    265265      //initiating values corresponding to new node in maps
     
    268268
    269269      // update coordinates
    270       mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y));
     270      (mainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));
    271271
    272272      // update all other maps
    273273      for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
    274           mapstorage.nodemap_storage.begin(); it !=
    275           mapstorage.nodemap_storage.end(); ++it)
     274          (mainwin.mapstorage).nodemap_storage.begin(); it !=
     275          (mainwin.mapstorage).nodemap_storage.end(); ++it)
    276276      {
    277277        if ((it->first != "coordinates_x") &&
     
    279279        {
    280280          (*(it->second))[active_node] =
    281             mapstorage.nodemap_default[it->first];
     281            (mainwin.mapstorage).nodemap_default[it->first];
    282282        }
    283283      }
    284284      // increment the id map's default value
    285       mapstorage.nodemap_default["id"] += 1.0;
     285      (mainwin.mapstorage).nodemap_default["id"] += 1.0;
    286286
    287287      nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
     
    302302      nodetextmap[active_node]->raise_to_top();
    303303
    304       mapwin.updateNode(active_node);
     304//       mapwin.updateNode(active_node);
     305      propertyUpdate(active_node);
    305306
    306307      isbutton=0;
     
    332333          active_item=(get_item_at(clicked_x, clicked_y));
    333334          active_node=INVALID;
    334           for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     335          for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    335336          {
    336337            if(nodesmap[i]==active_item)
     
    361362          target_item=(get_item_at(clicked_x, clicked_y));
    362363          Node target_node=INVALID;
    363           for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     364          for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    364365          {
    365366            if(nodesmap[i]==target_item)
     
    373374            if(target_node!=active_node)               
    374375            {
    375               mapstorage.modified = true;
     376              (mainwin.mapstorage).modified = true;
    376377
    377378              *(nodesmap[target_node]) <<
     
    379380
    380381              //creating new edge
    381               active_edge=mapstorage.graph.addEdge(active_node,
     382              active_edge=(mainwin.mapstorage).graph.addEdge(active_node,
    382383                  target_node);
    383384
     
    385386              for (std::map<std::string,
    386387                  Graph::EdgeMap<double>*>::const_iterator it =
    387                   mapstorage.edgemap_storage.begin(); it !=
    388                   mapstorage.edgemap_storage.end(); ++it)
     388                  (mainwin.mapstorage).edgemap_storage.begin(); it !=
     389                  (mainwin.mapstorage).edgemap_storage.end(); ++it)
    389390              {
    390391                (*(it->second))[active_edge] =
    391                   mapstorage.edgemap_default[it->first];
     392                  (mainwin.mapstorage).edgemap_default[it->first];
    392393              }
    393394              // increment the id map's default value
    394               mapstorage.edgemap_default["id"] += 1.0;
     395              (mainwin.mapstorage).edgemap_default["id"] += 1.0;
    395396
    396397              //calculating coordinates of new edge
     
    424425
    425426              //updating its properties
    426               mapwin.updateEdge(active_edge);
     427//               mapwin.updateEdge(active_edge);
     428              propertyUpdate(active_edge);
    427429            }
    428430            else
     
    479481      active_edge=INVALID;
    480482      //was it a node?
    481       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     483      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    482484        {
    483485          if(nodesmap[i]==active_item)
     
    489491      if(active_node==INVALID)
    490492        {
    491           for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     493          for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    492494            {
    493495              if(edgesmap[i]==active_item)
     
    515517              if(active_node!=INVALID)
    516518                {
    517                   mapstorage.modified = true;
     519                  (mainwin.mapstorage).modified = true;
    518520
    519521                  std::set<Graph::Edge> edges_to_delete;
    520522
    521                   for(OutEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
     523                  for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
    522524                    {
    523525                      edges_to_delete.insert(e);
    524526                    }
    525527                 
    526                   for(InEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
     528                  for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
    527529                    {
    528530                      edges_to_delete.insert(e);
     
    588590
    589591          //find the activated item between texts
    590           for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     592          for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    591593          {
    592594            //at the same time only one can be active
     
    600602          if(clicked_edge==INVALID)
    601603          {
    602             for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     604            for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    603605            {
    604606              //at the same time only one can be active
     
    623625
    624626              //create a dialog
    625               Gtk::Dialog dialog("Edit value", *parentwin, true);
     627              Gtk::Dialog dialog("Edit value", mainwin, true);
    626628              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    627629              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
     
    640642                case Gtk::RESPONSE_ACCEPT:
    641643                  double new_value = spin.get_value();
    642                   (*mapstorage.edgemap_storage[edgemap_to_edit])[active_edge] =
     644                  (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
    643645                    new_value;
    644646                  std::ostringstream ostr;
     
    647649                      ostr.str());
    648650                  //mapwin.updateEdge(active_edge);
    649                   mapwin.updateEdge(Edge(INVALID));
     651//                   mapwin.updateEdge(Edge(INVALID));
     652                  propertyUpdate(Edge(INVALID));
    650653              }
    651654            }
     
    675678
    676679          //find the activated item between texts
    677           for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     680          for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    678681          {
    679682            //at the same time only one can be active
     
    687690          if(clicked_node==INVALID)
    688691          {
    689             for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     692            for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    690693            {
    691694              //at the same time only one can be active
     
    710713
    711714              //create a dialog
    712               Gtk::Dialog dialog("Edit value", *parentwin, true);
     715              Gtk::Dialog dialog("Edit value", mainwin, true);
    713716              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    714717              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
     
    727730                case Gtk::RESPONSE_ACCEPT:
    728731                  double new_value = spin.get_value();
    729                   (*mapstorage.nodemap_storage[nodemap_to_edit])[active_node] =
     732                  (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
    730733                    new_value;
    731734                  std::ostringstream ostr;
     
    734737                      ostr.str());
    735738                  //mapwin.updateNode(active_node);
    736                   mapwin.updateNode(Node(INVALID));
     739//                   mapwin.updateNode(Node(INVALID));
     740                  propertyUpdate(Node(INVALID));
    737741              }
    738742            }
     
    751755  delete(nodetextmap[node_to_delete]);
    752756  delete(nodesmap[node_to_delete]);
    753   mapstorage.graph.erase(node_to_delete);
     757  (mainwin.mapstorage).graph.erase(node_to_delete);
    754758}
    755759
     
    758762  delete(edgetextmap[edge_to_delete]);
    759763  delete(edgesmap[edge_to_delete]);
    760   mapstorage.graph.erase(edge_to_delete);
     764  (mainwin.mapstorage).graph.erase(edge_to_delete);
    761765}
    762766
     
    778782      else
    779783        {
    780           for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     784          for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    781785            {
    782786              if(edgesmap[i]==active_bre)
     
    804808{
    805809  //create the new map
    806   Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mapstorage.graph, default_value);
     810  Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mainwin.mapstorage).graph, default_value);
    807811
    808812  //if addition was not successful addEdgeMap returns one.
    809813  //cause can be that there is already a map named like the new one
    810   if(mapstorage.addEdgeMap(mapname,emptr, default_value))
     814  if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))
    811815    {
    812816      return 1;
     
    815819
    816820  //add it to the list of the displayable maps
    817   mapwin.registerNewEdgeMap(mapname);
     821  mainwin.registerNewEdgeMap(mapname);
    818822
    819823  //display it
     
    826830{
    827831  //create the new map
    828   Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mapstorage.graph,default_value);
     832  Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mainwin.mapstorage).graph,default_value);
    829833
    830834  //if addition was not successful addNodeMap returns one.
    831835  //cause can be that there is already a map named like the new one
    832   if(mapstorage.addNodeMap(mapname,emptr, default_value))
     836  if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value))
    833837    {
    834838      return 1;
     
    836840
    837841  //add it to the list of the displayable maps
    838   mapwin.registerNewNodeMap(mapname);
     842  mainwin.registerNewNodeMap(mapname);
    839843
    840844  //display it
  • gui/graph_displayer_canvas-node.cc

    r1825 r1837  
    77  Graph::NodeMap<double> * actual_map;
    88  double min, max;
    9   min=mapstorage.minOfNodeMap(mapname);
    10   max=mapstorage.maxOfNodeMap(mapname);
    11   actual_map=(mapstorage.nodemap_storage)[mapname];
    12 
    13   if(node==INVALID)
    14     {
    15       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     9  min=(mainwin.mapstorage).minOfNodeMap(mapname);
     10  max=(mainwin.mapstorage).maxOfNodeMap(mapname);
     11  actual_map=((mainwin.mapstorage).nodemap_storage)[mapname];
     12
     13  if(node==INVALID)
     14    {
     15      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    1616        {
    1717          double v=fabs((*actual_map)[i]);
     
    6565  min=node_property_defaults[N_RADIUS];
    6666  max=node_property_defaults[N_RADIUS];
    67   Graph::NodeMap<double> actual_map(mapstorage.graph,node_property_defaults[N_RADIUS]);
     67  Graph::NodeMap<double> actual_map((mainwin.mapstorage).graph,node_property_defaults[N_RADIUS]);
    6868 
    6969  if(node==INVALID)
    7070    {
    71       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     71      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    7272        {
    7373          double v=fabs(actual_map[i]);
     
    124124
    125125  Graph::NodeMap<double> * actual_map;
    126   actual_map=(mapstorage.nodemap_storage)[mapname];
     126  actual_map=((mainwin.mapstorage).nodemap_storage)[mapname];
    127127
    128128  double max, min;
    129129
    130   max=mapstorage.maxOfNodeMap(mapname);
    131   min=mapstorage.minOfNodeMap(mapname);
    132 
    133   if(node==INVALID)
    134     {
    135 
    136       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     130  max=(mainwin.mapstorage).maxOfNodeMap(mapname);
     131  min=(mainwin.mapstorage).minOfNodeMap(mapname);
     132
     133  if(node==INVALID)
     134    {
     135
     136      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    137137        {
    138138          Gdk::Color color;
     
    179179  //green in RGB
    180180
    181   Graph::NodeMap<double> actual_map(mapstorage.graph,node_property_defaults[N_COLOR]);
     181  Graph::NodeMap<double> actual_map((mainwin.mapstorage).graph,node_property_defaults[N_COLOR]);
    182182
    183183  double max, min;
     
    189189    {
    190190
    191       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     191      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    192192        {
    193193          Gdk::Color color;
     
    236236
    237237  Graph::NodeMap<double> * actual_map=NULL;
    238   actual_map=(mapstorage.nodemap_storage)[mapname];
    239 
    240   if(node==INVALID)
    241     {
    242       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     238  actual_map=((mainwin.mapstorage).nodemap_storage)[mapname];
     239
     240  if(node==INVALID)
     241    {
     242      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    243243        {
    244244          nodemap_to_edit=mapname;
     
    273273  if(node==INVALID)
    274274    {
    275       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     275      for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    276276        {
    277277          nodemap_to_edit="";
  • gui/graph_displayer_canvas.cc

    r1819 r1837  
    22#include <cmath>
    33
    4 GraphDisplayerCanvas::GraphDisplayerCanvas(MapStorage & ms, MapWin & mw, Gtk::Window * mainwin) :
    5   nodesmap(ms.graph), edgesmap(ms.graph), edgetextmap(ms.graph),
    6   nodetextmap(ms.graph), displayed_graph(*(root()), 0, 0), mapstorage(ms),
     4GraphDisplayerCanvas::GraphDisplayerCanvas(MainWin & mainw) :
     5  nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
     6  nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
    77  isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
    8   edgemap_to_edit(""), mapwin(mw)
    9 {
    10   parentwin=mainwin;
    11 
     8  edgemap_to_edit(""), mainwin(mainw)
     9{
    1210  //base event handler is move tool
    1311  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
     
    2119GraphDisplayerCanvas::~GraphDisplayerCanvas()
    2220{
    23   for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
    24   {
    25     delete nodesmap[n];
    26     delete nodetextmap[n];
    27   }
    28 
    29   for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
    30   {
    31     delete edgesmap[e];
    32     delete edgetextmap[e];
    33   }
     21  for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n)
     22    {
     23      delete nodesmap[n];
     24      delete nodetextmap[n];
     25    }
     26 
     27  for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e)
     28    {
     29      delete edgesmap[e];
     30      delete edgetextmap[e];
     31    }
     32}
     33
     34void GraphDisplayerCanvas::propertyChange(bool itisedge, int prop)
     35{
     36  if(itisedge)
     37    {
     38      propertyUpdate(Edge(INVALID), prop);
     39    }
     40  else
     41    {
     42      propertyUpdate(Node(INVALID), prop);
     43    }
     44}
     45
     46void GraphDisplayerCanvas::propertyUpdate(Edge edge)
     47{
     48  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
     49    {
     50      propertyUpdate(edge, i);
     51    }
     52}
     53
     54void GraphDisplayerCanvas::propertyUpdate(Node node)
     55{
     56  for(int i=0;i<NODE_PROPERTY_NUM;i++)
     57    {
     58      propertyUpdate(node, i);
     59    }
     60}
     61
     62void GraphDisplayerCanvas::propertyUpdate(Node node, int prop, int dummy)
     63{
     64  dummy=dummy;
     65
     66  std::string mapname=mainwin.getActiveNodeMap(prop);
     67
     68  if(mapname!="")
     69    {
     70      if( ( ((mainwin.mapstorage).nodemap_storage).find(mapname) != ((mainwin.mapstorage).nodemap_storage).end() ) )
     71        {
     72          switch(prop)
     73            {
     74            case N_RADIUS:
     75              changeNodeRadius(mapname, node);
     76              break;
     77            case N_COLOR:
     78              changeNodeColor(mapname, node);
     79              break;
     80            case N_TEXT:
     81              changeNodeText(mapname, node);
     82              break;
     83            default:
     84              std::cerr<<"Error\n";
     85            }
     86        }
     87    }
     88  else //mapname==""
     89    {
     90      Node node=INVALID;       
     91      switch(prop)
     92        {
     93        case N_RADIUS:
     94          resetNodeRadius(node);
     95          break;
     96        case N_COLOR:
     97          resetNodeColor(node);
     98          break;
     99        case N_TEXT:
     100          resetNodeText(node);
     101          break;
     102        default:
     103          std::cerr<<"Error\n";
     104        }
     105    }
     106
     107}
     108
     109void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop, int dummy)
     110{
     111  dummy=dummy;
     112
     113  std::string mapname=mainwin.getActiveEdgeMap(prop);
     114
     115  if(mapname!="")
     116    {
     117      if( ( ((mainwin.mapstorage).edgemap_storage).find(mapname) != ((mainwin.mapstorage).edgemap_storage).end() ) )
     118        {
     119          switch(prop)
     120            {
     121            case E_WIDTH:
     122              changeEdgeWidth(mapname, edge);
     123              break;
     124            case E_COLOR:
     125              changeEdgeColor(mapname, edge);
     126              break;
     127            case E_TEXT:
     128              changeEdgeText(mapname, edge);
     129              break;
     130            default:
     131              std::cerr<<"Error\n";
     132            }
     133        }
     134    }
     135  else //mapname==""
     136    {
     137      switch(prop)
     138        {
     139        case E_WIDTH:
     140          resetEdgeWidth(edge);
     141          break;
     142        case E_COLOR:
     143          resetEdgeColor(edge);
     144          break;
     145        case E_TEXT:
     146          resetEdgeText(edge);
     147          break;
     148        default:
     149          std::cerr<<"Error\n";
     150        }
     151    }
    34152}
    35153
     
    38156  //first edges are drawn, to hide joining with nodes later
    39157
    40   for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     158  for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    41159  {
    42160
     
    45163    Gnome::Canvas::Points coos;
    46164    coos.push_back(Gnome::Art::Point(
    47           mapstorage.coords[mapstorage.graph.source(i)].x,
    48           mapstorage.coords[mapstorage.graph.source(i)].y));
     165          (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].x,
     166          (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].y));
    49167    coos.push_back(Gnome::Art::Point(
    50           mapstorage.coords[mapstorage.graph.target(i)].x,
    51           mapstorage.coords[mapstorage.graph.target(i)].y));
     168          (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].x,
     169          (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].y));
    52170   
    53171    edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
     
    69187  //afterwards nodes come to be drawn
    70188
    71   for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     189  for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    72190  {
    73191    //drawing bule nodes, with black line around them
     
    75193    nodesmap[i]=new Gnome::Canvas::Ellipse(
    76194        displayed_graph,
    77         mapstorage.coords[i].x-20,
    78         mapstorage.coords[i].y-20,
    79         mapstorage.coords[i].x+20,
    80         mapstorage.coords[i].y+20);
     195        (mainwin.mapstorage).coords[i].x-20,
     196        (mainwin.mapstorage).coords[i].y-20,
     197        (mainwin.mapstorage).coords[i].x+20,
     198        (mainwin.mapstorage).coords[i].y+20);
    81199    *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
    82200    *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
     
    86204
    87205    xy<double> text_pos(
    88         (mapstorage.coords[i].x+node_property_defaults[N_RADIUS]+5),
    89         (mapstorage.coords[i].y+node_property_defaults[N_RADIUS]+5));
     206        ((mainwin.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5),
     207        ((mainwin.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5));
    90208
    91209    nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
     
    105223  forming_edge=INVALID;
    106224
    107   for (NodeIt n(mapstorage.graph); n != INVALID; ++n)
     225  for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n)
    108226  {
    109227    delete nodesmap[n];
     
    111229  }
    112230
    113   for (EdgeIt e(mapstorage.graph); e != INVALID; ++e)
     231  for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e)
    114232  {
    115233    delete edgesmap[e];
  • gui/graph_displayer_canvas.h

    r1819 r1837  
    77
    88#include "all_include.h"
    9 #include "mapstorage.h"
    10 #include "map_win.h"
     9#include "main_win.h"
    1110#include <libgnomecanvasmm.h>
    1211#include <libgnomecanvasmm/polygon.h>
     
    4140
    4241public:
    43   GraphDisplayerCanvas(MapStorage &, MapWin &, Gtk::Window *);
     42  GraphDisplayerCanvas(MainWin &);
    4443  virtual ~GraphDisplayerCanvas();
    4544
     
    7372  int changeNodeText (std::string mapname, Node new_item=INVALID);
    7473  int resetNodeText (Node new_item=INVALID);
     74
     75  void propertyChange(bool, int);
     76  void propertyUpdate(Edge, int, int dummy=0);
     77  void propertyUpdate(Node, int, int dummy=0);
     78
     79  void propertyUpdate(Edge);
     80  void propertyUpdate(Node);
    7581
    7682  ///Callback for 'ViewZoomIn' action.
     
    166172  Gnome::Canvas::Group displayed_graph;
    167173
    168 public:
    169   ///Here we store the maps that can be displayed through properties.
    170   MapStorage & mapstorage;
    171 
    172174private:
    173175  ///Indicates whether the button of mouse is pressed or not
     
    194196  static const int zoom_step = 5;
    195197
    196 public:
    197   ///We need to store mapwin, to be able to ask the appropriate values for properties of new items.
    198   MapWin & mapwin;
    199 
    200 private:
    201 
    202   ///pointer to the parent window
    203   Gtk::Window * parentwin;
     198private:
     199
     200  ///reference to the parent window
     201  MainWin & mainwin;
    204202
    205203};
  • gui/main_win.cc

    r1823 r1837  
    22#include "icons/guipixbufs.h"
    33
    4 MainWin::MainWin() :
    5   mapwin("Map Setup", mapstorage, gd_canvas),
    6   gd_canvas(mapstorage, mapwin, (Gtk::Window *)this)
    7 {
     4MainWin::MainWin()
     5{
     6  mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
     7  gd_canvas=new GraphDisplayerCanvas(*this);
     8
    89  set_title ("unsaved file - " + prog_name);
    910  set_default_size(WIN_WIDTH,WIN_HEIGHT);
    1011  add(vbox);
    1112
     13  //connecting signals - controller character
     14  mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
    1215
    1316  // custom icons for the toolbar
     
    9396  ag->add( Gtk::Action::create("ViewMenu", "_View") );
    9497  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
    95       sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
     98      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomIn));
    9699  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
    97       sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
     100      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomOut));
    98101  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
    99       sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
     102      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomFit));
    100103  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
    101       sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
     104      sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100));
    102105 
    103106  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
    104107  ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
    105       sigc::mem_fun(this->mapwin, &MapWin::show));
     108      sigc::mem_fun(*(this->mapwin), &MapWin::show));
    106109
    107110  Gtk::RadioAction::Group tool_group;
    108111  ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
    109       sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
     112      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) );
    110113  ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"),
    111       sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );
     114      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 1) );
    112115  ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), "Create edge"),
    113       sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );
     116      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 2) );
    114117  ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), "Delete"),
    115       sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
     118      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 3) );
    116119
    117120  ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), "Edit edge map"),
    118       sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
     121      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 4) );
    119122  ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), "Edit node map"),
    120       sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
     123      sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 5) );
    121124
    122125  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
    123       sigc::mem_fun (new NewMapWin("NewMapWin", gd_canvas), &NewMapWin::show ) );
     126      sigc::mem_fun (new NewMapWin("NewMapWin", *this), &NewMapWin::show ) );
    124127
    125128  uim=Gtk::UIManager::create();
     
    195198  Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
    196199  pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN);
    197   pScrolledWindow->add(gd_canvas);
     200  pScrolledWindow->add(*gd_canvas);
    198201  vbox.pack_start(*pScrolledWindow);
    199202
     
    209212  mapstorage.file_name = file;
    210213  mapstorage.modified = false;
    211   gd_canvas.drawGraph();
    212   mapwin.update();
     214  gd_canvas->drawGraph();
     215  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    213216  set_title(Glib::filename_display_basename(file) + " - " + prog_name);
    214217}
     
    234237    }
    235238  }
    236   gd_canvas.clear();
     239  gd_canvas->clear();
    237240  mapstorage.clear();
    238   mapwin.update();
     241  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    239242  set_title("unsaved file - " + prog_name);
    240243}
     
    265268  if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
    266269  {
    267     gd_canvas.clear();
     270    gd_canvas->clear();
    268271    mapstorage.clear();
    269272    Glib::ustring filename = fcdialog.get_filename();
     
    272275      mapstorage.file_name = filename;
    273276      mapstorage.modified = false;
    274       gd_canvas.drawGraph();
    275       mapwin.update();
     277      gd_canvas->drawGraph();
     278      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    276279      set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
    277280    }
     
    328331    }
    329332  }
    330   gd_canvas.clear();
     333  gd_canvas->clear();
    331334  mapstorage.clear();
    332   mapwin.update();
     335  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    333336  set_title("unsaved file - " + prog_name);
    334337}
     338
     339void MainWin::propertyChange(bool itisedge, int prop, std::string mapname)
     340{
     341  mapstorage.changeActiveMap(itisedge, prop, mapname);
     342}
     343
     344void MainWin::popupNewMapWin(bool itisedge, int prop)
     345{
     346  prop=prop;
     347  (new NewMapWin("NewMapWin", *this, itisedge, false))->run();
     348}
     349
     350std::string MainWin::getActiveEdgeMap(int prop)
     351{
     352  return mapstorage.getActiveEdgeMap(prop);
     353}
     354
     355std::string MainWin::getActiveNodeMap(int prop)
     356{
     357  return mapstorage.getActiveNodeMap(prop);
     358}
     359
     360void MainWin::registerNewEdgeMap(std::string mapname)
     361{
     362  mapwin->registerNewEdgeMap(mapname);
     363}
     364
     365void MainWin::registerNewNodeMap(std::string mapname)
     366{
     367  mapwin->registerNewNodeMap(mapname);
     368}
  • gui/main_win.h

    r1823 r1837  
    33#ifndef MAIN_WIN_H
    44#define MAIN_WIN_H
     5
     6class MainWin;
    57
    68#include "all_include.h"
     
    2729protected:
    2830  ///Window of map-showing setup. Its type is \ref MapWin
    29   MapWin mapwin;
     31  MapWin * mapwin;
    3032
    3133  ///The graph will be drawn on this \ref GraphDisplayerCanvas
    32   GraphDisplayerCanvas gd_canvas;
     34  GraphDisplayerCanvas * gd_canvas;
    3335
    3436  ///ActionGroup for menu
     
    5456  ///Callback for 'Close' action.
    5557  virtual void close();
     58
     59public:
     60  void propertyChange(bool, int, std::string);
     61  void popupNewMapWin(bool, int);
     62
     63  std::string getActiveEdgeMap(int);
     64  std::string getActiveNodeMap(int);
     65
     66  void registerNewEdgeMap(std::string);
     67  void registerNewNodeMap(std::string);
     68
    5669};
    5770
  • gui/map_win.cc

    r1823 r1837  
    1111}
    1212
    13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
     13MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, MainWin & mw):mainwin(mw)
    1414{
    1515  set_title(title);
     
    2424  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    2525  {
    26     e_combo_array[i]=new MapSelector(gdc, ms, i, true);
     26    e_combo_array[i]=new MapSelector(eml, i, true);
    2727
    2828    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     29
     30    e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i));
     31    e_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
    2932  }
    3033
     
    4144  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    4245  {
    43     n_combo_array[i]=new MapSelector(gdc, ms, i, false);
     46    n_combo_array[i]=new MapSelector(nml, i, false);
    4447
    4548    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     49
     50    n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i));
     51    n_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i));
    4652  }
    4753
     
    5662}
    5763
    58 void MapWin::update()
     64void MapWin::nodeMapChanged(std::string mapname, int prop)
     65{
     66  mainwin.propertyChange(false, prop, mapname);
     67}
     68
     69void MapWin::edgeMapChanged(std::string mapname, int prop)
     70{
     71  mainwin.propertyChange(true, prop, mapname);
     72}
     73
     74void MapWin::newMapWinNeeded(bool itisedge, int prop)
     75{
     76  mainwin.popupNewMapWin(itisedge, prop);
     77}
     78
     79void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
    5980{
    6081  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    6182  {
    62     e_combo_array[i]->update_list();
     83    e_combo_array[i]->update_list(eml);
    6384  }
    6485
    6586  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    6687  {
    67     n_combo_array[i]->update_list();
     88    n_combo_array[i]->update_list(nml);
    6889  }
    69 }
    70 
    71 
    72 void MapWin::updateNode(Node node)
    73 {
    74   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    75     {
    76       n_combo_array[i]->update(node);
    77     }
    78 }
    79 
    80 void MapWin::updateEdge(Edge edge)
    81 {
    82   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    83     {
    84       e_combo_array[i]->update(edge);
    85     }
    8690}
    8791
  • gui/map_win.h

    r1823 r1837  
    66class MapWin;
    77
    8 #include "all_include.h"
    9 #include "graph_displayer_canvas.h"
    10 #include "mapstorage.h"
    11 #include "new_map_win.h"
     8#include <all_include.h>
     9#include <main_win.h>
    1210#include <libgnomecanvasmm.h>
    1311#include <libgnomecanvasmm/polygon.h>
     
    2220  {
    2321  protected:
    24     GraphDisplayerCanvas & gdc;
    25     ///The \ref MapStorage in which the visualizable maps are stored
    26     MapStorage & ms;
     22    sigc::signal<void, std::string> signal_cbt;
     23    sigc::signal<void, bool> signal_newmapwin;
    2724
    2825    int id;
     
    4239    Gtk::Label * label;
    4340
    44     Node node_to_update;
    45     Edge edge_to_update;
    46 
    47 
    4841  public:
    4942
    50     MapSelector(GraphDisplayerCanvas &, MapStorage &, int, bool);
     43    MapSelector(std::vector<std::string>, int, bool);
    5144
    52     void update_list();
     45    sigc::signal<void, std::string> signal_cbt_ch();
     46    sigc::signal<void, bool> signal_newmapwin_needed();
     47
     48    void update_list( std::vector<std::string> );
    5349
    5450    ///If a radiobutton is clicked, this function determines
     
    6258    virtual void reset();
    6359
    64     virtual void update(Node node);
    65     virtual void update(Edge edge);
    66 
    6760    Glib::ustring get_active_text();
    6861    void set_active_text(Glib::ustring);
     
    7366
    7467protected:
    75   ///The \ref GraphDisplayerCanvas on which the graph will be drawn.
    76   ///It has to be known for this class, because
    77   ///when a map assigned to a certain attribute
    78   ///a function of the \ref GraphDisplayerCanvas will be called.
    79   GraphDisplayerCanvas & gdc;
    80 
    81   ///The \ref MapStorage in which the visualizable maps are stored
    82   MapStorage & ms;
     68  MainWin & mainwin;
    8369
    8470  Gtk::Table * table;
     
    9278public:
    9379  ///Constructor of MapWin creates the widgets shown in MapWin.
    94   MapWin(const std::string& title, MapStorage &, GraphDisplayerCanvas &);
     80  MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, MainWin & mw);
    9581
    96   ///This function is created to set the appropriate maps on the newly created node
    97   void updateNode(Graph::Node);
     82  void nodeMapChanged(std::string, int);
    9883
    99   ///This function is created to set the appropriate maps on the newly created edge
    100   void updateEdge(Graph::Edge);
     84  void edgeMapChanged(std::string, int);
     85
     86  void newMapWinNeeded(bool, int);
    10187
    10288  ///This function inserts name of the new edgemap in the list in the combo box
     
    10894  virtual bool closeIfEscapeIsPressed(GdkEventKey*);
    10995
    110   void update();
     96  void update(std::vector<std::string>, std::vector<std::string>);
    11197};
    11298
  • gui/mapstorage.cc

    r1708 r1837  
    1717  nodemap_default["id"] = 1.0;
    1818  edgemap_default["id"] = 1.0;
     19
     20  active_nodemaps.resize(NODE_PROPERTY_NUM);
     21  for(int i=0;i<NODE_PROPERTY_NUM;i++)
     22    {
     23      active_nodemaps[i]="";
     24    }
     25
     26  active_edgemaps.resize(EDGE_PROPERTY_NUM);
     27  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
     28    {
     29      active_edgemaps[i]="";
     30    }
    1931}
    2032
     
    4355    }
    4456  return 1;
     57}
     58
     59void MapStorage::changeActiveMap(bool itisedge, int prop, std::string mapname)
     60{
     61  if(itisedge)
     62    {
     63      active_edgemaps[prop]=mapname;
     64    }
     65  else
     66    {
     67      active_nodemaps[prop]=mapname;
     68    }
     69  signal_prop.emit(itisedge, prop);
     70}
     71
     72std::string MapStorage::getActiveEdgeMap(int prop)
     73{
     74  return active_edgemaps[prop];
     75}
     76
     77std::string MapStorage::getActiveNodeMap(int prop)
     78{
     79  return active_nodemaps[prop];
     80}
     81
     82std::vector<std::string> MapStorage::getEdgeMapList()
     83{
     84  std::vector<std::string> eml;
     85  eml.resize(edgemap_storage.size());
     86  int i=0;
     87  std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=beginOfEdgeMaps();
     88  for(;emsi!=endOfEdgeMaps();emsi++)
     89    {
     90      eml[i]=(emsi->first);
     91      i++;
     92    }
     93  return eml;
     94}
     95
     96std::vector<std::string> MapStorage::getNodeMapList()
     97{
     98  std::vector<std::string> nml;
     99  nml.resize(nodemap_storage.size());
     100  int i=0;
     101  std::map< std::string,Graph::NodeMap<double> * >::iterator nmsi=beginOfNodeMaps();
     102  for(;nmsi!=endOfNodeMaps();nmsi++)
     103    {
     104      nml[i]=(nmsi->first);
     105      i++;
     106    }
     107  return nml;
     108}
     109
     110MapStorage::Signal_Prop MapStorage::signal_prop_ch()
     111{
     112  return signal_prop;
    45113}
    46114
  • gui/mapstorage.h

    r1645 r1837  
    44#define MAPSTORAGE_H
    55
     6class Mapstorage;
     7
    68#include "all_include.h"
    79#include "xymap.h"
     10#include <libgnomecanvasmm.h>
    811
    912///Class MapStorage is responsible for storing
     
    3841  std::vector<Graph::EdgeMap<double> > default_edgemaps;
    3942
     43  //Stores the active maps for the different visualization node attributes
     44  std::vector< std::string > active_nodemaps;
     45
     46  //Stores the active maps for the different visualization edge attributes
     47  std::vector< std::string > active_edgemaps;
     48
    4049  // Default values for the maps
    4150  std::map< std::string, double > nodemap_default;
     
    4352  // Default values for the maps
    4453  std::map< std::string, double > edgemap_default;
     54
     55protected:
     56  typedef sigc::signal<void, bool, int> Signal_Prop;
     57  Signal_Prop signal_prop;
    4558
    4659public:
     
    5467
    5568  ~MapStorage();
     69
     70  void changeActiveMap(bool, int, std::string);
     71
     72  std::string getActiveEdgeMap(int);
     73  std::string getActiveNodeMap(int);
     74
     75  std::vector<std::string> getEdgeMapList();
     76  std::vector<std::string> getNodeMapList();
     77
     78  Signal_Prop signal_prop_ch();
    5679
    5780  ///Adds given map to storage. A name and the map itself has to be provided.
  • gui/mw-mapselector.cc

    r1823 r1837  
    11#include "map_win.h"
    22
    3 MapWin::MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, int identifier, bool edge):gdc(grdispc),ms(mapst),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID)
     3MapWin::MapSelector::MapSelector(std::vector<std::string> ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false)
    44{
    5   update_list();
     5  update_list(ml);
    66
    77  cbt.set_active(0);
     
    5151{
    5252  set_new_map=true;
    53   (new NewMapWin("NewMapWin", gdc, itisedge, false))->run();
     53  signal_newmapwin.emit(itisedge);
    5454}
    5555
    56 void MapWin::MapSelector::update_list()
     56void MapWin::MapSelector::update_list( std::vector< std::string > ml )
    5757{
    5858  cbt.clear();
    59   if(itisedge)
     59  std::vector< std::string >::iterator emsi=ml.begin();
     60  for(;emsi!=ml.end();emsi++)
    6061    {
    61       std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
    62       for(;emsi!=ms.endOfEdgeMaps();emsi++)
    63         {
    64           cbt.append_text(emsi->first);
    65         }
    66     }
    67   else
    68     {
    69       std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
    70       for(;emsi!=ms.endOfNodeMaps();emsi++)
    71         {
    72           cbt.append_text(emsi->first);
    73         }
     62      cbt.append_text(*emsi);
    7463    }
    7564  cbt.prepend_text("Default values");
     
    8473      if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
    8574        {
    86           if(itisedge)
    87             {
    88               if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) )
    89                 {
    90                   Edge edge=edge_to_update;
    91                   switch(id)
    92                     {
    93                     case E_WIDTH:
    94                       gdc.changeEdgeWidth(mapname, edge);
    95                       break;
    96                     case E_COLOR:
    97                       gdc.changeEdgeColor(mapname, edge);
    98                       break;
    99                     case E_TEXT:
    100                       gdc.changeEdgeText(mapname, edge);
    101                       break;
    102                     default:
    103                       std::cerr<<"Error\n";
    104                     }
    105                 }
    106             }
    107           else
    108             {
    109               if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) )
    110                 {
    111                   Node node=node_to_update;
    112                   switch(id)
    113                     {
    114                     case N_RADIUS:
    115                       gdc.changeNodeRadius(mapname, node);
    116                       break;
    117                     case N_COLOR:
    118                       gdc.changeNodeColor(mapname, node);
    119                       break;
    120                     case N_TEXT:
    121                       gdc.changeNodeText(mapname, node);
    122                       break;
    123                     default:
    124                       std::cerr<<"Error\n";
    125                     }
    126                 }
    127             }
     75          signal_cbt.emit(mapname);
    12876        }
    12977    }
    13078  else if((!default_state)&&(cbt.get_active_row_number()==0))
    13179    {
     80      signal_cbt.emit("");
    13281      reset();
    13382    }
     
    13988  cbt.set_active(0);
    14089
    141   if(itisedge)
    142     {
    143       Edge edge=edge_to_update;
    144       switch(id)
    145         {
    146         case E_WIDTH:
    147           gdc.resetEdgeWidth(edge);
    148           break;
    149         case E_COLOR:
    150           gdc.resetEdgeColor(edge);
    151           break;
    152         case E_TEXT:
    153           gdc.resetEdgeText(edge);
    154           break;
    155         default:
    156           std::cerr<<"Error\n";
    157         }
    158     }
    159   else
    160     {
    161       Node node=node_to_update;
    162       switch(id)
    163         {
    164         case N_RADIUS:
    165           gdc.resetNodeRadius(node);
    166           break;
    167         case N_COLOR:
    168           gdc.resetNodeColor(node);
    169           break;
    170         case N_TEXT:
    171           gdc.resetNodeText(node);
    172           break;
    173         default:
    174           std::cerr<<"Error\n";
    175         }
    176     }
     90  signal_cbt.emit("");
    17791}
    17892
    179 void MapWin::MapSelector::update(Node node)
    180 {
    181   node_to_update=node;
    182   if(default_state)
    183     {
    184       reset();
    185     }
    186   else
    187     {
    188       comboChanged();
    189     }
    190   node_to_update=INVALID;
    191 }
    192 
    193 void MapWin::MapSelector::update(Edge edge)
    194 {
    195   edge_to_update=edge;
    196   if(default_state)
    197     {
    198       reset();
    199     }
    200   else
    201     {
    202       comboChanged();
    203     }
    204   edge_to_update=INVALID;
    205 }
    20693
    20794Glib::ustring MapWin::MapSelector::get_active_text()
     
    224111    }
    225112}
     113
     114sigc::signal<void, std::string> MapWin::MapSelector::signal_cbt_ch()
     115{
     116  return signal_cbt;
     117}
     118
     119sigc::signal<void, bool> MapWin::MapSelector::signal_newmapwin_needed()
     120{
     121  return signal_newmapwin;
     122}
  • gui/new_map_win.cc

    r1823 r1837  
    1010}
    1111
    12 NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap")
     12NewMapWin::NewMapWin(const std::string& title, MainWin & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mainwin(mw),node("Create NodeMap"),edge("Create EdgeMap")
    1313{
    1414  set_default_size(200, 50);
     
    8484            {
    8585              //create the new map
    86               Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (gdc.mapstorage.graph);
     86              Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mainwin.mapstorage.graph);
    8787
    8888              std::stack<double> polishstack;
    8989 
    90               for(EdgeIt k(gdc.mapstorage.graph); k!=INVALID; ++k)
     90              for(EdgeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k)
    9191                {
    9292                  for(int i=0;i<(int)polishform.size();i++)
     
    107107                        default:
    108108                          //substitute variable
    109                           std::map< std::string,Graph::EdgeMap<double> * > ems=gdc.mapstorage.edgemap_storage;
     109                          std::map< std::string,Graph::EdgeMap<double> * > ems=mainwin.mapstorage.edgemap_storage;
    110110                          bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end());
    111111                          if(itisvar)
    112112                            {
    113                               polishstack.push( (*(gdc.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
     113                              polishstack.push( (*(mainwin.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
    114114                            }
    115115                          else
     
    154154              //if addition was not successful addEdgeMap returns one.
    155155              //cause can be that there is already a map named like the new one
    156               if(gdc.mapstorage.addEdgeMap(mapname, emptr, def_val))
     156              if(mainwin.mapstorage.addEdgeMap(mapname, emptr, def_val))
    157157                {
    158158                  abortion=1;
     
    160160
    161161              //add it to the list of the displayable maps
    162               gdc.mapwin.registerNewEdgeMap(mapname);
     162              mainwin.registerNewEdgeMap(mapname);
    163163
    164164              //display it
    165               gdc.changeEdgeText(mapname);
     165              //gdc.changeEdgeText(mapname);
    166166            }
    167167          else //!edge.get_active()
    168168            {
    169169              //create the new map
    170               Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (gdc.mapstorage.graph);
     170              Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mainwin.mapstorage.graph);
    171171
    172172              std::stack<double> polishstack;
    173173 
    174               for(NodeIt k(gdc.mapstorage.graph); k!=INVALID; ++k)
     174              for(NodeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k)
    175175                {
    176176                  for(int i=0;i<(int)polishform.size();i++)
     
    190190                          break;
    191191                        default:
    192                           std::map< std::string,Graph::NodeMap<double> * > nms=gdc.mapstorage.nodemap_storage;
     192                          std::map< std::string,Graph::NodeMap<double> * > nms=mainwin.mapstorage.nodemap_storage;
    193193                          bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end());
    194194                          if(itisvar)
    195195                            {
    196                               polishstack.push( (*(gdc.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
     196                              polishstack.push( (*(mainwin.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
    197197                            }
    198198                          else
     
    237237              //if addition was not successful addNodeMap returns one.
    238238              //cause can be that there is already a map named like the new one
    239               if(gdc.mapstorage.addNodeMap(mapname,emptr, def_val))
     239              if(mainwin.mapstorage.addNodeMap(mapname,emptr, def_val))
    240240                {
    241241                  abortion=1;
     
    243243
    244244              //add it to the list of the displayable maps
    245               gdc.mapwin.registerNewNodeMap(mapname);
     245              mainwin.registerNewNodeMap(mapname);
    246246
    247247              //display it
     
    432432  if(itisedge)
    433433    {
    434       cancel=(gdc.mapstorage.edgemap_storage.find(variable)==gdc.mapstorage.edgemap_storage.end());
     434      cancel=(mainwin.mapstorage.edgemap_storage.find(variable)==mainwin.mapstorage.edgemap_storage.end());
    435435    }
    436436  else
    437437    {
    438       cancel=(gdc.mapstorage.nodemap_storage.find(variable)==gdc.mapstorage.nodemap_storage.end());
     438      cancel=(mainwin.mapstorage.nodemap_storage.find(variable)==mainwin.mapstorage.nodemap_storage.end());
    439439    }
    440440  //maybe it is number
  • gui/new_map_win.h

    r1823 r1837  
    77
    88#include <all_include.h>
    9 #include <graph_displayer_canvas.h>
     9#include <main_win.h>
    1010#include <libgnomecanvasmm.h>
    1111#include <libgnomecanvasmm/polygon.h>
     
    1717class NewMapWin : public Gtk::Dialog
    1818{
    19   ///The \ref GraphDisplayerCanvas on which the graph will be drawn.
    20   ///It has to be known for this class, because
    21   ///when a map is created
    22   ///a function of the \ref GraphDisplayerCanvas will be called.
    23   GraphDisplayerCanvas & gdc;
     19  MainWin & mainwin;
    2420
    2521public:
     
    3228 
    3329  ///Constructor of NewMapWin creates the widgets shown in NewMapWin.
    34   NewMapWin(const std::string& title, GraphDisplayerCanvas &, bool itisedge=true, bool edgenode=true);
     30  NewMapWin(const std::string& title, MainWin &, bool itisedge=true, bool edgenode=true);
    3531 
    3632  ///Signal on button is connected to this function,
Note: See TracChangeset for help on using the changeset viewer.