mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-04-21 12:27:27 +03:00
cameo/: new gnuplot tag #%id= with generator-assigned identifier
Excellon and Gerber store the file name there.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* gnuplot.c - Gnuplot file input/output
|
||||
*
|
||||
* Written 2010 by Werner Almesberger
|
||||
* Copyright 2010 Werner Almesberger
|
||||
* Written 2010-2011 by Werner Almesberger
|
||||
* Copyright 2010-2011 Werner Almesberger
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "path.h"
|
||||
#include "gnuplot.h"
|
||||
|
||||
@@ -25,6 +26,7 @@ struct path *gnuplot_read(const char *name, double r_tool_default)
|
||||
FILE *file;
|
||||
int lineno = 0;
|
||||
char buf[1024];
|
||||
char *id = NULL, *s;
|
||||
double x, y, z, tmp;
|
||||
double r_tool = r_tool_default;
|
||||
int outside = 0, notch = 0;
|
||||
@@ -46,6 +48,13 @@ struct path *gnuplot_read(const char *name, double r_tool_default)
|
||||
outside = 1;
|
||||
if (!strcmp(buf, "#%notch\n"))
|
||||
notch = 1;
|
||||
if (!strncmp(buf, "#%id=", 5)) {
|
||||
free(id);
|
||||
id = stralloc(buf+5);
|
||||
s = strchr(id, '\n');
|
||||
if (s)
|
||||
*s = 0;
|
||||
}
|
||||
if (*buf == '#')
|
||||
continue;
|
||||
n = sscanf(buf, "%lf %lf %lf\n", &x, &y, &z);
|
||||
@@ -67,7 +76,7 @@ struct path *gnuplot_read(const char *name, double r_tool_default)
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
path = path_new(r_tool);
|
||||
path = path_new(r_tool, id);
|
||||
path->outside = outside;
|
||||
path->notch = notch;
|
||||
*lnk = path;
|
||||
@@ -89,6 +98,9 @@ static int gnuplot_do_write(FILE *file, const struct path *paths)
|
||||
if (path != paths)
|
||||
if (fprintf(file, "\n") < 0)
|
||||
return 0;
|
||||
if (path->id &&
|
||||
fprintf(file, "#%%id=%s\n", path->id) < 0)
|
||||
return 0;
|
||||
if (path->r_tool &&
|
||||
fprintf(file, "#%%r_tool=%f\n", path->r_tool) < 0)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user