gnumeric r16963 - in trunk: . src/dialogs src/tools
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16963 - in trunk: . src/dialogs src/tools
- Date: Tue, 11 Nov 2008 22:59:11 +0000 (UTC)
Author: guelzow
Date: Tue Nov 11 22:59:11 2008
New Revision: 16963
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16963&view=rev
Log:
2008-11-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* kaplan-meier.glade: change radio buttons into spin buttons
* dialog-analysis-tool-kaplan-meier.c (KaplanMeierToolState):
change fields
(censor_mark_group): delete
(kaplan_meier_tool_ok_clicked_cb): read spin buttons rather than
radio buttons
(kaplan_meier_tool_set_censor_from_cb): new
(dialog_kaplan_meier_tool): setup spin buttons
2008-11-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-kaplan-meier.c (analysis_tool_kaplan_meier_engine_run):
handle a range of censor marks
* analysis-kaplan-meier.h (analysis_tools_data_kaplan_meier_t): add field
Modified:
trunk/NEWS
trunk/src/dialogs/ChangeLog
trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c
trunk/src/dialogs/kaplan-meier.glade
trunk/src/tools/ChangeLog
trunk/src/tools/analysis-kaplan-meier.c
trunk/src/tools/analysis-kaplan-meier.h
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Tue Nov 11 22:59:11 2008
@@ -7,6 +7,7 @@
* Permit lexicographic sorting by sheet names in the manage sheets
dialog [#527076]
* Add functional seealso links in the function browser
+ * Allow ranges of censor marks in Kaplan-Meier tool [#558582]
Hib Eris:
* Fix problems with toolbars when no handle bar present. [#559249]
Modified: trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c (original)
+++ trunk/src/dialogs/dialog-analysis-tool-kaplan-meier.c Tue Nov 11 22:59:11 2008
@@ -62,19 +62,13 @@
typedef struct {
GenericToolState base;
GtkWidget *censorship_button;
- GtkWidget *censorship_button_zero;
- GtkWidget *censorship_button_one;
+ GtkWidget *censor_spin_from;
+ GtkWidget *censor_spin_to;
GtkWidget *graph_button;
GtkWidget *tick_button;
GtkWidget *std_error_button;
} KaplanMeierToolState;
-static char const * const censor_mark_group[] = {
- "censor-button-0",
- "censor-button-1",
- NULL
-};
-
/**
* kaplan_meier_tool_update_sensitivity_cb:
* @dummy:
@@ -196,8 +190,9 @@
else
data->base.range_2 = NULL;
- data->censor_mark = gnumeric_glade_group_value (state->base.gui,
- censor_mark_group);
+ data->censor_mark = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (state->censor_spin_from));
+ data->censor_mark_to = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (state->censor_spin_to));
+
data->chart = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (state->graph_button));
data->ticks = gtk_toggle_button_get_active (
@@ -245,6 +240,16 @@
return FALSE;
}
static gboolean
+kaplan_meier_tool_set_censor_from_cb (G_GNUC_UNUSED GtkWidget *dummy,
+ KaplanMeierToolState *state)
+{
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (state->censor_spin_to),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (state->censor_spin_from)),G_MAXSHORT);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->censorship_button), TRUE);
+
+ return FALSE;
+}
+static gboolean
kaplan_meier_tool_set_censor_cb (G_GNUC_UNUSED GtkWidget *dummy,
KaplanMeierToolState *state)
{
@@ -292,12 +297,14 @@
state->censorship_button = GTK_WIDGET (glade_xml_get_widget
(state->base.gui,
"censor-button"));
- state->censorship_button_zero = GTK_WIDGET (glade_xml_get_widget
- (state->base.gui,
- "censor-button-0"));
- state->censorship_button_one = GTK_WIDGET (glade_xml_get_widget
- (state->base.gui,
- "censor-button-1"));
+ state->censor_spin_from = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "censored-spinbutton1"));
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (state->censor_spin_from), 0.,G_MAXSHORT);
+ state->censor_spin_to = GTK_WIDGET (glade_xml_get_widget
+ (state->base.gui,
+ "censored-spinbutton2"));
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (state->censor_spin_to), 0.,G_MAXSHORT);
state->graph_button = GTK_WIDGET (glade_xml_get_widget
(state->base.gui,
"graph-button"));
@@ -319,11 +326,11 @@
g_signal_connect_after (G_OBJECT (state->tick_button),
"toggled",
G_CALLBACK (kaplan_meier_tool_set_graph_cb), state);
- g_signal_connect_after (G_OBJECT (state->censorship_button_zero),
- "toggled",
- G_CALLBACK (kaplan_meier_tool_set_censor_cb), state);
- g_signal_connect_after (G_OBJECT (state->censorship_button_one),
- "toggled",
+ g_signal_connect_after (G_OBJECT (state->censor_spin_from),
+ "value-changed",
+ G_CALLBACK (kaplan_meier_tool_set_censor_from_cb), state);
+ g_signal_connect_after (G_OBJECT (state->censor_spin_to),
+ "value-changed",
G_CALLBACK (kaplan_meier_tool_set_censor_cb), state);
g_signal_connect (G_OBJECT
(gnm_expr_entry_get_entry (
Modified: trunk/src/dialogs/kaplan-meier.glade
==============================================================================
--- trunk/src/dialogs/kaplan-meier.glade (original)
+++ trunk/src/dialogs/kaplan-meier.glade Tue Nov 11 22:59:11 2008
@@ -37,39 +37,6 @@
<placeholder/>
</child>
<child>
- <widget class="GtkRadioButton" id="censor-button-1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Censored are marked by 1</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">censor-button-0</property>
- </widget>
- <packing>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_padding">50</property>
- </packing>
- </child>
- <child>
- <widget class="GtkRadioButton" id="censor-button-0">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Censored are marked by 0</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_padding">50</property>
- </packing>
- </child>
- <child>
<widget class="GtkCheckButton" id="censor-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -115,6 +82,58 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Censored record labels from:</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ </widget>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">to:</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ </widget>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="censored-spinbutton1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">0 0 1000 1 10 10</property>
+ <property name="climb_rate">1</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="censored-spinbutton2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">0 0 1000 1 10 10</property>
+ <property name="climb_rate">1</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
Modified: trunk/src/tools/analysis-kaplan-meier.c
==============================================================================
--- trunk/src/tools/analysis-kaplan-meier.c (original)
+++ trunk/src/tools/analysis-kaplan-meier.c Tue Nov 11 22:59:11 2008
@@ -55,7 +55,6 @@
int prob_col = info->censored ? 4 : 3;
GnmExpr const *expr_data;
- GnmExpr const *expr_censor;
GnmExpr const *expr_small;
GnmExpr const *expr_time;
GnmExpr const *expr_at_risk;
@@ -129,7 +128,38 @@
gnm_expr_new_constant (value_new_int (1)))));
if (info->censored) {
- expr_censor = gnm_expr_new_constant (value_dup (info->base.range_2));
+ GnmExpr const *expr_censor;
+
+ if (info->censor_mark == info->censor_mark_to)
+ expr_censor = gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (gnm_expr_new_constant (value_dup (info->base.range_2)),
+ GNM_EXPR_OP_EQUAL,
+ gnm_expr_new_constant (value_new_int (info->censor_mark))),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0)));
+ else
+ expr_censor = gnm_expr_new_binary
+ (gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (gnm_expr_new_constant (value_dup (info->base.range_2)),
+ GNM_EXPR_OP_GTE,
+ gnm_expr_new_constant (value_new_int (info->censor_mark))),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0))),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_binary
+ (gnm_expr_new_constant (value_dup (info->base.range_2)),
+ GNM_EXPR_OP_LTE,
+ gnm_expr_new_constant (value_new_int (info->censor_mark_to))),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0))));
+
+
expr_deaths = gnm_expr_new_funcall3
(fd_if,
gnm_expr_new_binary (make_cellref (-1, 0),
@@ -147,14 +177,10 @@
gnm_expr_new_constant (value_new_int (1)),
gnm_expr_new_constant (value_new_int (0))),
GNM_EXPR_OP_MULT,
- gnm_expr_new_funcall3
- (fd_if,
- gnm_expr_new_binary
- (gnm_expr_copy (expr_censor),
- GNM_EXPR_OP_EQUAL,
- gnm_expr_new_constant (value_new_int (info->censor_mark))),
- gnm_expr_new_constant (value_new_int (0)),
- gnm_expr_new_constant (value_new_int (1))))));
+ gnm_expr_new_binary
+ (gnm_expr_new_constant (value_new_int (1)),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_copy (expr_censor)))));
expr_censures = gnm_expr_new_funcall3
(fd_if,
gnm_expr_new_binary (make_cellref (-1, 0),
@@ -172,14 +198,7 @@
gnm_expr_new_constant (value_new_int (1)),
gnm_expr_new_constant (value_new_int (0))),
GNM_EXPR_OP_MULT,
- gnm_expr_new_funcall3
- (fd_if,
- gnm_expr_new_binary
- (expr_censor,
- GNM_EXPR_OP_EQUAL,
- gnm_expr_new_constant (value_new_int (info->censor_mark))),
- gnm_expr_new_constant (value_new_int (1)),
- gnm_expr_new_constant (value_new_int (0))))));
+ expr_censor)));
} else
expr_deaths = gnm_expr_new_funcall3
(fd_if,
Modified: trunk/src/tools/analysis-kaplan-meier.h
==============================================================================
--- trunk/src/tools/analysis-kaplan-meier.h (original)
+++ trunk/src/tools/analysis-kaplan-meier.h Tue Nov 11 22:59:11 2008
@@ -48,6 +48,7 @@
analysis_tools_data_generic_b_t base;
gboolean censored;
int censor_mark;
+ int censor_mark_to;
gboolean chart;
gboolean ticks;
gboolean std_err;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]