| 43 | // Requires in_ to be in either [order, n] or [n, order] format |
| 44 | template<typename T, int order> |
| 45 | fg_chart setup_plot(fg_window window, const af_array in_, |
| 46 | const af_cell* const props, fg_plot_type ptype, |
| 47 | fg_marker_type mtype) { |
| 48 | ForgeModule& _ = forgePlugin(); |
| 49 | |
| 50 | Array<T> in = getArray<T>(in_); |
| 51 | |
| 52 | af::dim4 dims = in.dims(); |
| 53 | |
| 54 | DIM_ASSERT(1, dims.ndims() == 2); |
| 55 | DIM_ASSERT(1, (dims[0] == order || dims[1] == order)); |
| 56 | |
| 57 | // The data expected by backend is 2D [order, n] |
| 58 | if (dims[1] == order) { in = transpose(in, false); } |
| 59 | |
| 60 | af::dim4 tdims = in.dims(); // transposed dimensions |
| 61 | |
| 62 | ForgeManager& fgMngr = forgeManager(); |
| 63 | |
| 64 | // Get the chart for the current grid position (if any) |
| 65 | fg_chart chart = NULL; |
| 66 | fg_chart_type ctype = order == 2 ? FG_CHART_2D : FG_CHART_3D; |
| 67 | |
| 68 | if (props->col > -1 && props->row > -1) { |
| 69 | chart = fgMngr.getChart(window, props->row, props->col, ctype); |
| 70 | } else { |
| 71 | chart = fgMngr.getChart(window, 0, 0, ctype); |
| 72 | } |
| 73 | |
| 74 | fg_plot plot = |
| 75 | fgMngr.getPlot(chart, tdims[1], getGLType<T>(), ptype, mtype); |
| 76 | |
| 77 | // ArrayFire LOGO Orange shade |
| 78 | FG_CHECK(_.fg_set_plot_color(plot, 0.929f, 0.529f, 0.212f, 1.0)); |
| 79 | |
| 80 | // If chart axes limits do not have a manual override |
| 81 | // then compute and set axes limits |
| 82 | if (!fgMngr.getChartAxesOverride(chart)) { |
| 83 | float cmin[3], cmax[3]; |
| 84 | T dmin[3], dmax[3]; |
| 85 | FG_CHECK(_.fg_get_chart_axes_limits( |
| 86 | &cmin[0], &cmax[0], &cmin[1], &cmax[1], &cmin[2], &cmax[2], chart)); |
| 87 | copyData(dmin, reduce<af_min_t, T, T>(in, 1)); |
| 88 | copyData(dmax, reduce<af_max_t, T, T>(in, 1)); |
| 89 | |
| 90 | if (cmin[0] == 0 && cmax[0] == 0 && cmin[1] == 0 && cmax[1] == 0 && |
| 91 | cmin[2] == 0 && cmax[2] == 0) { |
| 92 | // No previous limits. Set without checking |
| 93 | cmin[0] = step_round(dmin[0], false); |
| 94 | cmax[0] = step_round(dmax[0], true); |
| 95 | cmin[1] = step_round(dmin[1], false); |
| 96 | cmax[1] = step_round(dmax[1], true); |
| 97 | if (order == 3) { cmin[2] = step_round(dmin[2], false); } |
| 98 | if (order == 3) { cmax[2] = step_round(dmax[2], true); } |
| 99 | } else { |
| 100 | if (cmin[0] > dmin[0]) { cmin[0] = step_round(dmin[0], false); } |
| 101 | if (cmax[0] < dmax[0]) { cmax[0] = step_round(dmax[0], true); } |
| 102 | if (cmin[1] > dmin[1]) { cmin[1] = step_round(dmin[1], false); } |
nothing calls this directly
no test coverage detected