VikDEMLayer *dem_layer_create ( VikViewport *vp )
{
  VikDEMLayer *vdl = dem_layer_new ( vp );
  gint i;
  if ( vp ) {
    /* TODO: share GCS between layers */
    for ( i = 0; i < DEM_N_HEIGHT_COLORS; i++ ) {
      if ( i > 0 )
        vdl->gcs[i] = vik_viewport_new_gc ( vp, dem_height_colors[i], UNUSED_LINE_THICKNESS );
    }
    for ( i = 0; i < DEM_N_GRADIENT_COLORS; i++ )
      vdl->gcsgradient[i] = vik_viewport_new_gc ( vp, dem_gradient_colors[i], UNUSED_LINE_THICKNESS );
  }
  return vdl;
}
static VikDEMLayer *dem_layer_unmarshall( guint8 *data, gint len, VikViewport *vvp )
{
  VikDEMLayer *rv = dem_layer_new ( vvp );
  gint i;

  /* TODO: share GCS between layers */
  for ( i = 0; i < DEM_N_HEIGHT_COLORS; i++ ) {
    if ( i == 0 )
      rv->gcs[i] = vik_viewport_new_gc_from_color ( vvp, &(rv->color), UNUSED_LINE_THICKNESS );
    else
      rv->gcs[i] = vik_viewport_new_gc ( vvp, dem_height_colors[i], UNUSED_LINE_THICKNESS );
  }
  for ( i = 0; i < DEM_N_GRADIENT_COLORS; i++ )
    rv->gcsgradient[i] = vik_viewport_new_gc ( vvp, dem_gradient_colors[i], UNUSED_LINE_THICKNESS );

  vik_layer_unmarshall_params ( VIK_LAYER(rv), data, len, vvp );
  return rv;
}
Пример #3
0
gboolean vik_viewport_configure ( VikViewport *vvp )
{
  g_return_val_if_fail ( vvp != NULL, TRUE );

  vvp->width = GTK_WIDGET(vvp)->allocation.width;
  vvp->height = GTK_WIDGET(vvp)->allocation.height;

  vvp->width_2 = vvp->width/2;
  vvp->height_2 = vvp->height/2;

  if ( vvp->scr_buffer )
    g_object_unref ( G_OBJECT ( vvp->scr_buffer ) );

  vvp->scr_buffer = gdk_pixmap_new ( gtk_widget_get_window(GTK_WIDGET(vvp)), vvp->width, vvp->height, -1 );

  /* TODO trigger: only if enabled! */
  if ( vvp->snapshot_buffer )
    g_object_unref ( G_OBJECT ( vvp->snapshot_buffer ) );

  vvp->snapshot_buffer = gdk_pixmap_new ( gtk_widget_get_window(GTK_WIDGET(vvp)), vvp->width, vvp->height, -1 );
  /* TODO trigger */

  /* this is down here so it can get a GC (necessary?) */
  if ( !vvp->background_gc )
  {
    vvp->background_gc = vik_viewport_new_gc ( vvp, DEFAULT_BACKGROUND_COLOR, 1 );
    vik_viewport_set_background_color ( vvp, DEFAULT_BACKGROUND_COLOR );
  }
  if ( ! vvp->highlight_gc )
  {
    vvp->highlight_gc = vik_viewport_new_gc ( vvp, DEFAULT_HIGHLIGHT_COLOR, 1 );
    vik_viewport_set_highlight_color ( vvp, DEFAULT_HIGHLIGHT_COLOR );
  }
  if ( !vvp->scale_bg_gc) {
    vvp->scale_bg_gc = vik_viewport_new_gc(vvp, "grey", 3);
  }

  return FALSE;	
}
static VikDEMLayer *dem_layer_new ( VikViewport *vvp )
{
  VikDEMLayer *vdl = VIK_DEM_LAYER ( g_object_new ( VIK_DEM_LAYER_TYPE, NULL ) );

  vik_layer_set_type ( VIK_LAYER(vdl), VIK_LAYER_DEM );

  vdl->files = NULL;

  vdl->gcs = g_malloc(sizeof(GdkGC *)*DEM_N_HEIGHT_COLORS);
  vdl->gcsgradient = g_malloc(sizeof(GdkGC *)*DEM_N_GRADIENT_COLORS);
  /* make new gcs only if we need it (copy layer -> use old) */

  // Ensure the base GC is available so the default colour can be applied
  if ( vvp ) vdl->gcs[0] = vik_viewport_new_gc ( vvp, "#0000FF", 1 );

  vik_layer_set_defaults ( VIK_LAYER(vdl), vvp );

  return vdl;
}
Пример #5
0
static void datasource_gc_add_setup_widgets ( GtkWidget *dialog, VikViewport *vvp, gpointer user_data )
{
  datasource_gc_widgets_t *widgets = (datasource_gc_widgets_t *)user_data;
  GtkWidget *num_label, *center_label, *miles_radius_label;
  struct LatLon ll;
  gchar *s_ll;

  num_label = gtk_label_new (_("Number geocaches:"));
  widgets->num_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new( 20, 1, 1000, 10, 20, 0 )), 10, 0 );
  center_label = gtk_label_new (_("Centered around:"));
  widgets->center_entry = gtk_entry_new();
  miles_radius_label = gtk_label_new ("Miles Radius:");
  widgets->miles_radius_spin = gtk_spin_button_new ( GTK_ADJUSTMENT(gtk_adjustment_new( 5, 1, 1000, 1, 20, 0 )), 25, 1 );

  vik_coord_to_latlon ( vik_viewport_get_center(vvp), &ll );
  s_ll = g_strdup_printf("%f,%f", ll.lat, ll.lon );
  gtk_entry_set_text ( GTK_ENTRY(widgets->center_entry), s_ll );
  g_free ( s_ll );


  widgets->vvp = vvp;
  widgets->circle_gc = vik_viewport_new_gc ( vvp, "#000000", 3 );
  gdk_gc_set_function ( widgets->circle_gc, GDK_INVERT );
  widgets->circle_onscreen = TRUE;
  datasource_gc_draw_circle ( widgets );

  g_signal_connect_swapped ( G_OBJECT(widgets->center_entry), "changed", G_CALLBACK(datasource_gc_draw_circle), widgets );
  g_signal_connect_swapped ( G_OBJECT(widgets->miles_radius_spin), "value-changed", G_CALLBACK(datasource_gc_draw_circle), widgets );

  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), num_label, FALSE, FALSE, 5 );
  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), widgets->num_spin, FALSE, FALSE, 5 );
  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), center_label, FALSE, FALSE, 5 );
  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), widgets->center_entry, FALSE, FALSE, 5 );
  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), miles_radius_label, FALSE, FALSE, 5 );
  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), widgets->miles_radius_spin, FALSE, FALSE, 5 );
  gtk_widget_show_all(dialog);
}