summaryrefslogtreecommitdiff
path: root/meme/meme.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-02-15 21:13:47 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-02-15 21:13:47 (GMT)
commit64bd53f6a5413810dd8e36237cf5aaf9feee0be4 (patch)
tree3ec42f6762e9680c57c432314ab1467d09f73659 /meme/meme.c
parentff87a9e52408776b5f7fc32889b85d74e09857a7 (diff)
downloadmisc-64bd53f6a5413810dd8e36237cf5aaf9feee0be4.zip
misc-64bd53f6a5413810dd8e36237cf5aaf9feee0be4.tar.gz
misc-64bd53f6a5413810dd8e36237cf5aaf9feee0be4.tar.bz2
meme/: non-interactive screen dumps with -D ...
Diffstat (limited to 'meme/meme.c')
-rw-r--r--meme/meme.c101
1 files changed, 97 insertions, 4 deletions
diff --git a/meme/meme.c b/meme/meme.c
index 2f0c976..85e6c2c 100644
--- a/meme/meme.c
+++ b/meme/meme.c
@@ -66,6 +66,7 @@ static void usage(const char *name)
{
fprintf(stderr,
"usage: %s [-d dump.bmp] [-l logfile] [-m marker.gp] [-o overlay.gp ...]\n"
+" [-D xres yres [-C cx cy] [-E z zoom] [-M mx my] [-P] [-Z zoom]]\n"
" [file.stl]\n"
" %s -s plane.gp [-n] [file.stl]\n\n"
" -d dump.bmp\n"
@@ -77,7 +78,19 @@ static void usage(const char *name)
" -n when slicing, try to compensate for the scanning needle geometry\n"
" -o overlay.gp\n"
" display the specified overlays. The option can be repeated.\n"
-" -s slice the mesh with a plane. This is non-interactive.\n"
+" -s slice the mesh with a plane. This is non-interactive.\n\n"
+" -D xres yres\n"
+" non-interactively dump a screenshot of mesh and adornments\n"
+" -C cx cy\n"
+" show the cursor at the specified position\n"
+" -E z zoom\n"
+" enhance contrast around Z by the specified zoom factor\n"
+" -M mx my\n"
+" set the middle of the screen to the specified position\n"
+" -P show profiles\n"
+" -Z zoom\n"
+" set the specified zoom level. If prefixed with - or +, zoom out or\n"
+" in from default zoom\n"
, name, name);
exit(1);
}
@@ -92,8 +105,20 @@ int main(int argc, char **argv)
struct overlay overlays[N_OVERLAYS];
unsigned n_overlays = 0;
struct time t_load;
-
- while ((c = getopt(argc, argv, "d:l:m:no:s:")) != EOF)
+ int args = 0;
+ bool headless_dump = 0;
+ int dump_cursor = 0, dump_middle = 0, dump_enhance = 0, dump_zoom = 0;
+
+ struct dump_params prm = {
+ .middle = 0,
+ .zoom_abs = 0,
+ .zoom_rel = 0,
+ .cursor = 0,
+ .enhance = 0,
+ .profile = 0,
+ };
+
+ while ((c = getopt(argc, argv, "d:l:m:no:s:DCEMPZ")) != EOF)
switch (c) {
case 'd':
screen_dump_name = optarg;
@@ -119,10 +144,73 @@ int main(int argc, char **argv)
case 's':
slice = optarg;
break;
+ case 'D':
+ headless_dump = 1;
+ args += 2;
+ break;
+ case 'C':
+ if (!headless_dump)
+ usage(*argv);
+ prm.cursor = 1;
+ dump_cursor = args;
+ args += 2;
+ break;
+ case 'E':
+ if (!headless_dump)
+ usage(*argv);
+ prm.enhance = 1;
+ dump_enhance = args;
+ args += 2;
+ break;
+ case 'M':
+ if (!headless_dump)
+ usage(*argv);
+ prm.middle = 1;
+ dump_middle = args;
+ args += 2;
+ break;
+ case 'P':
+ if (!headless_dump)
+ usage(*argv);
+ prm.profile = 1;
+ break;
+ case 'Z':
+ if (!headless_dump)
+ usage(*argv);
+ dump_zoom = args;
+ args++;
+ break;
default:
usage(*argv);
}
+ if (headless_dump) {
+ if (argc - optind < args)
+ usage(*argv);
+ prm.xres = atoi(argv[optind]);
+ prm.yres = atoi(argv[optind + 1]);
+ if (prm.cursor)
+ overlay_xform(atof(argv[optind + dump_cursor]),
+ atof(argv[optind + dump_cursor + 1]),
+ &prm.cx, &prm.cy);
+ if (prm.enhance) {
+ prm.enh_z = atof(argv[optind + dump_enhance]) * 1000;
+ prm.enh_scale = atoi(argv[optind + dump_enhance + 1]);
+ }
+ if (prm.middle)
+ overlay_xform(atof(argv[optind + dump_middle]),
+ atof(argv[optind + dump_middle + 1]),
+ &prm.mx, &prm.my);
+ if (dump_zoom) {
+ prm.zoom = atof(argv[optind + dump_zoom]);
+ if (strchr("+-", *argv[optind + dump_zoom]))
+ prm.zoom_rel = 1;
+ else
+ prm.zoom_abs = 1;
+ }
+ optind += args;
+ }
+
switch (argc - optind) {
case 0:
time_start(&t_load);
@@ -144,7 +232,12 @@ int main(int argc, char **argv)
if (slice) {
slice_load(slice);
slice_run(slice_out, needle);
- exit(1);
+ exit(0);
+ }
+
+ if (headless_dump) {
+ gui_dump(overlays, n_overlays, &prm);
+ exit(0);
}
gui(logfile, overlays, n_overlays);