Compare commits
	
		
			21 Commits
		
	
	
		
			v1.2.2
			...
			46-open-fi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ce50fb708a | |||
| 14b1e8e22f | |||
| bc2fe92e07 | |||
| 504dc476b1 | |||
| 8ff872cf36 | |||
| 9c4dbd51c8 | |||
| 2829143bbe | |||
| 5185097075 | |||
| 573cd59892 | |||
| 8b1f667819 | |||
| c2ca2ff573 | |||
| c0ac6cc3c5 | |||
| 22bc3a18d7 | |||
| dbc9fcdf34 | |||
| b39030aeaa | |||
| 2f59a762cd | |||
| ab26f8a2af | |||
| 9a43cd53f8 | |||
| ba6b07c8a2 | |||
| 1548c82542 | |||
| fb6d31c120 | 
							
								
								
									
										5
									
								
								.github/workflows/cmake.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/cmake.yml
									
									
									
									
										vendored
									
									
								
							@@ -19,7 +19,10 @@ jobs:
 | 
				
			|||||||
    runs-on: ubuntu-latest
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
    - uses: actions/checkout@v2
 | 
					    - name: Checkout Repository
 | 
				
			||||||
 | 
					      uses: actions/checkout@v2
 | 
				
			||||||
 | 
					      with:
 | 
				
			||||||
 | 
					        submodules: recursive
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    - name: Install system dependencies
 | 
					    - name: Install system dependencies
 | 
				
			||||||
      if: runner.os == 'Linux'
 | 
					      if: runner.os == 'Linux'
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							@@ -2,3 +2,7 @@
 | 
				
			|||||||
	path = c-style-checker
 | 
						path = c-style-checker
 | 
				
			||||||
	url = https://git.shimatta.de/mhu/c-style-checker
 | 
						url = https://git.shimatta.de/mhu/c-style-checker
 | 
				
			||||||
	branch = master
 | 
						branch = master
 | 
				
			||||||
 | 
					[submodule "3rdparty/libfort"]
 | 
				
			||||||
 | 
						path = 3rdparty/libfort
 | 
				
			||||||
 | 
						url = https://git.shimatta.de/3rd-party/libfort
 | 
				
			||||||
 | 
						branch = develop
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								3rdparty/libfort
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								3rdparty/libfort
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule 3rdparty/libfort added at 41237162a9
									
								
							
							
								
								
									
										11
									
								
								AUR/PKGBUILD
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								AUR/PKGBUILD
									
									
									
									
									
								
							@@ -10,8 +10,8 @@ licence=('GPLv2')
 | 
				
			|||||||
depends=('glib2' 'gtk3' 'cairo')
 | 
					depends=('glib2' 'gtk3' 'cairo')
 | 
				
			||||||
makedepends=('cmake' 'git')
 | 
					makedepends=('cmake' 'git')
 | 
				
			||||||
privides=('gds-render')
 | 
					privides=('gds-render')
 | 
				
			||||||
source=("${pkgname}-git"::"git+https://git.shimatta.de/mhu/gds-render.git")
 | 
					source=("${pkgname}-git"::"git+https://git.shimatta.de/mhu/gds-render.git" "https://git.shimatta.de/3rd-party/libfort.git")
 | 
				
			||||||
