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

Stellarium / stellarium / 4853788370

pending completion
4853788370

push

github

Alexander V. Wolf
Special patch for John Simple

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

14729 of 125046 relevant lines covered (11.78%)

20166.5 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(Q_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
                        but->setProperty("stelOriginalText",but->text());
×
65
                }
66

67
                updateShortcutStrings();
×
68
        }
×
69
}
×
70

71
void Scenery3dDialog::createDialogContent()
×
72
{
73
        //manager should be created at this point
74
        mgr = GETSTELMODULE(Scenery3d);
×
75
        Q_ASSERT(mgr);
×
76

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

79
        //load Ui from form file
80
        ui->setupUi(dialog);
×
81

82
        updateToolTipStrings();
×
83

84
        //hook up retranslate event
85
        connect(&StelApp::getInstance(), &StelApp::languageChanged, this, &Scenery3dDialog::retranslate);
×
86

87
        //change ui a bit
88
        ui->comboBoxCubemapMode->setModel(new CubemapModeListModel(ui->comboBoxCubemapMode));
×
89

90
        //connect UI events
91
        connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
×
92
        connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
×
93
        connect(ui->scenery3dListWidget, &QListWidget::currentItemChanged, this, &Scenery3dDialog::scenery3dChanged);
×
94

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

107
        connectBoolProperty(ui->checkBoxEnablePixelLight,          "Scenery3d.enablePixelLighting");
×
108
        connectBoolProperty(ui->checkBoxEnableShadows,             "Scenery3d.enableShadows");
×
109
        connectBoolProperty(ui->checkBoxEnableBump,                "Scenery3d.enableBumps");
×
110
        connectBoolProperty(ui->checkBoxEnableLazyDrawing,         "Scenery3d.enableLazyDrawing");
×
111
        connectBoolProperty(ui->checkBoxDominantFace,              "Scenery3d.onlyDominantFaceWhenMoving");
×
112
        connectBoolProperty(ui->checkBoxSecondDominantFace,        "Scenery3d.secondDominantFaceWhenMoving");
×
113
        connectBoolProperty(ui->checkBoxPCSS,                      "Scenery3d.enablePCSS");
×
114
        connectDoubleProperty(ui->spinLazyDrawingInterval,         "Scenery3d.lazyDrawingInterval");
×
115
        connectBoolProperty(ui->overdrawLandscapePolylineCheckBox, "Scenery3d.forceHorizonPolyline");
×
116
        connectBoolProperty(ui->checkBoxSimpleShadows,             "Scenery3d.useSimpleShadows");
×
117
        connectBoolProperty(ui->checkBoxCubemapShadows,            "Scenery3d.useFullCubemapShadows");
×
118

119
        //hook up some Scenery3d actions
120
        StelActionMgr* acMgr = StelApp::getInstance().getStelActionManager();
×
121
        StelAction* ac = acMgr->findAction("actionShow_Scenery3d_torchlight");
×
122
        if(ac)
×
123
        {
124
                ui->checkBoxTorchlight->setProperty("stelActionKey",ac->getId());
×
125
                ui->checkBoxTorchlight->setProperty("stelOriginalText",ui->checkBoxTorchlight->text());
×
126
                ui->checkBoxTorchlight->setChecked(ac->isChecked());
×
127
                connect(ac,&StelAction::toggled,ui->checkBoxTorchlight, &QCheckBox::setChecked);
×
128
                connect(ui->checkBoxTorchlight,&QCheckBox::toggled,ac, &StelAction::setChecked);
×
129
                connect(ac,&StelAction::changed,this,&Scenery3dDialog::updateShortcutStrings);
×
130
                shortcutButtons.append(ui->checkBoxTorchlight);
×
131
        }
132
        ac = acMgr->findAction("actionShow_Scenery3d_locationinfo");
×
133
        if(ac)
×
134
        {
135
                ui->checkBoxShowGridCoordinates->setProperty("stelActionKey",ac->getId());
×
136
                ui->checkBoxShowGridCoordinates->setProperty("stelOriginalText",ui->checkBoxShowGridCoordinates->text());
×
137
                ui->checkBoxShowGridCoordinates->setChecked(ac->isChecked());
×
138
                connect(ac,&StelAction::toggled,ui->checkBoxShowGridCoordinates, &QCheckBox::setChecked);
×
139
                connect(ui->checkBoxShowGridCoordinates,&QCheckBox::toggled,ac, &StelAction::setChecked);
×
140
                connect(ac,&StelAction::changed,this,&Scenery3dDialog::updateShortcutStrings);
×
141
                shortcutButtons.append(ui->checkBoxShowGridCoordinates);
×
142
        }
143

144
        //connectSlotsByName does not work in our case (because this class does not "own" the GUI in the Qt sense)
145
        //the "new" syntax is extremely ugly in case signals have overloads
146
        connect(ui->comboBoxCubemapMode,     static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxCubemapMode_currentIndexChanged);
×
147
        connect(ui->comboBoxShadowFiltering, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxShadowFiltering_currentIndexChanged);
×
148
        connect(ui->comboBoxCubemapSize,     static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxCubemapSize_currentIndexChanged);
×
149
        connect(ui->comboBoxShadowmapSize,   static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Scenery3dDialog::on_comboBoxShadowmapSize_currentIndexChanged);
×
150

151
        connect(ui->sliderTorchStrength,  &QSlider::valueChanged, this, &Scenery3dDialog::on_sliderTorchStrength_valueChanged);
×
152
        connect(ui->sliderTorchRange,     &QSlider::valueChanged, this, &Scenery3dDialog::on_sliderTorchRange_valueChanged);
×
153
        connect(ui->checkBoxDefaultScene, &QCheckBox::stateChanged, this, &Scenery3dDialog::on_checkBoxDefaultScene_stateChanged);
×
154

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

157
        updateShortcutStrings();
×
158
        createUpdateConnections();
×
159

160
        // Fill the scenery list
161
        QListWidget* l = ui->scenery3dListWidget;
×
162
        l->blockSignals(true);
×
163
        l->clear();
×
164
        QStringList sceneList = SceneInfo::getAllSceneNames();
×
165
        for (const auto &sceneName : sceneList)
×
166
        {
167
                QString label = q_(sceneName);
×
168
                QListWidgetItem* item = new QListWidgetItem(label);
×
169
                item->setData(Qt::UserRole, sceneName);
×
170
                l->addItem(item);
×
171
        }
×
172
        l->sortItems(); // they may have been translated!
×
173

174
        SceneInfo current = mgr->getCurrentScene();
×
175

176
        if(!current.isValid)
×
177
        {
178
                //try to see if there is a scene currently in the loading process, and use this for gui selection
179
                current = mgr->getLoadingScene();
×
180
        }
181

182
        StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
×
183
        if (gui)
×
184
                ui->scenery3dTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet));
