+ return n_items - 1 + DIV_RND_UP (extra, a->default_size);
+ }
+
+
+ n = tower_lookup (&a->pixel_tower, pixel, &start);
+ an = tower_data (n, struct axis_node, pixel_node);
+
+ fraction = (pixel - start) / (gdouble) tower_node_get_size (&an->pixel_node);
+
+ return tower_node_get_level (&an->unit_node)
+ + fraction * tower_node_get_size (&an->unit_node);
+}
+
+
+gint
+psppire_axis_unit_count (const PsppireAxis *a)
+{
+ glong filler = 0;
+ glong actual_size;
+
+ actual_size = tower_height (&a->pixel_tower);
+
+ if ( actual_size < a->min_extent )
+ filler = DIV_RND_UP (a->min_extent - actual_size, a->default_size);
+
+ return tower_height (&a->unit_tower) + filler;
+}
+
+
+/* Return the starting pixel of UNIT */
+glong
+psppire_axis_start_pixel (const PsppireAxis *a, gint unit)
+{
+ gdouble fraction;
+ struct tower_node *n ;
+ struct axis_node *an;
+
+ unsigned long int start;
+
+ gint the_count, size ;
+
+ the_count = tower_height (&a->unit_tower);
+ size = tower_height (&a->pixel_tower);
+
+ if ( unit >= the_count)
+ {
+ return size + (unit - the_count) * a->default_size;
+ }
+
+ if ( unit < 0)
+ return -1;
+
+ if ( unit >= tower_height (&a->unit_tower))
+ return -1;
+
+ n = tower_lookup (&a->unit_tower, unit, &start);
+
+ an = tower_data (n, struct axis_node, unit_node);
+
+ fraction = (unit - start) / (gdouble) tower_node_get_size (&an->unit_node);
+
+ return tower_node_get_level (&an->pixel_node) +
+ rint (fraction * tower_node_get_size (&an->pixel_node));
+}
+
+gint
+psppire_axis_unit_size (const PsppireAxis *axis, gint unit)
+{
+ struct tower_node *n ;
+ struct axis_node *an;
+
+ unsigned long int start;
+
+ if (unit >= tower_height (&axis->unit_tower))
+ return axis->default_size;
+
+ if ( unit < 0)
+ return 0;
+
+ if ( unit >= tower_height (&axis->unit_tower))
+ return 0;
+
+ n = tower_lookup (&axis->unit_tower, unit, &start);
+
+ an = tower_data (n, struct axis_node, unit_node);
+
+ return rint (tower_node_get_size (&an->pixel_node)
+ / (gdouble) tower_node_get_size (&an->unit_node));
+}
+
+
+
+/* --- functions --- */
+/**
+ * psppire_axis_get_type:
+ * @returns: the type ID for accelerator groups.
+ */
+GType
+psppire_axis_get_type (void)
+{
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info = {
+ sizeof (PsppireAxisClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) psppire_axis_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PsppireAxis),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) psppire_axis_init,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "PsppireAxis",
+ &object_info, 0);