Disable prints in GDS renderer. Wrote documentation

This commit is contained in:
Mario Hüttel 2018-07-24 17:45:16 +02:00
parent 5c3b299eb0
commit 5526e403a3
7 changed files with 149 additions and 44 deletions

View File

@ -0,0 +1,6 @@
/* This file only contains help information for doxygen */
/**
* @defgroup MainApplication Main Application
*
*/

View File

@ -51,6 +51,11 @@
#define GDS_ERROR(fmt, ...) printf("[PARSE_ERROR] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS error*/ #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_WARN(fmt, ...) printf("[PARSE_WARNING] " fmt "\n", ##__VA_ARGS__) /**< @brief Print GDS warning */
#if GDS_PRINT_DEBUG_INFOS
#define GDS_INF(fmt, ...) printf(fmt, ##__VA_ARGS__) /**< @brief standard printf. But cna be disabled in code */
#else
#define GDS_INF(fmt, ...)
#endif
enum gds_record { enum gds_record {
INVALID = 0x0000, INVALID = 0x0000,
HEADER = 0x0002, HEADER = 0x0002,
@ -101,7 +106,7 @@ static int name_cell_ref(struct gds_cell_instance *cell_inst,
/* else: */ /* else: */
strcpy(cell_inst->ref_name, data); strcpy(cell_inst->ref_name, data);
printf("\tCell referenced: %s\n", cell_inst->ref_name); GDS_INF("\tCell referenced: %s\n", cell_inst->ref_name);
return 0; return 0;
} }
@ -355,7 +360,7 @@ static int name_library(struct gds_library *current_library,
} }
strcpy(current_library->name, data); strcpy(current_library->name, data);
printf("Named library: %s\n", current_library->name); GDS_INF("Named library: %s\n", current_library->name);
return 0; return 0;
} }
@ -385,7 +390,7 @@ static int name_cell(struct gds_cell *cell, unsigned int bytes,
} }
strcpy(cell->name, data); strcpy(cell->name, data);
printf("Named cell: %s\n", cell->name); GDS_INF("Named cell: %s\n", cell->name);
/* Append cell name to lib's list of names */ /* Append cell name to lib's list of names */
lib->cell_names = g_list_append(lib->cell_names, cell->name); lib->cell_names = g_list_append(lib->cell_names, cell->name);
@ -407,7 +412,7 @@ static void parse_reference_list(gpointer gcell_ref, gpointer glibrary)
GList *cell_item; GList *cell_item;
struct gds_cell *cell; struct gds_cell *cell;
printf("\t\t\tReference: %s: ", inst->ref_name); GDS_INF("\t\t\tReference: %s: ", inst->ref_name);
/* Find cell */ /* Find cell */
for (cell_item = lib->cells; cell_item != NULL; for (cell_item = lib->cells; cell_item != NULL;
cell_item = cell_item->next) { cell_item = cell_item->next) {
@ -415,14 +420,14 @@ static void parse_reference_list(gpointer gcell_ref, gpointer glibrary)
cell = (struct gds_cell *)cell_item->data; cell = (struct gds_cell *)cell_item->data;
/* Check if cell is found */ /* Check if cell is found */
if (!strcmp(cell->name, inst->ref_name)) { if (!strcmp(cell->name, inst->ref_name)) {
printf("found\n"); GDS_INF("found\n");
/* update reference link */ /* update reference link */
inst->cell_ref = cell; inst->cell_ref = cell;
return; return;
} }
} }
printf("MISSING!\n"); GDS_INF("MISSING!\n");
GDS_WARN("referenced cell could not be found in library"); GDS_WARN("referenced cell could not be found in library");
} }
@ -436,7 +441,7 @@ static void scan_cell_reference_dependencies(gpointer gcell, gpointer library)
{ {
struct gds_cell *cell = (struct gds_cell *)gcell; struct gds_cell *cell = (struct gds_cell *)gcell;
printf("\tScanning cell: %s\n", cell->name); GDS_INF("\tScanning cell: %s\n", cell->name);
/* Scan all library references */ /* Scan all library references */
g_list_foreach(cell->child_cells, parse_reference_list, library); g_list_foreach(cell->child_cells, parse_reference_list, library);
@ -454,7 +459,7 @@ static void scan_library_references(gpointer library_list_item, gpointer user)
{ {
struct gds_library *lib = (struct gds_library *)library_list_item; struct gds_library *lib = (struct gds_library *)library_list_item;
printf("Scanning Library: %s\n", lib->name); 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_reference_dependencies, lib);
} }
@ -583,7 +588,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
} }
printf("Entering Lib\n"); GDS_INF("Entering Lib\n");
break; break;
case ENDLIB: case ENDLIB:
if (current_lib == NULL) { if (current_lib == NULL) {
@ -599,7 +604,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
} }
current_lib = NULL; current_lib = NULL;
printf("Leaving Library\n"); GDS_INF("Leaving Library\n");
break; break;
case BGNSTR: case BGNSTR:
current_lib->cells = append_cell(current_lib->cells, &current_cell); current_lib->cells = append_cell(current_lib->cells, &current_cell);
@ -608,7 +613,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
run = -3; run = -3;
break; break;
} }
printf("Entering Cell\n"); GDS_INF("Entering Cell\n");
break; break;
case ENDSTR: case ENDSTR:
if (current_cell == NULL) { if (current_cell == NULL) {
@ -623,7 +628,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
} }
current_cell = NULL; current_cell = NULL;
printf("Leaving Cell\n"); GDS_INF("Leaving Cell\n");
break; break;
case BOX: case BOX:
case BOUNDARY: case BOUNDARY:
@ -640,7 +645,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
run = -4; run = -4;
break; break;
} }
printf("\tEntering boundary/Box\n"); GDS_INF("\tEntering boundary/Box\n");
break; break;
case SREF: case SREF:
if (current_cell == NULL) { if (current_cell == NULL) {
@ -656,7 +661,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
} }
printf("\tEntering reference\n"); GDS_INF("\tEntering reference\n");
break; break;
case PATH: case PATH:
if (current_cell == NULL) { if (current_cell == NULL) {
@ -671,16 +676,16 @@ int parse_gds_from_file(const char *filename, GList **library_list)
run = -4; run = -4;
break; break;
} }
printf("\tEntering Path\n"); GDS_INF("\tEntering Path\n");
break; break;
case ENDEL: case ENDEL:
if (current_graphics != NULL) { if (current_graphics != NULL) {
printf("\tLeaving %s\n", (current_graphics->gfx_type == GRAPHIC_POLYGON ? "boundary" : "path")); GDS_INF("\tLeaving %s\n", (current_graphics->gfx_type == GRAPHIC_POLYGON ? "boundary" : "path"));
current_graphics = NULL; current_graphics = NULL;
} }
if (current_s_reference != NULL) { if (current_s_reference != NULL) {
printf("\tLeaving Reference\n"); GDS_INF("\tLeaving Reference\n");
current_s_reference = NULL; current_s_reference = NULL;
} }
break; break;
@ -755,7 +760,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
/* Get origin of reference */ /* Get origin of reference */
current_s_reference->origin.x = gds_convert_signed_int(workbuff); current_s_reference->origin.x = gds_convert_signed_int(workbuff);
current_s_reference->origin.y = gds_convert_signed_int(&workbuff[4]); current_s_reference->origin.y = gds_convert_signed_int(&workbuff[4]);
printf("\t\tSet origin to: %d/%d\n", current_s_reference->origin.x, GDS_INF("\t\tSet origin to: %d/%d\n", current_s_reference->origin.x,
current_s_reference->origin.y); current_s_reference->origin.y);
} else if (current_graphics) { } else if (current_graphics) {
for (i = 0; i < read/8; i++) { for (i = 0; i < read/8; i++) {
@ -763,7 +768,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
y = gds_convert_signed_int(&workbuff[i*8+4]); y = gds_convert_signed_int(&workbuff[i*8+4]);
current_graphics->vertices = current_graphics->vertices =
append_vertex(current_graphics->vertices, x, y); append_vertex(current_graphics->vertices, x, y);
printf("\t\tSet coordinate: %d/%d\n", x, y); GDS_INF("\t\tSet coordinate: %d/%d\n", x, y);
} }
} }
@ -794,7 +799,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
if (current_graphics->layer < 0) { if (current_graphics->layer < 0) {
GDS_WARN("Layer negative!\n"); GDS_WARN("Layer negative!\n");
} }
printf("\t\tAdded layer %d\n", (int)current_graphics->layer); GDS_INF("\t\tAdded layer %d\n", (int)current_graphics->layer);
break; break;
case MAG: case MAG:
if (rec_data_length != 8) { if (rec_data_length != 8) {
@ -807,7 +812,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
} }
if (current_s_reference != NULL) { if (current_s_reference != NULL) {
current_s_reference->magnification = gds_convert_double(workbuff); current_s_reference->magnification = gds_convert_double(workbuff);
printf("\t\tMagnification defined: %lf\n", current_s_reference->magnification); GDS_INF("\t\tMagnification defined: %lf\n", current_s_reference->magnification);
} }
break; break;
case ANGLE: case ANGLE:
@ -821,7 +826,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
} }
if (current_s_reference != NULL) { if (current_s_reference != NULL) {
current_s_reference->angle = gds_convert_double(workbuff); current_s_reference->angle = gds_convert_double(workbuff);
printf("\t\tAngle defined: %lf\n", current_s_reference->angle); GDS_INF("\t\tAngle defined: %lf\n", current_s_reference->angle);
} }
break; break;
case PATHTYPE: case PATHTYPE:
@ -831,7 +836,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
} }
if (current_graphics->gfx_type == GRAPHIC_PATH) { if (current_graphics->gfx_type == GRAPHIC_PATH) {
current_graphics->path_render_type = (int)gds_convert_signed_int16(workbuff); current_graphics->path_render_type = (int)gds_convert_signed_int16(workbuff);
printf("\t\tPathtype: %d\n", current_graphics->path_render_type); GDS_INF("\t\tPathtype: %d\n", current_graphics->path_render_type);
} else { } else {
GDS_WARN("Path type defined inside non-path graphics object. Ignoring"); GDS_WARN("Path type defined inside non-path graphics object. Ignoring");
} }