×
185
        ui->checkBoxDefaultScene->setVisible(false);
×
186
        ui->pushButtonOpenStoredViewDialog->setVisible(false);
×
187

188
        if(current.isValid)
×
189
        {
190
                for (int i = 0; i < l->count(); i++)
×
191
                {
192
                        if (l->item(i)->data(Qt::UserRole).toString() == current.name)
×
193
                        {
194
                                l->setCurrentRow(i);
×
195
                                ui->checkBoxDefaultScene->blockSignals(true);
×
196
                                ui->checkBoxDefaultScene->setChecked(current.id == mgr->getDefaultScenery3dID());
×
197
                                ui->checkBoxDefaultScene->blockSignals(false);
×
198
                                ui->checkBoxDefaultScene->setVisible(true);
×
199
                                ui->pushButtonOpenStoredViewDialog->setVisible(true);
×
200
                                break;
×
201
                        }
202
                }
203
                l->blockSignals(false);
×
204
                updateTextBrowser(current);
×
205
        }
206
        l->blockSignals(false);
×
207

208
        //init resolution boxes
209
        initResolutionCombobox(ui->comboBoxCubemapSize);
×
210
        initResolutionCombobox(ui->comboBoxShadowmapSize);
×
211

212
        setToInitialValues();
×
213
}
×
214

