static void gv_shapes_finalize(GObject *gobject) { GvShapes *shapes = GV_SHAPES(gobject); int i; if (shapes->shapes != NULL) { for( i = 0; i < gv_shapes_num_shapes(shapes); i++ ) { if( gv_shapes_get_shape(shapes, i) != NULL ) gv_shape_unref( gv_shapes_get_shape(shapes, i) ); } g_ptr_array_free(shapes->shapes,TRUE); shapes->shapes = NULL; } #ifdef HAVE_OGR if (shapes->hOGRds != NULL) OGR_DS_Destroy( shapes->hOGRds ); #endif /* Call parent class finalize */ G_OBJECT_CLASS(parent_class)->finalize(gobject); }
static void gv_shapes_set_memento(GvData *gv_data, GvDataMemento *data_memento) { GvShapes *shapes = GV_SHAPES(gv_data); GvShapesMemento *memento = (GvShapesMemento *) data_memento; switch (memento->base.type) { case GV_CHANGE_ADD: gv_shapes_delete_shapes(shapes, memento->ids->len, (gint*)memento->ids->data); break; case GV_CHANGE_REPLACE: gv_shapes_replace_shapes(shapes, memento->ids->len, (gint*)memento->ids->data, (GvShape **)memento->shapes->pdata, TRUE); break; case GV_CHANGE_DELETE: gv_shapes_insert_shapes(shapes, memento->ids->len, (gint*)memento->ids->data, (GvShape **)memento->shapes->pdata); break; } gv_shapes_del_memento((GvData *) shapes, (GvDataMemento *) memento); }
static void gv_shapes_changed(GvData *gv_data, gpointer data) { GvShapes *shapes = GV_SHAPES(gv_data); shapes->extents_valid = FALSE; }
static void gv_shapes_get_memento(GvData *gv_data, gpointer data, GvDataMemento **memento) { GvShapes *shapes = GV_SHAPES(gv_data); GvShapesMemento *mem; GvShapeChangeInfo *info = (GvShapeChangeInfo *) data; int i; mem = g_new(GvShapesMemento, 1); mem->base.data = GV_DATA(shapes); mem->base.type = info->change_type; mem->ids = g_array_new(FALSE, FALSE, sizeof(gint)); g_array_append_vals(mem->ids, info->shape_id, info->num_shapes); /* Grab in ascending order */ if (info->num_shapes > 1) { g_sort_type(mem->ids->data, gint, mem->ids->len); } if (info->change_type == GV_CHANGE_ADD) { mem->shapes = NULL; } else { mem->shapes = g_ptr_array_new(); for (i=0; i < info->num_shapes; ++i) { GvShape *shape = gv_shapes_get_shape(shapes,info->shape_id[i]); shape = gv_shape_copy( shape ); gv_shape_ref( shape ); g_ptr_array_add(mem->shapes, shape ); } } *memento = (GvDataMemento*)mem; }
//static int _gv_loadLayer_cb(const char *filename, GvData *data) static int _gv_loadLayer_cb(const char *filename, void *data) // callback to load this data into GV layer // we need this all the way up here because of GvViewArea { //GvShapesLayer *gvlayer = (GvShapesLayer *)data; GvShapes *shapes_data = GV_SHAPES(data); GvViewArea *view = GV_VIEW_AREA(VecView); GObject *layer = NULL; //gv_data_set_property(GV_DATA(shape_data), "_filename", _filename); gv_data_set_property(GV_DATA(shapes_data), "_ogr_driver_name", DRVNAME); gv_undo_register_data(GV_DATA(shapes_data)); layer = gv_shapes_layer_new(shapes_data); gv_view_area_add_layer (view, layer); gv_view_area_set_active_layer(view, layer); return 1; }