View File

@ -34,6 +34,8 @@
#include <glib.h> #include <glib.h>
#include "gds-types.h" #include "gds-types.h"
#define GDS_PRINT_DEBUG_INFOS (0) /**< @brief 1: Print infos, 0: Don't print */
int parse_gds_from_file(const char *filename, GList **library_array); int parse_gds_from_file(const char *filename, GList **library_array);
/** /**
* @brief Deletes all libraries including cells, references etc. * @brief Deletes all libraries including cells, references etc.

View File

@ -17,11 +17,35 @@
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>. * along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/ */
/**
* @file latex-output.c
* @brief LaTeX output renderer
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#include "latex-output.h" #include "latex-output.h"
#include <math.h> #include <math.h>
/**
* @addtogroup LaTeX-Renderer
* @{
*/
/** @brief Writes a GString \p buffer to the fixed file tex_file */
#define WRITEOUT_BUFFER(buff) fwrite((buff)->str, sizeof(char), (buff)->len, tex_file) #define WRITEOUT_BUFFER(buff) fwrite((buff)->str, sizeof(char), (buff)->len, tex_file)
/**
* @brief Write the layer declarration to TeX file
*
* This writes the declaration of the layers and the mapping in which order
* the layers shall be rendered by TikZ. Layers are written in the order they are
* positioned inside the \p layer_infos list.
*
* @param tex_file TeX-File to write to
* @param layer_infos List containing layer_info structs.
* @param buffer
* @note The field layer_info::stacked_position is ignored. Stack depends on list order.
*/
static void write_layer_definitions(FILE *tex_file, GList *layer_infos, GString *buffer) static void write_layer_definitions(FILE *tex_file, GList *layer_infos, GString *buffer)
{ {
GList *list; GList *list;
@ -53,11 +77,30 @@ static void write_layer_definitions(FILE *tex_file, GList *layer_infos, GString
} }
/** /**
* @brief write_layer_env * @brief Write layer Envirmonment
* @param tex_file *
* @param layer * If the requested layer shall be rendered, this code writes the necessary code
* @param buffer * to open the layer. It also returns the color the layer shall be rendered in.
* @return TRUE if layer is placeable *
* The followingenvironments are generated:
*
* @code{.tex}
* \begin{pgfonlayer}{<layer>}
* % If pdf layers shall be used also this is enabled:
* \begin{scope}[ocg={ref=<layer>, status=visible,name={<Layer Name>}}]
* @endcode
*
*
* If the layer shall not be rendered, FALSE is returned and the color is not filled in and
* the cod eis not written to the file.
*
* @param tex_file TeX file to write to
* @param color Return of the layer's color
* @param layer Requested layer number
* @param linfo Layer information list containing layer_info structs
* @param buffer Some working buffer
* @return TRUE, if the layer shall be rendered.
* @note The opened environments have to be closed afterwards
*/ */
static gboolean write_layer_env(FILE *tex_file, GdkRGBA *color, int layer, GList *linfo, GString *buffer) static gboolean write_layer_env(FILE *tex_file, GdkRGBA *color, int layer, GList *linfo, GString *buffer)
{ {
@ -80,7 +123,17 @@ static gboolean write_layer_env(FILE *tex_file, GdkRGBA *color, int layer, GList
return FALSE; return FALSE;
} }
/**
* @brief Writes a graphics object to the specified tex_file
*
* This function opens the layer, writes a graphics object and closes the layer
*
* @param tex_file File to write to
* @param graphics Object to render
* @param linfo Layer information
* @param buffer Working buffer
* @param scale Scale abject down by this value
*/
static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GString *buffer, double scale) static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GString *buffer, double scale)
{ {
GList *temp; GList *temp;
@ -144,7 +197,14 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt
} /* For graphics */ } /* For graphics */
} }
/**
* @brief Render cell to file
* @param cell Cell to render
* @param layer_infos Layer information
* @param tex_file File to write to
* @param buffer Working buffer
* @param scale Scale output down by this value
*/
static void render_cell(struct gds_cell *cell, GList *layer_infos, FILE *tex_file, GString *buffer, double scale) static void render_cell(struct gds_cell *cell, GList *layer_infos, FILE *tex_file, GString *buffer, double scale)
{ {
@ -238,3 +298,5 @@ void latex_render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *
fflush(tex_file); fflush(tex_file);
g_string_free(working_line, TRUE); g_string_free(working_line, TRUE);
} }
/** @} */

