Compare commits
8 Commits
eeae61ad47
...
1ec0f9b297
Author | SHA1 | Date | |
---|---|---|---|
1ec0f9b297 | |||
2f2eb90b69 | |||
bbf08a4d6e | |||
34a19fa11d | |||
b4ae8eee37 | |||
6e1b7d3f61 | |||
d1e6e7b05a | |||
187ae2a74b |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "c-style-checker"]
|
||||
path = c-style-checker
|
||||
url = https://git.shimatta.de/mhu/c-style-checker
|
@ -8,6 +8,7 @@ pkg_check_modules(CAIRO REQUIRED cairo)
|
||||
|
||||
add_subdirectory(glade)
|
||||
add_subdirectory(doxygen)
|
||||
add_subdirectory(version)
|
||||
|
||||
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS})
|
||||
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
|
||||
@ -35,7 +36,8 @@ add_compile_options(-Wall)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCE} ${CMAKE_CURRENT_BINARY_DIR}/glade/resources.c)
|
||||
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)
|
||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m ${CMAKE_DL_LIBS})
|
||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})
|
||||
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||
|
||||
|
1
c-style-checker
Submodule
1
c-style-checker
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 3a58e3dd1c2ef6de78df89c8fdc7ba96b51cd4e0
|
@ -32,7 +32,8 @@
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_info_list, char *output_file, char *so_path)
|
||||
int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_info_list,
|
||||
char *output_file, char *so_path)
|
||||
{
|
||||
int (*so_render_func)(struct gds_cell *, GList *, char *) = NULL;
|
||||
void *so_handle = NULL;
|
||||
@ -40,9 +41,8 @@ int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_i
|
||||
int ret = 0;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Load shared object */
|
||||
so_handle = dlopen(so_path, RTLD_LAZY);
|
||||
@ -53,7 +53,8 @@ int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *layer_i
|
||||
|
||||
/* Load symbol from library */
|
||||
so_render_func = (int (*)(struct gds_cell *, GList *, char *))dlsym(so_handle, EXTERNAL_LIBRARY_FUNCTION);
|
||||
if ((error_msg = dlerror()) != NULL) {
|
||||
error_msg = dlerror();
|
||||
if (error_msg != NULL) {
|
||||
printf("Rendering function not found in library:\n%s\n", error_msg);
|
||||
goto ret_close_so_handle;
|
||||
}
|
||||
|
@ -7,12 +7,11 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">gds-render</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<object class="GtkHeaderBar" id="header-bar">
|
||||
<property name="name">header</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</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>
|
||||
<child>
|
||||
<object class="GtkButton" id="button-load-gds">
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "widgets/conv-settings-dialog.h"
|
||||
#include "cairo-output/cairo-output.h"
|
||||
#include "trigonometric/cell-trigonometrics.h"
|
||||
#include "version/version.h"
|
||||
#include "tree-renderer/lib-cell-renderer.h"
|
||||
#include "gds-parser/gds-tree-checker.h"
|
||||
|
||||
@ -118,8 +119,11 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
GString *acc_date;
|
||||
unsigned int cell_error_level;
|
||||
|
||||
open_dialog = gtk_file_chooser_dialog_new("Open GDSII File", ptr->main_window, GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"Cancel", GTK_RESPONSE_CANCEL, "Open GDSII", GTK_RESPONSE_ACCEPT, NULL);
|
||||
open_dialog = gtk_file_chooser_dialog_new("Open GDSII File", ptr->main_window,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"Cancel", GTK_RESPONSE_CANCEL,
|
||||
"Open GDSII", GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
file_chooser = GTK_FILE_CHOOSER(open_dialog);
|
||||
/* Add GDS II Filter */
|
||||
filter = gtk_file_filter_new();
|
||||
@ -165,7 +169,6 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
-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);
|
||||
|
||||
@ -196,7 +199,8 @@ static void on_load_gds(gpointer button, gpointer user)
|
||||
CELL_SEL_CELL, gds_c,
|
||||
CELL_SEL_MODDATE, mod_date->str,
|
||||
CELL_SEL_ACCESSDATE, acc_date->str,
|
||||
CELL_SEL_CELL_ERROR_STATE, cell_error_level, -1);
|
||||
CELL_SEL_CELL_ERROR_STATE, cell_error_level,
|
||||
-1);
|
||||
|
||||
/* Delete GStrings including string data. */
|
||||
/* Cell store copies String type data items */
|
||||
@ -238,7 +242,7 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
gint res;
|
||||
char *file_name;
|
||||
union bounding_box cell_box;
|
||||
double height, width;
|
||||
unsigned int height, width;
|
||||
|
||||
/* Get selected cell */
|
||||
selection = gtk_tree_view_get_selection(data->tree_view);
|
||||
@ -257,9 +261,12 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
bounding_box_prepare_empty(&cell_box);
|
||||
calculate_cell_bounding_box(&cell_box, cell_to_render);
|
||||
|
||||
/* Calculate size in meters database units */
|
||||
height = (cell_box.vectors.upper_right.y - cell_box.vectors.lower_left.y);
|
||||
width = (cell_box.vectors.upper_right.x - cell_box.vectors.lower_left.x);
|
||||
/* Calculate size in database units
|
||||
* Note that the results are bound to be positive,
|
||||
* so casting them to unsigned int is asbsolutely valid
|
||||
*/
|
||||
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 */
|
||||
settings = renderer_settings_dialog_new(GTK_WINDOW(data->main_window));
|
||||
@ -318,8 +325,12 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
case RENDERER_CAIROGRAPHICS_SVG:
|
||||
case RENDERER_CAIROGRAPHICS_PDF:
|
||||
cairo_render_cell_to_vector_file(cell_to_render, layer_list,
|
||||
(sett.renderer == RENDERER_CAIROGRAPHICS_PDF ? file_name : NULL),
|
||||
(sett.renderer == RENDERER_CAIROGRAPHICS_SVG ? file_name : NULL),
|
||||
(sett.renderer == RENDERER_CAIROGRAPHICS_PDF
|
||||
? file_name
|
||||
: NULL),
|
||||
(sett.renderer == RENDERER_CAIROGRAPHICS_SVG
|
||||
? file_name
|
||||
: NULL),
|
||||
sett.scale);
|
||||
break;
|
||||
}
|
||||
@ -361,6 +372,7 @@ GtkWindow *create_main_window()
|
||||
GtkWidget *listbox;
|
||||
GtkWidget *conv_button;
|
||||
GtkWidget *search_entry;
|
||||
GtkHeaderBar *header_bar;
|
||||
static GList *gds_libs;
|
||||
static struct open_button_data open_data;
|
||||
static struct convert_button_data conv_data;
|
||||
@ -404,9 +416,13 @@ GtkWindow *create_main_window()
|
||||
g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(cell_tree)), "changed",
|
||||
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);
|
||||
|
||||
return (conv_data.main_window);
|
||||
return conv_data.main_window;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
23
main.c
23
main.c
@ -23,6 +23,7 @@
|
||||
#include "main-window.h"
|
||||
#include "command-line.h"
|
||||
#include "external-renderer.h"
|
||||
#include "version/version.h"
|
||||
|
||||
struct application_data {
|
||||
GtkApplication *app;
|
||||
@ -31,7 +32,7 @@ struct application_data {
|
||||
|
||||
static void app_quit(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||
{
|
||||
struct application_data *appdata = (struct application_data *)user_data;
|
||||
const struct application_data * const appdata = (const struct application_data *)user_data;
|
||||
(void)action;
|
||||
(void)parameter;
|
||||
|
||||
@ -42,7 +43,7 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkDialog *dialog;
|
||||
struct application_data *appdata = (struct application_data *)user_data;
|
||||
const struct application_data * const appdata = (const struct application_data *)user_data;
|
||||
(void)action;
|
||||
(void)parameter;
|
||||
|
||||
@ -63,7 +64,7 @@ const static GActionEntry app_actions[] = {
|
||||
static void gapp_activate(GApplication *app, gpointer user_data)
|
||||
{
|
||||
GtkWindow *main_window;
|
||||
struct application_data *appdata = (struct application_data *)user_data;
|
||||
struct application_data * const appdata = (struct application_data *)user_data;
|
||||
|
||||
main_window = create_main_window();
|
||||
appdata->main_window = main_window;
|
||||
@ -106,6 +107,12 @@ static int start_gui(int argc, char **argv)
|
||||
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)
|
||||
{
|
||||
GError *error = NULL;
|
||||
@ -114,12 +121,14 @@ int main(int argc, char **argv)
|
||||
gchar *basename;
|
||||
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 version = FALSE;
|
||||
gchar *custom_library_path = NULL;
|
||||
gchar *custom_library_file_name = NULL;
|
||||
int scale = 1000;
|
||||
int app_status;
|
||||
int app_status = 0;
|
||||
|
||||
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 },
|
||||
{"pdf", 'p', 0, G_OPTION_ARG_NONE, &pdf, "Output PDF document", NULL },
|
||||
//{"svg", 'S', 0, G_OPTION_ARG_NONE, &svg, "Output SVG image", NULL },
|
||||
@ -145,6 +154,11 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (version) {
|
||||
print_version();
|
||||
goto ret_status;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
if (scale < 1) {
|
||||
printf("Scale < 1 not allowed. Setting to 1\n");
|
||||
@ -188,5 +202,6 @@ int main(int argc, char **argv)
|
||||
app_status = start_gui(argc, argv);
|
||||
}
|
||||
|
||||
ret_status:
|
||||
return app_status;
|
||||
}
|
||||
|
5
version/CMakeLists.txt
Normal file
5
version/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
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})
|
1
version/generate-version-string.sh
Executable file
1
version/generate-version-string.sh
Executable file
@ -0,0 +1 @@
|
||||
git describe --tags
|
34
version/version.c
Normal file
34
version/version.c
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/** @} */
|
28
version/version.h
Normal file
28
version/version.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/** @} */
|
@ -127,24 +127,73 @@ static gboolean shape_drawer_drawing_callback(GtkWidget *widget, cairo_t *cr, gp
|
||||
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)
|
||||
{
|
||||
char default_buff[100];
|
||||
double scale;
|
||||
double width_meters;
|
||||
double height_meters;
|
||||
double width_engineering;
|
||||
const char *width_prefix;
|
||||
double height_engineering;
|
||||
const char *height_prefix;
|
||||
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
snprintf(default_buff, sizeof(default_buff), "Width: %E", self->cell_width * self->unit_in_meters);
|
||||
width_meters = (double)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);
|
||||
snprintf(default_buff, sizeof(default_buff), "Height: %E", self->cell_height * self->unit_in_meters);
|
||||
snprintf(default_buff, sizeof(default_buff), "Height: %.3lf %sm", height_engineering, height_prefix);
|
||||
gtk_label_set_text(self->y_label, default_buff);
|
||||
|
||||
scale = gtk_range_get_value(GTK_RANGE(self->scale));
|
||||
|
||||
snprintf(default_buff, sizeof(default_buff), "Output Width: %u px", (unsigned int)((double)self->cell_width / scale));
|
||||
/* Set the pixel sizes */
|
||||
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);
|
||||
snprintf(default_buff, sizeof(default_buff), "Output Height: %u px", (unsigned int)((double)self->cell_height / scale));
|
||||
snprintf(default_buff, sizeof(default_buff), "Output Height: %u px",
|
||||
(unsigned int)((double)self->cell_height / scale));
|
||||
gtk_label_set_text(self->y_output_label, default_buff);
|
||||
}
|
||||
|
||||
@ -265,7 +314,6 @@ void renderer_settings_dialog_set_cell_width(RendererSettingsDialog *dialog, uns
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
|
||||
|
||||
dialog->cell_width = width;
|
||||
renderer_settings_dialog_update_labels(dialog);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user