215
void Scenery3dDialog::createUpdateConnections()
×
216
{
217
        //connect Scenery3d update events
218
        //connect(mgr, &Scenery3d::enablePixelLightingChanged, ui->checkBoxEnablePixelLight, &QCheckBox::setChecked);
219
        connect(mgr, &Scenery3d::enablePixelLightingChanged, ui->checkBoxEnableShadows, &QCheckBox::setEnabled);
×
220
        connect(mgr, &Scenery3d::enablePixelLightingChanged, ui->checkBoxEnableBump, &QCheckBox::setEnabled);
×
221
        //connect(mgr, &Scenery3d::enableShadowsChanged,       ui->checkBoxEnableShadows, &QCheckBox::setChecked);
222
        //connect(mgr, &Scenery3d::enableBumpsChanged,         ui->checkBoxEnableBump, &QCheckBox::setChecked);
223
        //connect(mgr, &Scenery3d::enablePCSSChanged,          ui->checkBoxPCSS,&QCheckBox::setChecked);
224

225
        connect(mgr, &Scenery3d::enableShadowsChanged, ui->checkBoxSimpleShadows, &QCheckBox::setEnabled);
×
226
        connect(mgr, &Scenery3d::enableShadowsChanged, ui->checkBoxCubemapShadows, &QCheckBox::setEnabled);
×
227
        //connect(mgr, &Scenery3d::useSimpleShadowsChanged, ui->checkBoxSimpleShadows, &QCheckBox::setChecked);
228
        //connect(mgr, &Scenery3d::useFullCubemapShadowsChanged, ui->checkBoxCubemapShadows, &QCheckBox::setChecked);
229

230
        connect(mgr, &Scenery3d::cubemappingModeChanged, ui->comboBoxCubemapMode, &QComboBox::setCurrentIndex);
×
231
        connect(mgr, &Scenery3d::shadowFilterQualityChanged, this, &Scenery3dDialog::updateShadowFilterQuality);
×
232

233
        connect(mgr, &Scenery3d::torchStrengthChanged, this, &Scenery3dDialog::updateTorchStrength);
×
234
        connect(mgr, &Scenery3d::torchRangeChanged, this, &Scenery3dDialog::updateTorchRange);
×
235

236
        //connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->checkBoxEnableLazyDrawing, &QCheckBox::setChecked);
237
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->labelLazyDrawingInterval, &QCheckBox::setEnabled);
×
238
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->spinLazyDrawingInterval, &QCheckBox::setEnabled);
×
239
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, ui->checkBoxDominantFace, &QCheckBox::setEnabled);
×
240
        connect(mgr, &Scenery3d::enableLazyDrawingChanged, this, &Scenery3dDialog::updateSecondDominantFaceEnabled);
×
241

242
        connect(mgr, &Scenery3d::lazyDrawingIntervalChanged, this, &Scenery3dDialog::updateLazyDrawingInterval);
×
243
        //connect(mgr, &Scenery3d::onlyDominantFaceWhenMovingChanged, ui->checkBoxDominantFace, &QCheckBox::setChecked);
244
        connect(mgr, &Scenery3d::onlyDominantFaceWhenMovingChanged, this, &Scenery3dDialog::updateSecondDominantFaceEnabled);
×
245
        //connect(mgr, &Scenery3d::secondDominantFaceWhenMovingChanged, ui->checkBoxSecondDominantFace, &QCheckBox::setChecked);
246

247
        connect(mgr, &Scenery3d::currentSceneChanged, this, &Scenery3dDialog::updateCurrentScene);
×
248
}
×
249

