[Lemon-commits] [lemon_svn] hegyi: r2453 - hugo/trunk/gui

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:52:48 CET 2006


Author: hegyi
Date: Thu Jan  5 13:30:09 2006
New Revision: 2453

Modified:
   hugo/trunk/gui/algobox.cc
   hugo/trunk/gui/algobox.h
   hugo/trunk/gui/algowin.cc
   hugo/trunk/gui/algowin.h
   hugo/trunk/gui/kruskalbox.cc
   hugo/trunk/gui/kruskalbox.h
   hugo/trunk/gui/main_win.cc
   hugo/trunk/gui/mapstorage.cc
   hugo/trunk/gui/mapstorage.h
   hugo/trunk/gui/nbtab.cc
   hugo/trunk/gui/new_map_win.cc

Log:
Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox.

Modified: hugo/trunk/gui/algobox.cc
==============================================================================
--- hugo/trunk/gui/algobox.cc	(original)
+++ hugo/trunk/gui/algobox.cc	Thu Jan  5 13:30:09 2006
@@ -3,12 +3,12 @@
 enum {N_DEMO1, N_DEMO2, NODE_INPUT_NUM}; // input IDs for nodes;
 enum {E_DEMO1, EDGE_INPUT_NUM}; // input IDs for edges;
 
-AlgoBox::AlgoBox(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
+AlgoBox::AlgoBox(std::vector<std::string> tabnames)
 {
-  init(tabnames, nodemapnames, edgemapnames);
+  init(tabnames);
 }
 
-void AlgoBox::init(std::vector<std::string> tabnames, std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
+void AlgoBox::init(std::vector<std::string> tabnames)
 {
   set_spacing(5);
 
@@ -18,11 +18,8 @@
   tabcbt.signal_changed().connect(sigc::mem_fun(*this, &AlgoBox::emit_tab_change));
 
   pack_start(tabcbt);
-
   build_box();
 
-  update_maplist(nodemapnames, edgemapnames);
-
   show_all_children();
 };
 
@@ -52,7 +49,7 @@
     }
   else if(actptr>0) //so there is item in the list
     {
-      cbt.set_active(0);
+      //cbt.set_active(0);
     }
 }
 
@@ -62,8 +59,18 @@
   emit_tab_change();
 }
 
-void AlgoBox::update_maplist( std::vector< std::string > nml, std::vector< std::string > eml )
+void AlgoBox::update_maplist( void * ms)
 {
+  mapstorage=(MapStorage *)ms;
+  std::vector<std::string> nml;
+  std::vector<std::string> eml;
+  if(mapstorage!=NULL)
+    {
+      mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
+      mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed));
+      nml=mapstorage->getNodeMapList();
+      eml=mapstorage->getNodeMapList();
+    }
   for(int i=0;i<(int)nodemapcbts.size();i++)
     {
       update_cbt(nml, *(nodemapcbts[i]));
@@ -74,6 +81,22 @@
     }
 }
 
