MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / paint_mid

Method paint_mid

DSView/pv/view/lissajoustrace.cpp:100–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void LissajousTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColor back)
101{
102 (void)fore;
103 (void)back;
104 (void)left;
105 (void)right;
106
107 assert(_data);
108 assert(_view);
109 assert(right >= left);
110
111 if (enabled()) {
112
113 if (_data->empty())
114 return;
115
116 int channel_num = _data->get_channel_num();
117 if (channel_num < 2){
118 p.setPen(view::View::Red);
119 p.drawText(_border.marginsRemoved(QMargins(10, 30, 10, 30)),
120 L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CHAN_NUM_ERR2), "Requires the data of two channels."));
121 return;
122 }
123
124 int left = _border.left();
125 int bottom = _border.bottom();
126 double scale = _border.width() / 255.0;
127 uint64_t sample_count = _data->get_sample_count() * min(_percent / 100.0, 1.0);
128 QPointF *points = new QPointF[sample_count];
129 QPointF *point = points;
130
131 if (_xIndex >= channel_num || _yIndex >= channel_num) {
132 p.setPen(view::View::Red);
133 p.drawText(_border.marginsRemoved(QMargins(10, 30, 10, 30)),
134 L_S(STR_PAGE_DLG, S_ID(IDS_DLG_DATA_SOURCE_ERROR), "Data source error."));
135 }
136 else {
137 const uint8_t* chan_data_array[2];
138 chan_data_array[_xIndex] = _data->get_samples(0, sample_count-1, _xIndex);
139 chan_data_array[_yIndex] = _data->get_samples(0, sample_count-1, _yIndex);
140
141 for (uint64_t i = 0; i < sample_count; i++) {
142 const uint8_t* dx = chan_data_array[_xIndex];
143 const uint8_t* dy = chan_data_array[_yIndex];
144
145 *point++ = QPointF(left + dx[i] * scale,
146 bottom - dy[i] * scale);
147 }
148
149 p.setPen(view::View::Blue);
150 p.drawPolyline(points, point - points);
151 delete[] points;
152 }
153 }
154}
155
156void LissajousTrace::paint_fore(QPainter &p, int left, int right, QColor fore, QColor back)
157{

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.80
get_channel_numMethod · 0.80
get_sample_countMethod · 0.80
get_samplesMethod · 0.45

Tested by

no test coverage detected