250
void Scenery3dDialog::updateToolTipStrings()
×
251
{
252
        QString toolTipEnablePixelLight = QString("<html><head/><body><p>%1</p><p>%2</p></body></html>")
×
253
                        .arg(q_("Provides more accurate lighting by calculating it per-pixel instead of per-vertex."),
×
254
                             q_("Required for bump mapping and shadows!"));
×
255
        QString toolTipSimpleShadows = QString("<html><head/><body><p>%1</p><p>%2</p></body></html>")
×
256
                        .arg(q_("Uses only a single shadow cascade instead of up to four."),
×
257
                             q_("Provides a speedup in exchange for shadow quality, especially in large scenes."));
×
258
        QString toolTipShadowFiltering = QString("<html><head/><body><p>%1</p><p>%2</p></body></html>")
×
259
                        .arg(q_("Determines how the shadows are filtered, in increasing quality from top to bottom."),
×
260
                             q_("PCSS requires the quality set to LOW or HIGH."));
×
261
        QString toolTipPCSS = QString("<html><head/><body><p>%1</p><p>%2</p><p>%3</p></body></html>")
×
262
                        .arg(q_("Approximate calculation of shadow penumbras (sharper shadows near contact points, blurred shadows further away)."),
×
263
                             q_("Requires <b>LOW</b> or <b>HIGH</b> shadow filtering (without <b>Hardware</b>)."),
×
264
                             q_("Causes a performance hit."));
×
265
        QString toolTipCubemapMode = QString("<html><head/><body><p>%1</p><p>%2</p><p>%3</p><p>%4</p></body></html>")
×
266
                        .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;."),
×
267
                             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."),
×
268
                             q_("<b>Cubemap</b> uses a single GL_TEXTURE_CUBEMAP. Recommended for most users."),
×
269
                             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."));
×
270
        QString toolTipCubemapShadows = QString("<html><head/><body><p>%1</p><p>%2</p><p>%3</p></body></html>")
×
271
                        .arg(q_("Calculates shadows for each cubemap face separately."),
×
272
                             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!"),
×
273
                             q_("This does not work when using the <b>Geometry shader</b> cubemapping mode!"));
×
274
        QString toolTipEnableLazyDrawing = QString("<html><head/><body><p>%1<br/>%2</p><p><b>%3</b></p></body></html>")
×
275
                        .arg(q_("When checked, the cubemap is only recreated in specific time intervals, instead of each frame."),
×
276
                             q_("Saves energy and may increase subjective application performance."),
×
277
                             q_("Note that the cubemap is always re-rendered when the view position changes."));
×
278
        QString toolTipDominantFace = QString("<html><head/><body><p>%1</p><p>%2</p><p><b>%3</b></p></body></html>")
×
279
                        .arg(q_("When checked, only the face that corresponds to your viewing direction is updated on movement."),
×
280
                             q_("This will speed up rendering, but the appearance will look &quot;broken&quot; until you stop moving."),
×
281
                             q_("This does NOT work with the &quot;Geometry-Shader&quot; cubemapping mode!"));
×
282
        QString toolTipSecondDominantFace = QString("<html><head/><body><p>%1</p></body></html>")
×
283
                        .arg(q_("This updates a second face, so that the visual appearance seems less &quot;broken&quot;."));
×
284

285
        ui->checkBoxEnablePixelLight->setToolTip(toolTipEnablePixelLight);
×
286
        ui->checkBoxSimpleShadows->setToolTip(toolTipSimpleShadows);
×
287
        ui->comboBoxShadowFiltering->setToolTip(toolTipShadowFiltering);
×
288
        ui->checkBoxPCSS->setToolTip(toolTipPCSS);
×
289
        ui->comboBoxCubemapMode->setToolTip(toolTipCubemapMode);
×
290
        ui->checkBoxCubemapShadows->setToolTip(toolTipCubemapShadows);
×
291
        ui->checkBoxEnableLazyDrawing->setToolTip(toolTipEnableLazyDrawing);
×
292
        ui->spinLazyDrawingInterval->setToolTip(q_("The interval (in timeline seconds) in which no redraw is performed"));
×
293
        ui->checkBoxDominantFace->setToolTip(toolTipDominantFace);
×
294
        ui->checkBoxSecondDominantFace->setToolTip(toolTipSecondDominantFace);
×
295
}
×
296

