Compare commits

..

No commits in common. "1ec0f9b297522dfde1a6d296efdc2ed9f01384bc" and "eeae61ad473b38207300e6d0b81cf6840f5b86ef" have entirely different histories.

12 changed files with 38 additions and 191 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "c-style-checker"]
path = c-style-checker
url = https://git.shimatta.de/mhu/c-style-checker

View File

@ -8,7 +8,6 @@ pkg_check_modules(CAIRO REQUIRED cairo)
add_subdirectory(glade) add_subdirectory(glade)
add_subdirectory(doxygen) add_subdirectory(doxygen)
add_subdirectory(version)
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS}) include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS})
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS}) link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
@ -36,8 +35,7 @@ add_compile_options(-Wall)
add_executable(${PROJECT_NAME} ${SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c) add_executable(${PROJECT_NAME} ${SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c)
add_dependencies(${PROJECT_NAME} glib-resources) add_dependencies(${PROJECT_NAME} glib-resources)
add_dependencies(${PROJECT_NAME} version)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c PROPERTIES GENERATED 1) SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c PROPERTIES GENERATED 1)
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS}) target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m ${CMAKE_DL_LIBS})
install (TARGETS ${PROJECT_NAME} DESTINATION bin) install (TARGETS ${PROJECT_NAME} DESTINATION bin)

@ -1 +0,0 @@
Subproject commit 3a58e3dd1c2ef6de78df89c8fdc7ba96b51cd4e0

View File

