44 Commits

Author SHA1 Message Date
01613d1977 Implement simple hole stencil to resolve holes in GDS polygons. 2022-04-19 22:14:52 +02:00
a6899a3f7c Add poly2tri and C++ wrapper for polygon tesselation. 2022-04-19 20:04:08 +02:00
4aa63db8dd Start preview feature. Add dummy triangle to test OpenGL. 2022-04-18 17:14:27 +02:00
f42d61192a Add preview rendering skeleton 2022-04-18 14:17:21 +02:00
8b1f667819 Merge pull request 'issue/47-add-vertex-count-to-gui' (#48) from issue/47-add-vertex-count-to-gui into dev
Reviewed-on: #48
2022-04-17 20:09:47 +02:00
c2ca2ff573 Rework the analysis cmd option to work with new statistics functions 2022-04-17 20:07:57 +02:00
c0ac6cc3c5 Move statistic calculation to parser. Show Vertex and GFX count in GUI. CLI -A param is now broken. Will implement in next commits. 2022-04-17 18:37:32 +02:00
22bc3a18d7 Issue #47: Add renderer for cell statistics and render dummy value 2022-04-17 17:40:18 +02:00
dbc9fcdf34 Issue #47: AddVertex count column to tree view 2022-04-17 16:54:57 +02:00
b39030aeaa Fix PKGBUILD 2022-04-17 00:47:41 +02:00
2f59a762cd Fix PKGBUILD 2022-04-17 00:46:51 +02:00
ab26f8a2af Fix PKGBUILD 2022-04-17 00:45:49 +02:00
9a43cd53f8 Update PKGBUILD 2022-04-17 00:38:50 +02:00
ba6b07c8a2 Implement cell statistics command line interface 2022-04-17 00:37:26 +02:00
1548c82542 Add libfort for pretty console tables 2022-04-16 16:13:22 +02:00
fb6d31c120 Fix stuck at -1 return value when executing command line interface 2022-04-16 16:00:50 +02:00
f6c65d9c7a Merge branch 'dev' 2022-04-10 15:35:14 +02:00
d43bec2cea Merge pull request 'issue/44-remove-duplicate-vertices' (#45) from issue/44-remove-duplicate-vertices into dev
Reviewed-on: #45
2022-04-10 15:33:41 +02:00
05a1ef9014 Disable debug output of parser. 2022-04-10 15:31:55 +02:00
a36b78b237 Add vertex simplification to parser
* Duplicate / Redundant vertices of polygons are now removed during parsing.
* Implications: Reduced output size of tex document, faster rendering.
2022-04-10 15:28:23 +02:00
ac87cafa37 Merge pull request 'Merge new features and minor fixes for v1.2.1 release' (#43) from dev into master
Reviewed-on: #43
2022-04-09 20:39:09 +02:00
091729841a Merge branch 'master' into dev 2022-04-09 20:39:07 +02:00
28368e8a32 Cairo Renderer: Only print notification that layer is rendered, if it is actually rendered 2022-04-09 20:36:49 +02:00
2b3cc8222a Merge pull request 'Change icons to new Adwaita icons' (#42) from update-icons into dev
Reviewed-on: #42
2022-04-09 20:15:26 +02:00
c23150b819 Merge branch 'dev' into update-icons 2022-04-09 20:15:01 +02:00
049e6c2a4c Merge pull request 'Improve some features' (#41) from improve-features into dev
Reviewed-on: #41
2022-04-09 20:13:47 +02:00
600e10e4d5 Increase layer count of Cairo renderer as this turned out to be too low for some semiconductor technologies 2022-04-09 20:10:11 +02:00
238f2cea82 Improve Autonaming in GUI
Autonaming now only asks for overwrite confirmation, if there
are layers with non empty names. Otherwise, the dialog is not shown.
2022-04-09 20:08:24 +02:00
91706ccf2e Change icons to new Adwaita icons 2022-04-09 19:40:39 +02:00
17e7239e54 Merge branch 'dev' 2022-02-11 21:57:10 +01:00
554b73c406 Fix hard crash in case of a unwritable Latex Output file. Print warnign instead of hard stop 2022-02-11 21:56:54 +01:00
4eebff04a4 Update README.MD
Add github status badge for CI
2021-10-01 23:46:32 +02:00
04525611fa Update cmake.yml
Add gettext to dependencies
2021-10-01 23:43:37 +02:00
cb92d64ec3 Update cmake.yml 2021-10-01 23:41:40 +02:00
37ff2080f9 Create cmake.yml 2021-10-01 23:35:16 +02:00
e1b85d1a99 Merge branch 'issue/39-fix-search' of mhu/gds-render into dev 2020-11-26 23:08:55 +01:00
b0c9afdae5 Fix #39: Checking of pure library entry in cell selector was broken 2020-11-26 23:07:48 +01:00
f6abfada2c ColorPalette: Fix Dispose function
* Set freed pointer to NULL in dispose function because dispose cna be run multiple times. This fixes the case of freeing an already freed pointer.
2020-07-09 23:54:40 +02:00
f135b42d8a make clear we're not getting a return value from vector_2d_copy 2020-06-29 20:03:38 +02:00
058564326b Update library and compiler versions in doxygen 2020-04-24 01:17:20 +02:00
fd1eac7fda Merge branch 'master' into dev 2020-04-24 01:07:50 +02:00
2c91956b32 Doxygen: Update calculate_cell_bounding_box()
* Fix typo
* Extend description
2020-04-24 01:05:37 +02:00
232d025211 Doxygen: Update calculate_cell_bounding_box()
* Add note about problematic behaviour
* Fix typos
2020-04-24 01:02:10 +02:00
e461b0be1d Merge branch 'dev' 2020-04-19 00:52:42 +02:00
43 changed files with 1594 additions and 229 deletions

37
.github/workflows/cmake.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: CMake
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install libgtk-3-dev gettext
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

7
.gitmodules vendored
View File

@@ -2,3 +2,10 @@
path = c-style-checker
url = https://git.shimatta.de/mhu/c-style-checker
branch = master
[submodule "3rdparty/libfort"]
path = 3rdparty/libfort
url = https://git.shimatta.de/3rd-party/libfort
branch = develop
[submodule "3rdparty/poly2tri"]
path = 3rdparty/poly2tri
url = https://git.shimatta.de/3rd-party/poly2tri.git

1
3rdparty/libfort vendored Submodule

Submodule 3rdparty/libfort added at 41237162a9

1
3rdparty/poly2tri vendored Submodule

Submodule 3rdparty/poly2tri added at 3380f5c805

View File

@@ -10,8 +10,8 @@ licence=('GPLv2')
depends=('glib2' 'gtk3' 'cairo')
makedepends=('cmake' 'git')
privides=('gds-render')
source=("${pkgname}-git"::"git+https://git.shimatta.de/mhu/gds-render.git")
sha1sums=('SKIP')
source=("${pkgname}-git"::"git+https://git.shimatta.de/mhu/gds-render.git" "https://git.shimatta.de/3rd-party/libfort.git")
sha1sums=('SKIP' 'SKIP')
pkgver () {
_date=`date +"%Y%m%d"`
@@ -26,6 +26,13 @@ build () {
make
}
prepare () {
cd "${pkgname}-git"
git submodule init
git config submodule.libfort.url "$srcdir/libfort"
git submodule update
}
package () {
cd "$srcdir/$pkgname-git/build"
make DESTDIR="${pkgdir}" install

View File

@@ -1,4 +1,8 @@
project(gds-render)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)
project(gds-render LANGUAGES C CXX)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr/" CACHE PATH "..." FORCE)
@@ -24,7 +28,7 @@ if(NOT WIN32)
set(BoldWhite "${Esc}[1;37m")
endif()
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
@@ -71,12 +75,21 @@ 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)
set(FORT_ENABLE_TESTING OFF CACHE INTERNAL "")
add_subdirectory(3rdparty/libfort)
if(OPENGL_PREVIEW)
message("${Green}OpenGL preview activated${ColorReset}")
add_definitions(-DGDS_RENDER_OPGENGL_PREVIEW)
add_subdirectory(preview-rendering)
endif(OPENGL_PREVIEW)
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
add_definitions(${GLIB2_CFLAGS_OTHER})
@@ -85,10 +98,14 @@ add_executable(${PROJECT_NAME} ${SOURCE} ${SOURCE_GENERATED})
add_dependencies(${PROJECT_NAME} glib-resources)
add_dependencies(${PROJECT_NAME} version)
add_dependencies(${PROJECT_NAME} translations)
if(OPENGL_PREVIEW)
add_dependencies(${PROJECT_NAME} opengl-preview)
target_link_libraries(${PROJECT_NAME} opengl-preview)
endif(OPENGL_PREVIEW)
install (TARGETS ${PROJECT_NAME}
RUNTIME
DESTINATION bin
)
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 version ${CMAKE_DL_LIBS} fort)

View File

@@ -1,5 +1,7 @@
# GDS-Render Readme
[![CMake](https://github.com/0mhu/gds-render/actions/workflows/cmake.yml/badge.svg?branch=master)](https://github.com/0mhu/gds-render/actions/workflows/cmake.yml)
This software is a rendering programm for GDS2 layout files.
The GDS2 format is mainly used in integrated circuit development.
This program allows the conversion of a GDS file to a vector graphics file.

View File

@@ -0,0 +1,106 @@
/*
* GDSII-Converter
* Copyright (C) 2022 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 cell-statistics-renderer.c
* @brief CellStatisticsRenderer GObject Class
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @addtogroup CellStatisticsRenderer
* @{
*/
#include <gds-render/cell-selector/cell-statistics-renderer.h>
G_DEFINE_TYPE(CellStatisticsRenderer, cell_statistics_renderer, GTK_TYPE_CELL_RENDERER_TEXT)
enum {
PROP_CELL_STAT = 1,
PROP_COUNT
};
static void cell_statistics_renderer_set_property(GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
GValue val = G_VALUE_INIT;
GString *string;
const struct gds_cell_statistics *cell_stat;
switch (param_id) {
case PROP_CELL_STAT:
cell_stat = (const struct gds_cell_statistics *)g_value_get_pointer(value);
g_value_init(&val, G_TYPE_STRING);
string = g_string_new_len("", 5);
if (cell_stat)
g_string_printf(string, "%zu (%zu) | %zu (%zu)", cell_stat->total_vertex_count,
cell_stat->vertex_count, cell_stat->total_gfx_count, cell_stat->gfx_count);
g_value_set_string(&val, string->str);
g_object_set_property(object, "text", &val);
g_value_unset(&val);
g_string_free(string, TRUE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
break;
}
}
static void cell_statistics_renderer_get_property(GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
(void)value;
switch (param_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
break;
}
}
static GParamSpec *properties[PROP_COUNT];
void cell_statistics_renderer_class_init(CellStatisticsRendererClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS(klass);
oclass->set_property = cell_statistics_renderer_set_property;
oclass->get_property = cell_statistics_renderer_get_property;
properties[PROP_CELL_STAT] = g_param_spec_pointer("cell-stat", "cell-stat",
"Cell statistics", G_PARAM_WRITABLE);
g_object_class_install_properties(oclass, PROP_COUNT, properties);
}
void cell_statistics_renderer_init(CellStatisticsRenderer *self)
{
(void)self;
}
GtkCellRenderer *cell_statistics_renderer_new(void)
{
return GTK_CELL_RENDERER(g_object_new(TYPE_GDS_RENDER_CELL_STAT_RENDERER, NULL));
}
/** @} */

View File

@@ -30,6 +30,7 @@
#include <stdio.h>
#include <glib/gi18n.h>
#include <string.h>
#include <gds-render/command-line.h>
#include <gds-render/gds-utils/gds-parser.h>
@@ -38,6 +39,41 @@
#include <gds-render/output-renderers/latex-renderer.h>
#include <gds-render/output-renderers/external-renderer.h>
#include <gds-render/gds-utils/gds-tree-checker.h>
#include <gds-render/gds-utils/gds-statistics.h>
#include <fort.h>
#ifndef COUNT_OF
#define COUNT_OF(x) (sizeof((x))/sizeof(0[(x)]))
#endif
enum analysis_format {
ANA_FORMAT_SIMPLE = 0,
ANA_FORMAT_CELLS_ONLY,
ANA_FORMAT_PRETTY,
};
struct analysis_format_cmdarg {
enum analysis_format format;
const char *argument;
};
static const struct analysis_format_cmdarg analysis_format_lookup[] = {
{
.format = ANA_FORMAT_SIMPLE,
.argument = "simple",
},
{
.format = ANA_FORMAT_PRETTY,
.argument = "pretty",
},
{
.format = ANA_FORMAT_CELLS_ONLY,
.argument = "cellsonly"
}
};
static int string_array_count(char **string_array)
{
@@ -136,14 +172,14 @@ static struct gds_cell *find_gds_cell_in_lib(struct gds_library *lib, const char
}
int command_line_convert_gds(const char *gds_name,
const char *cell_name,
char **renderers,
char **output_file_names,
const char *layer_file,
struct external_renderer_params *ext_param,
gboolean tex_standalone,
gboolean tex_layers,
double scale)
const char *cell_name,
char **renderers,
char **output_file_names,
const char *layer_file,
struct external_renderer_params *ext_param,
gboolean tex_standalone,
gboolean tex_layers,
double scale)
{
int ret = -1;
GList *libs = NULL;
@@ -155,6 +191,10 @@ int command_line_convert_gds(const char *gds_name,
LayerSettings *layer_sett;
GdsOutputRenderer *current_renderer;
const struct gds_library_parsing_opts gds_parsing_options = {
.simplified_polygons = 1,
};
/* Check if parameters are valid */
if (!gds_name || !cell_name || !output_file_names || !layer_file || !renderers) {
printf(_("Probably missing argument. Check --help option\n"));
@@ -173,7 +213,7 @@ int command_line_convert_gds(const char *gds_name,
/* Load GDS */
clear_lib_list(&libs);
res = parse_gds_from_file(gds_name, &libs);
res = parse_gds_from_file(gds_name, &libs, &gds_parsing_options);
if (res)
goto ret_destroy_library_list;
@@ -224,6 +264,8 @@ int command_line_convert_gds(const char *gds_name,
gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
}
ret = 0;
ret_destroy_library_list:
clear_lib_list(&libs);
ret_clear_renderers:
@@ -234,4 +276,192 @@ ret_destroy_layer_mapping:
return ret;
}
static void indent_line(int level)
{
while (level--)
printf("\t");
}
static int printf_indented(int level, const char *format, ...)
{
int ret;
va_list a_list;
va_start(a_list, format);
indent_line(level);
ret = vprintf(format, a_list);
va_end(a_list);
return ret;
}
static void print_simple_stat(GList *lib_stat_list)
{
int indentation_level = 0;
GList *lib_iter;
GList *cell_iter;
const struct gds_library *lib;
const struct gds_cell *cell;
const struct gds_lib_statistics *lib_stat;
const struct gds_cell_statistics *cell_stat;
for (lib_iter = lib_stat_list; lib_iter; lib_iter = g_list_next(lib_iter)) {
lib = (const struct gds_library *)lib_iter->data;
lib_stat = &lib->stats;
printf_indented(indentation_level, "Library %s\n", lib->name);
indentation_level++;
for (cell_iter = lib->cells; cell_iter; cell_iter = g_list_next(cell_iter)) {
cell = (const struct gds_cell *)cell_iter->data;
cell_stat = &cell->stats;
printf_indented(indentation_level, "Cell %s\n", cell->name);
indentation_level++;
printf_indented(indentation_level, "Reference count: %zu\n", cell_stat->reference_count);
printf_indented(indentation_level, "Graphics count: %zu\n", cell_stat->gfx_count);
printf_indented(indentation_level, "Total Graphics count: %zu\n", cell_stat->total_gfx_count);
printf_indented(indentation_level, "Vertex count: %zu\n", cell_stat->vertex_count);
printf_indented(indentation_level, "Total Vertex count: %zu\n", cell_stat->total_vertex_count);
printf_indented(indentation_level, "Unresolved children: %d\n",
cell->checks.unresolved_child_count);
printf_indented(indentation_level, "Reference loop: %s\n",
cell->checks.affected_by_reference_loop ? "yes" : "no");
indentation_level--;
}
printf_indented(indentation_level, "Cell count: %zu\n", lib_stat->cell_count);
printf_indented(indentation_level, "Reference count: %zu\n", lib_stat->reference_count);
printf_indented(indentation_level, "Graphics count: %zu\n", lib_stat->gfx_count);
printf_indented(indentation_level, "Vertex count: %zu\n", lib_stat->vertex_count);
}
}
static void table_stat_create_cell_row(struct gds_cell *cell, ft_table_t *tab)
{
ft_printf_ln(tab, "%s|%s|%zu|%zu|%zu|%zu|%zu|%d|%s",
cell->parent_library->name,
cell->name,
cell->stats.gfx_count,
cell->stats.total_gfx_count,
cell->stats.vertex_count,
cell->stats.total_vertex_count,
cell->stats.reference_count,
cell->checks.unresolved_child_count,
cell->checks.affected_by_reference_loop ? "yes" : "no");
}
static void table_stat_table_for_lib(struct gds_library *lib, ft_table_t *tab)
{
ft_printf_ln(tab, "%s|%zu|%zu|-|%zu|-|%zu|-|-",
lib->name,
lib->stats.cell_count,
lib->stats.gfx_count,
lib->stats.vertex_count,
lib->stats.reference_count);
g_list_foreach(lib->cells, (GFunc)table_stat_create_cell_row, tab);
}
static void print_table_stat(GList *lib_list)
{
ft_table_t *table;
table = ft_create_table();
ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER);
ft_write_ln(table, "Library", "Cell", "GFX", "GFX+", "Vertices", "Vertices+", "Refs", "Unresolved Refs", "Loops");
g_list_foreach(lib_list, (GFunc)table_stat_table_for_lib, table);
printf("%s\n", ft_to_string(table));
ft_destroy_table(table);
}
static void print_statistics(enum analysis_format format, GList *lib_list)
{
switch (format) {
case ANA_FORMAT_PRETTY:
print_table_stat(lib_list);
break;
default:
print_simple_stat(lib_list);
break;
}
}
static void print_cell_names(GList *lib_list)
{
GList *lib_iter;
GList *name_iter;
struct gds_library *lib;
for (lib_iter = lib_list; lib_iter; lib_iter = g_list_next(lib_iter)) {
lib = (struct gds_library *)lib_iter->data;
for (name_iter = lib->cell_names; name_iter; name_iter = name_iter->next) {
printf("%s\n", (const char *)name_iter->data);
}
}
}
int command_line_analyze_lib(const char *format, const char *gds_name)
{
enum analysis_format fmt = ANA_FORMAT_SIMPLE;
size_t idx;
int found = 0;
GList *lib_list = NULL;
const struct gds_library_parsing_opts parsing_opts = {
.simplified_polygons = 0,
};
int res;
int ret = 0;
GList *lib_iter;
g_return_val_if_fail(gds_name, -1002);
if (format && *format) {
/* Check format if it is not empty */
for (idx = 0; idx < COUNT_OF(analysis_format_lookup); idx++) {
if (!strcmp(analysis_format_lookup[idx].argument, format)) {
/* Format specifier matches */
fmt = analysis_format_lookup[idx].format;
found = 1;
}
}
if (!found) {
fprintf(stderr, "No format matches %s. Using default.\n", format);
}
}
/* Load the GDS file */
res = parse_gds_from_file(gds_name, &lib_list, &parsing_opts);
if (res) {
fprintf(stderr, "Error parsing GDS file\n");
(void)clear_lib_list(&lib_list);
ret = res;
goto return_val;
}
for (lib_iter = lib_list; lib_iter; lib_iter = g_list_next(lib_iter)) {
res = gds_tree_check_cell_references((struct gds_library *)lib_iter->data);
if (res < 0) {
fprintf(stderr, "Error checking cell references. Will continue...\n");
}
res = gds_tree_check_reference_loops((struct gds_library *)lib_iter->data);
if (res < 0) {
fprintf(stderr, "Error checking cell reference loops. Will continue...\n");
}
}
if (fmt == ANA_FORMAT_CELLS_ONLY) {
print_cell_names(lib_list);
goto return_clear_libs;
}
print_statistics(fmt, lib_list);
return_clear_libs:
clear_lib_list(&lib_list);
return_val:
return ret;
}
/** @} */

View File

@@ -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 |
| ------- | ---------- |

View File

@@ -37,17 +37,23 @@
#include <gds-render/layer/layer-selector.h>
#include <gds-render/widgets/activity-bar.h>
#include <gds-render/cell-selector/lib-cell-renderer.h>
#include <gds-render/cell-selector/cell-statistics-renderer.h>
#include <gds-render/output-renderers/latex-renderer.h>
#include <gds-render/output-renderers/cairo-renderer.h>
#include <gds-render/widgets/conv-settings-dialog.h>
#include <gds-render/geometric/cell-geometrics.h>
#include <gds-render/version.h>
#ifdef GDS_RENDER_OPGENGL_PREVIEW
#include <preview-rendering/preview-rendering-gui.h>
#endif
/** @brief Columns of selection tree view */
enum cell_store_columns {
CELL_SEL_LIBRARY = 0,
CELL_SEL_CELL,
CELL_SEL_CELL_ERROR_STATE, /**< Used for cell color and selectability */
CELL_SEL_STAT,
CELL_SEL_COLUMN_COUNT /**< @brief Not a column. Used to determine count of columns */
};
@@ -66,6 +72,9 @@ struct _GdsRenderGui {
/* Custom fields */
GtkWindow *main_window;
#ifdef GDS_RENDER_OPGENGL_PREVIEW
OpenGlPreviewGui *preview_gui;
#endif
GtkWidget *convert_button;
GtkWidget *open_button;
GtkWidget *load_layer_button;
@@ -187,7 +196,8 @@ static gboolean cell_store_filter_visible_func(GtkTreeModel *model, GtkTreeIter
gtk_tree_model_get(model, iter, CELL_SEL_CELL, &cell, CELL_SEL_LIBRARY, &lib, -1);
if (lib) {
/* Show always, if this is a pure lib entry */
if (lib && !cell) {
result = TRUE;
goto exit_filter;
}
@@ -218,10 +228,11 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
{
GtkCellRenderer *render_cell;
GtkCellRenderer *render_lib;
GtkCellRenderer *render_vertex_count;
GtkTreeViewColumn *column;
self->cell_tree_store = gtk_tree_store_new(CELL_SEL_COLUMN_COUNT, G_TYPE_POINTER,
G_TYPE_POINTER, G_TYPE_UINT);
G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_POINTER);
/* Searching */
self->cell_filter = GTK_TREE_MODEL_FILTER(
@@ -237,6 +248,7 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
render_cell = lib_cell_renderer_new();
render_lib = lib_cell_renderer_new();
render_vertex_count = cell_statistics_renderer_new();
column = gtk_tree_view_column_new_with_attributes(_("Library"), render_lib, "gds-lib", CELL_SEL_LIBRARY, NULL);
gtk_tree_view_append_column(self->cell_tree_view, column);
@@ -245,6 +257,10 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
"error-level", CELL_SEL_CELL_ERROR_STATE, NULL);
gtk_tree_view_append_column(self->cell_tree_view, column);
column = gtk_tree_view_column_new_with_attributes(_("Vertex | GFX Count"), render_vertex_count, "cell-stat", CELL_SEL_STAT,
NULL);
gtk_tree_view_append_column(self->cell_tree_view, column);
/* Callback for selection
* This prevents selecting a library
*/
@@ -254,6 +270,10 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
return 0;
}
const struct gds_cell_statistics cc = {
.vertex_count = 12,
};
/**
* @brief Callback function of Load GDS button
* @param button
@@ -277,6 +297,10 @@ static void on_load_gds(gpointer button, gpointer user)
char *filename;
unsigned int cell_error_level;
const struct gds_library_parsing_opts gds_parsing_options = {
.simplified_polygons = 1,
};
self = RENDERER_GUI(user);
if (!self)
return;
@@ -306,7 +330,7 @@ static void on_load_gds(gpointer button, gpointer user)
clear_lib_list(&self->gds_libraries);
/* Parse new GDSII file */
gds_result = parse_gds_from_file(filename, &self->gds_libraries);
gds_result = parse_gds_from_file(filename, &self->gds_libraries, &gds_parsing_options);
/* Delete file name afterwards */
g_free(filename);
@@ -348,6 +372,7 @@ static void on_load_gds(gpointer button, gpointer user)
CELL_SEL_CELL, gds_c,
CELL_SEL_CELL_ERROR_STATE, cell_error_level,
CELL_SEL_LIBRARY, gds_c->parent_library,
CELL_SEL_STAT, &gds_c->stats,
-1);
} /* for cells */
} /* for libraries */
@@ -647,6 +672,9 @@ static void gds_render_gui_dispose(GObject *gobject)
g_clear_object(&self->save_layer_button);
g_clear_object(&self->open_button);
g_clear_object(&self->select_all_button);
#ifdef GDS_RENDER_OPGENGL_PREVIEW
g_clear_object(&self->preview_gui);
#endif
if (self->main_window) {
g_signal_handlers_destroy(self->main_window);
@@ -690,19 +718,13 @@ static void on_select_all_layers_clicked(GtkWidget *button, gpointer user_data)
layer_selector_select_all_layers(gui->layer_selector, TRUE);
}
static void auto_naming_clicked(GtkWidget *button, gpointer user_data)
static gboolean auto_naming_ask_for_override(GdsRenderGui *gui)
{
GdsRenderGui *gui;
GtkDialog *dialog;
gboolean overwrite;
int dialog_result;
(void)button;
gint dialog_result;
gboolean overwrite = FALSE;
gui = RENDERER_GUI(user_data);
/* Don't do anything if the selector is empty. */
if (!layer_selector_contains_elements(gui->layer_selector))
return;
g_return_val_if_fail(RENDERER_IS_GUI(gui), FALSE);
/* Ask for overwrite */
dialog = GTK_DIALOG(gtk_message_dialog_new(gui->main_window, GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_QUESTION,
@@ -719,6 +741,25 @@ static void auto_naming_clicked(GtkWidget *button, gpointer user_data)
}
gtk_widget_destroy(GTK_WIDGET(dialog));
return overwrite;
}
static void auto_naming_clicked(GtkWidget *button, gpointer user_data)
{
GdsRenderGui *gui;
gboolean overwrite = FALSE;
(void)button;
gui = RENDERER_GUI(user_data);
/* Don't do anything if the selector is empty. */
if (!layer_selector_contains_elements(gui->layer_selector))
return;
/* Ask, if names shall be overwritten, if they are not empty */
if (layer_selector_num_of_named_elements(gui->layer_selector) > 0)
overwrite = auto_naming_ask_for_override(gui);
layer_selector_auto_name_layers(gui->layer_selector, overwrite);
}
@@ -737,7 +778,15 @@ static void gds_render_gui_init(GdsRenderGui *self)
GtkWidget *activity_bar_box;
GtkWidget *auto_color_button;
GtkWidget *auto_naming_button;
#ifdef GDS_RENDER_OPGENGL_PREVIEW
OpenGlPreviewGui *preview_gui;
preview_gui = opengl_preview_gui_new();
/* No need to reference the preview gui. It is already referenced upon creation */
self->preview_gui = preview_gui;
opengl_preview_gui_show(preview_gui);
#endif
main_builder = gtk_builder_new_from_resource("/gui/main.glade");
self->cell_tree_view = GTK_TREE_VIEW(gtk_builder_get_object(main_builder, "cell-tree"));

View File

@@ -43,6 +43,7 @@
#include <glib/gi18n.h>
#include <gds-render/gds-utils/gds-parser.h>
#include <gds-render/gds-utils/gds-statistics.h>
/**
* @brief Default units assumed for library.
@@ -50,8 +51,8 @@
*/
#define GDS_DEFAULT_UNITS (10E-9)
#define GDS_ERROR(fmt, ...) printf("[PARSE_ERROR] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS error*/
#define GDS_WARN(fmt, ...) printf("[PARSE_WARNING] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS warning */
#define GDS_ERROR(fmt, ...) fprintf(stderr, "[PARSE_ERROR] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS error*/
#define GDS_WARN(fmt, ...) fprintf(stderr, "[PARSE_WARNING] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS warning */
#if GDS_PRINT_DEBUG_INFOS
/**< @brief standard printf. But can be disabled in code. */
@@ -266,7 +267,8 @@ static uint16_t gds_convert_unsigned_int16(const char *data)
* @param library_ptr Return of newly created library.
* @return Newly created list pointer
*/
static GList *append_library(GList *curr_list, struct gds_library **library_ptr)
static GList *append_library(GList *curr_list, const struct gds_library_parsing_opts *opts,
struct gds_library **library_ptr)
{
struct gds_library *lib;
@@ -276,8 +278,15 @@ static GList *append_library(GList *curr_list, struct gds_library **library_ptr)
lib->name[0] = 0;
lib->unit_in_meters = GDS_DEFAULT_UNITS; // Default. Will be overwritten
lib->cell_names = NULL;
} else
/* Copy the settings into the library */
memcpy(&lib->parsing_opts, opts, sizeof(struct gds_library_parsing_opts));
lib->stats.cell_count = 0;
lib->stats.gfx_count = 0;
lib->stats.reference_count = 0;
lib->stats.vertex_count = 0;
} else {
return NULL;
}
if (library_ptr)
*library_ptr = lib;
@@ -353,6 +362,10 @@ static GList *append_cell(GList *curr_list, struct gds_cell **cell_ptr)
cell->parent_library = NULL;
cell->checks.unresolved_child_count = GDS_CELL_CHECK_NOT_RUN;
cell->checks.affected_by_reference_loop = GDS_CELL_CHECK_NOT_RUN;
cell->stats.reference_count = 0;
cell->stats.total_vertex_count = 0;
cell->stats.gfx_count = 0;
cell->stats.vertex_count = 0;
} else
return NULL;
/* return cell */
@@ -488,20 +501,102 @@ static void parse_reference_list(gpointer gcell_ref, gpointer glibrary)
}
/**
* @brief Scans cell references inside cell
This function searches all the references in \p gcell and updates the gds_cell_instance::cell_ref field in each instance
* @brief Simplify graphics objects
* @param graphics gfx struct
* @param user_data GDS library
*/
static void simplify_graphics(gpointer graphics, gpointer user_data)
{
struct gds_graphics *gfx;
const struct gds_point *first_vertex = NULL;
const struct gds_point *prev_vertex = NULL;
const struct gds_point *current_vertex;
GList *vertex_iter;
GList *next_iter;
(void)user_data;
size_t processed_count = 0U;
size_t removed_count = 0U;
gfx = (struct gds_graphics *)graphics;
if (gfx->gfx_type == GRAPHIC_POLYGON) {
GDS_INF("\t\t\tPolygon found\n");
/* Loop over all vertices */
for (vertex_iter = gfx->vertices; vertex_iter;) {
current_vertex = (const struct gds_point *)vertex_iter->data;
next_iter = g_list_next(vertex_iter);
processed_count++;
if (vertex_iter == gfx->vertices) {
/* This is the first vertex */
first_vertex = current_vertex;
prev_vertex = NULL;
}
if (prev_vertex) {
if (current_vertex->x == prev_vertex->x && current_vertex->y == prev_vertex->y) {
/* Vertex is the same as the previous one */
GDS_INF("\t\t\t\tDuplicate vertex (%d,%d). Removing...\n",
current_vertex->x, current_vertex->y);
/* Delete the current one from the list */
gfx->vertices = g_list_remove_link(gfx->vertices, vertex_iter);
/* Free the data */
if (vertex_iter->data)
free(vertex_iter->data);
vertex_iter->data = NULL;
g_list_free_1(vertex_iter);
removed_count++;
} else if (!g_list_next(vertex_iter)) {
/* This is the last element in the list */
if (current_vertex->x == first_vertex->x &&
current_vertex->y == first_vertex->y) {
GDS_INF("\t\t\t\tLast vertex is identical to first vertex (%d,%d). Removing\n",
current_vertex->x, current_vertex->y);
gfx->vertices = g_list_remove_link(gfx->vertices, vertex_iter);
if (vertex_iter->data)
free(vertex_iter->data);
g_list_free_1(vertex_iter);
removed_count++;
} else {
GDS_WARN("First vertex is not coincident with first vertex, although the GDS file format specifies this. However, this is not a problem.");
}
}
}
vertex_iter = next_iter;
prev_vertex = current_vertex;
}
GDS_INF("\t\t\tProcessed %zu vertices. %zu removed.\n", processed_count, removed_count);
}
}
/**
* @brief Scans cell and resolves references and simplifies polygons
* This function searches all the references in \p gcell and updates the gds_cell_instance::cell_ref field in each instance
*
* @param gcell pointer cast of #gds_cell *
* @param library Library where the cell references are searched in
*/
static void scan_cell_reference_dependencies(gpointer gcell, gpointer library)
static void scan_cell_references_and_polygons(gpointer gcell, gpointer library)
{
struct gds_cell *cell = (struct gds_cell *)gcell;
struct gds_library *my_lib = (struct gds_library *)library;
int simplify_polygons;
simplify_polygons = my_lib->parsing_opts.simplified_polygons;
GDS_INF("\tScanning cell: %s\n", cell->name);
GDS_INF("\t\tCell references\n");
/* Scan all library references */
g_list_foreach(cell->child_cells, parse_reference_list, library);
GDS_INF("\t\tSimplifying Polygons%s\n", simplify_polygons ? "" : ": skipped");
if (simplify_polygons) {
g_list_foreach(cell->graphic_objs, simplify_graphics, library);
}
}
/**
@@ -517,7 +612,16 @@ static void scan_library_references(gpointer library_list_item, gpointer user)
(void)user;
GDS_INF("Scanning Library: %s\n", lib->name);
g_list_foreach(lib->cells, scan_cell_reference_dependencies, lib);
g_list_foreach(lib->cells, scan_cell_references_and_polygons, lib);
}
static void calc_library_stats(gpointer library_list_item, gpointer user)
{
struct gds_library *lib = (struct gds_library *)library_list_item;
(void)user;
GDS_INF("Calculating stats for Library: %s\n", lib->name);
gds_statistics_calc_cummulative_counts_in_lib(lib);
}
/**
@@ -601,6 +705,7 @@ static void convert_aref_to_sref(struct gds_cell_array_instance *aref, struct gd
for (row = 0; row < aref->rows; row++) {
/* Create new instance for this row/column and configure data */
container_cell->child_cells = append_cell_ref(container_cell->child_cells, &sref_inst);
container_cell->stats.reference_count++;
if (!sref_inst) {
GDS_ERROR("Appending cell ref failed!");
continue;
@@ -617,7 +722,8 @@ static void convert_aref_to_sref(struct gds_cell_array_instance *aref, struct gd
GDS_INF("Converted AREF to SREFs\n");
}
int parse_gds_from_file(const char *filename, GList **library_list)
int parse_gds_from_file(const char *filename, GList **library_list,
const struct gds_library_parsing_opts *parsing_options)
{
char *workbuff;
int read;
@@ -697,7 +803,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
/* if begin: Allocate structures */
switch (rec_type) {
case BGNLIB:
lib_list = append_library(lib_list, &current_lib);
lib_list = append_library(lib_list, parsing_options, &current_lib);
if (lib_list == NULL) {
GDS_ERROR("Allocating memory failed");
run = -3;
@@ -771,7 +877,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
run = -4;
break;
}
GDS_INF("\tEntering boundary/Box\n");
GDS_INF("\tEntering boundary of type %s\n", rec_type==BOUNDARY ? "polygon" : "box");
break;
case SREF:
if (current_cell == NULL) {
@@ -781,6 +887,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
}
current_cell->child_cells = append_cell_ref(current_cell->child_cells,
&current_s_reference);
current_cell->stats.reference_count++;
if (current_cell->child_cells == NULL) {
GDS_ERROR("Memory allocation failed");
run = -4;
@@ -806,8 +913,13 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break;
case ENDEL:
if (current_graphics != NULL) {
GDS_INF("\tLeaving %s\n", (current_graphics->gfx_type == GRAPHIC_POLYGON ? "boundary" : "path"));
GDS_INF("\tLeaving %s\n", (current_graphics->gfx_type == GRAPHIC_POLYGON ? "boundary"
: (current_graphics->gfx_type == GRAPHIC_PATH ? "path"
: "box")));
current_graphics = NULL;
if (current_cell) {
current_cell->stats.gfx_count++;
}
}
if (current_s_reference != NULL) {
GDS_INF("\tLeaving Reference\n");
@@ -825,11 +937,11 @@ int parse_gds_from_file(const char *filename, GList **library_list)
} else if (current_s_reference) {
if (rec_data_length != 8) {
GDS_WARN("Instance has weird coordinates. Rendered output might be screwed!");
GDS_WARN("Instance has weird coordinates. Rendered output might be wrong!");
}
} else if (current_a_reference) {
if (rec_data_length != (3*(4+4)))
GDS_WARN("Array instance has weird coordinates. Rendered output might be screwed!");
GDS_WARN("Array instance has weird coordinates. Rendered output might be wrong!");
}
break;
case AREF:
@@ -957,7 +1069,9 @@ int parse_gds_from_file(const char *filename, GList **library_list)
current_graphics->vertices =
append_vertex(current_graphics->vertices, x, y);
GDS_INF("\t\tSet coordinate: %d/%d\n", x, y);
if (current_cell) {
current_cell->stats.vertex_count++;
}
}
} else if (current_a_reference) {
for (i = 0; i < 3; i++) {
@@ -1073,8 +1187,13 @@ int parse_gds_from_file(const char *filename, GList **library_list)
if (!run) {
/* Iterate and find references to cells */
g_list_foreach(lib_list, scan_library_references, NULL);
/* Calculate lib stats and cummulative total counts */
g_list_foreach(lib_list, calc_library_stats, NULL);
}
*library_list = lib_list;
free(workbuff);

View File

@@ -0,0 +1,93 @@
/*
* 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/>.
*/
/**
* @file gds-statistics.c
* @brief Statistics of GDS files
* @author Mario Hüttel <mario.huettel@gmx.net>
*
*/
#include <gds-render/gds-utils/gds-statistics.h>
#include <stdio.h>
/**
* @addtogroup GDS-Utilities
* @{
*/
#define MAX_RECURSION_DEPTH (1024)
static void calculate_vertex_gfx_count_cell(struct gds_cell *cell, unsigned int recursion_depth)
{
GList *cell_iter;
struct gds_cell_instance *cell_ref;
struct gds_cell *sub_cell;
g_return_if_fail(cell);
/* Check if cell has already been calculated */
if (cell->stats.total_gfx_count && cell->stats.total_vertex_count) {
/* Return. This cell and all of its subcells have been calculated */
return;
}
/* Update with own vertex / GFX count */
cell->stats.total_vertex_count = cell->stats.vertex_count;
cell->stats.total_gfx_count = cell->stats.gfx_count;
/* Do not analyze further, if maximum recursion depth is reached */
if (!recursion_depth)
return;
for (cell_iter = cell->child_cells; cell_iter; cell_iter = g_list_next(cell_iter)) {
/* Scan all subcells recursively, if there are any */
cell_ref = (struct gds_cell_instance *)cell_iter->data;
sub_cell = (struct gds_cell *)cell_ref->cell_ref;
calculate_vertex_gfx_count_cell(sub_cell, recursion_depth - 1);
/* Increment count */
cell->stats.total_vertex_count += sub_cell->stats.total_vertex_count;
cell->stats.total_gfx_count += sub_cell->stats.total_vertex_count;
}
}
void gds_statistics_calc_cummulative_counts_in_lib(struct gds_library *lib)
{
GList *cell_iter;
struct gds_cell *cell;
g_return_if_fail(lib);
for (cell_iter = lib->cells; cell_iter; cell_iter = g_list_next(cell_iter)) {
cell = (struct gds_cell *)cell_iter->data;
calculate_vertex_gfx_count_cell(cell, MAX_RECURSION_DEPTH);
lib->stats.vertex_count += cell->stats.vertex_count;
lib->stats.cell_count++;
lib->stats.gfx_count += cell->stats.gfx_count;
lib->stats.reference_count += cell->stats.reference_count;
}
}
/** @} */

View File

@@ -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);

View File

@@ -0,0 +1,56 @@
/*
* GDSII-Converter
* Copyright (C) 2022 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 cell-statistics-renderer.h
* @brief Header file for the CellStatisticsRenderer GObject Class
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/**
* @addtogroup CellStatisticsRenderer
* @{
*/
#ifndef _CELL_STATISTICS_RENDERER_H_
#define _CELL_STATISTICS_RENDERER_H_
#include <gtk/gtk.h>
#include <gds-render/gds-utils/gds-statistics.h>
G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE(CellStatisticsRenderer, cell_statistics_renderer, GDS_RENDER, CELL_STAT_RENDERER, GtkCellRendererText)
#define TYPE_GDS_RENDER_CELL_STAT_RENDERER (cell_statistics_renderer_get_type())
typedef struct _CellStatisticsRenderer {
GtkCellRendererText super;
} CellStatisticsRenderer;
/**
* @brief New Cell statistics renderer
* @return GObject
*/
GtkCellRenderer *cell_statistics_renderer_new(void);
G_END_DECLS
#endif /* _CELL_STATISTICS_RENDERER_H_ */
/** @} */

View File

@@ -71,6 +71,14 @@ int command_line_convert_gds(const char *gds_name,
gboolean tex_layers,
double scale);
/**
* @brief Analyze the given GDS file
* @param format Output format of the analysis result
* @param gds_name GDS file name
* @return 0 if successful
*/
int command_line_analyze_lib(const char *format, const char *gds_name);
#endif /* _COMMAND_LINE_H_ */
/** @} */

View File

@@ -48,9 +48,11 @@
*
* @param[in] filename Path to the GDS file
* @param[in,out] library_array GList Pointer.
* @param[in] parsing_options Parsing options.
* @return 0 if successful
*/
int parse_gds_from_file(const char *filename, GList **library_array);
int parse_gds_from_file(const char *filename, GList **library_array,
const struct gds_library_parsing_opts *parsing_options);
/**
* @brief Deletes all libraries including cells, references etc.

View File

@@ -0,0 +1,42 @@
/*
* 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/>.
*/
/**
* @file gds-parser.h
* @brief Header file for the GDS statistics
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#ifndef _GDS_STATISTICS_H_
#define _GDS_STATISTICS_H_
/**
* @addtogroup GDS-Utilities
* @{
*/
#include <glib.h>
#include <gds-render/gds-utils/gds-types.h>
void gds_statistics_calc_cummulative_counts_in_lib(struct gds_library *lib);
/** @} */
#endif /* _GDS_STATISTICS_H_ */

View File

@@ -65,6 +65,22 @@ struct gds_point {
int y;
};
struct gds_cell_statistics {
size_t gfx_count;
size_t vertex_count;
size_t total_vertex_count;
size_t total_gfx_count;
size_t reference_count;
};
struct gds_lib_statistics {
size_t gfx_count;
size_t vertex_count;
size_t reference_count;
size_t cell_count;
};
/**
* @brief Stores the result of the cell checks.
*/
@@ -127,6 +143,14 @@ struct gds_cell {
GList *graphic_objs; /**< @brief List of #gds_graphics */
struct gds_library *parent_library; /**< @brief Pointer to parent library */
struct gds_cell_checks checks; /**< @brief Checking results */
struct gds_cell_statistics stats; /**< @brief Optional statistic info */
};
/**
* @brief Options, hwo this liobrary was parsed.
*/
struct gds_library_parsing_opts {
int simplified_polygons; /**< @brief Polygons have been simplified. Coincident end point removed. */
};
/**
@@ -136,11 +160,14 @@ struct gds_library {
char name[CELL_NAME_MAX];
struct gds_time_field mod_time;
struct gds_time_field access_time;
struct gds_library_parsing_opts parsing_opts;
double unit_in_meters; /**< Length of a database unit in meters */
GList *cells; /**< List of #gds_cell that contains all cells in this library*/
GList *cell_names /**< List of strings that contains all cell names */;
struct gds_lib_statistics stats;
};
/** @} */
#endif /* __GDS_TYPES_H__ */

View File

@@ -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);

View File

@@ -130,6 +130,13 @@ void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean ove
*/
gboolean layer_selector_contains_elements(LayerSelector *layer_selector);
/**
* @brief Get number of layer elements that are named
* @param[in] layer_selector Layer selector
* @return Number of layers with a name != NULL or != ""
*/
size_t layer_selector_num_of_named_elements(LayerSelector *layer_selector);
G_END_DECLS
#endif /* __LAYER_SELECTOR_H__ */

View File

@@ -38,7 +38,7 @@ G_DECLARE_FINAL_TYPE(CairoRenderer, cairo_renderer, GDS_RENDER, CAIRO_RENDERER,
#define GDS_RENDER_TYPE_CAIRO_RENDERER (cairo_renderer_get_type())
#define MAX_LAYERS (300) /**< \brief Maximum layer count the output renderer can process. Typically GDS only specifies up to 255 layers.*/
#define MAX_LAYERS (5000) /**< \brief Maximum layer count the output renderer can process. Typically GDS only specifies up to 255 layers.*/
/**
* @brief Create new CairoRenderer for SVG output

View File

@@ -238,6 +238,7 @@ static void color_palette_dispose(GObject *gobj)
if (palette->color_array) {
palette->color_array_length = 0;
free(palette->color_array);
palette->color_array = NULL;
}
/* Chain up to parent class */

View File

@@ -822,12 +822,10 @@ void layer_selector_auto_color_layers(LayerSelector *layer_selector, ColorPalett
unsigned int color_count;
GdkRGBA color;
if (GDS_RENDER_IS_COLOR_PALETTE(palette) == FALSE || LAYER_IS_SELECTOR(layer_selector) == FALSE)
return;
if (global_alpha <= 0)
return;
if (GTK_IS_LIST_BOX(layer_selector->list_box) == FALSE)
return;
g_return_if_fail(GDS_RENDER_IS_COLOR_PALETTE(palette));
g_return_if_fail(LAYER_IS_SELECTOR(layer_selector));
g_return_if_fail(global_alpha > 0);
g_return_if_fail(GTK_IS_LIST_BOX(layer_selector->list_box));
le_list = gtk_container_get_children(GTK_CONTAINER(layer_selector->list_box));
@@ -898,4 +896,31 @@ gboolean layer_selector_contains_elements(LayerSelector *layer_selector)
return (layer_element_list ? TRUE : FALSE);
}
size_t layer_selector_num_of_named_elements(LayerSelector *layer_selector)
{
GList *le_list;
GList *le_list_ptr;
LayerElement *le;
const char *layer_name;
size_t count = 0U;
g_return_val_if_fail(LAYER_IS_SELECTOR(layer_selector), 0U);
le_list = gtk_container_get_children(GTK_CONTAINER(layer_selector->list_box));
for (le_list_ptr = le_list; le_list_ptr != NULL; le_list_ptr = g_list_next(le_list_ptr)) {
le = LAYER_ELEMENT(le_list_ptr->data);
if (!le)
continue;
layer_name = layer_element_get_name(le);
if (layer_name && *layer_name) {
/* Layer name is not empty. Count it */
count++;
}
}
return count;
}
/** @} */

20
main.c
View File

@@ -96,6 +96,11 @@ static void app_about(GSimpleAction *action, GVariant *parameter, gpointer user_
comment_text = g_string_new(_("gds-render is a free tool for rendering GDS2 layout files into vector graphics."));
g_string_append_printf(comment_text, _("\n\nFull git commit: %s"), _app_git_commit);
#ifdef GDS_RENDER_OPGENGL_PREVIEW
g_string_append_printf(comment_text, _("\nOpenGL Previev: Availabe"));
#else
g_string_append_printf(comment_text, _("\nOpenGL Previev: Unavailabe"));
#endif
builder = gtk_builder_new_from_resource("/gui/about.glade");
dialog = GTK_DIALOG(gtk_builder_get_object(builder, "about-dialog"));
gtk_window_set_transient_for(GTK_WINDOW(dialog), NULL);
@@ -262,6 +267,8 @@ int main(int argc, char **argv)
gchar *cellname = NULL;
gchar **renderer_args = NULL;
gboolean version = FALSE, pdf_standalone = FALSE, pdf_layers = FALSE;
gboolean analyze = FALSE;
gchar *format = NULL;
int scale = 1000;
int app_status = 0;
struct external_renderer_params so_render_params;
@@ -275,6 +282,8 @@ int main(int argc, char **argv)
GOptionEntry entries[] = {
{"version", 'v', 0, G_OPTION_ARG_NONE, &version, _("Print version"), NULL},
{"analyze", 'A', 0, G_OPTION_ARG_NONE, &analyze, _("Anaylze GDS file"), NULL},
{"format", 'f', 0, G_OPTION_ARG_STRING, &format, _("Output format of analysis result, Default simple"), "[simple | pretty | cellsonly]"},
{"renderer", 'r', 0, G_OPTION_ARG_STRING_ARRAY, &renderer_args,
_("Renderer to use. Can be used multiple times."), "pdf|svg|tikz|ext"},
{"scale", 's', 0, G_OPTION_ARG_INT, &scale, _("Divide output coordinates by <SCALE>"), "<SCALE>" },
@@ -320,10 +329,13 @@ int main(int argc, char **argv)
for (i = 2; i < argc; i++)
printf(_("Ignored argument: %s"), argv[i]);
app_status =
command_line_convert_gds(gds_name, cellname, renderer_args, output_paths, mappingname,
&so_render_params, pdf_standalone, pdf_layers, scale);
if (analyze) {
app_status = command_line_analyze_lib(format, gds_name);
} else {
app_status =
command_line_convert_gds(gds_name, cellname, renderer_args, output_paths, mappingname,
&so_render_params, pdf_standalone, pdf_layers, scale);
}
} else {
app_status = start_gui(argc, argv);
}

View File

@@ -371,8 +371,6 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer
for (info_list = layer_infos; info_list != NULL; info_list = g_list_next(info_list)) {
linfo = (struct layer_info *)info_list->data;
dprintf(comm_pipe[1], _("Exporting layer %d to file\n"), linfo->layer);
if (linfo->layer >= MAX_LAYERS) {
printf(_("Layer outside of spec.\n"));
continue;
@@ -381,6 +379,8 @@ static int cairo_renderer_render_cell_to_vector_file(GdsOutputRenderer *renderer
if (!linfo->render)
continue;
dprintf(comm_pipe[1], _("Exporting layer %d to file\n"), linfo->layer);
if (pdf_file && pdf_cr) {
cairo_set_source_surface(pdf_cr, layers[linfo->layer].rec, -xmin, -ymin);
cairo_paint_with_alpha(pdf_cr, linfo->color.alpha);

View File

@@ -370,7 +370,7 @@ static int latex_renderer_render_output(GdsOutputRenderer *renderer,
l_renderer->pdf_layers, l_renderer->tex_standalone, renderer);
fclose(tex_file);
} else {
g_error(_("Could not open LaTeX output file"));
g_warning(_("Could not open LaTeX output file"));
}
if (settings)

View File

@@ -1,2 +1,3 @@
add_subdirectory(plugin-example)
add_custom_target(plugins DEPENDS pluginexample)
cmake_minimum_required(VERSION 3.0)

View File

@@ -1,5 +1,5 @@
project(pluginexample)
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0)
find_package(PkgConfig REQUIRED)
pkg_search_module(PYTHON REQUIRED python3)

View File

@@ -0,0 +1,18 @@
project(opengl-preview)
cmake_minimum_required(VERSION 3.0)
find_package(PkgConfig REQUIRED)
pkg_check_modules(EPOXY REQUIRED epoxy)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
aux_source_directory("src" SRCS)
add_subdirectory(poly2tri-wrapper)
add_library(${PROJECT_NAME} STATIC ${SRCS})
target_include_directories(${PROJECT_NAME} PUBLIC "include")
target_include_directories(${PROJECT_NAME} PRIVATE ${EPOXY_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS} ${GTK3_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PUBLIC ${EPOXY_LINK_DIRS} ${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS})
target_link_libraries(${PROJECT_NAME} ${GLIB_LDFLAGS} ${EPOXY_LDFLAGS} ${GTK3_LDFLAGS} poly2tri-wrapper)

View File

@@ -0,0 +1,14 @@
#ifndef _PREVIEW_RENDERING_GUI_H_
#define _PREVIEW_RENDERING_GUI_H_
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE(OpenGlPreviewGui, opengl_preview_gui, GDS_RENDER, OPENGL_PREVIEW_GUI, GObject)
#define TYPE_GDS_RENDER_OPENGL_PREVIEW_GUI (opengl_preview_gui_get_type())
OpenGlPreviewGui *opengl_preview_gui_new(void);
void opengl_preview_gui_show(OpenGlPreviewGui *self);
#endif /* _PREVIEW_RENDERING_GUI_H_ */

View File

@@ -0,0 +1,11 @@
project(poly2tri-wrapper LANGUAGES CXX)
cmake_minimum_required(VERSION 3.12)
add_subdirectory(../../3rdparty/poly2tri poly2tri)
set(CMAKE_CXX_STANDARD 14)
aux_source_directory("src" WRAPPER_SOURCES)
add_library(${PROJECT_NAME} STATIC ${WRAPPER_SOURCES})
target_link_libraries(${PROJECT_NAME} poly2tri)
target_include_directories(${PROJECT_NAME} PUBLIC "include")

View File

@@ -0,0 +1,16 @@
#ifndef _POLY2TRI_WRAPPER_H_
#define _POLY2TRI_WRAPPER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <gds-render/gds-utils/gds-types.h>
int tesselator_triangulate_polygon(const struct gds_graphics *gfx, double scale, float **output_vertices, size_t *vertex_count);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _POLY2TRI_WRAPPER_H_ */

View File

@@ -0,0 +1,132 @@
#include <iostream>
#include <poly2tri/poly2tri.h>
#include <poly2tri-wrapper/poly2tri-wrapper.h>
//#include <gds-render/gds-utils/gds-types.h>
#include <vector>
class Hole {
private:
std::vector <p2t::Point *> hole_vertices;
public:
const std::vector <p2t::Point *> &get_vertices()
{
return hole_vertices;
}
void add_vertex(const p2t::Point &point)
{
auto pt = new p2t::Point(point);
hole_vertices.push_back(pt);
}
Hole(std::vector<p2t::Point *>::iterator start, std::vector<p2t::Point *>::iterator end)
{
hole_vertices = std::vector<p2t::Point *>(start, end);
}
};
static std::vector<Hole> resolve_holes_in_polyline(std::vector<p2t::Point *> &polyline)
{
bool found = false;
std::vector<Hole> holes;
std::vector<std::pair<
std::vector<p2t::Point *>::iterator,
std::vector<p2t::Point *>::iterator>
> points_to_remove;
for (auto start_it = polyline.begin(); start_it != polyline.end(); start_it++) {
for (auto check_it = std::next(start_it); check_it != polyline.end(); check_it++) {
/* Check if points are equal */
if (**start_it == **check_it) {
if (**std::prev(check_it) == **std::next(start_it)) {
/* Found a hole. Everything between start_it and check_it can be removed */
auto hole = Hole(std::next(start_it)+1, check_it);
holes.push_back(hole);
auto tbd = std::make_pair(start_it, check_it);
points_to_remove.push_back(tbd);
found = true;
break;
}
}
}
if (found)
break;
}
/* Remove form polyline */
for (auto it_pair_it = points_to_remove.begin(); it_pair_it != points_to_remove.end(); it_pair_it++) {
auto it_pair = *it_pair_it;
delete *it_pair.first;
delete *std::next(it_pair.first);
polyline.erase(it_pair.first, it_pair.second);
}
if (found) {
auto new_holes = resolve_holes_in_polyline(polyline);
holes.insert(holes.end(), new_holes.begin(), new_holes.end());
}
return holes;
}
int tesselator_triangulate_polygon(const struct gds_graphics *gfx, double scale, float** output_vertices, size_t *vertex_count)
{
GList *vertex_iter;
std::vector<p2t::Point*> polyline;
if (gfx->gfx_type != GRAPHIC_POLYGON)
return -1;
for (vertex_iter = gfx->vertices; vertex_iter; vertex_iter = g_list_next(vertex_iter)) {
struct gds_point *gds_pt = (struct gds_point *)vertex_iter->data;
auto pt = new p2t::Point((double)gds_pt->x/scale, (double)gds_pt->y/scale);
polyline.push_back(pt);
}
auto holes = resolve_holes_in_polyline(polyline);
auto my_cdt = p2t::CDT(polyline);
for (auto hole_it = holes.begin(); hole_it != holes.end(); hole_it++) {
my_cdt.AddHole((*hole_it).get_vertices());
}
my_cdt.Triangulate();
auto triangles = my_cdt.GetTriangles();
/* Free the triangles */
for (auto it = triangles.begin(); it != triangles.end(); it++) {
auto triangle = *it;
std::cout << "Triangle: " <<
triangle->GetPoint(0)->x << "|" << triangle->GetPoint(0)->y << ","
<< triangle->GetPoint(1)->x << "|" << triangle->GetPoint(1)->x << ","
<< triangle->GetPoint(2)->x << "|" << triangle->GetPoint(2)->y
<< std::endl;
}
/* Get the amount of triangles */
auto count = triangles.size();
*output_vertices = (float *)malloc(2*sizeof(float)*3*count);
*vertex_count = count * 3;
/* Free the points in the vector */
for (unsigned int i = 0; i < count; i++) {
for (int j = 0; j < 3; j++) {
auto pt = triangles[i]->GetPoint(j);
unsigned int idx = i * 6 + j * 2;
(*output_vertices)[idx] = (float)pt->x;
(*output_vertices)[idx + 1] = (float)pt->y;
}
}
for (auto it = polyline.begin(); it != polyline.end(); it++)
delete *it;
return 0;
}

View File

@@ -0,0 +1,258 @@
#include <preview-rendering/preview-rendering-gui.h>
#include <poly2tri-wrapper/poly2tri-wrapper.h>
#include <epoxy/gl.h>
struct _OpenGlPreviewGui {
GObject super;
GtkWindow *main_window;
GtkGLArea *gl_area;
unsigned int polygon_shader_prog;
unsigned int vao;
unsigned int vao_vertex_count;
unsigned int vbo;
float color[4];
gboolean line;
};
G_DEFINE_TYPE(OpenGlPreviewGui, opengl_preview_gui, G_TYPE_OBJECT)
static void opengl_preview_gui_dispose(GObject *gobj)
{
OpenGlPreviewGui *self;
self = GDS_RENDER_OPENGL_PREVIEW_GUI(gobj);
g_clear_object(&self->gl_area);
if (self->main_window) {
gtk_widget_destroy(GTK_WIDGET(self->main_window));
self->main_window = NULL;
}
G_OBJECT_CLASS(opengl_preview_gui_parent_class)->dispose(gobj);
}
static void opengl_preview_gui_class_init(OpenGlPreviewGuiClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS(klass);
oclass->dispose = opengl_preview_gui_dispose;
}
static gboolean gl_area_render(GtkGLArea *area, GdkGLContext *context, gpointer user)
{
OpenGlPreviewGui *gui;
int loc;
gui = GDS_RENDER_OPENGL_PREVIEW_GUI(user);
gtk_gl_area_make_current(area);
glClearColor (0, 0, 0, 1.0);
glClear (GL_COLOR_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, gui->line ? GL_LINE : GL_FILL);
glUseProgram(gui->polygon_shader_prog);
glBindVertexArray(gui->vao);
loc = glGetUniformLocation(gui->polygon_shader_prog, "const_color");
glUniform4fv(loc, 1, gui->color);
glDrawArrays(GL_TRIANGLES, 0, gui->vao_vertex_count);
glFlush();
return TRUE;
}
static int compile_shader_from_resource(GLenum shader_type, const char *res_name, unsigned int *shader)
{
int success;
GBytes *res_bytes;
const char *data;
gsize size;
int size_int;
int sh;
res_bytes = g_resources_lookup_data(res_name, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
data = g_bytes_get_data(res_bytes, &size);
sh = glCreateShader(shader_type);
size_int = (int)size;
glShaderSource(sh, 1, &data, &size_int);
glCompileShader(sh);
glGetShaderiv(sh, GL_COMPILE_STATUS, &success);
g_bytes_unref(res_bytes);
if (shader)
*shader = sh;
return success;
}
static gboolean gl_area_realize(GtkGLArea *area, gpointer user)
{
unsigned int vbo;
unsigned int vs;
unsigned int fs;
unsigned int prog;
unsigned int vao;
OpenGlPreviewGui *gui;
int success;
struct gds_graphics gfx;
struct gds_point points[20];
size_t vertex_count;
gui = GDS_RENDER_OPENGL_PREVIEW_GUI(user);
gui->color[0] = 0.6f;
gui->color[1] = 0.5f;
gui->color[2] = 0.12f;
gui->color[3] = 1.0f;
gtk_gl_area_make_current(area);
if (!compile_shader_from_resource(GL_VERTEX_SHADER, "/shaders/polygon.vs", &vs)) {
g_warning("Error compiling vertex shader");
}
if (!compile_shader_from_resource(GL_FRAGMENT_SHADER, "/shaders/polygon.fs", &fs)) {
g_warning("Error compiling fragment shader");
}
prog = glCreateProgram();
glAttachShader(prog, vs);
glAttachShader(prog, fs);
glLinkProgram(prog);
glGetProgramiv(prog, GL_LINK_STATUS, &success);
if (!success) {
g_warning("Error linking shader");
}
glUseProgram(prog);
glDeleteShader(vs);
glDeleteShader(fs);
gui->polygon_shader_prog = prog;
gfx.vertices = NULL;
points[0].x = -100;
points[0].y = -100;
points[1].x = -100;
points[1].y = +100;
points[2].x = +0;
points[2].y = +100;
points[3].x = +0;
points[3].y = 20;
points[4].x = -20;
points[4].y = 20;
points[5].x = -20;
points[5].y = -20;
points[6].x = 20;
points[6].y = -20;
points[7].x = 20;
points[7].y = 20;
points[8].x = 0;
points[8].y = 20;
points[9].x = 0;
points[9].y = 100;
points[10].x = 100;
points[10].y = 100;
points[11].x = 100;
points[11].y = 5;
points[12].x = 60;
points[12].y = 5;
points[13].x = 60;
points[13].y = 20;
points[14].x = 50;
points[14].y = 20;
points[15].x = 50;
points[15].y = 0;
points[16].x = 60;
points[16].y = 0;
points[17].x = 60;
points[17].y = 5;
points[18].x = 100;
points[18].y = 5;
points[19].x = 100;
points[19].y = -100;
gfx.gfx_type = GRAPHIC_POLYGON;
for (int i = 0; i < 20; i++) {
gfx.vertices = g_list_append(gfx.vertices, &points[i]);
}
float *vertices = NULL;
tesselator_triangulate_polygon(&gfx, 180.0, &vertices, &vertex_count);
gui->vao_vertex_count = vertex_count;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, vertex_count*2*sizeof(float), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), (void *)0);
glEnableVertexAttribArray(0);
free(vertices);
gui->vao = vao;
gui->vbo = vbo;
g_list_free(gfx.vertices);
return TRUE;
}
static void on_clicked(GtkWidget *sender, gboolean *p)
{
*p = !*p;
}
static void opengl_preview_gui_init(OpenGlPreviewGui *self)
{
GtkBuilder *builder;
builder = gtk_builder_new_from_resource("/gui/preview-window.glade");
self->main_window = GTK_WINDOW(gtk_builder_get_object(builder, "main-window"));
self->gl_area = GTK_GL_AREA(gtk_builder_get_object(builder, "gl-area"));
g_signal_connect(self->gl_area, "render", G_CALLBACK(gl_area_render), self);
g_signal_connect(self->gl_area, "realize", G_CALLBACK(gl_area_realize), self);
g_signal_connect(gtk_builder_get_object(builder, "test-button"), "clicked", G_CALLBACK(on_clicked), &self->line);
self->line = FALSE;
g_object_ref(self->gl_area);
}
OpenGlPreviewGui *opengl_preview_gui_new(void)
{
return GDS_RENDER_OPENGL_PREVIEW_GUI(g_object_new(TYPE_GDS_RENDER_OPENGL_PREVIEW_GUI, NULL));
}
void opengl_preview_gui_show(OpenGlPreviewGui *self)
{
gtk_widget_show(GTK_WIDGET(self->main_window));
}

View File

@@ -0,0 +1,8 @@
#include <epoxy/gl.h>
int foobar(void)
{
GLuint foo;
glGenBuffers(1, &foo);
return 42;
}

View File

@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">1</property>
<property name="value">1</property>
<property name="step_increment">0.01</property>
<property name="page_increment">0.10000000000000001</property>
<property name="step-increment">0.01</property>
<property name="page-increment">0.10</property>
</object>
<object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkEventBox" id="event-box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-justify-fill</property>
<property name="can-focus">False</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
</object>
@@ -33,7 +33,7 @@
<child>
<object class="GtkLabel" id="layer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">label</property>
</object>
<packing>
@@ -45,9 +45,9 @@
<child>
<object class="GtkColorButton" id="color">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-alpha">True</property>
<property name="title" translatable="yes">Select Layer Color and Opacity</property>
<property name="rgba">rgb(0,0,0)</property>
</object>
@@ -61,9 +61,9 @@
<object class="GtkCheckButton" id="export">
<property name="label" translatable="yes">Export Layer</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -74,7 +74,7 @@
<child>
<object class="GtkEntry" id="entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="expand">True</property>

View File

@@ -1,145 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="auto-name-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-edit</property>
<property name="can-focus">False</property>
<property name="icon-name">format-text-rich-symbolic</property>
</object>
<object class="GtkImage" id="color-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-select-color</property>
</object>
<object class="GtkImage" id="load-mapping-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-open</property>
</object>
<object class="GtkImage" id="save-mapping-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Save the current layer configuration to CSV</property>
<property name="stock">gtk-save-as</property>
<property name="can-focus">False</property>
<property name="icon-name">color-select-symbolic</property>
</object>
<object class="GtkImage" id="select-all-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-apply</property>
<property name="can-focus">False</property>
<property name="icon-name">emblem-ok-symbolic</property>
</object>
<object class="GtkImage" id="sort-down-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-sort-ascending</property>
<property name="can-focus">False</property>
<property name="icon-name">view-sort-descending-symbolic</property>
</object>
<object class="GtkImage" id="sort-up-img">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-sort-descending</property>
<property name="can-focus">False</property>
<property name="icon-name">view-sort-ascending-symbolic</property>
</object>
<object class="GtkWindow" id="main-window">
<property name="height_request">250</property>
<property name="can_focus">False</property>
<property name="icon_name">gds-render</property>
<child type="titlebar">
<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-Render</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="button-load-gds">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Open GDS2 Database</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
<child>
<object class="GtkButton" id="button-load-mapping">
<property name="label" translatable="yes">Load Mapping</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Load the current layer configuration from CSV</property>
<property name="image">load-mapping-img</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-save-mapping">
<property name="label" translatable="yes">Save Mapping</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">save-mapping-img</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="convert-button">
<property name="label">gtk-convert</property>
<property name="name">button-convert</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Convert selected cell</property>
<property name="use_stock">True</property>
<property name="always_show_image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
<property name="height-request">250</property>
<property name="can-focus">False</property>
<property name="icon-name">gds-render</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="cell-search">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<property name="can-focus">True</property>
<property name="primary-icon-name">edit-find-symbolic</property>
<property name="primary-icon-activatable">False</property>
<property name="primary-icon-sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
@@ -150,15 +62,15 @@
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="can-focus">True</property>
<property name="hscrollbar-policy">never</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTreeView" id="cell-tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="enable_search">False</property>
<property name="enable_grid_lines">both</property>
<property name="can-focus">True</property>
<property name="enable-search">False</property>
<property name="enable-grid-lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
@@ -181,20 +93,20 @@
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="button-up-sort">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Sort layers ascending</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Sort layers ascending</property>
<property name="image">sort-up-img</property>
<property name="always_show_image">True</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -205,11 +117,11 @@
<child>
<object class="GtkButton" id="button-down-sort">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Sort layers descending</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Sort layers descending</property>
<property name="image">sort-down-img</property>
<property name="always_show_image">True</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -220,11 +132,11 @@
<child>
<object class="GtkButton" id="auto-color-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Automatically color layers</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Automatically color layers</property>
<property name="image">color-img</property>
<property name="always_show_image">True</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -235,11 +147,11 @@
<child>
<object class="GtkButton" id="button-select-all">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Select all layers for export</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Select all layers for export</property>
<property name="image">select-all-img</property>
<property name="always_show_image">True</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -250,11 +162,11 @@
<child>
<object class="GtkButton" id="button-auto-name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Automatically name layers</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Automatically name layers</property>
<property name="image">auto-name-img</property>
<property name="always_show_image">True</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -272,19 +184,19 @@
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_top">1</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<property name="can-focus">True</property>
<property name="margin-top">1</property>
<property name="hscrollbar-policy">never</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<child>
<object class="GtkListBox" id="layer-list">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<property name="can-focus">False</property>
<property name="selection-mode">none</property>
</object>
</child>
</object>
@@ -313,7 +225,7 @@
<child>
<object class="GtkBox" id="activity-bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
@@ -327,5 +239,75 @@
</child>
</object>
</child>
<child type="titlebar">
<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-Render</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkButton" id="button-load-gds">
<property name="label">Open GDS</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Open GDS2 Database</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
<child>
<object class="GtkButton" id="button-load-mapping">
<property name="label" translatable="yes">Load Mapping</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Load the current layer configuration from CSV</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-save-mapping">
<property name="label" translatable="yes">Save Mapping</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="convert-button">
<property name="label">Convert Cell</property>
<property name="name">button-convert</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Convert selected cell</property>
<property name="always-show-image">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="main-window">
<property name="can-focus">False</property>
<property name="default-width">1024</property>
<property name="default-height">500</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="baseline-position">bottom</property>
<child>
<object class="GtkButton" id="test-button">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGLArea" id="gl-area">
<property name="visible">True</property>
<property name="app-paintable">True</property>
<property name="can-focus">False</property>
<property name="has-alpha">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -5,6 +5,7 @@
<file compressed="true">about.glade</file>
<file>layer-widget.glade</file>
<file>dialog.glade</file>
<file compressed="true">preview-window.glade</file>
</gresource>
<gresource prefix="/data">
<file compressed="true">color-palette.txt</file>
@@ -12,6 +13,10 @@
<gresource prefix="/images">
<file compressed="true" alias="logo.svg">../icon/gds-render.svg</file>
</gresource>
<gresource prefix="/shaders">
<file compressed="true" alias="polygon.fs">./shaders/polygon.fs.glsl</file>
<file compressed="true" alias="polygon.vs">./shaders/polygon.vs.glsl</file>
</gresource>
</gresources>

View File

@@ -0,0 +1,9 @@
#version 330 core
out vec4 FragColor;
in vec4 vertex_color;
void main()
{
FragColor = vertex_color;
}

View File

@@ -0,0 +1,12 @@
#version 330 core
//uniform mat4 mvp;
uniform vec4 const_color;
layout (location = 0) in vec2 input_vertex;
out vec4 vertex_color;
void main()
{
gl_Position = vec4(input_vertex.x, input_vertex.y, 0.0, 1.0);
vertex_color = const_color;
}

View File

@@ -1,4 +1,5 @@
project(gds-render-test)
cmake_minimum_required(VERSION 3.0)
add_custom_target(test "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}" "-r compact" "-s" DEPENDS ${PROJECT_NAME})
@@ -22,7 +23,6 @@ if(NOT WIN32)
set(BoldWhite "${Esc}[1;37m")
endif()
cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/catch-framework")