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 <[email protected]>
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 
20 DarkView::DarkView(QWidget *parent, FITSMode mode, FITSScale filter) : FITSView(parent, mode, filter)
21 {
22 }
23 
24 void 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 
35 void DarkView::reset()
36 {
37  m_CurrentDefectMap.clear();
38 }
39 
40 void DarkView::setDefectMapEnabled(bool enabled)
41 {
42  if (m_DefectMapEnabled == enabled)
43  return;
44 
45  m_DefectMapEnabled = enabled;
46  updateFrame();
47 }
48 
49 void 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 
55 void 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 
void setPen(const QColor &color)
void drawEllipse(const QRectF &rectangle)
QFuture< void > filter(Sequence &sequence, KeepFunctor filterFunction)
UniqueConnection
void setOpacity(qreal opacity)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.