From 9b0f268bbd93733e5a586729bd526c1d05014609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 28 May 2019 20:59:16 +0200 Subject: [PATCH 1/8] Add ActivityBar widget --- doxygen/activity-bar.dox | 6 ++ gds-render-gui.c | 11 +++ include/gds-render/widgets/activity-bar.h | 60 ++++++++++++ widgets/activity-bar.c | 109 ++++++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 doxygen/activity-bar.dox create mode 100644 include/gds-render/widgets/activity-bar.h create mode 100644 widgets/activity-bar.c diff --git a/doxygen/activity-bar.dox b/doxygen/activity-bar.dox new file mode 100644 index 0000000..34432ac --- /dev/null +++ b/doxygen/activity-bar.dox @@ -0,0 +1,6 @@ +/** + * @defgroup ActivityBar + * @ingroup Widgets + * + * Activity Status Bar + */ diff --git a/gds-render-gui.c b/gds-render-gui.c index 54e7938..a0df455 100644 --- a/gds-render-gui.c +++ b/gds-render-gui.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ struct _GdsRenderGui { LayerSelector *layer_selector; GtkTreeView *cell_tree_view; GList *gds_libraries; + ActivityBar *activity_status_bar; struct render_settings render_dialog_settings; }; @@ -442,6 +444,7 @@ static void gds_render_gui_dispose(GObject *gobject) g_clear_object(&self->layer_selector); g_clear_object(&self->cell_tree_store); g_clear_object(&self->cell_search_entry); + g_clear_object(&self->activity_status_bar); if (self->main_window) { g_signal_handlers_destroy(self->main_window); @@ -484,6 +487,7 @@ static void gds_render_gui_init(GdsRenderGui *self) struct tree_stores *cell_selector_stores; GtkWidget *sort_up_button; GtkWidget *sort_down_button; + GtkWidget *activity_bar_box; main_builder = gtk_builder_new_from_resource("/gui/main.glade"); @@ -505,6 +509,7 @@ static void gds_render_gui_init(GdsRenderGui *self) /* Create layer selector */ self->layer_selector = layer_selector_new(GTK_LIST_BOX(listbox)); + activity_bar_box = GTK_WIDGET(gtk_builder_get_object(main_builder, "activity-bar")); /* Callback for selection change of cell selector */ g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(self->cell_tree_view)), "changed", @@ -535,6 +540,11 @@ static void gds_render_gui_init(GdsRenderGui *self) g_object_unref(main_builder); + /* Create and apply ActivityBar */ + self->activity_status_bar = activity_bar_new(); + gtk_container_add(GTK_CONTAINER(activity_bar_box), GTK_WIDGET(self->activity_status_bar)); + gtk_widget_show(GTK_WIDGET(self->activity_status_bar)); + /* Set default conversion/rendering settings */ self->render_dialog_settings.scale = 1000; self->render_dialog_settings.renderer = RENDERER_LATEX_TIKZ; @@ -543,6 +553,7 @@ static void gds_render_gui_init(GdsRenderGui *self) /* Reference all objects referenced by this object */ + g_object_ref(self->activity_status_bar); g_object_ref(self->main_window); g_object_ref(self->cell_tree_view); g_object_ref(self->convert_button); diff --git a/include/gds-render/widgets/activity-bar.h b/include/gds-render/widgets/activity-bar.h new file mode 100644 index 0000000..37ef801 --- /dev/null +++ b/include/gds-render/widgets/activity-bar.h @@ -0,0 +1,60 @@ +/* + * GDSII-Converter + * Copyright (C) 2019 Mario Hüttel + * + * This file is part of GDSII-Converter. + * + * GDSII-Converter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * GDSII-Converter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GDSII-Converter. If not, see . + */ + +/** + * @file activity-bar.h + * @brief Header file for activity bar widget + * @author Mario Hüttel + */ + +/** + * @addtogroup ActivityBar + * @ingroup Widgets + * @{ + */ + +#ifndef __LAYER_ELEMENT_H__ +#define __LAYER_ELEMENT_H__ + +#include + +G_BEGIN_DECLS + +/* Creates Class structure etc */ +G_DECLARE_FINAL_TYPE(ActivityBar, activity_bar, ACTIVITY, BAR, GtkBox) + +#define TYPE_ACTIVITY_BAR (activity_bar_get_type()) + +/** + * @brief Create new Object ActivityBar + * @return New object. In case of error: NULL. + */ +ActivityBar *activity_bar_new(); + +/** + * @brief Deletes all applied tasks and sets bar to "Ready". + * @param[in] bar AcitivityBar object. + */ +void activity_bar_set_ready(ActivityBar *bar); + +G_END_DECLS + +#endif /* __LAYER_ELEMENT_H__ */ + +/** @} */ diff --git a/widgets/activity-bar.c b/widgets/activity-bar.c new file mode 100644 index 0000000..94e2474 --- /dev/null +++ b/widgets/activity-bar.c @@ -0,0 +1,109 @@ +/* + * GDSII-Converter + * Copyright (C) 2019 Mario Hüttel + * + * This file is part of GDSII-Converter. + * + * GDSII-Converter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * GDSII-Converter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GDSII-Converter. If not, see . + */ + +/* + * The drag and drop implementation is adapted from + * https://gitlab.gnome.org/GNOME/gtk/blob/gtk-3-22/tests/testlist3.c + * + * Thanks to the GTK3 people for creating these examples. + */ + +/** + * @file activity-bar.c + * @brief Status bar indicating activity of the program + * @author Mario Hüttel + */ + +/** + * @addtogroup ActivityBar + * @ingroup Widgets + * @{ + */ + +#include + +/** @brief Opaque ActivityBar object. Not viewable outside this source file. */ +struct _ActivityBar { + GtkBox super; + /* Private stuff */ + GtkWidget *spinner; + GtkWidget *label; +}; + +G_DEFINE_TYPE(ActivityBar, activity_bar, GTK_TYPE_BOX) + +static void activity_bar_dispose(GObject *obj) +{ + ActivityBar *bar; + + bar = ACTIVITY_BAR(obj); + + /* Clear references on owned objects */ + g_clear_object(&bar->label); + g_clear_object(&bar->spinner); + + /* Chain up */ + G_OBJECT_CLASS(activity_bar_parent_class)->dispose(obj); +} + +static void activity_bar_class_init(ActivityBarClass *klass) +{ + GObjectClass *oclass = G_OBJECT_CLASS(klass); + + oclass->dispose = activity_bar_dispose; +} + +static void activity_bar_init(ActivityBar *self) +{ + GtkContainer *box = GTK_CONTAINER(self); + + /* Create Widgets */ + self->label = gtk_label_new(""); + self->spinner = gtk_spinner_new(); + + /* Add to this widget and show */ + gtk_container_add(box, self->spinner); + gtk_container_add(box, self->label); + gtk_widget_show(self->label); + gtk_widget_show(self->spinner); + + g_object_ref(self->spinner); + g_object_ref(self->label); +} + +ActivityBar *activity_bar_new() +{ + ActivityBar *bar; + + bar = ACTIVITY_BAR(g_object_new(TYPE_ACTIVITY_BAR, "orientation", GTK_ORIENTATION_HORIZONTAL, NULL)); + if (bar) + activity_bar_set_ready(bar); + + return bar; +} + +/* TODO: Complete this once the task list is fully implemented */ +void activity_bar_set_ready(ActivityBar *bar) +{ + gtk_label_set_text(GTK_LABEL(bar->label), "Ready"); + gtk_spinner_stop(GTK_SPINNER(bar->spinner)); +} + + +/** @} */ From 2d3241d8b78041daf6490b69645e2ec1f2e8d748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 30 May 2019 14:17:36 +0200 Subject: [PATCH 2/8] cairo-renderer: check for valid pointers of crs and surfaces --- cairo-renderer/cairo-output.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cairo-renderer/cairo-output.c b/cairo-renderer/cairo-output.c index 1f25051..20908cc 100644 --- a/cairo-renderer/cairo-output.c +++ b/cairo-renderer/cairo-output.c @@ -181,8 +181,8 @@ static void render_cell(struct gds_cell *cell, struct cairo_layer *layers, doubl void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos, char *pdf_file, char *svg_file, double scale) { - cairo_surface_t *pdf_surface, *svg_surface; - cairo_t *pdf_cr, *svg_cr; + cairo_surface_t *pdf_surface = NULL, *svg_surface = NULL; + cairo_t *pdf_cr = NULL, *svg_cr = NULL; struct layer_info *linfo; struct cairo_layer *layers; struct cairo_layer *lay; @@ -276,16 +276,15 @@ void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos, continue; } - if (pdf_file) { + if (pdf_file && pdf_cr) { cairo_set_source_surface(pdf_cr, layers[linfo->layer].rec, -xmin, -ymin); cairo_paint_with_alpha(pdf_cr, linfo->color.alpha); } - if (svg_file) { + if (svg_file && svg_cr) { cairo_set_source_surface(svg_cr, layers[linfo->layer].rec, -xmin, -ymin); cairo_paint_with_alpha(svg_cr, linfo->color.alpha); } - } if (pdf_file) { From dadafa43a32942c0434d71e7e557739711e882c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 30 May 2019 14:49:35 +0200 Subject: [PATCH 3/8] Work around issue #16. This is not very beatiful. --- cairo-renderer/cairo-output.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cairo-renderer/cairo-output.c b/cairo-renderer/cairo-output.c index 20908cc..5ee1897 100644 --- a/cairo-renderer/cairo-output.c +++ b/cairo-renderer/cairo-output.c @@ -33,6 +33,8 @@ #include #include +#include +#include /** * @brief The cairo_layer struct @@ -190,12 +192,26 @@ void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos, int i; double rec_x0, rec_y0, rec_width, rec_height; double xmin = INT32_MAX, xmax = INT32_MIN, ymin = INT32_MAX, ymax = INT32_MIN; + pid_t process_id; if (pdf_file == NULL && svg_file == NULL) { /* No output specified */ return; } + /* Fork to a new child process. This ensures the memory leaks (see issue #16) in Cairo don't + * brick everything. + * + * And by the way: This now bricks all Windows compatibility. Deal with it. + */ + process_id = fork(); + if (process_id < 0) { + /* Well... shit... We have to run it in our process. */ + } else if (process_id > 0) { + /* Woohoo... Successfully dumped the shitty code to a unknowing victim */ + goto ret_parent; + } + layers = (struct cairo_layer *)calloc(MAX_LAYERS, sizeof(struct cairo_layer)); /* Clear layers */ @@ -310,6 +326,16 @@ ret_clear_layers: free(layers); printf("cairo export finished. It might still be buggy!\n"); + + /* If forked, suspend process */ + if (process_id == 0) + exit(0); + + /* fork didn't work. Just return here */ + return; +ret_parent: + waitpid(process_id, NULL, 0); + return; } /** @} */ From 906225f47f42300f7ffce3ec2bea67b41a35833e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 30 May 2019 14:55:37 +0200 Subject: [PATCH 4/8] Fix Typos --- cairo-renderer/cairo-output.c | 2 +- doxygen/versioning.dox | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cairo-renderer/cairo-output.c b/cairo-renderer/cairo-output.c index 5ee1897..6a8a89d 100644 --- a/cairo-renderer/cairo-output.c +++ b/cairo-renderer/cairo-output.c @@ -208,7 +208,7 @@ void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos, if (process_id < 0) { /* Well... shit... We have to run it in our process. */ } else if (process_id > 0) { - /* Woohoo... Successfully dumped the shitty code to a unknowing victim */ + /* Woohoo... Successfully dumped the shitty code to an unknowing victim */ goto ret_parent; } diff --git a/doxygen/versioning.dox b/doxygen/versioning.dox index dc41ff7..0a69308 100644 --- a/doxygen/versioning.dox +++ b/doxygen/versioning.dox @@ -31,6 +31,6 @@ In tabular form: *v1.0-rc4-41-gaa41373-dirty* | 1.0-rc4 | 41 | aa41373 | yes | -This git-based version number is automatically put into the application and this doxumentation during the application's compilation / the documentation's generation. For this *git* is needed. Therefore, it is highly recommended to have 'git' installed for compilation although it is no build dependency. In case of a missing git installation, the string "! version not set !" is compiled into the application. +This git-based version number is automatically put into the application and this documentation during the application's compilation / the documentation's generation. For this *git* is needed. Therefore, it is highly recommended to have 'git' installed for compilation although it is no build dependency. In case of a missing git installation, the string "! version not set !" is compiled into the application. **/ From 6ebd05007ea7a3e776f1d15f96b30016b6922fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 7 Jun 2019 19:28:07 +0200 Subject: [PATCH 5/8] Cairo Renderer: Fix Typos --- cairo-renderer/cairo-output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cairo-renderer/cairo-output.c b/cairo-renderer/cairo-output.c index 6a8a89d..f52c2dc 100644 --- a/cairo-renderer/cairo-output.c +++ b/cairo-renderer/cairo-output.c @@ -325,13 +325,13 @@ ret_clear_layers: } free(layers); - printf("cairo export finished. It might still be buggy!\n"); + printf("Cairo export finished. It might still be buggy!\n"); /* If forked, suspend process */ if (process_id == 0) exit(0); - /* fork didn't work. Just return here */ + /* Fork didn't work. Just return here */ return; ret_parent: waitpid(process_id, NULL, 0); From 795d496949ae63b9f6421414e868dfcd4a3bd46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 7 Jun 2019 19:30:37 +0200 Subject: [PATCH 6/8] GDS parser: Enhance doxygen headers --- include/gds-render/gds-utils/gds-parser.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/gds-render/gds-utils/gds-parser.h b/include/gds-render/gds-utils/gds-parser.h index 331e734..409dbc3 100644 --- a/include/gds-render/gds-utils/gds-parser.h +++ b/include/gds-render/gds-utils/gds-parser.h @@ -37,7 +37,21 @@ #define GDS_PRINT_DEBUG_INFOS (0) /**< @brief 1: Print infos, 0: Don't print */ +/** + * @brief Parse a GDS file + * + * This function parses a GDS File and creates a list of libraries, + * which then contain the different cells. + * + * The function appends The detected libraries to the \p library_array list. + * The library array may be empty, meaning *library_list may be NULL. + * + * @param filename[in] Path to the GDS file + * @param library_array[in] GList Pointer. + * @return 0 if successful + */ int parse_gds_from_file(const char *filename, GList **library_array); + /** * @brief Deletes all libraries including cells, references etc. * @param library_list Pointer to a list of #gds_library. Is set to NULL after completion. From 583f01faae6ff7cc20b609403199f5c5eadb6234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 7 Jun 2019 19:32:38 +0200 Subject: [PATCH 7/8] Enhance formatting, fix typos --- gds-utils/gds-parser.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gds-utils/gds-parser.c b/gds-utils/gds-parser.c index b808d94..b1f342d 100644 --- a/gds-utils/gds-parser.c +++ b/gds-utils/gds-parser.c @@ -53,7 +53,8 @@ #define GDS_WARN(fmt, ...) printf("[PARSE_WARNING] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS warning */ #if GDS_PRINT_DEBUG_INFOS - #define GDS_INF(fmt, ...) printf(fmt, ##__VA_ARGS__) /**< @brief standard printf. But can be disabled in code */ + /**< @brief standard printf. But can be disabled in code. */ + #define GDS_INF(fmt, ...) printf(fmt, ##__VA_ARGS__) #else #define GDS_INF(fmt, ...) #endif @@ -813,7 +814,7 @@ int parse_gds_from_file(const char *filename, GList **library_list) if (current_s_reference) { name_cell_ref(current_s_reference, (unsigned int)read, workbuff); } else { - GDS_ERROR("reference name set outside of cell reference.\n"); + GDS_ERROR("Reference name set outside of cell reference"); } break; case WIDTH: From 0d6b2c7a36ea5745267f3a0cd79a2dd95a06644d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 7 Jun 2019 19:33:53 +0200 Subject: [PATCH 8/8] Color palette: Cast unused function parameter --- layer/color-palette.c | 1 + 1 file changed, 1 insertion(+) diff --git a/layer/color-palette.c b/layer/color-palette.c index 64f080f..35d653f 100644 --- a/layer/color-palette.c +++ b/layer/color-palette.c @@ -112,6 +112,7 @@ unsigned int color_palette_get_color_count(ColorPalette *palette) static void color_palette_class_init(ColorPaletteClass *klass) { + (void)klass; /* Nothing to do for now */ return; }