From: John Darrington Date: Sun, 7 Dec 2008 05:50:14 +0000 (+0900) Subject: Written a proper implementation of psppire_axis_impl_delete X-Git-Tag: v0.7.1~59 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be5dc743c6dca9293d3559b27e74c83bec57eaa7;p=pspp-builds.git Written a proper implementation of psppire_axis_impl_delete --- diff --git a/lib/gtksheet/psppire-axis-impl.c b/lib/gtksheet/psppire-axis-impl.c index b722a87b..699e6aab 100644 --- a/lib/gtksheet/psppire-axis-impl.c +++ b/lib/gtksheet/psppire-axis-impl.c @@ -40,6 +40,24 @@ struct axis_node struct tower_node unit_node; }; +void +psppire_axis_impl_dump (const PsppireAxisImpl *a) +{ + struct tower_node *n = tower_first (&a->unit_tower); + + g_debug ("Axis %p", a); + while (n) + { + const struct axis_node *an = tower_data (n, struct axis_node, unit_node); + const struct tower_node *pn = &an->pixel_node; + g_debug ("%ld units of height %g", + n->size, pn->size / (float) n->size); + + n = tower_next (&a->unit_tower, n); + } + g_debug ("\n"); +} + static gint unit_at_pixel (const PsppireAxis *axis, glong pixel) { @@ -419,16 +437,33 @@ psppire_axis_impl_clear (PsppireAxisImpl *a) void psppire_axis_impl_delete (PsppireAxisImpl *a, gint first, gint n_units) { - gint i; - g_warning ("%s FIXME: This is an inefficient implementation", __FUNCTION__); - + gint units_to_delete = n_units; + unsigned long int start; g_return_if_fail (first + n_units < tower_height (&a->unit_tower)); - for (i = first; i < first + n_units; ++i) + split (a, first); + split (a, first + n_units); + + struct tower_node *unit_node = tower_lookup (&a->unit_tower, first, &start); + g_assert (start == first); + + while (units_to_delete > 0) { - struct axis_node *an = make_single (a, first); + struct tower_node *next_unit_node; + struct axis_node *an = tower_data (unit_node, + struct axis_node, unit_node); + + g_assert (unit_node == &an->unit_node); + g_assert (unit_node->size <= n_units); - tower_delete (&a->unit_tower, &an->unit_node); + units_to_delete -= unit_node->size; + + next_unit_node = tower_next (&a->unit_tower, unit_node); + + tower_delete (&a->unit_tower, unit_node); tower_delete (&a->pixel_tower, &an->pixel_node); + + + unit_node = next_unit_node; } } diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index dcc2cdf8..cab0f755 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -361,13 +361,13 @@ delete_variable_callback (PsppireDict *dict, gint posn, psppire_axis_impl_delete (var_vaxis, posn, 1); - for (i = 0 ; i < 4 ; ++i) - { - PsppireAxisImpl *haxis; - g_object_get (de->data_sheet[i], "horizontal-axis", &haxis, NULL); - psppire_axis_impl_delete (haxis, posn, 1); - } + { + PsppireAxisImpl *haxis; + g_object_get (de->data_sheet[0], "horizontal-axis", &haxis, NULL); + + psppire_axis_impl_delete (haxis, posn, 1); + } }