Compare commits

...

8 Commits

7 changed files with 62 additions and 50 deletions

View File

@ -41,14 +41,13 @@
static int string_array_count(char **string_array)
{
int count = 0;
int count;
if (!string_array)
return 0;
for (; *string_array; string_array++) {
for (count = 0; *string_array; string_array++)
count++;
}
return count;
}

View File

@ -37,8 +37,8 @@
#include <gds-render/widgets/activity-bar.h>
#include <gds-render/cell-selector/tree-store.h>
#include <gds-render/cell-selector/lib-cell-renderer.h>
//#include <gds-render/output-renderers/latex-output.h>
//#include <gds-render/output-renderers/cairo-output.h>
#include <gds-render/output-renderers/latex-renderer.h>
#include <gds-render/output-renderers/cairo-renderer.h>
#include <gds-render/widgets/conv-settings-dialog.h>
#include <gds-render/geometric/cell-geometrics.h>
#include <gds-render/version.h>
@ -266,9 +266,7 @@ static void on_convert_clicked(gpointer button, gpointer user)
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkTreeModel *model;
GList *layer_list;
struct gds_cell *cell_to_render;
FILE *output_file;
GtkWidget *dialog;
RendererSettingsDialog *settings;
GtkFileFilter *filter;
@ -277,6 +275,8 @@ static void on_convert_clicked(gpointer button, gpointer user)
union bounding_box cell_box;
unsigned int height, width;
struct render_settings *sett;
LayerSettings *layer_settings;
GdsOutputRenderer *render_engine;
self = RENDERER_GUI(user);
@ -296,7 +296,7 @@ static void on_convert_clicked(gpointer button, gpointer user)
return;
/* Get layers that are rendered */
//layer_list = layer_selector_export_rendered_layer_info(self->layer_selector);
layer_settings = layer_selector_export_rendered_layer_info(self->layer_selector);
/* Calculate cell size in DB units */
bounding_box_prepare_empty(&cell_box);
@ -359,31 +359,35 @@ static void on_convert_clicked(gpointer button, gpointer user)
switch (sett->renderer) {
case RENDERER_LATEX_TIKZ:
output_file = fopen(file_name, "w");
/*latex_render_cell_to_code(cell_to_render, layer_list, output_file, sett->scale,
sett->tex_pdf_layers, sett->tex_standalone);
*/fclose(output_file);
render_engine =
GDS_RENDER_OUTPUT_RENDERER(latex_renderer_new_with_options(sett->tex_pdf_layers,
sett->tex_standalone));
break;
case RENDERER_CAIROGRAPHICS_SVG:
render_engine = GDS_RENDER_OUTPUT_RENDERER(cairo_renderer_new_svg());
break;
case RENDERER_CAIROGRAPHICS_PDF:
/*cairo_render_cell_to_vector_file(cell_to_render, layer_list,
(sett->renderer == RENDERER_CAIROGRAPHICS_PDF
? file_name
: NULL),
(sett->renderer == RENDERER_CAIROGRAPHICS_SVG
? file_name
: NULL),
sett->scale);
*/break;
render_engine = GDS_RENDER_OUTPUT_RENDERER(cairo_renderer_new_pdf());
break;
}
if (render_engine) {
gds_output_renderer_set_output_file(render_engine, file_name);
gds_output_renderer_set_layer_settings(render_engine, layer_settings);
/* TODO: Replace this with asynchronous rendering. However, this fixes issue #19 */
gds_output_renderer_render_output(render_engine, cell_to_render, sett->scale);
g_object_unref(render_engine);
}
g_free(file_name);
} else {
gtk_widget_destroy(dialog);
}
ret_layer_destroy:
;
// g_list_free_full(layer_list, (GDestroyNotify)layer_info_delete_struct);
g_object_unref(layer_settings);
}
/**

View File

@ -23,14 +23,14 @@
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#ifndef _GDSPARSER_H_
#define _GDSPARSER_H_
/**
* @addtogroup GDS-Utilities
* @{
*/
#ifndef _GDSPARSER_H_
#define _GDSPARSER_H_
#include <glib.h>
#include <gds-render/gds-utils/gds-types.h>
@ -61,4 +61,4 @@ int clear_lib_list(GList **library_list);
/** @} */
#endif /* _GDSPARSE_H_ */
#endif /* _GDSPARSER_H_ */

View File