+void AlgoBox::nodemaplist_changed(std::string newmap)
+{
+  for(int i=0;i<(int)nodemapcbts.size();i++)
+    {
+      (nodemapcbts[i])->append_text(newmap);
+    }
+}
+
+void AlgoBox::edgemaplist_changed(std::string newmap)
+{
+  for(int i=0;i<(int)edgemapcbts.size();i++)
+    {
+      (edgemapcbts[i])->append_text(newmap);
+    }
+}
+
 void AlgoBox::run()
 {
   std::cout << "Start algorithm." << std::endl;
@@ -136,5 +159,14 @@
 
 void AlgoBox::emit_tab_change()
 {
-  signal_maplist_need.emit(tabcbt.get_active_text());
+  std::string active_tab=tabcbt.get_active_text();
+  if(active_tab!="")
+    {
+      signal_maplist_need.emit(active_tab);
+    }
+  else
+    {
+      std::vector<std::string> empty_vector;
+      update_maplist(NULL);
+    }
 }

Modified: hugo/trunk/gui/algobox.h
==============================================================================
--- hugo/trunk/gui/algobox.h	(original)
+++ hugo/trunk/gui/algobox.h	Thu Jan  5 13:30:09 2006
@@ -6,6 +6,7 @@
 class AlgoBox;
 
 #include <all_include.h>
+#include <mapstorage.h>
 #include <libgnomecanvasmm.h>
 #include <libgnomecanvasmm/polygon.h>
 
@@ -19,18 +20,23 @@
   Gtk::Label * label;
   std::vector<Gtk::ComboBoxText *> nodemapcbts;
   std::vector<Gtk::ComboBoxText *> edgemapcbts;
-  
+
+  MapStorage * mapstorage;
+
 public:
   AlgoBox(){};
-  AlgoBox(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
+  AlgoBox(std::vector<std::string>);
 
-  virtual void init(std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
+  virtual void init(std::vector<std::string>);
 
   sigc::signal<void, std::string> signal_maplist_needed();  
   void emit_tab_change();
 
   void update_tablist( std::vector< std::string > tl );
-  void update_maplist( std::vector< std::string >, std::vector< std::string >);
+  void update_maplist( void * );
+
+  void nodemaplist_changed(std::string);
+  void edgemaplist_changed(std::string);
 
   void update_cbt( std::vector< std::string > tl, Gtk::ComboBoxText &);
   

Modified: hugo/trunk/gui/algowin.cc
==============================================================================
--- hugo/trunk/gui/algowin.cc	(original)
+++ hugo/trunk/gui/algowin.cc	Thu Jan  5 13:30:09 2006
@@ -20,7 +20,7 @@
   return true;
 }
 
-AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames, std::vector<std::string> nodemapnames,std::vector<std::string> edgemapnames)
+AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
 {
   signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
 
@@ -32,11 +32,11 @@
   switch(algoid)
     {
     case 0:
-      ab=new AlgoBox(tabnames, nodemapnames, edgemapnames);
+      ab=new AlgoBox(tabnames);
       set_title("Algo Win Demo");
       break;
     case 1:
-      ab=new KruskalBox(tabnames, nodemapnames, edgemapnames);
+      ab=new KruskalBox(tabnames);
       set_title("Kruskal Algorithm");
       break;
     default:
@@ -71,9 +71,9 @@
   ab->update_tablist(tabnames);
 }
 
-void AlgoWin::update_maplist(std::vector<std::string> nodemapnames, std::vector<std::string> edgemapnames)
+void AlgoWin::update_maplist(void * mapstorage)
 {
-  ab->update_maplist(nodemapnames, edgemapnames);
+  ab->update_maplist(mapstorage);
 }
 
 void AlgoWin::on_hide()

Modified: hugo/trunk/gui/algowin.h
==============================================================================
--- hugo/trunk/gui/algowin.h	(original)
+++ hugo/trunk/gui/algowin.h	Thu Jan  5 13:30:09 2006
@@ -31,10 +31,10 @@
 
   void emit_tab_change(std::string);
 
-  AlgoWin(int, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>);
+  AlgoWin(int, std::vector<std::string>);
 
   void update_tablist(std::vector<std::string> tabnames);
-  void update_maplist(std::vector<std::string>, std::vector<std::string>);
+  void update_maplist( void *);
 
   void on_hide();
 };

Modified: hugo/trunk/gui/kruskalbox.cc
==============================================================================
--- hugo/trunk/gui/kruskalbox.cc	(original)
+++ hugo/trunk/gui/kruskalbox.cc	Thu Jan  5 13:30:09 2006
@@ -1,12 +1,13 @@
 #include <kruskalbox.h>
 
-KruskalBox::KruskalBox(std::vector<std::string> t, std::vector<std::string> nm, std::vector<std::string> em):AlgoBox()
+KruskalBox::KruskalBox(std::vector<std::string> t):AlgoBox()
 {
-  init(t, nm, em);
+  init(t);
 }
     
 void KruskalBox::run()
 {
+  
   std::cout << "Kruskal inditasa, de meg nincsen keszen." << std::endl;
 }
     

Modified: hugo/trunk/gui/kruskalbox.h
==============================================================================
--- hugo/trunk/gui/kruskalbox.h	(original)
+++ hugo/trunk/gui/kruskalbox.h	Thu Jan  5 13:30:09 2006
@@ -14,7 +14,7 @@
 class KruskalBox : public AlgoBox
 {
 public:
-  KruskalBox(std::vector<std::string> t, std::vector<std::string> nm, std::vector<std::string> em);
+  KruskalBox(std::vector<std::string> t);
     
   void run();
     

Modified: hugo/trunk/gui/main_win.cc
==============================================================================
--- hugo/trunk/gui/main_win.cc	(original)
+++ hugo/trunk/gui/main_win.cc	Thu Jan  5 13:30:09 2006
@@ -409,20 +409,30 @@
 
 void MainWin::createAlgoWin(int algoid)
 {
-  AlgoWin * aw=new AlgoWin(algoid, tabnames, tabs[0]->mapstorage.getNodeMapList(),tabs[0]->mapstorage.getEdgeMapList());
+  AlgoWin * aw=new AlgoWin(algoid, tabnames);
   aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
   aw->signal_maplist_needed().connect(sigc::mem_fun(*this, &MainWin::updateAlgoWinMaps));
   aws.insert(aw);
   aw->show();
 }
 
+void MainWin::updateAlgoWinTabs()
+{
+  std::set< AlgoWin* >::iterator awsi=aws.begin();
+  for(;awsi!=aws.end();awsi++)
+    {
+      (*awsi)->update_tablist(tabnames);
+    }
+}
+
 void MainWin::updateAlgoWinMaps(AlgoWin * awp, std::string tabname)
 {
   int i=0;
   for(;(i<(int)tabnames.size())&&(tabnames[i]!=tabname);i++)
     {
     }
-  awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList());
+  //awp->update_maplist(tabs[i]->mapstorage.getNodeMapList(),tabs[i]->mapstorage.getEdgeMapList());
+  awp->update_maplist(&(tabs[i]->mapstorage));
 }
 
 void MainWin::deRegisterAlgoWin(AlgoWin * awp)
@@ -430,15 +440,6 @@
   aws.erase(awp);
 }
 