297
void Scenery3dDialog::updateShortcutStrings()
×
298
{
299
        StelActionMgr* acMgr = StelApp::getInstance().getStelActionManager();
×
300

301
        for (auto* bt : shortcutButtons)
×
302
        {
303
                QVariant v = bt->property("stelActionKey");
×
304
                QVariant t = bt->property("stelOriginalText");
×
305
                if(v.isValid() && t.isValid())
×
306
                {
307
                        QString s = v.toString();
×
308
                        QString text = t.toString();
×
309
                        StelAction* ac = acMgr->findAction(s);
×
310
                        if(ac)
×
311
                        {
312
                                bt->setText(text.arg(ac->getShortcut().toString(QKeySequence::NativeText)));
×
313
                        }
314
                }
×
315
        }
×
316
}
×
317

318
void Scenery3dDialog::initResolutionCombobox(QComboBox *cb)
×
319
{
320
        bool oldval = cb->blockSignals(true);
×
321

322
        uint maxResolution = mgr->getMaximumFramebufferSize();
×
323
        for(uint i = 256;i<=qMin(16384u,maxResolution);i*=2)
×
324
        {
325
                cb->addItem(QString::number(i),i);
×
326
        }
327

328
        cb->blockSignals(oldval);
×
329
}
×
330

331
void Scenery3dDialog::on_comboBoxCubemapSize_currentIndexChanged(int index)
×
332
{
333
        Q_UNUSED(index)
334
        bool ok;
335
        uint val = ui->comboBoxCubemapSize->currentData().toUInt(&ok);
×
336
        if(ok)
×
337
        {
338
                mgr->setCubemapSize(val);
×
339
        }
340
}
×
341

342
void Scenery3dDialog::on_comboBoxShadowmapSize_currentIndexChanged(int index)
×
343
{
344
        Q_UNUSED(index)
345
        bool ok;
346
        uint val = ui->comboBoxShadowmapSize->currentData().toUInt(&ok);
×
347
        if(ok)
×
348
        {
349
                mgr->setShadowmapSize(val);
×
350
        }
351
}
×
352

353
void Scenery3dDialog::on_comboBoxShadowFiltering_currentIndexChanged(int index)
×
354
{
355
        qDebug()<<index;
×
356
        mgr->setShadowFilterQuality(static_cast<S3DEnum::ShadowFilterQuality>(index));
×
357
}
×
358

359
void Scenery3dDialog::on_comboBoxCubemapMode_currentIndexChanged(int index)
×
360
{
361
        mgr->setCubemappingMode(static_cast<S3DEnum::CubemappingMode>(index));
×
362
}
×
363

364
void Scenery3dDialog::on_sliderTorchStrength_valueChanged(int value)
×
365
{
366
        float val =  (static_cast<float>(value))  / ui->sliderTorchStrength->maximum();
×
367
        mgr->setTorchStrength(val);
×
368
}
×
369

370
void Scenery3dDialog::on_sliderTorchRange_valueChanged(int value)
×
371
{
372
        float val = value / 100.0f;
×
373
        mgr->setTorchRange(val);
×
374
}
×
375

376
void Scenery3dDialog::updateCurrentScene(const SceneInfo &sceneInfo)
×
377
{
378
        if(sceneInfo.isValid)
×
379
        {
380
                ui->scenery3dListWidget->blockSignals(true);
×
381
                QList<QListWidgetItem*> currentItems = ui->scenery3dListWidget->findItems(sceneInfo.name, Qt::MatchExactly);
×
382
                if(currentItems.size()>0)
×
383
                {
384
                        ui->scenery3dListWidget->setCurrentItem(currentItems.at(0));
×
385
                }
386
                ui->scenery3dListWidget->blockSignals(false);
×
387
                updateTextBrowser(sceneInfo);
×
388

389
                ui->checkBoxDefaultScene->blockSignals(true);
×
390
                ui->checkBoxDefaultScene->setVisible(true);
×
391
                ui->pushButtonOpenStoredViewDialog->setVisible(true);
×
392
                ui->checkBoxDefaultScene->setChecked(sceneInfo.id == mgr->getDefaultScenery3dID());
×
393
                ui->checkBoxDefaultScene->blockSignals(false);
×
394
        }
×
395
}
×
396