View File

@ -34,7 +34,7 @@
#include "../gds-parser/gds-types.h" #include "../gds-parser/gds-types.h"
#include <glib.h> #include <glib.h>
#include <stdio.h> #include <stdio.h>
#include "../layer-selector.h" #include "../mapping-parser.h"
#define LATEX_LINE_BUFFER_KB (10) /**< @brief Buffer for LaTeX Code line in KiB */ #define LATEX_LINE_BUFFER_KB (10) /**< @brief Buffer for LaTeX Code line in KiB */

View File

@ -18,18 +18,19 @@
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>. * along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "mapping-parser.h" /**
* @file mapping-parser.c
* @brief Function to read a mapping file line and parse it.
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
/** /**
* @brief load_csv_line * @addtogroup MainApplication
* @param file * @{
* @param export
* @param name
* @param layer
* @param color
* @param opacity
* @return 0 if succesfull, 1 if line was malformatted or parameters are broken, -1 if file end
*/ */
#include "mapping-parser.h"
int load_csv_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color) int load_csv_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color)
{ {
int ret; int ret;
@ -93,3 +94,5 @@ ret_direct:
} }
/** @} */

View File

@ -17,19 +17,46 @@
* along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>. * along with GDSII-Converter. If not, see <http://www.gnu.org/licenses/>.
*/ */
/**
* @file mapping-parser.h
* @brief Function to read a mapping file line and parse it.
* @author Mario Hüttel <mario.huettel@gmx.net>
*/
#ifndef __MAPPING_PARSER_H__ #ifndef __MAPPING_PARSER_H__
#define __MAPPING_PARSER_H__ #define __MAPPING_PARSER_H__
/**
* @addtogroup MainApplication
* @{
*/
#include <gtk/gtk.h> #include <gtk/gtk.h>
/**
* @brief Layer information.
*
* This structs contains information on how to render a layer
*/
struct layer_info struct layer_info
{ {
int layer; int layer; /**< @brief Layer number */
char *name; char *name; /**< @brief Layer name */
int stacked_position; ///< Lower is bottom, higher is top int stacked_position; ///< @brief Position of layer in output @warning This parameter is not used by any renderer so far @note Lower is bottom, higher is top
GdkRGBA color; GdkRGBA color; /**< @brief RGBA color used to render this layer */
}; };
/**
* @brief Load a line from \p stream and parse try to parse it as layer information
* @param stream Input data stream
* @param export Layer shall be exported
* @param name Layer name. Free returned pointer after using.
* @param layer Layer number
* @param color RGBA color.
* @return 1 if malformatted line, 0 if parsing was successful and parameters are valid, -1 if file end
*/
int load_csv_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color); int load_csv_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color);
/** @} */
#endif /* __MAPPING_PARSER_H__ */ #endif /* __MAPPING_PARSER_H__ */