Compare commits
80 Commits
v1.2
...
python-ren
Author | SHA1 | Date | |
---|---|---|---|
b959f8282a | |||
22efe4f8ca | |||
f135b42d8a | |||
058564326b | |||
fd1eac7fda | |||
391789b812 | |||
98483da759 | |||
2c91956b32 | |||
aafcb162b7 | |||
232d025211 | |||
1fac7d7721 | |||
ceeb67355d | |||
ba51a437a4 | |||
e461b0be1d | |||
b30aaa4c4e | |||
42f1636860 | |||
fb6e3a29af | |||
d29109e516 | |||
b784f28d4c | |||
f03dd0ab19 | |||
94851570e9 | |||
f4fa1bd4e5 | |||
2e7bb03c17 | |||
39ff0dec1a | |||
74f9663bde | |||
b6a2f29a2f | |||
330285cc2f | |||
24ae5e4d5b | |||
f7d15c7267 | |||
921b55b962 | |||
00d02b8291 | |||
75e01b80c8 | |||
4d3f0ccb94 | |||
89f9a638c6 | |||
7526597251 | |||
7b1722661c | |||
5a43a8a4bf | |||
f11e11e6a7 | |||
0c5dd3c8e7 | |||
77a3a0da5a | |||
f8b0b63937 | |||
2d389342fd | |||
1278af202a | |||
b63da7bf09 | |||
23ba7c0136 | |||
7721a40912 | |||
7297800a99 | |||
943007685c | |||
7d6faf8db7 | |||
9eed1ac33d | |||
246695610c | |||
bd4d91807b | |||
2aa1fffa8e | |||
447d583103 | |||
394efb79cf | |||
2420b80c9e | |||
02f221b926 | |||
dd2f21c5cd | |||
b27676e0a4 | |||
b610b1593a | |||
95f6b31e4b | |||
a4d84cff43 | |||
aa7f5b4745 | |||
71b500e030 | |||
d69d4f3f7e | |||
a60fe6543e | |||
dc32499ad7 | |||
322439145e | |||
231248e404 | |||
88d912f59d | |||
f454ca7e71 | |||
045b9dce30 | |||
112a5ac74c | |||
6b5101ecec | |||
583e5581c0 | |||
519d2296ad | |||
02720ec37b | |||
cf2947d2d5 | |||
c7ceef7d66 | |||
ebce4a2669 |
@@ -1,7 +1,7 @@
|
||||
# Maintainer: Mario Hüttel <mario (dot) huettel (!) gmx (dot) net>
|
||||
|
||||
pkgname=gds-render
|
||||
pkgver=20191020.403.448de30
|
||||
pkgver=v1.2_10_g00d02b8
|
||||
pkgrel=1
|
||||
pkgdesc="Conversion tool for converting GDS layout files into TikZ Code and PDF"
|
||||
arch=('i686' 'x86_64')
|
||||
@@ -15,8 +15,8 @@ sha1sums=('SKIP')
|
||||
|
||||
pkgver () {
|
||||
_date=`date +"%Y%m%d"`
|
||||
cd "${srcdir}/${pkgname}-git"
|
||||
echo "$_date.$(git rev-list --count master).$(git rev-parse --short master)"
|
||||
cd "${srcdir}/${pkgname}-git/version"
|
||||
echo "$(echo "$(sh ./generate-version-string.sh)" | sed 's/-/_/g')"
|
||||
}
|
||||
|
||||
build () {
|
||||
|
@@ -33,24 +33,16 @@ pkg_check_modules(CAIRO REQUIRED cairo)
|
||||
include_directories(${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
add_subdirectory(plugins)
|
||||
|
||||
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("${Yellow}Debug mode for translations used!${ColorReset}")
|
||||
add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"${CMAKE_CURRENT_BINARY_DIR}/translations/output\")
|
||||
message("${BoldMagenta}${CMAKE_CURRENT_BINARY_DIR}/translations/output used as data dir${ColorReset}")
|
||||
else(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("Global locale directory used. Make sure files in /usr/share/locale are available")
|
||||
message("${BoldCyan}Global locale directory used. Make sure files in /usr/share/locale are available${ColorReset}")
|
||||
add_definitions(-DGETTEXT_PACKAGE=\"gds-render\" -DLOCALEDATADIR=\"/usr/share\")
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
add_subdirectory(resources)
|
||||
add_subdirectory(doxygen)
|
||||
add_subdirectory(translations)
|
||||
add_subdirectory(version)
|
||||
|
||||
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
|
||||
add_definitions(${GLIB2_CFLAGS_OTHER})
|
||||
|
||||
aux_source_directory("widgets" LAYER_SOURCES)
|
||||
aux_source_directory("cell-selector" CELL_SELECTOR_SOURCES)
|
||||
@@ -74,15 +66,29 @@ set(SOURCE_GENERATED
|
||||
${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c
|
||||
)
|
||||
|
||||
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
|
||||
SET_SOURCE_FILES_PROPERTIES(${SOURCE_GENERATED} PROPERTIES GENERATED 1)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||
|
||||
add_subdirectory(resources)
|
||||
add_subdirectory(doxygen)
|
||||
add_subdirectory(translations)
|
||||
add_subdirectory(version)
|
||||
|
||||
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
|
||||
add_definitions(${GLIB2_CFLAGS_OTHER})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCE} ${SOURCE_GENERATED})
|
||||
add_dependencies(${PROJECT_NAME} glib-resources)
|
||||
add_dependencies(${PROJECT_NAME} version)
|
||||
add_dependencies(${PROJECT_NAME} translations)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})
|
||||
install (TARGETS ${PROJECT_NAME}
|
||||
RUNTIME
|
||||
DESTINATION bin
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -88,11 +88,13 @@ static void lib_cell_renderer_set_property(GObject *object,
|
||||
g_value_init(&val, G_TYPE_STRING);
|
||||
g_value_set_string(&val, ((struct gds_library *)g_value_get_pointer(value))->name);
|
||||
g_object_set_property(object, "text", &val);
|
||||
g_value_unset(&val);
|
||||
break;
|
||||
case PROP_CELL:
|
||||
g_value_init(&val, G_TYPE_STRING);
|
||||
g_value_set_string(&val, ((struct gds_cell *)g_value_get_pointer(value))->name);
|
||||
g_object_set_property(object, "text", &val);
|
||||
g_value_unset(&val);
|
||||
break;
|
||||
case PROP_ERROR_LEVEL:
|
||||
/* Set cell color according to error level */
|
||||
@@ -100,6 +102,7 @@ static void lib_cell_renderer_set_property(GObject *object,
|
||||
convert_error_level_to_color(&color, g_value_get_uint(value));
|
||||
g_value_set_boxed(&val, &color);
|
||||
g_object_set_property(object, "foreground-rgba", &val);
|
||||
g_value_unset(&val);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -146,6 +146,7 @@ int command_line_convert_gds(const char *gds_name,
|
||||
double scale)
|
||||
{
|
||||
int ret = -1;
|
||||
int render_ret;
|
||||
GList *libs = NULL;
|
||||
int res;
|
||||
GList *renderer_list = NULL;
|
||||
@@ -163,7 +164,14 @@ int command_line_convert_gds(const char *gds_name,
|
||||
|
||||
/* Load layer_settings */
|
||||
layer_sett = layer_settings_new();
|
||||
layer_settings_load_from_csv(layer_sett, layer_file);
|
||||
if (!layer_sett)
|
||||
goto return_value;
|
||||
|
||||
ret = layer_settings_load_from_csv(layer_sett, layer_file);
|
||||
if (ret) {
|
||||
fprintf(stderr, _("Loading layer mapping file failed.\n"));
|
||||
goto ret_destroy_layer_mapping;
|
||||
}
|
||||
|
||||
/* Create renderers */
|
||||
if (create_renderers(renderers, output_file_names, tex_layers, tex_standalone,
|
||||
@@ -221,7 +229,9 @@ int command_line_convert_gds(const char *gds_name,
|
||||
/* Execute all rendererer instances */
|
||||
for (list_iter = renderer_list; list_iter; list_iter = list_iter->next) {
|
||||
current_renderer = GDS_RENDER_OUTPUT_RENDERER(list_iter->data);
|
||||
gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
|
||||
render_ret = gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
|
||||
if (render_ret)
|
||||
fprintf(stderr, "Rendering failed with error code: %d\n", render_ret);
|
||||
}
|
||||
|
||||
ret_destroy_library_list:
|
||||
@@ -231,6 +241,7 @@ ret_clear_renderers:
|
||||
g_object_unref(list_iter->data);
|
||||
ret_destroy_layer_mapping:
|
||||
g_object_unref(layer_sett);
|
||||
return_value:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.8.16
|
||||
# Doxyfile 1.8.17
|
||||
|
||||
# This file describes the settings to be used by the documentation system
|
||||
# doxygen (www.doxygen.org) for a project.
|
||||
@@ -309,7 +309,7 @@ OPTIMIZE_OUTPUT_SLICE = NO
|
||||
# parses. With this tag you can assign which parser to use for a given
|
||||
# extension. Doxygen has a built-in mapping, but you can override or extend it
|
||||
# using this tag. The format is ext=language, where ext is a file extension, and
|
||||
# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
|
||||
# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
|
||||
# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice,
|
||||
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
|
||||
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
|
||||
@@ -535,8 +535,8 @@ HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
|
||||
# (class|struct|union) declarations. If set to NO, these declarations will be
|
||||
# included in the documentation.
|
||||
# declarations. If set to NO, these declarations will be included in the
|
||||
# documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
@@ -851,8 +851,10 @@ INPUT_ENCODING = UTF-8
|
||||
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
|
||||
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
|
||||
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
|
||||
# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
|
||||
# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
|
||||
# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
|
||||
# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen
|
||||
# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd,
|
||||
# *.vhdl, *.ucf, *.qsf and *.ice.
|
||||
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
@@ -928,7 +930,7 @@ EXCLUDE_SYMLINKS = NO
|
||||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_PATTERNS = */test/*
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||
@@ -1265,9 +1267,9 @@ HTML_TIMESTAMP = NO
|
||||
|
||||
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
|
||||
# documentation will contain a main index with vertical navigation menus that
|
||||
# are dynamically created via Javascript. If disabled, the navigation index will
|
||||
# are dynamically created via JavaScript. If disabled, the navigation index will
|
||||
# consists of multiple levels of tabs that are statically embedded in every HTML
|
||||
# page. Disable this option to support browsers that do not have Javascript,
|
||||
# page. Disable this option to support browsers that do not have JavaScript,
|
||||
# like the Qt help browser.
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
@@ -1555,8 +1557,14 @@ FORMULA_FONTSIZE = 10
|
||||
|
||||
FORMULA_TRANSPARENT = YES
|
||||
|
||||
# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
|
||||
# to create new LaTeX commands to be used in formulas as building blocks. See
|
||||
# the section "Including formulas" for details.
|
||||
|
||||
FORMULA_MACROFILE =
|
||||
|
||||
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
|
||||
# https://www.mathjax.org) which uses client side Javascript for the rendering
|
||||
# https://www.mathjax.org) which uses client side JavaScript for the rendering
|
||||
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
|
||||
# installed or if you want to formulas look prettier in the HTML output. When
|
||||
# enabled you may also need to install MathJax separately and configure the path
|
||||
@@ -1626,7 +1634,7 @@ MATHJAX_CODEFILE =
|
||||
SEARCHENGINE = YES
|
||||
|
||||
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
|
||||
# implemented using a web server instead of a web client using Javascript. There
|
||||
# implemented using a web server instead of a web client using JavaScript. There
|
||||
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
|
||||
# setting. When disabled, doxygen will generate a PHP script for searching and
|
||||
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
|
||||
|
@@ -30,7 +30,7 @@ Development is done with the following library versions:
|
||||
|
||||
| Cairographics | GLib2 | GTK3 |
|
||||
| ------------- | ---------- | --------- |
|
||||
| 1.17.3 | 2.60.6-1 | 3.24.10-1 |
|
||||
| 1.17.2 | 2.64.2 | 3.24.18 |
|
||||
|
||||
@section comp-instr Compilation Instructions
|
||||
@subsection linux-build General Linux Build Instruction
|
||||
@@ -47,7 +47,7 @@ Once cmake has finished, type
|
||||
make
|
||||
@endcode
|
||||
to build the program and
|
||||
|
||||
|
||||
@code
|
||||
make documentation
|
||||
@endcode
|
||||
@@ -59,7 +59,7 @@ The subfolder 'AUR' contains a PKGBUILD file to build an Archlinux/Pacman packag
|
||||
|
||||
@subsection comp-warnings Compiler Warnings
|
||||
|
||||
The compiler will throw the following warnings. Compiled with GCC 8.2.1.
|
||||
The compiler will throw the following warnings. Compiled with GCC 9.3.0.
|
||||
|
||||
| Warning | Assessment |
|
||||
| ------- | ---------- |
|
||||
|
@@ -22,5 +22,6 @@
|
||||
* @ref EXTERNAL_LIBRARY_RENDER_FUNCTION | int EXTERNAL_LIBRARY_RENDER_FUNCTION(struct gds_cell *toplevel, GList *layer_info_list, const char *output_file_name, double scale) | Render cell to output file
|
||||
* @ref EXTERNAL_LIBRARY_INIT_FUNCTION | int EXTERNAL_LIBRARY_INIT_FUNCTION(const char *option_string, const char *version_string) | Init function. Executed before rendering. This is given the command line parameters specified for the external renderer and the version string of the currently running gds-render program.
|
||||
* @ref EXTERNAL_LIBRARY_FORK_REQUEST | int EXTERNAL_LIBRARY_FORK_REQUEST; | The pure presence of this integer results in the execution inside a subprocess of hte whole shared object's code
|
||||
* @ref EXTERNAL_LIBRARY_FINALIZE_FUNCTION | int EXTERNAL_LIBRARY_FINALIZE_FUNCTION(void) | Called after rendering
|
||||
*
|
||||
*/
|
||||
|
@@ -5,7 +5,7 @@
|
||||
The version number of this application consists of a given version in the format of 'v1.0'.
|
||||
Where the first number indicates a major release and the second number indicates minor changes.
|
||||
|
||||
Versions, including release candidates and path-levels, are tagged in git.
|
||||
Versions, including release candidates and patch-levels, are tagged in git.
|
||||
|
||||
@subsection rc Release Candidates
|
||||
Release candidates are software versions that seem stable and functional to become a new version but testing is not fully finished. These versions are marked with an '-rcX', where X is the number of the release candidate.
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -80,6 +80,7 @@ enum gds_record {
|
||||
STRANS = 0x1A01,
|
||||
BOX = 0x2D00,
|
||||
LAYER = 0x0D02,
|
||||
DATATYPE = 0x0E02,
|
||||
WIDTH = 0x0F03,
|
||||
PATHTYPE = 0x2102,
|
||||
COLROW = 0x1302,
|
||||
@@ -867,6 +868,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
||||
case LIBNAME:
|
||||
case SNAME:
|
||||
case LAYER:
|
||||
case DATATYPE:
|
||||
case STRNAME:
|
||||
break;
|
||||
default:
|
||||
@@ -1003,6 +1005,16 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
||||
}
|
||||
GDS_INF("\t\tAdded layer %d\n", (int)current_graphics->layer);
|
||||
break;
|
||||
case DATATYPE:
|
||||
if (!current_graphics) {
|
||||
GDS_WARN("Datatype has to be defined inside graphics object. Probably unknown object. Implement it yourself!");
|
||||
break;
|
||||
}
|
||||
current_graphics->datatype = gds_convert_signed_int16(workbuff);
|
||||
if (current_graphics->datatype < 0)
|
||||
GDS_WARN("Datatype negative!");
|
||||
GDS_INF("\t\tAdded datatype %d\n", (int)current_graphics->datatype);
|
||||
break;
|
||||
case MAG:
|
||||
if (rec_data_length != 8) {
|
||||
GDS_WARN("Magnification is not an 8 byte real. Results may be wrong");
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) /**< @brief Return bigger number */
|
||||
#define ABS_DBL(a) ((a) < 0 ? -(a) : (a))
|
||||
|
||||
void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box)
|
||||
void bounding_box_calculate_from_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box)
|
||||
{
|
||||
double xmin = DBL_MAX, xmax = -DBL_MAX, ymin = DBL_MAX, ymax = -DBL_MAX;
|
||||
struct vector_2d temp_vec;
|
||||
@@ -68,7 +68,7 @@ void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t
|
||||
box->vectors.upper_right.y = ymax;
|
||||
}
|
||||
|
||||
void bounding_box_update_box(union bounding_box *destination, union bounding_box *update)
|
||||
void bounding_box_update_with_box(union bounding_box *destination, union bounding_box *update)
|
||||
{
|
||||
if (!destination || !update)
|
||||
return;
|
||||
@@ -151,8 +151,6 @@ void bounding_box_update_with_path(GList *vertices, double thickness,
|
||||
GList *vertex_iterator;
|
||||
struct vector_2d pt;
|
||||
|
||||
/* printf("Warning! Function %s not yet implemented correctly!\n", __func__); */
|
||||
|
||||
if (!vertices || !box)
|
||||
return;
|
||||
|
||||
@@ -173,7 +171,7 @@ void bounding_box_update_with_path(GList *vertices, double thickness,
|
||||
}
|
||||
}
|
||||
|
||||
void bounding_box_update_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt)
|
||||
void bounding_box_update_with_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt)
|
||||
{
|
||||
struct vector_2d point;
|
||||
|
||||
@@ -224,7 +222,7 @@ void bounding_box_apply_transform(double scale, double rotation_deg, bool flip_a
|
||||
vector_2d_rotate(&input_points[i], rotation_deg * M_PI / 180.0);
|
||||
vector_2d_scale(&input_points[i], scale);
|
||||
|
||||
bounding_box_update_point(box, NULL, &input_points[i]);
|
||||
bounding_box_update_with_point(box, NULL, &input_points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ static void update_box_with_gfx(union bounding_box *box, struct gds_graphics *gf
|
||||
case GRAPHIC_BOX:
|
||||
/* Expected fallthrough */
|
||||
case GRAPHIC_POLYGON:
|
||||
bounding_box_calculate_polygon(gfx->vertices,
|
||||
bounding_box_calculate_from_polygon(gfx->vertices,
|
||||
(conv_generic_to_vector_2d_t)&convert_gds_point_to_2d_vector,
|
||||
¤t_box);
|
||||
break;
|
||||
@@ -74,7 +74,7 @@ static void update_box_with_gfx(union bounding_box *box, struct gds_graphics *gf
|
||||
}
|
||||
|
||||
/* Update box with results */
|
||||
bounding_box_update_box(box, ¤t_box);
|
||||
bounding_box_update_with_box(box, ¤t_box);
|
||||
}
|
||||
|
||||
void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell)
|
||||
@@ -113,7 +113,7 @@ void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell)
|
||||
temp_box.vectors.upper_right.y += sub_cell->origin.y;
|
||||
|
||||
/* update the parent's box */
|
||||
bounding_box_update_box(box, &temp_box);
|
||||
bounding_box_update_with_box(box, &temp_box);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ void vector_2d_rotate(struct vector_2d *vec, double angle)
|
||||
sin_val = sin(angle);
|
||||
cos_val = cos(angle);
|
||||
|
||||
vector_2d_copy(&temp, vec);
|
||||
(void)vector_2d_copy(&temp, vec);
|
||||
|
||||
/* Apply rotation matrix */
|
||||
vec->x = (cos_val * temp.x) - (sin_val * temp.y);
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ struct gds_graphics {
|
||||
enum path_type path_render_type; /**< @brief Line cap */
|
||||
int width_absolute; /**< @brief Width. Not used for objects other than paths */
|
||||
int16_t layer; /**< @brief Layer the graphic object is on */
|
||||
uint16_t datatype;
|
||||
int16_t datatype; /**< @brief Data type of graphic object */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,15 +35,44 @@
|
||||
#include <gds-render/geometric/vector-operations.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief Union describing a bounding box
|
||||
*
|
||||
* Two ways of accessing a bounding box are possible.
|
||||
*
|
||||
* Either, use the "named" vectors struct to specifically access the points
|
||||
* @code
|
||||
* lower_left = box.vectors.lower_left;
|
||||
* upper right = box.vectors.upper_right;
|
||||
* @endcode
|
||||
*
|
||||
* or use the iterable vector array:
|
||||
* @code
|
||||
* for (i = 0; i < 2; i++)
|
||||
* box.vector_array[i] = points[i];
|
||||
* @endcode
|
||||
*/
|
||||
union bounding_box {
|
||||
/** Coordinate System is (y up | x right) */
|
||||
/**
|
||||
* @brief Location vectors of upper right and lower left bounding box points
|
||||
* @note Coordinate System is (y up | x right)
|
||||
*/
|
||||
struct _vectors {
|
||||
/** @brief Lower left point of the bounding box */
|
||||
struct vector_2d lower_left;
|
||||
/** @brief Upper right point of the bounding box */
|
||||
struct vector_2d upper_right;
|
||||
} vectors;
|
||||
/**
|
||||
* @brief Array of vectors representing a bounding box
|
||||
* @note This is more convenient for iterating
|
||||
*/
|
||||
struct vector_2d vector_array[2];
|
||||
};
|
||||
|
||||
/*
|
||||
* @brief Pointer to a function that takes any pointer and converts this object to a vector_2d struct
|
||||
*/
|
||||
typedef void (*conv_generic_to_vector_2d_t)(void *, struct vector_2d *);
|
||||
|
||||
/**
|
||||
@@ -52,14 +81,14 @@ typedef void (*conv_generic_to_vector_2d_t)(void *, struct vector_2d *);
|
||||
* @param conv_func Conversion function to convert vertices to vector_2d structs.
|
||||
* @param box Box to write to. This box is not updated! All previous data is discarded
|
||||
*/
|
||||
void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box);
|
||||
void bounding_box_calculate_from_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box);
|
||||
|
||||
/**
|
||||
* @brief Update an exisitng bounding box with another one.
|
||||
* @param destination Target box to update
|
||||
* @param update Box to update the target with
|
||||
*/
|
||||
void bounding_box_update_box(union bounding_box *destination, union bounding_box *update);
|
||||
void bounding_box_update_with_box(union bounding_box *destination, union bounding_box *update);
|
||||
|
||||
/**
|
||||
* @brief Prepare an empty bounding box.
|
||||
@@ -76,7 +105,7 @@ void bounding_box_prepare_empty(union bounding_box *box);
|
||||
* @param conv_func Conversion function to convert \p pt to a vector_2d. May be NULL
|
||||
* @param pt Point to update bounding box with
|
||||
*/
|
||||
void bounding_box_update_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt);
|
||||
void bounding_box_update_with_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt);
|
||||
|
||||
/**
|
||||
* @brief Return all four corner points of a bounding box
|
||||
@@ -102,7 +131,7 @@ void bounding_box_get_all_points(struct vector_2d *points, union bounding_box *b
|
||||
* @param rotation_deg Rotation of bounding box around the origin in degrees (counterclockwise)
|
||||
* @param flip_at_x Flip the boundig box on the x axis before rotating.
|
||||
* @param box Bounding box the operations should be applied to.
|
||||
* @note Keep in mind, that this bounding boxy is actually the bounding box of the rotated boundig box and not the object itself.
|
||||
* @note Keep in mind, that this bounding box is actually the bounding box of the rotated boundig box and not the object itself.
|
||||
* It might be too big.
|
||||
*/
|
||||
void bounding_box_apply_transform(double scale, double rotation_deg, bool flip_at_x, union bounding_box *box);
|
||||
@@ -113,6 +142,9 @@ void bounding_box_apply_transform(double scale, double rotation_deg, bool flip_a
|
||||
* @param thickness Thisckness of the path
|
||||
* @param conv_func Conversion function for vertices to vector_2d structs
|
||||
* @param box Bounding box to write results in.
|
||||
* @warning This function is not yet implemented correctly. Miter points of paths are not taken into account.
|
||||
* If a path is the outmost object of your cell _and_ it is not parallel to one of the coordinate axes,
|
||||
* the calculated bounding box size might be off. In other cases it should be reasonable close to the real bounding box.
|
||||
*/
|
||||
void bounding_box_update_with_path(GList *vertices, double thickness, conv_generic_to_vector_2d_t conv_func, union bounding_box *box);
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,10 +35,17 @@
|
||||
#include <gds-render/gds-utils/gds-types.h>
|
||||
|
||||
/**
|
||||
* @brief calculate_cell_bounding_box Calculate bounding box of gds cell
|
||||
* @param box Resulting boundig box. Will be uüdated and not overwritten
|
||||
* @brief Calculate bounding box of a gds cell.
|
||||
*
|
||||
* This function updates a given bounding box with the dimensions of a
|
||||
* gds_cell. Please note that the handling of path miter points is not complete yet.
|
||||
* If a path object is the outmost object of your cell at any edge,
|
||||
* the resulting bounding box might be the wrong size. The devistion from the real size
|
||||
* is guaranteed to be within the width of the path object.
|
||||
*
|
||||
* @param box Resulting boundig box. Will be updated and not overwritten
|
||||
* @param cell Toplevel cell
|
||||
* @warning Path handling not yet implemented correctly.
|
||||
* @warning Handling of Path graphic objects not yet implemented correctly.
|
||||
*/
|
||||
void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell);
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ struct layer_info
|
||||
{
|
||||
int layer; /**< @brief Layer number */
|
||||
char *name; /**< @brief Layer name. */
|
||||
int stacked_position; ///< @brief Position of layer in output @warning This parameter is not used by any renderer so far @note Lower is bottom, higher is top
|
||||
int stacked_position; /**< @brief Position of layer in output @warning This parameter is not used by any renderer so far @note Lower is bottom, higher is top */
|
||||
GdkRGBA color; /**< @brief RGBA color used to render this layer */
|
||||
int render; /**< @brief true: Render to output */
|
||||
};
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file cairo-renderer.h
|
||||
|
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __EXTERNAL_RENDERER_INTERFACES_H__
|
||||
#define __EXTERNAL_RENDERER_INTERFACES_H__
|
||||
|
||||
@@ -18,6 +37,11 @@
|
||||
*/
|
||||
#define EXPORT_FUNC __attribute__((visibility("default")))
|
||||
|
||||
/**
|
||||
* @brief This define is used to export a variable symbol from a shared object
|
||||
*/
|
||||
#define EXPORT_VAR EXPORT_FUNC
|
||||
|
||||
/**
|
||||
* @brief Function name expected to be found in external library for rendering.
|
||||
*
|
||||
@@ -37,6 +61,15 @@
|
||||
*/
|
||||
#define EXTERNAL_LIBRARY_INIT_FUNCTION exported_init
|
||||
|
||||
/**
|
||||
* @brief Function name expected to be found in external library for finalizing.
|
||||
*
|
||||
* @code
|
||||
* int EXTERNAL_LIBRARY_FINALIZE_FUNCTION(void);
|
||||
* @endcode
|
||||
*/
|
||||
#define EXTERNAL_LIBRARY_FINALIZE_FUNCTION exported_finalize
|
||||
|
||||
/**
|
||||
* @brief Global integer specified by an external renderer to signal, that the init and render functions shall be executed in a subprocess
|
||||
*
|
||||
@@ -48,10 +81,29 @@
|
||||
/**
|
||||
* @brief Define for declaring the exported functions.
|
||||
*
|
||||
* This not only helps with the declaration but also makes the symbols visible, so they can be called form outside the library
|
||||
* This not only helps with the declaration but also makes the symbols visible, so they can be called from outside the library
|
||||
*/
|
||||
#define EXPORTED_FUNC_DECL(FUNC) EXPORT_FUNC FUNC
|
||||
|
||||
/**
|
||||
* @brief Define for declaring exported variables
|
||||
*
|
||||
* This not only helps with the declaration but also makes the symbols visible, so they can be accessed from outside the library
|
||||
*/
|
||||
#define EXPORTED_VAR_DECL(VAR) EXPORT_VAR VAR
|
||||
|
||||
/**
|
||||
* @brief Define for declaring variables based on a define expansion
|
||||
* @note If you want to declare an exported variable use @ref EXPORTED_VAR_DECL
|
||||
*/
|
||||
#define VAR_DECL(VAR) VAR
|
||||
|
||||
/**
|
||||
* @brief Define for declaring functions based on a define expansion
|
||||
* @note If you want to declare an exported function use @ref EXPORTED_FUNC_DECL
|
||||
*/
|
||||
#define FUNC_DECL(FUNC) FUNC
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __EXTERNAL_RENDERER_INTERFACES_H__ */
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
2
main.c
2
main.c
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file cairo-renderer.c
|
||||
@@ -275,12 +275,20 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer
|
||||
goto ret_parent;
|
||||
}
|
||||
|
||||
/* Close stdin and (stdout and stderr may live on) */
|
||||
/* We are now in a separate process just for rendering the output image.
|
||||
* You may print a log message to the activity bar of the gui by writing a line
|
||||
* teminated with '\n' to comm_pipe[1]. This will be handled by the parent process.
|
||||
* Directly calling the update function
|
||||
* gds_output_renderer_update_async_progress()
|
||||
* does not have any effect because this is a separate process.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Close stdin and (stdout and stderr may live on)
|
||||
*/
|
||||
close(0);
|
||||
//close(1);
|
||||
close(comm_pipe[0]);
|
||||
|
||||
|
||||
layers = (struct cairo_layer *)calloc(MAX_LAYERS, sizeof(struct cairo_layer));
|
||||
|
||||
/* Clear layers */
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -67,6 +67,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
|
||||
{
|
||||
int (*so_render_func)(struct gds_cell *, GList *, const char *, double) = NULL;
|
||||
int (*so_init_func)(const char *, const char *) = NULL;
|
||||
int (*so_finalize_func)(void) = NULL;
|
||||
void *so_handle = NULL;
|
||||
char *error_msg;
|
||||
int forking_req;
|
||||
@@ -94,7 +95,7 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
|
||||
so_render_func = (int (*)(struct gds_cell *, GList *, const char *, double))
|
||||
dlsym(so_handle, xstr(EXTERNAL_LIBRARY_RENDER_FUNCTION));
|
||||
error_msg = dlerror();
|
||||
if (error_msg != NULL) {
|
||||
if (error_msg) {
|
||||
fprintf(stderr, _("Rendering function not found in library:\n%s\n"), error_msg);
|
||||
goto ret_close_so_handle;
|
||||
}
|
||||
@@ -102,8 +103,16 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
|
||||
/* Load the init function */
|
||||
so_init_func = (int (*)(const char *, const char *))dlsym(so_handle, xstr(EXTERNAL_LIBRARY_INIT_FUNCTION));
|
||||
error_msg = dlerror();
|
||||
if (error_msg != NULL) {
|
||||
fprintf(stderr, _("Init function not found in library:\n%s\n"), error_msg);
|
||||
if (error_msg) {
|
||||
fprintf(stderr, _("Rendering function not found in library:\n%s\n"), error_msg);
|
||||
goto ret_close_so_handle;
|
||||
}
|
||||
|
||||
/* Load the finalize function */
|
||||
so_finalize_func = (int (*)(void))dlsym(so_handle, xstr(EXTERNAL_LIBRARY_FINALIZE_FUNCTION));
|
||||
error_msg = dlerror();
|
||||
if (error_msg) {
|
||||
fprintf(stderr, "Finalize function not found in library:\n%s\n", error_msg);
|
||||
goto ret_close_so_handle;
|
||||
}
|
||||
|
||||
@@ -128,6 +137,9 @@ static int external_renderer_render_cell(struct gds_cell *toplevel_cell, GList *
|
||||
if (!ret)
|
||||
ret = so_render_func(toplevel_cell, layer_info_list, output_file, scale);
|
||||
|
||||
/* Finalize the external renderer */
|
||||
ret |= so_finalize_func();
|
||||
|
||||
/* If we are in a separate process, terminate here */
|
||||
if (forking_req)
|
||||
exit(ret);
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -100,6 +100,11 @@ static void gds_output_renderer_dispose(GObject *self_obj)
|
||||
if (priv->output_file)
|
||||
g_free(priv->output_file);
|
||||
|
||||
if (priv->idle_function_parameters.status_message) {
|
||||
g_free(priv->idle_function_parameters.status_message);
|
||||
priv->idle_function_parameters.status_message = NULL;
|
||||
}
|
||||
|
||||
g_clear_object(&priv->layer_settings);
|
||||
|
||||
/* Chain up to parent class */
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -1,2 +1,4 @@
|
||||
add_subdirectory(plugin-example)
|
||||
add_custom_target(plugins DEPENDS pluginexample)
|
||||
add_subdirectory(python-renderer)
|
||||
|
||||
add_custom_target(plugins DEPENDS pluginexample pythonrenderer)
|
||||
|
@@ -1,12 +1,11 @@
|
||||
project(pluginexample)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(PYTHON REQUIRED python3)
|
||||
|
||||
aux_source_directory(src SOURCES)
|
||||
|
||||
include_directories(${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
link_libraries(${PYTHON_LDFLAGS} version)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
link_libraries(version)
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL ${SOURCES})
|
||||
add_dependencies(${PROJECT_NAME} version)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -25,7 +25,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <glib.h>
|
||||
#include <gds-render/gds-utils/gds-types.h>
|
||||
@@ -46,4 +45,10 @@ int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
|
||||
{
|
||||
printf("Finalize function called.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
34
plugins/python-renderer/CMakeLists.txt
Normal file
34
plugins/python-renderer/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
project(pythonrenderer)
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
find_package(PythonLibs)
|
||||
|
||||
if(NOT WIN32)
|
||||
string(ASCII 27 Esc)
|
||||
set(ColorReset "${Esc}[m")
|
||||
set(ColorBold "${Esc}[1m")
|
||||
set(Red "${Esc}[31m")
|
||||
set(Green "${Esc}[32m")
|
||||
set(Yellow "${Esc}[33m")
|
||||
set(Blue "${Esc}[34m")
|
||||
set(Magenta "${Esc}[35m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
set(White "${Esc}[37m")
|
||||
set(BoldRed "${Esc}[1;31m")
|
||||
set(BoldGreen "${Esc}[1;32m")
|
||||
set(BoldYellow "${Esc}[1;33m")
|
||||
set(BoldBlue "${Esc}[1;34m")
|
||||
set(BoldMagenta "${Esc}[1;35m")
|
||||
set(BoldCyan "${Esc}[1;36m")
|
||||
set(BoldWhite "${Esc}[1;37m")
|
||||
endif()
|
||||
|
||||
aux_source_directory(src SOURCES)
|
||||
|
||||
include_directories(${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
link_libraries(${PYTHON_LIBRARIES} version)
|
||||
|
||||
message("${BoldCyan}Python version found: ${PYTHONLIBS_VERSION_STRING}${ColorReset}")
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED EXCLUDE_FROM_ALL ${SOURCES})
|
||||
add_dependencies(${PROJECT_NAME} version)
|
||||
|
43
plugins/python-renderer/include/python-renderer/force-fork.h
Normal file
43
plugins/python-renderer/include/python-renderer/force-fork.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* GDSII-Converter Python Plugin
|
||||
* Copyright (C) 2019 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file force-fork.h
|
||||
* @brief Header file force fork variabel definition.
|
||||
*
|
||||
* This file makes the force fork variable accessible.
|
||||
* Actually this is kind of useless. However, here it is :)
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
#ifndef __PYTHON_PLUGIN_FORCE_FORK_H__
|
||||
#define __PYTHON_PLUGIN_FORCE_FORK_H__
|
||||
|
||||
/**
|
||||
* @addtogroup python-plugin
|
||||
* @{
|
||||
*/
|
||||
#include <gds-render/output-renderers/external-renderer-interfaces.h>
|
||||
|
||||
extern const int VAR_DECL(EXTERNAL_LIBRARY_FORK_REQUEST);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __PYTHON_PLUGIN_FORCE_FORK_H__ */
|
||||
|
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* GDSII-Converter Python Plugin
|
||||
* Copyright (C) 2019 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file gds-render-module.h
|
||||
* @brief Header file for the gds-render python module implementation
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
#ifndef __GDS_RENDER_MODULE_H__
|
||||
#define __GDS_RENDER_MODULE_H__
|
||||
|
||||
/**
|
||||
* @addtogroup python-renderer
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
/**
|
||||
* @brief The gds_render python module name as string
|
||||
*/
|
||||
#define GDS_RENDER_MOD_NAME "gds_render"
|
||||
|
||||
/**
|
||||
* @brief Set up the gds_render python module
|
||||
* @return New module reference
|
||||
*/
|
||||
PyObject *init_gds_render_module();
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __GDS_RENDER_MODULE_H__ */
|
50
plugins/python-renderer/include/python-renderer/glist.h
Normal file
50
plugins/python-renderer/include/python-renderer/glist.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* GDSII-Converter Python Plugin
|
||||
* Copyright (C) 2020 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file python-renderer/glist.c
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup python-plugin-glist GList wrapper for python
|
||||
* @ingroup python-plugin
|
||||
* This is a wrapping class for GLists
|
||||
* @addtogroup python-plugin-glist
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __GLIST_H__
|
||||
#define __GLIST_H__
|
||||
|
||||
#ifndef PY_SSIZE_T_CLEAN
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#endif
|
||||
#include <Python.h>
|
||||
#include <glib.h>
|
||||
|
||||
extern PyTypeObject GListType;
|
||||
|
||||
typedef struct _GListObject GListObject;
|
||||
|
||||
void glist_set_head_ptr(GListObject *self, GList *head);
|
||||
|
||||
#endif /* __GLIST_H__ */
|
||||
|
||||
/** @} */
|
37
plugins/python-renderer/src/force-fork.c
Normal file
37
plugins/python-renderer/src/force-fork.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* GDSII-Converter Python Plugin
|
||||
* Copyright (C) 2019 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file python-renderer/force-fork.c
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
#include <python-renderer/force-fork.h>
|
||||
|
||||
/**
|
||||
* @addtogroup python-plugin
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* The precense of this variable tells the gds-render application to execute this plugin in a separate process
|
||||
* The variable's value is don't care
|
||||
*/
|
||||
const int EXPORTED_VAR_DECL(EXTERNAL_LIBRARY_FORK_REQUEST) = 1;
|
||||
|
||||
/** @} */
|
100
plugins/python-renderer/src/gds-render-module.c
Normal file
100
plugins/python-renderer/src/gds-render-module.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* GDSII-Converter Python Plugin
|
||||
* Copyright (C) 2019 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file gds-render-module.c
|
||||
* @brief Gds-render python module implementation
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
#include <python-renderer/gds-render-module.h>
|
||||
#include <gds-render/gds-utils/gds-types.h>
|
||||
#include <python-renderer/glist.h>
|
||||
|
||||
static PyObject *test(PyObject *self, PyObject *args)
|
||||
{
|
||||
long int i;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "l:get_number", &i))
|
||||
return NULL;
|
||||
|
||||
i *= i;
|
||||
|
||||
return PyLong_FromLong(i);
|
||||
}
|
||||
|
||||
static PyMethodDef gds_render_methods[] = {
|
||||
{"get_number", test, METH_VARARGS, "Return the number of arguments received by the process."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
static PyModuleDef gds_render_module_def = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
.m_name = GDS_RENDER_MOD_NAME,
|
||||
.m_doc = "GDS Render Base App Module",
|
||||
.m_size = -1,
|
||||
.m_methods = gds_render_methods,
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static int gds_render_module_check_types_ready()
|
||||
{
|
||||
if (!PyType_Ready(&GListType))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gds_render_module_add_types(PyObject *module)
|
||||
{
|
||||
int err;
|
||||
|
||||
Py_INCREF(&GListType);
|
||||
err = PyModule_AddObject(module, "GdsPoint", (PyObject *)&GListType);
|
||||
if (err < 0) {
|
||||
goto decref_glist;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
decref_glist:
|
||||
Py_DECREF(&GListType);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject *init_gds_render_module(void)
|
||||
{
|
||||
int err;
|
||||
PyObject *gds_render_module;
|
||||
|
||||
if (gds_render_module_check_types_ready())
|
||||
return NULL;
|
||||
|
||||
gds_render_module = PyModule_Create(&gds_render_module_def);
|
||||
|
||||
err = gds_render_module_add_types(gds_render_module);
|
||||
if (err) {
|
||||
Py_DECREF(gds_render_module);
|
||||
gds_render_module = NULL;
|
||||
goto return_module;
|
||||
}
|
||||
|
||||
return_module:
|
||||
return gds_render_module;
|
||||
}
|
72
plugins/python-renderer/src/glist.c
Normal file
72
plugins/python-renderer/src/glist.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* GDSII-Converter Python Plugin
|
||||
* Copyright (C) 2020 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file python-renderer/glist.c
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup python-plugin-glist GList wrapper for python
|
||||
* @ingroup python-plugin
|
||||
* This is a wrapping class for GLists
|
||||
* This wrpper acts as a read only access to the lists
|
||||
*
|
||||
* @addtogroup python-plugin-glist
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <python-renderer/glist.h>
|
||||
|
||||
struct _GListObject {
|
||||
PyObject_HEAD
|
||||
GList *head;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
static PyObject *glist_to_list(GListObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
static PyMethodDef glist_methods[] = {
|
||||
{"tolist", (PyCFunction)glist_to_list, METH_NOARGS, "Convert GList to editable list"}
|
||||
};
|
||||
|
||||
void glist_set_head_ptr(GListObject *self, GList *head)
|
||||
{
|
||||
if (!self || !head)
|
||||
return;
|
||||
|
||||
self->head = head;
|
||||
self->len = g_list_length(self->head);
|
||||
}
|
||||
|
||||
PyTypeObject GListType = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
.tp_name = "gds_render.GList",
|
||||
.tp_doc = "Read only GList",
|
||||
.tp_basicsize = sizeof(GListObject),
|
||||
.tp_itemsize = 0,
|
||||
.tp_flags = Py_TPFLAGS_DEFAULT,
|
||||
.tp_new = PyType_GenericNew,
|
||||
.tp_methods = glist_methods
|
||||
};
|
||||
|
||||
/** @} */
|
173
plugins/python-renderer/src/plugin-main.c
Normal file
173
plugins/python-renderer/src/plugin-main.c
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* GDSII-Converter Python Plugin
|
||||
* Copyright (C) 2019 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file python-renderer/plugin-main.c
|
||||
* @author Mario Hüttel <mario.huettel@gmx.net>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup python-plugin Python Plugin for External Renderer
|
||||
* @ingroup plugins
|
||||
* This is a plugin for calling an external python script as renderer
|
||||
* @addtogroup python-plugin
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libgen.h>
|
||||
#include <glib.h>
|
||||
#include <unistd.h>
|
||||
#include <Python.h>
|
||||
|
||||
#include <gds-render/gds-utils/gds-types.h>
|
||||
#include <gds-render/output-renderers/external-renderer-interfaces.h>
|
||||
|
||||
#include <python-renderer/gds-render-module.h>
|
||||
|
||||
/**
|
||||
* @brief Global variable for loaded module. This is not very nice.
|
||||
* @warning This has to be changed, if this api wants to be re-entrant.
|
||||
*/
|
||||
static PyObject *p_module = NULL;
|
||||
|
||||
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_RENDER_FUNCTION)(struct gds_cell *toplevel, GList *layer_info_list, const char *output_file_name, double scale)
|
||||
{
|
||||
int ret = 0;
|
||||
PyObject *p_render_func;
|
||||
PyObject *p_return_value;
|
||||
|
||||
if (!toplevel)
|
||||
return -1000;
|
||||
if (!p_module)
|
||||
return -2000;
|
||||
|
||||
printf("Rendering %s\n", toplevel->name);
|
||||
|
||||
p_render_func = PyObject_GetAttrString(p_module, "test_func");
|
||||
if (!p_render_func && !PyCallable_Check(p_render_func)) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
else
|
||||
fprintf(stderr, "Function not found in python module\n");
|
||||
|
||||
ret = -1;
|
||||
goto return_value;
|
||||
}
|
||||
|
||||
p_return_value = PyObject_CallObject(p_render_func, NULL);
|
||||
if (p_return_value) {
|
||||
printf("Result of call: %ld\n", PyLong_AsLong(p_return_value));
|
||||
Py_DECREF(p_return_value);
|
||||
}
|
||||
|
||||
Py_XDECREF(p_render_func);
|
||||
|
||||
return_value:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const char *version)
|
||||
{
|
||||
int ret = 0;
|
||||
PyObject *p_name;
|
||||
PyObject *p_sys_path;
|
||||
PyObject *p_mod_dir_string;
|
||||
PyObject *gds_render_module;
|
||||
char file_path[PATH_MAX];
|
||||
char *file_path_for_dir;
|
||||
char *file_path_for_base;
|
||||
char *dir_name;
|
||||
char *base_name;
|
||||
|
||||
if (!params || !version)
|
||||
return -1000;
|
||||
|
||||
printf("Init with params: %s\ngds-render version: %s\n", params, version);
|
||||
|
||||
ret = PyImport_AppendInittab("gds_render", &init_gds_render_module);
|
||||
if (ret) {
|
||||
ret = -1;
|
||||
fprintf(stderr, "Registration of gds_render python module failed\n");
|
||||
goto return_value;
|
||||
}
|
||||
|
||||
Py_Initialize();
|
||||
|
||||
if (!realpath(params, file_path)) {
|
||||
ret = -2;
|
||||
fprintf(stderr, "Invalid file name.\n");
|
||||
goto return_value;
|
||||
}
|
||||
|
||||
file_path_for_dir = strdup(file_path);
|
||||
if (!file_path_for_dir) {
|
||||
ret = -3;
|
||||
goto return_value;
|
||||
}
|
||||
|
||||
file_path_for_base = strdup(file_path);
|
||||
if (!file_path_for_base) {
|
||||
ret = -3;
|
||||
free (file_path_for_dir);
|
||||
goto return_value;
|
||||
}
|
||||
|
||||
dir_name = dirname(file_path_for_dir);
|
||||
base_name = basename(file_path_for_base);
|
||||
|
||||
printf("Dir name : %s\n BAse name: %s\n", dir_name, base_name);
|
||||
|
||||
p_sys_path = PySys_GetObject("path");
|
||||
p_mod_dir_string = PyUnicode_FromString(dir_name);
|
||||
PyList_Append(p_sys_path, p_mod_dir_string);
|
||||
Py_DECREF(p_mod_dir_string);
|
||||
|
||||
p_name = PyUnicode_DecodeFSDefault(strtok(base_name, "."));
|
||||
p_module = PyImport_Import(p_name);
|
||||
Py_DECREF(p_name);
|
||||
|
||||
if (!p_module) {
|
||||
PyErr_Print();
|
||||
fprintf(stderr, "Failed to load %s\n", params);
|
||||
ret = -1;
|
||||
goto return_value;
|
||||
}
|
||||
|
||||
free(file_path_for_dir);
|
||||
free(file_path_for_base);
|
||||
|
||||
return_value:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EXPORTED_FUNC_DECL(EXTERNAL_LIBRARY_FINALIZE_FUNCTION)(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
printf("Finalizing\n");
|
||||
|
||||
if (p_module)
|
||||
Py_DECREF(p_module);
|
||||
|
||||
ret = Py_FinalizeEx();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** @} */
|
41
test/CMakeLists.txt
Normal file
41
test/CMakeLists.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
project(gds-render-test)
|
||||
|
||||
add_custom_target(test "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}" "-r compact" "-s" DEPENDS ${PROJECT_NAME})
|
||||
|
||||
if(NOT WIN32)
|
||||
string(ASCII 27 Esc)
|
||||
set(ColorReset "${Esc}[m")
|
||||
set(ColorBold "${Esc}[1m")
|
||||
set(Red "${Esc}[31m")
|
||||
set(Green "${Esc}[32m")
|
||||
set(Yellow "${Esc}[33m")
|
||||
set(Blue "${Esc}[34m")
|
||||
set(Magenta "${Esc}[35m")
|
||||
set(Cyan "${Esc}[36m")
|
||||
set(White "${Esc}[37m")
|
||||
set(BoldRed "${Esc}[1;31m")
|
||||
set(BoldGreen "${Esc}[1;32m")
|
||||
set(BoldYellow "${Esc}[1;33m")
|
||||
set(BoldBlue "${Esc}[1;34m")
|
||||
set(BoldMagenta "${Esc}[1;35m")
|
||||
set(BoldCyan "${Esc}[1;36m")
|
||||
set(BoldWhite "${Esc}[1;37m")
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/catch-framework")
|
||||
|
||||
aux_source_directory("geometric" GEOMETRIC_TEST_SOURCES)
|
||||
set(TEST_SOURCES
|
||||
${GEOMETRIC_TEST_SOURCES}
|
||||
)
|
||||
|
||||
set(DUT_SOURCES
|
||||
"../geometric/vector-operations.c"
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} EXCLUDE_FROM_ALL "test-main.cpp" ${TEST_SOURCES} ${DUT_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${GTK3_LDFLAGS} ${CAIRO_LDFLAGS} m version ${CMAKE_DL_LIBS})
|
||||
|
17618
test/catch-framework/catch.hpp
Normal file
17618
test/catch-framework/catch.hpp
Normal file
File diff suppressed because it is too large
Load Diff
160
test/geometric/vector-operations.cpp
Normal file
160
test/geometric/vector-operations.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
#include <catch.hpp>
|
||||
#include <limits>
|
||||
|
||||
extern "C" {
|
||||
#include <gds-render/geometric/vector-operations.h>
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_add", "[GEOMETRIC]")
|
||||
{
|
||||
struct vector_2d res;
|
||||
struct vector_2d a;
|
||||
struct vector_2d b;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 2;
|
||||
|
||||
b.x = 2;
|
||||
b.y = 6;
|
||||
|
||||
vector_2d_add(&res, &a, &b);
|
||||
|
||||
REQUIRE(res.x == Approx(a.x + b.x));
|
||||
REQUIRE(res.y == Approx(a.y + b.y));
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_calculate_angle_between", "[GEOMETRIC]")
|
||||
{
|
||||
double angle;
|
||||
struct vector_2d a;
|
||||
struct vector_2d b;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 0;
|
||||
|
||||
b.x = 0;
|
||||
b.y = 1;
|
||||
|
||||
angle = vector_2d_calculate_angle_between(&a, &a);
|
||||
REQUIRE(angle == Approx(0.0));
|
||||
|
||||
angle = vector_2d_calculate_angle_between(&a, &b);
|
||||
REQUIRE(angle == Approx(90.0 / 180.0 * M_PI));
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_subtract", "[GEOMETRIC]")
|
||||
{
|
||||
struct vector_2d res;
|
||||
struct vector_2d a;
|
||||
struct vector_2d b;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 2;
|
||||
|
||||
b.x = 2;
|
||||
b.y = 6;
|
||||
|
||||
vector_2d_subtract(&res, &a, &b);
|
||||
|
||||
REQUIRE(res.x == Approx(a.x - b.x));
|
||||
REQUIRE(res.y == Approx(a.y - b.y));
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_abs", "[GEOMETRIC]")
|
||||
{
|
||||
struct vector_2d c;
|
||||
struct vector_2d a;
|
||||
struct vector_2d b;
|
||||
double a_len, b_len, c_len;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 0;
|
||||
|
||||
b.x = 0;
|
||||
b.y = 2;
|
||||
|
||||
c.x = 3;
|
||||
c.y = 4;
|
||||
|
||||
a_len = vector_2d_abs(&a);
|
||||
b_len = vector_2d_abs(&b);
|
||||
c_len = vector_2d_abs(&c);
|
||||
|
||||
REQUIRE(a_len == Approx(1.0));
|
||||
REQUIRE(b_len == Approx(2.0));
|
||||
REQUIRE(c_len == Approx(5.0));
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_scalar_multipy", "[GEOMETRIC]")
|
||||
{
|
||||
struct vector_2d c;
|
||||
struct vector_2d a;
|
||||
struct vector_2d b;
|
||||
double mult;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 0;
|
||||
b.x = 0;
|
||||
b.y = 2;
|
||||
mult = vector_2d_scalar_multipy(&a, &b);
|
||||
REQUIRE(mult == Approx(0.0));
|
||||
|
||||
a.x = 1;
|
||||
a.y = 1;
|
||||
b.x = 1;
|
||||
b.y = 1;
|
||||
mult = vector_2d_scalar_multipy(&a, &b);
|
||||
REQUIRE(mult == Approx(2.0));
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_normalize", "[GEOMETRIC]")
|
||||
{
|
||||
struct vector_2d a;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 0;
|
||||
vector_2d_normalize(&a);
|
||||
REQUIRE(a.x == Approx(1.0));
|
||||
REQUIRE(a.y == Approx(0.0));
|
||||
|
||||
a.x = 1;
|
||||
a.y = -1;
|
||||
vector_2d_normalize(&a);
|
||||
REQUIRE(a.x == Approx(1.0/sqrt(2)));
|
||||
REQUIRE(a.y == Approx(-1.0/sqrt(2)));
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_rotate", "[GEOMETRIC]")
|
||||
{
|
||||
struct vector_2d a;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 0;
|
||||
vector_2d_rotate(&a, M_PI/2);
|
||||
REQUIRE(a.x == Approx(0.0).scale(0.001));
|
||||
REQUIRE(a.y == Approx(1.0));
|
||||
|
||||
a.x = 0;
|
||||
a.y = 1;
|
||||
vector_2d_rotate(&a, -M_PI/2);
|
||||
vector_2d_rotate(&a, M_PI);
|
||||
REQUIRE(a.x == Approx(-1.0));
|
||||
REQUIRE(a.y == Approx(0.0).scale(0.001));
|
||||
}
|
||||
|
||||
TEST_CASE("geometric/vector-operations/vector_2d_scale", "[GEOMETRIC]")
|
||||
{
|
||||
struct vector_2d a;
|
||||
|
||||
a.x = 1;
|
||||
a.y = 0;
|
||||
vector_2d_scale(&a, 2.0);
|
||||
REQUIRE(a.x == Approx(2.0));
|
||||
REQUIRE(a.y == Approx(0.0));
|
||||
|
||||
a.x = 1;
|
||||
a.y = -3;
|
||||
vector_2d_scale(&a, 0.5);
|
||||
REQUIRE(a.x == Approx(0.5));
|
||||
REQUIRE(a.y == Approx(-1.5));
|
||||
}
|
2
test/test-main.cpp
Normal file
2
test/test-main.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch-framework/catch.hpp"
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* 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/>.
|
||||
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user