[Lemon-commits] [lemon_svn] hegyi: r3032 - glemon/trunk
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 21:51:58 CET 2006
Author: hegyi
Date: Mon Oct 30 15:57:48 2006
New Revision: 3032
Modified:
glemon/trunk/design_win.cc
glemon/trunk/design_win.h
glemon/trunk/graph_displayer_canvas.cc
glemon/trunk/graph_displayer_canvas.h
glemon/trunk/gui_reader.cc
glemon/trunk/gui_writer.cc
glemon/trunk/mapstorage.cc
glemon/trunk/mapstorage.h
glemon/trunk/nbtab.cc
glemon/trunk/nbtab.h
Log:
Redesign parameters can now be saved and loaded.
Modified: glemon/trunk/design_win.cc
==============================================================================
--- glemon/trunk/design_win.cc (original)
+++ glemon/trunk/design_win.cc Mon Oct 30 15:57:48 2006
@@ -89,3 +89,10 @@
{
Gtk::Window::set_title("Design Setup - "+tabname);
}
+
+void DesignWin::set_data(double attr, double propuls, int it)
+{
+ attraction->set_value(attr);
+ propulsation->set_value(propuls);
+ iteration->set_value(it);
+}
Modified: glemon/trunk/design_win.h
==============================================================================
--- glemon/trunk/design_win.h (original)
+++ glemon/trunk/design_win.h Mon Oct 30 15:57:48 2006
@@ -63,5 +63,7 @@
sigc::signal<void> close_run(){return close_run_pr;};
void set_title(std::string);
+
+ void set_data(double, double, int);
};
#endif //DESWIN_H
Modified: glemon/trunk/graph_displayer_canvas.cc
==============================================================================
--- glemon/trunk/graph_displayer_canvas.cc (original)
+++ glemon/trunk/graph_displayer_canvas.cc Mon Oct 30 15:57:48 2006
@@ -25,7 +25,7 @@
nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
- iterations(20), attraction(0.05), propulsation(40000), was_redesigned(false), is_drawn(false), mytab(mainw)
+ was_redesigned(false), is_drawn(false), mytab(mainw)
{
//base event handler is move tool
actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
@@ -304,7 +304,12 @@
moveNode(init.x, init.y, nodesmap[i], i);
was_redesigned=true;
}
-
+
+ double attraction;
+ double propulsation;
+ int iterations;
+
+ (mytab.mapstorage).get_design_data(attraction, propulsation, iterations);
//iteration counter
for(int l=0;l<iterations;l++)
@@ -393,25 +398,3 @@
}
}
-void GraphDisplayerCanvas::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
-{
- attraction_p=attraction;
- propulsation_p=propulsation;
- iterations_p=iterations;
-}
-
-void GraphDisplayerCanvas::set_attraction(double attraction_p)
-{
- attraction=attraction_p;
-}
-
-void GraphDisplayerCanvas::set_propulsation(double propulsation_p)
-{
- propulsation=propulsation_p;
-}
-
-void GraphDisplayerCanvas::set_iteration(int iterations_p)
-{
- iterations=iterations_p;
-}
-
Modified: glemon/trunk/graph_displayer_canvas.h
==============================================================================
--- glemon/trunk/graph_displayer_canvas.h (original)
+++ glemon/trunk/graph_displayer_canvas.h Mon Oct 30 15:57:48 2006
@@ -336,11 +336,6 @@
void reDesignGraph();
- void get_design_data(double &, double &, int &);
- void set_attraction(double);
- void set_propulsation(double);
- void set_iteration(int);
-
///Show whether the graph is already drawn.
bool is_drawn;
@@ -428,15 +423,6 @@
///Edge width
double edge_width;
- ///Iteration number during graph design
- int iterations;
-
- ///Attraction factor during graph design
- double attraction;
-
- ///Propulsation factor during graph design
- double propulsation;
-
///Was redesign run on this graph already?
///
///If not, the layout will be modified randomly
Modified: glemon/trunk/gui_reader.cc
==============================================================================
--- glemon/trunk/gui_reader.cc (original)
+++ glemon/trunk/gui_reader.cc Mon Oct 30 15:57:48 2006
@@ -60,6 +60,20 @@
{
mapstorage->changeActiveMap(true, i, em[i]);
}
+
+ double attraction;
+ double propulsation;
+ int iteration;
+
+ x("redesign-attraction", attraction);
+ x("redesign-propulsation", propulsation);
+ x("redesign-iteration", iteration);
+
+ mapstorage->set_attraction(attraction);
+ mapstorage->set_propulsation(propulsation);
+ mapstorage->set_iteration(iteration);
+
+ mapstorage->redesign_data_changed();
}
GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
Modified: glemon/trunk/gui_writer.cc
==============================================================================
--- glemon/trunk/gui_writer.cc (original)
+++ glemon/trunk/gui_writer.cc Mon Oct 30 15:57:48 2006
@@ -51,6 +51,16 @@
em[i]=mapstorage->active_edgemaps[i];
}
x("active_edgemaps", em);
+
+ double attraction;
+ double propulsation;
+ int iteration;
+
+ mapstorage->get_design_data(attraction, propulsation, iteration);
+
+ x("redesign-attraction", attraction);
+ x("redesign-propulsation", propulsation);
+ x("redesign-iteration", iteration);
}
GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms)
Modified: glemon/trunk/mapstorage.cc
==============================================================================
--- glemon/trunk/mapstorage.cc (original)
+++ glemon/trunk/mapstorage.cc Mon Oct 30 15:57:48 2006
@@ -23,7 +23,11 @@
#include <cmath>
#include <gtkmm.h>
-MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false)
+const double i_d=20;
+const double a_d=0.05;
+const double p_d=40000;
+
+MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false), iterations(i_d), attraction(a_d), propulsation(p_d)
{
nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph);
coords.setXMap(*nodemap_storage["coordinates_x"]);
@@ -148,7 +152,7 @@
return nml;
}
-MapStorage::Signal_Prop MapStorage::signal_prop_ch()
+sigc::signal<void, bool, int> MapStorage::signal_prop_ch()
{
return signal_prop;
}
@@ -485,6 +489,12 @@
changeActiveMap(true, i, "");
signal_map_win.emit(true, i, "");
}
+
+ attraction=a_d;
+ propulsation=p_d;
+ iterations=i_d;
+
+ signal_design_win.emit(attraction, propulsation, iterations);
}
void MapStorage::ArrowPosReadOK()
@@ -515,3 +525,30 @@
}
}
}
+
+void MapStorage::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
+{
+ attraction_p=attraction;
+ propulsation_p=propulsation;
+ iterations_p=iterations;
+}
+
+void MapStorage::set_attraction(double attraction_p)
+{
+ attraction=attraction_p;
+}
+
+void MapStorage::set_propulsation(double propulsation_p)
+{
+ propulsation=propulsation_p;
+}
+
+void MapStorage::set_iteration(int iterations_p)
+{
+ iterations=iterations_p;
+}
+
+void MapStorage::redesign_data_changed()
+{
+ signal_design_win.emit(attraction, propulsation, iterations);
+}
Modified: glemon/trunk/mapstorage.h
==============================================================================
--- glemon/trunk/mapstorage.h (original)
+++ glemon/trunk/mapstorage.h Mon Oct 30 15:57:48 2006
@@ -82,14 +82,13 @@
bool arrow_pos_read_ok;
protected:
- /// type of the signal emitted if the visualization of the maps might have to be updated.
+ /// Signal emitted on any change made on map values
+
+ /// Signal emitted if the visualization of the maps might have to be updated.
/// bool shows us whether the changed map is edge or nodemap.
/// int tells us the refreshed property
- typedef sigc::signal<void, bool, int> Signal_Prop;
-
- /// Signal emitted on any change made on map values
- Signal_Prop signal_prop;
+ sigc::signal<void, bool, int> signal_prop;
/// Signal emitted in the case of nodemap addition
@@ -106,6 +105,18 @@
/// Signal emitted, when entry in \ref MapWin should be changed.
sigc::signal<void, bool, int, std::string> signal_map_win;
+ /// Signal emitted, when entry in \ref DesignWin should be changed.
+ sigc::signal<void, double, double, int> signal_design_win;
+
+ ///Iteration number during graph design
+ int iterations;
+
+ ///Attraction factor during graph design
+ double attraction;
+
+ ///Propulsation factor during graph design
+ double propulsation;
+
public:
///Constructor of MapStorage.
@@ -152,7 +163,7 @@
std::vector<std::string> getNodeMapList();
///returns \ref signal_prop to be able to connect functions to it
- Signal_Prop signal_prop_ch();
+ sigc::signal<void, bool, int> signal_prop_ch();
///returns \ref signal_node_map to be able to connect functions to it
sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
@@ -163,6 +174,9 @@
///returns \ref signal_map_win to be able to connect functions to it
sigc::signal<void, bool, int, std::string> signal_map_win_ch(){return signal_map_win;};
+ ///returns \ref signal_design_win to be able to connect functions to it
+ sigc::signal<void, double, double, int> signal_design_win_ch(){return signal_design_win;};
+
///Adds given map to storage.
///A name and the map itself has to be provided.
@@ -261,6 +275,13 @@
void clear();
void ArrowPosReadOK();
+
+ void get_design_data(double &, double &, int &);
+ void set_attraction(double);
+ void set_propulsation(double);
+ void set_iteration(int);
+
+ void redesign_data_changed();
};
#endif //MAPSTORAGE_H
Modified: glemon/trunk/nbtab.cc
==============================================================================
--- glemon/trunk/nbtab.cc (original)
+++ glemon/trunk/nbtab.cc Mon Oct 30 15:57:48 2006
@@ -235,16 +235,18 @@
{
double attraction, propulsation;
int iterations;
- gd_canvas->get_design_data(attraction, propulsation, iterations);
+ mapstorage.get_design_data(attraction, propulsation, iterations);
designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations, *this);
- designwin->signal_attraction().connect(sigc::mem_fun(*this, &NoteBookTab::attraction_ch));
- designwin->signal_propulsation().connect(sigc::mem_fun(*this, &NoteBookTab::propulsation_ch));
- designwin->signal_iteration().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::set_iteration));
+ designwin->signal_attraction().connect(sigc::mem_fun(mapstorage, &MapStorage::set_attraction));
+ designwin->signal_propulsation().connect(sigc::mem_fun(mapstorage, &MapStorage::set_propulsation));
+ designwin->signal_iteration().connect(sigc::mem_fun(mapstorage, &MapStorage::set_iteration));
designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::reDesignGraph));
designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin));
+ mapst2designwin=mapstorage.signal_design_win_ch().connect(sigc::mem_fun(*designwin, &DesignWin::set_data));
+
designwin->show();
designwinexists=true;
}
@@ -262,6 +264,7 @@
if(e->type==GDK_DELETE)
{
designwinexists=false;
+ mapst2designwin.disconnect();
delete designwin;
}
}
@@ -286,21 +289,6 @@
gd_canvas->reDesignGraph();
}
-void NoteBookTab::attraction_ch(double v)
-{
- gd_canvas->set_attraction(v);
-}
-
-void NoteBookTab::propulsation_ch(double v)
-{
- gd_canvas->set_propulsation(v);
-}
-
-void NoteBookTab::iteration_ch(int v)
-{
- gd_canvas->set_iteration(v);
-}
-
void NoteBookTab::active_maps_needed()
{
mapstorage.broadcastActiveMaps();
Modified: glemon/trunk/nbtab.h
==============================================================================
--- glemon/trunk/nbtab.h (original)
+++ glemon/trunk/nbtab.h Mon Oct 30 15:57:48 2006
@@ -202,15 +202,6 @@
///Let the graph redesign, based on gravity and edge elasticity.
void reDesignGraph();
- ///Indicates that attraction factor is changed
- void attraction_ch(double);
-
- ///Indicates that propulsation factor is changed
- void propulsation_ch(double);
-
- ///Indicates that iteration number of redesign is changed
- void iteration_ch(int);
-
///\ref MapWin calls this function when it updates the maplist in comboboxes.
void active_maps_needed();
@@ -220,6 +211,12 @@
///If \ref MapWin is closed this connection has to be disconnected,
///therefore we have to store it.
sigc::connection mapst2mapwin;
+
+ ///Signal connection from \ref MapStorage to \ref DesignWin
+
+ ///If \ref DesignWin is closed this connection has to be disconnected,
+ ///therefore we have to store it.
+ sigc::connection mapst2designwin;
};
#endif //NBTAB_H
More information about the Lemon-commits
mailing list