Git commit 6eab46a6410469c0df662cebdc0ab9d3e6257760 by Jasem Mutlaq, on behalf of Madhav Prabhu. Committed on 11/07/2022 at 13:39. Pushed by mutlaqja into branch 'master'.
Added documentation for measure fits background, some bug fixes, merge conflicts M +30 -0 doc/fitsviewer.docbook A +- -- doc/fitsviewer_selstat.png M +11 -2 kstars/fitsviewer/fitslabel.cpp M +1 -1 kstars/fitsviewer/fitslabel.h M +10 -12 kstars/fitsviewer/fitsview.cpp M +7 -6 kstars/fitsviewer/fitsview.h M +1 -25 kstars/fitsviewer/fitsviewer.cpp https://invent.kde.org/education/kstars/commit/6eab46a6410469c0df662cebdc0ab9d3e6257760 diff --git a/doc/fitsviewer.docbook b/doc/fitsviewer.docbook index ae6bad51c..5011a7357 100644 --- a/doc/fitsviewer.docbook +++ b/doc/fitsviewer.docbook @@ -79,6 +79,7 @@ To open a FITS file, select the <menuchoice><guimenu>File</guimenu> <listitem><para>Histogram: Toggle histogram view in the side panel.</para></listitem> <listitem><para>Statistics: Toggle FITS Statistic view in the side panel.</para></listitem> <listitem><para>Auto Stretch: Apply Auto Stretch filter to the image.</para></listitem> + <listitem><para>Toggle Selection Rectangle: Toggle selection rectangle for statistics of a region of interest.</para></listitem> </itemizedlist> </listitem> <listitem><para>Side Panel: The side panel can be opened by dragging the separator to the right. When dragged to the left, the side panel can also be closed.</para> @@ -166,6 +167,11 @@ To open a FITS file, select the <menuchoice><guimenu>File</guimenu> Statistics. </para> </listitem> + <listitem> + <para> + Statistics for a region of interest(Rectangle). + </para> + </listitem> <listitem> <para> Rectangular and Equatorial Grids (if WCS info is present). @@ -225,6 +231,30 @@ To open a FITS file, select the <menuchoice><guimenu>File</guimenu> </para> </listitem> </varlistentry> + <varlistentry> + <term>Statistics of region of interest</term> + <listitem> + <screenshot> + <screeninfo> + FITSViewer + </screeninfo> + <mediaobject> + <imageobject> + <imagedata fileref="fitsviewer_selstat.png" format="PNG"/> + </imageobject> + <textobject> + <phrase>Selection Statistics</phrase> + </textobject> + </mediaobject> + </screenshot> + <para> + Provides simple statistics average mean, average standard deviation and average median of the selected region by the user in a tooltip. + </para> + <para> + The user can either set the selection region by <keycombo>&Shift;<keycap>Left Click</keycap></keycombo> dragging or by choosing an entry from the drop down menu of the Toggle Selection Rectangle button. In addition to this, the user can translate the region by simple <keycap>Left Click</keycap> drag of the mouse. The statistics of the region are shown as a tooltip once the cursor is brought over the selection region. For smaller images, the statistics are updated instantly, and for larger images, the statistics are updated once the user releases the <keycap>Left Click</keycap> button after modification of the region. + </para> + </listitem> + </varlistentry> </variablelist> </sect2> diff --git a/doc/fitsviewer_selstat.png b/doc/fitsviewer_selstat.png new file mode 100644 index 000000000..dd8461048 Binary files /dev/null and b/doc/fitsviewer_selstat.png differ diff --git a/kstars/fitsviewer/fitslabel.cpp b/kstars/fitsviewer/fitslabel.cpp index ba79439db..ced28b3b7 100644 --- a/kstars/fitsviewer/fitslabel.cpp +++ b/kstars/fitsviewer/fitslabel.cpp @@ -266,7 +266,7 @@ void FITSLabel::mouseMoveEvent(QMouseEvent *e) break; } } - if (!objFound) + if (!objFound && !view->isSelectionRectShown()) QToolTip::hideText(); } @@ -468,13 +468,17 @@ void FITSLabel::showRubberBand(bool on) } /// Scales the rubberband on zoom -void FITSLabel::zoomRubberBand(float scale) +void FITSLabel::zoomRubberBand(double scale) { QRect r = roiRB->geometry() ; if(prevscale == 0.0 ) prevscale = scale; + double ap = r.width() / r.height(); + double ow = r.width() * scale / prevscale; + double oh = r.height() * scale / prevscale; + int rx, ry; rx = round(r.topLeft().x() * scale / prevscale); ry = round(r.topLeft().y() * scale / prevscale); @@ -484,6 +488,11 @@ void FITSLabel::zoomRubberBand(float scale) ry = round(r.bottomRight().y() * scale / prevscale); r.setBottomRight(QPoint(rx, ry)); + if (ap != r.width() / r.height()) + { + r.setSize(QSize(ow, oh)); + } + roiRB->setGeometry(r); prevscale = scale; } diff --git a/kstars/fitsviewer/fitslabel.h b/kstars/fitsviewer/fitslabel.h index 39b1bb250..0341ac6da 100644 --- a/kstars/fitsviewer/fitslabel.h +++ b/kstars/fitsviewer/fitslabel.h @@ -34,7 +34,7 @@ class FITSLabel : public QLabel public slots: void setRubberBand(QRect rect); void showRubberBand(bool on); - void zoomRubberBand(float scale); + void zoomRubberBand(double scale); protected: virtual void mouseMoveEvent(QMouseEvent *e) override; diff --git a/kstars/fitsviewer/fitsview.cpp b/kstars/fitsviewer/fitsview.cpp index fd261a5c7..243697114 100644 --- a/kstars/fitsviewer/fitsview.cpp +++ b/kstars/fitsviewer/fitsview.cpp @@ -346,7 +346,6 @@ void FITSView::loadFile(const QString &inFilename) m_ImageData->setBayerParams(¶m); fitsWatcher.setFuture(m_ImageData->loadFromFile(inFilename)); - m_ROICenter = QPoint(m_ImageData->width() / 2, m_ImageData->height() / 2); } void FITSView::clearData() @@ -669,6 +668,7 @@ void FITSView::ZoomIn() updateFrame(true); emit newStatus(QString("%1%").arg(currentZoom), FITS_ZOOM); + emit zoomRubberBand(getCurrentZoom() / ZOOM_DEFAULT); } void FITSView::ZoomOut() @@ -697,6 +697,7 @@ void FITSView::ZoomOut() updateFrame(true); emit newStatus(QString("%1%").arg(currentZoom), FITS_ZOOM); + emit zoomRubberBand(getCurrentZoom() / ZOOM_DEFAULT); } void FITSView::ZoomToFit() @@ -709,6 +710,7 @@ void FITSView::ZoomToFit() rescale(ZOOM_FIT_WINDOW); updateFrame(true); } + emit zoomRubberBand(getCurrentZoom() / ZOOM_DEFAULT); } void FITSView::setStarFilterRange(float const innerRadius, float const outerRadius) @@ -1662,22 +1664,18 @@ void FITSView::resizeTrackingBox(int newSize) void FITSView::processRectangleFixed(int s) { - if(s % 2) - s++; - - int w = m_ImageData->width(); int h = m_ImageData->height(); - QPoint c = QPoint(round(1 + w) / 2, round(1 + h / 2)); - c.setX(qMax((int)round(s / 2), c.x())); - c.setX(qMin(w - (int)round(s / 2), c.x())); - c.setY(qMax((int)round(s / 2), c.y())); - c.setY(qMin(h - (int)round(s / 2), c.y())); + QPoint c = selectionRectangleRaw.center(); + c.setX(qMax((int)round(s / 2.0), c.x())); + c.setX(qMin(w - (int)round(s / 2.0), c.x())); + c.setY(qMax((int)round(s / 2.0), c.y())); + c.setY(qMin(h - (int)round(s / 2.0), c.y())); QPoint topLeft, botRight; - topLeft = QPoint(c.x() - round(s / 2), c.y() - round(s / 2)); - botRight = QPoint(c.x() + round(s / 2), c.y() + round(s / 2)); + topLeft = QPoint(c.x() - round(s / 2.0), c.y() - round(s / 2.0)); + botRight = QPoint(c.x() + round(s / 2.0), c.y() + round(s / 2.0)); emit setRubberBand(QRect(topLeft, botRight)); processRectangle(topLeft, botRight, true); diff --git a/kstars/fitsviewer/fitsview.h b/kstars/fitsviewer/fitsview.h index 0acd6b548..0586462cd 100644 --- a/kstars/fitsviewer/fitsview.h +++ b/kstars/fitsviewer/fitsview.h @@ -175,10 +175,6 @@ class FITSView : public QScrollArea { return m_ZoomFactor; } - QPoint roiCenter() const - { - return m_ROICenter; - } // Star Detection QFuture<bool> findStars(StarAlgorithm algorithm = ALGORITHM_CENTROID, const QRect &searchBox = QRect()); @@ -268,6 +264,12 @@ class FITSView : public QScrollArea { return m_NumClipped; } + + QRect getSelectionRegion() const + { + return selectionRectangleRaw; + } + public slots: void wheelEvent(QWheelEvent *event) override; void resizeEvent(QResizeEvent *event) override; @@ -446,7 +448,6 @@ class FITSView : public QScrollArea QAction *toggleStarsAction { nullptr }; QAction *toggleProfileAction { nullptr }; QAction *toggleStretchAction { nullptr }; - QPoint m_ROICenter; // State for the magnifying glass overlay. int magnifyingGlassX { -1 }; @@ -473,7 +474,7 @@ class FITSView : public QScrollArea void rectangleUpdated(QRect roi); void setRubberBand(QRect rect); void showRubberBand(bool on = false); - void zoomRubberBand(float scale); + void zoomRubberBand(double scale); friend class FITSLabel; }; diff --git a/kstars/fitsviewer/fitsviewer.cpp b/kstars/fitsviewer/fitsviewer.cpp index 45a9a5075..b4ef14005 100644 --- a/kstars/fitsviewer/fitsviewer.cpp +++ b/kstars/fitsviewer/fitsviewer.cpp @@ -204,28 +204,6 @@ FITSViewer::FITSViewer(QWidget *parent) : KXmlGuiWindow(parent) connect(roiActionMenu->menu()->actions().at(3), &QAction::triggered, this, [this] { ROIFixedSize(25); }); connect(roiActionMenu->menu()->actions().at(4), &QAction::triggered, this, [this] { customROIInputWindow();}); connect(action, &QAction::triggered, this, &FITSViewer::toggleSelectionMode); - // - //roiMenu = new QMenu; - //roiMenu->addAction("100x100"); - //roiMenu->addAction("50x50"); - //roiMenu->addAction("25x25"); - //roiMenu->addAction("xy"); - - //action = actionCollection()->addAction("menu"); - //action->setIcon(QIcon(":/icons/select_stat")); - //action->setMenu(roiMenu); - //action->setCheckable(true); - //connect(action, SIGNAL(triggered(bool)), SLOT(toggleSelectionMode())); - //connect(action->menu()->actions()[0], SIGNAL(&QAction::triggered), SLOT(roiFixedSize(100))); - //connect(action->menu()->actions()[1], SIGNAL(&QAction::triggered), SLOT(roiFixedSize(50))); - //connect(action->menu()->actions()[2], SIGNAL(&QAction::triggered), SLOT(roiFixedSize(25))); - //connect(action->menu()->actions()[3], SIGNAL(&QAction::triggered), SLOT(customRoiInputWindow())); - - //action = actionCollection()->addAction("image_roi_stats"); - //action->setIcon(QIcon(":/icons/select_stat")); - //action->setText(i18n("Show Selection Statistics")); - //action->setCheckable(true); - //connect(action, SIGNAL(triggered(bool)), SLOT(toggleSelectionMode())); action = actionCollection()->addAction("view_crosshair"); action->setIcon(QIcon::fromTheme("crosshairs")); @@ -1060,9 +1038,7 @@ void FITSViewer::customROIInputWindow() if(customRoiDialog.exec() == QDialog::Accepted) { - QPoint resetCenter = QPoint(mw / 2, mh / 2); - getCurrentView()->imageData()->setRoiCenter(resetCenter); - + QPoint resetCenter = getCurrentView()->getSelectionRegion().center(); int newheight = hle.text().toInt(); int newwidth = wle.text().toInt();