COIN-OR::LEMON - Graph Library

Changeset 1849:a4d1362397fe in lemon-0.x


Ignore:
Timestamp:
12/06/05 11:53:38 (14 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2414
Message:

Notebook style is provided. Without opportunity to close tabs. :-) But with all other necessary things (I think).

Location:
gui
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • gui/Makefile.am

    r1819 r1849  
    99glemon_SOURCES = \
    1010        all_include.h \
     11        gdc-broken_edge.cc \
    1112        graph_displayer_canvas.cc \
     13        graph_displayer_canvas.h \
    1214        graph_displayer_canvas-edge.cc \
     15        graph_displayer_canvas-event.cc \
    1316        graph_displayer_canvas-node.cc \
    14         graph_displayer_canvas-event.cc \
    1517        graph_displayer_canvas-zoom.cc \
    16         graph_displayer_canvas.h \
    1718        graph-displayer.cc \
    18         gdc-broken_edge.cc \
    1919        main_win.cc \
    2020        main_win.h \
     
    2424        map_win.h \
    2525        mw-mapselector.cc \
     26        nbtab.h \
     27        nbtab.cc \
    2628        new_map_win.cc \
    2729        new_map_win.h \
  • gui/graph-displayer.cc

    r1731 r1849  
    6262  Gtk::Main app(argc, argv);
    6363
    64   MainWin mainwin;
     64  MainWin mytab;
    6565
    6666  if ((argc == 2) && (Glib::file_test(argv[1], Glib::FILE_TEST_IS_REGULAR)))
    67   {
    68     mainwin.readFile(argv[1]);
    69   }
     67    {
     68      mytab.readFile(argv[1]);
     69    }
    7070 
    71   app.run(mainwin);
     71  app.run(mytab);
    7272
    7373  return 0;
  • gui/graph_displayer_canvas-edge.cc

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

    r1837 r1849  
    9595      active_item=(get_item_at(clicked_x, clicked_y));
    9696      active_node=INVALID;
    97       for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     97      for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    9898        {
    9999          if(nodesmap[i]==active_item)
     
    126126      if(active_node!=INVALID)
    127127      {
    128         (mainwin.mapstorage).modified = true;
     128        (mytab.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 - (mainwin.mapstorage).coords[active_node].x);
    148         double coord_y = new_y - (clicked_y - (mainwin.mapstorage).coords[active_node].y);
     147        double coord_x = new_x - (clicked_x - (mytab.mapstorage).coords[active_node].x);
     148        double coord_y = new_y - (clicked_y - (mytab.mapstorage).coords[active_node].y);
    149149
    150150        clicked_x=new_x;
     
    152152
    153153        // write back the new coordinates to the coords map
    154         (mainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
     154        (mytab.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
    155155
    156156        // reposition the coordinates text
    157157        std::ostringstream ostr;
    158158        ostr << "(" <<
    159           (mainwin.mapstorage).coords[active_node].x << ", " <<
    160           (mainwin.mapstorage).coords[active_node].y << ")";
     159          (mytab.mapstorage).coords[active_node].x << ", " <<
     160          (mytab.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((mainwin.mapstorage).coords[active_node].x +
     167          coord_text->property_x().set_value((mytab.mapstorage).coords[active_node].x +
    168168              radius);
    169           coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y -
     169          coord_text->property_y().set_value((mytab.mapstorage).coords[active_node].y -
    170170              radius);
    171171        }
     
    174174          coord_text = new Gnome::Canvas::Text(
    175175              displayed_graph,
    176               (mainwin.mapstorage).coords[active_node].x + radius,
    177               (mainwin.mapstorage).coords[active_node].y - radius,
     176              (mytab.mapstorage).coords[active_node].x + radius,
     177              (mytab.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((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
     184        for(OutEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
    185185        {
    186186            Gnome::Canvas::Points coos;
    187187            double x1, x2, y1, y2;
    188188
    189             nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
     189            nodesmap[(mytab.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[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
     192            nodesmap[(mytab.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((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
     211        for(InEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
    212212        {
    213213            Gnome::Canvas::Points coos;
    214214            double x1, x2, y1, y2;
    215215
    216             nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
     216            nodesmap[(mytab.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[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
     219            nodesmap[(mytab.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       (mainwin.mapstorage).modified = true;
     259      (mytab.mapstorage).modified = true;
    260260
    261261      isbutton=1;
    262262
    263       active_node=(mainwin.mapstorage).graph.addNode();
     263      active_node=(mytab.mapstorage).graph.addNode();
    264264
    265265      //initiating values corresponding to new node in maps
     
    268268
    269269      // update coordinates
    270       (mainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));
     270      (mytab.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           (mainwin.mapstorage).nodemap_storage.begin(); it !=
    275           (mainwin.mapstorage).nodemap_storage.end(); ++it)
     274          (mytab.mapstorage).nodemap_storage.begin(); it !=
     275          (mytab.mapstorage).nodemap_storage.end(); ++it)
    276276      {
    277277        if ((it->first != "coordinates_x") &&
     
    279279        {
    280280          (*(it->second))[active_node] =
    281             (mainwin.mapstorage).nodemap_default[it->first];
     281            (mytab.mapstorage).nodemap_default[it->first];
    282282        }
    283283      }
    284284      // increment the id map's default value
    285       (mainwin.mapstorage).nodemap_default["id"] += 1.0;
     285      (mytab.mapstorage).nodemap_default["id"] += 1.0;
    286286
    287287      nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
     
    333333          active_item=(get_item_at(clicked_x, clicked_y));
    334334          active_node=INVALID;
    335           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     335          for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    336336          {
    337337            if(nodesmap[i]==active_item)
     
    362362          target_item=(get_item_at(clicked_x, clicked_y));
    363363          Node target_node=INVALID;
    364           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     364          for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    365365          {
    366366            if(nodesmap[i]==target_item)
     
    374374            if(target_node!=active_node)               
    375375            {
    376               (mainwin.mapstorage).modified = true;
     376              (mytab.mapstorage).modified = true;
    377377
    378378              *(nodesmap[target_node]) <<
     
    380380
    381381              //creating new edge
    382               active_edge=(mainwin.mapstorage).graph.addEdge(active_node,
     382              active_edge=(mytab.mapstorage).graph.addEdge(active_node,
    383383                  target_node);
    384384
     
    386386              for (std::map<std::string,
    387387                  Graph::EdgeMap<double>*>::const_iterator it =
    388                   (mainwin.mapstorage).edgemap_storage.begin(); it !=
    389                   (mainwin.mapstorage).edgemap_storage.end(); ++it)
     388                  (mytab.mapstorage).edgemap_storage.begin(); it !=
     389                  (mytab.mapstorage).edgemap_storage.end(); ++it)
    390390              {
    391391                (*(it->second))[active_edge] =
    392                   (mainwin.mapstorage).edgemap_default[it->first];
     392                  (mytab.mapstorage).edgemap_default[it->first];
    393393              }
    394394              // increment the id map's default value
    395               (mainwin.mapstorage).edgemap_default["id"] += 1.0;
     395              (mytab.mapstorage).edgemap_default["id"] += 1.0;
    396396
    397397              //calculating coordinates of new edge
     
    481481      active_edge=INVALID;
    482482      //was it a node?
    483       for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     483      for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    484484        {
    485485          if(nodesmap[i]==active_item)
     
    491491      if(active_node==INVALID)
    492492        {
    493           for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     493          for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    494494            {
    495495              if(edgesmap[i]==active_item)
     
    517517              if(active_node!=INVALID)
    518518                {
    519                   (mainwin.mapstorage).modified = true;
     519                  (mytab.mapstorage).modified = true;
    520520
    521521                  std::set<Graph::Edge> edges_to_delete;
    522522
    523                   for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
     523                  for(OutEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e)
    524524                    {
    525525                      edges_to_delete.insert(e);
    526526                    }
    527527                 
    528                   for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
     528                  for(InEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e)
    529529                    {
    530530                      edges_to_delete.insert(e);
     
    590590
    591591          //find the activated item between texts
    592           for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     592          for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    593593          {
    594594            //at the same time only one can be active
     
    602602          if(clicked_edge==INVALID)
    603603          {
    604             for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     604            for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    605605            {
    606606              //at the same time only one can be active
     
    625625
    626626              //create a dialog
    627               Gtk::Dialog dialog("Edit value", mainwin, true);
     627              Gtk::Dialog dialog("Edit value", true);
    628628              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    629629              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
     
    642642                case Gtk::RESPONSE_ACCEPT:
    643643                  double new_value = spin.get_value();
    644                   (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
     644                  (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
    645645                    new_value;
    646646                  std::ostringstream ostr;
     
    678678
    679679          //find the activated item between texts
    680           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     680          for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    681681          {
    682682            //at the same time only one can be active
     
    690690          if(clicked_node==INVALID)
    691691          {
    692             for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     692            for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    693693            {
    694694              //at the same time only one can be active
     
    713713
    714714              //create a dialog
    715               Gtk::Dialog dialog("Edit value", mainwin, true);
     715              Gtk::Dialog dialog("Edit value", true);
    716716              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    717717              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
     
    730730                case Gtk::RESPONSE_ACCEPT:
    731731                  double new_value = spin.get_value();
    732                   (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
     732                  (*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
    733733                    new_value;
    734734                  std::ostringstream ostr;
     
    755755  delete(nodetextmap[node_to_delete]);
    756756  delete(nodesmap[node_to_delete]);
    757   (mainwin.mapstorage).graph.erase(node_to_delete);
     757  (mytab.mapstorage).graph.erase(node_to_delete);
    758758}
    759759
     
    762762  delete(edgetextmap[edge_to_delete]);
    763763  delete(edgesmap[edge_to_delete]);
    764   (mainwin.mapstorage).graph.erase(edge_to_delete);
     764  (mytab.mapstorage).graph.erase(edge_to_delete);
    765765}
    766766
     
    782782      else
    783783        {
    784           for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     784          for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    785785            {
    786786              if(edgesmap[i]==active_bre)
     
    808808{
    809809  //create the new map
    810   Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mainwin.mapstorage).graph, default_value);
     810  Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mytab.mapstorage).graph, default_value);
    811811
    812812  //if addition was not successful addEdgeMap returns one.
    813813  //cause can be that there is already a map named like the new one
    814   if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))
     814  if((mytab.mapstorage).addEdgeMap(mapname,emptr, default_value))
    815815    {
    816816      return 1;
     
    819819
    820820  //add it to the list of the displayable maps
    821   mainwin.registerNewEdgeMap(mapname);
     821  mytab.registerNewEdgeMap(mapname);
    822822
    823823  //display it
     
    830830{
    831831  //create the new map
    832   Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mainwin.mapstorage).graph,default_value);
     832  Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mytab.mapstorage).graph,default_value);
    833833
    834834  //if addition was not successful addNodeMap returns one.
    835835  //cause can be that there is already a map named like the new one
    836   if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value))
     836  if((mytab.mapstorage).addNodeMap(mapname,emptr, default_value))
    837837    {
    838838      return 1;
     
    840840
    841841  //add it to the list of the displayable maps
    842   mainwin.registerNewNodeMap(mapname);
     842  mytab.registerNewNodeMap(mapname);
    843843
    844844  //display it
  • gui/graph_displayer_canvas-node.cc

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

    r1837 r1849  
    22#include <cmath>
    33
    4 GraphDisplayerCanvas::GraphDisplayerCanvas(MainWin & mainw) :
     4GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) :
    55  nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
    66  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(""), mainwin(mainw)
     8  edgemap_to_edit(""), mytab(mainw)
    99{
    1010  //base event handler is move tool
     
    1919GraphDisplayerCanvas::~GraphDisplayerCanvas()
    2020{
    21   for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n)
     21  for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n)
    2222    {
    2323      delete nodesmap[n];
     
    2525    }
    2626 
    27   for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e)
     27  for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e)
    2828    {
    2929      delete edgesmap[e];
     
    6464  dummy=dummy;
    6565
    66   std::string mapname=mainwin.getActiveNodeMap(prop);
     66  std::string mapname=mytab.getActiveNodeMap(prop);
    6767
    6868  if(mapname!="")
    6969    {
    70       if( ( ((mainwin.mapstorage).nodemap_storage).find(mapname) != ((mainwin.mapstorage).nodemap_storage).end() ) )
     70      if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) )
    7171        {
    7272          switch(prop)
     
    111111  dummy=dummy;
    112112
    113   std::string mapname=mainwin.getActiveEdgeMap(prop);
     113  std::string mapname=mytab.getActiveEdgeMap(prop);
    114114
    115115  if(mapname!="")
    116116    {
    117       if( ( ((mainwin.mapstorage).edgemap_storage).find(mapname) != ((mainwin.mapstorage).edgemap_storage).end() ) )
     117      if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) )
    118118        {
    119119          switch(prop)
     
    156156  //first edges are drawn, to hide joining with nodes later
    157157
    158   for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     158  for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    159159  {
    160160
     
    163163    Gnome::Canvas::Points coos;
    164164    coos.push_back(Gnome::Art::Point(
    165           (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].x,
    166           (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.source(i)].y));
     165          (mytab.mapstorage).coords[(mytab.mapstorage).graph.source(i)].x,
     166          (mytab.mapstorage).coords[(mytab.mapstorage).graph.source(i)].y));
    167167    coos.push_back(Gnome::Art::Point(
    168           (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].x,
    169           (mainwin.mapstorage).coords[(mainwin.mapstorage).graph.target(i)].y));
     168          (mytab.mapstorage).coords[(mytab.mapstorage).graph.target(i)].x,
     169          (mytab.mapstorage).coords[(mytab.mapstorage).graph.target(i)].y));
    170170   
    171171    edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
     
    187187  //afterwards nodes come to be drawn
    188188
    189   for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
     189  for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    190190  {
    191191    //drawing bule nodes, with black line around them
     
    193193    nodesmap[i]=new Gnome::Canvas::Ellipse(
    194194        displayed_graph,
    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);
     195        (mytab.mapstorage).coords[i].x-20,
     196        (mytab.mapstorage).coords[i].y-20,
     197        (mytab.mapstorage).coords[i].x+20,
     198        (mytab.mapstorage).coords[i].y+20);
    199199    *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
    200200    *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
     
    204204
    205205    xy<double> text_pos(
    206         ((mainwin.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5),
    207         ((mainwin.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5));
     206        ((mytab.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5),
     207        ((mytab.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5));
    208208
    209209    nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
     
    223223  forming_edge=INVALID;
    224224
    225   for (NodeIt n((mainwin.mapstorage).graph); n != INVALID; ++n)
     225  for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n)
    226226  {
    227227    delete nodesmap[n];
     
    229229  }
    230230
    231   for (EdgeIt e((mainwin.mapstorage).graph); e != INVALID; ++e)
     231  for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e)
    232232  {
    233233    delete edgesmap[e];
  • gui/graph_displayer_canvas.h

    r1837 r1849  
    77
    88#include "all_include.h"
    9 #include "main_win.h"
     9#include "nbtab.h"
    1010#include <libgnomecanvasmm.h>
    1111#include <libgnomecanvasmm/polygon.h>
     
    4040
    4141public:
    42   GraphDisplayerCanvas(MainWin &);
     42  GraphDisplayerCanvas(NoteBookTab &);
    4343  virtual ~GraphDisplayerCanvas();
    4444
     
    199199
    200200  ///reference to the parent window
    201   MainWin & mainwin;
     201  NoteBookTab & mytab;
    202202
    203203};
  • gui/main_win.cc

    r1838 r1849  
    22#include "icons/guipixbufs.h"
    33
    4 MainWin::MainWin():mapwinexists(false)
    5 {
    6   gd_canvas=new GraphDisplayerCanvas(*this);
    7 
    8   set_title ("unsaved file - " + prog_name);
     4MainWin::MainWin()
     5{
     6  set_title ("no file");
    97  set_default_size(WIN_WIDTH,WIN_HEIGHT);
    108  add(vbox);
    119
    12   //connecting signals - controller character
    13   mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
    14 
    1510  // custom icons for the toolbar
    16 
    1711  Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create();
    1812 
     
    7670  p_icon_factory->add_default();
    7771 
    78 
    7972  ag=Gtk::ActionGroup::create();
    8073
    8174  ag->add( Gtk::Action::create("FileMenu", "_File") );
     75  ag->add( Gtk::Action::create("FileNewTab", "New _Tab"),
     76      sigc::mem_fun(*this, &MainWin::newTab));
    8277  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
    8378      sigc::mem_fun(*this, &MainWin::newFile));
     
    9590  ag->add( Gtk::Action::create("ViewMenu", "_View") );
    9691  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
    97       sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomIn));
     92      sigc::mem_fun(*this, &MainWin::zoomIn));
    9893  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
    99       sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomOut));
     94      sigc::mem_fun(*this, &MainWin::zoomOut));
    10095  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
    101       sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoomFit));
     96      sigc::mem_fun(*this, &MainWin::zoomFit));
    10297  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
    103       sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100));
     98      sigc::mem_fun(*this, &MainWin::zoom100));
    10499 
    105100  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
     
    109104  Gtk::RadioAction::Group tool_group;
    110105  ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
    111       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) );
     106      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) );
    112107  ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"),
    113       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 1) );
     108      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 1) );
    114109  ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), "Create edge"),
    115       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 2) );
     110      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 2) );
    116111  ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), "Delete"),
    117       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 3) );
     112      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 3) );
    118113
    119114  ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), "Edit edge map"),
    120       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 4) );
     115      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) );
    121116  ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), "Edit node map"),
    122       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 5) );
     117      sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 5) );
    123118
    124119  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
    125       sigc::mem_fun (new NewMapWin("NewMapWin", *this), &NewMapWin::show ) );
     120      sigc::mem_fun ( *this , &MainWin::createNewMapWin ) );
    126121
    127122  uim=Gtk::UIManager::create();
     
    136131      "  <menubar name='MenuBar'>"
    137132      "    <menu action='FileMenu'>"
     133      "      <menuitem action='FileNewTab'/>"
    138134      "      <menuitem action='FileNew'/>"
    139135      "      <menuitem action='FileOpen'/>"
     
    195191  }
    196192
    197   Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
    198   pScrolledWindow->set_shadow_type(Gtk::SHADOW_IN);
    199   pScrolledWindow->add(*gd_canvas);
    200   vbox.pack_start(*pScrolledWindow);
    201 
    202193  tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
    203194  tooltips.enable();
    204195
     196  active_tab=-1;
     197  notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab));
     198
     199  vbox.pack_start(notebook);
     200 
    205201  show_all_children();
    206202}
    207203
    208 void MainWin::readFile(const std::string &file)
    209 {
    210   mapstorage.readFromFile(file);
    211   mapstorage.file_name = file;
    212   mapstorage.modified = false;
    213   gd_canvas->drawGraph();
    214   if(mapwinexists)
    215     {
    216       mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    217     }
    218   set_title(Glib::filename_display_basename(file) + " - " + prog_name);
     204void MainWin::set_tabtitle(std::string name)
     205{
     206  tabnames[active_tab]=name;
     207  set_title(tabnames[active_tab] + " - " + prog_name);
     208  notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]);
     209}
     210
     211void MainWin::readFile(const std::string & filename)
     212{
     213  newTab();
     214  tabs[active_tab]->readFile(filename);
     215}
     216
     217void MainWin::newTab()
     218{
     219  int size=tabs.size();
     220  tabs.resize(size+1);
     221  tabnames.resize(size+1);
     222  active_tab=size;
     223  tabs[active_tab]=new NoteBookTab();
     224  tabnames[active_tab]="unsaved file";
     225  tabs[active_tab]->signal_title_ch().connect(sigc::mem_fun(*this, &MainWin::set_tabtitle));
     226  tabs[active_tab]->signal_newmap_needed().connect(sigc::mem_fun(*this, &MainWin::createNewMapWinAfterSignal));
     227  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
     228  notebook.append_page((Gtk::Widget&)(*(tabs[active_tab])));
     229  notebook.set_current_page(size);
     230  set_tabtitle(tabnames[active_tab]);
     231}
     232
     233void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num)
     234{
     235  page=page;
     236  active_tab=page_num;
     237  tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
     238  set_title(tabnames[active_tab]);
     239}
     240
     241void MainWin::onCloseTab()
     242{
    219243}
    220244
    221245void MainWin::newFile()
    222246{
    223   if (mapstorage.modified)
    224   {
    225     Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
    226         Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
    227     mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
    228     mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    229     mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
    230     switch (mdialog.run())
    231     {
    232       case Gtk::RESPONSE_CANCEL:
    233         return;
    234       case Gtk::RESPONSE_REJECT:
    235         break;
    236       case Gtk::RESPONSE_ACCEPT:
    237         saveFile();
    238         break;
    239     }
    240   }
    241   gd_canvas->clear();
    242   mapstorage.clear();
    243   if(mapwinexists)
    244     {
    245       mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    246     }
    247   set_title("unsaved file - " + prog_name);
    248 }
    249 
     247  if(active_tab!=-1)
     248    {
     249      tabs[active_tab]->newFile();
     250    }
     251}
     252 
    250253void MainWin::openFile()
    251254{
    252   if (mapstorage.modified)
    253   {
    254     Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
    255         Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
    256     mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
    257     mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    258     mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
    259     switch (mdialog.run())
    260     {
    261       case Gtk::RESPONSE_CANCEL:
    262         return;
    263       case Gtk::RESPONSE_REJECT:
    264         break;
    265       case Gtk::RESPONSE_ACCEPT:
    266         saveFile();
    267         break;
    268     }
    269   }
    270   Gtk::FileChooserDialog fcdialog("Open File");
    271   fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    272   fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
    273   if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
    274   {
    275     gd_canvas->clear();
    276     mapstorage.clear();
    277     Glib::ustring filename = fcdialog.get_filename();
    278     if (!mapstorage.readFromFile(filename))
    279     {
    280       mapstorage.file_name = filename;
    281       mapstorage.modified = false;
    282       gd_canvas->drawGraph();
    283       if(mapwinexists)
     255  if(active_tab!=-1)
     256    {
     257      tabs[active_tab]->openFile();
     258    }
     259}
     260 
     261void MainWin::saveFile()
     262{
     263  if(active_tab!=-1)
     264    {
     265      tabs[active_tab]->saveFile();
     266    }
     267}
     268 
     269void MainWin::saveFileAs()
     270{
     271  if(active_tab!=-1)
     272    {
     273      tabs[active_tab]->saveFileAs();
     274    }
     275}
     276 
     277void MainWin::close()
     278{
     279  if(active_tab!=-1)
     280    {
     281      tabs[active_tab]->close();
     282    }
     283}
     284
     285void MainWin::zoomIn()
     286{
     287  if(active_tab!=-1)
     288    {
     289      tabs[active_tab]->gd_canvas->zoomIn();
     290    }
     291}
     292
     293void MainWin::zoomOut()
     294{
     295  if(active_tab!=-1)
     296    {
     297      tabs[active_tab]->gd_canvas->zoomOut();
     298    }
     299}
     300
     301void MainWin::zoomFit()
     302{
     303  if(active_tab!=-1)
     304    {
     305      tabs[active_tab]->gd_canvas->zoomFit();
     306    }
     307}
     308
     309void MainWin::zoom100()
     310{
     311  if(active_tab!=-1)
     312    {
     313      tabs[active_tab]->gd_canvas->zoom100();
     314    }
     315}
     316
     317void MainWin::createMapWin()
     318{
     319  if(active_tab!=-1)
     320    {
     321      tabs[active_tab]->createMapWin(tabnames[active_tab]);
     322    }
     323}
     324
     325void MainWin::changeEditorialTool(int tool)
     326{
     327  active_tool=tool;
     328  if(active_tab!=-1)
     329    {
     330      tabs[active_tab]->gd_canvas->changeEditorialTool(tool);
     331    }
     332}
     333
     334void MainWin::createNewMapWin()
     335{
     336  if(active_tab!=-1)
     337    {
     338      NewMapWin * nmw=new NewMapWin("Create New Map - "+tabnames[active_tab], *(tabs[active_tab]));
     339      nmw->show();
     340    }
     341}
     342
     343void MainWin::createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge)
     344{
     345  std::vector<NoteBookTab*>::iterator nbti=tabs.begin();
     346  int i=0;
     347  for(;nbti!=tabs.end();nbti++)
     348    {
     349      if(*nbti!=nbt)
    284350        {
    285           mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
     351          i++;
    286352        }
    287       set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
    288     }
    289   }
    290 }
    291 
    292 void MainWin::saveFile()
    293 {
    294   if (mapstorage.file_name == "") {
    295     saveFileAs();
    296   }
    297   else
    298   {
    299     mapstorage.writeToFile(mapstorage.file_name);
    300     mapstorage.modified = false;
    301     set_title(Glib::filename_display_basename(mapstorage.file_name) + " - " +
    302         prog_name);
    303   }
    304 }
    305 
    306 void MainWin::saveFileAs()
    307 {
    308   Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE);
    309   fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    310   fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
    311   if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
    312   {
    313     Glib::ustring filename = fcdialog.get_filename();
    314     mapstorage.file_name = filename;
    315     mapstorage.writeToFile(filename);
    316     mapstorage.modified = false;
    317     set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
    318   }
    319 }
    320 
    321 void MainWin::close()
    322 {
    323   if (mapstorage.modified)
    324   {
    325     Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
    326         Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
    327     mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
    328     mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    329     mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
    330     switch (mdialog.run())
    331     {
    332       case Gtk::RESPONSE_CANCEL:
    333         return;
    334       case Gtk::RESPONSE_REJECT:
    335         break;
    336       case Gtk::RESPONSE_ACCEPT:
    337         saveFile();
    338         break;
    339     }
    340   }
    341   gd_canvas->clear();
    342   mapstorage.clear();
    343   if(mapwinexists)
    344     {
    345       mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    346     }
    347   set_title("unsaved file - " + prog_name);
    348 }
    349 
    350 void MainWin::propertyChange(bool itisedge, int prop, std::string mapname)
    351 {
    352   mapstorage.changeActiveMap(itisedge, prop, mapname);
    353 }
    354 
    355 void MainWin::popupNewMapWin(bool itisedge, int prop)
    356 {
    357   prop=prop;
    358   (new NewMapWin("NewMapWin", *this, itisedge, false))->run();
    359 }
    360 
    361 std::string MainWin::getActiveEdgeMap(int prop)
    362 {
    363   return mapstorage.getActiveEdgeMap(prop);
    364 }
    365 
    366 std::string MainWin::getActiveNodeMap(int prop)
    367 {
    368   return mapstorage.getActiveNodeMap(prop);
    369 }
    370 
    371 void MainWin::registerNewEdgeMap(std::string mapname)
    372 {
    373   if(mapwinexists)
    374     {
    375       mapwin->registerNewEdgeMap(mapname);
    376     }
    377 }
    378 
    379 void MainWin::registerNewNodeMap(std::string mapname)
    380 {
    381   if(mapwinexists)
    382     {
    383       mapwin->registerNewNodeMap(mapname);
    384     }
    385 }
    386 
    387 void MainWin::createMapWin()
    388 {
    389   if(!mapwinexists)
    390     {
    391       mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
    392       mapwin->show();
    393       mapwinexists=true;
    394     }
    395 }
    396 
    397 void MainWin::closeMapWin()
    398 {
    399   mapwinexists=false;
    400   delete mapwin;
    401 }
     353      else
     354        {
     355          continue;
     356        }
     357    }
     358  NewMapWin * nmw=new NewMapWin("Create New Map - "+tabnames[i], *nbt, itisedge, false);
     359  nmw->run();
     360}
  • gui/main_win.h

    r1838 r1849  
    44#define MAIN_WIN_H
    55
    6 class MainWin;
    7 
    86#include "all_include.h"
    9 #include "mapstorage.h"
    107#include "map_win.h"
    118#include "new_map_win.h"
    12 #include "graph_displayer_canvas.h"
     9#include "nbtab.h"
    1310#include <libgnomecanvasmm.h>
    1411#include <libgnomecanvasmm/polygon.h>
     12
    1513
    1614///This class is the main window of GUI.
     
    1816class MainWin : public Gtk::Window
    1917{
     18  ///Container
     19  Gtk::VBox vbox;
     20
     21  Gtk::Notebook notebook;
     22
     23  int active_tool;
     24
     25  int active_tab;
     26  std::vector<NoteBookTab *> tabs;
     27  std::vector<std::string> tabnames;
     28
    2029public:
    21   ///Constructor of the \ref MainWin. It creates the menu and the \ref GraphDisplayerCanvas on which the graph will be drawn.
     30 
     31  ///Constructor of the \ref NoteBookTab. It creates the menu and the \ref GraphDisplayerCanvas on which the graph will be drawn.
    2232  ///\param title is the title of the window
    2333  MainWin();
    2434
    25   MapStorage mapstorage;
    26 
    27   void readFile(const std::string &);
    28 
    29 protected:
    30   MapWin * mapwin;
    31   bool mapwinexists;
    32 
    33   ///The graph will be drawn on this \ref GraphDisplayerCanvas
    34   GraphDisplayerCanvas * gd_canvas;
     35  void set_tabtitle(std::string);
    3536
    3637  ///ActionGroup for menu
     
    4041  Glib::RefPtr<Gtk::UIManager> uim;
    4142
    42   ///Container
    43   Gtk::VBox vbox;
     43  void readFile(const std::string &);
    4444
    4545  ///Tooltips
    4646  Gtk::Tooltips tooltips;
     47
     48  //Call-backs of buttons
    4749
    4850  ///Callback for 'FileNew' action.
     
    5759  virtual void close();
    5860
    59 public:
    60   void propertyChange(bool, int, std::string);
    61   void popupNewMapWin(bool, int);
     61  //Toolbar
     62  virtual void zoomIn();
     63  virtual void zoomOut();
     64  virtual void zoomFit();
     65  virtual void zoom100();
    6266
    63   std::string getActiveEdgeMap(int);
    64   std::string getActiveNodeMap(int);
     67  virtual void createMapWin();
    6568
    66   void registerNewEdgeMap(std::string);
    67   void registerNewNodeMap(std::string);
     69  virtual void changeEditorialTool(int);
    6870
    69   void createMapWin();
    70   void closeMapWin();
     71  virtual void createNewMapWinAfterSignal(NoteBookTab *, bool);
     72  virtual void createNewMapWin();
     73
     74  //Notebook handlers
     75  ///Callback for 'FileNewTab' action.
     76  virtual void newTab();
     77  virtual void onChangeTab(GtkNotebookPage*, guint);
     78  virtual void onCloseTab();
     79
     80
    7181};
    7282
  • gui/map_win.cc

    r1838 r1849  
    66  if(e->keyval==GDK_Escape)
    77  {
    8     mainwin.closeMapWin();
     8    mytab.closeMapWin();
    99    //    hide();
    1010  }
     
    1212}
    1313
    14 MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, MainWin & mw):mainwin(mw)
     14MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw)
    1515{
    1616  set_title(title);
     
    2525  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    2626  {
    27     e_combo_array[i]=new MapSelector(eml, mainwin.getActiveEdgeMap(i), i, true);
     27    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), i, true);
    2828
    2929    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     
    4545  for(int i=0;i<NODE_PROPERTY_NUM;i++)
    4646  {
    47     n_combo_array[i]=new MapSelector(nml, mainwin.getActiveNodeMap(i), i, false);
     47    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), i, false);
    4848
    4949    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
     
    6969void MapWin::nodeMapChanged(std::string mapname, int prop)
    7070{
    71   mainwin.propertyChange(false, prop, mapname);
     71  mytab.propertyChange(false, prop, mapname);
    7272}
    7373
    7474void MapWin::edgeMapChanged(std::string mapname, int prop)
    7575{
    76   mainwin.propertyChange(true, prop, mapname);
     76  mytab.propertyChange(true, prop, mapname);
    7777}
    7878
    7979void MapWin::newMapWinNeeded(bool itisedge, int prop)
    8080{
    81   mainwin.popupNewMapWin(itisedge, prop);
     81  mytab.popupNewMapWin(itisedge, prop);
    8282}
    8383
     
    116116{
    117117  event=event;
    118   mainwin.closeMapWin();
     118  mytab.closeMapWin();
    119119  return true;
    120120}
  • gui/map_win.h

    r1838 r1849  
    77
    88#include <all_include.h>
    9 #include <main_win.h>
     9#include <nbtab.h>
    1010#include <libgnomecanvasmm.h>
    1111#include <libgnomecanvasmm/polygon.h>
     
    6666
    6767protected:
    68   MainWin & mainwin;
     68  NoteBookTab & mytab;
    6969
    7070  Gtk::Table * table;
     
    7878public:
    7979  ///Constructor of MapWin creates the widgets shown in MapWin.
    80   MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, MainWin & mw);
     80  MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, NoteBookTab & mw);
    8181
    8282  ~MapWin();
  • gui/new_map_win.cc

    r1837 r1849  
    1010}
    1111
    12 NewMapWin::NewMapWin(const std::string& title, MainWin & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mainwin(mw),node("Create NodeMap"),edge("Create EdgeMap")
     12NewMapWin::NewMapWin(const std::string& title, NoteBookTab & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mytab(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> (mainwin.mapstorage.graph);
     86              Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mytab.mapstorage.graph);
    8787
    8888              std::stack<double> polishstack;
    8989 
    90               for(EdgeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k)
     90              for(EdgeIt k(mytab.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=mainwin.mapstorage.edgemap_storage;
     109                          std::map< std::string,Graph::EdgeMap<double> * > ems=mytab.mapstorage.edgemap_storage;
    110110                          bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end());
    111111                          if(itisvar)
    112112                            {
    113                               polishstack.push( (*(mainwin.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
     113                              polishstack.push( (*(mytab.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(mainwin.mapstorage.addEdgeMap(mapname, emptr, def_val))
     156              if(mytab.mapstorage.addEdgeMap(mapname, emptr, def_val))
    157157                {
    158158                  abortion=1;
     
    160160
    161161              //add it to the list of the displayable maps
    162               mainwin.registerNewEdgeMap(mapname);
     162              mytab.registerNewEdgeMap(mapname);
    163163
    164164              //display it
     
    168168            {
    169169              //create the new map
    170               Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mainwin.mapstorage.graph);
     170              Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mytab.mapstorage.graph);
    171171
    172172              std::stack<double> polishstack;
    173173 
    174               for(NodeIt k(mainwin.mapstorage.graph); k!=INVALID; ++k)
     174              for(NodeIt k(mytab.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=mainwin.mapstorage.nodemap_storage;
     192                          std::map< std::string,Graph::NodeMap<double> * > nms=mytab.mapstorage.nodemap_storage;
    193193                          bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end());
    194194                          if(itisvar)
    195195                            {
    196                               polishstack.push( (*(mainwin.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
     196                              polishstack.push( (*(mytab.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(mainwin.mapstorage.addNodeMap(mapname,emptr, def_val))
     239              if(mytab.mapstorage.addNodeMap(mapname,emptr, def_val))
    240240                {
    241241                  abortion=1;
     
    243243
    244244              //add it to the list of the displayable maps
    245               mainwin.registerNewNodeMap(mapname);
     245              mytab.registerNewNodeMap(mapname);
    246246
    247247              //display it
     
    432432  if(itisedge)
    433433    {
    434       cancel=(mainwin.mapstorage.edgemap_storage.find(variable)==mainwin.mapstorage.edgemap_storage.end());
     434      cancel=(mytab.mapstorage.edgemap_storage.find(variable)==mytab.mapstorage.edgemap_storage.end());
    435435    }
    436436  else
    437437    {
    438       cancel=(mainwin.mapstorage.nodemap_storage.find(variable)==mainwin.mapstorage.nodemap_storage.end());
     438      cancel=(mytab.mapstorage.nodemap_storage.find(variable)==mytab.mapstorage.nodemap_storage.end());
    439439    }
    440440  //maybe it is number
  • gui/new_map_win.h

    r1837 r1849  
    77
    88#include <all_include.h>
    9 #include <main_win.h>
     9#include <nbtab.h>
    1010#include <libgnomecanvasmm.h>
    1111#include <libgnomecanvasmm/polygon.h>
     
    1717class NewMapWin : public Gtk::Dialog
    1818{
    19   MainWin & mainwin;
     19  NoteBookTab & mytab;
    2020
    2121public:
     
    2828 
    2929  ///Constructor of NewMapWin creates the widgets shown in NewMapWin.
    30   NewMapWin(const std::string& title, MainWin &, bool itisedge=true, bool edgenode=true);
     30  NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true);
    3131 
    3232  ///Signal on button is connected to this function,
Note: See TracChangeset for help on using the changeset viewer.