2009-08-07 16:37:51 +03:00
|
|
|
/*
|
|
|
|
* meas.h - Measurements
|
|
|
|
*
|
|
|
|
* Written 2009 by Werner Almesberger
|
|
|
|
* Copyright 2009 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MEAS_H
|
|
|
|
#define MEAS_H
|
|
|
|
|
2009-08-09 03:06:54 +03:00
|
|
|
|
|
|
|
#include "coord.h"
|
|
|
|
#include "expr.h"
|
2009-08-07 16:37:51 +03:00
|
|
|
|
|
|
|
|
2009-08-08 00:47:51 +03:00
|
|
|
typedef int (*lt_op_type)(struct coord a, struct coord b);
|
|
|
|
|
2009-08-09 03:06:54 +03:00
|
|
|
struct vec;
|
|
|
|
struct obj;
|
2009-08-08 00:47:51 +03:00
|
|
|
|
2009-08-07 16:37:51 +03:00
|
|
|
struct meas {
|
|
|
|
enum meas_type {
|
|
|
|
mt_xy_next,
|
|
|
|
mt_x_next,
|
|
|
|
mt_y_next,
|
|
|
|
mt_xy_max,
|
|
|
|
mt_x_max,
|
|
|
|
mt_y_max,
|
|
|
|
mt_n
|
|
|
|
} type;
|
|
|
|
char *label; /* or NULL */
|
|
|
|
int inverted;
|
2009-08-09 03:06:54 +03:00
|
|
|
/* low is obj->base */
|
2009-08-07 16:37:51 +03:00
|
|
|
struct vec *high;
|
|
|
|
struct expr *offset;
|
|
|
|
};
|
|
|
|
|
2009-08-10 16:51:51 +03:00
|
|
|
struct sample {
|
|
|
|
struct coord pos;
|
|
|
|
struct sample *next;
|
|
|
|
};
|
2009-08-08 00:47:51 +03:00
|
|
|
|
2009-08-07 16:37:51 +03:00
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
extern int n_samples;
|
|
|
|
|
|
|
|
|
2009-08-08 00:47:51 +03:00
|
|
|
int lt_x(struct coord a, struct coord b);
|
|
|
|
int lt_y(struct coord a, struct coord b);
|
|
|
|
int lt_xy(struct coord a, struct coord b);
|
|
|
|
|
|
|
|
struct coord meas_find_min(lt_op_type lt, const struct sample *s);
|
|
|
|
struct coord meas_find_next(lt_op_type lt, const struct sample *s,
|
|
|
|
struct coord ref);
|
|
|
|
struct coord meas_find_max(lt_op_type lt, const struct sample *s);
|
|
|
|
|
2009-08-17 23:42:51 +03:00
|
|
|
|
2009-08-18 23:52:09 +03:00
|
|
|
void reset_samples(struct sample **samples, int n);
|
2009-08-07 16:37:51 +03:00
|
|
|
void meas_start(void);
|
2009-08-17 23:42:51 +03:00
|
|
|
void meas_post(const struct vec *vec, struct coord pos);
|
2009-08-07 16:37:51 +03:00
|
|
|
int instantiate_meas(void);
|
|
|
|
|
|
|
|
#endif /* !MEAS_H */
|