-void MainWin::updateAlgoWinTabs()
-{
-  std::set< AlgoWin* >::iterator awsi=aws.begin();
-  for(;awsi!=aws.end();awsi++)
-    {
-      (*awsi)->update_tablist(tabnames);
-    }
-}
-
 void MainWin::changeEditorialTool(int tool)
 {
   active_tool=tool;

Modified: hugo/trunk/gui/mapstorage.cc
==============================================================================
--- hugo/trunk/gui/mapstorage.cc	(original)
+++ hugo/trunk/gui/mapstorage.cc	Thu Jan  5 13:30:09 2006
@@ -58,6 +58,9 @@
       nodemap_storage[name]=nodemap;
       // set the maps default value
       nodemap_default[name] = default_value;
+
+      //announce changement in maps
+      signal_node_map.emit(name);
       return 0;
     }
   return 1;
@@ -126,6 +129,9 @@
       edgemap_storage[name]=edgemap;
       // set the maps default value
       edgemap_default[name] = default_value;
+
+      //announce changement in maps
+      signal_edge_map.emit(name);
       return 0;
     }
   return 1;

Modified: hugo/trunk/gui/mapstorage.h
==============================================================================
--- hugo/trunk/gui/mapstorage.h	(original)
+++ hugo/trunk/gui/mapstorage.h	Thu Jan  5 13:30:09 2006
@@ -60,6 +60,8 @@
 protected:
   typedef sigc::signal<void, bool, int> Signal_Prop;
   Signal_Prop signal_prop;
+  sigc::signal<void, std::string> signal_node_map;
+  sigc::signal<void, std::string> signal_edge_map;
 
 public:
   ///Constructor of MapStorage. Expects the Graph of
@@ -82,6 +84,9 @@
 
   Signal_Prop signal_prop_ch();
 
+  sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
+  sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
+
   ///Adds given map to storage. A name and the map itself has to be provided.
   ///\param name is the name of map
   ///\nodemap is the pointer of the given nodemap

Modified: hugo/trunk/gui/nbtab.cc
==============================================================================
--- hugo/trunk/gui/nbtab.cc	(original)
+++ hugo/trunk/gui/nbtab.cc	Thu Jan  5 13:30:09 2006
@@ -7,6 +7,8 @@
 
   //connecting signals - controller character
   mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
+  mapstorage.signal_node_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewNodeMap));
+  mapstorage.signal_edge_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewEdgeMap));
   show_all_children();
   show();
 }

Modified: hugo/trunk/gui/new_map_win.cc
==============================================================================
--- hugo/trunk/gui/new_map_win.cc	(original)
+++ hugo/trunk/gui/new_map_win.cc	Thu Jan  5 13:30:09 2006
@@ -159,7 +159,8 @@
 		}
 
 	      //add it to the list of the displayable maps
-	      mytab.registerNewEdgeMap(mapname);
+	      //furthermore it is done by signals
+	      //mytab.registerNewEdgeMap(mapname);
 
 	      //display it
 	      //gdc.changeEdgeText(mapname);
@@ -242,7 +243,8 @@
 		}
 
 	      //add it to the list of the displayable maps
-	      mytab.registerNewNodeMap(mapname);
+	      //furthermore it is done by signals
+	      //mytab.registerNewNodeMap(mapname);
 
 	      //display it
 	      //gdc.changeNodeText(mapname);



More information about the Lemon-commits mailing list