24 #include <QTextStream>
27 #include <kstandarddirs.h>
34 FOV::FOV(
const QString &n,
float a,
float b,
float xoffset,
float yoffset,
float rot,
Shape sh,
const QString &col )
38 m_sizeY = (b < 0.0) ? a : b;
49 m_name = i18n(
"No FOV" );
52 m_sizeX = m_sizeY = 0;
54 m_offsetX=m_offsetY=m_rotation=0;
58 p.setPen( QColor(
color() ) );
59 p.setBrush( Qt::NoBrush );
64 float pixelSizeX =
sizeX() * zoomFactor / 57.3 / 60.0;
65 float pixelSizeY =
sizeY() * zoomFactor / 57.3 / 60.0;
67 float offsetXPixelSize =
offsetX() * zoomFactor / 57.3 / 60.0;
68 float offsetYPixelSize =
offsetY() * zoomFactor / 57.3 / 60.0;
71 p.translate(p.viewport().center());
73 p.translate(offsetXPixelSize, offsetYPixelSize);
81 p.drawRect( center.x() - pixelSizeX/2, center.y() - pixelSizeY/2, pixelSizeX, pixelSizeY);
84 p.drawEllipse( center, pixelSizeX/2, pixelSizeY/2 );
88 p.drawLine(center.x() + 0.5*pixelSizeX, center.y(),
89 center.x() + 1.5*pixelSizeX, center.y());
90 p.drawLine(center.x() - 0.5*pixelSizeX, center.y(),
91 center.x() - 1.5*pixelSizeX, center.y());
92 p.drawLine(center.x(), center.y() + 0.5*pixelSizeY,
93 center.x(), center.y() + 1.5*pixelSizeY);
94 p.drawLine(center.x(), center.y() - 0.5*pixelSizeY,
95 center.x(), center.y() - 1.5*pixelSizeY);
97 p.drawEllipse( center, 0.5 * pixelSizeX, 0.5 * pixelSizeY);
98 p.drawEllipse( center, pixelSizeX, pixelSizeY);
101 p.drawEllipse(center, 0.5 * pixelSizeX, 0.5 * pixelSizeY);
102 p.drawEllipse(center, 2.0 * pixelSizeX, 2.0 * pixelSizeY);
103 p.drawEllipse(center, 4.0 * pixelSizeX, 4.0 * pixelSizeY);
106 QColor colorAlpha =
color();
107 colorAlpha.setAlpha(127);
108 p.setBrush( QBrush( colorAlpha ) );
109 p.drawEllipse(center, pixelSizeX/2, pixelSizeY/2 );
110 p.setBrush(Qt::NoBrush);
121 float xfactor = x /
sizeX() * 57.3 * 60.0;
122 float yfactor = y /
sizeY() * 57.3 * 60.0;
123 float zoomFactor = std::min(xfactor, yfactor);
126 case BULLSEYE: zoomFactor /= 8;
break;
141 fovs <<
new FOV(
i18nc(
"use field-of-view for binoculars",
"7x35 Binoculars" ),
142 558, 558, 0,0,0,
CIRCLE,
"#AAAAAA")
143 <<
new FOV(
i18nc(
"use a Telrad field-of-view indicator",
"Telrad" ),
145 <<
new FOV(
i18nc(
"use 1-degree field-of-view indicator",
"One Degree"),
146 60, 60, 0,0,0,
CIRCLE,
"#AAAAAA")
147 <<
new FOV(
i18nc(
"use HST field-of-view indicator",
"HST WFPC2"),
148 2.4, 2.4, 0,0,0,
SQUARE,
"#AAAAAA")
149 <<
new FOV(
i18nc(
"use Radiotelescope HPBW",
"30m at 1.3cm" ),
150 1.79, 1.79, 0,0,0,
SQUARE,
"#AAAAAA");
157 f.setFileName( KStandardDirs::locateLocal(
"appdata",
"fov.dat" ) );
159 if ( ! f.open( QIODevice::WriteOnly ) ) {
160 kDebug() << i18n(
"Could not open fov.dat." );
164 foreach(
FOV* fov, fovs) {
165 ostream << fov->
name() <<
':'
166 << fov->
sizeX() <<
':'
167 << fov->
sizeY() <<
':'
171 << QString::number( fov->
shape() ) <<
':'
172 << fov->
color() << endl;
181 f.setFileName( KStandardDirs::locateLocal(
"appdata",
"fov.dat" ) );
189 if( f.open(QIODevice::ReadOnly) ) {
192 while( !istream.atEnd() ) {
193 QStringList fields = istream.readLine().split(
':');
196 float sizeX,
sizeY, xoffset, yoffset, rot, orient;
198 if( fields.count() == 8 )
201 sizeX = fields[1].toFloat(&ok);
205 sizeY = fields[2].toFloat(&ok);
209 xoffset = fields[3].toFloat(&ok);
214 yoffset = fields[4].toFloat(&ok);
219 rot = fields[5].toFloat(&ok);
232 fovs.append(
new FOV(name, sizeX, sizeY, xoffset, yoffset, rot, shape, color) );
FOV()
Default constructor.
class encapulating a Field-of-View symbol
static QList< FOV * > readFOVs()
Read list of FOVs from "fov.dat".
static void writeFOVs(const QList< FOV * > fovs)
Write list of FOVs to "fov.dat".
i18nc("string from libindi, used in the config dialog","100x")
void draw(QPainter &p, float zoomFactor)
draw the FOV symbol on a QPainter
static QList< FOV * > defaults()
Fill list with default FOVs.
static FOV::Shape intToShape(int)
static bool useAntialias()
Get Use antialiasing when drawing the screen?