| 156 | } |
| 157 | |
| 158 | void XCursor::paint(QPainter &p, const QRect &rect, XCur_type highlight) |
| 159 | { |
| 160 | // Attach the channel |
| 161 | if (_dsoSig == NULL && _sig_index != -1){ |
| 162 | auto sig = _view.session().get_signal_by_index(_sig_index); |
| 163 | if (sig != NULL){ |
| 164 | _dsoSig = dynamic_cast<DsoSignal*>(sig); |
| 165 | |
| 166 | if (_dsoSig != NULL){ |
| 167 | connect(_dsoSig, SIGNAL(sig_released(void*)), this, SLOT(on_signal_deleted(void*))); |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | const int arrow = 3; |
| 173 | const int x = rect.left() + _yvalue * rect.width(); |
| 174 | const int y0 = rect.top() + _value0 * rect.height(); |
| 175 | const int y1 = rect.top() + _value1 * rect.height(); |
| 176 | QColor color = get_color(); |
| 177 | const bool hit0 = (_grabbed == XCur_X0) | (_grabbed == XCur_None && (highlight == XCur_X0 || highlight == XCur_All)); |
| 178 | p.setPen(hit0 ? QPen(color.lighter(), 2, Qt::DashLine) : QPen(color, 1, Qt::DashLine)); |
| 179 | p.drawLine(QPoint(0, y0), QPoint(rect.right()-_v0_size.width(), y0)); |
| 180 | const bool hit1 = (_grabbed == XCur_X1) | (_grabbed == XCur_None && (highlight == XCur_X1 || highlight == XCur_All)); |
| 181 | p.setPen(hit1 ? QPen(color.lighter(), 2, Qt::DashLine) : QPen(color, 1, Qt::DashLine)); |
| 182 | p.drawLine(QPoint(0, y1), QPoint(rect.right()-_v1_size.width(), y1)); |
| 183 | |
| 184 | if (_dsoSig) { |
| 185 | if ((_grabbed == XCur_Y) | (_grabbed == XCur_None && (highlight == XCur_Y || highlight == XCur_All))) |
| 186 | p.setPen(QPen(_dsoSig->get_colour(), 2, Qt::DashLine)); |
| 187 | else |
| 188 | p.setPen(QPen(_dsoSig->get_colour(), 1, Qt::DashLine)); |
| 189 | p.drawLine(QPoint(x, y0), QPoint(x, y1)); |
| 190 | p.drawLine(QPoint(x-arrow, y0 + ((y0 > y1) ? -arrow : arrow)), QPoint(x, y0)); |
| 191 | p.drawLine(QPoint(x+arrow, y0 + ((y0 > y1) ? -arrow : arrow)), QPoint(x, y0)); |
| 192 | p.drawLine(QPoint(x-arrow, y1 + ((y0 > y1) ? arrow : -arrow)), QPoint(x, y1)); |
| 193 | p.drawLine(QPoint(x+arrow, y1 + ((y0 > y1) ? arrow : -arrow)), QPoint(x, y1)); |
| 194 | |
| 195 | QString vol = " Δ:" + _dsoSig->get_voltage(qAbs(y0 - y1), 2, true); |
| 196 | const QSizeF delta_size = p.boundingRect(rect, Qt::AlignLeft | Qt::AlignTop, vol).size(); |
| 197 | const QRectF delta_rect = QRectF(x, (y0+y1-delta_size.height())/2, delta_size.width(), delta_size.height()); |
| 198 | p.drawText(delta_rect, Qt::AlignCenter, vol); |
| 199 | |
| 200 | vol = _dsoSig->get_voltage((_dsoSig->get_zero_ratio() - _value0)*rect.height(), 2, true); |
| 201 | _v0_size = p.boundingRect(rect, Qt::AlignLeft | Qt::AlignTop, vol).size(); |
| 202 | p.drawText(QRectF(rect.right()-_v0_size.width(), y0-_v0_size.height()/2, _v0_size.width(), _v0_size.height()), |
| 203 | Qt::AlignLeft | Qt::AlignVCenter, |
| 204 | vol); |
| 205 | |
| 206 | vol = _dsoSig->get_voltage((_dsoSig->get_zero_ratio() - _value1)*rect.height(), 2, true); |
| 207 | _v1_size = p.boundingRect(rect, Qt::AlignLeft | Qt::AlignTop, vol).size(); |
| 208 | p.drawText(QRectF(rect.right()-_v1_size.width(), y1-_v1_size.height()/2, _v1_size.width(), _v1_size.height()), |
| 209 | Qt::AlignLeft | Qt::AlignVCenter, |
| 210 | vol); |
| 211 | } |
| 212 | |
| 213 | paint_label(p, rect); |
| 214 | } |
| 215 |
no test coverage detected