Kstars

fovwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "fovwidget.h"
8
9#include "fov.h"
10#include "dialogs/fovdialog.h"
11
12#include <QPainter>
13#include <QPaintEvent>
14
15FOVWidget::FOVWidget(QWidget *parent) : QFrame(parent), m_FOV(nullptr)
16{
17}
18
19void FOVWidget::setFOV(FOV *f)
20{
21 m_FOV = f;
22}
23
24void FOVWidget::paintEvent(QPaintEvent *)
25{
26 QPainter p;
27 p.begin(this);
29 p.fillRect(contentsRect(), QColor("black"));
30
31 if (m_FOV && m_FOV->sizeX() > 0 && m_FOV->sizeY() > 0)
32 {
33 m_FOV->draw(p, 0.6 * contentsRect().width(), 0.6 * contentsRect().height());
34 QFont smallFont = p.font();
35 smallFont.setPointSize(p.font().pointSize() - 2);
36 p.setFont(smallFont);
37 // TODO: Check if decimal points in this are localized (eg: It should read 1,5 x 1,5 in German rather than 1.5 x 1.5)
39 i18nc("angular size in arcminutes", "%1 x %2 arcmin", QString::number(m_FOV->sizeX(), 'f', 1),
40 QString::number(m_FOV->sizeY(), 'f', 1)));
41 }
42
43 p.end();
44}
A simple class encapsulating a Field-of-View symbol.
Definition fov.h:28
void draw(QPainter &p, float zoomFactor)
draw the FOV symbol on a QPainter
Definition fov.cpp:230
QString i18nc(const char *context, const char *text, const TYPE &arg...)
int pointSize() const const
void setPointSize(int pointSize)
bool begin(QPaintDevice *device)
void drawText(const QPoint &position, const QString &text)
bool end()
void fillRect(const QRect &rectangle, QGradient::Preset preset)
const QFont & font() const const
void setFont(const QFont &font)
void setRenderHint(RenderHint hint, bool on)
QString number(double n, char format, int precision)
AlignHCenter
QRect contentsRect() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.