2018-07-19 17:49:33 +02:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cairo-output.h"
|
|
|
|
#include <math.h>
|
2018-07-19 18:45:37 +02:00
|
|
|
#include <stdlib.h>
|
2018-07-19 17:49:33 +02:00
|
|
|
#include <cairo.h>
|
|
|
|
#include <cairo-pdf.h>
|
|
|
|
|
2018-07-19 18:45:37 +02:00
|
|
|
struct cairo_layer {
|
|
|
|
cairo_t *cr;
|
|
|
|
cairo_surface_t *rec;
|
|
|
|
struct layer_info *linfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
void cairo_render_cell_to_pdf(struct gds_cell *cell, GList *layer_infos, char *pdf_file, double scale)
|
2018-07-19 17:49:33 +02:00
|
|
|
{
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
cairo_t *cr;
|
2018-07-19 18:45:37 +02:00
|
|
|
struct layer_info *linfo;
|
|
|
|
struct cairo_layer *layers;
|
|
|
|
struct cairo_layer *lay;
|
|
|
|
GList *info_list;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
layers = (struct cairo_layer *)calloc(MAX_LAYERS, sizeof(struct cairo_layer));
|
|
|
|
|
|
|
|
/* Clear layers */
|
|
|
|
for (i = 0; i < MAX_LAYERS; i++) {
|
|
|
|
layers[i].cr = NULL;
|
|
|
|
layers[i].rec = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create recording surface for each layer */
|
|
|
|
for (info_list = layer_infos; info_list != NULL; info_list = g_list_next(info_list)) {
|
|
|
|
linfo = (struct layer_info *)info_list->data;
|
|
|
|
if (linfo->layer < MAX_LAYERS) {
|
|
|
|
lay = &(layers[(unsigned int)linfo->layer]);
|
|
|
|
lay->linfo = linfo;
|
|
|
|
lay->rec = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA,
|
|
|
|
NULL);
|
|
|
|
lay->cr = cairo_create(layers[(unsigned int)linfo->layer].rec);
|
|
|
|
cairo_scale(lay->cr, 1/scale, 1/scale);
|
|
|
|
} else {
|
|
|
|
printf("Layer number (%d) too high!\n", linfo->layer);
|
|
|
|
goto ret_clear_layers;
|
|
|
|
}
|
|
|
|
}
|
2018-07-19 17:49:33 +02:00
|
|
|
|
|
|
|
|
2018-07-19 18:45:37 +02:00
|
|
|
ret_clear_layers:
|
|
|
|
for (i = 0; i < MAX_LAYERS; i++) {
|
|
|
|
lay = &layers[i];
|
|
|
|
cairo_destroy(lay->cr);
|
|
|
|
cairo_surface_destroy(lay->rec);
|
|
|
|
}
|
|
|
|
free(layers);
|
2018-07-19 17:49:33 +02:00
|
|
|
|
|
|
|
printf("cairo export not yet implemented!\n");
|
|
|
|
}
|