problems when drawing a large canvas item



My application (Red Hat 9, GTK 2, GnomeCanvas 2.0) draws rectangles
representing features on DNA sequences, maybe even whole chromosomes, so
there are enormous numbers of them.  For various reasons I wanted a box
running the complete length of the sequence, but found that it wasn't
always being drawn correctly.

Specifically, when the box exceeds about 33000 units (world units, I
think) in length, its display becomes erratic - in the cut-down example
I attach you see the top horizontal line, but the verticals don't reach
it, you have to scroll down to find them.  At the bottom it's mostly
drawn OK, but if you drag the scroll bar up and down a few times it's
usually possible to get a similar effect to the top - the verticals
don't meet the horizontal.

I first noticed this when, in my original application, I zoomed in quite
a few times, doubling pixels_per_unit each time - after a while long
rectangles had gaps in them and were often clipped at the bottom.  This
is why I think we're dealing in world units here - I assume canvas units
would grow and shrink with zooming.

Increasing the canvas scrollable region doesn't seem to help at all and
I'm not sure how to proceed.  Is this a canvas bug?  Is there a limit to
the size of a canvas item?  I've searched the archives but found nothing
at all.  Am I looking in the right place?

Hope someone can help.
Rob
--------------------- example code ------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <libgnomecanvas/libgnomecanvas.h>

#define HEIGHT 32864.0



static void Quit(GtkWidget *widget, gpointer data)
{
  gtk_main_quit();
  return;
}




static void createMainWindow()
{
  GtkWidget   *window;
  GtkWidget   *vbox;
  GtkWidget   *swindow;
  GnomeCanvas *canvas;
  GtkWidget   *w;
  GdkColor     white;
  GdkColor     red;
  GnomeCanvasItem *group;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Paned Windows");
  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (Quit), window);

  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
  gtk_window_set_default_size (GTK_WINDOW(window), 750, 500);

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window), vbox);

  swindow = gtk_scrolled_window_new (NULL, NULL);

  w = gnome_canvas_new();

  canvas = GNOME_CANVAS(w);
  gnome_canvas_set_scroll_region(canvas, 0.0, 0.0, 1000, HEIGHT);

  gdk_color_parse("white", &white);
  gdk_color_parse("red"  , &red);

  gtk_widget_modify_bg(GTK_WIDGET(canvas), GTK_STATE_NORMAL, &white);

  gtk_container_add(GTK_CONTAINER(swindow),w);

  gtk_box_pack_start(GTK_BOX(vbox), swindow, TRUE, TRUE, 0);

  group = gnome_canvas_item_new(gnome_canvas_root(canvas),
                                         gnome_canvas_group_get_type(),
                                         "x", (double)0.0,
                                         "y", (double)0.0 ,
                                         NULL);

  gnome_canvas_item_new(GNOME_CANVAS_GROUP(group),
                      gnome_canvas_rect_get_type(),
                      "x1"           , 0.0 ,
                      "y1"           , 0.0 ,
                      "x2"           , 200.0,
                      "y2"           , HEIGHT - 1.0,
                      "outline_color_gdk", &red  ,
                      "fill_color_gdk"   , &white,
                      "width_pixels"  , 1,

                      NULL);
  gtk_widget_show_all (window);

  return;
}



int main( int   argc, char *argv[] )
{
  gtk_init (&argc, &argv);

  createMainWindow();

  gtk_main ();

  return 0;
}
--------------------- makefile ----------------------------------------
CFLAGS = -g -Wall `pkg-config --cflags libgnomecanvas-2.0`
LDFLAGS = `pkg-config --libs libgnomecanvas-2.0`

zoom : zoom.c
        cc -g -o zoom $(CFLAGS) $(LDFLAGS) zoom.c

--------------------- end ---------------------------------------------
--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 The only intuitive user-interface is the nipple; all others are learned.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Rob Clack                        Acedb Development,  Informatics Group
 email: rnc sanger ac uk                Wellcome Trust Sanger Institute
 Tel: +44 1223 494883                   Wellcome Trust Genome Campus
 Fax: +44 1223 494919                   Hinxton  Cambridge    CB10 1SA


--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 The only intuitive user-interface is the nipple; all others are learned.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Rob Clack                        Acedb Development,  Informatics Group
 email: rnc sanger ac uk                Wellcome Trust Sanger Institute
 Tel: +44 1223 494883                   Wellcome Trust Genome Campus
 Fax: +44 1223 494919                   Hinxton  Cambridge    CB10 1SA



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]