31#include <glib/gi18n.h>
61G_DEFINE_TYPE_WITH_PRIVATE(GdsOutputRenderer, gds_output_renderer, G_TYPE_OBJECT)
74 g_warning(_(
"Output renderer does not define a render_output function!"));
80 GdsOutputRenderer *renderer = GDS_RENDER_OUTPUT_RENDERER(self_obj);
83 priv = gds_output_renderer_get_instance_private(renderer);
98 g_clear_object(&priv->
task);
111 G_OBJECT_CLASS(gds_output_renderer_parent_class)->dispose(self_obj);
116 GdsOutputRenderer *self = GDS_RENDER_OUTPUT_RENDERER(obj);
119 priv = gds_output_renderer_get_instance_private(self);
121 switch (property_id) {
129 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec);
136 GdsOutputRenderer *self = GDS_RENDER_OUTPUT_RENDERER(obj);
139 priv = gds_output_renderer_get_instance_private(self);
141 switch (property_id) {
146 priv->
output_file = g_strdup(g_value_get_string(value));
157 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, property_id, pspec);
166 GObjectClass *oclass = G_OBJECT_CLASS(klass);
167 GType progress_changed_param_types[1] = {G_TYPE_POINTER};
177 g_param_spec_string(N_(
"output-file"), N_(
"output file"), N_(
"Output file for renderer"),
178 NULL, G_PARAM_READWRITE);
180 g_param_spec_object(N_(
"layer-settings"), N_(
"Layer Settings object"),
181 N_(
"Object containing the layer rendering information"),
188 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
198 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
205 progress_changed_param_types);
212 priv = gds_output_renderer_get_instance_private(self);
232 N_(
"layer-settings"), layer_settings,
233 N_(
"output-file"), output_file,
239 g_return_if_fail(GDS_RENDER_IS_OUTPUT_RENDERER(renderer));
242 if (!file_name || !file_name[0])
244 g_object_set(renderer, N_(
"output-file"), file_name, NULL);
249 const char *file = NULL;
251 g_object_get(renderer, N_(
"output-file"), &file, NULL);
257 LayerSettings *ret = NULL;
260 priv = gds_output_renderer_get_instance_private(renderer);
266 g_object_get(renderer, N_(
"layer-settings"), &ret, NULL);
276 g_return_if_fail(GDS_RENDER_IS_LAYER_SETTINGS(settings));
278 g_object_set(renderer, N_(
"layer-settings"), settings, NULL);
284 GdsOutputRendererClass *klass;
287 if (GDS_RENDER_IS_OUTPUT_RENDERER(renderer) == FALSE) {
288 g_error(_(
"Output Renderer not valid."));
293 g_error(_(
"No/invalid output file set."));
298 g_error(_(
"No layer specification supplied."));
303 g_error(_(
"Output renderer called without cell to render."));
307 klass = GDS_RENDER_OUTPUT_RENDERER_GET_CLASS(renderer);
308 if (klass->render_output == NULL) {
309 g_critical(_(
"Output Renderer: Rendering function broken. This is a bug."));
313 ret = klass->render_output(renderer, cell, scale);
319 gpointer source_object,
321 GCancellable *cancellable)
323 GdsOutputRenderer *renderer;
329 renderer = GDS_RENDER_OUTPUT_RENDERER(source_object);
330 priv = gds_output_renderer_get_instance_private(renderer);
343 g_task_return_int(task, ret);
352 priv = gds_output_renderer_get_instance_private(GDS_RENDER_OUTPUT_RENDERER(src_obj));
357 g_clear_object(&priv->
task);
360 g_object_unref(src_obj);
368 priv = gds_output_renderer_get_instance_private(renderer);
370 g_warning(_(
"Renderer already started asynchronously"));
386 g_object_ref(renderer);
396 GdsOutputRenderer *renderer;
403 if (!GDS_RENDER_IS_OUTPUT_RENDERER(user_data))
406 renderer = GDS_RENDER_OUTPUT_RENDERER(user_data);
407 priv = gds_output_renderer_get_instance_private(renderer);
424 GSource *idle_event_processor;
426 gboolean skip_source = FALSE;
428 g_return_if_fail(GDS_RENDER_IS_OUTPUT_RENDERER(renderer));
432 priv = gds_output_renderer_get_instance_private(renderer);
449 idle_event_processor = g_idle_source_new();
451 g_source_attach(idle_event_processor, priv->
main_context);
Header for output renderer base class.
static GParamSpec * gds_output_renderer_properties[N_PROPERTIES]
static void gds_output_renderer_get_property(GObject *obj, guint property_id, GValue *value, GParamSpec *pspec)
static guint gds_output_renderer_signals[GDS_OUTPUT_RENDERER_SIGNAL_COUNT]
GdsOutputRenderer * gds_output_renderer_new()
Create a new GdsOutputRenderer GObject.
GdsOutputRenderer * gds_output_renderer_new_with_props(const char *output_file, LayerSettings *layer_settings)
Create a new GdsOutputRenderer GObject with its properties.
static void gds_output_renderer_set_property(GObject *obj, guint property_id, const GValue *value, GParamSpec *pspec)
int gds_output_renderer_render_output_async(GdsOutputRenderer *renderer, struct gds_cell *cell, double scale)
Render output asynchronously.
static int gds_output_renderer_render_dummy(GdsOutputRenderer *renderer, struct gds_cell *cell, double scale)
void gds_output_renderer_set_output_file(GdsOutputRenderer *renderer, const gchar *file_name)
Convenience function for setting the "output-file" property.
static void gds_output_renderer_class_init(GdsOutputRendererClass *klass)
const char * gds_output_renderer_get_output_file(GdsOutputRenderer *renderer)
Convenience function for getting the "output-file" property.
static void gds_output_renderer_dispose(GObject *self_obj)
int gds_output_renderer_render_output(GdsOutputRenderer *renderer, struct gds_cell *cell, double scale)
gds_output_renderer_render_output
void gds_output_renderer_update_async_progress(GdsOutputRenderer *renderer, const char *status)
This function emits the 'progress-changed' in the thread/context that triggered an asynchronous rende...
LayerSettings * gds_output_renderer_get_and_ref_layer_settings(GdsOutputRenderer *renderer)
Get layer settings.
#define GDS_RENDER_TYPE_OUTPUT_RENDERER
gds_output_renderer_signal_ids
static gboolean idle_event_processor_callback(gpointer user_data)
static void gds_output_renderer_async_finished(GObject *src_obj, GAsyncResult *res, gpointer user_data)
static void gds_output_renderer_async_wrapper(GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable)
void gds_output_renderer_set_layer_settings(GdsOutputRenderer *renderer, LayerSettings *settings)
Set layer settings.
void gds_output_renderer_init(GdsOutputRenderer *self)
@ GDS_OUTPUT_RENDERER_PARAM_ERR
Error set by the _GdsOutputRendererClass::render_output virtual function, if parameters are faulty.
@ GDS_OUTPUT_RENDERER_GEN_ERR
Error set by the _GdsOutputRendererClass::render_output virtual function, if renderer is invalid.
@ GDS_OUTPUT_RENDERER_SIGNAL_COUNT
#define GDS_RENDER_TYPE_LAYER_SETTINGS
gboolean mutex_init_status
GMainContext * main_context
struct idle_function_params idle_function_parameters
LayerSettings * layer_settings
struct renderer_params async_params
A Cell inside a gds_library.