Compare commits
No commits in common. "bb13993e340416e71e613437c2bba0c5d14373c6" and "c60afedd6cf88f02a550c3f41111d0c92a9dd212" have entirely different histories.
bb13993e34
...
c60afedd6c
@ -17,43 +17,20 @@
|
|||||||
* 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 <stdio.h>
|
|
||||||
#include "command-line.h"
|
#include "command-line.h"
|
||||||
#include "gds-parser/gds-parser.h"
|
#include "gds-parser/gds-parser.h"
|
||||||
#include "mapping-parser.h"
|
#include "mapping-parser.h"
|
||||||
#include "cairo-output/cairo-output.h"
|
|
||||||
#include "latex-output/latex-output.h"
|
|
||||||
|
|
||||||
static void delete_layer_info_with_name(struct layer_info *info)
|
void command_line_convert_gds(char *gds_name, char *pdf_name, char *tex_name, gboolean pdf, gboolean tex, char *layer_file)
|
||||||
{
|
|
||||||
if (info) {
|
|
||||||
if (info->name)
|
|
||||||
g_free(info->name);
|
|
||||||
free(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void command_line_convert_gds(char *gds_name, char *pdf_name, char *tex_name, gboolean pdf, gboolean tex,
|
|
||||||
char *layer_file, char *cell_name, double scale, gboolean pdf_layers, gboolean pdf_standalone)
|
|
||||||
{
|
{
|
||||||
GList *libs = NULL;
|
GList *libs = NULL;
|
||||||
FILE *tex_file;
|
|
||||||
int res;
|
int res;
|
||||||
GFile *file;
|
GFile *file;
|
||||||
int i;
|
|
||||||
GFileInputStream *stream;
|
GFileInputStream *stream;
|
||||||
GDataInputStream *dstream;
|
GDataInputStream *dstream;
|
||||||
gboolean layer_export;
|
|
||||||
GdkRGBA layer_color;
|
|
||||||
int layer;
|
|
||||||
char *layer_name;
|
|
||||||
GList *layer_info_list = NULL;
|
|
||||||
GList *cell_list;
|
|
||||||
struct layer_info *linfo_temp;
|
|
||||||
struct gds_cell *toplevel_cell = NULL, *temp_cell;
|
|
||||||
|
|
||||||
/* Check if parameters are valid */
|
/* Check if parameters are valid */
|
||||||
if (!gds_name || ! pdf_name || !tex_name || !layer_file || !cell_name) {
|
if (!gds_name || ! pdf_name || !tex_name || !layer_file) {
|
||||||
printf("Probably missing argument. Check --help option\n");
|
printf("Probably missing argument. Check --help option\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,66 +44,12 @@ void command_line_convert_gds(char *gds_name, char *pdf_name, char *tex_name, gb
|
|||||||
file = g_file_new_for_path(layer_file);
|
file = g_file_new_for_path(layer_file);
|
||||||
stream = g_file_read(file, NULL, NULL);
|
stream = g_file_read(file, NULL, NULL);
|
||||||
|
|
||||||
if (!stream) {
|
if (!stream)
|
||||||
printf("Layer mapping not readable!\n");
|
|
||||||
goto destroy_file;
|
goto destroy_file;
|
||||||
}
|
|
||||||
dstream = g_data_input_stream_new(G_INPUT_STREAM(stream));
|
dstream = g_data_input_stream_new(G_INPUT_STREAM(stream));
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
res = load_csv_line(dstream, &layer_export, &layer_name, &layer, &layer_color);
|
|
||||||
if (res == 0) {
|
|
||||||
if (!layer_export)
|
|
||||||
continue;
|
|
||||||
linfo_temp = (struct layer_info *)malloc(sizeof(struct layer_info));
|
|
||||||
if (!linfo_temp) {
|
|
||||||
printf("Out of memory\n");
|
|
||||||
goto ret_clear_list;
|
|
||||||
}
|
|
||||||
linfo_temp->color.alpha = layer_color.alpha;
|
|
||||||
linfo_temp->color.red = layer_color.red;
|
|
||||||
linfo_temp->color.green = layer_color.green;
|
|
||||||
linfo_temp->color.blue = layer_color.blue;
|
|
||||||
linfo_temp->name = layer_name;
|
|
||||||
linfo_temp->stacked_position = i++;
|
|
||||||
linfo_temp->layer = layer;
|
|
||||||
layer_info_list = g_list_append(layer_info_list, (gpointer)linfo_temp);
|
|
||||||
}
|
|
||||||
} while(res >= 0);
|
|
||||||
|
|
||||||
|
|
||||||
/* find_cell in first library. */
|
|
||||||
if (!libs)
|
|
||||||
goto ret_clear_list;
|
|
||||||
|
|
||||||
for (cell_list = ((struct gds_library *)libs->data)->cells; cell_list != NULL; cell_list = g_list_next(cell_list)) {
|
|
||||||
temp_cell = (struct gds_cell *)cell_list->data;
|
|
||||||
if (!strcmp(temp_cell->name, cell_name)) {
|
|
||||||
toplevel_cell = temp_cell;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!toplevel_cell) {
|
|
||||||
printf("Couldn't find cell in first library!\n");
|
|
||||||
goto ret_clear_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Render outputs */
|
|
||||||
if (pdf == TRUE) {
|
|
||||||
cairo_render_cell_to_pdf(toplevel_cell, layer_info_list, pdf_name, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tex == TRUE) {
|
|
||||||
tex_file = fopen(tex_name, "w");
|
|
||||||
if (!tex_file)
|
|
||||||
goto ret_clear_list;
|
|
||||||
latex_render_cell_to_code(toplevel_cell, layer_info_list, tex_file, scale, pdf_layers, pdf_standalone);
|
|
||||||
fclose(tex_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_clear_list:
|
|
||||||
g_list_free_full(layer_info_list, (GDestroyNotify)delete_layer_info_with_name);
|
|
||||||
|
|
||||||
g_object_unref(dstream);
|
g_object_unref(dstream);
|
||||||
g_object_unref(stream);
|
g_object_unref(stream);
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#define _COMMAND_LINE_H_
|
#define _COMMAND_LINE_H_
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
void command_line_convert_gds(char *gds_name, char *pdf_name, char *tex_name, gboolean pdf, gboolean tex,
|
void command_line_convert_gds(char *gds_name, char *pdf_name, char *tex_name, gboolean pdf, gboolean tex, char *layer_file);
|
||||||
char *layer_file, char *cell_name, double scale, gboolean pdf_layers, gboolean pdf_standalone);
|
|
||||||
|
|
||||||
#endif /* _COMMAND_LINE_H_ */
|
#endif /* _COMMAND_LINE_H_ */
|
||||||
|
44
main.c
44
main.c
@ -108,10 +108,8 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gchar *gds_name;
|
gchar *pdfname = NULL, *texname = NULL, *mappingname = NULL;
|
||||||
gchar *basename;
|
gboolean tikz = TRUE, pdf = FALSE;
|
||||||
gchar *pdfname = NULL, *texname = NULL, *mappingname = NULL, *cellname = NULL;
|
|
||||||
gboolean tikz = FALSE, pdf = FALSE, pdf_layers = FALSE, pdf_standalone = FALSE;
|
|
||||||
int scale = 1000;
|
int scale = 1000;
|
||||||
int app_status;
|
int app_status;
|
||||||
|
|
||||||
@ -124,9 +122,6 @@ int main(int argc, char **argv)
|
|||||||
{ "tex-output", 'o', 0, G_OPTION_ARG_FILENAME, &texname, "Optional path for TeX file", "PATH" },
|
{ "tex-output", 'o', 0, G_OPTION_ARG_FILENAME, &texname, "Optional path for TeX file", "PATH" },
|
||||||
{ "pdf-output", 'O', 0, G_OPTION_ARG_FILENAME, &pdfname, "Optional path for PDF file", "PATH" },
|
{ "pdf-output", 'O', 0, G_OPTION_ARG_FILENAME, &pdfname, "Optional path for PDF file", "PATH" },
|
||||||
{ "mapping", 'm', 0, G_OPTION_ARG_FILENAME, &mappingname, "Path for Layer Mapping File", "PATH" },
|
{ "mapping", 'm', 0, G_OPTION_ARG_FILENAME, &mappingname, "Path for Layer Mapping File", "PATH" },
|
||||||
{ "cell", 'c', 0, G_OPTION_ARG_STRING, &cellname, "Cell to render", "NAME" },
|
|
||||||
{ "tex-standalone", 'a', 0, G_OPTION_ARG_NONE, &pdf_standalone, "Create standalone PDF", NULL },
|
|
||||||
{ "tex-layers", 'l', 0, G_OPTION_ARG_NONE, &pdf_layers, "Create standalone PDF", NULL },
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,40 +135,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
if (scale < 1) {
|
command_line_convert_gds(NULL, pdfname, texname, pdf, tikz, mappingname);
|
||||||
printf("Scale < 1 not allowed. Setting to 1\n");
|
|
||||||
scale = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No format selected */
|
|
||||||
if (!(tikz || pdf)) {
|
|
||||||
tikz = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get gds name */
|
|
||||||
gds_name = argv[1];
|
|
||||||
|
|
||||||
/* Check if PDF/TeX names are supplied. if not generate */
|
|
||||||
basename = g_path_get_basename(gds_name);
|
|
||||||
|
|
||||||
if (!texname) {
|
|
||||||
texname = g_strdup_printf("./%s.tex", basename);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pdfname) {
|
|
||||||
pdfname = g_strdup_printf("./%s.pdf", basename);
|
|
||||||
}
|
|
||||||
|
|
||||||
command_line_convert_gds(gds_name, pdfname, texname, pdf, tikz, mappingname, cellname,
|
|
||||||
(double)scale, pdf_layers, pdf_standalone);
|
|
||||||
/* Clean up */
|
|
||||||
g_free(pdfname);
|
|
||||||
g_free(texname);
|
|
||||||
if (mappingname)
|
|
||||||
g_free(mappingname);
|
|
||||||
if (cellname)
|
|
||||||
g_free(cellname);
|
|
||||||
app_status = 0;
|
|
||||||
} else {
|
} else {
|
||||||
app_status = start_gui(argc, argv);
|
app_status = start_gui(argc, argv);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user