OGS
VisPrefsDialog.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "VisPrefsDialog.h"
5
6#include <QDoubleValidator>
7#include <QLineEdit>
8#include <QSettings>
9#include <QVariant>
10
11#include "VisualizationWidget.h"
12#include "VtkVisPipeline.h"
13
16 VisualizationWidget& widget,
17 QDialog* parent)
18 : QDialog(parent),
19 _vtkVisPipeline(pipeline),
20 _visWidget(widget),
21 _above(0, 0, 2000000),
22 _below(0, 0, -2000000)
23{
24 setupUi(this);
25 if (_vtkVisPipeline.getLight(_above))
26 {
27 lightAboveBox->toggle();
28 }
29 if (_vtkVisPipeline.getLight(_below))
30 {
31 lightBelowBox->toggle();
32 }
33
34 bgColorButton->setColor(_vtkVisPipeline.getBGColor());
35
36 QValidator* validator = new QDoubleValidator(0, 100000, 2, this);
37 superelevationLineEdit->setValidator(validator);
38 QSettings settings;
39 superelevationLineEdit->setText(
40 settings.value("globalSuperelevation", 1.0).toString());
41 cullBackfacesCheckBox->setCheckState(
42 Qt::CheckState(settings.value("globalCullBackfaces", 0).toInt()));
43 loadShowAllCheckBox->setCheckState(
44 Qt::CheckState(settings.value("resetViewOnLoad", 2).toInt()));
45}
46
48{
49 QColor bgColor(color.red(), color.green(), color.blue());
50 _vtkVisPipeline.setBGColor(bgColor);
51}
52
54{
55 if (lightAboveBox->isChecked())
56 {
57 _vtkVisPipeline.addLight(_above);
58 }
59 else
60 {
61 _vtkVisPipeline.removeLight(_above);
62 }
63}
64
66{
67 if (lightBelowBox->isChecked())
68 {
69 _vtkVisPipeline.addLight(_below);
70 }
71 else
72 {
73 _vtkVisPipeline.removeLight(_below);
74 }
75}
76
78{
79 double factor = superelevationLineEdit->text().toDouble();
80 _vtkVisPipeline.setGlobalSuperelevation(factor);
81
82 QSettings settings;
83 settings.setValue("globalSuperelevation", factor);
84}
85
87{
88 _visWidget.setShowAllOnLoad(static_cast<bool>(state));
89 _vtkVisPipeline.resetCameraOnAddOrRemove(static_cast<bool>(state));
90
91 QSettings settings;
92 settings.setValue("resetViewOnLoad", state);
93}
94
96{
97 _vtkVisPipeline.setGlobalBackfaceCulling(static_cast<bool>(state));
98
99 QSettings settings;
100 settings.setValue("globalCullBackfaces", state);
101}
void on_bgColorButton_colorPicked(QColor color)
Sets the background colour.
VtkVisPipeline & _vtkVisPipeline
void on_superelevationPushButton_pressed()
Sets the given superelevation on all vis pipeline source objects.
void on_loadShowAllCheckBox_stateChanged(int state)
void on_lightAboveBox_clicked()
Adds a light above the scene.
VisPrefsDialog(VtkVisPipeline &pipeline, VisualizationWidget &widget, QDialog *parent=nullptr)
Constructor.
void on_cullBackfacesCheckBox_stateChanged(int state)
Culls backfacing rendering primitives on all actors.
GeoLib::Point _above
GeoLib::Point _below
void on_lightBelowBox_clicked()
Adds a light below the scene.
VisualizationWidget & _visWidget
Widget containing the 3d VTK scene view.
VtkVisPipeline manages the VTK visualization. It is a TreeModel and provides functions for adding and...