From: John Darrington Date: Sun, 25 Sep 2011 11:22:56 +0000 (+0200) Subject: Added dialog box for univariate anova. X-Git-Tag: v0.7.9~139 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cc0ad44c71734d01e88e95b402ab663ee406191;p=pspp-builds.git Added dialog box for univariate anova. Added a dialog box to conduct a univariate anova using the GLM command. Currently only entry of the dependent variable and the factors are possible. Choosing the interactions must be done through syntax, if the default is not what the user wants. --- diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 0ff301b8..116e2be3 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -35,6 +35,7 @@ UI_FILES = \ src/ui/gui/select-cases.ui \ src/ui/gui/t-test.ui \ src/ui/gui/text-data-import.ui \ + src/ui/gui/univariate.ui \ src/ui/gui/var-sheet-dialogs.ui \ src/ui/gui/variable-info.ui \ src/ui/gui/data-editor.ui \ @@ -270,6 +271,8 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/t-test-paired-samples.h \ src/ui/gui/npar-two-sample-related.c \ src/ui/gui/npar-two-sample-related.h \ + src/ui/gui/univariate-dialog.c \ + src/ui/gui/univariate-dialog.h \ src/ui/gui/val-labs-dialog.c \ src/ui/gui/val-labs-dialog.h \ src/ui/gui/var-display.c \ diff --git a/src/ui/gui/data-editor.ui b/src/ui/gui/data-editor.ui index 985d6708..07919483 100644 --- a/src/ui/gui/data-editor.ui +++ b/src/ui/gui/data-editor.ui @@ -397,6 +397,12 @@ One Way _ANOVA... + + + univariate + _Univariate Analysis... + + correlation @@ -595,6 +601,7 @@ + diff --git a/src/ui/gui/dict-display.c b/src/ui/gui/dict-display.c index ada7fb40..77da88bd 100644 --- a/src/ui/gui/dict-display.c +++ b/src/ui/gui/dict-display.c @@ -23,7 +23,10 @@ #include "dict-display.h" #include "psppire-dict.h" +#include "psppire-dictview.h" +#include "psppire-var-ptr.h" #include "psppire-var-view.h" +#include "psppire-select-dest.h" #include #include "helper.h" #include @@ -152,3 +155,33 @@ is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter, return result; } +gboolean +is_currently_in_varview (GtkTreeModel *model, GtkTreeIter *iter, PsppireSelector *sel) +{ + gboolean ret = false; + + /* First, fetch the variable from the source */ + + PsppireDictView *dv = PSPPIRE_DICT_VIEW (sel->source); + + GtkTreePath *path = gtk_tree_model_get_path (model, iter); + + gint *idx = gtk_tree_path_get_indices (path); + + const struct variable *var = psppire_dict_get_variable (dv->dict, *idx); + + + /* Now test if that variable exists in the destination */ + + GValue value = {0}; + + g_value_init (&value, PSPPIRE_VAR_PTR_TYPE); + g_value_set_boxed (&value, var); + + ret = psppire_select_dest_widget_contains_var (PSPPIRE_SELECT_DEST_WIDGET (sel->dest), &value); + + g_value_unset (&value); + + return ret ; +} + diff --git a/src/ui/gui/dict-display.h b/src/ui/gui/dict-display.h index 5586cb10..b3b395bb 100644 --- a/src/ui/gui/dict-display.h +++ b/src/ui/gui/dict-display.h @@ -47,4 +47,9 @@ void insert_source_row_into_entry (GtkTreeIter source_iter, gboolean is_currently_in_entry (GtkTreeModel *model, GtkTreeIter *iter, PsppireSelector *selector); + +/* A FilterItemsFunc function for PsppireVarview widgets */ +gboolean is_currently_in_varview (GtkTreeModel *model, GtkTreeIter *iter, + PsppireSelector *sel); + #endif diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index 4a23cf1f..64e044b0 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -66,6 +66,7 @@ #include "ui/gui/t-test-paired-samples.h" #include "ui/gui/text-data-import-dialog.h" #include "ui/gui/transpose-dialog.h" +#include "ui/gui/univariate-dialog.h" #include "ui/gui/variable-info-dialog.h" #include "ui/gui/weight-cases-dialog.h" #include "ui/syntax-gen.h" @@ -1116,6 +1117,10 @@ psppire_data_window_finish_init (PsppireDataWindow *de, connect_action (de, "roc-curve", G_CALLBACK (roc_dialog)); + connect_action (de, "analyze_explore", G_CALLBACK (examine_dialog)); + + connect_action (de, "univariate", G_CALLBACK (univariate_dialog)); + connect_action (de, "correlation", G_CALLBACK (correlation_dialog)); connect_action (de, "factor-analysis", G_CALLBACK (factor_dialog)); diff --git a/src/ui/gui/univariate-dialog.c b/src/ui/gui/univariate-dialog.c new file mode 100644 index 00000000..2692e488 --- /dev/null +++ b/src/ui/gui/univariate-dialog.c @@ -0,0 +1,161 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2011 Free Software Foundation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include +#include +#include "psppire-dialog.h" +#include "dict-display.h" + +#include "psppire-var-view.h" +#include "psppire-selector.h" +#include "psppire-dictview.h" +#include + +#include "executor.h" + +#include "univariate-dialog.h" + +struct uni_dialog +{ + struct dictionary *dict; + + /* Entry box for the dependent variable */ + GtkWidget *dep_entry; + + GtkWidget *factor_list; +}; + + +/* Dialog is valid iff at least one variable has been selected in both + the dependent variable box and the factor list. */ +static gboolean +dialog_state_valid (gpointer data) +{ + struct uni_dialog *uv_d = data; + GtkTreeModel *vars; + GtkTreeIter notused; + + if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (uv_d->dep_entry)))) + return false; + + vars = + gtk_tree_view_get_model (GTK_TREE_VIEW (uv_d->factor_list)); + + return gtk_tree_model_get_iter_first (vars, ¬used); +} + +/* Reset the dialog to its default state */ +static void +refresh (PsppireDialog *dialog, struct uni_dialog *uv_d) +{ + GtkTreeModel *liststore ; + + gtk_entry_set_text (GTK_ENTRY (uv_d->dep_entry), ""); + + liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (uv_d->factor_list)); + + gtk_list_store_clear (GTK_LIST_STORE (liststore)); +} + + +static char * +generate_syntax (const struct uni_dialog *uvd) +{ + gchar *text = NULL; + GString *str = g_string_new ("GLM "); + + + g_string_append (str, gtk_entry_get_text (GTK_ENTRY (uvd->dep_entry))); + + + g_string_append (str, " BY "); + + psppire_var_view_append_names (PSPPIRE_VAR_VIEW (uvd->factor_list), 0, str); + + + g_string_append (str, "."); + + text = str->str; + + g_string_free (str, FALSE); + + return text; +} + +void +univariate_dialog (PsppireDataWindow * de) +{ + struct uni_dialog uv_d; + + gint response; + + GtkBuilder *xml = builder_new ("univariate.ui"); + + GtkWidget *dialog = get_widget_assert (xml, "univariate-dialog"); + GtkWidget *source = get_widget_assert (xml, "dict-view"); + + GtkWidget *dep_selector = get_widget_assert (xml, "dep-selector"); + GtkWidget *factor_selector = get_widget_assert (xml, "factor-selector"); + + + PsppireVarStore *vs = NULL; + + uv_d.dep_entry = get_widget_assert (xml, "dep-entry"); + uv_d.factor_list = get_widget_assert (xml, "factors-view"); + + g_object_get (de->data_editor, "var-store", &vs, NULL); + + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); + g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &uv_d); + + psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog), + dialog_state_valid, &uv_d); + + + g_object_get (vs, "dictionary", &uv_d.dict, NULL); + g_object_set (source, "model", uv_d.dict, NULL); + + psppire_selector_set_allow (PSPPIRE_SELECTOR (dep_selector), + numeric_only); + + psppire_selector_set_filter_func (PSPPIRE_SELECTOR (dep_selector), + is_currently_in_entry); + + + psppire_selector_set_filter_func (PSPPIRE_SELECTOR (factor_selector), + is_currently_in_varview); + + response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); + + + switch (response) + { + case GTK_RESPONSE_OK: + g_free (execute_syntax_string (de, generate_syntax (&uv_d))); + break; + case PSPPIRE_RESPONSE_PASTE: + g_free (paste_syntax_to_window (generate_syntax (&uv_d))); + break; + default: + break; + } + + g_object_unref (xml); +} + + diff --git a/src/ui/gui/univariate-dialog.h b/src/ui/gui/univariate-dialog.h new file mode 100644 index 00000000..5fef0ba7 --- /dev/null +++ b/src/ui/gui/univariate-dialog.h @@ -0,0 +1,24 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2011 Free Software Foundation + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef __UNIVARIATE_DIALOG_H +#define __UNIVARIATE_DIALOG_H + +#include "psppire-data-window.h" + +void univariate_dialog (PsppireDataWindow * data); + +#endif diff --git a/src/ui/gui/univariate.ui b/src/ui/gui/univariate.ui new file mode 100644 index 00000000..a4c8fa82 --- /dev/null +++ b/src/ui/gui/univariate.ui @@ -0,0 +1,342 @@ + + + + + + + Univariate + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + 5 + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 3 + 3 + + + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + 5 + dict-view + dep-entry + + + 1 + 2 + + + + + + + True + True + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + 5 + dict-view + factors-view + + + 1 + 2 + 1 + 2 + + + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + never + automatic + etched-in + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + False + + + + + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + none + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + True + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Dependent Variable + True + True + dep-entry + + + + + 2 + 3 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + none + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + never + automatic + etched-in + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + False + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Fixed Factors + True + True + factors-view + + + + + 2 + 3 + 1 + 2 + + + + + + + + + + + + + + + + 0 + + + + + True + 5 + vertical + + + False + False + end + 1 + + + + + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Univariate: Save + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical + True + + + _Predicted values + True + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + + + 0 + + + + + _Residuals + True + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + + + 1 + + + + + 0 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + PSPPIRE_BUTTON_CONTINUE_MASK | PSPPIRE_BUTTON_CANCEL_MASK | PSPPIRE_BUTTON_HELP_MASK + + + False + False + end + 1 + + + + + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Univariate: Statistics + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + none + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + never + automatic + etched-in + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + S_tatistics + True + True + stat-view + + + + + 0 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + vertical + PSPPIRE_BUTTON_CONTINUE_MASK | PSPPIRE_BUTTON_CANCEL_MASK | PSPPIRE_BUTTON_HELP_MASK + + + False + False + end + 1 + + + + + +