-
Notifications
You must be signed in to change notification settings - Fork 0
/
fits_viewer.h
executable file
·105 lines (80 loc) · 2.69 KB
/
fits_viewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef FITS_VIEWER_H
#define FITS_VIEWER_H
#include "fits_viewer_global.h"
#include<QtWidgets>
#include<QPixmap>
#include<QVector>
#include<QRgb>
#include<QCursor>
#include<QRubberBand>
#include<QGraphicsRectItem>
#define FITS_VIEWER_ERROR_OK 0
#define FITS_VIEWER_ERROR_BAD_ALLOC 10000
#define FITS_VIEWER_ERROR_BAD_SCALE_PARS 10001
#define FITS_VIEWER_ERROR_BAD_COLOR_TABLE 10002
#define FITS_VIEWER_CT_LENGTH 256
#define FITS_VIEWER_ZSCALE_NSAMPLE 10000
class FITS_VIEWERSHARED_EXPORT Fits_viewer: public QGraphicsView
{
Q_OBJECT
public:
enum ColorTable {CT_BW, CT_NEGBW};
Fits_viewer(QString fits_filename, QWidget *parent = 0);
Fits_viewer(QWidget *parent = 0);
~Fits_viewer();
void GetCurrentCuts(double *low_cuts, double *high_cuts);
void GetImageMinMax(double *min_val, double *max_val);
int getCurrentError() const;
double* getCurrentSubImage(QRect *rect);
signals:
void Fits_viewer_error(int err);
void ImagePoint(QPointF pos, double val);
void ImagePoint(double xpos, double ypos, double val);
void SelectedRegion(QRectF region);
void DeselectRegion();
void ScalingIsChanged(double low_cuts, double high_cuts);
public slots:
void LoadFile(QString fits_filename);
void ScaleImage(const double low_val, const double high_val);
protected:
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void resizeEvent(QResizeEvent* event);
virtual void wheelEvent(QWheelEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
private slots:
void SetError(int err);
void scalingTime(qreal x);
void animFinished();
private:
int currentError;
QString currentFITS_filename;
bool isImageLoaded;
double *currentImage_buffer;
uchar *currentScaledImage_buffer;
size_t currentImage_npix;
size_t currentImage_dim[2];
double currentImageMinVal;
double currentImageMaxVal;
double currentLowCut,currentHighCut;
double *currentSubImage;
QPixmap currentPixmap;
QVector<QRgb> currentCT;
QGraphicsScene *scene;
QGraphicsItem *pixmap_item;
QCursor currentCursor;
// QRubberBand *rubberBand;
QGraphicsRectItem *rubberBand;
void ShowImage();
void GenerateCT(Fits_viewer::ColorTable ct);
void Compute_ZScale(double *zmin, double *zmax, const double contrast = 0.25);
void ZScale(double *zmin, double *zmax, const double contrast = 0.25);
int _numScheduledScalings;
qreal currentScale;
QPointF rubberBand_origin, rubberBand_end;
QPen rubberBand_pen;
bool isRubberBandActive;
bool isRubberBandShown;
};
#endif // FITS_VIEWER_H