32#include <glib/gi18n.h>
86G_DEFINE_TYPE(GdsRenderGui, gds_render_gui, G_TYPE_OBJECT)
100 self = RENDERER_GUI(user);
106 g_clear_object(&self->main_window);
107 gtk_widget_destroy(GTK_WIDGET(window));
129 gboolean path_currently_selected,
134 unsigned int error_level;
135 gboolean ret = FALSE;
137 (void)path_currently_selected;
140 gtk_tree_model_get_iter(model, &iter, path);
160 GdsRenderGui *self = RENDERER_GUI(data);
163 gtk_tree_model_filter_refilter(self->cell_filter);
179 gboolean result = FALSE;
180 const char *search_string;
182 self = RENDERER_GUI(data);
183 g_return_val_if_fail(RENDERER_IS_GUI(self), FALSE);
199 search_string = gtk_entry_get_text(GTK_ENTRY(self->cell_search_entry));
202 if (!strlen(search_string))
205 if (strstr(cell->
name, search_string))
208 gtk_tree_view_expand_all(self->cell_tree_view);
221 GtkCellRenderer *render_lib;
222 GtkTreeViewColumn *column;
225 G_TYPE_POINTER, G_TYPE_UINT);
228 self->cell_filter = GTK_TREE_MODEL_FILTER(
229 gtk_tree_model_filter_new(GTK_TREE_MODEL(self->cell_tree_store), NULL));
231 gtk_tree_model_filter_set_visible_func(self->cell_filter,
234 g_signal_connect(GTK_SEARCH_ENTRY(self->cell_search_entry),
"search-changed",
237 gtk_tree_view_set_model(self->cell_tree_view, GTK_TREE_MODEL(self->cell_filter));
242 column = gtk_tree_view_column_new_with_attributes(_(
"Library"), render_lib,
"gds-lib",
CELL_SEL_LIBRARY, NULL);
243 gtk_tree_view_append_column(self->cell_tree_view, column);
247 gtk_tree_view_append_column(self->cell_tree_view, column);
252 gtk_tree_selection_set_select_function(gtk_tree_view_get_selection(self->cell_tree_view),
267 GtkTreeIter celliter;
272 GtkWidget *open_dialog;
273 GtkFileChooser *file_chooser;
274 GtkFileFilter *filter;
275 GtkStyleContext *button_style;
279 unsigned int cell_error_level;
281 self = RENDERER_GUI(user);
285 open_dialog = gtk_file_chooser_dialog_new(_(
"Open GDSII File"), self->main_window,
286 GTK_FILE_CHOOSER_ACTION_OPEN,
287 _(
"Cancel"), GTK_RESPONSE_CANCEL,
288 _(
"Open GDSII"), GTK_RESPONSE_ACCEPT,
290 file_chooser = GTK_FILE_CHOOSER(open_dialog);
293 filter = gtk_file_filter_new();
294 gtk_file_filter_add_pattern(filter,
"*.gds");
295 gtk_file_filter_set_name(filter, _(
"GDSII-Files"));
296 gtk_file_chooser_add_filter(file_chooser, filter);
298 dialog_result = gtk_dialog_run(GTK_DIALOG(open_dialog));
300 if (dialog_result != GTK_RESPONSE_ACCEPT)
304 filename = gtk_file_chooser_get_filename(file_chooser);
306 gtk_tree_store_clear(self->cell_tree_store);
318 button_style = gtk_widget_get_style_context(GTK_WIDGET(button));
319 gtk_style_context_remove_class(button_style,
"suggested-action");
321 for (lib = self->gds_libraries; lib != NULL; lib = lib->next) {
324 gtk_tree_store_append(self->cell_tree_store, &libiter, NULL);
326 gtk_tree_store_set(self->cell_tree_store, &libiter,
334 for (cell = gds_lib->
cells; cell != NULL; cell = cell->next) {
335 gds_c = (
struct gds_cell *)cell->data;
336 gtk_tree_store_append(self->cell_tree_store, &celliter, &libiter);
339 cell_error_level = 0;
348 gtk_tree_store_set(self->cell_tree_store, &celliter,
361 gtk_widget_destroy(open_dialog);
366 gboolean convert_button_state = FALSE;
367 gboolean open_gds_button_state = FALSE;
370 if (!self->button_state_data.rendering_active) {
371 open_gds_button_state = TRUE;
372 if (self->button_state_data.valid_cell_selected)
373 convert_button_state = TRUE;
377 gtk_widget_set_sensitive(self->convert_button, convert_button_state);
378 gtk_widget_set_sensitive(self->open_button, open_gds_button_state);
391 self = RENDERER_GUI(user);
399 self = RENDERER_GUI(gui);
401 self->button_state_data.rendering_active = FALSE;
405 g_object_unref(renderer);
409 const char *status_message,
415 gui = RENDERER_GUI(data);
429 GtkTreeSelection *selection;
434 RendererSettingsDialog *settings;
435 GtkFileFilter *filter;
439 unsigned int height, width;
441 LayerSettings *layer_settings;
442 GdsOutputRenderer *render_engine;
444 self = RENDERER_GUI(user);
450 if (self->button_state_data.rendering_active == TRUE)
453 sett = &self->render_dialog_settings;
456 selection = gtk_tree_view_get_selection(self->cell_tree_view);
457 if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE)
460 gtk_tree_model_get(model, &iter,
CELL_SEL_CELL, &cell_to_render, -1);
485 g_object_set(G_OBJECT(settings),
"cell-name", cell_to_render->
name, NULL);
487 res = gtk_dialog_run(GTK_DIALOG(settings));
488 if (res == GTK_RESPONSE_OK) {
490 gtk_widget_destroy(GTK_WIDGET(settings));
492 gtk_widget_destroy(GTK_WIDGET(settings));
493 goto ret_layer_destroy;
498 ?
"Save LaTeX File" :
"Save PDF"),
499 GTK_WINDOW(self->main_window), GTK_FILE_CHOOSER_ACTION_SAVE,
500 "Cancel", GTK_RESPONSE_CANCEL,
"Save", GTK_RESPONSE_ACCEPT, NULL);
502 filter = gtk_file_filter_new();
505 gtk_file_filter_add_pattern(filter,
"*.tex");
506 gtk_file_filter_set_name(filter,
"LaTeX-Files");
509 gtk_file_filter_add_pattern(filter,
"*.pdf");
510 gtk_file_filter_set_name(filter,
"PDF-Files");
513 gtk_file_filter_add_pattern(filter,
"*.svg");
514 gtk_file_filter_set_name(filter,
"SVG-Files");
518 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
520 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
522 res = gtk_dialog_run(GTK_DIALOG(dialog));
523 if (res == GTK_RESPONSE_ACCEPT) {
524 file_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
525 gtk_widget_destroy(dialog);
541 render_engine = NULL;
549 self->button_state_data.rendering_active = TRUE;
557 g_signal_connect(render_engine,
"progress-changed",
563 gtk_widget_destroy(dialog);
566 g_object_unref(layer_settings);
577 GtkTreeViewColumn *column, gpointer user)
596 GtkTreeModel *model = NULL;
599 if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
601 self->button_state_data.valid_cell_selected = TRUE;
603 self->button_state_data.valid_cell_selected = FALSE;
614 self = RENDERER_GUI(user);
625 self = RENDERER_GUI(user);
635 self = RENDERER_GUI(gobject);
639 g_clear_object(&self->cell_tree_view);
640 g_clear_object(&self->convert_button);
641 g_clear_object(&self->layer_selector);
642 g_clear_object(&self->cell_tree_store);
643 g_clear_object(&self->cell_filter);
644 g_clear_object(&self->cell_search_entry);
645 g_clear_object(&self->activity_status_bar);
646 g_clear_object(&self->palette);
647 g_clear_object(&self->load_layer_button);
648 g_clear_object(&self->save_layer_button);
649 g_clear_object(&self->open_button);
650 g_clear_object(&self->select_all_button);
652 if (self->main_window) {
653 g_signal_handlers_destroy(self->main_window);
654 gtk_widget_destroy(GTK_WIDGET(self->main_window));
655 self->main_window = NULL;
659 G_OBJECT_CLASS(gds_render_gui_parent_class)->dispose(gobject);
664 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
668 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
690 gui = RENDERER_GUI(user_data);
698 gboolean overwrite = FALSE;
700 g_return_val_if_fail(RENDERER_IS_GUI(gui), FALSE);
703 dialog = GTK_DIALOG(gtk_message_dialog_new(gui->main_window, GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_QUESTION,
704 GTK_BUTTONS_YES_NO,
"Overwrite existing layer names?"));
705 dialog_result = gtk_dialog_run(dialog);
706 switch (dialog_result) {
707 case GTK_RESPONSE_YES:
710 case GTK_RESPONSE_NO:
715 gtk_widget_destroy(GTK_WIDGET(dialog));
723 gboolean overwrite = FALSE;
726 gui = RENDERER_GUI(user_data);
741 return gui->main_window;
746 GtkBuilder *main_builder;
748 GtkHeaderBar *header_bar;
749 GtkWidget *sort_up_button;
750 GtkWidget *sort_down_button;
751 GtkWidget *activity_bar_box;
752 GtkWidget *auto_color_button;
753 GtkWidget *auto_naming_button;
755 main_builder = gtk_builder_new_from_resource(
"/gui/main.glade");
757 self->cell_tree_view = GTK_TREE_VIEW(gtk_builder_get_object(main_builder,
"cell-tree"));
758 self->cell_search_entry = GTK_WIDGET(gtk_builder_get_object(main_builder,
"cell-search"));
762 self->main_window = GTK_WINDOW(gtk_builder_get_object(main_builder,
"main-window"));
763 self->open_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"button-load-gds"));
764 g_signal_connect(self->open_button,
765 "clicked", G_CALLBACK(
on_load_gds), (gpointer)self);
767 self->convert_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"convert-button"));
768 g_signal_connect(self->convert_button,
"clicked", G_CALLBACK(
on_convert_clicked), (gpointer)self);
770 listbox = GTK_WIDGET(gtk_builder_get_object(main_builder,
"layer-list"));
774 activity_bar_box = GTK_WIDGET(gtk_builder_get_object(main_builder,
"activity-bar"));
777 g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(self->cell_tree_view)),
"changed",
782 header_bar = GTK_HEADER_BAR(gtk_builder_get_object(main_builder,
"header-bar"));
786 sort_up_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"button-up-sort"));
787 sort_down_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"button-down-sort"));
789 g_signal_connect(sort_up_button,
"clicked", G_CALLBACK(
sort_up_callback), self);
793 self->load_layer_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"button-load-mapping"));
794 self->save_layer_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"button-save-mapping"));
799 g_signal_connect(GTK_WIDGET(self->main_window),
"delete-event",
804 gtk_container_add(GTK_CONTAINER(activity_bar_box), GTK_WIDGET(self->activity_status_bar));
805 gtk_widget_show(GTK_WIDGET(self->activity_status_bar));
809 auto_color_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"auto-color-button"));
814 self->render_dialog_settings.scale = 1000;
816 self->render_dialog_settings.tex_pdf_layers = FALSE;
817 self->render_dialog_settings.tex_standalone = FALSE;
820 self->select_all_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"button-select-all"));
824 auto_naming_button = GTK_WIDGET(gtk_builder_get_object(main_builder,
"button-auto-name"));
827 g_object_unref(main_builder);
830 self->button_state_data.rendering_active = FALSE;
831 self->button_state_data.valid_cell_selected = FALSE;
834 g_object_ref(self->activity_status_bar);
835 g_object_ref(self->main_window);
836 g_object_ref(self->cell_tree_view);
837 g_object_ref(self->convert_button);
839 g_object_ref(self->cell_search_entry);
841 g_object_ref(self->open_button);
842 g_object_ref(self->load_layer_button);
843 g_object_ref(self->save_layer_button);
844 g_object_ref(self->select_all_button);
Header file for activity bar widget.
Header File for Cairo output renderer.
Calculation of gds_cell geometrics.
ColorPalette * color_palette_new_from_resource(char *resource_name)
Create a new object with from a resource containing the html hex color scheme.
Header file for the Conversion Settings Dialog.
Header file for the GDS-Parser.
Header for GdsRenderGui Object.
Checking functions of a cell tree (Header)
void activity_bar_set_ready(ActivityBar *bar)
Deletes all applied tasks and sets bar to "Ready".
ActivityBar * activity_bar_new()
Create new Object ActivityBar.
void activity_bar_set_busy(ActivityBar *bar, const char *text)
Enable spinner and set text. If text is NULL, 'Working...' is displayed.
static void render_cell(struct gds_cell *cell, struct cairo_layer *layers, double scale)
render_cell Render a cell with its sub-cells
CairoRenderer * cairo_renderer_new_pdf()
Create new CairoRenderer for PDF output.
CairoRenderer * cairo_renderer_new_svg()
Create new CairoRenderer for SVG output.
int gds_tree_check_reference_loops(struct gds_library *lib)
gds_tree_check_reference_loops checks if the given library contains reference loops
int gds_tree_check_cell_references(struct gds_library *lib)
gds_tree_check_cell_references checks if all child cell references can be resolved in the given libra...
int clear_lib_list(GList **library_list)
Deletes all libraries including cells, references etc.
int parse_gds_from_file(const char *filename, GList **library_list)
Parse a GDS file.
static void process_button_state_changes(GdsRenderGui *self)
static guint gds_render_gui_signals[SIGNAL_COUNT]
static void gds_render_gui_init(GdsRenderGui *self)
static void gds_render_gui_class_init(GdsRenderGuiClass *klass)
cell_store_columns
Columns of selection tree view.
gds_render_gui_signal_sig_ids
static void async_rendering_finished_callback(GdsOutputRenderer *renderer, gpointer gui)
static void async_rendering_status_update_callback(GdsOutputRenderer *renderer, const char *status_message, gpointer data)
static gboolean cell_store_filter_visible_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
cell_store_filter_visible_func Decides whether an element of the tree model model is visible.
static void cell_selection_changed(GtkTreeSelection *sel, GdsRenderGui *self)
Callback for cell-selection change event.
#define RENDERER_TYPE_GUI
static void sort_up_callback(GtkWidget *widget, gpointer user)
static void on_convert_clicked(gpointer button, gpointer user)
Convert button callback.
static gboolean auto_naming_ask_for_override(GdsRenderGui *gui)
static void cell_tree_view_activated(gpointer tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user)
cell_tree_view_activated Callback for 'double click' on cell selector element
GtkWindow * gds_render_gui_get_main_window(GdsRenderGui *gui)
Get main window.
static void gds_render_gui_dispose(GObject *gobject)
static void on_load_gds(gpointer button, gpointer user)
Callback function of Load GDS button.
static void on_auto_color_clicked(gpointer button, gpointer user)
Callback for auto coloring button.
static void on_select_all_layers_clicked(GtkWidget *button, gpointer user_data)
Callback for the 'select all layers'-button.
GdsRenderGui * gds_render_gui_new()
Create new GdsRenderGui Object.
static void cell_tree_view_change_filter(GtkWidget *entry, gpointer data)
Trigger refiltering of cell filter.
int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
Setup a GtkTreeView with the necessary columns.
static gboolean on_window_close(gpointer window, GdkEvent *event, gpointer user)
Main window close event.
static void sort_down_callback(GtkWidget *widget, gpointer user)
static void auto_naming_clicked(GtkWidget *button, gpointer user_data)
static gboolean tree_sel_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data)
This function only allows valid cells to be selected.
@ CELL_SEL_CELL_ERROR_STATE
@ CELL_SEL_COLUMN_COUNT
Not a column. Used to determine count of columns.
int gds_output_renderer_render_output_async(GdsOutputRenderer *renderer, struct gds_cell *cell, double scale)
Render output asynchronously.
void gds_output_renderer_set_output_file(GdsOutputRenderer *renderer, const gchar *file_name)
Convenience function for setting the "output-file" property.
void gds_output_renderer_set_layer_settings(GdsOutputRenderer *renderer, LayerSettings *settings)
Set layer settings.
LatexRenderer * latex_renderer_new_with_options(gboolean pdf_layers, gboolean standalone)
Create new LatexRenderer object.
GtkCellRenderer * lib_cell_renderer_new()
Create a new renderer for renderering gds_cell and gds_library elements.
#define LIB_CELL_RENDERER_ERROR_ERR
#define LIB_CELL_RENDERER_ERROR_WARN
void renderer_settings_dialog_get_settings(RendererSettingsDialog *dialog, struct render_settings *settings)
Get the settings configured in the dialog.
void renderer_settings_dialog_set_cell_height(RendererSettingsDialog *dialog, unsigned int height)
renderer_settings_dialog_set_cell_height Set height for rendered cell
void renderer_settings_dialog_set_database_unit_scale(RendererSettingsDialog *dialog, double unit_in_meters)
renderer_settings_dialog_set_database_unit_scale Set database scale
G_END_DECLS void renderer_settings_dialog_set_settings(RendererSettingsDialog *dialog, struct render_settings *settings)
Apply settings to dialog.
void renderer_settings_dialog_set_cell_width(RendererSettingsDialog *dialog, unsigned int width)
renderer_settings_dialog_set_cell_width Set width for rendered cell
RendererSettingsDialog * renderer_settings_dialog_new(GtkWindow *parent)
Create a new RedererSettingsDialog GObject.
@ RENDERER_CAIROGRAPHICS_PDF
@ RENDERER_CAIROGRAPHICS_SVG
void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell)
Calculate bounding box of a gds cell.
void bounding_box_prepare_empty(union bounding_box *box)
Prepare an empty bounding box.
void layer_selector_force_sort(LayerSelector *selector, enum layer_selector_sort_algo sort_function)
Force the layer selector list to be sorted according to sort_function.
void layer_selector_generate_layer_widgets(LayerSelector *selector, GList *libs)
Generate layer widgets in in the LayerSelector instance.
void layer_selector_set_load_mapping_button(LayerSelector *selector, GtkWidget *button, GtkWindow *main_window)
Supply button for loading the layer mapping.
void layer_selector_select_all_layers(LayerSelector *layer_selector, gboolean select)
Set 'export' value of all layers in the LayerSelector to the supplied select value.
LayerSettings * layer_selector_export_rendered_layer_info(LayerSelector *selector)
Get a list of all layers that shall be exported when rendering the cells.
void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean overwrite)
Auto name all layers in the layer selector.
void layer_selector_set_save_mapping_button(LayerSelector *selector, GtkWidget *button, GtkWindow *main_window)
Supply button for saving the layer mapping.
LayerSelector * layer_selector_new(GtkListBox *list_box)
layer_selector_new
gboolean layer_selector_contains_elements(LayerSelector *layer_selector)
Check if the given layer selector contains layer elements.
size_t layer_selector_num_of_named_elements(LayerSelector *layer_selector)
Get number of layer elements that are named.
void layer_selector_auto_color_layers(LayerSelector *layer_selector, ColorPalette *palette, double global_alpha)
Apply colors from palette to all layers. Aditionally set alpha.
@ LAYER_SELECTOR_SORT_DOWN
const char * _app_version_string
This string holds the Git Based Version Number of the app.
Implementation of the Layer selection list.
Header file for the LibCellRenderer GObject Class.
GtkTreeView * cell_tree_view
GtkWidget * cell_search_entry
struct gui_button_states button_state_data
struct render_settings render_dialog_settings
LayerSelector * layer_selector
ActivityBar * activity_status_bar
GtkWidget * select_all_button
GtkWidget * convert_button
GtkTreeStore * cell_tree_store
GtkWidget * save_layer_button
GtkTreeModelFilter * cell_filter
GtkWidget * load_layer_button
struct vector_2d upper_right
Upper right point of the bounding box.
struct vector_2d lower_left
Lower left point of the bounding box.
int unresolved_child_count
Number of unresolved cell instances inside this cell. Default: GDS_CELL_CHECK_NOT_RUN.
int affected_by_reference_loop
1 if the cell is affected by a reference loop and therefore not renderable. Default: GDS_CELL_CHECK_N...
A Cell inside a gds_library.
struct gds_cell_checks checks
Checking results.
struct gds_library * parent_library
Pointer to parent library.
This struct holds the renderer configuration.
double scale
Scale image down by this factor.
enum output_renderer renderer
Union describing a bounding box.
struct bounding_box::_vectors vectors