@ -32,8 +32,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <stdio.h> #include <stdio.h>
int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_info_list, int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_info_list, char *output_file, char *so_path)
char *output_file, char *so_path)
{ {
int (*so_render_func)(struct gds_cell *, GList *, char *) = NULL; int (*so_render_func)(struct gds_cell *, GList *, char *) = NULL;
void *so_handle = NULL; void *so_handle = NULL;
@ -41,8 +40,9 @@ int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_i
int ret = 0; int ret = 0;
/* Check parameter sanity */ /* Check parameter sanity */
if (!output_file || !so_path || !toplevel_cell || !layer_info_list) if (!output_file || !so_path || !toplevel_cell || !layer_info_list) {
return -3000; return -3000;
}
/* Load shared object */ /* Load shared object */
so_handle = dlopen(so_path, RTLD_LAZY); so_handle = dlopen(so_path, RTLD_LAZY);
@ -53,8 +53,7 @@ int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_i
/* Load symbol from library */ /* Load symbol from library */
so_render_func = (int (*)(struct gds_cell *, GList *, char *))dlsym(so_handle, EXTERNAL_LIBRARY_FUNCTION); so_render_func = (int (*)(struct gds_cell *, GList *, char *))dlsym(so_handle, EXTERNAL_LIBRARY_FUNCTION);
error_msg = dlerror(); if ((error_msg = dlerror()) != NULL) {
if (error_msg != NULL) {
printf("Rendering function not found in library:\n%s\n", error_msg); printf("Rendering function not found in library:\n%s\n", error_msg);
goto ret_close_so_handle; goto ret_close_so_handle;
} }

View File

@ -7,11 +7,12 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">gds-render</property> <property name="icon_name">gds-render</property>
<child type="titlebar"> <child type="titlebar">
<object class="GtkHeaderBar" id="header-bar"> <object class="GtkHeaderBar">
<property name="name">header</property> <property name="name">header</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="title" translatable="yes">GDS Renderer</property> <property name="title" translatable="yes">GDS Renderer</property>
<property name="subtitle" translatable="yes">GDSII to PDF/TikZ Converter</property>
<property name="show_close_button">True</property> <property name="show_close_button">True</property>
<child> <child>
<object class="GtkButton" id="button-load-gds"> <object class="GtkButton" id="button-load-gds">

View File

@ -37,7 +37,6 @@
#include "widgets/conv-settings-dialog.h" #include "widgets/conv-settings-dialog.h"
#include "cairo-output/cairo-output.h" #include "cairo-output/cairo-output.h"
#include "trigonometric/cell-trigonometrics.h" #include "trigonometric/cell-trigonometrics.h"
#include "version/version.h"
#include "tree-renderer/lib-cell-renderer.h" #include "tree-renderer/lib-cell-renderer.h"
#include "gds-parser/gds-tree-checker.h" #include "gds-parser/gds-tree-checker.h"
@ -119,11 +118,8 @@ static void on_load_gds(gpointer button, gpointer user)
GString *acc_date; GString *acc_date;
unsigned int cell_error_level; unsigned int cell_error_level;
open_dialog = gtk_file_chooser_dialog_new("Open GDSII File", ptr->main_window, open_dialog = gtk_file_chooser_dialog_new("Open GDSII File", ptr->main_window, GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_FILE_CHOOSER_ACTION_OPEN, "Cancel", GTK_RESPONSE_CANCEL, "Open GDSII", GTK_RESPONSE_ACCEPT, NULL);
"Cancel", GTK_RESPONSE_CANCEL,
"Open GDSII", GTK_RESPONSE_ACCEPT,
NULL);
file_chooser = GTK_FILE_CHOOSER(open_dialog); file_chooser = GTK_FILE_CHOOSER(open_dialog);
/* Add GDS II Filter */ /* Add GDS II Filter */
filter = gtk_file_filter_new(); filter = gtk_file_filter_new();
@ -169,6 +165,7 @@ static void on_load_gds(gpointer button, gpointer user)
-1); -1);
/* Check this library. This might take a while */ /* Check this library. This might take a while */
(void)gds_tree_check_cell_references(gds_lib); (void)gds_tree_check_cell_references(gds_lib);
(void)gds_tree_check_reference_loops(gds_lib); (void)gds_tree_check_reference_loops(gds_lib);
@ -199,8 +196,7 @@ static void on_load_gds(gpointer button, gpointer user)
CELL_SEL_CELL, gds_c, CELL_SEL_CELL, gds_c,
CELL_SEL_MODDATE, mod_date->str, CELL_SEL_MODDATE, mod_date->str,
CELL_SEL_ACCESSDATE, acc_date->str, CELL_SEL_ACCESSDATE, acc_date->str,
CELL_SEL_CELL_ERROR_STATE, cell_error_level, CELL_SEL_CELL_ERROR_STATE, cell_error_level, -1);
-1);
/* Delete GStrings including string data. */ /* Delete GStrings including string data. */
/* Cell store copies String type data items */ /* Cell store copies String type data items */
@ -242,7 +238,7 @@ static void on_convert_clicked(gpointer button, gpointer user)
gint res; gint res;
char *file_name; char *file_name;
union bounding_box cell_box; union bounding_box cell_box;
unsigned int height, width; double height, width;
/* Get selected cell */ /* Get selected cell */
selection = gtk_tree_view_get_selection(data->tree_view); selection = gtk_tree_view_get_selection(data->tree_view);
@ -261,12 +257,9 @@ static void on_convert_clicked(gpointer button, gpointer user)
bounding_box_prepare_empty(&cell_box); bounding_box_prepare_empty(&cell_box);
calculate_cell_bounding_box(&cell_box, cell_to_render); calculate_cell_bounding_box(&cell_box, cell_to_render);
/* Calculate size in database units /* Calculate size in meters database units */
* Note that the results are bound to be positive, height = (cell_box.vectors.upper_right.y - cell_box.vectors.lower_left.y);
* so casting them to unsigned int is asbsolutely valid width = (cell_box.vectors.upper_right.x - cell_box.vectors.lower_left.x);
*/
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);
/* Show settings dialog */ /* Show settings dialog */
settings = renderer_settings_dialog_new(GTK_WINDOW(data->main_window)); settings = renderer_settings_dialog_new(GTK_WINDOW(data->main_window));
@ -325,12 +318,8 @@ static void on_convert_clicked(gpointer button, gpointer user)
case RENDERER_CAIROGRAPHICS_SVG: case RENDERER_CAIROGRAPHICS_SVG:
case RENDERER_CAIROGRAPHICS_PDF: case RENDERER_CAIROGRAPHICS_PDF:
cairo_render_cell_to_vector_file(cell_to_render, layer_list, cairo_render_cell_to_vector_file(cell_to_render, layer_list,
(sett.renderer == RENDERER_CAIROGRAPHICS_PDF (sett.renderer == RENDERER_CAIROGRAPHICS_PDF ? file_name : NULL),
? file_name (sett.renderer == RENDERER_CAIROGRAPHICS_SVG ? file_name : NULL),
: NULL),
(sett.renderer == RENDERER_CAIROGRAPHICS_SVG
? file_name
: NULL),
sett.scale); sett.scale);
break; break;
} }
@ -372,7 +361,6 @@ GtkWindow *create_main_window()
GtkWidget *listbox; GtkWidget *listbox;
GtkWidget *conv_button; GtkWidget *conv_button;
GtkWidget *search_entry; GtkWidget *search_entry;
GtkHeaderBar *header_bar;
static GList *gds_libs; static GList *gds_libs;
static struct open_button_data open_data; static struct open_button_data open_data;
static struct convert_button_data conv_data; static struct convert_button_data conv_data;
@ -416,13 +404,9 @@ GtkWindow *create_main_window()
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(cell_tree)), "changed", g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(cell_tree)), "changed",
G_CALLBACK(cell_selection_changed), conv_button); G_CALLBACK(cell_selection_changed), conv_button);
/* 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);
g_object_unref(main_builder); g_object_unref(main_builder);
return conv_data.main_window; return (conv_data.main_window);
} }
/** @} */ /** @} */

