|
|
|
|
@ -1377,102 +1377,6 @@ marker_position(int m, int t, int *x, int *y)
|
|
|
|
|
*y = CELL_Y(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int greater(int x, int y, int d) { return x - d > y; }
|
|
|
|
|
static int lesser(int x, int y, int d) { return x - d < y; }
|
|
|
|
|
|
|
|
|
|
static int (*compare)(int x, int y, int d) = greater;
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
marker_search(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
if (uistat.current_trace == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
int value = CELL_Y(trace_index[TRACE_ACTUAL][0]);
|
|
|
|
|
for (i = 0; i < sweep_points; i++) {
|
|
|
|
|
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
|
|
|
|
|
if ((*compare)(value, new_value, 0)) {
|
|
|
|
|
value = new_value;
|
|
|
|
|
found = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
set_marker_search(int mode)
|
|
|
|
|
{
|
|
|
|
|
compare = (mode == 0) ? greater : lesser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
search_is_greater(void)
|
|
|
|
|
{
|
|
|
|
|
return(compare == greater);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define MINMAX_DELTA 10
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
marker_search_left(int from)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int found = -1;
|
|
|
|
|
if (uistat.current_trace == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
|
|
|
|
|
for (i = from - 1; i >= 0; i--) {
|
|
|
|
|
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
|
|
|
|
|
if ((*compare)(value, new_value, MINMAX_DELTA))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (; i >= 0; i--) {
|
|
|
|
|
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
|
|
|
|
|
if ((*compare)(new_value, value, -MINMAX_DELTA)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if ((*compare)(value, new_value, 0)) {
|
|
|
|
|
found = i;
|
|
|
|
|
value = new_value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
marker_search_right(int from)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int found = -1;
|
|
|
|
|
|
|
|
|
|
if (uistat.current_trace == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
int value = CELL_Y(trace_index[TRACE_ACTUAL][from]);
|
|
|
|
|
for (i = from + 1; i < sweep_points; i++) {
|
|
|
|
|
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
|
|
|
|
|
if ((*compare)(value, new_value, MINMAX_DELTA))
|
|
|
|
|
break;
|
|
|
|
|
value = new_value;
|
|
|
|
|
}
|
|
|
|
|
for (; i < sweep_points; i++) {
|
|
|
|
|
int new_value = CELL_Y(trace_index[TRACE_ACTUAL][i]);
|
|
|
|
|
if ((*compare)(new_value, value, -MINMAX_DELTA)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if ((*compare)(value, new_value, 0)) {
|
|
|
|
|
found = i;
|
|
|
|
|
value = new_value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
search_nearest_index(int x, int y, int t)
|
|
|
|
|
{
|
|
|
|
|
|