Merge branch 'translations' into japanese-translations

This commit is contained in:
Mario Hüttel 2019-11-09 01:52:18 +01:00
commit 25efe527c3
16 changed files with 180 additions and 147 deletions

View File

@ -225,9 +225,8 @@ int command_line_convert_gds(const char *gds_name,
ret_destroy_library_list: ret_destroy_library_list:
clear_lib_list(&libs); clear_lib_list(&libs);
ret_clear_renderers: ret_clear_renderers:
for (list_iter = renderer_list; list_iter; list_iter = list_iter->next) { for (list_iter = renderer_list; list_iter; list_iter = list_iter->next)
g_object_unref(list_iter->data); g_object_unref(list_iter->data);
}
ret_destroy_layer_mapping: ret_destroy_layer_mapping:
g_object_unref(layer_sett); g_object_unref(layer_sett);
return ret; return ret;

View File

@ -247,7 +247,9 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
G_TYPE_STRING, G_TYPE_STRING); G_TYPE_STRING, G_TYPE_STRING);
/* Searching */ /* Searching */
self->cell_filter = GTK_TREE_MODEL_FILTER(gtk_tree_model_filter_new(GTK_TREE_MODEL(self->cell_tree_store), NULL)); self->cell_filter = GTK_TREE_MODEL_FILTER(
gtk_tree_model_filter_new(GTK_TREE_MODEL(self->cell_tree_store), NULL));
gtk_tree_model_filter_set_visible_func(self->cell_filter, gtk_tree_model_filter_set_visible_func(self->cell_filter,
(GtkTreeModelFilterVisibleFunc)cell_store_filter_visible_func, (GtkTreeModelFilterVisibleFunc)cell_store_filter_visible_func,
self, NULL); self, NULL);
@ -274,8 +276,10 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
gtk_tree_view_append_column(self->cell_tree_view, column); gtk_tree_view_append_column(self->cell_tree_view, column);
/* Callback for selection /* Callback for selection
* This prevents selecting a library */ * This prevents selecting a library
gtk_tree_selection_set_select_function(gtk_tree_view_get_selection(self->cell_tree_view), tree_sel_func, NULL, NULL); */
gtk_tree_selection_set_select_function(gtk_tree_view_get_selection(self->cell_tree_view),
tree_sel_func, NULL, NULL);
return 0; return 0;
} }
@ -451,7 +455,9 @@ static void async_rendering_finished_callback(GdsOutputRenderer *renderer, gpoin
g_object_unref(renderer); g_object_unref(renderer);
} }
static void async_rendering_status_update_callback(GdsOutputRenderer *renderer, const char *status_message, gpointer data) static void async_rendering_status_update_callback(GdsOutputRenderer *renderer,
const char *status_message,
gpointer data)
{ {
GdsRenderGui *gui; GdsRenderGui *gui;
(void)renderer; (void)renderer;

View File

@ -90,7 +90,8 @@ int gds_tree_check_cell_references(struct gds_library *lib)
* @param cell Cell to check for * @param cell Cell to check for
* @return 0 if cell is not in list. 1 if cell is in list * @return 0 if cell is not in list. 1 if cell is in list
*/ */
static int gds_tree_check_list_contains_cell(GList *list, struct gds_cell *cell) { static int gds_tree_check_list_contains_cell(GList *list, struct gds_cell *cell)
{
GList *iter; GList *iter;
for (iter = list; iter != NULL; iter = g_list_next(iter)) { for (iter = list; iter != NULL; iter = g_list_next(iter)) {
@ -177,12 +178,14 @@ int gds_tree_check_reference_loops(struct gds_library *lib)
res = gds_tree_check_iterate_ref_and_check(cell_to_check, &visited_cells); res = gds_tree_check_iterate_ref_and_check(cell_to_check, &visited_cells);
if (visited_cells) { if (visited_cells) {
/* If cell contains no loop, print error when list not empty. /*
* If cell contains no loop, print error when list not empty.
* In case of a loop, it is completely normal that the list is not empty, * In case of a loop, it is completely normal that the list is not empty,
* due to the instant return from gds_tree_check_iterate_ref_and_check() * due to the instant return from gds_tree_check_iterate_ref_and_check()
*/ */
if (res == 0) if (res == 0)
fprintf(stderr, "Visited cell list should be empty. This is a bug. Please report this.\n"); fprintf(stderr,
"Visited cell list should be empty. This is a bug. Please report this.\n");
g_list_free(visited_cells); g_list_free(visited_cells);
visited_cells = NULL; visited_cells = NULL;
} }

View File

@ -151,7 +151,7 @@ void bounding_box_calculate_path_box(GList *vertices, double thickness,
GList *vertex_iterator; GList *vertex_iterator;
struct vector_2d pt; struct vector_2d pt;
//printf("Warning! Function bounding_box_calculate_path_box not yet implemented correctly!\n"); /* printf("Warning! Function %s not yet implemented correctly!\n", __func__); */
if (!vertices || !box) if (!vertices || !box)
return; return;

View File

@ -46,6 +46,7 @@ double vector_2d_scalar_multipy(struct vector_2d *a, struct vector_2d *b)
void vector_2d_normalize(struct vector_2d *vec) void vector_2d_normalize(struct vector_2d *vec)
{ {
double len; double len;
if (!vec) if (!vec)
return; return;
len = sqrt(pow(vec->x, 2) + pow(vec->y, 2)); len = sqrt(pow(vec->x, 2) + pow(vec->y, 2));
@ -97,10 +98,9 @@ struct vector_2d *vector_2d_alloc(void)
void vector_2d_free(struct vector_2d *vec) void vector_2d_free(struct vector_2d *vec)
{ {
if (vec) { if (vec)
free(vec); free(vec);
} }
}
void vector_2d_scale(struct vector_2d *vec, double scale) void vector_2d_scale(struct vector_2d *vec, double scale)
{ {
@ -114,9 +114,9 @@ void vector_2d_scale(struct vector_2d *vec, double scale)
double vector_2d_abs(struct vector_2d *vec) double vector_2d_abs(struct vector_2d *vec)
{ {
double len = 0.0; double len = 0.0;
if (vec) {
if (vec)
len = sqrt(pow(vec->x, 2) + pow(vec->y, 2)); len = sqrt(pow(vec->x, 2) + pow(vec->y, 2));
}
return len; return len;
} }

View File

@ -141,13 +141,16 @@ static int color_palette_fill_with_resource(ColorPalette *palette, char *resourc
g_regex_match(regex, line, 0, &mi); g_regex_match(regex, line, 0, &mi);
if (g_match_info_matches(mi) && color_idx < lines) { if (g_match_info_matches(mi) && color_idx < lines) {
match = g_match_info_fetch_named(mi, "red"); match = g_match_info_fetch_named(mi, "red");
palette->color_array[color_idx].red = (double)g_ascii_strtoll(match, NULL, 16) / 255.0; palette->color_array[color_idx].red =
(double)g_ascii_strtoll(match, NULL, 16) / 255.0;
g_free(match); g_free(match);
match = g_match_info_fetch_named(mi, "green"); match = g_match_info_fetch_named(mi, "green");
palette->color_array[color_idx].green = (double)g_ascii_strtoll(match, NULL, 16) / 255.0; palette->color_array[color_idx].green =
(double)g_ascii_strtoll(match, NULL, 16) / 255.0;
g_free(match); g_free(match);
match = g_match_info_fetch_named(mi, "blue"); match = g_match_info_fetch_named(mi, "blue");
palette->color_array[color_idx].blue = (double)g_ascii_strtoll(match, NULL, 16) / 255.0; palette->color_array[color_idx].blue =
(double)g_ascii_strtoll(match, NULL, 16) / 255.0;
g_free(match); g_free(match);
/* Only RGB supported so far. Fix alpha channel to 1.0 */ /* Only RGB supported so far. Fix alpha channel to 1.0 */
@ -233,8 +236,7 @@ static void color_palette_dispose(GObject *gobj)
ColorPalette *palette; ColorPalette *palette;
palette = GDS_RENDER_COLOR_PALETTE(gobj); palette = GDS_RENDER_COLOR_PALETTE(gobj);
if (palette->color_array) if (palette->color_array) {
{
palette->color_array_length = 0; palette->color_array_length = 0;
free(palette->color_array); free(palette->color_array);
} }

View File

@ -54,7 +54,8 @@ struct _LayerSelector {
G_DEFINE_TYPE(LayerSelector, layer_selector, G_TYPE_OBJECT) G_DEFINE_TYPE(LayerSelector, layer_selector, G_TYPE_OBJECT)
/* Drag and drop code /*
* Drag and drop code
* Original code from https://blog.gtk.org/2017/06/01/drag-and-drop-in-lists-revisited/ * Original code from https://blog.gtk.org/2017/06/01/drag-and-drop-in-lists-revisited/
*/ */
@ -119,10 +120,10 @@ static GtkListBoxRow *layer_selector_get_last_row (GtkListBox *list)
{ {
int i; int i;
GtkListBoxRow *row; GtkListBoxRow *row;
GtkListBoxRow *tmp;
row = NULL; row = NULL;
for (i = 0; ; i++) { for (i = 0; ; i++) {
GtkListBoxRow *tmp;
tmp = gtk_list_box_get_row_at_index(list, i); tmp = gtk_list_box_get_row_at_index(list, i);
if (tmp == NULL) if (tmp == NULL)
break; break;
@ -348,7 +349,8 @@ static void layer_selector_class_init(LayerSelectorClass *klass)
static void layer_selector_setup_dnd(LayerSelector *self) static void layer_selector_setup_dnd(LayerSelector *self)
{ {
gtk_drag_dest_set(GTK_WIDGET(self->list_box), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &self->dnd_target, 1, GDK_ACTION_MOVE); gtk_drag_dest_set(GTK_WIDGET(self->list_box), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
&self->dnd_target, 1, GDK_ACTION_MOVE);
g_signal_connect(self->list_box, "drag-data-received", G_CALLBACK(layer_selector_drag_data_received), NULL); g_signal_connect(self->list_box, "drag-data-received", G_CALLBACK(layer_selector_drag_data_received), NULL);
g_signal_connect(self->list_box, "drag-motion", G_CALLBACK(layer_selector_drag_motion), NULL); g_signal_connect(self->list_box, "drag-motion", G_CALLBACK(layer_selector_drag_motion), NULL);
g_signal_connect(self->list_box, "drag-leave", G_CALLBACK(layer_selector_drag_leave), NULL); g_signal_connect(self->list_box, "drag-leave", G_CALLBACK(layer_selector_drag_leave), NULL);
@ -424,9 +426,9 @@ static void layer_selector_clear_widgets(LayerSelector *self)
GList *temp; GList *temp;
list = gtk_container_get_children(GTK_CONTAINER(self->list_box)); list = gtk_container_get_children(GTK_CONTAINER(self->list_box));
for (temp = list; temp != NULL; temp = temp->next) { for (temp = list; temp != NULL; temp = temp->next)
gtk_container_remove(GTK_CONTAINER(self->list_box), GTK_WIDGET(temp->data)); gtk_container_remove(GTK_CONTAINER(self->list_box), GTK_WIDGET(temp->data));
}
/* Widgets are already destroyed when removed from box because they are only referenced inside the container */ /* Widgets are already destroyed when removed from box because they are only referenced inside the container */
g_list_free(list); g_list_free(list);
@ -444,7 +446,8 @@ static void layer_selector_clear_widgets(LayerSelector *self)
* @param layer Layer number to check for * @param layer Layer number to check for
* @return TRUE if layer is present, else FALSE * @return TRUE if layer is present, else FALSE
*/ */
static gboolean layer_selector_check_if_layer_widget_exists(LayerSelector *self, int layer) { static gboolean layer_selector_check_if_layer_widget_exists(LayerSelector *self, int layer)
{
GList *list; GList *list;
GList *temp; GList *temp;
LayerElement *widget; LayerElement *widget;
@ -552,9 +555,8 @@ void layer_selector_generate_layer_widgets(LayerSelector *selector, GList *libs)
for (; libs != NULL; libs = libs->next) { for (; libs != NULL; libs = libs->next) {
lib = (struct gds_library *)libs->data; lib = (struct gds_library *)libs->data;
for (cell_list = lib->cells; cell_list != NULL; cell_list = cell_list->next) { for (cell_list = lib->cells; cell_list != NULL; cell_list = cell_list->next)
layer_selector_analyze_cell_layers(selector, (struct gds_cell *)cell_list->data); layer_selector_analyze_cell_layers(selector, (struct gds_cell *)cell_list->data);
} /* For Cell List */
} /* For libs */ } /* For libs */
/* Sort the layers */ /* Sort the layers */
@ -690,7 +692,8 @@ static void layer_selector_load_mapping_clicked(GtkWidget *button, gpointer user
sel = LAYER_SELECTOR(user_data); sel = LAYER_SELECTOR(user_data);
dialog = gtk_file_chooser_dialog_new("Load Mapping File", GTK_WINDOW(sel->load_parent_window), GTK_FILE_CHOOSER_ACTION_OPEN, dialog = gtk_file_chooser_dialog_new("Load Mapping File", GTK_WINDOW(sel->load_parent_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
"Cancel", GTK_RESPONSE_CANCEL, "Load Mapping", GTK_RESPONSE_ACCEPT, NULL); "Cancel", GTK_RESPONSE_CANCEL, "Load Mapping", GTK_RESPONSE_ACCEPT, NULL);
res = gtk_dialog_run(GTK_DIALOG(dialog)); res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) { if (res == GTK_RESPONSE_ACCEPT) {
@ -735,7 +738,8 @@ static void layer_selector_save_mapping_clicked(GtkWidget *button, gpointer user
sel = LAYER_SELECTOR(user_data); sel = LAYER_SELECTOR(user_data);
dialog = gtk_file_chooser_dialog_new("Save Mapping File", GTK_WINDOW(sel->save_parent_window), GTK_FILE_CHOOSER_ACTION_SAVE, dialog = gtk_file_chooser_dialog_new("Save Mapping File", GTK_WINDOW(sel->save_parent_window),
GTK_FILE_CHOOSER_ACTION_SAVE,
"Cancel", GTK_RESPONSE_CANCEL, "Save Mapping", GTK_RESPONSE_ACCEPT, NULL); "Cancel", GTK_RESPONSE_CANCEL, "Save Mapping", GTK_RESPONSE_ACCEPT, NULL);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
@ -802,10 +806,9 @@ void layer_selector_select_all_layers(LayerSelector *layer_selector, gboolean se
for (iter = le_list; iter != NULL; iter = g_list_next(iter)) { for (iter = le_list; iter != NULL; iter = g_list_next(iter)) {
le = LAYER_ELEMENT(iter->data); le = LAYER_ELEMENT(iter->data);
if (LAYER_IS_ELEMENT(le)) { if (LAYER_IS_ELEMENT(le))
layer_element_set_export(le, select); layer_element_set_export(le, select);
} }
}
g_list_free(le_list); g_list_free(le_list);
} }

14
main.c
View File

@ -130,7 +130,7 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
*/ */
static const GActionEntry app_actions[] = { static const GActionEntry app_actions[] = {
{ "quit", app_quit, NULL, NULL, NULL, {0} }, { "quit", app_quit, NULL, NULL, NULL, {0} },
{"about", app_about, NULL, NULL, NULL, {0}} { "about", app_about, NULL, NULL, NULL, {0} },
}; };
/** /**
@ -275,14 +275,17 @@ int main(int argc, char **argv)
GOptionEntry entries[] = { GOptionEntry entries[] = {
{"version", 'v', 0, G_OPTION_ARG_NONE, &version, _("Print version"), NULL}, {"version", 'v', 0, G_OPTION_ARG_NONE, &version, _("Print version"), NULL},
{"renderer", 'r', 0, G_OPTION_ARG_STRING_ARRAY, &renderer_args, _("Renderer to use. Can be used multiple times."), "pdf|svg|tikz|ext"}, {"renderer", 'r', 0, G_OPTION_ARG_STRING_ARRAY, &renderer_args,
_("Renderer to use. Can be used multiple times."), "pdf|svg|tikz|ext"},
{"scale", 's', 0, G_OPTION_ARG_INT, &scale, _("Divide output coordinates by <SCALE>"), "<SCALE>" }, {"scale", 's', 0, G_OPTION_ARG_INT, &scale, _("Divide output coordinates by <SCALE>"), "<SCALE>" },
{"output-file", 'o', 0, G_OPTION_ARG_FILENAME_ARRAY, &output_paths, _("Output file path. Can be used multiple times."), "PATH" }, {"output-file", 'o', 0, G_OPTION_ARG_FILENAME_ARRAY, &output_paths,
_("Output file path. Can be used multiple times."), "PATH" },
{"mapping", 'm', 0, G_OPTION_ARG_FILENAME, &mappingname, _("Path for Layer Mapping File"), "PATH" }, {"mapping", 'm', 0, G_OPTION_ARG_FILENAME, &mappingname, _("Path for Layer Mapping File"), "PATH" },
{"cell", 'c', 0, G_OPTION_ARG_STRING, &cellname, _("Cell to render"), "NAME" }, {"cell", 'c', 0, G_OPTION_ARG_STRING, &cellname, _("Cell to render"), "NAME" },
{"tex-standalone", 'a', 0, G_OPTION_ARG_NONE, &pdf_standalone, _("Create standalone TeX"), NULL }, {"tex-standalone", 'a', 0, G_OPTION_ARG_NONE, &pdf_standalone, _("Create standalone TeX"), NULL },
{"tex-layers", 'l', 0, G_OPTION_ARG_NONE, &pdf_layers, _("Create PDF Layers (OCG)"), NULL }, {"tex-layers", 'l', 0, G_OPTION_ARG_NONE, &pdf_layers, _("Create PDF Layers (OCG)"), NULL },
{"custom-render-lib", 'P', 0, G_OPTION_ARG_FILENAME, &custom_library_path, "Path to a custom shared object, that implements the " EXTERNAL_LIBRARY_FUNCTION " function", "PATH"}, {"custom-render-lib", 'P', 0, G_OPTION_ARG_FILENAME, &custom_library_path,
"Path to a custom shared object, that implements the " EXTERNAL_LIBRARY_FUNCTION " function", "PATH"},
{NULL} {NULL}
}; };
@ -310,9 +313,8 @@ int main(int argc, char **argv)
gds_name = argv[1]; gds_name = argv[1];
/* Print out additional arguments as ignored */ /* Print out additional arguments as ignored */
for (i = 2; i < argc; i++) { for (i = 2; i < argc; i++)
printf(_("Ignored argument: %s"), argv[i]); printf(_("Ignored argument: %s"), argv[i]);
}
app_status = app_status =
command_line_convert_gds(gds_name, cellname, renderer_args, output_paths, mappingname, command_line_convert_gds(gds_name, cellname, renderer_args, output_paths, mappingname,

View File

@ -121,7 +121,8 @@ static void render_cell(struct gds_cell *cell, struct cairo_layer *layers, doubl
/* Render child cells */ /* Render child cells */
for (instance_list = cell->child_cells; instance_list != NULL; instance_list = instance_list->next) { for (instance_list = cell->child_cells; instance_list != NULL; instance_list = instance_list->next) {
cell_instance = (struct gds_cell_instance *)instance_list->data; cell_instance = (struct gds_cell_instance *)instance_list->data;
if ((temp_cell = cell_instance->cell_ref) != NULL) { temp_cell = cell_instance->cell_ref;
if (temp_cell != NULL) {
apply_inherited_transform_to_all_layers(layers, apply_inherited_transform_to_all_layers(layers,
&cell_instance->origin, &cell_instance->origin,
cell_instance->magnification, cell_instance->magnification,
@ -228,8 +229,12 @@ static int read_line_from_fd(int fd, char *buff, size_t buff_size)
* @param scale Scale the output image down by \p scale * @param scale Scale the output image down by \p scale
* @return Error * @return Error
*/ */
static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer, struct gds_cell *cell, GList *layer_infos, const char *pdf_file, static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer,
const char *svg_file, double scale) struct gds_cell *cell,
GList *layer_infos,
const char *pdf_file,
const char *svg_file,
double scale)
{ {
cairo_surface_t *pdf_surface = NULL, *svg_surface = NULL; cairo_surface_t *pdf_surface = NULL, *svg_surface = NULL;
cairo_t *pdf_cr = NULL, *svg_cr = NULL; cairo_t *pdf_cr = NULL, *svg_cr = NULL;

View File

@ -79,7 +79,8 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
} }
/* Load symbol from library */ /* Load symbol from library */
so_render_func = (int (*)(struct gds_cell *, GList *, const char *, double))dlsym(so_handle, EXTERNAL_LIBRARY_FUNCTION); so_render_func = (int (*)(struct gds_cell *, GList *, const char *, double))
dlsym(so_handle, EXTERNAL_LIBRARY_FUNCTION);
error_msg = dlerror(); error_msg = dlerror();
if (error_msg != NULL) { if (error_msg != NULL) {
fprintf(stderr, "Rendering function not found in library:\n%s\n", error_msg); fprintf(stderr, "Rendering function not found in library:\n%s\n", error_msg);

View File

@ -213,8 +213,6 @@ void gds_output_renderer_init(GdsOutputRenderer *self)
priv->idle_function_parameters.status_message = NULL; priv->idle_function_parameters.status_message = NULL;
g_mutex_init(&priv->settings_lock); g_mutex_init(&priv->settings_lock);
g_mutex_init(&priv->idle_function_parameters.message_lock); g_mutex_init(&priv->idle_function_parameters.message_lock);
return;
} }
GdsOutputRenderer *gds_output_renderer_new() GdsOutputRenderer *gds_output_renderer_new()

View File

@ -140,7 +140,8 @@ static gboolean write_layer_env(FILE *tex_file, GdkRGBA *color, int layer, GList
color->red = inf->color.red; color->red = inf->color.red;
color->green = inf->color.green; color->green = inf->color.green;
color->blue = inf->color.blue; color->blue = inf->color.blue;
g_string_printf(buffer, "\\begin{pgfonlayer}{l%d}\n\\ifcreatepdflayers\n\\begin{scope}[ocg={ref=%d, status=visible,name={%s}}]\n\\fi\n", g_string_printf(buffer,
"\\begin{pgfonlayer}{l%d}\n\\ifcreatepdflayers\n\\begin{scope}[ocg={ref=%d, status=visible,name={%s}}]\n\\fi\n",
layer, layer, inf->name); layer, layer, inf->name);
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
return TRUE; return TRUE;
@ -167,7 +168,7 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
struct gds_graphics *gfx; struct gds_graphics *gfx;
struct gds_point *pt; struct gds_point *pt;
GdkRGBA color; GdkRGBA color;
static const char *line_caps[] = {"butt", "round", "rect"}; static const char * const line_caps[] = {"butt", "round", "rect"};
for (temp = graphics; temp != NULL; temp = temp->next) { for (temp = graphics; temp != NULL; temp = temp->next) {
gfx = (struct gds_graphics *)temp->data; gfx = (struct gds_graphics *)temp->data;
@ -175,13 +176,18 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
/* Layer is defined => create graphics */ /* Layer is defined => create graphics */
if (gfx->gfx_type == GRAPHIC_POLYGON || gfx->gfx_type == GRAPHIC_BOX) { if (gfx->gfx_type == GRAPHIC_POLYGON || gfx->gfx_type == GRAPHIC_BOX) {
g_string_printf(buffer, "\\draw[line width=0.00001 pt, draw={c%d}, fill={c%d}, fill opacity={%lf}] ", g_string_printf(buffer,
"\\draw[line width=0.00001 pt, draw={c%d}, fill={c%d}, fill opacity={%lf}] ",
gfx->layer, gfx->layer, color.alpha); gfx->layer, gfx->layer, color.alpha);
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
/* Append vertices */ /* Append vertices */
for (temp_vertex = gfx->vertices; temp_vertex != NULL; temp_vertex = temp_vertex->next) { for (temp_vertex = gfx->vertices;
temp_vertex != NULL;
temp_vertex = temp_vertex->next) {
pt = (struct gds_point *)temp_vertex->data; pt = (struct gds_point *)temp_vertex->data;
g_string_printf(buffer, "(%lf pt, %lf pt) -- ", ((double)pt->x)/scale, ((double)pt->y)/scale); g_string_printf(buffer, "(%lf pt, %lf pt) -- ",
((double)pt->x)/scale,
((double)pt->y)/scale);
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
} }
g_string_printf(buffer, "cycle;\n"); g_string_printf(buffer, "cycle;\n");
@ -204,7 +210,9 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
/* Append vertices */ /* Append vertices */
for (temp_vertex = gfx->vertices; temp_vertex != NULL; temp_vertex = temp_vertex->next) { for (temp_vertex = gfx->vertices;
temp_vertex != NULL;
temp_vertex = temp_vertex->next) {
pt = (struct gds_point *)temp_vertex->data; pt = (struct gds_point *)temp_vertex->data;
g_string_printf(buffer, "(%lf pt, %lf pt)%s", g_string_printf(buffer, "(%lf pt, %lf pt)%s",
((double)pt->x)/scale, ((double)pt->x)/scale,
@ -263,7 +271,8 @@ static void render_cell(struct gds_cell *cell, GList *layer_infos, FILE *tex_fil
g_string_printf(buffer, "\\begin{scope}[rotate=%lf]\n", inst->angle); g_string_printf(buffer, "\\begin{scope}[rotate=%lf]\n", inst->angle);
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
g_string_printf(buffer, "\\begin{scope}[yscale=%lf, xscale=%lf]\n", (inst->flipped ? -1*inst->magnification : inst->magnification), g_string_printf(buffer, "\\begin{scope}[yscale=%lf, xscale=%lf]\n",
(inst->flipped ? -1*inst->magnification : inst->magnification),
inst->magnification); inst->magnification);
WRITEOUT_BUFFER(buffer); WRITEOUT_BUFFER(buffer);
@ -302,7 +311,8 @@ static int latex_render_cell_to_code(struct gds_cell *cell, GList *layer_infos,
WRITEOUT_BUFFER(working_line); WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\iftestmode\n"); g_string_printf(working_line, "\\iftestmode\n");
WRITEOUT_BUFFER(working_line); WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\documentclass[tikz]{standalone}\n\\usepackage{xcolor}\n\\usetikzlibrary{ocgx}\n\\begin{document}\n"); g_string_printf(working_line,
"\\documentclass[tikz]{standalone}\n\\usepackage{xcolor}\n\\usetikzlibrary{ocgx}\n\\begin{document}\n");
WRITEOUT_BUFFER(working_line); WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\fi\n"); g_string_printf(working_line, "\\fi\n");
WRITEOUT_BUFFER(working_line); WRITEOUT_BUFFER(working_line);
@ -361,9 +371,8 @@ static int latex_renderer_render_output(GdsOutputRenderer *renderer,
g_error("Could not open LaTeX output file"); g_error("Could not open LaTeX output file");
} }
if (settings) { if (settings)
g_object_unref(settings); g_object_unref(settings);
}
return ret; return ret;
} }

View File

@ -47,7 +47,7 @@
<property name="name">header</property> <property name="name">header</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="title" translatable="yes">GDS Renderer</property> <property name="title" translatable="yes">GDS-Render</property>
<property name="show_close_button">True</property> <property name="show_close_button">True</property>
<child> <child>
<object class="GtkButton" id="button-load-gds"> <object class="GtkButton" id="button-load-gds">

View File

@ -170,8 +170,11 @@ static gboolean shape_drawer_drawing_callback(GtkWidget *widget, cairo_t *cr, gp
final_scale_value = (width_scale < height_scale ? width_scale : height_scale); final_scale_value = (width_scale < height_scale ? width_scale : height_scale);
cairo_rectangle(cr, -(double)dialog->cell_width*final_scale_value/2.0, -(double)dialog->cell_height*final_scale_value/2.0, cairo_rectangle(cr,
(double)dialog->cell_width*final_scale_value, (double)dialog->cell_height*final_scale_value); -(double)dialog->cell_width * final_scale_value / 2.0,
-(double)dialog->cell_height * final_scale_value / 2.0,
(double)dialog->cell_width * final_scale_value,
(double)dialog->cell_height * final_scale_value);
cairo_stroke(cr); cairo_stroke(cr);
cairo_restore(cr); cairo_restore(cr);
@ -183,7 +186,7 @@ static double convert_number_to_engineering(double input, const char **out_prefi
const char *selected_prefix = NULL; const char *selected_prefix = NULL;
double return_val = 0.0; double return_val = 0.0;
int idx; int idx;
static const char * prefixes[] = {"y", "z", "a", "f", "p", "n", "u", "m", "c", "d", /* < 1 */ static const char * const prefixes[] = {"y", "z", "a", "f", "p", "n", "u", "m", "c", "d", /* < 1 */
"", /* 1 */ "", /* 1 */
"h", "k", "M", "G", "T", "P", "E", "Z", "Y"}; /* > 1 */ "h", "k", "M", "G", "T", "P", "E", "Z", "Y"}; /* > 1 */
static const double scale[] = {1E-24, 1E-21, 1E-18, 1E-15, 1E-12, 1E-9, 1E-6, 1E-3, 1E-2, 1E-1, static const double scale[] = {1E-24, 1E-21, 1E-18, 1E-15, 1E-12, 1E-9, 1E-6, 1E-3, 1E-2, 1E-1,
@ -193,7 +196,7 @@ static double convert_number_to_engineering(double input, const char **out_prefi
/* If pointer is invalid, return NaN */ /* If pointer is invalid, return NaN */
if (!out_prefix) if (!out_prefix)
return 0.0 / 0.0; return (0.0 / 0.0);
/* Start with the 2nd smallest prefix */ /* Start with the 2nd smallest prefix */
for (idx = 1; idx < prefix_count; idx++) { for (idx = 1; idx < prefix_count; idx++) {
@ -308,9 +311,9 @@ RendererSettingsDialog *renderer_settings_dialog_new(GtkWindow *parent)
RendererSettingsDialog *res; RendererSettingsDialog *res;
res = RENDERER_SETTINGS_DIALOG(g_object_new(RENDERER_TYPE_SETTINGS_DIALOG, NULL)); res = RENDERER_SETTINGS_DIALOG(g_object_new(RENDERER_TYPE_SETTINGS_DIALOG, NULL));
if (res && parent) { if (res && parent)
gtk_window_set_transient_for(GTK_WINDOW(res), parent); gtk_window_set_transient_for(GTK_WINDOW(res), parent);
}
return res; return res;
} }
@ -322,13 +325,12 @@ void renderer_settings_dialog_get_settings(RendererSettingsDialog *dialog, struc
settings->scale = gtk_range_get_value(GTK_RANGE(dialog->scale)); settings->scale = gtk_range_get_value(GTK_RANGE(dialog->scale));
/* Get active radio button selection */ /* Get active radio button selection */
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_latex)) == TRUE) { if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_latex)) == TRUE)
settings->renderer = RENDERER_LATEX_TIKZ; settings->renderer = RENDERER_LATEX_TIKZ;
} else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_cairo_pdf)) == TRUE) { else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_cairo_pdf)) == TRUE)
settings->renderer = RENDERER_CAIROGRAPHICS_PDF; settings->renderer = RENDERER_CAIROGRAPHICS_PDF;
} else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_cairo_svg)) == TRUE) { else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_cairo_svg)) == TRUE)
settings->renderer = RENDERER_CAIROGRAPHICS_SVG; settings->renderer = RENDERER_CAIROGRAPHICS_SVG;
}
settings->tex_pdf_layers = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->layer_check)); settings->tex_pdf_layers = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->layer_check));
settings->tex_standalone = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->standalone_check)); settings->tex_standalone = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->standalone_check));

View File

@ -54,6 +54,7 @@ static void layer_element_constructed(GObject *obj)
static void layer_element_class_init(LayerElementClass *klass) static void layer_element_class_init(LayerElementClass *klass)
{ {
GObjectClass *oclass = G_OBJECT_CLASS(klass); GObjectClass *oclass = G_OBJECT_CLASS(klass);
oclass->dispose = layer_element_dispose; oclass->dispose = layer_element_dispose;
oclass->constructed = layer_element_constructed; oclass->constructed = layer_element_constructed;
} }
@ -62,6 +63,7 @@ static void layer_element_init(LayerElement *self)
{ {
GtkBuilder *builder; GtkBuilder *builder;
GtkWidget *glade_box; GtkWidget *glade_box;
builder = gtk_builder_new_from_resource("/gui/layer-widget.glade"); builder = gtk_builder_new_from_resource("/gui/layer-widget.glade");
glade_box = GTK_WIDGET(gtk_builder_get_object(builder, "box")); glade_box = GTK_WIDGET(gtk_builder_get_object(builder, "box"));
gtk_container_add(GTK_CONTAINER(self), glade_box); gtk_container_add(GTK_CONTAINER(self), glade_box);
@ -140,7 +142,8 @@ void layer_element_set_dnd_callbacks(LayerElement *elem, struct layer_element_dn
/* Setup drag and drop */ /* Setup drag and drop */
gtk_style_context_add_class(gtk_widget_get_style_context(GTK_WIDGET(elem)), "row"); gtk_style_context_add_class(gtk_widget_get_style_context(GTK_WIDGET(elem)), "row");
gtk_drag_source_set(GTK_WIDGET(elem->priv.event_handle), GDK_BUTTON1_MASK, data->entries, data->entry_count, GDK_ACTION_MOVE); gtk_drag_source_set(GTK_WIDGET(elem->priv.event_handle), GDK_BUTTON1_MASK,
data->entries, data->entry_count, GDK_ACTION_MOVE);
g_signal_connect(elem->priv.event_handle, "drag-begin", G_CALLBACK(data->drag_begin), NULL); g_signal_connect(elem->priv.event_handle, "drag-begin", G_CALLBACK(data->drag_begin), NULL);
g_signal_connect(elem->priv.event_handle, "drag-data-get", G_CALLBACK(data->drag_data_get), NULL); g_signal_connect(elem->priv.event_handle, "drag-data-get", G_CALLBACK(data->drag_data_get), NULL);
g_signal_connect(elem->priv.event_handle, "drag-end", G_CALLBACK(data->drag_end), NULL); g_signal_connect(elem->priv.event_handle, "drag-end", G_CALLBACK(data->drag_end), NULL);