Kstars

opscatalog.cpp
1/*
2 SPDX-FileCopyrightText: 2004 Jason Harris <jharris@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "opscatalog.h"
8
9#include "kstars.h"
10#include "kstarsdata.h"
11#include "Options.h"
12#include "skymap.h"
13#include "skycomponents/catalogscomponent.h"
14#include "skycomponents/skymapcomposite.h"
15#include "widgets/magnitudespinbox.h"
16#include "skyobject.h"
17
18#include <KActionCollection>
19#include <KConfigDialog>
20
21#include <QList>
22#include <QListWidgetItem>
23#include <QTextStream>
24#include <QFileDialog>
25
26OpsCatalog::OpsCatalog() : QFrame(KStars::Instance())
27{
28 setupUi(this);
29
30 //Get a pointer to the KConfigDialog
31 m_ConfigDialog = KConfigDialog::exists("settings");
32
33 // kcfg_MagLimitDrawStar->setValue( Options::magLimitDrawStar() );
34 kcfg_StarDensity->setValue(Options::starDensity());
35 // kcfg_MagLimitDrawStarZoomOut->setValue( Options::magLimitDrawStarZoomOut() );
36 // m_MagLimitDrawStar = kcfg_MagLimitDrawStar->value();
37 m_StarDensity = kcfg_StarDensity->value();
38 // m_MagLimitDrawStarZoomOut = kcfg_MagLimitDrawStarZoomOut->value();
39
40 // kcfg_MagLimitDrawStar->setMinimum( Options::magLimitDrawStarZoomOut() );
41 // kcfg_MagLimitDrawStarZoomOut->setMaximum( 12.0 );
42
43 kcfg_DSOCachePercentage->setValue(Options::dSOCachePercentage());
44 connect(kcfg_DSOCachePercentage, &QSlider::valueChanged, this,
45 [&] { isDirty = true; });
46
47 kcfg_DSOMinZoomFactor->setValue(Options::dSOMinZoomFactor());
48 connect(kcfg_DSOMinZoomFactor, &QSlider::valueChanged, this, [&] { isDirty = true; });
49
50 kcfg_ShowUnknownMagObjects->setChecked(Options::showUnknownMagObjects());
51 connect(kcfg_ShowUnknownMagObjects, &QCheckBox::stateChanged, this,
52 [&] { isDirty = true; });
53
54 //disable star-related widgets if not showing stars
55 if (!kcfg_ShowStars->isChecked())
56 slotStarWidgets(false);
57
58 /*
59 connect( kcfg_MagLimitDrawStar, SIGNAL(valueChanged(double)),
60 SLOT(slotSetDrawStarMagnitude(double)) );
61 connect( kcfg_MagLimitDrawStarZoomOut, SIGNAL(valueChanged(double)),
62 SLOT(slotSetDrawStarZoomOutMagnitude(double)) );
63 */
64 connect(kcfg_ShowStars, SIGNAL(toggled(bool)), SLOT(slotStarWidgets(bool)));
65 connect(kcfg_ShowDeepSky, SIGNAL(toggled(bool)), SLOT(slotDeepSkyWidgets(bool)));
66 connect(kcfg_ShowDeepSkyNames, SIGNAL(toggled(bool)), kcfg_DeepSkyLongLabels,
67 SLOT(setEnabled(bool)));
68 connect(m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()),
69 SLOT(slotApply()));
70 connect(m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()),
71 SLOT(slotApply()));
72 connect(m_ConfigDialog->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
73 SLOT(slotCancel()));
74
77
78 // Make sure the zoomed-out limit is always brighter than the
79 // zoomed-in limit to avoid weird behavior
80 kcfg_MagLimitDrawDeepSky->setMaximum(FAINTEST_MAGNITUDE);
81 connect(kcfg_MagLimitDrawDeepSky, &QDoubleSpinBox::editingFinished,
82 [&]() {
83 kcfg_MagLimitDrawDeepSkyZoomOut->setMaximum(kcfg_MagLimitDrawDeepSky->value());
84 });
85
86 isDirty = false;
87}
88
89void OpsCatalog::slotApply()
90{
91 if (isDirty == false)
92 return;
93
94 isDirty = false;
95
96 Options::setStarDensity(kcfg_StarDensity->value());
97 // Options::setMagLimitDrawStarZoomOut( kcfg_MagLimitDrawStarZoomOut->value() );
98
99 //FIXME: need to add the ShowDeepSky meta-option to the config dialog!
100 //For now, I'll set showDeepSky to true if any catalog options changed
101
102 KStars::Instance()->data()->skyComposite()->reloadDeepSky();
103
104 // update time for all objects because they might be not initialized
105 // it's needed when using horizontal coordinates
109
110 Options::setDSOCachePercentage(kcfg_DSOCachePercentage->value());
111 KStars::Instance()->data()->skyComposite()->catalogsComponent()->resizeCache(
112 kcfg_DSOCachePercentage->value());
113
114 Options::setDSOMinZoomFactor(kcfg_DSOMinZoomFactor->value());
115 Options::setShowUnknownMagObjects(kcfg_ShowUnknownMagObjects->isChecked());
116}
117
118void OpsCatalog::slotCancel()
119{
120 //Revert all local option placeholders to the values in the global config object
121 // m_MagLimitDrawStar = Options::magLimitDrawStar();
122 m_StarDensity = Options::starDensity();
123 // m_MagLimitDrawStarZoomOut = Options::magLimitDrawStarZoomOut();
124}
125
126void OpsCatalog::slotStarWidgets(bool on)
127{
128 // LabelMagStars->setEnabled(on);
129 LabelStarDensity->setEnabled(on);
130 // LabelMagStarsZoomOut->setEnabled(on);
131 LabelDensity->setEnabled(on);
132 // LabelMag1->setEnabled(on);
133 // LabelMag2->setEnabled(on);
134 // kcfg_MagLimitDrawStar->setEnabled(on);
135 kcfg_StarDensity->setEnabled(on);
136 LabelStarDensity->setEnabled(on);
137 // kcfg_MagLimitDrawStarZoomOut->setEnabled(on);
138 kcfg_StarLabelDensity->setEnabled(on);
139 kcfg_ShowStarNames->setEnabled(on);
140 kcfg_ShowStarMagnitudes->setEnabled(on);
141}
142
143void OpsCatalog::slotDeepSkyWidgets(bool on)
144{
145 LabelMagDeepSky->setEnabled(on);
146 LabelMagDeepSkyZoomOut->setEnabled(on);
147 kcfg_MagLimitDrawDeepSky->setEnabled(on);
148 kcfg_MagLimitDrawDeepSkyZoomOut->setEnabled(on);
149 kcfg_ShowDeepSkyNames->setEnabled(on);
150 kcfg_ShowDeepSkyMagnitudes->setEnabled(on);
151 kcfg_DSOCachePercentage->setEnabled(on);
152 DSOCacheLabel->setEnabled(on);
153 kcfg_DSOMinZoomFactor->setEnabled(on);
154 kcfg_ShowUnknownMagObjects->setEnabled(on);
155 DSOMInZoomLabel->setEnabled(on);
156 DeepSkyLabelDensityLabel->setEnabled(on);
157 kcfg_DeepSkyLabelDensity->setEnabled(on);
158 kcfg_DeepSkyLongLabels->setEnabled(on);
159 LabelMag3->setEnabled(on);
160 LabelMag4->setEnabled(on);
161}
void resizeCache(const int percentage)
Set the cache size to the new percentage.
static KConfigDialog * exists(const QString &name)
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
SkyMapComposite * skyComposite()
Definition kstarsdata.h:168
This is the main window for KStars.
Definition kstars.h:89
SkyMap * map() const
Definition kstars.h:139
static KStars * Instance()
Definition kstars.h:121
void slotDSOCatalogGUI()
Show the DSO Catalog Management GUI.
KStarsData * data() const
Definition kstars.h:133
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition kstars.cpp:592
void forceUpdate(bool now=false)
Recalculates the positions of objects in the sky, and then repaints the sky map.
Definition skymap.cpp:1173
void clicked(bool checked)
void valueChanged(int value)
void editingFinished()
void stateChanged(int state)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.