10#include "fitscommon.h"
11#include "auxiliary/imagemask.h"
13#include <config-kstars.h>
16#ifdef HAVE_DATAVISUALIZATION
17#include "starprofileviewer.h"
20#include <QFutureWatcher>
54 explicit FITSView(
QWidget *
parent =
nullptr, FITSMode fitsMode = FITS_NORMAL, FITSScale filterType = FITS_NONE);
55 virtual ~FITSView()
override;
57 typedef enum {dragCursor, selectCursor, scopeCursor, crosshairCursor } CursorMode;
65 void loadFile(
const QString &inFilename);
79 bool saveImage(
const QString &newFilename);
81 bool rescale(FITSZoom type);
88 Q_SCRIPTABLE
void setStretchValues(
double shadows,
double midtones,
double highlights);
89 Q_SCRIPTABLE
void setAutoStretch();
91 double getCurrentZoom()
const
95 const QImage &getDisplayImage()
const
99 const QPixmap &getDisplayPixmap()
const
101 return displayPixmap;
105 void setTrackingBoxEnabled(
bool enable);
106 bool isTrackingBoxEnabled()
const
108 return trackingBoxEnabled;
110 QPixmap &getTrackingBoxPixmap(uint8_t margin = 0);
112 const QRect &getTrackingBox()
const
118 const QString &lastError()
const
124 virtual void drawOverlay(
QPainter *,
double scale);
127 void drawStarRingFilter(
QPainter *,
double scale, ImageRingMask *ringMask);
128 void drawStarCentroid(
QPainter *,
double scale);
130 void drawTrackingBox(
QPainter *,
double scale);
131 void drawMarker(
QPainter *,
double scale);
132 void drawCrosshair(
QPainter *,
double scale);
134#if !defined(KSTARS_LITE) && defined(HAVE_WCSLIB)
135 void drawEQGrid(
QPainter *,
double scale);
136 void drawHiPSOverlay(
QPainter *painter,
double scale);
138 void drawObjectNames(
QPainter *painter,
double scale);
139 void drawCatObjectNames(
QPainter *painter,
double scale);
140 void drawCatROI(
QPainter *painter,
double scale);
141 void drawPixelGrid(
QPainter *painter,
double scale);
142 void drawMagnifyingGlass(
QPainter *painter,
double scale);
144 bool isImageStretched();
145 bool isCrosshairShown();
146 bool isClippingShown();
147 bool areObjectsShown();
148 bool isEQGridShown();
149 bool isSelectionRectShown();
150 bool isPixelGridShown();
151 bool isHiPSOverlayShown();
155 void updateFrame(
bool now =
false);
158 bool isTelescopeActive();
159 void updateScopeButton();
160 void setScopeButton(
QAction *action)
162 centerTelescopeAction = action;
166#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
169 void enterEvent(
QEvent *event)
override;
171 void leaveEvent(
QEvent *event)
override;
172 CursorMode getCursorMode();
173 void setCursorMode(CursorMode mode);
174 void updateMouseCursor();
179 uint16_t zoomedWidth()
183 uint16_t zoomedHeight()
185 return currentHeight;
187 double ZoomFactor()
const
194 void toggleStars(
bool enable);
196 void setStarsEnabled(
bool enable);
197 void setStarsHFREnabled(
bool enable);
205 void setImageMask(ImageMask *
mask);
208 void updateMode(FITSMode fmode);
214 void setFilter(FITSScale newFilter)
219 void setFirstLoad(
bool value);
221 void pushFilter(FITSScale value)
223 filterStack.
push(value);
225 FITSScale popFilter()
227 return filterStack.
pop();
230 CursorMode lastMouseMode { selectCursor };
231 bool isStarProfileShown()
233 return showStarProfile;
236 void createFloatingToolBar();
241 StretchParams getStretchParams()
const
243 return stretchParams;
248 bool getAutoStretch()
const
256 void setStretchParams(
const StretchParams ¶ms);
260 void setStretch(
bool onOff);
263 void setAutoStretchParams();
267 void setPreviewSampling(uint8_t value)
271 m_PreviewSampling = m_AdaptiveSampling;
272 m_StretchingInProgress =
false;
276 m_PreviewSampling = value * m_AdaptiveSampling;
277 m_StretchingInProgress =
true;
287 QRect getSelectionRegion()
const
289 return selectionRectangleRaw;
301 void updateMagnifyingGlass(
int x,
int y);
305 void toggleObjects();
306 void togglePixelGrid();
307 void toggleCrosshair();
310 void toggleHiPSOverlay();
313 void toggleSelectionMode();
317 void toggleStarProfile();
318 void viewStarProfile();
320 void centerTelescope();
322 void toggleStretch();
323 void toggleClipping();
325 virtual void processPointSelection(
int x,
int y);
326 virtual void processMarkerSelection(
int x,
int y);
327 void processHighlight(
int x,
int y);
330 void move3DTrackingBox(
int x,
int y);
331 void resizeTrackingBox(
int newSize);
332 void processRectangle(
QPoint p1,
QPoint p2,
bool refreshCenter =
false);
333 void processRectangleFixed(
int s);
341 bool event(
QEvent *event)
override;
348 void calculateMaxPixel(
double min,
double max);
349 void initDisplayImage();
352 bool pointIsInImage(
QPointF pt,
double scale);
359 QRect selectionRectangleRaw;
361 QToolBar *floatingToolBar {
nullptr };
371 double currentZoom { 0 };
376 uint8_t *m_ImageRoiBuffer {
nullptr };
378 uint32_t m_ImageRoiBufferSize { 0 };
382 void doStretch(
QImage *outputImage);
383 double scaleSize(
double size);
385 bool initDisplayPixmap(
QImage &image,
float space);
386 void updateFrameLargeImage();
387 void updateFrameSmallImage();
396 uint16_t currentWidth { 0 };
398 uint16_t currentHeight { 0 };
400 const double m_ZoomFactor;
407 bool firstLoad {
true };
408 bool markStars {
false };
409 bool showStarProfile {
false };
410 bool showCrosshair {
false };
411 bool showObjects {
false };
412 bool showEQGrid {
false };
413 bool showPixelGrid {
false };
414 bool showHiPSOverlay {
false };
415 bool showStarsHFR {
false };
416 bool showClipping {
false };
418 int m_NumClipped { 0 };
420 bool showSelectionRect {
false };
424 bool stretchImage {
false };
429 bool autoStretch {
true };
432 StretchParams stretchParams;
435 uint8_t m_PreviewSampling { 1 };
436 bool m_StretchingInProgress {
false};
438 uint8_t m_AdaptiveSampling {1};
443 CursorMode cursorMode { selectCursor };
444 bool zooming {
false };
452 QTimer m_UpdateFrameTimer;
457 bool trackingBoxEnabled {
false };
467 QAction *centerTelescopeAction {
nullptr };
468 QAction *toggleEQGridAction {
nullptr };
469 QAction *toggleObjectsAction {
nullptr };
470 QAction *toggleStarsAction {
nullptr };
471 QAction *toggleProfileAction {
nullptr };
472 QAction *toggleStretchAction {
nullptr };
473 QAction *toggleHiPSOverlayAction {
nullptr };
476 int magnifyingGlassX { -1 };
477 int magnifyingGlassY { -1 };
478 bool showMagnifyingGlass {
false };
479 bool m_Suspended {
false};
482 bool m_QueueUpdate {
false};
487#ifdef HAVE_DATAVISUALIZATION
492 void newStatus(
const QString &msg, FITSBar
id);
493 void newStretch(
const StretchParams ¶ms);
494 void debayerToggled(
bool);
495 void wcsToggled(
bool);
496 void actionUpdated(
const QString &name,
bool enable);
497 void trackingStarSelected(
int x,
int y);
500 void failed(
const QString &error);
501 void starProfileWindowClosed();
502 void rectangleUpdated(
QRect roi);
504 void showRubberBand(
bool on =
false);
505 void zoomRubberBand(
double scale);
506 void mouseOverPixel(
int x,
int y);
509 void catQueryFailed(
const QString text);
511 void catHighlightChanged(
const int highlight);
512 void headerChanged();
514 friend class FITSLabel;
QObject * parent() const const