23
main.c
View File

@ -23,7 +23,6 @@
#include "main-window.h" #include "main-window.h"
#include "command-line.h" #include "command-line.h"
#include "external-renderer.h" #include "external-renderer.h"
#include "version/version.h"
struct application_data { struct application_data {
GtkApplication *app; GtkApplication *app;
@ -32,7 +31,7 @@ struct application_data {
static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_data) static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{ {
const struct application_data * const appdata = (const struct application_data *)user_data; struct application_data *appdata = (struct application_data *)user_data;
(void)action; (void)action;
(void)parameter; (void)parameter;
@ -43,7 +42,7 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
{ {
GtkBuilder *builder; GtkBuilder *builder;
GtkDialog *dialog; GtkDialog *dialog;
const struct application_data * const appdata = (const struct application_data *)user_data; struct application_data *appdata = (struct application_data *)user_data;
(void)action; (void)action;
(void)parameter; (void)parameter;
@ -64,7 +63,7 @@ const static GActionEntry app_actions[] = {
static void gapp_activate(GApplication *app, gpointer user_data) static void gapp_activate(GApplication *app, gpointer user_data)
{ {
GtkWindow *main_window; GtkWindow *main_window;
struct application_data * const appdata = (struct application_data *)user_data; struct application_data *appdata = (struct application_data *)user_data;
main_window = create_main_window(); main_window = create_main_window();
appdata->main_window = main_window; appdata->main_window = main_window;
@ -107,12 +106,6 @@ static int start_gui(int argc, char **argv)
return app_status; return app_status;
} }
static void print_version()
{
printf("This is gds-render, version: %s\n\nFor a list of supported commands execute with --help option.\n",
_app_version_string);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
GError *error = NULL; GError *error = NULL;
@ -121,14 +114,12 @@ int main(int argc, char **argv)
gchar *basename; gchar *basename;
gchar *pdfname = NULL, *texname = NULL, *mappingname = NULL, *cellname = NULL, *svgname = NULL; gchar *pdfname = NULL, *texname = NULL, *mappingname = NULL, *cellname = NULL, *svgname = NULL;
gboolean tikz = FALSE, pdf = FALSE, pdf_layers = FALSE, pdf_standalone = FALSE, svg = FALSE; gboolean tikz = FALSE, pdf = FALSE, pdf_layers = FALSE, pdf_standalone = FALSE, svg = FALSE;
gboolean version = FALSE;
gchar *custom_library_path = NULL; gchar *custom_library_path = NULL;
gchar *custom_library_file_name = NULL; gchar *custom_library_file_name = NULL;
int scale = 1000; int scale = 1000;
int app_status = 0; int app_status;
GOptionEntry entries[] = { GOptionEntry entries[] = {
{"version", 'v', 0, G_OPTION_ARG_NONE, &version, "Print version", NULL},
{"tikz", 't', 0, G_OPTION_ARG_NONE, &tikz, "Output TikZ code", NULL }, {"tikz", 't', 0, G_OPTION_ARG_NONE, &tikz, "Output TikZ code", NULL },
{"pdf", 'p', 0, G_OPTION_ARG_NONE, &pdf, "Output PDF document", NULL }, {"pdf", 'p', 0, G_OPTION_ARG_NONE, &pdf, "Output PDF document", NULL },
//{"svg", 'S', 0, G_OPTION_ARG_NONE, &svg, "Output SVG image", NULL }, //{"svg", 'S', 0, G_OPTION_ARG_NONE, &svg, "Output SVG image", NULL },
@ -154,11 +145,6 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
if (version) {
print_version();
goto ret_status;
}
if (argc >= 2) { if (argc >= 2) {
if (scale < 1) { if (scale < 1) {
printf("Scale < 1 not allowed. Setting to 1\n"); printf("Scale < 1 not allowed. Setting to 1\n");
@ -202,6 +188,5 @@ int main(int argc, char **argv)
app_status = start_gui(argc, argv); app_status = start_gui(argc, argv);
} }
ret_status:
return app_status; return app_status;
} }

View File

@ -1,5 +0,0 @@
add_library(version STATIC "version.c")
execute_process(COMMAND bash ./generate-version-string.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VER)
target_compile_definitions(version PUBLIC PROJECT_GIT_VERSION=${GIT_VER})

View File

@ -1 +0,0 @@
git describe --tags

View File

@ -1,34 +0,0 @@
/*
* 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/>.
*/
/**
* @addtogroup MainApplication
* @{
*/
#ifdef PROJECT_GIT_VERSION
#define xstr(a) str(a)
#define str(a) #a
const char *_app_version_string = xstr(PROJECT_GIT_VERSION);
#else
const char *_app_version_string = "! version not set !";
#endif
/** @} */

View File

@ -1,28 +0,0 @@
/*
* 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/>.
*/
/**
* @addtogroup MainApplication
* @{
*/
/** @brief This string holds the 'git describe' version of the app */
extern char *_app_version_string;
/** @} */

View File

@ -127,73 +127,24 @@ static gboolean shape_drawer_drawing_callback(GtkWidget *widget, cairo_t *cr, gp
return FALSE; return FALSE;
} }
static double convert_number_to_engineering(double input, const char **out_prefix)
{
const char *selected_prefix = NULL;
double return_val = 0.0;
int idx;
const static char * prefixes[] = {"y", "z", "a", "f", "p", "n", "u", "m", "c", "d", /* < 1 */
"", /* 1 */
"h", "k", "M", "G", "T", "P", "E", "Z", "Y"}; /* > 1 */
const static double scale[] = {1E-24, 1E-21, 1E-18, 1E-15, 1E-12, 1E-9, 1E-6, 1E-3, 1E-2, 1E-1,
1,
1E2, 1E3, 1E6, 1E9, 1E12, 1E15, 1E18, 1E21, 1E24};
const int prefix_count = (int)(sizeof(prefixes)/sizeof(char *));
for (idx = 1; idx < prefix_count; idx++) {
if (input < scale[idx]) {
/* This prefix is bigger than the number. Take the previous one */
selected_prefix = prefixes[idx-1];
return_val = input / scale[idx-1];
break;
}
}
/* Check if prefix was set by loop. Else take the largest in the list */
if (selected_prefix == NULL) {
selected_prefix = prefixes[prefix_count-1];
return_val = input / scale[prefix_count-1];
}
if (out_prefix)
*out_prefix = selected_prefix;
return return_val;
}
static void renderer_settings_dialog_update_labels(RendererSettingsDialog *self) static void renderer_settings_dialog_update_labels(RendererSettingsDialog *self)
{ {
char default_buff[100]; char default_buff[100];
double scale; double scale;
double width_meters;
double height_meters;
double width_engineering;
const char *width_prefix;
double height_engineering;
const char *height_prefix;
if (!self) if (!self)
return; return;
width_meters = (double)self->cell_width * self->unit_in_meters; snprintf(default_buff, sizeof(default_buff), "Width: %E", self->cell_width * self->unit_in_meters);
height_meters = (double)self->cell_height * self->unit_in_meters;
width_engineering = convert_number_to_engineering(width_meters, &width_prefix);
height_engineering = convert_number_to_engineering(height_meters, &height_prefix);
snprintf(default_buff, sizeof(default_buff), "Width: %.3lf %sm", width_engineering, width_prefix);
gtk_label_set_text(self->x_label, default_buff); gtk_label_set_text(self->x_label, default_buff);
snprintf(default_buff, sizeof(default_buff), "Height: %.3lf %sm", height_engineering, height_prefix); snprintf(default_buff, sizeof(default_buff), "Height: %E", self->cell_height * self->unit_in_meters);
gtk_label_set_text(self->y_label, default_buff); gtk_label_set_text(self->y_label, default_buff);
scale = gtk_range_get_value(GTK_RANGE(self->scale)); scale = gtk_range_get_value(GTK_RANGE(self->scale));
/* Set the pixel sizes */ snprintf(default_buff, sizeof(default_buff), "Output Width: %u px", (unsigned int)((double)self->cell_width / scale));
snprintf(default_buff, sizeof(default_buff), "Output Width: %u px",
(unsigned int)((double)self->cell_width / scale));
gtk_label_set_text(self->x_output_label, default_buff); gtk_label_set_text(self->x_output_label, default_buff);
snprintf(default_buff, sizeof(default_buff), "Output Height: %u px", snprintf(default_buff, sizeof(default_buff), "Output Height: %u px", (unsigned int)((double)self->cell_height / scale));
(unsigned int)((double)self->cell_height / scale));
gtk_label_set_text(self->y_output_label, default_buff); gtk_label_set_text(self->y_output_label, default_buff);
} }
@ -314,6 +265,7 @@ void renderer_settings_dialog_set_cell_width(RendererSettingsDialog *dialog, uns
if (width == 0) if (width == 0)
width = 1; width = 1;
dialog->cell_width = width; dialog->cell_width = width;
renderer_settings_dialog_update_labels(dialog); renderer_settings_dialog_update_labels(dialog);
} }