struct tower_node *n;
struct axis_node *an;
gdouble fraction;
- gint unit;
- glong size;
- g_return_val_if_fail (pixel >= 0, -1);
-
- g_mutex_lock (a->mutex);
+ glong size = tower_height (&a->pixel_tower);
- size = tower_height (&a->pixel_tower);
+ g_return_val_if_fail (pixel >= 0, -1);
if (pixel >= size)
{
gint n_items = tower_height (&a->unit_tower);
glong extra = pixel - size;
- unit = n_items - 1 + DIV_RND_UP (extra, a->default_size);
- goto finish;
+ return n_items - 1 + DIV_RND_UP (extra, a->default_size);
}
fraction = (pixel - start) / (gdouble) tower_node_get_size (&an->pixel_node);
- unit = tower_node_get_level (&an->unit_node)
+ return tower_node_get_level (&an->unit_node)
+ fraction * tower_node_get_size (&an->unit_node);
-
- finish:
-
- g_mutex_unlock (a->mutex);
-
- return unit;
}
{
glong filler = 0;
glong actual_size;
- gint n_units;
-
- g_mutex_lock (a->mutex);
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);
- n_units = tower_height (&a->unit_tower) + filler;
-
- g_mutex_unlock (a->mutex);
-
- return n_units;
+ return tower_height (&a->unit_tower) + filler;
}
gdouble fraction;
struct tower_node *n ;
struct axis_node *an;
- glong pixel ;
unsigned long int start;
gint the_count, size ;
- g_mutex_lock (a->mutex);
-
the_count = tower_height (&a->unit_tower);
size = tower_height (&a->pixel_tower);
if ( unit >= the_count)
{
- pixel = size + (unit - the_count) * a->default_size;
- goto finish;
+ return size + (unit - the_count) * a->default_size;
}
if ( unit < 0)
- goto error;
+ return -1;
if ( unit >= tower_height (&a->unit_tower))
- goto error;
+ return -1;
n = tower_lookup (&a->unit_tower, unit, &start);
fraction = (unit - start) / (gdouble) tower_node_get_size (&an->unit_node);
- pixel = tower_node_get_level (&an->pixel_node) +
+ return tower_node_get_level (&an->pixel_node) +
nearbyint (fraction * tower_node_get_size (&an->pixel_node));
-
- finish:
- g_mutex_unlock (a->mutex);
- return pixel;
-
- error:
- g_mutex_unlock (a->mutex);
- return -1;
}
gint
{
struct tower_node *n ;
struct axis_node *an;
- gint size;
unsigned long int start;
- g_mutex_lock (axis->mutex);
-
if (unit >= tower_height (&axis->unit_tower))
- {
- size = axis->default_size;
- goto finish;
- }
+ return axis->default_size;
if ( unit < 0)
- {
- size = 0;
- goto finish;
- }
+ return 0;
if ( unit >= tower_height (&axis->unit_tower))
- {
- size = 0;
- goto finish;
- }
+ return 0;
n = tower_lookup (&axis->unit_tower, unit, &start);
an = tower_data (n, struct axis_node, unit_node);
- size = nearbyint (tower_node_get_size (&an->pixel_node)
- / (gdouble) tower_node_get_size (&an->unit_node));
- finish:
- g_mutex_unlock (axis->mutex);
- return size;
+ return nearbyint (tower_node_get_size (&an->pixel_node)
+ / (gdouble) tower_node_get_size (&an->unit_node));
}
static void
psppire_axis_init (PsppireAxis *axis)
{
- axis->mutex = g_mutex_new ();
tower_init (&axis->pixel_tower);
tower_init (&axis->unit_tower);
{
PsppireAxis *a = PSPPIRE_AXIS (object);
pool_destroy (a->pool);
- g_mutex_free (a->mutex);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
{
struct axis_node *node;
- g_mutex_lock (a->mutex);
-
if (n_units == 0)
- goto finish;
+ return;
node = pool_malloc (a->pool, sizeof *node);
tower_insert (&a->unit_tower, n_units, &node->unit_node, NULL);
tower_insert (&a->pixel_tower, (size + a->padding) * n_units,
&node->pixel_node, NULL);
-
- finish:
- g_mutex_unlock (a->mutex);
- return;
}
g_return_if_fail ( posn >= 0);
g_return_if_fail ( posn <= tower_height (&a->unit_tower));
- g_mutex_lock (a->mutex);
-
if ( posn < tower_height (&a->unit_tower))
{
unsigned long int start = 0;
size + a->padding,
&new_node->pixel_node,
before ? &before->pixel_node : NULL);
-
- g_mutex_unlock (a->mutex);
}
g_return_if_fail (posn >= 0);
g_return_if_fail (size > 0);
- g_mutex_lock (axis->mutex);
-
/* Silently ignore this request if the position is greater than the number of
units in the axis */
if (posn >= tower_height (&axis->unit_tower))
- goto error;
+ return ;
an = make_single (axis, posn);
tower_resize (&axis->pixel_tower, &an->pixel_node, size + axis->padding);
- finish:
- g_mutex_unlock (axis->mutex);
g_signal_emit (axis, signals[RESIZE_UNIT], 0, posn, size + axis->padding);
- return;
-
- error:
- g_mutex_unlock (axis->mutex);
- return;
}
void
psppire_axis_clear (PsppireAxis *a)
{
- g_mutex_lock (a->mutex);
pool_destroy (a->pool);
a->pool = pool_create ();
tower_init (&a->pixel_tower);
tower_init (&a->unit_tower);
- g_mutex_unlock (a->mutex);
}
struct tower_node *unit_node ;
g_return_if_fail (first + n_units <= tower_height (&a->unit_tower));
- g_mutex_lock (a->mutex);
-
split (a, first);
split (a, first + n_units);
unit_node = next_unit_node;
}
- g_mutex_unlock (a->mutex);
}