summaryrefslogtreecommitdiff
path: root/meme
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2015-03-14 15:13:32 (GMT)
committerWerner Almesberger <werner@almesberger.net>2015-03-14 15:13:32 (GMT)
commit1b6ddad3bc38ee43bbed59d695acf538b7284feb (patch)
tree22aa08bad0f2ed6804e29a3a232cd0b47160ea2a /meme
parent1f9086e6b4da68a49d00ab4a25624119b8a36d56 (diff)
downloadmisc-1b6ddad3bc38ee43bbed59d695acf538b7284feb.zip
misc-1b6ddad3bc38ee43bbed59d695acf538b7284feb.tar.gz
misc-1b6ddad3bc38ee43bbed59d695acf538b7284feb.tar.bz2
meme/: support multiple overlays
Diffstat (limited to 'meme')
-rw-r--r--meme/README10
-rw-r--r--meme/gui.c28
-rw-r--r--meme/gui.h3
-rw-r--r--meme/meme.c21
4 files changed, 46 insertions, 16 deletions
diff --git a/meme/README b/meme/README
index 453a550..e5380bf 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 [-l logfile] [-o overlay.gp ...] <path-to-STL-file>
meme -s slice.gp <path-to-STL-file>
@@ -32,6 +32,7 @@ Keyboard
- O: toggle overlay; see below
- P: toggle profiles display, see below
- Q: quit
+- 1, 2, 3: select the respective overlay (if present)
- *: center and zoom to extents
- +: zooom in
- -: zoom out
@@ -84,7 +85,12 @@ Overlay
A set of lines in gnuplot format can be drawn over the scan data. The
file containing the lines (in model coordinates) is specified with the
--o option. The O key toggle overlay display.
+-o option. The O key toggles overlay display.
+
+The -o option can be used multiple times. The overlay to display is
+selected with the numeric keys, starting with 1.
+
+To better visualize overlays, the mesh can be toggled by pressing M.
Slicing
diff --git a/meme/gui.c b/meme/gui.c
index 0cd6836..847fb4b 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -62,6 +62,7 @@ static bool show_profiles = 0;
static bool show_overlay = 0;
static bool show_mesh = 1;
static const struct vertex *cursor;
+static const struct overlay *overlay;
/* ----- Coordinate transform ---------------------------------------------- */
@@ -923,9 +924,9 @@ static void lineto(void *user, int x, int y)
}
-static void draw_overlay(SDL_Surface *s, const struct overlay *overlay)
+static void draw_overlay(SDL_Surface *s, const struct overlay *over)
{
- overlay_draw(overlay, moveto, lineto, s);
+ overlay_draw(over, moveto, lineto, s);
}
@@ -1196,7 +1197,8 @@ static void delayed_motion(void *user)
}
-static bool event_loop(SDL_Surface **surf, const char *logfile)
+static bool event_loop(SDL_Surface **surf, const char *logfile,
+ const struct overlay *const *overlays, unsigned n_overlays)
{
SDL_Surface *s = *surf;
SDL_Event event;
@@ -1249,6 +1251,18 @@ static bool event_loop(SDL_Surface **surf, const char *logfile)
return 0;
case SDLK_q:
return 1;
+ case SDLK_1:
+ if (n_overlays)
+ overlay = overlays[0];
+ return 0;
+ case SDLK_2:
+ if (n_overlays > 1)
+ overlay = overlays[1];
+ return 0;
+ case SDLK_3:
+ if (n_overlays > 2)
+ overlay = overlays[2];
+ return 0;
default:
break;
}
@@ -1286,7 +1300,8 @@ static bool event_loop(SDL_Surface **surf, const char *logfile)
}
-void gui(const char *logfile, const struct overlay *overlay)
+void gui(const char *logfile,
+ const struct overlay *const *overlays, unsigned n_overlays)
{
SDL_Surface *surf;
@@ -1312,6 +1327,9 @@ void gui(const char *logfile, const struct overlay *overlay)
init_z_grad();
auto_scale();
+ if (n_overlays)
+ overlay = overlays[0];
+
while (1) {
struct time t;
discard_changes();
@@ -1336,7 +1354,7 @@ fprintf(stderr, "%.3f s @ zoom %d\n", time_ms(&t)/1000.0, zoom);
}
apply_changes(surf);
- if (event_loop(&surf, logfile))
+ if (event_loop(&surf, logfile, overlays, n_overlays))
break;
}
}
diff --git a/meme/gui.h b/meme/gui.h
index 3ddd31c..49b9e9c 100644
--- a/meme/gui.h
+++ b/meme/gui.h
@@ -16,6 +16,7 @@
#include "overlay.h"
-void gui(const char *logfile, const struct overlay *overlay);
+void gui(const char *logfile,
+ const struct overlay *const *overlays, unsigned n_overlays);
#endif /* !GUI_H */
diff --git a/meme/meme.c b/meme/meme.c
index 5f41079..aab8736 100644
--- a/meme/meme.c
+++ b/meme/meme.c
@@ -23,6 +23,9 @@
#include "gui.h"
+#define N_OVERLAYS 3
+
+
static bool count_edge(const struct vertex *a, const struct vertex *b,
void *user)
{
@@ -51,7 +54,7 @@ static void slice_out(double x, double y, double z, bool last)
static void usage(const char *name)
{
fprintf(stderr,
-"usage: %s [-l logfile] [-o overlap.gp] [file.stl]\n"
+"usage: %s [-l logfile] [-o overlay.gp ...] [file.stl]\n"
" %s -s plane.gp [file.stl]\n",
name, name);
exit(1);
@@ -62,9 +65,9 @@ int main(int argc, char **argv)
{
int c;
const char *logfile = NULL;
- const char *overlay = NULL;
const char *slice = NULL;
- const struct overlay *over = NULL;
+ const struct overlay *overlays[N_OVERLAYS];
+ unsigned n_overlays = 0;
struct time t_load;
while ((c = getopt(argc, argv, "l:o:s:")) != EOF)
@@ -73,7 +76,12 @@ int main(int argc, char **argv)
logfile = optarg;
break;
case 'o':
- overlay = optarg;
+ if (n_overlays == N_OVERLAYS) {
+ fprintf(stderr, "too many overlays\n");
+ exit(1);
+ }
+ overlays[n_overlays] = overlay_load(optarg);
+ n_overlays++;
break;
case 's':
slice = optarg;
@@ -106,10 +114,7 @@ int main(int argc, char **argv)
exit(1);
}
- if (overlay)
- over = overlay_load(overlay);
-
- gui(logfile, over);
+ gui(logfile, overlays, n_overlays);
return 0;
}