3 void Sampled_drawInside_cairo (I
, cairo_t
*cr
, double xmin
, double xmax
, double ymin
, double ymax
, long ilevel
, int unit
)
6 long ixmin
, ixmax
, ix
, startOfDefinedStretch
= -1;
7 float *xarray
= NULL
, *yarray
= NULL
;
8 double previousValue
= NUMundefined
;
9 Function_unidirectionalAutowindow (me
, & xmin
, & xmax
);
10 Sampled_getWindowSamples (me
, xmin
, xmax
, & ixmin
, & ixmax
);
11 if (ClassFunction_isUnitLogarithmic (my methods
, ilevel
, unit
)) {
12 ymin
= ClassFunction_convertStandardToSpecialUnit (my methods
, ymin
, ilevel
, unit
);
13 ymax
= ClassFunction_convertStandardToSpecialUnit (my methods
, ymax
, ilevel
, unit
);
15 if (ymax
<= ymin
) return;
17 xarray
= NUMfvector (ixmin
- 1, ixmax
+ 1); cherror
18 yarray
= NUMfvector (ixmin
- 1, ixmax
+ 1); cherror
19 previousValue
= Sampled_getValueAtSample (me
, ixmin
- 1, ilevel
, unit
);
20 if (NUMdefined (previousValue
)) {
21 startOfDefinedStretch
= ixmin
- 1;
22 xarray
[ixmin
- 1] = Sampled_indexToX (me
, ixmin
- 1);
23 yarray
[ixmin
- 1] = previousValue
;
25 for (ix
= ixmin
; ix
<= ixmax
; ix
++) {
26 double x
= Sampled_indexToX (me
, ix
), value
= Sampled_getValueAtSample (me
, ix
, ilevel
, unit
);
27 if (NUMdefined (value
)) {
28 if (NUMdefined (previousValue
)) {
32 startOfDefinedStretch
= ix
- 1;
33 xarray
[ix
- 1] = x
- 0.5 * my dx
;
34 yarray
[ix
- 1] = value
;
38 } else if (NUMdefined (previousValue
)) {
39 Melder_assert (startOfDefinedStretch
>= ixmin
- 1);
41 xarray
[ix
] = x
- 0.5 * my dx
;
42 yarray
[ix
] = previousValue
;
43 if (xarray
[startOfDefinedStretch
] < xmin
) {
44 double phase
= (xmin
- xarray
[startOfDefinedStretch
]) / my dx
;
45 xarray
[startOfDefinedStretch
] = xmin
;
46 yarray
[startOfDefinedStretch
] = phase
* yarray
[startOfDefinedStretch
+ 1] + (1.0 - phase
) * yarray
[startOfDefinedStretch
];
48 // forlusje eerst moveto zetten dan lineto
50 // Graphics_polyline (g, ix + 1 - startOfDefinedStretch, & xarray [startOfDefinedStretch], & yarray [startOfDefinedStretch]);
53 startOfDefinedStretch
= -1;
55 previousValue
= value
;
57 if (startOfDefinedStretch
> -1) {
58 double x
= Sampled_indexToX (me
, ixmax
+ 1), value
= Sampled_getValueAtSample (me
, ixmax
+ 1, ilevel
, unit
);
59 Melder_assert (NUMdefined (previousValue
));
60 if (NUMdefined (value
)) {
61 xarray
[ixmax
+ 1] = x
;
62 yarray
[ixmax
+ 1] = value
;
64 xarray
[ixmax
+ 1] = x
- 0.5 * my dx
;
65 yarray
[ixmax
+ 1] = previousValue
;
67 if (xarray
[startOfDefinedStretch
] < xmin
) {
68 double phase
= (xmin
- xarray
[startOfDefinedStretch
]) / my dx
;
69 xarray
[startOfDefinedStretch
] = xmin
;
70 yarray
[startOfDefinedStretch
] = phase
* yarray
[startOfDefinedStretch
+ 1] + (1.0 - phase
) * yarray
[startOfDefinedStretch
];
72 if (xarray
[ixmax
+ 1] > xmax
) {
73 double phase
= (xarray
[ixmax
+ 1] - xmax
) / my dx
;
74 xarray
[ixmax
+ 1] = xmax
;
75 yarray
[ixmax
+ 1] = phase
* yarray
[ixmax
] + (1.0 - phase
) * yarray
[ixmax
+ 1];
77 // Graphics_polyline (g, ixmax + 2 - startOfDefinedStretch, & xarray [startOfDefinedStretch], & yarray [startOfDefinedStretch]);
80 NUMfvector_free (xarray
, ixmin
- 1);
81 NUMfvector_free (yarray
, ixmin
- 1);