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 drawPixelGrid(
QPainter *painter,
double scale);
140 void drawMagnifyingGlass(
QPainter *painter,
double scale);
142 bool isImageStretched();
143 bool isCrosshairShown();
144 bool isClippingShown();
145 bool areObjectsShown();
146 bool isEQGridShown();
147 bool isSelectionRectShown();
148 bool isPixelGridShown();
149 bool isHiPSOverlayShown();
153 void updateFrame(
bool now =
false);
156 bool isTelescopeActive();
157 void updateScopeButton();
158 void setScopeButton(
QAction *action)
160 centerTelescopeAction = action;
164 void enterEvent(
QEvent *event)
override;
165 void leaveEvent(
QEvent *event)
override;
166 CursorMode getCursorMode();
167 void setCursorMode(CursorMode mode);
168 void updateMouseCursor();
173 uint16_t zoomedWidth()
177 uint16_t zoomedHeight()
179 return currentHeight;
181 double ZoomFactor()
const
188 void toggleStars(
bool enable);
190 void setStarsEnabled(
bool enable);
191 void setStarsHFREnabled(
bool enable);
196 void setImageMask(ImageMask *
mask);
199 void updateMode(FITSMode fmode);
205 void setFilter(FITSScale newFilter)
210 void setFirstLoad(
bool value);
212 void pushFilter(FITSScale value)
214 filterStack.
push(value);
216 FITSScale popFilter()
218 return filterStack.
pop();
221 CursorMode lastMouseMode { selectCursor };
222 bool isStarProfileShown()
224 return showStarProfile;
227 void createFloatingToolBar();
232 StretchParams getStretchParams()
const
234 return stretchParams;
239 bool getAutoStretch()
const
247 void setStretchParams(
const StretchParams ¶ms);
251 void setStretch(
bool onOff);
254 void setAutoStretchParams();
258 void setPreviewSampling(uint8_t value)
262 m_PreviewSampling = m_AdaptiveSampling;
263 m_StretchingInProgress =
false;
267 m_PreviewSampling = value * m_AdaptiveSampling;
268 m_StretchingInProgress =
true;
278 QRect getSelectionRegion()
const
280 return selectionRectangleRaw;
292 void updateMagnifyingGlass(
int x,
int y);
296 void toggleObjects();
297 void togglePixelGrid();
298 void toggleCrosshair();
301 void toggleHiPSOverlay();
304 void toggleSelectionMode();
308 void toggleStarProfile();
309 void viewStarProfile();
311 void centerTelescope();
313 void toggleStretch();
314 void toggleClipping();
316 virtual void processPointSelection(
int x,
int y);
317 virtual void processMarkerSelection(
int x,
int y);
319 void move3DTrackingBox(
int x,
int y);
320 void resizeTrackingBox(
int newSize);
321 void processRectangle(
QPoint p1,
QPoint p2,
bool refreshCenter =
false);
322 void processRectangleFixed(
int s);
330 bool event(
QEvent *event)
override;
337 void calculateMaxPixel(
double min,
double max);
338 void initDisplayImage();
341 bool pointIsInImage(
QPointF pt,
double scale);
348 QRect selectionRectangleRaw;
350 QToolBar *floatingToolBar {
nullptr };
360 double currentZoom { 0 };
365 uint8_t *m_ImageRoiBuffer {
nullptr };
367 uint32_t m_ImageRoiBufferSize { 0 };
371 void doStretch(
QImage *outputImage);
372 double scaleSize(
double size);
374 bool initDisplayPixmap(
QImage &image,
float space);
375 void updateFrameLargeImage();
376 void updateFrameSmallImage();
385 uint16_t currentWidth { 0 };
387 uint16_t currentHeight { 0 };
389 const double m_ZoomFactor;
396 bool firstLoad {
true };
397 bool markStars {
false };
398 bool showStarProfile {
false };
399 bool showCrosshair {
false };
400 bool showObjects {
false };
401 bool showEQGrid {
false };
402 bool showPixelGrid {
false };
403 bool showHiPSOverlay {
false };
404 bool showStarsHFR {
false };
405 bool showClipping {
false };
407 int m_NumClipped { 0 };
409 bool showSelectionRect {
false };
413 bool stretchImage {
false };
418 bool autoStretch {
true };
421 StretchParams stretchParams;
424 uint8_t m_PreviewSampling { 1 };
425 bool m_StretchingInProgress {
false};
427 uint8_t m_AdaptiveSampling {1};
432 CursorMode cursorMode { selectCursor };
433 bool zooming {
false };
441 QTimer m_UpdateFrameTimer;
446 bool trackingBoxEnabled {
false };
456 QAction *centerTelescopeAction {
nullptr };
457 QAction *toggleEQGridAction {
nullptr };
458 QAction *toggleObjectsAction {
nullptr };
459 QAction *toggleStarsAction {
nullptr };
460 QAction *toggleProfileAction {
nullptr };
461 QAction *toggleStretchAction {
nullptr };
462 QAction *toggleHiPSOverlayAction {
nullptr };
465 int magnifyingGlassX { -1 };
466 int magnifyingGlassY { -1 };
467 bool showMagnifyingGlass {
false };
468 bool m_Suspended {
false};
471 bool m_QueueUpdate {
false};
476#ifdef HAVE_DATAVISUALIZATION
481 void newStatus(
const QString &msg, FITSBar
id);
482 void newStretch(
const StretchParams ¶ms);
483 void debayerToggled(
bool);
484 void wcsToggled(
bool);
485 void actionUpdated(
const QString &name,
bool enable);
486 void trackingStarSelected(
int x,
int y);
489 void failed(
const QString &error);
490 void starProfileWindowClosed();
491 void rectangleUpdated(
QRect roi);
493 void showRubberBand(
bool on =
false);
494 void zoomRubberBand(
double scale);
495 void mouseOverPixel(
int x,
int y);
497 friend class FITSLabel;
QObject * parent() const const