Beispiel #1
0
void destroy_screen_context(struct ScreenContext *screenContext)
{
  	region_free_func(screenContext->region);
  	region_free_func(screenContext->vRegion);
	duallist_destroy(&screenContext->roads, NULL);
	duallist_destroy(&screenContext->crosses, NULL);
	duallist_destroy(&screenContext->links, NULL);
	duallist_destroy(&screenContext->rsus, NULL);
	duallist_destroy(&screenContext->districts, NULL);
	duallist_destroy(&screenContext->rivers, NULL);
	duallist_destroy(&screenContext->surroundings, NULL);
	hashtable_destroy(&screenContext->routeTable, (void(*)(void*))route_free_func);
	duallist_destroy(&screenContext->selectedRoutes, NULL);
	hashtable_destroy(&screenContext->nodeTable, (void(*)(void*))node_free_func);
	hashtable_destroy(&screenContext->traceTable, (void(*)(void*))trace_free_func);
	duallist_destroy(&screenContext->selectedTraces, NULL);
	if(screenContext->contactTableMode == PAIRWISE_TABLE)
		hashtable_destroy(&screenContext->contactTable, (void(*)(void*))pair_free_func);
	else
		hashtable_destroy(&screenContext->contactTable, (void(*)(void*))ego_free_func);
	duallist_destroy(&screenContext->selected, NULL);
	hashtable_destroy(&screenContext->cellTable, NULL);
	free_colormap(screenContext->colormap);

  	gdk_gc_unref(screenContext->gc);
	if(screenContext->canvas) {
		g_object_unref(screenContext->canvas);
		cairo_destroy(screenContext->cr_on_canvas);
		cairo_destroy(screenContext->cr_on_screen);
	}
  	if(screenContext->timeout != 0) 
		gtk_timeout_remove(screenContext->timeout);  
	free(screenContext);
}
Error3DViewerWidget::~Error3DViewerWidget()
{
  // NOTE: Don't delete display lists and/or texture bindings here, it
  // sometimes leads to coredumps on some combinations of QT and libGL. In any
  // case those resources will be freed when the GL context is finally
  // destroyed (normally just before this method returns). In addition, it is
  // much faster to let the GL context do it (especially with a large number
  // of textures, as is often the case in sample error texture mode).
  free_colormap(colormap);
  free(etex_id);
  free(etex_sz);
}
Beispiel #3
0
/* calling the QPainter stuff. */
void ColorMapWidget::paintEvent(QPaintEvent *) {
    QFont f(QApplication::font());
    double res;
    QPainter p;
    QString tmpDisplayedText;
    int i,h,yoff,ysub,cidx;
    int lscale;
    double scale;

    lscale = (int) floor(log10(dmax));
    scale = pow(10,lscale);
    f.setPixelSize(11);
    p.begin(this);
    p.setFont(f);
    QFontMetrics fm(p.fontMetrics());
    yoff = fm.lineSpacing();
    ysub = fm.ascent()/2;
    tmpDisplayedText.sprintf("x 1 e %i",lscale);
    p.setPen(Qt::white);
    p.drawText(10,yoff,tmpDisplayedText);
    h = height()-3*yoff;
    h = h/CBAR_STEP*CBAR_STEP;
    yoff *= 2;
    if (cmap_len != h) {
        free_colormap(colormap);
        cmap_len = h;
        if (colorState == HSV)
            colormap = colormap_hsv(cmap_len);
        else if (colorState == GRAYSCALE)
            colormap = colormap_gs(cmap_len);
        else
            fprintf(stderr, "Invalid color space specified\n");

        doHistogram(scaleState);
    }
    p.drawText(40, yoff+ysub, tmpDisplayedText.sprintf( "%.3f",dmax/scale));
    for(i=0; i<N_LABELS-1; i++) {
        res = dmax - (i+1)*(dmax - dmin)/(double)(N_LABELS-1);
        p.drawText(40, yoff+ysub+(int)((i+1)*(h/(double)(N_LABELS-1))),
                   tmpDisplayedText.sprintf( "%.3f",res/scale));
    }
    for(i=0; i<cmap_len; i++) {
        cidx = cmap_len-1-i;
        p.setPen(QColor((int)(255*colormap[cidx][0]), (int)(255*colormap[cidx][1]),
                        (int)(255*colormap[cidx][2])));
        p.drawLine(10, yoff+i, 10+histogram[cidx/CBAR_STEP], yoff+i);
    }
    p.end();
}
Beispiel #4
0
void ColorMapWidget::setColorMap(int newSpace) {

    if (colorState != newSpace) {
        colorState = (colorSpace)newSpace;
        free_colormap(colormap);

        if (colorState == HSV)
            colormap = colormap_hsv(cmap_len);
        else if (colorState == GRAYSCALE)
            colormap = colormap_gs(cmap_len);
        else
            fprintf(stderr, "Invalid color space specified\n");
        doHistogram(scaleState);
    }
}
Beispiel #5
0
static inline void
release_colormap (TFB_ColorMap *map)
{
	if (!map)
		return;

	if (map->refcount <= 0)
	{
		log_add (log_Warning, "BUG: release_colormap(): refcount not >0");
		return;
	}

	map->refcount--;
	if (map->refcount == 0)
		free_colormap (map);
}
Beispiel #6
0
static unsigned long
critical_draw (Display *dpy, Window window, void *closure)
{
  struct state *st = (struct state *) closure;

  if (st->eraser) {
    st->eraser = erase_window (st->dpy, st->window, st->eraser);
    return st->delay_usecs;
  }

  /* for (d_i_batch = batchcount; d_i_batch; d_i_batch--) */
    {
      /* Set color */
      if ((st->d_i_batch % st->lines_per_color) == 0)
        {
          st->d_i_color = (st->d_i_color + 1) % st->d_n_colors;
          st->gcv.foreground = st->d_colors[st->d_i_color].pixel;
          XChangeGC (st->dpy, st->fgc, GCForeground, &st->gcv);
        }
	
      assert(st->d_pos >= 0 && st->d_pos < st->settings.trail);
      model_step (st->model, &st->history[st->d_pos]);

      draw_step (st, st->fgc, st->d_pos);

      /* we use the history as a ring buffer, but don't start erasing until
         we've d_wrapped around once. */
      if (++st->d_pos >= st->settings.trail)
        {
          st->d_pos -= st->settings.trail;
          st->d_wrapped = 1;
        }

      if (st->d_wrapped)
        {
          draw_step (st, st->bgc, st->d_pos+1);
        }

    }
    
  st->d_i_batch--;
  if (st->d_i_batch < 0)
    st->d_i_batch = st->batchcount;
  else
    return st->delay_usecs;

  st->i_restart = (st->i_restart + 1) % st->n_restart;

  if (st->i_restart == 0)
    {
      /* Time to start a new simulation, this one has probably got
         to be a bit boring. */
      free_colormap (st, &st->d_colors, st->d_n_colors);
      setup_colormap (st, &st->d_colors, &st->d_n_colors);
      st->eraser = erase_window (st->dpy, st->window, st->eraser);
      model_initialize (st->model);
      model_step (st->model, &st->history[0]);
      st->d_pos = 1;
      st->d_wrapped = 0;
      st->d_i_batch = st->batchcount;
    }

  return st->delay_usecs;
}
Beispiel #7
0
ColorMapWidget::~ColorMapWidget() {
    delete [] histogram;
    free_colormap(colormap);
}