case: Introduce new functions for numbers and substrings in cases.
[pspp] / src / output / charts / roc-chart-cairo.c
index b5c22aca5329a8e3a1af7c0449f2d8a323c1a92c..04e37405f1e36e30ae15023843526e25b16a798c 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 <data/case.h>
-#include <data/casereader.h>
-#include <language/stats/roc.h>
-#include <output/cairo-chart.h>
+#include "data/case.h"
+#include "data/casereader.h"
+#include "language/stats/roc.h"
+#include "output/cairo-chart.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
 void
-xrchart_draw_roc (const struct chart_item *chart_item, cairo_t *cr,
+xrchart_draw_roc (const struct chart *chart, cairo_t *cr,
                   struct xrchart_geometry *geom)
 {
-  const struct roc_chart *rc = to_roc_chart (chart_item);
+  const struct roc_chart *rc = to_roc_chart (chart);
   size_t i;
 
   xrchart_write_title (cr, geom, _("ROC Curve"));
   xrchart_write_xlabel (cr, geom, _("1 - Specificity"));
   xrchart_write_ylabel (cr, geom, _("Sensitivity"));
 
-  xrchart_write_xscale (cr, geom, 0, 1, 5);
-  xrchart_write_yscale (cr, geom, 0, 1, 5);
+  if (! xrchart_write_xscale (cr, geom, 0, 1))
+    return;
+  if (! xrchart_write_yscale (cr, geom, 0, 1))
+    return;
 
-  if ( rc->reference )
+  if (rc->reference)
     {
       xrchart_line (cr, geom, 1.0, 0,
                     0.0, 1.0,
@@ -56,11 +58,11 @@ xrchart_draw_roc (const struct chart_item *chart_item, cairo_t *cr,
       xrchart_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;
+         double se = case_num_idx (cc, ROC_TP);
+         double sp = case_num_idx (cc, ROC_TN);
 
-         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 ;
+         se /= case_num_idx (cc, ROC_FN) + case_num_idx (cc, ROC_TP);
+         sp /= case_num_idx (cc, ROC_TN) + case_num_idx (cc, ROC_FP);
 
          xrchart_vector (cr, geom, 1 - sp, se);
        }