2018-07-23 15:26:51 +02:00
|
|
|
/*
|
|
|
|
* GDSII-Converter
|
|
|
|
* Copyright (C) 2018 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-07-24 18:47:29 +02:00
|
|
|
/**
|
2019-03-15 20:02:03 +01:00
|
|
|
* @file gds-render-gui.c
|
2018-07-24 18:47:29 +02:00
|
|
|
* @brief Handling of GUI
|
|
|
|
* @author Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*/
|
|
|
|
|
2019-03-30 19:51:56 +01:00
|
|
|
/** @addtogroup GUI
|
2018-07-24 18:47:29 +02:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2018-07-23 13:10:34 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <gtk/gtk.h>
|
2019-10-18 23:25:27 +02:00
|
|
|
#include <glib/gi18n.h>
|
2019-03-26 19:57:19 +01:00
|
|
|
|
|
|
|
#include <gds-render/gds-render-gui.h>
|
|
|
|
#include <gds-render/gds-utils/gds-parser.h>
|
|
|
|
#include <gds-render/gds-utils/gds-tree-checker.h>
|
|
|
|
#include <gds-render/layer/layer-selector.h>
|
2019-05-28 20:59:16 +02:00
|
|
|
#include <gds-render/widgets/activity-bar.h>
|
2019-06-17 21:32:45 +02:00
|
|
|
#include <gds-render/cell-selector/lib-cell-renderer.h>
|
2019-08-20 19:05:14 +02:00
|
|
|
#include <gds-render/output-renderers/latex-renderer.h>
|
|
|
|
#include <gds-render/output-renderers/cairo-renderer.h>
|
2019-03-26 19:57:19 +01:00
|
|
|
#include <gds-render/widgets/conv-settings-dialog.h>
|
|
|
|
#include <gds-render/geometric/cell-geometrics.h>
|
|
|
|
#include <gds-render/version.h>
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-09-28 21:42:49 +02:00
|
|
|
/** @brief Columns of selection tree view */
|
|
|
|
enum cell_store_columns {
|
|
|
|
CELL_SEL_LIBRARY = 0,
|
|
|
|
CELL_SEL_CELL,
|
|
|
|
CELL_SEL_CELL_ERROR_STATE, /**< Used for cell color and selectability */
|
|
|
|
CELL_SEL_COLUMN_COUNT /**< @brief Not a column. Used to determine count of columns */
|
|
|
|
};
|
|
|
|
|
2019-03-16 16:09:29 +01:00
|
|
|
enum gds_render_gui_signal_sig_ids {SIGNAL_WINDOW_CLOSED = 0, SIGNAL_COUNT};
|
|
|
|
|
|
|
|
static guint gds_render_gui_signals[SIGNAL_COUNT];
|
|
|
|
|
2019-08-21 18:34:40 +02:00
|
|
|
struct gui_button_states {
|
|
|
|
gboolean rendering_active;
|
|
|
|
gboolean valid_cell_selected;
|
|
|
|
};
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
struct _GdsRenderGui {
|
|
|
|
/* Parent GObject */
|
|
|
|
GObject parent;
|
|
|
|
|
|
|
|
/* Custom fields */
|
2018-07-23 13:10:34 +02:00
|
|
|
GtkWindow *main_window;
|
2019-03-15 20:02:03 +01:00
|
|
|
GtkWidget *convert_button;
|
2019-08-21 18:34:40 +02:00
|
|
|
GtkWidget *open_button;
|
|
|
|
GtkWidget *load_layer_button;
|
|
|
|
GtkWidget *save_layer_button;
|
2019-08-25 22:11:36 +02:00
|
|
|
GtkWidget *select_all_button;
|
2019-03-15 20:02:03 +01:00
|
|
|
GtkTreeStore *cell_tree_store;
|
2019-09-28 21:42:49 +02:00
|
|
|
GtkTreeModelFilter *cell_filter;
|
2019-03-15 20:02:03 +01:00
|
|
|
GtkWidget *cell_search_entry;
|
2019-03-14 23:40:26 +01:00
|
|
|
LayerSelector *layer_selector;
|
2019-03-15 20:02:03 +01:00
|
|
|
GtkTreeView *cell_tree_view;
|
|
|
|
GList *gds_libraries;
|
2019-05-28 20:59:16 +02:00
|
|
|
ActivityBar *activity_status_bar;
|
2019-03-22 21:59:27 +01:00
|
|
|
struct render_settings render_dialog_settings;
|
2019-06-13 21:46:25 +02:00
|
|
|
ColorPalette *palette;
|
2019-08-21 18:34:40 +02:00
|
|
|
struct gui_button_states button_state_data;
|
2018-07-23 13:10:34 +02:00
|
|
|
};
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
G_DEFINE_TYPE(GdsRenderGui, gds_render_gui, G_TYPE_OBJECT)
|
|
|
|
|
2018-07-24 18:47:29 +02:00
|
|
|
/**
|
2019-03-25 18:47:12 +01:00
|
|
|
* @brief Main window close event
|
|
|
|
* @param window GtkWindow which is closed
|
|
|
|
* @param event unused event
|
|
|
|
* @param user GdsRenderGui instance
|
|
|
|
* @return Status of the event handling. Always true.
|
2018-07-24 18:47:29 +02:00
|
|
|
*/
|
2019-03-14 23:40:26 +01:00
|
|
|
static gboolean on_window_close(gpointer window, GdkEvent *event, gpointer user)
|
2018-07-23 13:10:34 +02:00
|
|
|
{
|
2019-03-15 20:02:03 +01:00
|
|
|
GdsRenderGui *self;
|
2019-08-26 20:01:32 +02:00
|
|
|
(void)event;
|
2019-03-15 20:02:03 +01:00
|
|
|
|
|
|
|
self = RENDERER_GUI(user);
|
|
|
|
/* Don't close window in case of error */
|
|
|
|
if (!self)
|
|
|
|
return TRUE;
|
2019-03-14 23:40:26 +01:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
/* Close Window. Leads to termination of the program/the current instance */
|
2019-03-15 20:36:23 +01:00
|
|
|
g_clear_object(&self->main_window);
|
2018-07-23 13:10:34 +02:00
|
|
|
gtk_widget_destroy(GTK_WIDGET(window));
|
2019-03-15 20:36:23 +01:00
|
|
|
|
2019-03-16 16:09:29 +01:00
|
|
|
/* Delete loaded library data */
|
|
|
|
clear_lib_list(&self->gds_libraries);
|
|
|
|
|
|
|
|
g_signal_emit(self, gds_render_gui_signals[SIGNAL_WINDOW_CLOSED], 0);
|
|
|
|
|
2018-07-23 13:10:34 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-09-28 21:42:49 +02:00
|
|
|
/**
|
2019-09-28 21:59:24 +02:00
|
|
|
* @brief This function only allows valid cells to be selected
|
2019-09-28 21:42:49 +02:00
|
|
|
* @param selection
|
|
|
|
* @param model
|
|
|
|
* @param path
|
|
|
|
* @param path_currently_selected
|
|
|
|
* @param data
|
|
|
|
* @return TRUE if element is selectable, FALSE if not
|
|
|
|
*/
|
|
|
|
static gboolean tree_sel_func(GtkTreeSelection *selection,
|
|
|
|
GtkTreeModel *model,
|
|
|
|
GtkTreePath *path,
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
struct gds_cell *cell;
|
|
|
|
unsigned int error_level;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
(void)selection;
|
|
|
|
(void)path_currently_selected;
|
|
|
|
(void)data;
|
|
|
|
|
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
|
gtk_tree_model_get(model, &iter, CELL_SEL_CELL, &cell, CELL_SEL_CELL_ERROR_STATE, &error_level, -1);
|
|
|
|
|
|
|
|
/* Allow only rows with _valid_ cell to be selected */
|
|
|
|
if (cell) {
|
|
|
|
/* Cell available. Check if it passed the critical checks */
|
|
|
|
if (!(error_level & LIB_CELL_RENDERER_ERROR_ERR))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-09-28 21:59:24 +02:00
|
|
|
/**
|
|
|
|
* @brief Trigger refiltering of cell filter
|
|
|
|
* @param entry Unused widget, that emitted the signal
|
|
|
|
* @param data GdsrenderGui self instance
|
|
|
|
*/
|
2019-09-28 21:42:49 +02:00
|
|
|
static void cell_tree_view_change_filter(GtkWidget *entry, gpointer data)
|
|
|
|
{
|
|
|
|
GdsRenderGui *self = RENDERER_GUI(data);
|
|
|
|
(void)entry;
|
|
|
|
|
|
|
|
gtk_tree_model_filter_refilter(self->cell_filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief cell_store_filter_visible_func Decides whether an element of the tree model @p model is visible.
|
|
|
|
* @param model Tree model
|
|
|
|
* @param iter Current element / iter in Model to check
|
|
|
|
* @param data Data. Set to static stores variable
|
|
|
|
* @return TRUE if visible, else FALSE
|
|
|
|
* @note TODO: Maybe implement Damerau-Levenshtein distance matching
|
|
|
|
*/
|
|
|
|
static gboolean cell_store_filter_visible_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
|
|
|
|
{
|
|
|
|
GdsRenderGui *self;
|
|
|
|
struct gds_cell *cell;
|
|
|
|
struct gds_library *lib;
|
|
|
|
gboolean result = FALSE;
|
|
|
|
const char *search_string;
|
|
|
|
|
|
|
|
self = RENDERER_GUI(data);
|
|
|
|
g_return_val_if_fail(RENDERER_IS_GUI(self), FALSE);
|
|
|
|
|
|
|
|
if (!model || !iter)
|
|
|
|
goto exit_filter;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, iter, CELL_SEL_CELL, &cell, CELL_SEL_LIBRARY, &lib, -1);
|
|
|
|
|
|
|
|
if (lib) {
|
|
|
|
result = TRUE;
|
|
|
|
goto exit_filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cell)
|
|
|
|
goto exit_filter;
|
|
|
|
|
2019-10-25 20:42:54 +02:00
|
|
|
search_string = gtk_entry_get_text(GTK_ENTRY(self->cell_search_entry));
|
2019-09-28 21:42:49 +02:00
|
|
|
|
|
|
|
/* Show all, if field is empty */
|
|
|
|
if (!strlen(search_string))
|
|
|
|
result = TRUE;
|
|
|
|
|
|
|
|
if (strstr(cell->name, search_string))
|
|
|
|
result = TRUE;
|
|
|
|
|
|
|
|
gtk_tree_view_expand_all(self->cell_tree_view);
|
|
|
|
|
|
|
|
exit_filter:
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Setup a GtkTreeView with the necessary columns
|
|
|
|
* @param self Current GUI object
|
|
|
|
*/
|
|
|
|
int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
|
|
|
|
{
|
|
|
|
GtkCellRenderer *render_cell;
|
|
|
|
GtkCellRenderer *render_lib;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
|
|
|
|
self->cell_tree_store = gtk_tree_store_new(CELL_SEL_COLUMN_COUNT, G_TYPE_POINTER,
|
2019-11-25 20:45:57 +01:00
|
|
|
G_TYPE_POINTER, G_TYPE_UINT);
|
2019-09-28 21:42:49 +02:00
|
|
|
|
|
|
|
/* Searching */
|
2019-10-25 20:42:54 +02:00
|
|
|
self->cell_filter = GTK_TREE_MODEL_FILTER(
|
|
|
|
gtk_tree_model_filter_new(GTK_TREE_MODEL(self->cell_tree_store), NULL));
|
|
|
|
|
2019-09-28 21:42:49 +02:00
|
|
|
gtk_tree_model_filter_set_visible_func(self->cell_filter,
|
|
|
|
(GtkTreeModelFilterVisibleFunc)cell_store_filter_visible_func,
|
|
|
|
self, NULL);
|
|
|
|
g_signal_connect(GTK_SEARCH_ENTRY(self->cell_search_entry), "search-changed",
|
|
|
|
G_CALLBACK(cell_tree_view_change_filter), self);
|
|
|
|
|
|
|
|
gtk_tree_view_set_model(self->cell_tree_view, GTK_TREE_MODEL(self->cell_filter));
|
|
|
|
|
|
|
|
render_cell = lib_cell_renderer_new();
|
|
|
|
render_lib = lib_cell_renderer_new();
|
|
|
|
|
2019-10-18 23:25:27 +02:00
|
|
|
column = gtk_tree_view_column_new_with_attributes(_("Library"), render_lib, "gds-lib", CELL_SEL_LIBRARY, NULL);
|
2019-09-28 21:42:49 +02:00
|
|
|
gtk_tree_view_append_column(self->cell_tree_view, column);
|
|
|
|
|
2019-10-18 23:25:27 +02:00
|
|
|
column = gtk_tree_view_column_new_with_attributes(_("Cell"), render_cell, "gds-cell", CELL_SEL_CELL,
|
2019-09-28 21:42:49 +02:00
|
|
|
"error-level", CELL_SEL_CELL_ERROR_STATE, NULL);
|
|
|
|
gtk_tree_view_append_column(self->cell_tree_view, column);
|
|
|
|
|
|
|
|
/* Callback for selection
|
2019-10-25 20:42:54 +02:00
|
|
|
* 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);
|
2019-09-28 21:42:49 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-07-24 18:47:29 +02:00
|
|
|
/**
|
|
|
|
* @brief Callback function of Load GDS button
|
|
|
|
* @param button
|
2019-03-25 18:47:12 +01:00
|
|
|
* @param user GdsRenderGui instance
|
2018-07-24 18:47:29 +02:00
|
|
|
*/
|
2018-07-23 13:10:34 +02:00
|
|
|
static void on_load_gds(gpointer button, gpointer user)
|
|
|
|
{
|
|
|
|
GList *cell;
|
|
|
|
GtkTreeIter libiter;
|
|
|
|
GtkTreeIter celliter;
|
|
|
|
GList *lib;
|
|
|
|
struct gds_library *gds_lib;
|
|
|
|
struct gds_cell *gds_c;
|
2019-03-15 20:02:03 +01:00
|
|
|
GdsRenderGui *self;
|
2018-07-23 13:10:34 +02:00
|
|
|
GtkWidget *open_dialog;
|
|
|
|
GtkFileChooser *file_chooser;
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
GtkStyleContext *button_style;
|
|
|
|
gint dialog_result;
|
|
|
|
int gds_result;
|
|
|
|
char *filename;
|
2019-03-06 20:07:26 +01:00
|
|
|
unsigned int cell_error_level;
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
self = RENDERER_GUI(user);
|
|
|
|
if (!self)
|
|
|
|
return;
|
|
|
|
|
2019-10-18 23:25:27 +02:00
|
|
|
open_dialog = gtk_file_chooser_dialog_new(_("Open GDSII File"), self->main_window,
|
2019-03-07 20:32:55 +01:00
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
2019-10-18 23:25:27 +02:00
|
|
|
_("Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("Open GDSII"), GTK_RESPONSE_ACCEPT,
|
2019-03-07 20:32:55 +01:00
|
|
|
NULL);
|
2018-07-23 13:10:34 +02:00
|
|
|
file_chooser = GTK_FILE_CHOOSER(open_dialog);
|
2019-03-30 19:51:56 +01:00
|
|
|
|
2018-07-23 13:10:34 +02:00
|
|
|
/* Add GDS II Filter */
|
|
|
|
filter = gtk_file_filter_new();
|
|
|
|
gtk_file_filter_add_pattern(filter, "*.gds");
|
2019-10-18 23:25:27 +02:00
|
|
|
gtk_file_filter_set_name(filter, _("GDSII-Files"));
|
2018-07-23 13:10:34 +02:00
|
|
|
gtk_file_chooser_add_filter(file_chooser, filter);
|
|
|
|
|
|
|
|
dialog_result = gtk_dialog_run(GTK_DIALOG(open_dialog));
|
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
if (dialog_result != GTK_RESPONSE_ACCEPT)
|
|
|
|
goto end_destroy;
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
/* Get File name */
|
|
|
|
filename = gtk_file_chooser_get_filename(file_chooser);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
gtk_tree_store_clear(self->cell_tree_store);
|
|
|
|
clear_lib_list(&self->gds_libraries);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
/* Parse new GDSII file */
|
2019-09-15 13:28:40 +02:00
|
|
|
gds_result = parse_gds_from_file(filename, &self->gds_libraries);
|
2019-03-22 22:24:48 +01:00
|
|
|
|
|
|
|
/* Delete file name afterwards */
|
|
|
|
g_free(filename);
|
|
|
|
if (gds_result)
|
|
|
|
goto end_destroy;
|
|
|
|
|
|
|
|
/* remove suggested action from Open button */
|
|
|
|
button_style = gtk_widget_get_style_context(GTK_WIDGET(button));
|
|
|
|
gtk_style_context_remove_class(button_style, "suggested-action");
|
|
|
|
|
|
|
|
for (lib = self->gds_libraries; lib != NULL; lib = lib->next) {
|
|
|
|
gds_lib = (struct gds_library *)lib->data;
|
|
|
|
/* Create top level iter */
|
|
|
|
gtk_tree_store_append(self->cell_tree_store, &libiter, NULL);
|
|
|
|
|
|
|
|
gtk_tree_store_set(self->cell_tree_store, &libiter,
|
|
|
|
CELL_SEL_LIBRARY, gds_lib,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
/* Check this library. This might take a while */
|
|
|
|
(void)gds_tree_check_cell_references(gds_lib);
|
|
|
|
(void)gds_tree_check_reference_loops(gds_lib);
|
|
|
|
|
|
|
|
for (cell = gds_lib->cells; cell != NULL; cell = cell->next) {
|
|
|
|
gds_c = (struct gds_cell *)cell->data;
|
|
|
|
gtk_tree_store_append(self->cell_tree_store, &celliter, &libiter);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
/* Get the checking results for this cell */
|
|
|
|
cell_error_level = 0;
|
|
|
|
if (gds_c->checks.unresolved_child_count)
|
|
|
|
cell_error_level |= LIB_CELL_RENDERER_ERROR_WARN;
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
/* Check if it is completely b0rken */
|
|
|
|
if (gds_c->checks.affected_by_reference_loop)
|
|
|
|
cell_error_level |= LIB_CELL_RENDERER_ERROR_ERR;
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
/* Add cell to tree store model */
|
|
|
|
gtk_tree_store_set(self->cell_tree_store, &celliter,
|
|
|
|
CELL_SEL_CELL, gds_c,
|
|
|
|
CELL_SEL_CELL_ERROR_STATE, cell_error_level,
|
2019-11-25 20:48:09 +01:00
|
|
|
CELL_SEL_LIBRARY, gds_c->parent_library,
|
2019-03-07 20:32:55 +01:00
|
|
|
-1);
|
2019-03-22 22:24:48 +01:00
|
|
|
} /* for cells */
|
|
|
|
} /* for libraries */
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-22 22:24:48 +01:00
|
|
|
/* Create Layers in Layer Box */
|
|
|
|
layer_selector_generate_layer_widgets(self->layer_selector, self->gds_libraries);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
|
|
|
end_destroy:
|
|
|
|
/* Destroy dialog and filter */
|
|
|
|
gtk_widget_destroy(open_dialog);
|
|
|
|
}
|
|
|
|
|
2019-08-21 19:30:52 +02:00
|
|
|
static void process_button_state_changes(GdsRenderGui *self)
|
|
|
|
{
|
|
|
|
gboolean convert_button_state = FALSE;
|
|
|
|
gboolean open_gds_button_state = FALSE;
|
|
|
|
|
|
|
|
/* Calculate states */
|
|
|
|
if (!self->button_state_data.rendering_active) {
|
|
|
|
open_gds_button_state = TRUE;
|
|
|
|
if (self->button_state_data.valid_cell_selected)
|
|
|
|
convert_button_state = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply states */
|
|
|
|
gtk_widget_set_sensitive(self->convert_button, convert_button_state);
|
|
|
|
gtk_widget_set_sensitive(self->open_button, open_gds_button_state);
|
|
|
|
}
|
|
|
|
|
2019-06-13 22:01:39 +02:00
|
|
|
/**
|
|
|
|
* @brief Callback for auto coloring button
|
|
|
|
* @param button
|
|
|
|
* @param user
|
|
|
|
*/
|
|
|
|
static void on_auto_color_clicked(gpointer button, gpointer user)
|
|
|
|
{
|
|
|
|
GdsRenderGui *self;
|
|
|
|
(void)button;
|
|
|
|
|
|
|
|
self = RENDERER_GUI(user);
|
|
|
|
layer_selector_auto_color_layers(self->layer_selector, self->palette, 1.0);
|
|
|
|
}
|
|
|
|
|
2019-08-21 19:30:52 +02:00
|
|
|
static void async_rendering_finished_callback(GdsOutputRenderer *renderer, gpointer gui)
|
|
|
|
{
|
|
|
|
GdsRenderGui *self;
|
|
|
|
|
|
|
|
self = RENDERER_GUI(gui);
|
|
|
|
|
|
|
|
self->button_state_data.rendering_active = FALSE;
|
|
|
|
process_button_state_changes(self);
|
|
|
|
activity_bar_set_ready(self->activity_status_bar);
|
|
|
|
|
|
|
|
g_object_unref(renderer);
|
|
|
|
}
|
|
|
|
|
2019-10-25 20:42:54 +02:00
|
|
|
static void async_rendering_status_update_callback(GdsOutputRenderer *renderer,
|
|
|
|
const char *status_message,
|
|
|
|
gpointer data)
|
2019-08-22 18:55:56 +02:00
|
|
|
{
|
|
|
|
GdsRenderGui *gui;
|
|
|
|
(void)renderer;
|
|
|
|
|
|
|
|
gui = RENDERER_GUI(data);
|
2019-08-22 19:31:47 +02:00
|
|
|
|
2019-08-22 18:55:56 +02:00
|
|
|
activity_bar_set_busy(gui->activity_status_bar, status_message);
|
|
|
|
}
|
|
|
|
|
2018-07-24 18:47:29 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert button callback
|
|
|
|
* @param button
|
|
|
|
* @param user
|
|
|
|
*/
|
2018-07-23 13:10:34 +02:00
|
|
|
static void on_convert_clicked(gpointer button, gpointer user)
|
|
|
|
{
|
2019-03-11 23:33:51 +01:00
|
|
|
(void)button;
|
2019-03-15 20:02:03 +01:00
|
|
|
GdsRenderGui *self;
|
2018-07-23 13:10:34 +02:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
struct gds_cell *cell_to_render;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
RendererSettingsDialog *settings;
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
gint res;
|
|
|
|
char *file_name;
|
2019-02-27 21:30:41 +01:00
|
|
|
union bounding_box cell_box;
|
2019-03-08 20:46:48 +01:00
|
|
|
unsigned int height, width;
|
2019-03-22 21:59:27 +01:00
|
|
|
struct render_settings *sett;
|
2019-08-20 19:05:14 +02:00
|
|
|
LayerSettings *layer_settings;
|
|
|
|
GdsOutputRenderer *render_engine;
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
self = RENDERER_GUI(user);
|
|
|
|
|
|
|
|
if (!self)
|
2019-03-11 23:33:51 +01:00
|
|
|
return;
|
|
|
|
|
2019-08-21 18:34:40 +02:00
|
|
|
/* Abort if rendering is already active */
|
|
|
|
if (self->button_state_data.rendering_active == TRUE)
|
|
|
|
return;
|
|
|
|
|
2019-03-22 21:59:27 +01:00
|
|
|
sett = &self->render_dialog_settings;
|
|
|
|
|
2018-07-23 13:10:34 +02:00
|
|
|
/* Get selected cell */
|
2019-03-15 20:02:03 +01:00
|
|
|
selection = gtk_tree_view_get_selection(self->cell_tree_view);
|
2018-07-23 13:10:34 +02:00
|
|
|
if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, &iter, CELL_SEL_CELL, &cell_to_render, -1);
|
|
|
|
|
|
|
|
if (!cell_to_render)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Get layers that are rendered */
|
2019-08-20 19:05:14 +02:00
|
|
|
layer_settings = layer_selector_export_rendered_layer_info(self->layer_selector);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2018-12-29 01:13:33 +01:00
|
|
|
/* Calculate cell size in DB units */
|
2019-02-27 21:30:41 +01:00
|
|
|
bounding_box_prepare_empty(&cell_box);
|
|
|
|
calculate_cell_bounding_box(&cell_box, cell_to_render);
|
|
|
|
|
2019-03-08 20:46:48 +01:00
|
|
|
/* Calculate size in database units
|
|
|
|
* Note that the results are bound to be positive,
|
2019-03-14 23:40:26 +01:00
|
|
|
* so casting them to unsigned int is absolutely valid
|
2019-03-08 20:46:48 +01:00
|
|
|
*/
|
|
|
|
height = (unsigned int)(cell_box.vectors.upper_right.y - cell_box.vectors.lower_left.y);
|
|
|
|
width = (unsigned int)(cell_box.vectors.upper_right.x - cell_box.vectors.lower_left.x);
|
2018-12-29 01:13:33 +01:00
|
|
|
|
|
|
|
/* Show settings dialog */
|
2019-03-15 20:02:03 +01:00
|
|
|
settings = renderer_settings_dialog_new(GTK_WINDOW(self->main_window));
|
2019-03-22 21:59:27 +01:00
|
|
|
renderer_settings_dialog_set_settings(settings, sett);
|
2019-03-04 20:14:21 +01:00
|
|
|
renderer_settings_dialog_set_database_unit_scale(settings, cell_to_render->parent_library->unit_in_meters);
|
2019-02-27 21:30:41 +01:00
|
|
|
renderer_settings_dialog_set_cell_height(settings, height);
|
|
|
|
renderer_settings_dialog_set_cell_width(settings, width);
|
2019-04-08 19:05:07 +02:00
|
|
|
g_object_set(G_OBJECT(settings), "cell-name", cell_to_render->name, NULL);
|
2019-02-27 21:30:41 +01:00
|
|
|
|
2018-07-23 13:10:34 +02:00
|
|
|
res = gtk_dialog_run(GTK_DIALOG(settings));
|
|
|
|
if (res == GTK_RESPONSE_OK) {
|
2019-03-22 21:59:27 +01:00
|
|
|
renderer_settings_dialog_get_settings(settings, sett);
|
2018-07-23 13:10:34 +02:00
|
|
|
gtk_widget_destroy(GTK_WIDGET(settings));
|
|
|
|
} else {
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(settings));
|
|
|
|
goto ret_layer_destroy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save file dialog */
|
2019-03-22 21:59:27 +01:00
|
|
|
dialog = gtk_file_chooser_dialog_new((sett->renderer == RENDERER_LATEX_TIKZ
|
2018-07-23 13:10:34 +02:00
|
|
|
? "Save LaTeX File" : "Save PDF"),
|
2019-03-15 20:02:03 +01:00
|
|
|
GTK_WINDOW(self->main_window), GTK_FILE_CHOOSER_ACTION_SAVE,
|
2018-07-23 13:10:34 +02:00
|
|
|
"Cancel", GTK_RESPONSE_CANCEL, "Save", GTK_RESPONSE_ACCEPT, NULL);
|
|
|
|
/* Set file filter according to settings */
|
|
|
|
filter = gtk_file_filter_new();
|
2019-03-22 21:59:27 +01:00
|
|
|
switch (sett->renderer) {
|
2018-07-30 12:35:30 +02:00
|
|
|
case RENDERER_LATEX_TIKZ:
|
2018-07-23 13:10:34 +02:00
|
|
|
gtk_file_filter_add_pattern(filter, "*.tex");
|
|
|
|
gtk_file_filter_set_name(filter, "LaTeX-Files");
|
2018-07-30 12:35:30 +02:00
|
|
|
break;
|
|
|
|
case RENDERER_CAIROGRAPHICS_PDF:
|
2018-07-23 13:10:34 +02:00
|
|
|
gtk_file_filter_add_pattern(filter, "*.pdf");
|
|
|
|
gtk_file_filter_set_name(filter, "PDF-Files");
|
2018-07-30 12:35:30 +02:00
|
|
|
break;
|
|
|
|
case RENDERER_CAIROGRAPHICS_SVG:
|
|
|
|
gtk_file_filter_add_pattern(filter, "*.svg");
|
|
|
|
gtk_file_filter_set_name(filter, "SVG-Files");
|
|
|
|
break;
|
2018-07-23 13:10:34 +02:00
|
|
|
}
|
2018-07-30 12:35:30 +02:00
|
|
|
|
2018-07-23 13:10:34 +02:00
|
|
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
|
|
|
|
|
2018-07-28 10:01:02 +02:00
|
|
|
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
|
|
|
|
|
2018-07-23 13:10:34 +02:00
|
|
|
res = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
|
|
if (res == GTK_RESPONSE_ACCEPT) {
|
|
|
|
file_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
|
2019-03-22 21:59:27 +01:00
|
|
|
switch (sett->renderer) {
|
2018-07-23 13:10:34 +02:00
|
|
|
case RENDERER_LATEX_TIKZ:
|
2019-08-20 19:05:14 +02:00
|
|
|
render_engine =
|
|
|
|
GDS_RENDER_OUTPUT_RENDERER(latex_renderer_new_with_options(sett->tex_pdf_layers,
|
|
|
|
sett->tex_standalone));
|
2018-07-23 13:10:34 +02:00
|
|
|
break;
|
2018-07-30 12:35:30 +02:00
|
|
|
case RENDERER_CAIROGRAPHICS_SVG:
|
2019-08-20 19:05:14 +02:00
|
|
|
render_engine = GDS_RENDER_OUTPUT_RENDERER(cairo_renderer_new_svg());
|
|
|
|
break;
|
2018-07-30 12:35:30 +02:00
|
|
|
case RENDERER_CAIROGRAPHICS_PDF:
|
2019-08-20 19:05:14 +02:00
|
|
|
render_engine = GDS_RENDER_OUTPUT_RENDERER(cairo_renderer_new_pdf());
|
|
|
|
break;
|
2019-08-22 19:37:26 +02:00
|
|
|
default:
|
|
|
|
/* Abort rendering */
|
|
|
|
render_engine = NULL;
|
|
|
|
break;
|
2018-07-23 13:10:34 +02:00
|
|
|
}
|
2019-08-20 19:05:14 +02:00
|
|
|
|
|
|
|
if (render_engine) {
|
|
|
|
gds_output_renderer_set_output_file(render_engine, file_name);
|
|
|
|
gds_output_renderer_set_layer_settings(render_engine, layer_settings);
|
2019-08-21 18:34:40 +02:00
|
|
|
/* Prevent user from overwriting library or triggering additional conversion */
|
|
|
|
self->button_state_data.rendering_active = TRUE;
|
2019-08-21 19:30:52 +02:00
|
|
|
process_button_state_changes(self);
|
2019-08-20 19:05:14 +02:00
|
|
|
|
2019-08-21 19:30:52 +02:00
|
|
|
g_signal_connect(render_engine, "async-finished", G_CALLBACK(async_rendering_finished_callback),
|
|
|
|
self);
|
|
|
|
|
|
|
|
activity_bar_set_busy(self->activity_status_bar, "Rendering cell...");
|
2019-08-22 18:55:56 +02:00
|
|
|
|
|
|
|
g_signal_connect(render_engine, "progress-changed",
|
|
|
|
G_CALLBACK(async_rendering_status_update_callback), self);
|
2019-08-21 19:30:52 +02:00
|
|
|
gds_output_renderer_render_output_async(render_engine, cell_to_render, sett->scale);
|
2019-08-20 19:05:14 +02:00
|
|
|
}
|
2018-07-23 13:10:34 +02:00
|
|
|
g_free(file_name);
|
|
|
|
} else {
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
}
|
|
|
|
ret_layer_destroy:
|
2019-08-20 19:05:14 +02:00
|
|
|
g_object_unref(layer_settings);
|
2018-07-23 13:10:34 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 23:33:51 +01:00
|
|
|
/**
|
2019-03-25 18:47:12 +01:00
|
|
|
* @brief cell_tree_view_activated Callback for 'double click' on cell selector element
|
|
|
|
* @param tree_view The tree view the event occured in
|
|
|
|
* @param path path to the selected row
|
|
|
|
* @param column The clicked column
|
|
|
|
* @param user pointer to GdsRenderGui object
|
2019-03-11 23:33:51 +01:00
|
|
|
*/
|
|
|
|
static void cell_tree_view_activated(gpointer tree_view, GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *column, gpointer user)
|
|
|
|
{
|
|
|
|
(void)tree_view;
|
|
|
|
(void)path;
|
|
|
|
(void)column;
|
|
|
|
|
|
|
|
on_convert_clicked(NULL, user);
|
|
|
|
}
|
|
|
|
|
2018-07-24 18:47:29 +02:00
|
|
|
/**
|
|
|
|
* @brief Callback for cell-selection change event
|
|
|
|
*
|
|
|
|
* This function activates/deactivates the convert button depending on whether
|
|
|
|
* a cell is selected for conversion or not
|
|
|
|
* @param sel
|
2019-03-15 20:02:03 +01:00
|
|
|
* @param self
|
2018-07-24 18:47:29 +02:00
|
|
|
*/
|
2019-03-15 20:02:03 +01:00
|
|
|
static void cell_selection_changed(GtkTreeSelection *sel, GdsRenderGui *self)
|
2018-07-23 13:10:34 +02:00
|
|
|
{
|
|
|
|
GtkTreeModel *model = NULL;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
|
|
|
|
/* Node selected. Show button */
|
2019-08-21 18:34:40 +02:00
|
|
|
self->button_state_data.valid_cell_selected = TRUE;
|
2018-07-23 13:10:34 +02:00
|
|
|
} else {
|
2019-08-21 18:34:40 +02:00
|
|
|
self->button_state_data.valid_cell_selected = FALSE;
|
2018-07-23 13:10:34 +02:00
|
|
|
}
|
2019-08-21 18:34:40 +02:00
|
|
|
|
|
|
|
process_button_state_changes(self);
|
2018-07-23 13:10:34 +02:00
|
|
|
}
|
|
|
|
|
2019-03-12 19:47:39 +01:00
|
|
|
static void sort_up_callback(GtkWidget *widget, gpointer user)
|
|
|
|
{
|
|
|
|
(void)widget;
|
2019-03-15 20:02:03 +01:00
|
|
|
GdsRenderGui *self;
|
2019-03-12 19:47:39 +01:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
self = RENDERER_GUI(user);
|
|
|
|
if (!self)
|
2019-03-14 23:40:26 +01:00
|
|
|
return;
|
2019-03-15 20:02:03 +01:00
|
|
|
layer_selector_force_sort(self->layer_selector, LAYER_SELECTOR_SORT_UP);
|
2019-03-12 19:47:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sort_down_callback(GtkWidget *widget, gpointer user)
|
|
|
|
{
|
|
|
|
(void)widget;
|
2019-03-15 20:02:03 +01:00
|
|
|
GdsRenderGui *self;
|
2019-03-12 19:47:39 +01:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
self = RENDERER_GUI(user);
|
|
|
|
if (!self)
|
2019-03-14 23:40:26 +01:00
|
|
|
return;
|
2019-03-15 20:02:03 +01:00
|
|
|
layer_selector_force_sort(self->layer_selector, LAYER_SELECTOR_SORT_DOWN);
|
2019-03-12 19:47:39 +01:00
|
|
|
}
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
static void gds_render_gui_dispose(GObject *gobject)
|
|
|
|
{
|
|
|
|
GdsRenderGui *self;
|
|
|
|
|
|
|
|
self = RENDERER_GUI(gobject);
|
|
|
|
|
2019-03-16 16:09:29 +01:00
|
|
|
clear_lib_list(&self->gds_libraries);
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
g_clear_object(&self->cell_tree_view);
|
|
|
|
g_clear_object(&self->convert_button);
|
|
|
|
g_clear_object(&self->layer_selector);
|
|
|
|
g_clear_object(&self->cell_tree_store);
|
2019-09-28 21:42:49 +02:00
|
|
|
g_clear_object(&self->cell_filter);
|
2019-03-15 20:02:03 +01:00
|
|
|
g_clear_object(&self->cell_search_entry);
|
2019-05-28 20:59:16 +02:00
|
|
|
g_clear_object(&self->activity_status_bar);
|
2019-06-13 21:46:25 +02:00
|
|
|
g_clear_object(&self->palette);
|
2019-08-21 18:34:40 +02:00
|
|
|
g_clear_object(&self->load_layer_button);
|
|
|
|
g_clear_object(&self->save_layer_button);
|
|
|
|
g_clear_object(&self->open_button);
|
2019-08-25 22:11:36 +02:00
|
|
|
g_clear_object(&self->select_all_button);
|
2019-03-15 20:02:03 +01:00
|
|
|
|
2019-03-15 20:36:23 +01:00
|
|
|
if (self->main_window) {
|
|
|
|
g_signal_handlers_destroy(self->main_window);
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(self->main_window));
|
|
|
|
self->main_window = NULL;
|
|
|
|
}
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
/* Chain up */
|
|
|
|
G_OBJECT_CLASS(gds_render_gui_parent_class)->dispose(gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gds_render_gui_class_init(GdsRenderGuiClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
|
|
|
|
|
2019-03-16 16:09:29 +01:00
|
|
|
gds_render_gui_signals[SIGNAL_WINDOW_CLOSED] =
|
|
|
|
g_signal_newv("window-closed", RENDERER_TYPE_GUI,
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
G_TYPE_NONE,
|
|
|
|
0,
|
|
|
|
NULL);
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
gobject_class->dispose = gds_render_gui_dispose;
|
|
|
|
}
|
|
|
|
|
2019-08-25 23:26:59 +02:00
|
|
|
/**
|
|
|
|
* @brief Callback for the 'select all layers'-button
|
|
|
|
* @param button Button that triggered the event
|
|
|
|
* @param user_data the GdsrenderGui object containing the main-window the button is placed in
|
|
|
|
*/
|
2019-08-25 22:11:36 +02:00
|
|
|
static void on_select_all_layers_clicked(GtkWidget *button, gpointer user_data)
|
|
|
|
{
|
|
|
|
GdsRenderGui *gui;
|
2019-08-25 23:24:24 +02:00
|
|
|
(void)button;
|
2019-08-25 22:11:36 +02:00
|
|
|
|
|
|
|
gui = RENDERER_GUI(user_data);
|
2019-08-25 23:24:24 +02:00
|
|
|
layer_selector_select_all_layers(gui->layer_selector, TRUE);
|
2019-08-25 22:11:36 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 17:58:39 +02:00
|
|
|
static void auto_naming_clicked(GtkWidget *button, gpointer user_data)
|
|
|
|
{
|
|
|
|
GdsRenderGui *gui;
|
2019-08-29 18:31:53 +02:00
|
|
|
GtkDialog *dialog;
|
|
|
|
gboolean overwrite;
|
|
|
|
int dialog_result;
|
|
|
|
(void)button;
|
2019-08-29 17:58:39 +02:00
|
|
|
|
|
|
|
gui = RENDERER_GUI(user_data);
|
2019-08-29 18:31:53 +02:00
|
|
|
|
2019-11-09 02:21:57 +01:00
|
|
|
/* Don't do anything if the selector is empty. */
|
|
|
|
if (!layer_selector_contains_elements(gui->layer_selector))
|
|
|
|
return;
|
|
|
|
|
2019-08-29 18:31:53 +02:00
|
|
|
/* Ask for overwrite */
|
|
|
|
dialog = GTK_DIALOG(gtk_message_dialog_new(gui->main_window, GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_QUESTION,
|
|
|
|
GTK_BUTTONS_YES_NO, "Overwrite existing layer names?"));
|
|
|
|
dialog_result = gtk_dialog_run(dialog);
|
|
|
|
switch (dialog_result) {
|
|
|
|
case GTK_RESPONSE_YES:
|
|
|
|
overwrite = TRUE;
|
|
|
|
break;
|
|
|
|
case GTK_RESPONSE_NO: /* Expected fallthrough */
|
|
|
|
default:
|
|
|
|
overwrite = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(dialog));
|
|
|
|
|
|
|
|
layer_selector_auto_name_layers(gui->layer_selector, overwrite);
|
2019-08-29 17:58:39 +02:00
|
|
|
}
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui)
|
|
|
|
{
|
|
|
|
return gui->main_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gds_render_gui_init(GdsRenderGui *self)
|
2018-07-23 13:10:34 +02:00
|
|
|
{
|
|
|
|
GtkBuilder *main_builder;
|
|
|
|
GtkWidget *listbox;
|
2019-03-11 10:36:02 +01:00
|
|
|
GtkHeaderBar *header_bar;
|
2019-03-12 19:47:39 +01:00
|
|
|
GtkWidget *sort_up_button;
|
|
|
|
GtkWidget *sort_down_button;
|
2019-05-28 20:59:16 +02:00
|
|
|
GtkWidget *activity_bar_box;
|
2019-06-13 22:01:39 +02:00
|
|
|
GtkWidget *auto_color_button;
|
2019-08-29 17:58:39 +02:00
|
|
|
GtkWidget *auto_naming_button;
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-05-20 19:18:01 +02:00
|
|
|
main_builder = gtk_builder_new_from_resource("/gui/main.glade");
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
self->cell_tree_view = GTK_TREE_VIEW(gtk_builder_get_object(main_builder, "cell-tree"));
|
|
|
|
self->cell_search_entry = GTK_WIDGET(gtk_builder_get_object(main_builder, "cell-search"));
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-09-28 21:42:49 +02:00
|
|
|
gds_render_gui_setup_cell_selector(self);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
self->main_window = GTK_WINDOW(gtk_builder_get_object(main_builder, "main-window"));
|
2019-08-21 18:34:40 +02:00
|
|
|
self->open_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-load-gds"));
|
|
|
|
g_signal_connect(self->open_button,
|
2019-03-15 20:02:03 +01:00
|
|
|
"clicked", G_CALLBACK(on_load_gds), (gpointer)self);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
self->convert_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "convert-button"));
|
|
|
|
g_signal_connect(self->convert_button, "clicked", G_CALLBACK(on_convert_clicked), (gpointer)self);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
|
|
|
listbox = GTK_WIDGET(gtk_builder_get_object(main_builder, "layer-list"));
|
2019-03-14 23:40:26 +01:00
|
|
|
/* Create layer selector */
|
2019-03-15 20:02:03 +01:00
|
|
|
self->layer_selector = layer_selector_new(GTK_LIST_BOX(listbox));
|
|
|
|
|
2019-05-28 20:59:16 +02:00
|
|
|
activity_bar_box = GTK_WIDGET(gtk_builder_get_object(main_builder, "activity-bar"));
|
2018-07-23 13:10:34 +02:00
|
|
|
|
|
|
|
/* Callback for selection change of cell selector */
|
2019-03-15 20:02:03 +01:00
|
|
|
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(self->cell_tree_view)), "changed",
|
|
|
|
G_CALLBACK(cell_selection_changed), self);
|
|
|
|
g_signal_connect(self->cell_tree_view, "row-activated", G_CALLBACK(cell_tree_view_activated), self);
|
2018-07-23 13:10:34 +02:00
|
|
|
|
2019-03-11 10:36:02 +01:00
|
|
|
/* Set version in main window subtitle */
|
|
|
|
header_bar = GTK_HEADER_BAR(gtk_builder_get_object(main_builder, "header-bar"));
|
|
|
|
gtk_header_bar_set_subtitle(header_bar, _app_version_string);
|
|
|
|
|
2019-03-12 19:47:39 +01:00
|
|
|
/* Get layer sorting buttons and set callbacks */
|
|
|
|
sort_up_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-up-sort"));
|
|
|
|
sort_down_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-down-sort"));
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
g_signal_connect(sort_up_button, "clicked", G_CALLBACK(sort_up_callback), self);
|
|
|
|
g_signal_connect(sort_down_button, "clicked", G_CALLBACK(sort_down_callback), self);
|
2019-03-14 23:40:26 +01:00
|
|
|
|
|
|
|
/* Set buttons for loading and saving */
|
2019-08-21 18:34:40 +02:00
|
|
|
self->load_layer_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-load-mapping"));
|
|
|
|
self->save_layer_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-save-mapping"));
|
|
|
|
layer_selector_set_load_mapping_button(self->layer_selector, self->load_layer_button, self->main_window);
|
|
|
|
layer_selector_set_save_mapping_button(self->layer_selector, self->save_layer_button, self->main_window);
|
2019-03-14 23:40:26 +01:00
|
|
|
|
|
|
|
/* Connect delete-event */
|
2019-03-15 20:02:03 +01:00
|
|
|
g_signal_connect(GTK_WIDGET(self->main_window), "delete-event",
|
|
|
|
G_CALLBACK(on_window_close), self);
|
2019-03-12 19:47:39 +01:00
|
|
|
|
2019-05-28 20:59:16 +02:00
|
|
|
/* 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));
|
|
|
|
|
2019-06-13 21:46:25 +02:00
|
|
|
/* Create color palette */
|
|
|
|
self->palette = color_palette_new_from_resource("/data/color-palette.txt");
|
2019-06-13 22:01:39 +02:00
|
|
|
auto_color_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "auto-color-button"));
|
|
|
|
g_signal_connect(auto_color_button, "clicked", G_CALLBACK(on_auto_color_clicked), self);
|
|
|
|
|
2019-06-13 21:46:25 +02:00
|
|
|
|
2019-03-22 21:59:27 +01:00
|
|
|
/* Set default conversion/rendering settings */
|
|
|
|
self->render_dialog_settings.scale = 1000;
|
|
|
|
self->render_dialog_settings.renderer = RENDERER_LATEX_TIKZ;
|
|
|
|
self->render_dialog_settings.tex_pdf_layers = FALSE;
|
|
|
|
self->render_dialog_settings.tex_standalone = FALSE;
|
|
|
|
|
2019-08-25 22:11:36 +02:00
|
|
|
/* Get select all button and connect callback */
|
|
|
|
self->select_all_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-select-all"));
|
|
|
|
g_signal_connect(self->select_all_button, "clicked", G_CALLBACK(on_select_all_layers_clicked), self);
|
|
|
|
|
2019-08-29 17:58:39 +02:00
|
|
|
/* Setup auto naming button */
|
|
|
|
auto_naming_button = GTK_WIDGET(gtk_builder_get_object(main_builder, "button-auto-name"));
|
|
|
|
g_signal_connect(auto_naming_button, "clicked", G_CALLBACK(auto_naming_clicked), self);
|
|
|
|
|
2019-06-13 22:01:39 +02:00
|
|
|
g_object_unref(main_builder);
|
2019-03-22 21:59:27 +01:00
|
|
|
|
2019-08-21 18:34:40 +02:00
|
|
|
/* Setup default button sensibility data */
|
|
|
|
self->button_state_data.rendering_active = FALSE;
|
|
|
|
self->button_state_data.valid_cell_selected = FALSE;
|
|
|
|
|
2019-03-15 20:02:03 +01:00
|
|
|
/* Reference all objects referenced by this object */
|
2019-05-28 20:59:16 +02:00
|
|
|
g_object_ref(self->activity_status_bar);
|
2019-03-15 20:02:03 +01:00
|
|
|
g_object_ref(self->main_window);
|
|
|
|
g_object_ref(self->cell_tree_view);
|
|
|
|
g_object_ref(self->convert_button);
|
2019-09-28 21:42:49 +02:00
|
|
|
/* g_object_ref(self->layer_selector); <= This is already referenced by the _new() function */
|
2019-03-15 20:02:03 +01:00
|
|
|
g_object_ref(self->cell_search_entry);
|
2019-09-28 21:42:49 +02:00
|
|
|
/* g_object_ref(self->palette); */
|
2019-08-21 18:34:40 +02:00
|
|
|
g_object_ref(self->open_button);
|
|
|
|
g_object_ref(self->load_layer_button);
|
|
|
|
g_object_ref(self->save_layer_button);
|
2019-08-25 22:11:36 +02:00
|
|
|
g_object_ref(self->select_all_button);
|
2019-03-15 20:02:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GdsRenderGui *gds_render_gui_new()
|
|
|
|
{
|
|
|
|
return RENDERER_GUI(g_object_new(RENDERER_TYPE_GUI, NULL));
|
2018-07-23 13:10:34 +02:00
|
|
|
}
|
2018-07-24 18:47:29 +02:00
|
|
|
|
|
|
|
/** @} */
|