diff --git a/gds-render-gui.c b/gds-render-gui.c index 7802013..2193066 100644 --- a/gds-render-gui.c +++ b/gds-render-gui.c @@ -691,19 +691,13 @@ static void on_select_all_layers_clicked(GtkWidget *button, gpointer user_data) layer_selector_select_all_layers(gui->layer_selector, TRUE); } -static void auto_naming_clicked(GtkWidget *button, gpointer user_data) +static gboolean auto_naming_ask_for_override(GdsRenderGui *gui) { - GdsRenderGui *gui; GtkDialog *dialog; - gboolean overwrite; - int dialog_result; - (void)button; + gint dialog_result; + gboolean overwrite = FALSE; - gui = RENDERER_GUI(user_data); - - /* Don't do anything if the selector is empty. */ - if (!layer_selector_contains_elements(gui->layer_selector)) - return; + g_return_val_if_fail(RENDERER_IS_GUI(gui), FALSE); /* Ask for overwrite */ dialog = GTK_DIALOG(gtk_message_dialog_new(gui->main_window, GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_QUESTION, @@ -720,6 +714,25 @@ static void auto_naming_clicked(GtkWidget *button, gpointer user_data) } gtk_widget_destroy(GTK_WIDGET(dialog)); + return overwrite; +} + +static void auto_naming_clicked(GtkWidget *button, gpointer user_data) +{ + GdsRenderGui *gui; + gboolean overwrite = FALSE; + (void)button; + + gui = RENDERER_GUI(user_data); + + /* Don't do anything if the selector is empty. */ + if (!layer_selector_contains_elements(gui->layer_selector)) + return; + + /* Ask, if names shall be overwritten, if they are not empty */ + if (layer_selector_num_of_named_elements(gui->layer_selector) > 0) + overwrite = auto_naming_ask_for_override(gui); + layer_selector_auto_name_layers(gui->layer_selector, overwrite); } diff --git a/include/gds-render/layer/layer-selector.h b/include/gds-render/layer/layer-selector.h index a3d7535..d4a6871 100644 --- a/include/gds-render/layer/layer-selector.h +++ b/include/gds-render/layer/layer-selector.h @@ -130,6 +130,13 @@ void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean ove */ gboolean layer_selector_contains_elements(LayerSelector *layer_selector); +/** + * @brief Get number of layer elements that are named + * @param[in] layer_selector Layer selector + * @return Number of layers with a name != NULL or != "" + */ +size_t layer_selector_num_of_named_elements(LayerSelector *layer_selector); + G_END_DECLS #endif /* __LAYER_SELECTOR_H__ */ diff --git a/include/gds-render/output-renderers/cairo-renderer.h b/include/gds-render/output-renderers/cairo-renderer.h index cceb692..78cec69 100644 --- a/include/gds-render/output-renderers/cairo-renderer.h +++ b/include/gds-render/output-renderers/cairo-renderer.h @@ -38,7 +38,7 @@ G_DECLARE_FINAL_TYPE(CairoRenderer, cairo_renderer, GDS_RENDER, CAIRO_RENDERER, #define GDS_RENDER_TYPE_CAIRO_RENDERER (cairo_renderer_get_type()) -#define MAX_LAYERS (300) /**< \brief Maximum layer count the output renderer can process. Typically GDS only specifies up to 255 layers.*/ +#define MAX_LAYERS (5000) /**< \brief Maximum layer count the output renderer can process. Typically GDS only specifies up to 255 layers.*/ /** * @brief Create new CairoRenderer for SVG output diff --git a/layer/layer-selector.c b/layer/layer-selector.c index 4111731..0872c9c 100644 --- a/layer/layer-selector.c +++ b/layer/layer-selector.c @@ -822,12 +822,10 @@ void layer_selector_auto_color_layers(LayerSelector *layer_selector, ColorPalett unsigned int color_count; GdkRGBA color; - if (GDS_RENDER_IS_COLOR_PALETTE(palette) == FALSE || LAYER_IS_SELECTOR(layer_selector) == FALSE) - return; - if (global_alpha <= 0) - return; - if (GTK_IS_LIST_BOX(layer_selector->list_box) == FALSE) - return; + g_return_if_fail(GDS_RENDER_IS_COLOR_PALETTE(palette)); + g_return_if_fail(LAYER_IS_SELECTOR(layer_selector)); + g_return_if_fail(global_alpha > 0); + g_return_if_fail(GTK_IS_LIST_BOX(layer_selector->list_box)); le_list = gtk_container_get_children(GTK_CONTAINER(layer_selector->list_box)); @@ -898,4 +896,31 @@ gboolean layer_selector_contains_elements(LayerSelector *layer_selector) return (layer_element_list ? TRUE : FALSE); } +size_t layer_selector_num_of_named_elements(LayerSelector *layer_selector) +{ + GList *le_list; + GList *le_list_ptr; + LayerElement *le; + const char *layer_name; + size_t count = 0U; + + g_return_val_if_fail(LAYER_IS_SELECTOR(layer_selector), 0U); + + le_list = gtk_container_get_children(GTK_CONTAINER(layer_selector->list_box)); + + for (le_list_ptr = le_list; le_list_ptr != NULL; le_list_ptr = g_list_next(le_list_ptr)) { + le = LAYER_ELEMENT(le_list_ptr->data); + if (!le) + continue; + layer_name = layer_element_get_name(le); + + if (layer_name && *layer_name) { + /* Layer name is not empty. Count it */ + count++; + } + } + + return count; +} + /** @} */ diff --git a/output-renderers/cairo-renderer.c b/output-renderers/cairo-renderer.c index 28abcf8..753eeb8 100644 --- a/output-renderers/cairo-renderer.c +++ b/output-renderers/cairo-renderer.c @@ -371,8 +371,6 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer for (info_list = layer_infos; info_list != NULL; info_list = g_list_next(info_list)) { linfo = (struct layer_info *)info_list->data; - dprintf(comm_pipe[1], _("Exporting layer %d to file\n"), linfo->layer); - if (linfo->layer >= MAX_LAYERS) { printf(_("Layer outside of spec.\n")); continue; @@ -381,6 +379,8 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer if (!linfo->render) continue; + dprintf(comm_pipe[1], _("Exporting layer %d to file\n"), linfo->layer); + 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); diff --git a/resources/layer-widget.glade b/resources/layer-widget.glade index 3b20036..99e0d70 100644 --- a/resources/layer-widget.glade +++ b/resources/layer-widget.glade @@ -1,26 +1,26 @@ - + 1 1 - 0.01 - 0.10000000000000001 + 0.01 + 0.10 True - False + False 3 True - False + False True - False - gtk-justify-fill + False + open-menu-symbolic @@ -33,7 +33,7 @@ True - False + False label @@ -45,9 +45,9 @@ True - True - True - True + True + True + True Select Layer Color and Opacity rgb(0,0,0) @@ -61,9 +61,9 @@ Export Layer True - True - False - True + True + False + True False @@ -74,7 +74,7 @@ True - True + True True diff --git a/resources/main.glade b/resources/main.glade index c55f964..1650a30 100644 --- a/resources/main.glade +++ b/resources/main.glade @@ -1,145 +1,57 @@ - + True - False - gtk-edit + False + format-text-rich-symbolic True - False - gtk-select-color - - - True - False - gtk-open - - - True - False - Save the current layer configuration to CSV - gtk-save-as + False + color-select-symbolic True - False - gtk-apply + False + emblem-ok-symbolic True - False - gtk-sort-ascending + False + view-sort-descending-symbolic True - False - gtk-sort-descending + False + view-sort-ascending-symbolic - 250 - False - gds-render - - - header - True - False - GDS-Render - True - - - gtk-open - True - True - True - Open GDS2 Database - True - True - - - - - - Load Mapping - True - False - True - True - Load the current layer configuration from CSV - load-mapping-img - True - - - - 1 - - - - - Save Mapping - True - False - True - True - save-mapping-img - True - - - - 2 - - - - - gtk-convert - button-convert - True - False - True - True - Convert selected cell - True - True - - - - 3 - - - - + 250 + False + gds-render True - False + False vertical True - False + False True - False + False vertical True - True - edit-find-symbolic - False - False + True + edit-find-symbolic + False + False False @@ -150,15 +62,15 @@ True - True - never - in + True + never + in True - True - False - both + True + False + both @@ -181,20 +93,20 @@ True - False + False vertical True - False + False True - True - True - Sort layers ascending + True + True + Sort layers ascending sort-up-img - True + True False @@ -205,11 +117,11 @@ True - True - True - Sort layers descending + True + True + Sort layers descending sort-down-img - True + True False @@ -220,11 +132,11 @@ True - True - True - Automatically color layers + True + True + Automatically color layers color-img - True + True False @@ -235,11 +147,11 @@ True - True - True - Select all layers for export + True + True + Select all layers for export select-all-img - True + True False @@ -250,11 +162,11 @@ True - True - True - Automatically name layers + True + True + Automatically name layers auto-name-img - True + True False @@ -272,19 +184,19 @@ True - True - 1 - never - in + True + 1 + never + in True - False + False True - False - none + False + none @@ -313,7 +225,7 @@ True - False + False vertical @@ -327,5 +239,75 @@ + + + header + True + False + GDS-Render + True + + + Open GDS + True + True + True + Open GDS2 Database + + + + + + Load Mapping + True + False + True + True + Load the current layer configuration from CSV + + + + 1 + + + + + Save Mapping + True + False + True + True + + + + 2 + + + + + Convert Cell + button-convert + True + False + True + True + Convert selected cell + True + + + + 3 + + + +