m_mouseMode = GraphView::MouseMode::CROSSHAIR;
break;
case GraphView::MouseMode::INTEGRATE:
- if (m_integrateStartXPix > m_integrateStopXPix)
- std::swap(m_integrateStartXPix, m_integrateStopXPix);
-
PeakDrawData pdData = m_controller->integratePeak(xPixToRel(m_integrateStartXPix), yPixToRel(m_integrateStartYPix),
xPixToRel(m_integrateStopXPix), yPixToRel(m_integrateStopYPix));
eraseIntegrationBaseline(true);
return ReturnCode::E_INVAL;
}
+ if (startIdx > stopIdx) {
+ std::swap(startIdx, stopIdx);
+ std::swap(startY, stopY);
+ }
+
qDebug() << "INTEG" << startIdx << stopIdx << startY << stopY;
- slope = (stopY - startY) / (stopIdx - startIdx);
+ slope = (stopY - startY) / static_cast<double>(stopIdx - startIdx);
/* Try to find first intersection */
if (startY < m_signal->valueAt(startIdx)) {
expectDownward = true;
- qDebug() << "Expecting downward peak";
+ //qDebug() << "Expecting downward peak";
} else {
expectDownward = false;
- qDebug() << "Expecting upward peak";
+ //qDebug() << "Expecting upward peak";
}
for (i = startIdx; i <= stopIdx; i++) {
double value = m_signal->valueAt(i);
- double blY = slope * (i - startIdx) + startY;
+ double blY = slope * static_cast<double>(i - startIdx) + startY;
if (expectDownward && blY > value) { /* Found first intersection */
- startIntersIdx = i-1;
+ startIntersIdx = i;
startYVal = blY;
break;
} else if (!expectDownward && blY < value) { /* Found first intersection */
- startIntersIdx = i-1;
+ startIntersIdx = i;
startYVal = blY;
break;
}
/* Try to find second intersection */
for (; i <= stopIdx; i++) {
double value = m_signal->valueAt(i);
- double blY = slope * (i - startIdx) + startY;
+ double blY = slope * static_cast<double>(i - startIdx) + startY;
- if (expectDownward && blY <= value) {
+ if (expectDownward && blY < value) {
stopIntersIdx = i;
stopYVal = blY;
break;
- } else if (!expectDownward && blY >= value) {
+ } else if (!expectDownward && blY > value) {
stopIntersIdx = i;
stopYVal = blY;
break;
/* Integrate */
peakValueIdx = startIntersIdx;
for (i = startIntersIdx+1; i < stopIntersIdx; i++) {
- double blXA = slope * (i - startIntersIdx - 1) + startY;
+ double blXA = slope * (i - startIntersIdx) + startY;
double blXB = slope * (i - startIntersIdx) + startY;
double valA = m_signal->valueAt(i-1);
double valB = m_signal->valueAt(i);
m_gWidth = width - SCALE_MARGIN_VALUE;
m_gHeight = height - SCALE_MARGIN_TIME;
- qDebug() << __QFUNC__ << width << height << m_width << m_height;
+ //qDebug() << __QFUNC__ << width << height << m_width << m_height;
return draw(m_relXMin, m_relYMin, m_relXMax, m_relYMax);
}
xStep = static_cast<double>(m_gWidth) / m_gdData->ddataLen;
yStep = static_cast<double>(m_gHeight) / (m_relYMax - m_relYMin);
- Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + " yStep: " + QString::number(yStep)
- + " fY " + QString::number(m_relYMin) + " tY " + QString::number(m_relYMax));
+ /*Logger::log(Logger::Level::DEBUG, ME_SENDER_STR, __QFUNC__ + " yStep: " + QString::number(yStep)
+ + " fY " + QString::number(m_relYMin) + " tY " + QString::number(m_relYMax));*/
fromYPix = m_gHeight - yStep * (m_gdData->ddata[0] - m_relYMin);
for (size_t i = 1; i < m_gdData->ddataLen; i++) {
int toXPix = xStep * i + SCALE_MARGIN_VALUE;