File indexing completed on 2024-07-07 07:09:16

0001 /*
0002     SPDX-FileCopyrightText: 2007 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "fovwidget.h"
0008 
0009 #include "fov.h"
0010 #include "dialogs/fovdialog.h"
0011 
0012 #include <QPainter>
0013 #include <QPaintEvent>
0014 
0015 FOVWidget::FOVWidget(QWidget *parent) : QFrame(parent), m_FOV(nullptr)
0016 {
0017 }
0018 
0019 void FOVWidget::setFOV(FOV *f)
0020 {
0021     m_FOV = f;
0022 }
0023 
0024 void FOVWidget::paintEvent(QPaintEvent *)
0025 {
0026     QPainter p;
0027     p.begin(this);
0028     p.setRenderHint(QPainter::Antialiasing, true);
0029     p.fillRect(contentsRect(), QColor("black"));
0030 
0031     if (m_FOV && m_FOV->sizeX() > 0 && m_FOV->sizeY() > 0)
0032     {
0033         m_FOV->draw(p, 0.6 * contentsRect().width(), 0.6 * contentsRect().height());
0034         QFont smallFont = p.font();
0035         smallFont.setPointSize(p.font().pointSize() - 2);
0036         p.setFont(smallFont);
0037         // 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)
0038         p.drawText(rect(), Qt::AlignHCenter | Qt::AlignBottom,
0039                    i18nc("angular size in arcminutes", "%1 x %2 arcmin", QString::number(m_FOV->sizeX(), 'f', 1),
0040                          QString::number(m_FOV->sizeY(), 'f', 1)));
0041     }
0042 
0043     p.end();
0044 }