Changeset View
Changeset View
Standalone View
Standalone View
kstars/fitsviewer/fitsview.cpp
Show First 20 Lines • Show All 874 Lines • ▼ Show 20 Line(s) | 863 | { | |||
---|---|---|---|---|---|
875 | update(); | 875 | update(); | ||
876 | } | 876 | } | ||
877 | } | 877 | } | ||
878 | 878 | | |||
879 | void FITSView::drawOverlay(QPainter * painter) | 879 | void FITSView::drawOverlay(QPainter * painter) | ||
880 | { | 880 | { | ||
881 | painter->setRenderHint(QPainter::Antialiasing, Options::useAntialias()); | 881 | painter->setRenderHint(QPainter::Antialiasing, Options::useAntialias()); | ||
882 | 882 | | |||
883 | if (markStars) | | |||
884 | drawStarCentroid(painter); | | |||
885 | | ||||
886 | if (trackingBoxEnabled && getCursorMode() != FITSView::scopeCursor) | 883 | if (trackingBoxEnabled && getCursorMode() != FITSView::scopeCursor) | ||
887 | drawTrackingBox(painter); | 884 | drawTrackingBox(painter); | ||
888 | 885 | | |||
889 | if (!markerCrosshair.isNull()) | 886 | if (!markerCrosshair.isNull()) | ||
890 | drawMarker(painter); | 887 | drawMarker(painter); | ||
891 | 888 | | |||
892 | if (showCrosshair) | 889 | if (showCrosshair) | ||
893 | drawCrosshair(painter); | 890 | drawCrosshair(painter); | ||
894 | 891 | | |||
895 | if (showObjects) | 892 | if (showObjects) | ||
896 | drawObjectNames(painter); | 893 | drawObjectNames(painter); | ||
897 | 894 | | |||
898 | if (showEQGrid) | 895 | if (showEQGrid) | ||
899 | drawEQGrid(painter); | 896 | drawEQGrid(painter); | ||
900 | 897 | | |||
901 | if (showPixelGrid) | 898 | if (showPixelGrid) | ||
902 | drawPixelGrid(painter); | 899 | drawPixelGrid(painter); | ||
900 | | ||||
901 | if (markStars) | ||||
902 | drawStarCentroid(painter); | ||||
903 | } | 903 | } | ||
904 | 904 | | |||
905 | void FITSView::updateMode(FITSMode fmode) | 905 | void FITSView::updateMode(FITSMode fmode) | ||
906 | { | 906 | { | ||
907 | mode = fmode; | 907 | mode = fmode; | ||
908 | } | 908 | } | ||
909 | 909 | | |||
910 | void FITSView::drawMarker(QPainter * painter) | 910 | void FITSView::drawMarker(QPainter * painter) | ||
Show All 22 Lines | 911 | { | |||
933 | painter->drawLine(QPointF(x0, y0 + 0.5 * s1), QPointF(x0, y0 + s2)); | 933 | painter->drawLine(QPointF(x0, y0 + 0.5 * s1), QPointF(x0, y0 + s2)); | ||
934 | //Draw circles at 0.5 & 1 degrees | 934 | //Draw circles at 0.5 & 1 degrees | ||
935 | painter->drawEllipse(QRectF(x1, y1, s1, s1)); | 935 | painter->drawEllipse(QRectF(x1, y1, s1, s1)); | ||
936 | painter->drawEllipse(QRectF(x2, y2, s2, s2)); | 936 | painter->drawEllipse(QRectF(x2, y2, s2, s2)); | ||
937 | } | 937 | } | ||
938 | 938 | | |||
939 | void FITSView::drawStarCentroid(QPainter * painter) | 939 | void FITSView::drawStarCentroid(QPainter * painter) | ||
940 | { | 940 | { | ||
941 | painter->setPen(QPen(Qt::red, 2)); | 941 | float const ratio = currentZoom / ZOOM_DEFAULT; | ||
942 | | ||||
943 | if (showStarsHFR) | ||||
944 | { | ||||
945 | QFont painterFont; | ||||
942 | 946 | | |||
943 | // image_data->getStarCenter(); | 947 | // If we need to print the HFR out, give an arbitrarily sized font to the painter | ||
948 | painterFont.setPointSizeF(painterFont.pointSizeF() * 3 * ratio); | ||||
949 | painter->setFont(painterFont); | ||||
950 | } | ||||
951 | | ||||
952 | painter->setPen(QPen(Qt::red, 2)); | ||||
944 | 953 | | |||
945 | QList<Edge *> starCenters = imageData->getStarCenters(); | 954 | QFontMetrics const fontMetrics = painter->fontMetrics(); | ||
955 | QRect const boundingRect(0, 0, painter->device()->width(), painter->device()->height()); | ||||
mutlaqja: That seems a bit too large when it is subframed. Also, the number is clipped. Maybe it should… | |||||
Originally, I made the font size independent from the zoom level. But noise when zoomed made the string unreadable. So I chose to make the font zoom dependent, but with the generic 1280x1024 resolution, the font was far too small in the 800x600 focus UI :) therefore I multiplied by this arbitrary 3. But I think what you really mean is that the number is clipped when subframing. Thanks, I'll remove HFR printout when subframing, that's not useful with a single star. Correct understanding? TallFurryMan: Originally, I made the font size independent from the zoom level. But noise when zoomed made… | |||||
946 | 956 | | |||
947 | for (int i = 0; i < starCenters.count(); i++) | 957 | foreach (auto const &starCenter, imageData->getStarCenters()) | ||
mutlaqja: for(const auto ¢er: imageData->getStarCenters()) | |||||
Will fix. I'm not a fan of auto variables though, they have a tendency to leave unverified code behind if items change their type, and new functions change their meaning. TallFurryMan: Will fix. I'm not a fan of auto variables though, they have a tendency to leave unverified code… | |||||
948 | { | 958 | { | ||
949 | int x1 = (starCenters[i]->x - starCenters[i]->width / 2) * (currentZoom / ZOOM_DEFAULT); | 959 | int const x1 = std::round((starCenter->x - starCenter->width / 2.0f) * ratio); | ||
950 | int y1 = (starCenters[i]->y - starCenters[i]->width / 2) * (currentZoom / ZOOM_DEFAULT); | 960 | int const y1 = std::round((starCenter->y - starCenter->width / 2.0f) * ratio); | ||
951 | int w = (starCenters[i]->width) * (currentZoom / ZOOM_DEFAULT); | 961 | int const w = std::round(starCenter->width * ratio); | ||
952 | 962 | | |||
963 | // Draw a circle around the detected star | ||||
953 | painter->drawEllipse(x1, y1, w, w); | 964 | painter->drawEllipse(x1, y1, w, w); | ||
965 | | ||||
966 | if (showStarsHFR) | ||||
967 | { | ||||
968 | // Ask the painter how large will the HFR text be | ||||
969 | QString const hfr = QString("%1").arg(starCenter->HFR, 0, 'f', 2); | ||||
970 | QSize const hfrSize = fontMetrics.size(Qt::TextSingleLine, hfr); | ||||
971 | | ||||
972 | // Store the HFR text in a rect | ||||
973 | QPoint const hfrBottomLeft(x1+w+5, y1+w/2); | ||||
974 | QRect const hfrRect(hfrBottomLeft.x(), hfrBottomLeft.y() - hfrSize.height(), hfrSize.width(), hfrSize.height()); | ||||
975 | | ||||
976 | // Render the HFR text only if it can be displayed entirely | ||||
977 | if (boundingRect.contains(hfrRect)) | ||||
978 | { | ||||
979 | painter->setPen(QPen(Qt::red, 3)); | ||||
980 | painter->drawText(hfrBottomLeft, hfr); | ||||
981 | painter->setPen(QPen(Qt::red, 2)); | ||||
982 | } | ||||
983 | } | ||||
954 | } | 984 | } | ||
955 | } | 985 | } | ||
956 | 986 | | |||
957 | void FITSView::drawTrackingBox(QPainter * painter) | 987 | void FITSView::drawTrackingBox(QPainter * painter) | ||
958 | { | 988 | { | ||
959 | painter->setPen(QPen(Qt::green, 2)); | 989 | painter->setPen(QPen(Qt::green, 2)); | ||
960 | 990 | | |||
961 | if (trackingBox.isNull()) | 991 | if (trackingBox.isNull()) | ||
▲ Show 20 Lines • Show All 961 Lines • ▼ Show 20 Line(s) | 1952 | { | |||
1923 | if (action->text() == i18n("Detect Stars in Image")) | 1953 | if (action->text() == i18n("Detect Stars in Image")) | ||
1924 | { | 1954 | { | ||
1925 | action->setChecked(markStars); | 1955 | action->setChecked(markStars); | ||
1926 | break; | 1956 | break; | ||
1927 | } | 1957 | } | ||
1928 | } | 1958 | } | ||
1929 | } | 1959 | } | ||
1930 | } | 1960 | } | ||
1961 | | ||||
1962 | void FITSView::setStarsHFREnabled(bool enable) | ||||
1963 | { | ||||
1964 | showStarsHFR = enable; | ||||
1965 | } |
That seems a bit too large when it is subframed. Also, the number is clipped. Maybe it should be Above the star? or maybe it should be smaller in this case?