Merge branch 'master' into dev
This commit is contained in:
commit
60e20f45cc
@ -16,7 +16,7 @@ add_definitions(${GLIB2_CFLAGS_OTHER})
|
||||
|
||||
aux_source_directory("widgets" LAYER_SOURCES)
|
||||
aux_source_directory("tree-renderer" RENDERER_SOURCES)
|
||||
aux_source_directory("gds-parser" PARSER_SOURCES)
|
||||
aux_source_directory("gds-utils" GDS_SOURCES)
|
||||
aux_source_directory("latex-output" LATEX_SOURCES)
|
||||
aux_source_directory("cairo-output" CAIRO_SOURCES)
|
||||
aux_source_directory("trigonometric" TRIG_SOURCES)
|
||||
@ -27,7 +27,7 @@ set(SOURCE
|
||||
${SOURCE}
|
||||
${LAYER_SOURCES}
|
||||
${RENDERER_SOURCES}
|
||||
${PARSER_SOURCES}
|
||||
${GDS_SOURCES}
|
||||
${LATEX_SOURCES}
|
||||
${CAIRO_SOURCES}
|
||||
${TRIG_SOURCES}
|
||||
|
@ -235,8 +235,12 @@ void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos,
|
||||
/* Print size */
|
||||
cairo_recording_surface_ink_extents(layers[linfo->layer].rec, &rec_x0, &rec_y0,
|
||||
&rec_width, &rec_height);
|
||||
printf("Size of layer %d: %lf -- %lf\n", linfo->layer,
|
||||
rec_width, rec_height);
|
||||
printf("Size of layer %d%s%s%s: <%lf x %lf> @ (%lf | %lf)\n",
|
||||
linfo->layer,
|
||||
(linfo->name && linfo->name[0] ? " (" : ""),
|
||||
(linfo->name && linfo->name[0] ? linfo->name : ""),
|
||||
(linfo->name && linfo->name[0] ? ")" : ""),
|
||||
rec_width, rec_height, rec_x0, rec_y0);
|
||||
|
||||
/* update bounding box */
|
||||
xmin = MIN(xmin, rec_x0);
|
||||
@ -250,7 +254,7 @@ void cairo_render_cell_to_vector_file(struct gds_cell *cell, GList *layer_infos,
|
||||
|
||||
}
|
||||
|
||||
printf("Bounding box: (%lf,%lf) -- (%lf,%lf)\n", xmin, ymin, xmax, ymax);
|
||||
printf("Cell bounding box: (%lf | %lf) -- (%lf | %lf)\n", xmin, ymin, xmax, ymax);
|
||||
|
||||
if (pdf_file) {
|
||||
pdf_surface = cairo_pdf_surface_create(pdf_file, xmax-xmin, ymax-ymin);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define __CAIRO_OUTPUT_H__
|
||||
|
||||
#include "../layer/layer-info.h"
|
||||
#include "../gds-parser/gds-types.h"
|
||||
#include "../gds-utils/gds-types.h"
|
||||
|
||||
/** @addtogroup Cairo-Renderer
|
||||
* @{
|
||||
|
@ -30,13 +30,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "command-line.h"
|
||||
#include "gds-parser/gds-parser.h"
|
||||
#include "gds-utils/gds-parser.h"
|
||||
#include "mapping-parser.h"
|
||||
#include "layer/layer-info.h"
|
||||
#include "cairo-output/cairo-output.h"
|
||||
#include "latex-output/latex-output.h"
|
||||
#include "external-renderer.h"
|
||||
#include "gds-parser/gds-tree-checker.h"
|
||||
#include "gds-utils/gds-tree-checker.h"
|
||||
|
||||
/**
|
||||
* @brief Delete layer_info and free nem element.
|
||||
@ -98,7 +98,7 @@ void command_line_convert_gds(char *gds_name, char *pdf_name, char *tex_name, gb
|
||||
dstream = g_data_input_stream_new(G_INPUT_STREAM(stream));
|
||||
i = 0;
|
||||
do {
|
||||
res = load_csv_line(dstream, &layer_export, &layer_name, &layer, &layer_color);
|
||||
res = mapping_parser_load_line(dstream, &layer_export, &layer_name, &layer, &layer_color);
|
||||
if (res == 0) {
|
||||
if (!layer_export)
|
||||
continue;
|
||||
|
@ -31,7 +31,7 @@
|
||||
#ifndef _EXTERNAL_RENDERER_H_
|
||||
#define _EXTERNAL_RENDERER_H_
|
||||
|
||||
#include "gds-parser/gds-types.h"
|
||||
#include "gds-utils/gds-types.h"
|
||||
#include <glib.h>
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "gds-render-gui.h"
|
||||
#include <stdio.h>
|
||||
#include "gds-parser/gds-parser.h"
|
||||
#include "gds-utils/gds-parser.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include "layer/layer-selector.h"
|
||||
#include "tree-renderer/tree-store.h"
|
||||
@ -39,7 +39,7 @@
|
||||
#include "trigonometric/cell-trigonometrics.h"
|
||||
#include "version/version.h"
|
||||
#include "tree-renderer/lib-cell-renderer.h"
|
||||
#include "gds-parser/gds-tree-checker.h"
|
||||
#include "gds-utils/gds-tree-checker.h"
|
||||
|
||||
enum gds_render_gui_signal_sig_ids {SIGNAL_WINDOW_CLOSED = 0, SIGNAL_COUNT};
|
||||
|
||||
@ -57,17 +57,17 @@ struct _GdsRenderGui {
|
||||
LayerSelector *layer_selector;
|
||||
GtkTreeView *cell_tree_view;
|
||||
GList *gds_libraries;
|
||||
struct render_settings render_dialog_settings;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(GdsRenderGui, gds_render_gui, G_TYPE_OBJECT)
|
||||
|
||||
/**
|
||||
* @brief Window close event of main window
|
||||
*
|
||||
* Closes the main window. This leads to the termination of the whole application
|
||||
* @param window main window
|
||||
* @param user not used
|
||||
* @return TRUE. This indicates that the event has been fully handled
|
||||
* @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.
|
||||
*/
|
||||
static gboolean on_window_close(gpointer window, GdkEvent *event, gpointer user)
|
||||
{
|
||||
@ -112,7 +112,7 @@ static GString *generate_string_from_date(struct gds_time_field *date)
|
||||
/**
|
||||
* @brief Callback function of Load GDS button
|
||||
* @param button
|
||||
* @param user Necessary Data
|
||||
* @param user GdsRenderGui instance
|
||||
*/
|
||||
static void on_load_gds(gpointer button, gpointer user)
|
||||
{
|
||||
@ -152,7 +152,8 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
|
||||
dialog_result = gtk_dialog_run(GTK_DIALOG(open_dialog));
|
||||
|
||||
if (dialog_result == GTK_RESPONSE_ACCEPT) {
|
||||
if (dialog_result != GTK_RESPONSE_ACCEPT)
|
||||
goto end_destroy;
|
||||
|
||||
/* Get File name */
|
||||
filename = gtk_file_chooser_get_filename(file_chooser);
|
||||
@ -190,7 +191,6 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
/* Check this library. This might take a while */
|
||||
(void)gds_tree_check_cell_references(gds_lib);
|
||||
(void)gds_tree_check_reference_loops(gds_lib);
|
||||
|
||||
/* Delete GStrings including string data. */
|
||||
/* Cell store copies String type data items */
|
||||
g_string_free(mod_date, TRUE);
|
||||
@ -199,7 +199,6 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
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);
|
||||
|
||||
/* Convert dates to String */
|
||||
mod_date = generate_string_from_date(&gds_c->mod_time);
|
||||
acc_date = generate_string_from_date(&gds_c->access_time);
|
||||
@ -225,12 +224,11 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
/* Cell store copies String type data items */
|
||||
g_string_free(mod_date, TRUE);
|
||||
g_string_free(acc_date, TRUE);
|
||||
}
|
||||
}
|
||||
} /* for cells */
|
||||
} /* for libraries */
|
||||
|
||||
/* Create Layers in Layer Box */
|
||||
layer_selector_generate_layer_widgets(self->layer_selector, self->gds_libraries);
|
||||
}
|
||||
|
||||
end_destroy:
|
||||
/* Destroy dialog and filter */
|
||||
@ -245,10 +243,6 @@ end_destroy:
|
||||
static void on_convert_clicked(gpointer button, gpointer user)
|
||||
{
|
||||
(void)button;
|
||||
static struct render_settings sett = {
|
||||
.scale = 1000.0,
|
||||
.renderer = RENDERER_LATEX_TIKZ,
|
||||
};
|
||||
GdsRenderGui *self;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeIter iter;
|
||||
@ -263,12 +257,15 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
char *file_name;
|
||||
union bounding_box cell_box;
|
||||
unsigned int height, width;
|
||||
struct render_settings *sett;
|
||||
|
||||
self = RENDERER_GUI(user);
|
||||
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
sett = &self->render_dialog_settings;
|
||||
|
||||
/* Get selected cell */
|
||||
selection = gtk_tree_view_get_selection(self->cell_tree_view);
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE)
|
||||
@ -295,14 +292,14 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
|
||||
/* Show settings dialog */
|
||||
settings = renderer_settings_dialog_new(GTK_WINDOW(self->main_window));
|
||||
renderer_settings_dialog_set_settings(settings, &sett);
|
||||
renderer_settings_dialog_set_settings(settings, sett);
|
||||
renderer_settings_dialog_set_database_unit_scale(settings, cell_to_render->parent_library->unit_in_meters);
|
||||
renderer_settings_dialog_set_cell_height(settings, height);
|
||||
renderer_settings_dialog_set_cell_width(settings, width);
|
||||
|
||||
res = gtk_dialog_run(GTK_DIALOG(settings));
|
||||
if (res == GTK_RESPONSE_OK) {
|
||||
renderer_settings_dialog_get_settings(settings, &sett);
|
||||
renderer_settings_dialog_get_settings(settings, sett);
|
||||
gtk_widget_destroy(GTK_WIDGET(settings));
|
||||
} else {
|
||||
gtk_widget_destroy(GTK_WIDGET(settings));
|
||||
@ -310,13 +307,13 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
}
|
||||
|
||||
/* save file dialog */
|
||||
dialog = gtk_file_chooser_dialog_new((sett.renderer == RENDERER_LATEX_TIKZ
|
||||
dialog = gtk_file_chooser_dialog_new((sett->renderer == RENDERER_LATEX_TIKZ
|
||||
? "Save LaTeX File" : "Save PDF"),
|
||||
GTK_WINDOW(self->main_window), GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"Cancel", GTK_RESPONSE_CANCEL, "Save", GTK_RESPONSE_ACCEPT, NULL);
|
||||
/* Set file filter according to settings */
|
||||
filter = gtk_file_filter_new();
|
||||
switch (sett.renderer) {
|
||||
switch (sett->renderer) {
|
||||
case RENDERER_LATEX_TIKZ:
|
||||
gtk_file_filter_add_pattern(filter, "*.tex");
|
||||
gtk_file_filter_set_name(filter, "LaTeX-Files");
|
||||
@ -340,23 +337,23 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
file_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
|
||||
switch (sett.renderer) {
|
||||
switch (sett->renderer) {
|
||||
case RENDERER_LATEX_TIKZ:
|
||||
output_file = fopen(file_name, "w");
|
||||
latex_render_cell_to_code(cell_to_render, layer_list, output_file, sett.scale,
|
||||
sett.tex_pdf_layers, sett.tex_standalone);
|
||||
latex_render_cell_to_code(cell_to_render, layer_list, output_file, sett->scale,
|
||||
sett->tex_pdf_layers, sett->tex_standalone);
|
||||
fclose(output_file);
|
||||
break;
|
||||
case RENDERER_CAIROGRAPHICS_SVG:
|
||||
case RENDERER_CAIROGRAPHICS_PDF:
|
||||
cairo_render_cell_to_vector_file(cell_to_render, layer_list,
|
||||
(sett.renderer == RENDERER_CAIROGRAPHICS_PDF
|
||||
(sett->renderer == RENDERER_CAIROGRAPHICS_PDF
|
||||
? file_name
|
||||
: NULL),
|
||||
(sett.renderer == RENDERER_CAIROGRAPHICS_SVG
|
||||
(sett->renderer == RENDERER_CAIROGRAPHICS_SVG
|
||||
? file_name
|
||||
: NULL),
|
||||
sett.scale);
|
||||
sett->scale);
|
||||
break;
|
||||
}
|
||||
g_free(file_name);
|
||||
@ -369,9 +366,11 @@ ret_layer_destroy:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief cell_tree_view_activated
|
||||
* @param tree_view Not used
|
||||
* @param user convert button data
|
||||
* @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
|
||||
*/
|
||||
static void cell_tree_view_activated(gpointer tree_view, GtkTreePath *path,
|
||||
GtkTreeViewColumn *column, gpointer user)
|
||||
@ -484,7 +483,6 @@ static void gds_render_gui_init(GdsRenderGui *self)
|
||||
GtkWidget *sort_down_button;
|
||||
|
||||
main_builder = gtk_builder_new_from_resource("/main.glade");
|
||||
gtk_builder_connect_signals(main_builder, NULL);
|
||||
|
||||
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"));
|
||||
@ -534,6 +532,13 @@ static void gds_render_gui_init(GdsRenderGui *self)
|
||||
|
||||
g_object_unref(main_builder);
|
||||
|
||||
/* 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;
|
||||
|
||||
|
||||
/* Reference all objects referenced by this object */
|
||||
g_object_ref(self->main_window);
|
||||
g_object_ref(self->cell_tree_view);
|
||||
|
@ -41,7 +41,7 @@ G_DECLARE_FINAL_TYPE(GdsRenderGui, gds_render_gui, RENDERER, GUI, GObject);
|
||||
|
||||
/**
|
||||
* @brief Create new GdsRenderGui Object
|
||||
* @return
|
||||
* @return New object
|
||||
*/
|
||||
GdsRenderGui *gds_render_gui_new();
|
||||
|
||||
@ -50,7 +50,7 @@ GdsRenderGui *gds_render_gui_new();
|
||||
*
|
||||
* This function returns the main window of the GUI, which can later be displayed.
|
||||
* All handling of hte GUI is taken care of inside the GdsRenderGui Object
|
||||
* @return
|
||||
* @return The generated main window
|
||||
*/
|
||||
GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
add_custom_target(glib-resources DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resources.c)
|
||||
add_custom_command(DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.glade
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources.xml
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_BINARY_DIR}/resources.c
|
||||
COMMAND
|
||||
|
@ -10,7 +10,7 @@
|
||||
<property name="website">https://git.shimatta.de/mhu/gds-render</property>
|
||||
<property name="website_label" translatable="yes">Git Repository</property>
|
||||
<property name="authors">Mario Hüttel <mario.huettel@gmx.net></property>
|
||||
<property name="logo_icon_name">gds-render</property>
|
||||
<property name="logo_icon_name"/>
|
||||
<property name="license_type">gpl-2-0-only</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
|
@ -16,7 +16,6 @@
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="latex-radio">
|
||||
<property name="label" translatable="yes">Generate LaTeX/TikZ output</property>
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
@ -32,11 +31,9 @@
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="cairo-pdf-radio">
|
||||
<property name="label" translatable="yes">Render PDF using Cairographics</property>
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">latex-radio</property>
|
||||
</object>
|
||||
@ -49,11 +46,10 @@
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="cairo-svg-radio">
|
||||
<property name="label" translatable="yes">Render SVG using Cairographics (too buggy at the moment)</property>
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">latex-radio</property>
|
||||
</object>
|
||||
|
@ -5,6 +5,7 @@
|
||||
<file compressed="true">about.glade</file>
|
||||
<file>layer-widget.glade</file>
|
||||
<file>dialog.glade</file>
|
||||
<file compressed="true" alias="logo.svg">../icon/gds-render.svg</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "../gds-parser/gds-types.h"
|
||||
#include "../gds-utils/gds-types.h"
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include "../layer/layer-info.h"
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "layer-selector.h"
|
||||
#include "layer-info.h"
|
||||
#include "../gds-parser/gds-parser.h"
|
||||
#include "../gds-utils/gds-parser.h"
|
||||
#include "../widgets/layer-element.h"
|
||||
#include "../mapping-parser.h"
|
||||
#include <glib.h>
|
||||
@ -56,7 +56,9 @@ struct _LayerSelector {
|
||||
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/
|
||||
*/
|
||||
|
||||
static void sel_layer_element_drag_begin(GtkWidget *widget, GdkDragContext *context, gpointer data)
|
||||
{
|
||||
@ -422,9 +424,10 @@ static void layer_selector_clear_widgets(LayerSelector *self)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if specific layer number is present in list box
|
||||
* @param layer Layer nu,ber
|
||||
* @return TRUE if present
|
||||
* @brief Check if a specific layer element with the given layer number is present in the layer selector
|
||||
* @param self LayerSelector instance
|
||||
* @param layer Layer number to check for
|
||||
* @return TRUE if layer is present, else FALSE
|
||||
*/
|
||||
static gboolean layer_selector_check_if_layer_widget_exists(LayerSelector *self, int layer) {
|
||||
GList *list;
|
||||
@ -447,17 +450,30 @@ static gboolean layer_selector_check_if_layer_widget_exists(LayerSelector *self,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Setup the necessary drag and drop callbacks of layer elements.
|
||||
* @param self LayerSelector instance. Used to get the DnD target entry.
|
||||
* @param element LayerElement instance to set the callbacks
|
||||
*/
|
||||
static void sel_layer_element_setup_dnd_callbacks(LayerSelector *self, LayerElement *element)
|
||||
{
|
||||
layer_element_set_dnd_callbacks(element, &self->dnd_target, 1,
|
||||
sel_layer_element_drag_begin,
|
||||
sel_layer_element_drag_data_get,
|
||||
sel_layer_element_drag_end);
|
||||
struct layer_element_dnd_data dnd_data;
|
||||
|
||||
if (!self || !element)
|
||||
return;
|
||||
|
||||
dnd_data.entries = &self->dnd_target;
|
||||
dnd_data.entry_count = 1;
|
||||
dnd_data.drag_end = sel_layer_element_drag_end;
|
||||
dnd_data.drag_begin = sel_layer_element_drag_begin;
|
||||
dnd_data.drag_data_get = sel_layer_element_drag_data_get;
|
||||
|
||||
layer_element_set_dnd_callbacks(element, &dnd_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Analyze \p cell and append used layers to list box
|
||||
* @param listbox listbox to add layer
|
||||
* @brief Analyze \p cell layers and append detected layers to layer selector \p self
|
||||
* @param self LayerSelector instance
|
||||
* @param cell Cell to analyze
|
||||
*/
|
||||
static void layer_selector_analyze_cell_layers(LayerSelector *self, struct gds_cell *cell)
|
||||
@ -555,8 +571,15 @@ static LayerElement *layer_selector_find_layer_element_in_list(GList *el_list, i
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Load file and apply layer definitions to listbox
|
||||
* @param file_name CSV Layer Mapping File
|
||||
* @brief Load the layer mapping from a CSV formatted file
|
||||
*
|
||||
* This function imports the layer specification from a file (see @ref lmf-spec).
|
||||
* The layer ordering defined in the file is kept. All layers present in the
|
||||
* current loaded library, which are not present in the layer mapping file
|
||||
* are appended at the end of the layer selector list.
|
||||
*
|
||||
* @param self LayerSelector instance
|
||||
* @param file_name File name to load from
|
||||
*/
|
||||
static void layer_selector_load_layer_mapping_from_file(LayerSelector *self, gchar *file_name)
|
||||
{
|
||||
@ -590,7 +613,7 @@ static void layer_selector_load_layer_mapping_from_file(LayerSelector *self, gch
|
||||
gtk_container_remove(GTK_CONTAINER(self->list_box), GTK_WIDGET(le));
|
||||
}
|
||||
|
||||
while((result = load_csv_line(dstream, &export, &name, &layer, &color)) >= 0) {
|
||||
while((result = mapping_parser_load_line(dstream, &export, &name, &layer, &color)) >= 0) {
|
||||
/* skip broken line */
|
||||
if (result == 1)
|
||||
continue;
|
||||
@ -656,9 +679,9 @@ static void layer_selector_load_mapping_clicked(GtkWidget *button, gpointer user
|
||||
|
||||
|
||||
/**
|
||||
* @brief Save layer mapping of whole list box into file
|
||||
* @param file_name layer mapping file
|
||||
* @param list_box listbox
|
||||
* @brief Save layer mapping of selector \p self to a file
|
||||
* @param self LayerSelector instance
|
||||
* @param file_name File name to save to
|
||||
*/
|
||||
static void layer_selector_save_layer_mapping_data(LayerSelector *self, const gchar *file_name)
|
||||
{
|
||||
@ -676,7 +699,7 @@ static void layer_selector_save_layer_mapping_data(LayerSelector *self, const gc
|
||||
for (temp = le_list; temp != NULL; temp = temp->next) {
|
||||
/* To be sure it is a valid string */
|
||||
workbuff[0] = 0;
|
||||
create_csv_line(LAYER_ELEMENT(temp->data), workbuff, sizeof(workbuff));
|
||||
mapping_parser_gen_csv_line(LAYER_ELEMENT(temp->data), workbuff, sizeof(workbuff));
|
||||
fwrite(workbuff, sizeof(char), strlen(workbuff), file);
|
||||
}
|
||||
|
||||
|
@ -48,39 +48,40 @@ enum layer_selector_sort_algo {LAYER_SELECTOR_SORT_DOWN = 0, LAYER_SELECTOR_SORT
|
||||
LayerSelector *layer_selector_new(GtkListBox *list_box);
|
||||
|
||||
/**
|
||||
* @brief Generate layer widgets in \p listbox
|
||||
* @brief Generate layer widgets in in the LayerSelector instance
|
||||
* @note This clears all previously inserted elements
|
||||
* @param listbox
|
||||
* @param selector LayerSelector instance
|
||||
* @param libs The libraries to add
|
||||
*/
|
||||
void layer_selector_generate_layer_widgets(LayerSelector *selector, GList *libs);
|
||||
|
||||
/**
|
||||
* @brief Supply button for loading the layer mapping
|
||||
* @param button
|
||||
* @param main_window Parent window for dialogs
|
||||
* @param selector LayerSelector instance
|
||||
* @param button Load button. Will be referenced
|
||||
* @param main_window Parent window for dialogs. Will be referenced
|
||||
*/
|
||||
void layer_selector_set_load_mapping_button(LayerSelector *selector, GtkWidget *button, GtkWindow *main_window);
|
||||
|
||||
/**
|
||||
* @brief Supply button for saving the layer mapping
|
||||
* @param button
|
||||
* @param main_window Parent window for dialogs
|
||||
* @param selector LayerSelector instance
|
||||
* @param button Save button. Will be refeneced
|
||||
* @param main_window Parent window for dialogs. Will be referenced
|
||||
*/
|
||||
void layer_selector_set_save_mapping_button(LayerSelector *selector, GtkWidget *button, GtkWindow *main_window);
|
||||
|
||||
/**
|
||||
* @brief get the layer information present in the listbox of the selector
|
||||
* @return List with layer_info elements
|
||||
* @brief Get a list of all layers that shall be exported when rendering the cells
|
||||
* @param selector Layer selector instance
|
||||
* @return List of layer_info structures containing the layer information
|
||||
*/
|
||||
GList *layer_selector_export_rendered_layer_info(LayerSelector *selector);
|
||||
|
||||
/**
|
||||
* @brief Force sorting of the layer selector in a specified way
|
||||
*
|
||||
* If the layer selector is not yet set up, this function has no effect.
|
||||
*
|
||||
* @param sort_function Sorting direction
|
||||
* @brief Force the layer selector list to be sorted according to \p sort_function
|
||||
* @param selector LayerSelector instance
|
||||
* @param sort_function The sorting method (up or down sorting)
|
||||
*/
|
||||
void layer_selector_force_sort(LayerSelector *selector, enum layer_selector_sort_algo sort_function);
|
||||
|
||||
|
16
main.c
16
main.c
@ -52,6 +52,8 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkDialog *dialog;
|
||||
GdkPixbuf *logo_buf;
|
||||
GError *error = NULL;
|
||||
(void)user_data;
|
||||
(void)action;
|
||||
(void)parameter;
|
||||
@ -60,6 +62,20 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
|
||||
dialog = GTK_DIALOG(gtk_builder_get_object(builder, "about-dialog"));
|
||||
gtk_window_set_transient_for(GTK_WINDOW(dialog), NULL);
|
||||
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), _app_version_string);
|
||||
|
||||
/* Load icon from resource */
|
||||
logo_buf = gdk_pixbuf_new_from_resource_at_scale("/logo.svg", 100, 100, TRUE, &error);
|
||||
if (logo_buf) {
|
||||
/* Set logo */
|
||||
gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), logo_buf);
|
||||
|
||||
/* Pixbuf is now owned by about dialog. Unref */
|
||||
g_object_unref(logo_buf);
|
||||
} else if (error) {
|
||||
fprintf(stderr, "Logo could not be displayed: %s\n", error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
gtk_dialog_run(dialog);
|
||||
|
||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include "mapping-parser.h"
|
||||
|
||||
int load_csv_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color)
|
||||
int mapping_parser_load_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color)
|
||||
{
|
||||
int ret;
|
||||
gsize len;
|
||||
@ -94,7 +94,7 @@ ret_direct:
|
||||
|
||||
}
|
||||
|
||||
void create_csv_line(LayerElement *layer_element, char *line_buffer, size_t max_len)
|
||||
void mapping_parser_gen_csv_line(LayerElement *layer_element, char *line_buffer, size_t max_len)
|
||||
{
|
||||
int i;
|
||||
GString *string;
|
||||
|
@ -43,7 +43,7 @@
|
||||
* @param color RGBA color.
|
||||
* @return 1 if malformatted line, 0 if parsing was successful and parameters are valid, -1 if file end
|
||||
*/
|
||||
int load_csv_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color);
|
||||
int mapping_parser_load_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color);
|
||||
|
||||
/**
|
||||
* @brief Create Line for LayerMapping file with supplied information
|
||||
@ -51,7 +51,7 @@ int load_csv_line(GDataInputStream *stream, gboolean *export, char **name, int *
|
||||
* @param line_buffer buffer to write to
|
||||
* @param max_len Maximum length that cna be used in \p line_buffer
|
||||
*/
|
||||
void create_csv_line(LayerElement *layer_element, char *line_buffer, size_t max_len);
|
||||
void mapping_parser_gen_csv_line(LayerElement *layer_element, char *line_buffer, size_t max_len);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "lib-cell-renderer.h"
|
||||
#include "../gds-parser/gds-types.h"
|
||||
#include "../gds-utils/gds-types.h"
|
||||
|
||||
G_DEFINE_TYPE(LibCellRenderer, lib_cell_renderer, GTK_TYPE_CELL_RENDERER_TEXT)
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "tree-store.h"
|
||||
#include "lib-cell-renderer.h"
|
||||
#include "../gds-parser/gds-types.h"
|
||||
#include "../gds-utils/gds-types.h"
|
||||
|
||||
/**
|
||||
* @brief this function olny allows cells to be selected
|
||||
@ -51,6 +51,9 @@ static gboolean tree_sel_func(GtkTreeSelection *selection,
|
||||
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);
|
||||
@ -112,6 +115,8 @@ exit_filter:
|
||||
static void change_filter(GtkWidget *entry, gpointer data)
|
||||
{
|
||||
struct tree_stores *stores = (struct tree_stores *)data;
|
||||
(void)entry;
|
||||
|
||||
gtk_tree_model_filter_refilter(stores->filter);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#define _CELL_TRIGONOMETRICS_H_
|
||||
|
||||
#include "bounding-box.h"
|
||||
#include "../gds-parser/gds-types.h"
|
||||
#include "../gds-utils/gds-types.h"
|
||||
|
||||
/**
|
||||
* @brief calculate_cell_bounding_box Calculate bounding box of gds cell
|
||||
|
@ -140,6 +140,7 @@ static double convert_number_to_engineering(double input, const char **out_prefi
|
||||
1E2, 1E3, 1E6, 1E9, 1E12, 1E15, 1E18, 1E21, 1E24};
|
||||
const int prefix_count = (int)(sizeof(prefixes)/sizeof(char *));
|
||||
|
||||
/* Start with the 2nd smallest prefix */
|
||||
for (idx = 1; idx < prefix_count; idx++) {
|
||||
if (input < scale[idx]) {
|
||||
/* This prefix is bigger than the number. Take the previous one */
|
||||
@ -212,7 +213,7 @@ static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
||||
GtkWidget *box;
|
||||
GtkDialog *dialog;
|
||||
|
||||
dialog = &(self->parent);
|
||||
dialog = &self->parent;
|
||||
|
||||
builder = gtk_builder_new_from_resource("/dialog.glade");
|
||||
box = GTK_WIDGET(gtk_builder_get_object(builder, "dialog-box"));
|
||||
@ -260,10 +261,7 @@ RendererSettingsDialog *renderer_settings_dialog_new(GtkWindow *parent)
|
||||
|
||||
void renderer_settings_dialog_get_settings(RendererSettingsDialog *dialog, struct render_settings *settings)
|
||||
{
|
||||
/*GList *radio_buttons;
|
||||
*GList *temp_button_list;
|
||||
*GtkToggleButton *temp_button = NULL;
|
||||
*/
|
||||
|
||||
if (!settings || !dialog)
|
||||
return;
|
||||
settings->scale = gtk_range_get_value(GTK_RANGE(dialog->scale));
|
||||
|
@ -120,26 +120,29 @@ void layer_element_get_color(LayerElement *elem, GdkRGBA *rgba)
|
||||
{
|
||||
if (!rgba)
|
||||
return;
|
||||
|
||||
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(elem->priv.color), rgba);
|
||||
}
|
||||
|
||||
void layer_element_set_color(LayerElement *elem, GdkRGBA *rgba)
|
||||
{
|
||||
if (!elem || !rgba)
|
||||
return;
|
||||
|
||||
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(elem->priv.color), rgba);
|
||||
}
|
||||
|
||||
void layer_element_set_dnd_callbacks(LayerElement *elem, GtkTargetEntry *entries, int entry_count,
|
||||
void (*drag_begin)(GtkWidget *, GdkDragContext *, gpointer),
|
||||
void (*drag_data_get)(GtkWidget *, GdkDragContext *,
|
||||
GtkSelectionData *, guint , guint, gpointer),
|
||||
void (*drag_end)(GtkWidget *, GdkDragContext *, gpointer))
|
||||
void layer_element_set_dnd_callbacks(LayerElement *elem, struct layer_element_dnd_data *data)
|
||||
{
|
||||
if (!elem || !data)
|
||||
return;
|
||||
|
||||
/* Setup drag and drop */
|
||||
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, entries, entry_count, GDK_ACTION_MOVE);
|
||||
g_signal_connect(elem->priv.event_handle, "drag-begin", G_CALLBACK(drag_begin), NULL);
|
||||
g_signal_connect(elem->priv.event_handle, "drag-data-get", G_CALLBACK(drag_data_get), NULL);
|
||||
g_signal_connect(elem->priv.event_handle, "drag-end", G_CALLBACK(drag_end), NULL);
|
||||
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-data-get", G_CALLBACK(data->drag_data_get), NULL);
|
||||
g_signal_connect(elem->priv.event_handle, "drag-end", G_CALLBACK(data->drag_end), NULL);
|
||||
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,22 @@ struct _LayerElement {
|
||||
LayerElementPriv priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This structure holds the necessary data to set up a LayerElement for Drag'n'Drop
|
||||
*/
|
||||
struct layer_element_dnd_data {
|
||||
/** @brief Array of target entries for the DnD operation */
|
||||
GtkTargetEntry *entries;
|
||||
/** @brief Count of elements in layer_element_dnd_data::entries array */
|
||||
int entry_count;
|
||||
/** @brief Callback function for drag_begin event */
|
||||
void (*drag_begin)(GtkWidget *, GdkDragContext *, gpointer);
|
||||
/** @brief Callback fucktion for data_get event */
|
||||
void (*drag_data_get)(GtkWidget *, GdkDragContext *, GtkSelectionData *, guint, guint, gpointer);
|
||||
/** @brief Callback function for drag_end event */
|
||||
void (*drag_end)(GtkWidget *, GdkDragContext *, gpointer);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Create new layer element object
|
||||
* @return new object
|
||||
@ -119,16 +135,11 @@ void layer_element_get_color(LayerElement *elem, GdkRGBA *rgba);
|
||||
void layer_element_set_color(LayerElement *elem, GdkRGBA *rgba);
|
||||
|
||||
/**
|
||||
* @brief layer_element_set_dnd_callbacks
|
||||
* @param elem
|
||||
* @param entries
|
||||
* @param entry_count
|
||||
* @brief Setup drag and drop of \p elem for use in the LayerSelector
|
||||
* @param elem Layer element to set up
|
||||
* @param data Data array containing the necessary callbacks etc. for drag and drop.
|
||||
*/
|
||||
void layer_element_set_dnd_callbacks(LayerElement *elem, GtkTargetEntry *entries, int entry_count,
|
||||
void (*drag_begin)(GtkWidget *, GdkDragContext *, gpointer),
|
||||
void (*drag_data_get)(GtkWidget *, GdkDragContext *,
|
||||
GtkSelectionData *, guint , guint, gpointer),
|
||||
void (*drag_end)(GtkWidget *, GdkDragContext *, gpointer));
|
||||
void layer_element_set_dnd_callbacks(LayerElement *elem, struct layer_element_dnd_data *data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user