void ViewProfileDivider::setX (double x, double xLow, double xHigh) { // Convert to screen coordinates m_xScene = m_sceneWidth * (x - xLow) / (xHigh - xLow); sendSignalMoved (); updateGeometryPaddle (); updateGeometryDivider (); updateGeometryNonPaddle (); // Triangle vertices double xLeft = rect().left() + rect().width() / 2.0 - ARROW_WIDTH / 2.0; double xRight = rect().left() + rect().width() / 2.0 + ARROW_WIDTH / 2.0; double yTop = rect().top() + rect().height() / 2.0 - ARROW_HEIGHT / 2.0; double yMiddle = rect().top() + rect().height() / 2.0; double yBottom = rect().top() + rect().height() / 2.0 + ARROW_HEIGHT / 2.0; QPolygonF polygonArrow; if (m_isLowerBoundary) { // Draw arrow pointing to the right polygonArrow.push_front (QPointF (xLeft, yTop)); polygonArrow.push_front (QPointF (xRight, yMiddle)); polygonArrow.push_front (QPointF (xLeft, yBottom)); } else { // Draw arrow pointing to the left polygonArrow.push_front (QPointF (xRight, yTop)); polygonArrow.push_front (QPointF (xLeft, yMiddle)); polygonArrow.push_front (QPointF (xRight, yBottom)); } m_arrow->setPolygon (polygonArrow); m_arrow->setPen (QPen (Qt::black)); m_arrow->setBrush (QBrush (ARROW_COLOR)); }
bool DataConverter::digitalPattern_Rotate(QPolygonF &points, qreal angle) { if (angle == 0.0) return true; if (angle < -180.0 || angle > 180.0) { qDebug("[DataConverter::digitalPattern_Rotate] Error: Angle: [%f]", angle); return false; } if (points.size() < 10) { qDebug("[DataConverter::digitalPattern_Rotate] Error: Polygon Point Count: [%d]", points.size()); return false; } // QTransform transform; transform.rotate(angle); points = transform.map(points); // int bottomIndex = 0; { qreal tmpX = -9999.99; for (int i = 0; i < points.size(); i++) { if (points.at(i).y() < 0.0) continue; if (points.at(i).x() > 0.0) continue; if (points.at(i).x() > tmpX) { tmpX = points.at(i).x(); bottomIndex = i; } } } qDebug("** bottomIndex: [%d]", bottomIndex); if (bottomIndex > 0) { QPointF tmpPoint; for (int i = points.size() - 1; i >= bottomIndex; i--) { tmpPoint = points.last(); points.pop_back(); points.push_front(tmpPoint); } } return true; }