summaryrefslogtreecommitdiff
path: root/meme
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-02-14 02:12:42 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-02-14 02:13:28 (GMT)
commitfd505de82aa73c850d7b122dc3c9f7829995ad9c (patch)
tree26c825b2c209918c758a7dee1fa7a29e1b6195bb /meme
parent32f2b42c5055e0783ad3c076a1bdb9d6abcb5b28 (diff)
downloadmisc-fd505de82aa73c850d7b122dc3c9f7829995ad9c.zip
misc-fd505de82aa73c850d7b122dc3c9f7829995ad9c.tar.gz
misc-fd505de82aa73c850d7b122dc3c9f7829995ad9c.tar.bz2
meme/: add screen dumps with "D"; option "-d dump.bmp" to set dump name
Diffstat (limited to 'meme')
-rw-r--r--meme/Makefile7
-rw-r--r--meme/README5
-rw-r--r--meme/gui.c8
-rw-r--r--meme/meme.c12
-rw-r--r--meme/screen.c23
-rw-r--r--meme/screen.h10
6 files changed, 40 insertions, 25 deletions
diff --git a/meme/Makefile b/meme/Makefile
index 617ed21..5022e38 100644
--- a/meme/Makefile
+++ b/meme/Makefile
@@ -1,8 +1,8 @@
#
# Makefile - Build Measmesh
#
-# Written 2014-2015 by Werner Almesberger
-# Copyright 2014-2015 by Werner Almesberger
+# Written 2014-2016 by Werner Almesberger
+# Copyright 2014-2016 by 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
@@ -13,7 +13,8 @@
include Makefile.c-common
CFLAGS = -Wall -Wshadow -g -O9
-OBJS = meme.o stl.o mesh.o gui.o time.o plane.o text.o gaux.o overlay.o slice.o
+OBJS = meme.o stl.o mesh.o gui.o time.o plane.o text.o gaux.o overlay.o \
+ slice.o screen.o
CFLAGS += $(shell sdl-config --cflags)
LDLIBS = $(shell sdl-config --libs) -lSDL_gfx -lSDL_Pango -lgsl -lgslcblas -lm
diff --git a/meme/README b/meme/README
index d1b8b4d..a157389 100644
--- a/meme/README
+++ b/meme/README
@@ -4,7 +4,7 @@ Mesh measurement utility
Usage:
-meme [-l logfile] [-o overlay.gp ...] <path-to-STL-file>
+meme [-d dump.bmp] [-l logfile] [-o overlay.gp ...] <path-to-STL-file>
meme -s slice.gp [-n] <path-to-STL-file>
@@ -26,6 +26,9 @@ Keyboard
--------
- C: enter contrast enhancement mode, see below
+- D: write a screen dump to either file specified with "-d dump.bmp" or to
+ meme-NNNN.bmp, where NNNN is the first unique number for which no file
+ exists yet.
- E: highlight equal height, see below
- G: toggle grid (edges) display
- M: toggle mesh display
diff --git a/meme/gui.c b/meme/gui.c
index 45ed8ad..4133db6 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -1,8 +1,8 @@
/*
* gui.c - User interface
*
- * Written 2014-2015 by Werner Almesberger
- * Copyright 2014-2015 by Werner Almesberger
+ * Written 2014-2016 by Werner Almesberger
+ * Copyright 2014-2016 by 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
@@ -25,6 +25,7 @@
#include "overlay.h"
#include "plane.h"
#include "gaux.h"
+#include "screen.h"
#include "text.h"
#include "gui.h"
@@ -1243,6 +1244,9 @@ static bool event_loop(SDL_Surface **surf, const char *logfile,
case SDLK_c:
begin_contrast();
return 0;
+ case SDLK_d:
+ dump_screen(*surf);
+ break;
case SDLK_e:
begin_equal();
return 0;
diff --git a/meme/meme.c b/meme/meme.c
index 57e906a..3bb7b80 100644
--- a/meme/meme.c
+++ b/meme/meme.c
@@ -1,8 +1,8 @@
/*
* meme.c - Measmesh command-line processing and setup
*
- * Written 2014-2015 by Werner Almesberger
- * Copyright 2014-2015 by Werner Almesberger
+ * Written 2014-2016 by Werner Almesberger
+ * Copyright 2014-2016 by 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
@@ -20,6 +20,7 @@
#include "time.h"
#include "mesh.h"
#include "stl.h"
+#include "screen.h"
#include "overlay.h"
#include "slice.h"
#include "gui.h"
@@ -63,7 +64,7 @@ static void overlay_xform(float x, float y, float *res_x, float *res_y)
static void usage(const char *name)
{
fprintf(stderr,
-"usage: %s [-l logfile] [-o overlay.gp ...] [file.stl]\n"
+"usage: %s [-d dump.bmp] [-l logfile] [-o overlay.gp ...] [file.stl]\n"
" %s -s plane.gp [-n] [file.stl]\n",
name, name);
exit(1);
@@ -80,8 +81,11 @@ int main(int argc, char **argv)
unsigned n_overlays = 0;
struct time t_load;
- while ((c = getopt(argc, argv, "l:no:s:")) != EOF)
+ while ((c = getopt(argc, argv, "d:l:no:s:")) != EOF)
switch (c) {
+ case 'd':
+ screen_dump_name = optarg;
+ break;
case 'l':
logfile = optarg;
break;
diff --git a/meme/screen.c b/meme/screen.c
index c1b0f99..b9b570f 100644
--- a/meme/screen.c
+++ b/meme/screen.c
@@ -1,8 +1,8 @@
/*
* screen.c - Screen dump
*
- * Written 2015 by Werner Almesberger
- * Copyright 2015 Werner Almesberger
+ * Written 2015-2016 by Werner Almesberger
+ * Copyright 2015-2016 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
@@ -15,19 +15,20 @@
#include <stdio.h>
#include <unistd.h>
-#include "sim.h"
+#include "SDL.h"
+
#include "screen.h"
-#define BASE_NAME "anelok-sim-"
+#define BASE_NAME "meme-"
const char *screen_dump_name = NULL;
-void dump_screen_file(const char *name)
+void dump_screen_file(SDL_Surface *s, const char *name)
{
- if (SDL_SaveBMP(surf, name)) {
+ if (SDL_SaveBMP(s, name)) {
fprintf(stderr, "SDL_SaveBMP: %s\n", SDL_GetError());
exit(1);
}
@@ -35,7 +36,7 @@ void dump_screen_file(const char *name)
}
-static void dump_screen_unique(void)
+static void dump_screen_unique(SDL_Surface *s)
{
char tmp[sizeof(BASE_NAME) + 4 + 4];
int n;
@@ -43,7 +44,7 @@ static void dump_screen_unique(void)
for (n = 0; n <= 9999; n++) {
snprintf(tmp, sizeof(tmp), BASE_NAME "%04d.bmp", n);
if (access(tmp, R_OK)) {
- dump_screen_file(tmp);
+ dump_screen_file(s, tmp);
return;
}
}
@@ -52,10 +53,10 @@ static void dump_screen_unique(void)
}
-void dump_screen(void)
+void dump_screen(SDL_Surface *s)
{
if (screen_dump_name)
- dump_screen_file(screen_dump_name);
+ dump_screen_file(s, screen_dump_name);
else
- dump_screen_unique();
+ dump_screen_unique(s);
}
diff --git a/meme/screen.h b/meme/screen.h
index 9bfe845..f9c0c9a 100644
--- a/meme/screen.h
+++ b/meme/screen.h
@@ -1,8 +1,8 @@
/*
* screen.h - Screen dump
*
- * Written 2015 by Werner Almesberger
- * Copyright 2015 Werner Almesberger
+ * Written 2015-2016 by Werner Almesberger
+ * Copyright 2015-2016 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
@@ -14,11 +14,13 @@
#ifndef SCREEN_H
#define SCREEN_H
+#include "SDL.h"
+
extern const char *screen_dump_name;
-void dump_screen_file(const char *name);
-void dump_screen(void);
+void dump_screen_file(SDL_Surface *s, const char *name);
+void dump_screen(SDL_Surface *s);
#endif /* !SCREEN_H */