@ -34,6 +34,7 @@
#include <gtk/gtk.h>
#include <glib.h>
#include <gds-render/layer/color-palette.h>
#include <gds-render/layer/layer-info.h>
G_BEGIN_DECLS
@ -80,9 +81,9 @@ void layer_selector_set_save_mapping_button(LayerSelector *selector, GtkWidget *
/**
* @brief Get a list of all layers that shall be exported when rendering the cells
* @param selector Layer selector instance
* @return List of layer_info structures containing the layer information
* @return LayerSettings containing the layer information
*/
GList *layer_selector_export_rendered_layer_info(LayerSelector *selector);
LayerSettings *layer_selector_export_rendered_layer_info(LayerSelector *selector);
/**
* @brief Force the layer selector list to be sorted according to \p sort_function

View File

@ -371,38 +371,39 @@ LayerSelector *layer_selector_new(GtkListBox *list_box)
return selector;
}
GList *layer_selector_export_rendered_layer_info(LayerSelector *selector)
LayerSettings *layer_selector_export_rendered_layer_info(LayerSelector *selector)
{
GList *info_list = NULL;
LayerElement *le;
struct layer_info *linfo;
LayerSettings *layer_settings;
struct layer_info linfo;
GList *row_list;
GList *temp;
GList *iterator;
LayerElement *le;
int i;
if (!selector)
layer_settings = layer_settings_new();
if (!layer_settings)
return NULL;
row_list = gtk_container_get_children(GTK_CONTAINER(selector->list_box));
/* Iterate through widgets and add layers that shall be exported */
for (i = 0, temp = row_list; temp != NULL; temp = temp->next, i++) {
for (i = 0,iterator = row_list; iterator != NULL; iterator = g_list_next(iterator), i++) {
le = LAYER_ELEMENT(iterator->data);
le = LAYER_ELEMENT(temp->data);
/* Get name from layer element. This must not be freed */
linfo.name =(char *)layer_element_get_name(le);
if (layer_element_get_export(le) == TRUE) {
/* Allocate new info and fill with info */
linfo = (struct layer_info *)malloc(sizeof(struct layer_info));
layer_element_get_color(le, &linfo->color);
linfo->layer = layer_element_get_layer(le);
linfo->name = (char *)layer_element_get_name(le);
layer_element_get_color(le, &linfo.color);
linfo.render = (layer_element_get_export(le) ? 1 : 0);
linfo.stacked_position = i;
linfo.layer = layer_element_get_layer(le);
/* Append to list */
info_list = g_list_append(info_list, (gpointer)linfo);
}
/* This function copies the entire layer info struct including the name string.
* Therefore, using the same layer_info struct over and over is safe.
*/
layer_settings_append_layer_info(layer_settings, &linfo);
}
return info_list;
return layer_settings;
}
static void layer_selector_clear_widgets(LayerSelector *self)

View File

@ -220,7 +220,10 @@ static int cairo_renderer_render_cell_to_vector_file(struct gds_cell *cell, GLis
*
* And by the way: This now bricks all Windows compatibility. Deal with it.
*/
/* Use fork for production code and -1 as value for debugging */
process_id = fork();
//process_id = -1;
if (process_id < 0) {
/* Well... shit... We have to run it in our process. */
} else if (process_id > 0) {
@ -239,7 +242,11 @@ static int cairo_renderer_render_cell_to_vector_file(struct gds_cell *cell, GLis
/* Create recording surface for each layer */
for (info_list = layer_infos; info_list != NULL; info_list = g_list_next(info_list)) {
linfo = (struct layer_info *)info_list->data;
if (linfo->layer < MAX_LAYERS && linfo->render) {
if (linfo->layer < MAX_LAYERS) {
/* Layer shall not be rendered */
if (!linfo->render)
continue;
lay = &(layers[(unsigned int)linfo->layer]);
lay->linfo = linfo;
lay->rec = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA,

View File

@ -260,7 +260,7 @@ void gds_output_renderer_set_layer_settings(GdsOutputRenderer *renderer, LayerSe
{
g_return_if_fail(GDS_RENDER_IS_LAYER_SETTINGS(settings));
g_object_set(renderer, "layer_settings", settings, NULL);
g_object_set(renderer, "layer-settings", settings, NULL);
}
int gds_output_renderer_render_output(GdsOutputRenderer *renderer, struct gds_cell *cell, double scale)