[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461

Andrei Zavada johnhommer at gmail.com
Fri Nov 16 00:50:11 UTC 2012


The following commit has been merged in the master branch:
commit 5c117bdefee72dc83d50646b26b30f5bc77a88e6
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Fri Oct 12 02:39:12 2012 +0300

    SUIVar WIP

diff --git a/src/ui/expdesign.cc b/src/ui/expdesign.cc
index 6f0776b..028fa4f 100644
--- a/src/ui/expdesign.cc
+++ b/src/ui/expdesign.cc
@@ -193,6 +193,11 @@ SExpDesignUI (aghui::SSessionChooser *parent,
 					placeholders::_1, placeholders::_2, placeholders::_3));
 	nodestroy_by_cb = false;
 
+	// bind fields to widgets
+	W_V.reg( eUltradianCycleDetectionAccuracy, uc_accuracy_factor);
+	W_V.reg( eArtifDampenWindowType, (int)ED->af_dampen_window_type);
+	W_V.reg( eArtifDampenFactor, ED->af_dampen_factor);
+
 	fft_params_welch_window_type_saved	= ED->fft_params.welch_window_type;
 	af_dampen_window_type_saved		= ED->af_dampen_window_type;
 	af_dampen_factor_saved			= ED->af_dampen_factor;
diff --git a/src/ui/expdesign.hh b/src/ui/expdesign.hh
index 6f160b4..6dd558c 100644
--- a/src/ui/expdesign.hh
+++ b/src/ui/expdesign.hh
@@ -284,6 +284,8 @@ class SExpDesignUI
 	// 	fft_params_saved; // members not represented in widgets as is
 	sigfile::SMCParamSet
 		mc_params_saved;
+	SUICollection
+		W_V;
 
       // status bar bits
 	void sb_main_progress_indicator( const char*, size_t n, size_t i);
diff --git a/src/ui/ui.hh b/src/ui/ui.hh
index 02464f5..fe0e998 100644
--- a/src/ui/ui.hh
+++ b/src/ui/ui.hh
@@ -18,6 +18,7 @@
 #include <cstdlib>
 #include <cstring>
 #include <string>
+#include <list>
 #include <valarray>
 #include <itpp/base/mat.h>
 #include <gtk/gtk.h>
@@ -202,49 +203,69 @@ class SBusyBlock {
 
 
 
+class SUIVar_base {
+    public:
+	virtual void down() const = 0;
+	virtual void up() const = 0;
+};
+
 
 template <typename Tw, typename Tv>
-class SUIVar {
-	DELETE_DEFAULT_METHODS (SUIVar);
+class SUIVar_ : public SUIVar_base {
+	DELETE_DEFAULT_METHODS (SUIVar_);
 
-    private:
 	Tw	*w;
 	Tv&	v;
 
     public:
-	SUIVar (Tw w_, Tv& v_)
+	SUIVar_ (Tw* w_, Tv& v_)
 	      : w (w_), v (v_)
 		{}
-	void down();
-	void up();
+
+	virtual void down() const;
+	virtual void up() const;
 };
 
 
 template <>
 inline void
-SUIVar<GtkSpinButton, double>::up()
+SUIVar_<GtkSpinButton, double>::up() const
 {
 	gtk_spin_button_set_value( w, v);
 }
 
 template <>
 inline void
-SUIVar<GtkSpinButton, double>::down()
+SUIVar_<GtkSpinButton, double>::down() const
 {
 	v = gtk_spin_button_get_value( w);
 }
 
+template <>
+inline void
+SUIVar_<GtkSpinButton, int>::up() const
+{
+	gtk_spin_button_set_value( w, (double)v);
+}
+
+template <>
+inline void
+SUIVar_<GtkSpinButton, int>::down() const
+{
+	v = (int)round(gtk_spin_button_get_value( w));
+}
+
 
 template <>
 inline void
-SUIVar<GtkCheckButton, bool>::up()
+SUIVar_<GtkCheckButton, bool>::up() const
 {
 	gtk_toggle_button_set_active( (GtkToggleButton*)w, v);
 }
 
 template <>
 inline void
-SUIVar<GtkCheckButton, bool>::down()
+SUIVar_<GtkCheckButton, bool>::down() const
 {
 	v = gtk_toggle_button_get_active( (GtkToggleButton*)w);
 }
@@ -252,14 +273,14 @@ SUIVar<GtkCheckButton, bool>::down()
 
 template <>
 inline void
-SUIVar<GtkEntry, string>::up()
+SUIVar_<GtkEntry, string>::up() const
 {
 	gtk_entry_set_text( w, v.c_str());
 }
 
 template <>
 inline void
-SUIVar<GtkEntry, string>::down()
+SUIVar_<GtkEntry, string>::down() const
 {
 	const char *tmp = gtk_entry_get_text( w);
 	v.assign(tmp);
@@ -268,6 +289,50 @@ SUIVar<GtkEntry, string>::down()
 
 
 
+class SUICollection {
+    public:
+       ~SUICollection ()
+		{
+			for ( auto& A : c )
+				delete A;
+		}
+
+	void reg( GtkSpinButton *w, double& v)
+		{
+			c.push_back( new SUIVar_<GtkSpinButton, double> (w, v));
+		}
+	void reg( GtkSpinButton *w, int& v)
+		{
+			c.push_back( new SUIVar_<GtkSpinButton, int> (w, v));
+		}
+	void reg( GtkCheckButton *w, bool& v)
+		{
+			c.push_back( new SUIVar_<GtkCheckButton, bool> (w, v));
+		}
+	void reg( GtkEntry *w, string& v)
+		{
+			c.push_back( new SUIVar_<GtkEntry, string> (w, v));
+		}
+
+	void up() const
+		{
+			for ( auto& A : c )
+				A->up();
+		}
+	void down() const
+		{
+			for ( auto& A : c )
+				A->down();
+		}
+
+    private:
+	list<SUIVar_base*> c;
+};
+
+
+
+
+
 
 
 #define AGH_GBGETOBJ(Type, A)				\

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list