Commit a67a3eee authored by Jukka-Pekka Iivonen's avatar Jukka-Pekka Iivonen Committed by jpekka

Implemented Glade dialogs for Correlation, Covariance, and F-Test tools.

2000-02-14  Jukka-Pekka Iivonen  <iivonen@iki.fi>

	* src/dialogs/analysis-tools.glade, src/analysis-tools.c,
 	src/dialogs/dialog-analysis-tools.c: Implemented Glade dialogs for
 	Correlation, Covariance, and F-Test tools.
parent fbf52c42
2000-02-14 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/analysis-tools.glade, src/analysis-tools.c,
src/dialogs/dialog-analysis-tools.c: Implemented Glade dialogs for
Correlation, Covariance, and F-Test tools.
2000-02-14 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_event) : Handle rename from
......
2000-02-14 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialogs/analysis-tools.glade, src/analysis-tools.c,
src/dialogs/dialog-analysis-tools.c: Implemented Glade dialogs for
Correlation, Covariance, and F-Test tools.
2000-02-14 Jody Goldberg <jgoldberg@home.com>
* src/item-bar.c (item_bar_event) : Handle rename from
......
......@@ -310,7 +310,7 @@ correlation_tool (Workbook *wb, Sheet *sheet,
prepare_output (wb, dao, _("Correlations"));
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
if (columns_flag) {
vars = cols;
......@@ -458,7 +458,7 @@ covariance_tool (Workbook *wb, Sheet *sheet,
cols = input_range->end.col - input_range->start.col + 1;
rows = input_range->end.row - input_range->start.row + 1;
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
if (columns_flag) {
vars = cols;
......@@ -627,7 +627,7 @@ summary_statistics (Workbook *wb, data_set_t *data_set, int vars,
prepare_output (wb, dao, _("Summary Statistics"));
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
for (col=0; col<vars; col++) {
sprintf (buf, _("Column %d"), col+1);
set_cell (dao, col+1, 0, buf);
......@@ -1005,7 +1005,7 @@ int ztest_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
get_data (sheet, input_range1, &set_one);
get_data (sheet, input_range2, &set_two);
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
if (dao->labels_flag) {
char *s;
......@@ -1135,7 +1135,7 @@ ttest_paired_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
prepare_output (wb, dao, _("t-Test"));
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
if (dao->labels_flag) {
char *s;
......@@ -1282,7 +1282,7 @@ ttest_eq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
get_data (sheet, input_range1, &set_one);
get_data (sheet, input_range2, &set_two);
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
if (dao->labels_flag) {
char *s;
......@@ -1408,7 +1408,7 @@ ttest_neq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
get_data (sheet, input_range1, &set_one);
get_data (sheet, input_range2, &set_two);
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
if (dao->labels_flag) {
char *s;
......@@ -1532,7 +1532,7 @@ ftest_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
prepare_output (wb, dao, _("F-Test"));
set_cell (dao, 0, 0, "");
set_cell (dao, 0, 0, " ");
if (dao->labels_flag) {
char *s;
......
This diff is collapsed.
......@@ -6,3 +6,24 @@
gchar *s = N_("Data Analysis");
gchar *s = N_("Analysis Tools");
gchar *s = N_("F-Test: Two-Sample for Variances");
gchar *s = N_("Input:");
gchar *s = N_("Labels in First Row");
gchar *s = N_("Variable 1 Range:");
gchar *s = N_("Variable 2 Range:");
gchar *s = N_(" Alpha:");
gchar *s = N_("Output options:");
gchar *s = N_("Output Range: ");
gchar *s = N_("New Workbook");
gchar *s = N_("New Sheet ");
gchar *s = N_("Correlation");
gchar *s = N_("Input:");
gchar *s = N_(" Input Range: ");
gchar *s = N_("Grouped By:");
gchar *s = N_("Columns");
gchar *s = N_("Rows");
gchar *s = N_("Labels");
gchar *s = N_("Output options:");
gchar *s = N_("Output Range: ");
gchar *s = N_("New Workbook");
gchar *s = N_("New Sheet ");
......@@ -120,6 +120,110 @@ static const char *distribution_strs[] = {
NULL
};
static void
new_sheet_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*type = NewSheetOutput;
}
}
static void
new_workbook_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*type = NewWorkbookOutput;
}
}
static void
range_output_toggled(GtkWidget *widget, data_analysis_output_type_t *type)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*type = RangeOutput;
}
}
static void
columns_toggled(GtkWidget *widget, int *group)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*group = 0;
}
}
static void
rows_toggled(GtkWidget *widget, int *group)
{
if (GTK_TOGGLE_BUTTON (widget)->active) {
*group = 1;
}
}
static int
set_output_option_signals (GladeXML *gui, data_analysis_output_t *dao)
{
GtkWidget *radiobutton;
radiobutton = glade_xml_get_widget (gui, "radiobutton1");
if (!radiobutton) {
printf ("Corrupt file analysis-tools.glade\n");
return 1;
}
gtk_signal_connect (GTK_OBJECT (radiobutton), "toggled",
GTK_SIGNAL_FUNC (new_sheet_toggled),
&dao->type);
radiobutton = glade_xml_get_widget (gui, "radiobutton2");
if (!radiobutton) {
printf ("Corrupt file analysis-tools.glade\n");
return 1;
}
gtk_signal_connect (GTK_OBJECT (radiobutton), "toggled",
GTK_SIGNAL_FUNC (new_workbook_toggled),
&dao->type);
radiobutton = glade_xml_get_widget (gui, "radiobutton3");
if (!radiobutton) {
printf ("Corrupt file analysis-tools.glade\n");
return 1;
}
gtk_signal_connect (GTK_OBJECT (radiobutton), "toggled",
GTK_SIGNAL_FUNC (range_output_toggled),
&dao->type);
return 0;
}
static int
set_group_option_signals (GladeXML *gui, int *group)
{
GtkWidget *radiobutton;
radiobutton = glade_xml_get_widget (gui, "radiobutton5");
if (!radiobutton) {
printf ("Corrupt file analysis-tools.glade\n");
return 1;
}
gtk_signal_connect (GTK_OBJECT (radiobutton), "toggled",
GTK_SIGNAL_FUNC (columns_toggled),
group);
radiobutton = glade_xml_get_widget (gui, "radiobutton6");
if (!radiobutton) {
printf ("Corrupt file analysis-tools.glade\n");
return 1;
}
gtk_signal_connect (GTK_OBJECT (radiobutton), "toggled",
GTK_SIGNAL_FUNC (rows_toggled),
group);
return 0;
}
static void
checkbutton_toggled(GtkWidget *widget, gboolean *flag)
{
*flag = GTK_TOGGLE_BUTTON (widget)->active;
}
static void
summary_stat_signal_fun ()
{
......@@ -433,63 +537,61 @@ add_groupped_by(GtkWidget *box)
static void
dialog_correlation_tool (Workbook *wb, Sheet *sheet)
{
static GtkWidget *dialog, *box;
static GtkWidget *range_entry, *output_range_entry;
static GSList *group_ops, *output_ops;
static int labels = 0;
data_analysis_output_t dao;
char *text;
int selection;
static Range range;
int i=0, output;
label_row_flag = labels;
if (!dialog) {
dialog = new_dialog(_("Correlation"));
GladeXML *gui;
GtkWidget *range_entry;
GtkWidget *dialog;
GtkWidget *checkbutton;
GtkWidget *output_range_entry;
box = gtk_vbox_new (FALSE, 0);
data_analysis_output_t dao;
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
gboolean labels = FALSE;
char *text;
int group, selection, x1, x2, y1, y2;
Range range;
box = new_frame(_("Input:"), box);
gui = glade_xml_new (GNUMERIC_GLADEDIR "/analysis-tools.glade", NULL);
range_entry = hbox_pack_label_and_entry
(_("Input Range:"), "", 20, box);
if (!gui) {
printf ("Could not find analysis-tools.glade\n");
return;
}
group_ops = add_groupped_by(box);
dao.type = NewSheetOutput;
group = 0;
add_check_buttons(box, label_button);
dialog = glade_xml_get_widget (gui, "Correlation");
range_entry = glade_xml_get_widget (gui, "entry5");
checkbutton = glade_xml_get_widget (gui, "checkbutton1");
output_range_entry = glade_xml_get_widget (gui, "entry4");
box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
output_range_entry = add_output_frame(box, &output_ops);
if (!dialog || !range_entry || !output_range_entry || !checkbutton) {
printf ("Corrupt file analysis-tools.glade\n");
return;
}
if (set_group_option_signals (gui, &group) ||
set_output_option_signals (gui, &dao))
return;
gtk_widget_show_all (dialog);
} else
gtk_widget_show_all (dialog);
gtk_signal_connect (GTK_OBJECT (checkbutton), "toggled",
GTK_SIGNAL_FUNC (checkbutton_toggled), &labels);
gtk_widget_grab_focus (range_entry);
correlation_dialog_loop:
selection = gnumeric_dialog_run (wb, GNOME_DIALOG (dialog));
if (selection == -1)
if (selection == -1) {
gtk_object_unref (GTK_OBJECT (gui));
return;
}
if (selection != 0) {
gnome_dialog_close (GNOME_DIALOG (dialog));
gtk_object_destroy (GTK_OBJECT (dialog));
gnome_dialog_close (GNOME_DIALOG (dialog));
return;
}
i = gtk_radio_group_get_selected (group_ops);
output = gtk_radio_group_get_selected (output_ops);
text = gtk_entry_get_text (GTK_ENTRY (range_entry));
if (!parse_range (text, &range.start.col,
&range.start.row,
......@@ -501,78 +603,91 @@ correlation_dialog_loop:
goto correlation_dialog_loop;
}
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto correlation_dialog_loop;
labels = label_row_flag;
dao.labels_flag = labels;
if (correlation_tool (wb, sheet, &range, !i, &dao))
if (dao.type == RangeOutput) {
text = gtk_entry_get_text (GTK_ENTRY (output_range_entry));
if (!parse_range (text, &x1, &y1, &x2, &y2)) {
error_in_entry(wb, output_range_entry,
_("You should introduce a valid cell "
"range in 'Output Range:'"));
goto correlation_dialog_loop;
} else {
dao.start_col = x1;
dao.start_row = y1;
dao.cols = x2-x1+1;
dao.rows = y2-y1+1;
dao.sheet = sheet;
}
}
if (correlation_tool (wb, sheet, &range, !group, &dao))
goto correlation_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
gtk_object_destroy (GTK_OBJECT (dialog));
gtk_object_unref (GTK_OBJECT (gui));
}
static void
dialog_covariance_tool (Workbook *wb, Sheet *sheet)
{
static GtkWidget *dialog, *box;
static GtkWidget *range_entry, *output_range_entry;
static GSList *group_ops, *output_ops;
static int labels = 0;
data_analysis_output_t dao;
char *text;
int selection, output;
static Range range;
int i=0;
label_row_flag = labels;
GladeXML *gui;
GtkWidget *range_entry;
GtkWidget *dialog;
GtkWidget *checkbutton;
GtkWidget *output_range_entry;
if (!dialog) {
dialog = new_dialog(_("Covariance"));
data_analysis_output_t dao;
box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
gboolean labels = FALSE;
char *text;
int group, selection, x1, x2, y1, y2;
Range range;
box = new_frame(_("Input:"), box);
gui = glade_xml_new (GNUMERIC_GLADEDIR "/analysis-tools.glade", NULL);
range_entry = hbox_pack_label_and_entry
(_("Input Range:"), "", 20, box);
if (!gui) {
printf ("Could not find analysis-tools.glade\n");
return;
}
group_ops = add_groupped_by(box);
add_check_buttons(box, label_button);
dao.type = NewSheetOutput;
group = 0;
box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
dialog = glade_xml_get_widget (gui, "Covariance");
range_entry = glade_xml_get_widget (gui, "entry5");
checkbutton = glade_xml_get_widget (gui, "checkbutton1");
output_range_entry = glade_xml_get_widget (gui, "entry4");
output_range_entry = add_output_frame(box, &output_ops);
if (!dialog || !range_entry || !output_range_entry || !checkbutton) {
printf ("Corrupt file analysis-tools.glade\n");
return;
}
if (set_group_option_signals (gui, &group) ||
set_output_option_signals (gui, &dao))
return;
gtk_widget_show_all (dialog);
} else
gtk_widget_show_all (dialog);
gtk_signal_connect (GTK_OBJECT (checkbutton), "toggled",
GTK_SIGNAL_FUNC (checkbutton_toggled), &labels);
gtk_widget_grab_focus (range_entry);
covariance_dialog_loop:
dialog_loop:
selection = gnumeric_dialog_run (wb, GNOME_DIALOG (dialog));
if (selection == -1)
if (selection == -1) {
gtk_object_unref (GTK_OBJECT (gui));
return;
}
if (selection != 0) {
gtk_object_destroy (GTK_OBJECT (dialog));
gnome_dialog_close (GNOME_DIALOG (dialog));
return;
}
i = gtk_radio_group_get_selected (group_ops);
output = gtk_radio_group_get_selected (output_ops);
text = gtk_entry_get_text (GTK_ENTRY (range_entry));
if (!parse_range (text, &range.start.col,
&range.start.row,
......@@ -581,22 +696,37 @@ covariance_dialog_loop:
error_in_entry(wb, range_entry,
_("You should introduce a valid cell range "
"in 'Range:'"));
goto covariance_dialog_loop;
goto dialog_loop;
}
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto covariance_dialog_loop;
labels = label_row_flag;
dao.labels_flag = labels;
if (covariance_tool (wb, sheet, &range, !i, &dao))
goto covariance_dialog_loop;
if (dao.type == RangeOutput) {
text = gtk_entry_get_text (GTK_ENTRY (output_range_entry));
if (!parse_range (text, &x1, &y1, &x2, &y2)) {
error_in_entry(wb, output_range_entry,
_("You should introduce a valid cell "
"range in 'Output Range:'"));
goto dialog_loop;
} else {
dao.start_col = x1;
dao.start_row = y1;
dao.cols = x2-x1+1;
dao.rows = y2-y1+1;
dao.sheet = sheet;
}
}
if (covariance_tool (wb, sheet, &range, !group, &dao))
goto dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
gtk_object_destroy (GTK_OBJECT (dialog));
gtk_object_unref (GTK_OBJECT (gui));
}
static void
dialog_sampling_tool (Workbook *wb, Sheet *sheet)
{
......@@ -1250,64 +1380,67 @@ ttest_dialog_loop:
static void
dialog_ftest_tool (Workbook *wb, Sheet *sheet)
{
static GtkWidget *dialog, *box, *vbox;
static GtkWidget *range1_entry, *range2_entry, *output_range_entry;
static GtkWidget *alpha_entry;
static GSList *output_ops;
static int labels = 0;
data_analysis_output_t dao;
float_t alpha;
char *text;
int selection, output;
static Range range_input1, range_input2;
GladeXML *gui;
GtkWidget *range1_entry, *range2_entry;
GtkWidget *alpha_entry;
GtkWidget *dialog;
GtkWidget *checkbutton;
GtkWidget *output_range_entry;
if (!dialog) {
dialog = new_dialog(_("F-Test: Two-Sample for Variances"));
data_analysis_output_t dao;
box = gtk_vbox_new (FALSE, 0);
vbox = new_frame("Input:", box);
gboolean labels = FALSE;
float_t alpha;
char *text;
int selection, x1, x2, y1, y2;
Range range_input1, range_input2;
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
gui = glade_xml_new (GNUMERIC_GLADEDIR "/analysis-tools.glade", NULL);
range1_entry = hbox_pack_label_and_entry
(_("Variable 1 Range:"), "", 20, vbox);
if (!gui) {
printf ("Could not find analysis-tools.glade\n");
return;
}
range2_entry = hbox_pack_label_and_entry
(_("Variable 2 Range:"), "", 20, vbox);
dao.type = NewSheetOutput;
alpha_entry = hbox_pack_label_and_entry(_("Alpha:"), "0.95",
20, vbox);
dialog = glade_xml_get_widget (gui, "FTest");
range1_entry = glade_xml_get_widget (gui, "entry1");
range2_entry = glade_xml_get_widget (gui, "entry2");
alpha_entry = glade_xml_get_widget (gui, "entry3");
checkbutton = glade_xml_get_widget (gui, "checkbutton1");
output_range_entry = glade_xml_get_widget (gui, "entry4");
add_check_buttons(vbox, first_row_label_button);
if (!dialog || !range1_entry || !range2_entry ||
!output_range_entry || !checkbutton) {
printf ("Corrupt file analysis-tools.glade\n");
return;
}
if (set_output_option_signals (gui, &dao))
return;
box = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG
(dialog)->vbox), box);
gtk_entry_set_text (GTK_ENTRY (alpha_entry), "0.95");
output_range_entry = add_output_frame(box, &output_ops);
gtk_signal_connect (GTK_OBJECT (checkbutton), "toggled",
GTK_SIGNAL_FUNC (checkbutton_toggled), &labels);
gtk_widget_show_all (dialog);
} else
gtk_widget_show_all (dialog);
gtk_widget_grab_focus (range1_entry);
ftest_dialog_loop:
selection = gnumeric_dialog_run (wb, GNOME_DIALOG (dialog));
if (selection == -1)
if (selection == -1) {
gtk_object_unref (GTK_OBJECT (gui));
return;
}
if (selection != 0) {
gtk_object_destroy (GTK_OBJECT (dialog));
gnome_dialog_close (GNOME_DIALOG (dialog));
return;
}
output = gtk_radio_group_get_selected (output_ops);
text = gtk_entry_get_text (GTK_ENTRY (range1_entry));
if (!parse_range (text, &range_input1.start.col,
&range_input1.start.row,
......@@ -1333,17 +1466,31 @@ ftest_dialog_loop:
text = gtk_entry_get_text (GTK_ENTRY (alpha_entry));
alpha = atof(text);
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ftest_dialog_loop;
if (dao.type == RangeOutput) {
text = gtk_entry_get_text (GTK_ENTRY (output_range_entry));
if (!parse_range (text, &x1, &y1, &x2, &y2)) {
error_in_entry(wb, output_range_entry,
_("You should introduce a valid cell "
"range in 'Output Range:'"));
goto ftest_dialog_loop;
} else {
dao.start_col = x1;
dao.start_row = y1;
dao.cols = x2-x1+1;
dao.rows = y2-y1+1;
dao.sheet = sheet;
}
}
labels = label_row_flag;
dao.labels_flag = labels;
if (ftest_tool (wb, sheet, &range_input1, &range_input2, alpha, &dao))
goto ftest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
gtk_object_destroy (GTK_OBJECT (dialog));
gtk_object_unref (GTK_OBJECT (gui));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment