• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 6685397774

29 Oct 2023 07:37PM UTC coverage: 11.735% (-0.002%) from 11.737%
6685397774

push

github

10110111
Deduplicate title bar implementation

131 of 131 new or added lines in 56 files covered. (100.0%)

14842 of 126472 relevant lines covered (11.74%)

21617.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/Scenery3d/src/gui/Scenery3dDialog.cpp
1
/*
2
 * Stellarium Scenery3d Plug-in
3
 *
4
 * Copyright (C) 2011-2015 Simon Parzer, Peter Neubauer, Georg Zotti, Andrei Borza, Florian Schaukowitsch
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
19
 */
20

21
#include "Scenery3dDialog.hpp"
22
#include "Scenery3dDialog_p.hpp"
23
#include "Scenery3d.hpp"
24
#include "SceneInfo.hpp"
25
#include "S3DEnum.hpp"
26

27
#include "StelModuleMgr.hpp"
28
#include "StelApp.hpp"
29
#include "StelGui.hpp"
30
#include "StelTranslator.hpp"
31
#include "StelActionMgr.hpp"
32

33
#include <QLineEdit>
34
#include <QStandardItemModel>
35
#include <QTimer>
36

37
Scenery3dDialog::Scenery3dDialog(QObject* parent) : StelDialog("Scenery3d", parent), mgr(nullptr)
×
38
{
39
        ui = new Ui_scenery3dDialogForm;
×
40
}
×
41

42
Scenery3dDialog::~Scenery3dDialog()
×
43
{
44
        delete ui;
×
45
}
×
46

47
void Scenery3dDialog::retranslate()
×
48
{
49
        if (dialog)
×
50
        {
51
                ui->retranslateUi(dialog);
×
52

53
                updateToolTipStrings();
×
54

55
                //update description
56
                SceneInfo si = mgr->getLoadingScene(); //the scene that is currently being loaded
×
57
                if(!si.isValid)
×
58
                        si = mgr->getCurrentScene(); //the scene that is currently displayed
×
59
                updateTextBrowser(si);
×
60

61
                for (auto* but : qAsConst(shortcutButtons))
×
62
                {
63
                        //replace stored text with re-translated one
64
                        const QString btClassName=but->metaObject()->className();
×
65
                        if (btClassName == "QGroupBox")
×
66
                                dynamic_cast<QGroupBox*>(but)->setProperty("stelOriginalText",dynamic_cast<QGroupBox*>(but)->title());
×
67
                        else if (btClassName == "QCheckBox")
×
68
                                dynamic_cast<QCheckBox*>(but)->setProperty("stelOriginalText",dynamic_cast<QCheckBox*>(but)->text());
×
69
                        else
70
                                qCritical() << "Scenery3dDialog: UNKNOWN WIDGET TYPE: " << but->metaObject()->className();
×
71
                }
×
72

73
                updateShortcutStrings();
×
74
        }
×
75
}
×
76

77
void Scenery3dDialog::createDialogContent()
×
78
{
79
        //manager should be created at this point
80
        mgr = GETSTELMODULE(Scenery3d);
×
81
        Q_ASSERT(mgr);
×
82

83
        //additionally, Scenery3dMgr::init should have been called to make sure the correct values are set for hardware support
84

85
        //load Ui from form file
86
        ui->setupUi(dialog);
×
87

88
        updateToolTipStrings();
×
89

90
        //hook up retranslate event
91
        connect(&StelApp::getInstance(), &StelApp::languageChanged, this, &Scenery3dDialog::retranslate);
×
92

93
        //change ui a bit
94
        ui->comboBoxCubemapMode->setModel(new CubemapModeListModel(ui->comboBoxCubemapMode));
×
95

96
        //connect UI events
97
        connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
×
98
        connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
×
99
        connect(ui->scenery3dListWidget, &QListWidget::currentItemChanged, this, &Scenery3dDialog::scenery3dChanged);
×
100

101
        //checkboxes can connect directly to manager
102
        //connect(ui->checkBoxEnablePixelLight, SIGNAL(clicked(bool)), mgr, SLOT(setEnablePixelLighting(bool)));
103
        //connect(ui->checkBoxEnableShadows,    SIGNAL(clicked(bool)), mgr, SLOT(setEnableShadows(bool)));
104
        //connect(ui->checkBoxEnableBump,       SIGNAL(clicked(bool)), mgr, SLOT(setEnableBumps(bool)));
105
        //connect(ui->checkBoxEnableLazyDrawing,  &QCheckBox::clicked, mgr, &Scenery3d::setEnableLazyDrawing);
106
        //connect(ui->checkBoxDominantFace,       &QCheckBox::clicked, mgr, &Scenery3d::setOnlyDominantFaceWhenMoving);
107
        //connect(ui->checkBoxSecondDominantFace, &QCheckBox::clicked, mgr, &Scenery3d::setSecondDominantFaceWhenMoving);
108
        //connect(ui->checkBoxPCSS,               &QCheckBox::clicked, mgr, &Scenery3d::setEnablePCSS);
109
        //connect(ui->checkBoxSimpleShadows,      &QCheckBox::clicked, mgr, &Scenery3d::setUseSimpleShadows);
110
        //connect(ui->checkBoxCubemapShadows,     &QCheckBox::clicked, mgr, &Scenery3d::setUseFullCubemapShadows);
111
        //connect(ui->spinLazyDrawingInterval, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), mgr, &Scenery3d::setLazyDrawingInterval);
112

113

114
        connectBoolProperty(ui->ignoreInitialViewCheckBox,         "Scenery3d.ignoreInitialView");
×
115

116
        connectBoolProperty(ui->checkBoxEnablePixelLight,          "Scenery3d.enablePixelLighting");
×
117
        connectBoolProperty(ui->checkBoxEnableShadows,             "Scenery3d.enableShadows");
×
118
        connectBoolProperty(ui->checkBoxEnableBump,                "Scenery3d.enableBumps");
×
119
        connectBoolProperty(ui->checkBoxEnableLazyDrawing,         "Scenery3d.enableLazyDrawing");
×
120
        connectBoolProperty(ui->checkBoxDominantFace,              "Scenery3d.onlyDominantFaceWhenMoving");
×
121
        connectBoolProperty(ui->checkBoxSecondDominantFace,        "Scenery3d.secondDominantFaceWhenMoving");
×
122
        connectBoolProperty(ui->checkBoxPCSS,                      "Scenery3d.enablePCSS");
×
123
        connectDoubleProperty(ui->spinLazyDrawingInterval,         "Scenery3d.lazyDrawingInterval");
×
124
        connectBoolProperty(ui->overdrawLandscapePolylineCheckBox, "Scenery3d.forceHorizonPolyline");
×
125
        connectBoolProperty(ui->checkBoxSimpleShadows,             "Scenery3d.useSimpleShadows");
×
126
        connectBoolProperty(ui->checkBoxCubemapShadows,            "Scenery3d.useFullCubemapShadows");
×
127

128
        //hook up some Scenery3d actions
129
        StelActionMgr* acMgr = StelApp::getInstance().getStelActionManager();
×
130
        StelAction* ac = acMgr->findAction("actionShow_Scenery3d_torchlight");
×
131
        if(ac)
×
132
        {
133
                ui->checkBoxTorchlight->setProperty("stelActionKey",ac->getId());
×
134
                ui->checkBoxTorchlight->setProperty("stelOriginalText",ui->checkBoxTorchlight->text());
×
135
                ui->checkBoxTorchlight->setChecked(ac->isChecked());
×
136
                connect(ac,&StelAction::toggled,ui->checkBoxTorchlight, &QCheckBox::setChecked);
×
137
                connect(ui->checkBoxTorchlight,&QCheckBox::toggled,ac, &StelAction::setChecked);
×
138
                connect(ac,&StelAction::changed,this,&Scenery3dDialog::updateShortcutStrings);
×
139
                shortcutButtons.append(ui->checkBoxTorchlight);
×
140
        }
141
        ac = acMgr->findAction("actionShow_Scenery3d_locationinfo");
×
142
        if(ac)
×
143
        {
144
                connectBoolProperty(ui->gridCoordinatesGroupBox, "Scenery3d.enableLocationInfo");
×
145
                ui->gridCoordinatesGroupBox->setProperty("stelActionKey",ac->getId());
×
146
                ui->gridCoordinatesGroupBox->setProperty("stelOriginalText",ui->gridCoordinatesGroupBox->title());
×
147
                connect(ac,&StelAction::changed,this,&Scenery3dDialog::updateShortcutStrings);
×
148
                shortcutButtons.append(ui->gridCoordinatesGroupBox);
×
149
                ui->radioButton_GCTopRight->setChecked(mgr->getLocationInfoStyle()==S3DRenderer::LocationInfoTopRight);
×
150
                ui->radioButton_GCBottom->setChecked(mgr->getLocationInfoStyle()==S3DRenderer::LocationInfoBottomCenter);
×
151
                connect(ui->radioButton_GCTopRight, SIGNAL(toggled(bool)), this, SLOT(setCoordinateTextStyle()));
×
152
                connect(ui->radioButton_GCBottom, SIGNAL(toggled(bool)), this, SLOT(setCoordinateTextStyle()));
×
153
        }
154

155
        //connectSlotsByName does not work in our case (because this class does not "own" the GUI in the Qt sense)
156
        //the "new" syntax is extremely ugly in case signals have overloads
157
        connect(ui->comboBoxCubemapMode,     static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxCubemapMode_currentIndexChanged);
×
158
        connect(ui->comboBoxShadowFiltering, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxShadowFiltering_currentIndexChanged);
×
159
        connect(ui->comboBoxCubemapSize,     static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxCubemapSize_currentIndexChanged);
×
160
        connect(ui->comboBoxShadowmapSize,   static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxShadowmapSize_currentIndexChanged);
×
161

162
        connect(ui->sliderTorchStrength,  &QSlider::valueChanged, this, &Scenery3dDialog::on_sliderTorchStrength_valueChanged);
×
163
        connect(ui->sliderTorchRange,     &QSlider::valueChanged, this, &Scenery3dDialog::on_sliderTorchRange_valueChanged);
×
164
        connectDoubleProperty(ui->directionalLightPushSpinBox, "Scenery3d.directionalLightPush");
×
165
        connect(ui->checkBoxDefaultScene, &QCheckBox::stateChanged, this, &Scenery3dDialog::on_checkBoxDefaultScene_stateChanged);
×
166

167
        connect(ui->pushButtonOpenStoredViewDialog, &QPushButton::clicked, mgr, &Scenery3d::showStoredViewDialog);
×
168

169
        updateShortcutStrings();
×
170
        createUpdateConnections();
×
171

172
        // Fill the scenery list
173
        QListWidget* l = ui->scenery3dListWidget;
×
174
        l->blockSignals(true);
×
175
        l->clear();
×
176
        QStringList sceneList = SceneInfo::getAllSceneNames();
×
177
        for (const auto &sceneName : sceneList)
×
178
        {
179
                QString label = q_(sceneName);
×
180
                QListWidgetItem* item = new QListWidgetItem(label);
×
181
                item->setData(Qt::UserRole, sceneName);
×
182
                l->addItem(item);
×
183
        }
×
184
        l->sortItems(); // they may have been translated!
×
185

186
        SceneInfo current = mgr->getCurrentScene();
×
187

188
        if(!current.isValid)
×
189
        {
190
                //try to see if there is a scene currently in the loading process, and use this for gui selection
191
                current = mgr->getLoadingScene();
×
192
        }
193

194
        StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
195
        if (gui)
×
196
                ui->scenery3dTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet));
×
197
        ui->checkBoxDefaultScene->setVisible(false);
×
198
        ui->pushButtonOpenStoredViewDialog->setVisible(false);
×
199

200
        if(current.isValid)
×
201
        {
202
                for (int i = 0; i < l->count(); i++)
×
203
                {
204
                        if (l->item(i)->data(Qt::UserRole).toString() == current.name)
×
205
                        {
206
                                l->setCurrentRow(i);
×
207
                                ui->checkBoxDefaultScene->blockSignals(true);
×
208
                                ui->checkBoxDefaultScene->setChecked(current.id == mgr->getDefaultScenery3dID());
×
209
                                ui->checkBoxDefaultScene->blockSignals(false);
×
210
                                ui->checkBoxDefaultScene->setVisible(true);
×
211
                                ui->pushButtonOpenStoredViewDialog->setVisible(true);
×
212
                                break;
×
213
                        }
214
                }
215
                l->blockSignals(false);
×
216
                updateTextBrowser(current);
×
217
        }
218
        l->blockSignals(false);
×
219

220
        //init resolution boxes
221
        initResolutionCombobox(ui->comboBoxCubemapSize);
×
222
        initResolutionCombobox(ui->comboBoxShadowmapSize);
×
223

224
        setToInitialValues();
×
225
}
×
226

227
void Scenery3dDialog::createUpdateConnections()
×
228
{
229
        //connect Scenery3d update events
230
        //connect(mgr, &Scenery3d::enablePixelLightingChanged, ui->checkBoxEnablePixelLight, &QCheckBox::setChecked);
231
        connect(mgr, &Scenery3d::enablePixelLightingChanged, ui->checkBoxEnableShadows, &QCheckBox::setEnabled);
×
232
        connect(mgr, &Scenery3d::enablePixelLightingChanged, ui->checkBoxEnableBump, &QCheckBox::setEnabled);
×
233
        //connect(mgr, &Scenery3d::enableShadowsChanged,       ui->checkBoxEnableShadows, &QCheckBox::setChecked);
234
        //connect(mgr, &Scenery3d::enableBumpsChanged,         ui->checkBoxEnableBump, &QCheckBox::setChecked);
235
        //connect(mgr, &Scenery3d::enablePCSSChanged,          ui->checkBoxPCSS,&QCheckBox::setChecked);
236

237
        connect(mgr, &Scenery3d::enableShadowsChanged, ui->checkBoxSimpleShadows, &QCheckBox::setEnabled);
×
238
        connect(mgr, &Scenery3d::enableShadowsChanged, ui->checkBoxCubemapShadows, &QCheckBox::setEnabled);
×
239
        //connect(mgr, &Scenery3d::useSimpleShadowsChanged, ui->checkBoxSimpleShadows, &QCheckBox::setChecked);
240
        //connect(mgr, &Scenery3d::useFullCubemapShadowsChanged, ui->checkBoxCubemapShadows, &QCheckBox::setChecked);
241

242
        connect(mgr, &Scenery3d::cubemappingModeChanged, ui->comboBoxCubemapMode, &QComboBox::setCurrentIndex);
×
243
        connect(mgr, &Scenery3d::shadowFilterQualityChanged, this, &Scenery3dDialog::updateShadowFilterQuality);
×
244

245
        connect(mgr, &Scenery3d::torchStrengthChanged, this, &Scenery3dDialog::updateTorchStrength);
×
246
        connect(mgr, &Scenery3d::torchRangeChanged, this, &Scenery3dDialog::updateTorchRange);
×
247

248
        //connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->checkBoxEnableLazyDrawing, &QCheckBox::setChecked);
249
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->labelLazyDrawingInterval, &QCheckBox::setEnabled);
×
250
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->spinLazyDrawingInterval, &QCheckBox::setEnabled);
×
251
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->checkBoxDominantFace, &QCheckBox::setEnabled);
×
252
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, this, &Scenery3dDialog::updateSecondDominantFaceEnabled);
×
253

254
        connect(mgr, &Scenery3d::lazyDrawingIntervalChanged, this, &Scenery3dDialog::updateLazyDrawingInterval);
×
255
        //connect(mgr, &Scenery3d::onlyDominantFaceWhenMovingChanged, ui->checkBoxDominantFace, &QCheckBox::setChecked);
256
        connect(mgr, &Scenery3d::onlyDominantFaceWhenMovingChanged, this, &Scenery3dDialog::updateSecondDominantFaceEnabled);
×
257
        //connect(mgr, &Scenery3d::secondDominantFaceWhenMovingChanged, ui->checkBoxSecondDominantFace, &QCheckBox::setChecked);
258

259
        connect(mgr, &Scenery3d::currentSceneChanged, this, &Scenery3dDialog::updateCurrentScene);
×
260
}
×
261

262
void Scenery3dDialog::updateToolTipStrings()
×
263
{
264
        QString toolTipEnablePixelLight = QString("<html><head/><body><p>%1</p><p>%2</p></body></html>")
×
265
                        .arg(q_("Provides more accurate lighting by calculating it per-pixel instead of per-vertex."),
×
266
                             q_("Required for bump mapping and shadows!"));
×
267
        QString toolTipSimpleShadows = QString("<html><head/><body><p>%1</p><p>%2</p></body></html>")
×
268
                        .arg(q_("Uses only a single shadow cascade instead of up to four."),
×
269
                             q_("Provides a speedup in exchange for shadow quality, especially in large scenes."));
×
270
        QString toolTipShadowFiltering = QString("<html><head/><body><p>%1</p><p>%2</p></body></html>")
×
271
                        .arg(q_("Determines how the shadows are filtered, in increasing quality from top to bottom."),
×
272
                             q_("PCSS requires the quality set to LOW or HIGH."));
×
273
        QString toolTipPCSS = QString("<html><head/><body><p>%1</p><p>%2</p><p>%3</p></body></html>")
×
274
                        .arg(q_("Approximate calculation of shadow penumbras (sharper shadows near contact points, blurred shadows further away)."),
×
275
                             q_("Requires <b>LOW</b> or <b>HIGH</b> shadow filtering (without <b>Hardware</b>)."),
×
276
                             q_("Causes a performance hit."));
×
277
        QString toolTipCubemapMode = QString("<html><head/><body><p>%1</p><p>%2</p><p>%3</p><p>%4</p></body></html>")
×
278
                        .arg(q_("This determines the way the scene is rendered when Stellarium uses a projection other than &quot;Perspective&quot;. The scene is always rendered onto a cube, and this cube is then warped according to the real projection. The cube is described using an image called &quot;cubemap&quot;."),
×
279
                             q_("<b>6 Textures</b> uses 6 single textures, one for each cube side. This is the most compatible method, but may be slower than the others."),
×
280
                             q_("<b>Cubemap</b> uses a single GL_TEXTURE_CUBEMAP. Recommended for most users."),
×
281
                             q_("<b>Geometry shader</b> uses a modern GPU feature to render all 6 sides of the cube at once. It may be the fastest method depending on the scene and your GPU hardware. If not supported, this cannot be selected."));
×
282
        QString toolTipCubemapShadows = QString("<html><head/><body><p>%1</p><p>%2</p><p>%3</p></body></html>")
×
283
                        .arg(q_("Calculates shadows for each cubemap face separately."),
×
284
                             q_("If disabled, the shadowed area is calculated using a perspective projection, which may cause missing shadows with high FOV values, but is quite a bit faster!"),
×
285
                             q_("This does not work when using the <b>Geometry shader</b> cubemapping mode!"));
×
286
        QString toolTipEnableLazyDrawing = QString("<html><head/><body><p>%1<br/>%2</p><p><b>%3</b></p></body></html>")
×
287
                        .arg(q_("When checked, the cubemap is only recreated in specific time intervals, instead of each frame."),
×
288
                             q_("Saves energy and may increase subjective application performance."),
×
289
                             q_("Note that the cubemap is always re-rendered when the view position changes."));
×
290
        QString toolTipDominantFace = QString("<html><head/><body><p>%1</p><p>%2</p><p><b>%3</b></p></body></html>")
×
291
                        .arg(q_("When checked, only the face that corresponds to your viewing direction is updated on movement."),
×
292
                             q_("This will speed up rendering, but the appearance will look &quot;broken&quot; until you stop moving."),
×
293
                             q_("This does NOT work with the &quot;Geometry-Shader&quot; cubemapping mode!"));
×
294
        QString toolTipSecondDominantFace = QString("<html><head/><body><p>%1</p></body></html>")
×
295
                        .arg(q_("This updates a second face, so that the visual appearance seems less &quot;broken&quot;."));
×
296

297
        ui->checkBoxEnablePixelLight->setToolTip(toolTipEnablePixelLight);
×
298
        ui->checkBoxSimpleShadows->setToolTip(toolTipSimpleShadows);
×
299
        ui->comboBoxShadowFiltering->setToolTip(toolTipShadowFiltering);
×
300
        ui->checkBoxPCSS->setToolTip(toolTipPCSS);
×
301
        ui->comboBoxCubemapMode->setToolTip(toolTipCubemapMode);
×
302
        ui->checkBoxCubemapShadows->setToolTip(toolTipCubemapShadows);
×
303
        ui->checkBoxEnableLazyDrawing->setToolTip(toolTipEnableLazyDrawing);
×
304
        ui->spinLazyDrawingInterval->setToolTip(q_("The interval (in timeline seconds) in which no redraw is performed"));
×
305
        ui->checkBoxDominantFace->setToolTip(toolTipDominantFace);
×
306
        ui->checkBoxSecondDominantFace->setToolTip(toolTipSecondDominantFace);
×
307
}
×
308

309
void Scenery3dDialog::updateShortcutStrings()
×
310
{
311
        StelActionMgr* acMgr = StelApp::getInstance().getStelActionManager();
×
312

313
        for (auto* bt : shortcutButtons)
×
314
        {
315
                const QString btClassName=bt->metaObject()->className();
×
316
                QVariant v = bt->property("stelActionKey");
×
317
                QVariant t = bt->property("stelOriginalText");
×
318
                if(v.isValid() && t.isValid())
×
319
                {
320
                        QString s = v.toString();
×
321
                        QString text = t.toString();
×
322
                        StelAction* ac = acMgr->findAction(s);
×
323
                        if(ac)
×
324
                        {
325
                                if (btClassName == "QGroupBox")
×
326
                                        dynamic_cast<QGroupBox*>(bt)->setTitle(text.arg(ac->getShortcut().toString(QKeySequence::NativeText)));
×
327
                                else if (btClassName == "QCheckBox")
×
328
                                        dynamic_cast<QCheckBox*>(bt)->setText(text.arg(ac->getShortcut().toString(QKeySequence::NativeText)));
×
329
                                else
330
                                        qCritical() << "Scenery3dDialog: UNKNOWN WIDGET TYPE: " << bt->metaObject()->className();
×
331
                        }
332
                }
×
333
        }
×
334
}
×
335

336
void Scenery3dDialog::initResolutionCombobox(QComboBox *cb)
×
337
{
338
        bool oldval = cb->blockSignals(true);
×
339

340
        uint maxResolution = mgr->getMaximumFramebufferSize();
×
341
        for(uint i = 256;i<=qMin(16384u,maxResolution);i*=2)
×
342
        {
343
                cb->addItem(QString::number(i),i);
×
344
        }
345

346
        cb->blockSignals(oldval);
×
347
}
×
348

349
void Scenery3dDialog::on_comboBoxCubemapSize_currentIndexChanged(int index)
×
350
{
351
        Q_UNUSED(index)
352
        bool ok;
353
        uint val = ui->comboBoxCubemapSize->currentData().toUInt(&ok);
×
354
        if(ok)
×
355
        {
356
                mgr->setCubemapSize(val);
×
357
        }
358
}
×
359

360
void Scenery3dDialog::on_comboBoxShadowmapSize_currentIndexChanged(int index)
×
361
{
362
        Q_UNUSED(index)
363
        bool ok;
364
        uint val = ui->comboBoxShadowmapSize->currentData().toUInt(&ok);
×
365
        if(ok)
×
366
        {
367
                mgr->setShadowmapSize(val);
×
368
        }
369
}
×
370

371
void Scenery3dDialog::on_comboBoxShadowFiltering_currentIndexChanged(int index)
×
372
{
373
        qDebug()<<index;
×
374
        mgr->setShadowFilterQuality(static_cast<S3DEnum::ShadowFilterQuality>(index));
×
375
}
×
376

377
void Scenery3dDialog::on_comboBoxCubemapMode_currentIndexChanged(int index)
×
378
{
379
        mgr->setCubemappingMode(static_cast<S3DEnum::CubemappingMode>(index));
×
380
}
×
381

382
void Scenery3dDialog::on_sliderTorchStrength_valueChanged(int value)
×
383
{
384
        float val =  (static_cast<float>(value))  / ui->sliderTorchStrength->maximum();
×
385
        mgr->setTorchStrength(val);
×
386
}
×
387

388
void Scenery3dDialog::on_sliderTorchRange_valueChanged(int value)
×
389
{
390
        float val = value / 100.0f;
×
391
        mgr->setTorchRange(val);
×
392
}
×
393

394
void Scenery3dDialog::updateCurrentScene(const SceneInfo &sceneInfo)
×
395
{
396
        if(sceneInfo.isValid)
×
397
        {
398
                ui->scenery3dListWidget->blockSignals(true);
×
399
                QList<QListWidgetItem*> currentItems = ui->scenery3dListWidget->findItems(sceneInfo.name, Qt::MatchExactly);
×
400
                if(!currentItems.isEmpty())
×
401
                {
402
                        ui->scenery3dListWidget->setCurrentItem(currentItems.at(0));
×
403
                }
404
                ui->scenery3dListWidget->blockSignals(false);
×
405
                updateTextBrowser(sceneInfo);
×
406

407
                ui->checkBoxDefaultScene->blockSignals(true);
×
408
                ui->checkBoxDefaultScene->setVisible(true);
×
409
                ui->pushButtonOpenStoredViewDialog->setVisible(true);
×
410
                ui->checkBoxDefaultScene->setChecked(sceneInfo.id == mgr->getDefaultScenery3dID());
×
411
                ui->checkBoxDefaultScene->blockSignals(false);
×
412
        }
×
413
}
×
414

415
void Scenery3dDialog::on_checkBoxDefaultScene_stateChanged(int value)
×
416
{
417
        QList<QListWidgetItem*> sel = ui->scenery3dListWidget->selectedItems();
×
418
        if(sel.size()==0)
×
419
                return;
×
420

421
        if(value)
×
422
        {
423
                QString id = SceneInfo::getIDFromName(sel.at(0)->data(Qt::UserRole).toString());
×
424
                if(!id.isEmpty())
×
425
                        mgr->setDefaultScenery3dID(id);
×
426
        }
×
427
        else
428
                mgr->setDefaultScenery3dID("");
×
429
}
×
430

431
void Scenery3dDialog::scenery3dChanged(QListWidgetItem* item)
×
432
{
433
        SceneInfo info = mgr->loadScenery3dByName(item->data(Qt::UserRole).toString());
×
434

435
        if(info.isValid) //this if makes sure the .ini has been loaded
×
436
        {
437
                ui->checkBoxDefaultScene->blockSignals(true);
×
438
                ui->checkBoxDefaultScene->setChecked(info.id == mgr->getDefaultScenery3dID());
×
439
                ui->checkBoxDefaultScene->blockSignals(false);
×
440

441
                updateTextBrowser(info);
×
442
                ui->checkBoxDefaultScene->setVisible(true);
×
443
        }
444
        else
445
        {
446
                ui->pushButtonOpenStoredViewDialog->setVisible(false);
×
447
                ui->checkBoxDefaultScene->setVisible(false);
×
448
                ui->checkBoxDefaultScene->setChecked(false);
×
449
        }
450
}
×
451

452
void Scenery3dDialog::updateTextBrowser(const SceneInfo &si)
×
453
{
454
        if(!si.isValid)
×
455
        {
456
                ui->scenery3dTextBrowser->setHtml("");
×
457
                ui->scenery3dTextBrowser->setSearchPaths(QStringList());
×
458
        }
459
        else
460
        {
461
                QStringList list;
×
462
                list<<si.fullPath;
×
463
                ui->scenery3dTextBrowser->setSearchPaths(list);
×
464

465
                //first, try to find a localized description
466
                QString desc = si.getLocalizedHTMLDescription();
×
467
                if(desc.isEmpty())
×
468
                {
469
                        //use the "old" way to create an description from data contained in the .ini
470
                        desc = QString("<h3>%1</h3>").arg(si.name);
×
471
                        desc+= si.description;
×
472
                        desc+="<br><br>";
×
473
                        desc+="<b>"+q_("Author")+":</b>";
×
474
                        desc+= si.author;
×
475
                }
476

477
                ui->scenery3dTextBrowser->setHtml(desc);
×
478
        }
×
479
}
×
480

481
void Scenery3dDialog::setResolutionCombobox(QComboBox *cb, uint val)
×
482
{
483
        cb->blockSignals(true);
×
484
        int idx = cb->findData(val);
×
485
        if(idx>=0)
×
486
        {
487
                //valid entry
488
                cb->setCurrentIndex(idx);
×
489
        }
490
        else
491
        {
492
                //add entry for the current value, making sure it is at first place
493
                cb->clear();
×
494
                cb->addItem(QString::number(val),val);
×
495
                initResolutionCombobox(cb);
×
496
                cb->setCurrentIndex(0);
×
497
        }
498
        cb->blockSignals(false);
×
499
}
×
500

501
void Scenery3dDialog::updateShadowFilterQuality(S3DEnum::ShadowFilterQuality quality)
×
502
{
503
        ui->checkBoxPCSS->setEnabled(quality == S3DEnum::SFQ_HIGH || quality == S3DEnum::SFQ_LOW);
×
504
        ui->comboBoxShadowFiltering->setCurrentIndex(quality);
×
505
}
×
506

507
void Scenery3dDialog::updateTorchRange(float val)
×
508
{
509
        ui->sliderTorchRange->blockSignals(true);
×
510
        ui->sliderTorchRange->setValue(static_cast<int>(val * 100.0f));
×
511
        ui->sliderTorchRange->blockSignals(false);
×
512
}
×
513

514
void Scenery3dDialog::updateTorchStrength(float val)
×
515
{
516
        ui->sliderTorchStrength->blockSignals(true);
×
517
        ui->sliderTorchStrength->setValue(static_cast<int>(val * 100.0f));
×
518
        ui->sliderTorchStrength->blockSignals(false);
×
519
}
×
520