397
void Scenery3dDialog::on_checkBoxDefaultScene_stateChanged(int value)
×
398
{
399
        QList<QListWidgetItem*> sel = ui->scenery3dListWidget->selectedItems();
×
400
        if(sel.size()==0)
×
401
                return;
×
402

403
        if(value)
×
404
        {
405
                QString id = SceneInfo::getIDFromName(sel.at(0)->data(Qt::UserRole).toString());
×
406
                if(!id.isEmpty())
×
407
                        mgr->setDefaultScenery3dID(id);
×
408
        }
×
409
        else
410
                mgr->setDefaultScenery3dID("");
×
411
}
×
412

413
void Scenery3dDialog::scenery3dChanged(QListWidgetItem* item)
×
414
{
415
        SceneInfo info = mgr->loadScenery3dByName(item->data(Qt::UserRole).toString());
×
416

417
        if(info.isValid) //this if makes sure the .ini has been loaded
×
418
        {
419
                ui->checkBoxDefaultScene->blockSignals(true);
×
420
                ui->checkBoxDefaultScene->setChecked(info.id == mgr->getDefaultScenery3dID());
×
421
                ui->checkBoxDefaultScene->blockSignals(false);
×
422

423
                updateTextBrowser(info);
×
424
                ui->checkBoxDefaultScene->setVisible(true);
×
425
        }
426
        else
427
        {
428
                ui->pushButtonOpenStoredViewDialog->setVisible(false);
×
429
                ui->checkBoxDefaultScene->setVisible(false);
×
430
                ui->checkBoxDefaultScene->setChecked(false);
×
431
        }
432
}
×
433

434
void Scenery3dDialog::updateTextBrowser(const SceneInfo &si)
×
435
{
436
        if(!si.isValid)
×
437
        {
438
                ui->scenery3dTextBrowser->setHtml("");
×
439
                ui->scenery3dTextBrowser->setSearchPaths(QStringList());
×
440
        }
441
        else
442
        {
443
                QStringList list;
×
444
                list<<si.fullPath;
×
445
                ui->scenery3dTextBrowser->setSearchPaths(list);
×
446

447
                //first, try to find a localized description
448
                QString desc = si.getLocalizedHTMLDescription();
×
449
                if(desc.isEmpty())
×
450
                {
451
                        //use the "old" way to create an description from data contained in the .ini
452
                        desc = QString("<h3>%1</h3>").arg(si.name);
×
453
                        desc+= si.description;
×
454
                        desc+="<br><br>";
×
455
                        desc+="<b>"+q_("Author")+":</b>";
×
456
                        desc+= si.author;
×
457
                }
458

459
                ui->scenery3dTextBrowser->setHtml(desc);
×
460
        }
×
461
}
×
462

463
void Scenery3dDialog::setResolutionCombobox(QComboBox *cb, uint val)
×
464
{
465
        cb->blockSignals(true);
×
466
        int idx = cb->findData(val);
×
467
        if(idx>=0)
×
468
        {
469
                //valid entry
470
                cb->setCurrentIndex(idx);
×
471
        }
472
        else
473
        {
474
                //add entry for the current value, making sure it is at first place
475
                cb->clear();
×
476
                cb->addItem(QString::number(val),val);
×
477
                initResolutionCombobox(cb);
×
478
                cb->setCurrentIndex(0);
×
479
        }
480
        cb->blockSignals(false);
×
481
}
×
482

483
void Scenery3dDialog::updateShadowFilterQuality(S3DEnum::ShadowFilterQuality quality)
×
484
{
485
        ui->checkBoxPCSS->setEnabled(quality == S3DEnum::SFQ_HIGH || quality == S3DEnum::SFQ_LOW);
×
486
        ui->comboBoxShadowFiltering->setCurrentIndex(quality);
×
487
}
×
488

489
void Scenery3dDialog::updateTorchRange(float val)
×
490
{
491
        ui->sliderTorchRange->blockSignals(true);
×
492
        ui->sliderTorchRange->setValue(static_cast<int>(val * 100.0f));
×
493
        ui->sliderTorchRange->blockSignals(false);
×
494
}
×
495

496
void Scenery3dDialog::updateTorchStrength(float val)
×
497
{
498
        ui->sliderTorchStrength->blockSignals(true);
×
499
        ui->sliderTorchStrength->setValue(static_cast<int>(val * 100.0f));
×
500
        ui->sliderTorchStrength->blockSignals(false);
×
501
}
×
502

503
void Scenery3dDialog::updateLazyDrawingInterval(double val)
×
504
{
505
        ui->spinLazyDrawingInterval->blockSignals(true);
×
506
        ui->spinLazyDrawingInterval->setValue(val);
×
507
        ui->spinLazyDrawingInterval->blockSignals(false);
×
508
}
×
509

510
void Scenery3dDialog::updateSecondDominantFaceEnabled()
×
511
{
512
        ui->checkBoxSecondDominantFace->setEnabled(mgr->getOnlyDominantFaceWhenMoving() && mgr->getEnableLazyDrawing());
×
513
}
×
514

515
// Update the widget to make sure it is synchrone if a value was changed programmatically
516
void Scenery3dDialog::setToInitialValues()
×
517
{
518
        bool pix = mgr->getEnablePixelLighting();
×
519
        //ui->checkBoxEnablePixelLight->setChecked(pix);
520

521
        //ui->checkBoxEnableBump->setChecked(mgr->getEnableBumps());
522
        ui->checkBoxEnableBump->setEnabled(pix);
×
523
        //ui->checkBoxEnableShadows->setChecked(mgr->getEnableShadows());
524
        ui->checkBoxEnableShadows->setEnabled(pix);
×
525
        //ui->checkBoxPCSS->setChecked(mgr->getEnablePCSS());
526

527
        ui->checkBoxSimpleShadows->setEnabled(mgr->getEnableShadows());
×
528
        ui->checkBoxCubemapShadows->setEnabled(mgr->getEnableShadows());
×
529
        //ui->checkBoxSimpleShadows->setChecked(mgr->getUseSimpleShadows());
530
        //ui->checkBoxCubemapShadows->setChecked(mgr->getUseFullCubemapShadows());
531

532
        updateShadowFilterQuality(mgr->getShadowFilterQuality());
×
533

534
        ui->comboBoxCubemapMode->setCurrentIndex(mgr->getCubemappingMode());
×
535

536
        updateTorchStrength(mgr->getTorchStrength());
×
537
        updateTorchRange(mgr->getTorchRange());
×
538

539
        bool lazy = mgr->getEnableLazyDrawing();
×
540
        //ui->checkBoxEnableLazyDrawing->setChecked(val);
541

542
        //ui->checkBoxDominantFace->setChecked(mgr->getOnlyDominantFaceWhenMoving());
543
        updateSecondDominantFaceEnabled();
×
544
        //ui->checkBoxSecondDominantFace->setChecked(mgr->getSecondDominantFaceWhenMoving());
545

546
        ui->labelLazyDrawingInterval->setEnabled(lazy);
×
547
        ui->spinLazyDrawingInterval->setEnabled(lazy);
×
548
        ui->checkBoxDominantFace->setEnabled(lazy);
×
549

550
        updateLazyDrawingInterval(mgr->getLazyDrawingInterval());
×
551

552
        setResolutionCombobox(ui->comboBoxCubemapSize,mgr->getCubemapSize());
×
553
        setResolutionCombobox(ui->comboBoxShadowmapSize,mgr->getShadowmapSize());
×
554

555
        //hide some stuff depending on hardware support
556
        if(!mgr->getIsShadowFilteringSupported())
×
557
        {
558
                ui->labelFilterQuality->setVisible(false);
×
559
                ui->comboBoxShadowFiltering->setVisible(false);
×
560
                ui->checkBoxPCSS->setVisible(false);
×
561
        }
562

563
        if(!mgr->getAreShadowsSupported())
×
564
        {
565
                ui->labelShadowmapSize->setVisible(false);
×
566
                ui->comboBoxShadowmapSize->setVisible(false);
×
567
                ui->checkBoxEnableShadows->setVisible(false);
×
568
                ui->checkBoxCubemapShadows->setVisible(false);
×
569
                ui->checkBoxSimpleShadows->setVisible(false);
×
570
        }
571
}
×
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