Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / output / charts / roc-chart.c
index 2094ede545c79edb0c264a2c63c0630cfef1339f..0285d6f6a107e8a599e9be7e93e3adf580389548 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011 Free Software Foundation, Inc.
 
    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
 
 #include <config.h>
 
-#include <output/charts/roc-chart.h>
+#include "output/charts/roc-chart.h"
 
-#include <output/chart-provider.h>
-#include <output/charts/cartesian.h>
-#include <output/charts/plot-chart.h>
-#include <data/casereader.h>
-#include <language/stats/roc.h>
+#include "data/casereader.h"
+#include "language/stats/roc.h"
+#include "output/chart-item-provider.h"
 
-#include "xalloc.h"
+#include "gl/xalloc.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
-struct roc_var
-  {
-    char *name;
-    struct casereader *cutpoint_reader;
-  };
-
-struct roc_chart
-  {
-    struct chart chart;
-    bool reference;
-    struct roc_var *vars;
-    size_t n_vars;
-    size_t allocated_vars;
-  };
-
-static const struct chart_class roc_chart_class;
-
 struct roc_chart *
 roc_chart_create (bool reference)
 {
   struct roc_chart *rc = xmalloc (sizeof *rc);
-  chart_init (&rc->chart, &roc_chart_class);
+  chart_item_init (&rc->chart_item, &roc_chart_class, NULL);
   rc->reference = reference;
   rc->vars = NULL;
   rc->n_vars = 0;
@@ -72,61 +53,10 @@ roc_chart_add_var (struct roc_chart *rc, const char *var_name,
   rv->cutpoint_reader = casereader_clone (cutpoint_reader);
 }
 
-struct chart *
-roc_chart_get_chart (struct roc_chart *rc)
-{
-  return &rc->chart;
-}
-
 static void
-roc_chart_draw (const struct chart *chart, cairo_t *cr,
-                struct chart_geometry *geom)
+roc_chart_destroy (struct chart_item *chart_item)
 {
-  const struct roc_chart *rc = UP_CAST (chart, struct roc_chart, chart);
-  size_t i;
-
-  chart_write_title (cr, geom, _("ROC Curve"));
-  chart_write_xlabel (cr, geom, _("1 - Specificity"));
-  chart_write_ylabel (cr, geom, _("Sensitivity"));
-
-  chart_write_xscale (cr, geom, 0, 1, 5);
-  chart_write_yscale (cr, geom, 0, 1, 5);
-
-  if ( rc->reference )
-    {
-      chart_line (cr, geom, 1.0, 0,
-                 0.0, 1.0,
-                 CHART_DIM_X);
-    }
-
-  for (i = 0; i < rc->n_vars; ++i)
-    {
-      const struct roc_var *rv = &rc->vars[i];
-      struct casereader *r = casereader_clone (rv->cutpoint_reader);
-      struct ccase *cc;
-
-      chart_vector_start (cr, geom, rv->name);
-      for (; (cc = casereader_read (r)) != NULL; case_unref (cc))
-       {
-         double se = case_data_idx (cc, ROC_TP)->f;
-         double sp = case_data_idx (cc, ROC_TN)->f;
-
-         se /= case_data_idx (cc, ROC_FN)->f + case_data_idx (cc, ROC_TP)->f ;
-         sp /= case_data_idx (cc, ROC_TN)->f + case_data_idx (cc, ROC_FP)->f ;
-
-         chart_vector (cr, geom, 1 - sp, se);
-       }
-      chart_vector_end (cr, geom);
-      casereader_destroy (r);
-    }
-
-  chart_write_legend (cr, geom);
-}
-
-static void
-roc_chart_destroy (struct chart *chart)
-{
-  struct roc_chart *rc = UP_CAST (chart, struct roc_chart, chart);
+  struct roc_chart *rc = UP_CAST (chart_item, struct roc_chart, chart_item);
   size_t i;
 
   for (i = 0; i < rc->n_vars; i++)
@@ -139,10 +69,7 @@ roc_chart_destroy (struct chart *chart)
   free (rc);
 }
 
-static const struct chart_class roc_chart_class =
+const struct chart_item_class roc_chart_class =
   {
-    roc_chart_draw,
     roc_chart_destroy
   };
-
-