sha1sums=('SKIP')
 | 
					sha1sums=('SKIP' 'SKIP')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pkgver () {
 | 
					pkgver () {
 | 
				
			||||||
	_date=`date +"%Y%m%d"`
 | 
						_date=`date +"%Y%m%d"`
 | 
				
			||||||
@@ -26,6 +26,13 @@ build () {
 | 
				
			|||||||
	make
 | 
						make
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					prepare () {
 | 
				
			||||||
 | 
						cd "${pkgname}-git"
 | 
				
			||||||
 | 
						git submodule init
 | 
				
			||||||
 | 
						git config submodule.libfort.url "$srcdir/libfort"
 | 
				
			||||||
 | 
						git submodule update
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package () {
 | 
					package () {
 | 
				
			||||||
	cd "$srcdir/$pkgname-git/build"
 | 
						cd "$srcdir/$pkgname-git/build"
 | 
				
			||||||
	make DESTDIR="${pkgdir}" install 
 | 
						make DESTDIR="${pkgdir}" install 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
project(gds-render)
 | 
					project(gds-render LANGUAGES C)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 | 
					if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 | 
				
			||||||
  set(CMAKE_INSTALL_PREFIX "/usr/" CACHE PATH "..." FORCE)
 | 
					  set(CMAKE_INSTALL_PREFIX "/usr/" CACHE PATH "..." FORCE)
 | 
				
			||||||
@@ -77,6 +77,9 @@ add_subdirectory(resources)
 | 
				
			|||||||
add_subdirectory(doxygen)
 | 
					add_subdirectory(doxygen)
 | 
				
			||||||
add_subdirectory(translations)
 | 
					add_subdirectory(translations)
 | 
				
			||||||
add_subdirectory(version)
 | 
					add_subdirectory(version)
 | 
				
			||||||
 | 
					set(FORT_ENABLE_TESTING OFF CACHE INTERNAL "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_subdirectory(3rdparty/libfort)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
 | 
					link_directories(${GLIB_LINK_DIRS} ${GTK3_LINK_DIRS} ${CAIRO_LINK_DIRS})
 | 
				
			||||||
add_definitions(${GLIB2_CFLAGS_OTHER})
 | 
					add_definitions(${GLIB2_CFLAGS_OTHER})
 | 
				
			||||||
@@ -90,5 +93,5 @@ install (TARGETS ${PROJECT_NAME}
 | 
				
			|||||||
	RUNTIME	
 | 
						RUNTIME	
 | 
				
			||||||
		DESTINATION bin
 | 
							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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										106
									
								
								cell-selector/cell-statistics-renderer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								cell-selector/cell-statistics-renderer.c
									
									
									
									
									
										Normal 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));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** @} */
 | 
				
			||||||
							
								
								
									
										226
									
								
								command-line.c
									
									
									
									
									
								
							
							
						
						
									
										226
									
								
								command-line.c
									
									
									
									
									
								
							@@ -30,6 +30,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <glib/gi18n.h>
 | 
					#include <glib/gi18n.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <gds-render/command-line.h>
 | 
					#include <gds-render/command-line.h>
 | 
				
			||||||
#include <gds-render/gds-utils/gds-parser.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/latex-renderer.h>
 | 
				
			||||||
#include <gds-render/output-renderers/external-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-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)
 | 
					static int string_array_count(char **string_array)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -228,6 +264,8 @@ int command_line_convert_gds(const char *gds_name,
 | 
				
			|||||||
		gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
 | 
							gds_output_renderer_render_output(current_renderer, toplevel_cell, scale);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ret_destroy_library_list:
 | 
					ret_destroy_library_list:
 | 
				
			||||||
	clear_lib_list(&libs);
 | 
						clear_lib_list(&libs);
 | 
				
			||||||
ret_clear_renderers:
 | 
					ret_clear_renderers:
 | 
				
			||||||
@@ -238,4 +276,192 @@ ret_destroy_layer_mapping:
 | 
				
			|||||||
	return ret;
 | 
						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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** @} */
 | 
					/** @} */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										149
									
								
								gds-render-gui.c
									
									
									
									
									
								
							
							
						
						
									
										149
									
								
								gds-render-gui.c
									
									
									
									
									
								
							@@ -37,6 +37,7 @@
 | 
				
			|||||||
#include <gds-render/layer/layer-selector.h>
 | 
					#include <gds-render/layer/layer-selector.h>
 | 
				
			||||||
#include <gds-render/widgets/activity-bar.h>
 | 
					#include <gds-render/widgets/activity-bar.h>
 | 
				
			||||||
#include <gds-render/cell-selector/lib-cell-renderer.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/latex-renderer.h>
 | 
				
			||||||
#include <gds-render/output-renderers/cairo-renderer.h>
 | 
					#include <gds-render/output-renderers/cairo-renderer.h>
 | 
				
			||||||
#include <gds-render/widgets/conv-settings-dialog.h>
 | 
					#include <gds-render/widgets/conv-settings-dialog.h>
 | 
				
			||||||
@@ -48,6 +49,7 @@ enum cell_store_columns {
 | 
				
			|||||||
	CELL_SEL_LIBRARY = 0,
 | 
						CELL_SEL_LIBRARY = 0,
 | 
				
			||||||
	CELL_SEL_CELL,
 | 
						CELL_SEL_CELL,
 | 
				
			||||||
	CELL_SEL_CELL_ERROR_STATE, /**< Used for cell color and selectability */
 | 
						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 */
 | 
						CELL_SEL_COLUMN_COUNT /**< @brief Not a column. Used to determine count of columns */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -219,10 +221,11 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	GtkCellRenderer *render_cell;
 | 
						GtkCellRenderer *render_cell;
 | 
				
			||||||
	GtkCellRenderer *render_lib;
 | 
						GtkCellRenderer *render_lib;
 | 
				
			||||||
 | 
						GtkCellRenderer *render_vertex_count;
 | 
				
			||||||
	GtkTreeViewColumn *column;
 | 
						GtkTreeViewColumn *column;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	self->cell_tree_store = gtk_tree_store_new(CELL_SEL_COLUMN_COUNT, G_TYPE_POINTER,
 | 
						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 */
 | 
						/* Searching */
 | 
				
			||||||
	self->cell_filter = GTK_TREE_MODEL_FILTER(
 | 
						self->cell_filter = GTK_TREE_MODEL_FILTER(
 | 
				
			||||||
@@ -238,6 +241,7 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	render_cell = lib_cell_renderer_new();
 | 
						render_cell = lib_cell_renderer_new();
 | 
				
			||||||
	render_lib = 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);
 | 
						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);
 | 
						gtk_tree_view_append_column(self->cell_tree_view, column);
 | 
				
			||||||
@@ -246,6 +250,10 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
 | 
				
			|||||||
							  "error-level", CELL_SEL_CELL_ERROR_STATE, NULL);
 | 
												  "error-level", CELL_SEL_CELL_ERROR_STATE, NULL);
 | 
				
			||||||
	gtk_tree_view_append_column(self->cell_tree_view, column);
 | 
						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
 | 
						/* Callback for selection
 | 
				
			||||||
	 * This prevents selecting a library
 | 
						 * This prevents selecting a library
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
@@ -255,6 +263,10 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
 | 
				
			|||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct gds_cell_statistics cc =  {
 | 
				
			||||||
 | 
						.vertex_count = 12,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Callback function of Load GDS button
 | 
					 * @brief Callback function of Load GDS button
 | 
				
			||||||
 * @param button
 | 
					 * @param button
 | 
				
			||||||
@@ -262,25 +274,13 @@ int gds_render_gui_setup_cell_selector(GdsRenderGui *self)
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
static void on_load_gds(gpointer button, gpointer user)
 | 
					static void on_load_gds(gpointer button, gpointer user)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	GList *cell;
 | 
						(void)button;
 | 
				
			||||||
	GtkTreeIter libiter;
 | 
					 | 
				
			||||||
	GtkTreeIter celliter;
 | 
					 | 
				
			||||||
	GList *lib;
 | 
					 | 
				
			||||||
	struct gds_library *gds_lib;
 | 
					 | 
				
			||||||
	struct gds_cell *gds_c;
 | 
					 | 
				
			||||||
	GdsRenderGui *self;
 | 
						GdsRenderGui *self;
 | 
				
			||||||
	GtkWidget *open_dialog;
 | 
						GtkWidget *open_dialog;
 | 
				
			||||||
	GtkFileChooser *file_chooser;
 | 
						GtkFileChooser *file_chooser;
 | 
				
			||||||
	GtkFileFilter *filter;
 | 
						GtkFileFilter *filter;
 | 
				
			||||||
	GtkStyleContext *button_style;
 | 
					 | 
				
			||||||
	gint dialog_result;
 | 
						gint dialog_result;
 | 
				
			||||||
	int gds_result;
 | 
					 | 
				
			||||||
	char *filename;
 | 
						char *filename;
 | 
				
			||||||
	unsigned int cell_error_level;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const struct gds_library_parsing_opts gds_parsing_options = {
 | 
					 | 
				
			||||||
		.simplified_polygons = 1,
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	self = RENDERER_GUI(user);
 | 
						self = RENDERER_GUI(user);
 | 
				
			||||||
	if (!self)
 | 
						if (!self)
 | 
				
			||||||
@@ -307,58 +307,9 @@ static void on_load_gds(gpointer button, gpointer user)
 | 
				
			|||||||
	/* Get File name */
 | 
						/* Get File name */
 | 
				
			||||||
	filename = gtk_file_chooser_get_filename(file_chooser);
 | 
						filename = gtk_file_chooser_get_filename(file_chooser);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gtk_tree_store_clear(self->cell_tree_store);
 | 
						gds_render_gui_open_gds(self, filename);
 | 
				
			||||||
	clear_lib_list(&self->gds_libraries);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Parse new GDSII file */
 | 
					 | 
				
			||||||
	gds_result = parse_gds_from_file(filename, &self->gds_libraries, &gds_parsing_options);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Delete file name afterwards */
 | 
					 | 
				
			||||||
	g_free(filename);
 | 
						g_free(filename);
 | 
				
			||||||
	if (gds_result)
 | 
					 | 
				
			||||||
		goto end_destroy;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* remove suggested action from Open button */
 | 
					 | 
				
			||||||
	button_style = gtk_widget_get_style_context(GTK_WIDGET(button));
 | 
					 | 
				
			||||||
	gtk_style_context_remove_class(button_style, "suggested-action");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (lib = self->gds_libraries; lib != NULL; lib = lib->next) {
 | 
					 | 
				
			||||||
		gds_lib = (struct gds_library *)lib->data;
 | 
					 | 
				
			||||||
		/* Create top level iter */
 | 
					 | 
				
			||||||
		gtk_tree_store_append(self->cell_tree_store, &libiter, NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		gtk_tree_store_set(self->cell_tree_store, &libiter,
 | 
					 | 
				
			||||||
				   CELL_SEL_LIBRARY, gds_lib,
 | 
					 | 
				
			||||||
				   -1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* Check this library. This might take a while */
 | 
					 | 
				
			||||||
		(void)gds_tree_check_cell_references(gds_lib);
 | 
					 | 
				
			||||||
		(void)gds_tree_check_reference_loops(gds_lib);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		for (cell = gds_lib->cells; cell != NULL; cell = cell->next) {
 | 
					 | 
				
			||||||
			gds_c = (struct gds_cell *)cell->data;
 | 
					 | 
				
			||||||
			gtk_tree_store_append(self->cell_tree_store, &celliter, &libiter);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			/* Get the checking results for this cell */
 | 
					 | 
				
			||||||
			cell_error_level = 0;
 | 
					 | 
				
			||||||
			if (gds_c->checks.unresolved_child_count)
 | 
					 | 
				
			||||||
				cell_error_level |= LIB_CELL_RENDERER_ERROR_WARN;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			/* Check if it is completely b0rken */
 | 
					 | 
				
			||||||
			if (gds_c->checks.affected_by_reference_loop)
 | 
					 | 
				
			||||||
				cell_error_level |= LIB_CELL_RENDERER_ERROR_ERR;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			/* Add cell to tree store model */
 | 
					 | 
				
			||||||
			gtk_tree_store_set(self->cell_tree_store, &celliter,
 | 
					 | 
				
			||||||
					   CELL_SEL_CELL, gds_c,
 | 
					 | 
				
			||||||
					   CELL_SEL_CELL_ERROR_STATE, cell_error_level,
 | 
					 | 
				
			||||||
					   CELL_SEL_LIBRARY, gds_c->parent_library,
 | 
					 | 
				
			||||||
					   -1);
 | 
					 | 
				
			||||||
		} /* for cells */
 | 
					 | 
				
			||||||
	} /* for libraries */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Create Layers in Layer Box */
 | 
					 | 
				
			||||||
	layer_selector_generate_layer_widgets(self->layer_selector, self->gds_libraries);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
end_destroy:
 | 
					end_destroy:
 | 
				
			||||||
	/* Destroy dialog and filter */
 | 
						/* Destroy dialog and filter */
 | 
				
			||||||
@@ -745,6 +696,76 @@ GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui)
 | 
				
			|||||||
	return gui->main_window;
 | 
						return gui->main_window;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void gds_render_gui_open_gds(GdsRenderGui *self, const char *path)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						GList *cell;
 | 
				
			||||||
 | 
						GtkTreeIter libiter;
 | 
				
			||||||
 | 
						GtkTreeIter celliter;
 | 
				
			||||||
 | 
						GList *lib;
 | 
				
			||||||
 | 
						struct gds_library *gds_lib;
 | 
				
			||||||
 | 
						struct gds_cell *gds_c;
 | 
				
			||||||
 | 
						GtkStyleContext *button_style;
 | 
				
			||||||
 | 
						int gds_result;
 | 
				
			||||||
 | 
						unsigned int cell_error_level;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const struct gds_library_parsing_opts gds_parsing_options = {
 | 
				
			||||||
 | 
							.simplified_polygons = 1,
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						gtk_tree_store_clear(self->cell_tree_store);
 | 
				
			||||||
 | 
						clear_lib_list(&self->gds_libraries);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Parse new GDSII file */
 | 
				
			||||||
 | 
						gds_result = parse_gds_from_file(path, &self->gds_libraries, &gds_parsing_options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Delete file name afterwards */
 | 
				
			||||||
 | 
						if (gds_result)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* remove suggested action from Open button */
 | 
				
			||||||
 | 
						button_style = gtk_widget_get_style_context(self->open_button);
 | 
				
			||||||
 | 
						gtk_style_context_remove_class(button_style, "suggested-action");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (lib = self->gds_libraries; lib != NULL; lib = lib->next) {
 | 
				
			||||||
 | 
							gds_lib = (struct gds_library *)lib->data;
 | 
				
			||||||
 | 
							/* Create top level iter */
 | 
				
			||||||
 | 
							gtk_tree_store_append(self->cell_tree_store, &libiter, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							gtk_tree_store_set(self->cell_tree_store, &libiter,
 | 
				
			||||||
 | 
									   CELL_SEL_LIBRARY, gds_lib,
 | 
				
			||||||
 | 
									   -1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/* Check this library. This might take a while */
 | 
				
			||||||
 | 
							(void)gds_tree_check_cell_references(gds_lib);
 | 
				
			||||||
 | 
							(void)gds_tree_check_reference_loops(gds_lib);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (cell = gds_lib->cells; cell != NULL; cell = cell->next) {
 | 
				
			||||||
 | 
								gds_c = (struct gds_cell *)cell->data;
 | 
				
			||||||
 | 
								gtk_tree_store_append(self->cell_tree_store, &celliter, &libiter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								/* Get the checking results for this cell */
 | 
				
			||||||
 | 
								cell_error_level = 0;
 | 
				
			||||||
 | 
								if (gds_c->checks.unresolved_child_count)
 | 
				
			||||||
 | 
									cell_error_level |= LIB_CELL_RENDERER_ERROR_WARN;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								/* Check if it is completely b0rken */
 | 
				
			||||||
 | 
								if (gds_c->checks.affected_by_reference_loop)
 | 
				
			||||||
 | 
									cell_error_level |= LIB_CELL_RENDERER_ERROR_ERR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								/* Add cell to tree store model */
 | 
				
			||||||
 | 
								gtk_tree_store_set(self->cell_tree_store, &celliter,
 | 
				
			||||||
 | 
										   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 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Create Layers in Layer Box */
 | 
				
			||||||
 | 
						layer_selector_generate_layer_widgets(self->layer_selector, self->gds_libraries);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void gds_render_gui_init(GdsRenderGui *self)
 | 
					static void gds_render_gui_init(GdsRenderGui *self)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	GtkBuilder *main_builder;
 | 
						GtkBuilder *main_builder;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,6 +43,7 @@
 | 
				
			|||||||
#include <glib/gi18n.h>
 | 
					#include <glib/gi18n.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <gds-render/gds-utils/gds-parser.h>
 | 
					#include <gds-render/gds-utils/gds-parser.h>
 | 
				
			||||||
 | 
					#include <gds-render/gds-utils/gds-statistics.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Default units assumed for library.
 | 
					 * @brief Default units assumed for library.
 | 
				
			||||||
@@ -50,8 +51,8 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
#define GDS_DEFAULT_UNITS (10E-9)
 | 
					#define GDS_DEFAULT_UNITS (10E-9)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GDS_ERROR(fmt, ...) printf("[PARSE_ERROR] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS error*/
 | 
					#define GDS_ERROR(fmt, ...) fprintf(stderr, "[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_WARN(fmt, ...) fprintf(stderr, "[PARSE_WARNING] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS warning */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if GDS_PRINT_DEBUG_INFOS
 | 
					#if GDS_PRINT_DEBUG_INFOS
 | 
				
			||||||
	/**< @brief standard printf. But can be disabled in code. */
 | 
						/**< @brief standard printf. But can be disabled in code. */
 | 
				
			||||||
@@ -279,8 +280,13 @@ static GList *append_library(GList *curr_list, const struct gds_library_parsing_
 | 
				
			|||||||
		lib->cell_names = NULL;
 | 
							lib->cell_names = NULL;
 | 
				
			||||||
		/* Copy the settings into the library */
 | 
							/* Copy the settings into the library */
 | 
				
			||||||
		memcpy(&lib->parsing_opts, opts, sizeof(struct gds_library_parsing_opts));
 | 
							memcpy(&lib->parsing_opts, opts, sizeof(struct gds_library_parsing_opts));
 | 
				
			||||||
	} else
 | 
							lib->stats.cell_count = 0;
 | 
				
			||||||
 | 
							lib->stats.gfx_count = 0;
 | 
				
			||||||
 | 
							lib->stats.reference_count = 0;
 | 
				
			||||||
 | 
							lib->stats.vertex_count = 0;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (library_ptr)
 | 
						if (library_ptr)
 | 
				
			||||||
		*library_ptr = lib;
 | 
							*library_ptr = lib;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -356,6 +362,11 @@ static GList *append_cell(GList *curr_list, struct gds_cell **cell_ptr)
 | 
				
			|||||||
		cell->parent_library = NULL;
 | 
							cell->parent_library = NULL;
 | 
				
			||||||
		cell->checks.unresolved_child_count = GDS_CELL_CHECK_NOT_RUN;
 | 
							cell->checks.unresolved_child_count = GDS_CELL_CHECK_NOT_RUN;
 | 
				
			||||||
		cell->checks.affected_by_reference_loop = 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.total_gfx_count = 0;
 | 
				
			||||||
 | 
							cell->stats.gfx_count = 0;
 | 
				
			||||||
 | 
							cell->stats.vertex_count = 0;
 | 
				
			||||||
	} else
 | 
						} else
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	/* return cell */
 | 
						/* return cell */
 | 
				
			||||||
@@ -605,6 +616,15 @@ static void scan_library_references(gpointer library_list_item, gpointer user)
 | 
				
			|||||||
	g_list_foreach(lib->cells, scan_cell_references_and_polygons, 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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief gds_parse_date
 | 
					 * @brief gds_parse_date
 | 
				
			||||||
 * @param buffer Buffer that contains the GDS Date field
 | 
					 * @param buffer Buffer that contains the GDS Date field
 | 
				
			||||||
@@ -686,6 +706,7 @@ static void convert_aref_to_sref(struct gds_cell_array_instance *aref, struct gd
 | 
				
			|||||||
		for (row = 0; row < aref->rows; row++) {
 | 
							for (row = 0; row < aref->rows; row++) {
 | 
				
			||||||
			/* Create new instance for this row/column and configure data */
 | 
								/* 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->child_cells = append_cell_ref(container_cell->child_cells, &sref_inst);
 | 
				
			||||||
 | 
								container_cell->stats.reference_count++;
 | 
				
			||||||
			if (!sref_inst) {
 | 
								if (!sref_inst) {
 | 
				
			||||||
				GDS_ERROR("Appending cell ref failed!");
 | 
									GDS_ERROR("Appending cell ref failed!");
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
@@ -867,6 +888,7 @@ int parse_gds_from_file(const char *filename, GList **library_list,
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			current_cell->child_cells = append_cell_ref(current_cell->child_cells,
 | 
								current_cell->child_cells = append_cell_ref(current_cell->child_cells,
 | 
				
			||||||
								    ¤t_s_reference);
 | 
													    ¤t_s_reference);
 | 
				
			||||||
 | 
								current_cell->stats.reference_count++;
 | 
				
			||||||
			if (current_cell->child_cells == NULL) {
 | 
								if (current_cell->child_cells == NULL) {
 | 
				
			||||||
				GDS_ERROR("Memory allocation failed");
 | 
									GDS_ERROR("Memory allocation failed");
 | 
				
			||||||
				run = -4;
 | 
									run = -4;
 | 
				
			||||||
@@ -896,6 +918,9 @@ int parse_gds_from_file(const char *filename, GList **library_list,
 | 
				
			|||||||
							: (current_graphics->gfx_type == GRAPHIC_PATH ? "path"
 | 
												: (current_graphics->gfx_type == GRAPHIC_PATH ? "path"
 | 
				
			||||||
							: "box")));
 | 
												: "box")));
 | 
				
			||||||
				current_graphics = NULL;
 | 
									current_graphics = NULL;
 | 
				
			||||||
 | 
									if (current_cell) {
 | 
				
			||||||
 | 
										current_cell->stats.gfx_count++;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (current_s_reference != NULL) {
 | 
								if (current_s_reference != NULL) {
 | 
				
			||||||
				GDS_INF("\tLeaving Reference\n");
 | 
									GDS_INF("\tLeaving Reference\n");
 | 
				
			||||||
@@ -1045,7 +1070,9 @@ int parse_gds_from_file(const char *filename, GList **library_list,
 | 
				
			|||||||
					current_graphics->vertices =
 | 
										current_graphics->vertices =
 | 
				
			||||||
							append_vertex(current_graphics->vertices, x, y);
 | 
												append_vertex(current_graphics->vertices, x, y);
 | 
				
			||||||
					GDS_INF("\t\tSet coordinate: %d/%d\n", 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) {
 | 
								} else if (current_a_reference) {
 | 
				
			||||||
				for (i = 0; i < 3; i++) {
 | 
									for (i = 0; i < 3; i++) {
 | 
				
			||||||
@@ -1161,8 +1188,13 @@ int parse_gds_from_file(const char *filename, GList **library_list,
 | 
				
			|||||||
	if (!run) {
 | 
						if (!run) {
 | 
				
			||||||
		/* Iterate and find references to cells */
 | 
							/* Iterate and find references to cells */
 | 
				
			||||||
		g_list_foreach(lib_list, scan_library_references, NULL);
 | 
							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;
 | 
						*library_list = lib_list;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	free(workbuff);
 | 
						free(workbuff);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										93
									
								
								gds-utils/gds-statistics.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								gds-utils/gds-statistics.c
									
									
									
									
									
										Normal 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;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** @} */
 | 
				
			||||||
							
								
								
									
										56
									
								
								include/gds-render/cell-selector/cell-statistics-renderer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								include/gds-render/cell-selector/cell-statistics-renderer.h
									
									
									
									
									
										Normal 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_ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** @} */
 | 
				
			||||||
@@ -71,6 +71,14 @@ int command_line_convert_gds(const char *gds_name,
 | 
				
			|||||||
			     gboolean tex_layers,
 | 
								     gboolean tex_layers,
 | 
				
			||||||
			     double scale);
 | 
								     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_ */
 | 
					#endif /* _COMMAND_LINE_H_ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** @} */
 | 
					/** @} */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,6 +54,13 @@ GdsRenderGui *gds_render_gui_new();
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui);
 | 
					GtkWindow *gds_render_gui_get_main_window(GdsRenderGui *gui);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @brief gds_render_gui_open_gds Open a GDS file. Emulates the manual load via GUI open button
 | 
				
			||||||
 | 
					 * @param self GUI instance
 | 
				
			||||||
 | 
					 * @param path file path
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void gds_render_gui_open_gds(GdsRenderGui *self, const char *path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
G_END_DECLS
 | 
					G_END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** @} */
 | 
					/** @} */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										42
									
								
								include/gds-render/gds-utils/gds-statistics.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								include/gds-render/gds-utils/gds-statistics.h
									
									
									
									
									
										Normal 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_ */
 | 
				
			||||||
@@ -65,6 +65,22 @@ struct gds_point {
 | 
				
			|||||||
	int y;
 | 
						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.
 | 
					 * @brief Stores the result of the cell checks.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -127,6 +143,7 @@ struct gds_cell {
 | 
				
			|||||||
	GList *graphic_objs; /**< @brief List of #gds_graphics */
 | 
						GList *graphic_objs; /**< @brief List of #gds_graphics */
 | 
				
			||||||
	struct gds_library *parent_library; /**< @brief Pointer to parent library */
 | 
						struct gds_library *parent_library; /**< @brief Pointer to parent library */
 | 
				
			||||||
	struct gds_cell_checks checks; /**< @brief Checking results */
 | 
						struct gds_cell_checks checks; /**< @brief Checking results */
 | 
				
			||||||
 | 
					    struct gds_cell_statistics stats; /**< @brief Optional statistic info */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -147,8 +164,10 @@ struct gds_library {
 | 
				
			|||||||
	double unit_in_meters;  /**< Length of a database unit in meters */
 | 
						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 *cells; /**< List of #gds_cell that contains all cells in this library*/
 | 
				
			||||||
	GList *cell_names /**< List of strings that contains all cell names */;
 | 
						GList *cell_names /**< List of strings that contains all cell names */;
 | 
				
			||||||
 | 
					    struct gds_lib_statistics stats;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** @} */
 | 
					/** @} */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __GDS_TYPES_H__ */
 | 
					#endif /* __GDS_TYPES_H__ */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										45
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								main.c
									
									
									
									
									
								
							@@ -40,6 +40,8 @@
 | 
				
			|||||||
struct application_data {
 | 
					struct application_data {
 | 
				
			||||||
		GtkApplication *app;
 | 
							GtkApplication *app;
 | 
				
			||||||
		GList *gui_list;
 | 
							GList *gui_list;
 | 
				
			||||||
 | 
							gint num_files_to_open;
 | 
				
			||||||
 | 
							GFile **files;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -158,6 +160,7 @@ static void gapp_activate(GApplication *app, gpointer user_data)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	GtkWindow *main_window;
 | 
						GtkWindow *main_window;
 | 
				
			||||||
	GdsRenderGui *gui;
 | 
						GdsRenderGui *gui;
 | 
				
			||||||
 | 
						char *open_file_path;
 | 
				
			||||||
	struct application_data * const appdata = (struct application_data *)user_data;
 | 
						struct application_data * const appdata = (struct application_data *)user_data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gui = gds_render_gui_new();
 | 
						gui = gds_render_gui_new();
 | 
				
			||||||
@@ -166,11 +169,32 @@ static void gapp_activate(GApplication *app, gpointer user_data)
 | 
				
			|||||||
	g_signal_connect(gui, "window-closed", G_CALLBACK(gui_window_closed_callback), &appdata->gui_list);
 | 
						g_signal_connect(gui, "window-closed", G_CALLBACK(gui_window_closed_callback), &appdata->gui_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	main_window = gds_render_gui_get_main_window(gui);
 | 
						main_window = gds_render_gui_get_main_window(gui);
 | 
				
			||||||
 | 
						if (appdata->num_files_to_open >= 1) {
 | 
				
			||||||
 | 
							/* Open first file. Multiple files are not supported and ignored */
 | 
				
			||||||
 | 
							open_file_path = g_file_get_path(appdata->files[0]);
 | 
				
			||||||
 | 
							gds_render_gui_open_gds(gui, open_file_path);
 | 
				
			||||||
 | 
							g_free(open_file_path);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	gtk_application_add_window(GTK_APPLICATION(app), main_window);
 | 
						gtk_application_add_window(GTK_APPLICATION(app), main_window);
 | 
				
			||||||
	gtk_widget_show(GTK_WIDGET(main_window));
 | 
						gtk_widget_show(GTK_WIDGET(main_window));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @brief Activation of GUI when opening a file from commandline
 | 
				
			||||||
 | 
					 * @param app he GApplication reference
 | 
				
			||||||
 | 
					 * @param user_data Used to store the individual GUI instances.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static void gapp_activate_open(GApplication *app, GFile** files, gint n_files, const gchar* hint, gpointer user_data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						(void)hint;
 | 
				
			||||||
 | 
						struct application_data *appdata = (struct application_data *)user_data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						appdata->files = files;
 | 
				
			||||||
 | 
						appdata->num_files_to_open = n_files;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						gapp_activate(app, user_data);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Start the graphical interface.
 | 
					 * @brief Start the graphical interface.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -188,7 +212,9 @@ static int start_gui(int argc, char **argv)
 | 
				
			|||||||
	GString *application_domain;
 | 
						GString *application_domain;
 | 
				
			||||||
	int app_status;
 | 
						int app_status;
 | 
				
			||||||
	static struct application_data appdata = {
 | 
						static struct application_data appdata = {
 | 
				
			||||||
		.gui_list = NULL
 | 
							.gui_list = NULL,
 | 
				
			||||||
 | 
							.num_files_to_open = 0,
 | 
				
			||||||
 | 
							.files = NULL,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	GMenu *menu;
 | 
						GMenu *menu;
 | 
				
			||||||
	GMenu *m_quit;
 | 
						GMenu *m_quit;
 | 
				
			||||||
@@ -201,10 +227,11 @@ static int start_gui(int argc, char **argv)
 | 
				
			|||||||
	application_domain = g_string_new(NULL);
 | 
						application_domain = g_string_new(NULL);
 | 
				
			||||||
	g_string_printf(application_domain, "de.shimatta.gds_render_%s", _app_git_commit);
 | 
						g_string_printf(application_domain, "de.shimatta.gds_render_%s", _app_git_commit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gapp = gtk_application_new(application_domain->str, G_APPLICATION_FLAGS_NONE);
 | 
						gapp = gtk_application_new(application_domain->str, G_APPLICATION_HANDLES_OPEN);
 | 
				
			||||||
	g_string_free(application_domain, TRUE);
 | 
						g_string_free(application_domain, TRUE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	g_application_register(G_APPLICATION(gapp), NULL, NULL);
 | 
						g_application_register(G_APPLICATION(gapp), NULL, NULL);
 | 
				
			||||||
 | 
						g_signal_connect(gapp, "open", G_CALLBACK(gapp_activate_open), &appdata);
 | 
				
			||||||
	g_signal_connect(gapp, "activate", G_CALLBACK(gapp_activate), &appdata);
 | 
						g_signal_connect(gapp, "activate", G_CALLBACK(gapp_activate), &appdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (g_application_get_is_remote(G_APPLICATION(gapp)) == TRUE) {
 | 
						if (g_application_get_is_remote(G_APPLICATION(gapp)) == TRUE) {
 | 
				
			||||||
@@ -262,6 +289,8 @@ int main(int argc, char **argv)
 | 
				
			|||||||
	gchar *cellname = NULL;
 | 
						gchar *cellname = NULL;
 | 
				
			||||||
	gchar **renderer_args = NULL;
 | 
						gchar **renderer_args = NULL;
 | 
				
			||||||
	gboolean version = FALSE, pdf_standalone = FALSE, pdf_layers = FALSE;
 | 
						gboolean version = FALSE, pdf_standalone = FALSE, pdf_layers = FALSE;
 | 
				
			||||||
 | 
						gboolean analyze = FALSE;
 | 
				
			||||||
 | 
						gchar *format = NULL;
 | 
				
			||||||
	int scale = 1000;
 | 
						int scale = 1000;
 | 
				
			||||||
	int app_status = 0;
 | 
						int app_status = 0;
 | 
				
			||||||
	struct external_renderer_params so_render_params;
 | 
						struct external_renderer_params so_render_params;
 | 
				
			||||||
@@ -275,6 +304,8 @@ int main(int argc, char **argv)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	GOptionEntry entries[] = {
 | 
						GOptionEntry entries[] = {
 | 
				
			||||||
		{"version", 'v', 0, G_OPTION_ARG_NONE, &version, _("Print version"), NULL},
 | 
							{"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", 'r', 0, G_OPTION_ARG_STRING_ARRAY, &renderer_args,
 | 
				
			||||||
			_("Renderer to use. Can be used multiple times."), "pdf|svg|tikz|ext"},
 | 
								_("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>" },
 | 
							{"scale", 's', 0, G_OPTION_ARG_INT, &scale, _("Divide output coordinates by <SCALE>"), "<SCALE>" },
 | 
				
			||||||
@@ -307,7 +338,8 @@ int main(int argc, char **argv)
 | 
				
			|||||||
		goto ret_status;
 | 
							goto ret_status;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (argc >= 2) {
 | 
						/* A minimum of a file name and a cell or analyze command are needed to use CLI */
 | 
				
			||||||
 | 
						if (argc >= 2 && (analyze || cellname || output_paths)) {
 | 
				
			||||||
		if (scale < 1) {
 | 
							if (scale < 1) {
 | 
				
			||||||
			printf(_("Scale < 1 not allowed. Setting to 1\n"));
 | 
								printf(_("Scale < 1 not allowed. Setting to 1\n"));
 | 
				
			||||||
			scale = 1;
 | 
								scale = 1;
 | 
				
			||||||
@@ -320,10 +352,13 @@ int main(int argc, char **argv)
 | 
				
			|||||||
		for (i = 2; i < argc; i++)
 | 
							for (i = 2; i < argc; i++)
 | 
				
			||||||
			printf(_("Ignored argument: %s"), argv[i]);
 | 
								printf(_("Ignored argument: %s"), argv[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (analyze) {
 | 
				
			||||||
 | 
								app_status = command_line_analyze_lib(format, gds_name);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			app_status =
 | 
								app_status =
 | 
				
			||||||
				command_line_convert_gds(gds_name, cellname, renderer_args, output_paths, mappingname,
 | 
									command_line_convert_gds(gds_name, cellname, renderer_args, output_paths, mappingname,
 | 
				
			||||||
							 &so_render_params, pdf_standalone, pdf_layers, scale);
 | 
												 &so_render_params, pdf_standalone, pdf_layers, scale);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		app_status = start_gui(argc, argv);
 | 
							app_status = start_gui(argc, argv);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user