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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/***************************************************************************
fitsimage.cpp - FITS Image
-------------------
begin : Tue Feb 24 2004
copyright : (C) 2004 by Jasem Mutlaq
email : mutlaqja@ikarustech.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* Some code fragments were adapted from Peter Kirchgessner's FITS plugin*
* See http://members.aol.com/pkirchg for more details. *
***************************************************************************/
#ifndef FITSIMAGE_H
#define FITSIMAGE_H
#include <qwidget.h>
#include <qstring.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qframe.h>
#include <qrect.h>
#include <qptrlist.h>
#include <qscrollview.h>
#include <kpixmapio.h>
#include <kpixmap.h>
#include <kdialog.h>
#include <kmainwindow.h>
#include <kurl.h>
#include "indi/fitsrw.h"
class KCommandHistory;
class QScrollView;
class FITSViewer;
class FITSFrame;
class FITSImage : public QScrollView {
Q_OBJECT
public:
friend class ContrastBrightnessDlg;
friend class FITSProcess;
friend class FITSFrame;
friend class FITSViewer;
friend class FITSHistogram;
friend class FITSHistogramCommand;
friend class FITSChangeCommand;
friend class FITSProcessCommand;
FITSImage(QWidget * parent, const char * name = 0);
~FITSImage();
enum scaleType { FITSAuto = 0 , FITSLinear, FITSLog, FITSSqrt, FITSCustom };
/**Bitblt the image onto the viewer widget */
/*void paintEvent (QPaintEvent *ev);*/
/* Resize event */
void resizeEvent (QResizeEvent *ev);
/* Loads FITS image, scales it, and displays it in the GUI */
int loadFits(const char *filename);
/* Convert current image to a pixmap */
void convertImageToPixmap();
/* Clear memory */
void clearMem();
private:
FITSViewer *viewer; /* parent FITSViewer */
FITSFrame *imgFrame; /* Frame holding the image */
QImage *displayImage; /* FITS image that is displayed in the GUI */
QImage *templateImage; /* backup image for currentImage */
QPixmap qpix; /* Pixmap for drawing */
KPixmapIO kpix; /* Pixmap IO for fast converting */
QRect currentRect; /* Current rectangle encapsulating the image */
int bitpix, bpp; /* bits per pixel and bytes per pixels for FITS */
int width, height; /* Original FITS dimensions */
double currentWidth,currentHeight; /* Current width and height due to zoom */
const double zoomFactor; /* Image zoom factor */
double currentZoom; /* Current Zoom level */
QRgb *grayTable;
unsigned char *reducedImgBuffer; /* scaled image buffer (0-255) range */
void saveTemplateImage(); /* saves a backup image */
void reLoadTemplateImage(); /* reloads backup image into the current image */
void destroyTemplateImage(); /* deletes backup image */
void zoomToCurrent(); /* Zoom the image to current zoom level without modifying it */
protected:
/*void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );*/
void contentsMouseMoveEvent ( QMouseEvent * e );
void viewportResizeEvent ( QResizeEvent * e) ;
public slots:
void fitsZoomIn();
void fitsZoomOut();
void fitsZoomDefault();
};
class FITSFrame : public QFrame
{
Q_OBJECT
public:
FITSFrame(FITSImage * img, QWidget * parent = 0, const char * name = 0);
~FITSFrame();
private:
FITSImage *image;
protected:
void paintEvent( QPaintEvent * e);
};
#endif
|