521
void Scenery3dDialog::updateLazyDrawingInterval(double val)
×
522
{
523
        ui->spinLazyDrawingInterval->blockSignals(true);
×
524
        ui->spinLazyDrawingInterval->setValue(val);
×
525
        ui->spinLazyDrawingInterval->blockSignals(false);
×
526
}
×
527

528
void Scenery3dDialog::updateSecondDominantFaceEnabled()
×
529
{
530
        ui->checkBoxSecondDominantFace->setEnabled(mgr->getOnlyDominantFaceWhenMoving() && mgr->getEnableLazyDrawing());
×
531
}
×
532

533
// Update the widget to make sure it is synchrone if a value was changed programmatically
534
void Scenery3dDialog::setToInitialValues()
×
535
{
536
        bool pix = mgr->getEnablePixelLighting();
×
537
        //ui->checkBoxEnablePixelLight->setChecked(pix);
538

539
        //ui->checkBoxEnableBump->setChecked(mgr->getEnableBumps());
540
        ui->checkBoxEnableBump->setEnabled(pix);
×
541
        //ui->checkBoxEnableShadows->setChecked(mgr->getEnableShadows());
542
        ui->checkBoxEnableShadows->setEnabled(pix);
×
543
        //ui->checkBoxPCSS->setChecked(mgr->getEnablePCSS());
544

545
        ui->checkBoxSimpleShadows->setEnabled(mgr->getEnableShadows());
×
546
        ui->checkBoxCubemapShadows->setEnabled(mgr->getEnableShadows());
×
547
        //ui->checkBoxSimpleShadows->setChecked(mgr->getUseSimpleShadows());
548
        //ui->checkBoxCubemapShadows->setChecked(mgr->getUseFullCubemapShadows());
549

550
        updateShadowFilterQuality(mgr->getShadowFilterQuality());
×
551

552
        ui->comboBoxCubemapMode->setCurrentIndex(mgr->getCubemappingMode());
×
553

554
        updateTorchStrength(mgr->getTorchStrength());
×
555
        updateTorchRange(mgr->getTorchRange());
×
556

557
        bool lazy = mgr->getEnableLazyDrawing();
×
558
        //ui->checkBoxEnableLazyDrawing->setChecked(val);
559

560
        //ui->checkBoxDominantFace->setChecked(mgr->getOnlyDominantFaceWhenMoving());
561
        updateSecondDominantFaceEnabled();
×
562
        //ui->checkBoxSecondDominantFace->setChecked(mgr->getSecondDominantFaceWhenMoving());
563

564
        ui->labelLazyDrawingInterval->setEnabled(lazy);
×
565
        ui->spinLazyDrawingInterval->setEnabled(lazy);
×
566
        ui->checkBoxDominantFace->setEnabled(lazy);
×
567

568
        updateLazyDrawingInterval(mgr->getLazyDrawingInterval());
×
569

570
        setResolutionCombobox(ui->comboBoxCubemapSize,mgr->getCubemapSize());
×
571
        setResolutionCombobox(ui->comboBoxShadowmapSize,mgr->getShadowmapSize());
×
572

573
        //hide some stuff depending on hardware support
574
        if(!mgr->getIsShadowFilteringSupported())
×
575
        {
576
                ui->labelFilterQuality->setVisible(false);
×
577
                ui->comboBoxShadowFiltering->setVisible(false);
×
578
                ui->checkBoxPCSS->setVisible(false);
×
579
        }
580

581
        if(!mgr->getAreShadowsSupported())
×
582
        {
583
                ui->labelShadowmapSize->setVisible(false);
×
584
                ui->comboBoxShadowmapSize->setVisible(false);
×
585
                ui->checkBoxEnableShadows->setVisible(false);
×
586
                ui->checkBoxCubemapShadows->setVisible(false);
×
587
                ui->checkBoxSimpleShadows->setVisible(false);
×
588
        }
589
}
×
590

591
// Connect to the RadioButtons to set coordinate text output
592
void Scenery3dDialog::setCoordinateTextStyle()
×
593
{
594
        if (ui->radioButton_GCTopRight->isChecked())
×
595
                mgr->setLocationInfoStyle(S3DRenderer::LocationInfoTopRight);
×
596
        else if (ui->radioButton_GCBottom->isChecked())
×
597
                mgr->setLocationInfoStyle(S3DRenderer::LocationInfoBottomCenter);
×
598
        else
599
                qCritical() << "Scenery3dDialog: Problem with determining coordinate output!";
×
600
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc