Kstars

darkview.cpp
1/* Ekos Dark View
2 Child of FTISView with few additions necessary for Alignment functions
3
4 SPDX-FileCopyrightText: 2021 Jasem Mutlaq <mutlaqja@ikarustech.com>
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#include "darkview.h"
10
11#include "kstarsdata.h"
12#include "Options.h"
13#include "fitsviewer/fitsdata.h"
14#include "defectmap.h"
15
16#include <QPainter>
17#include <QtConcurrent>
18#include <QRectF>
19
20DarkView::DarkView(QWidget *parent, FITSMode mode, FITSScale filter) : FITSView(parent, mode, filter)
21{
22}
23
24void DarkView::drawOverlay(QPainter *painter, double scale)
25{
26 Q_UNUSED(scale);
27 painter->setOpacity(0.5);
28 FITSView::drawOverlay(painter, getScale());
29 painter->setOpacity(1);
30
31 if (m_CurrentDefectMap && m_DefectMapEnabled)
32 drawBadPixels(painter, scale);
33}
34
35void DarkView::reset()
36{
37 m_CurrentDefectMap.clear();
38}
39
40void DarkView::setDefectMapEnabled(bool enabled)
41{
42 if (m_DefectMapEnabled == enabled)
43 return;
44
45 m_DefectMapEnabled = enabled;
46 updateFrame();
47}
48
49void DarkView::setDefectMap(const QSharedPointer<DefectMap> &defect)
50{
51 m_CurrentDefectMap = defect;
52 connect(m_CurrentDefectMap.data(), &DefectMap::pixelsUpdated, this, &DarkView::updateFrame, Qt::UniqueConnection);
53}
54
55void DarkView::drawBadPixels(QPainter * painter, double scale)
56{
57 if (!m_CurrentDefectMap)
58 return;
59
60 if (m_CurrentDefectMap->hotCount() > 0)
61 {
62 painter->setPen(QPen(QColor(qRgba(255, 0, 0, 128)), scale));
63 for (BadPixelSet::const_iterator onePixel = m_CurrentDefectMap->hotThreshold();
64 onePixel != m_CurrentDefectMap->hotPixels().cend(); ++onePixel)
65 {
66 painter->drawEllipse(QRectF(((*onePixel).x - 1) * scale, ((*onePixel).y - 1) * scale, 2 * scale, 2 * scale));
67 }
68 }
69
70 if (m_CurrentDefectMap->coldCount() > 0)
71 {
72 painter->setPen(QPen(QColor(qRgba(0, 0, 255, 128)), scale));
73 for (BadPixelSet::const_iterator onePixel = m_CurrentDefectMap->coldPixels().cbegin();
74 onePixel != m_CurrentDefectMap->coldThreshold(); ++onePixel)
75 {
76 painter->drawEllipse(QRectF(((*onePixel).x - 1) * scale, ((*onePixel).y - 1) * scale, 2 * scale, 2 * scale));
77 }
78 }
79}
80
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void drawEllipse(const QPoint &center, int rx, int ry)
void setOpacity(qreal opacity)
void setPen(Qt::PenStyle style)
T * data() const const
UniqueConnection
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:57:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.