1 /**
2 * Mandelbulber v2, a 3D fractal generator ,=#MKNmMMKmmßMNWy,
3 * ,B" ]L,,p%%%,,,§;, "K
4 * Copyright (C) 2016-21 Mandelbulber Team §R-==%w["'~5]m%=L.=~5N
5 * ,=mm=§M ]=4 yJKA"/-Nsaj "Bw,==,,
6 * This file is part of Mandelbulber. §R.r= jw",M Km .mM FW ",§=ß., ,TN
7 * ,4R =%["w[N=7]J '"5=],""]]M,w,-; T=]M
8 * Mandelbulber is free software: §R.ß~-Q/M=,=5"v"]=Qf,'§"M= =,M.§ Rz]M"Kw
9 * you can redistribute it and/or §w "xDY.J ' -"m=====WeC=\ ""%""y=%"]"" §
10 * modify it under the terms of the "§M=M =D=4"N #"%==A%p M§ M6 R' #"=~.4M
11 * GNU General Public License as §W =, ][T"]C § § '§ e===~ U !§[Z ]N
12 * published by the 4M",,Jm=,"=e~ § § j]]""N BmM"py=ßM
13 * Free Software Foundation, ]§ T,M=& 'YmMMpM9MMM%=w=,,=MT]M m§;'§,
14 * either version 3 of the License, TWw [.j"5=~N[=§%=%W,T ]R,"=="Y[LFT ]N
15 * or (at your option) TW=,-#"%=;[ =Q:["V"" ],,M.m == ]N
16 * any later version. J§"mr"] ,=,," =="""J]= M"M"]==ß"
17 * §= "=C=4 §"eM "=B:m|4"]#F,§~
18 * Mandelbulber is distributed in "9w=,,]w em%wJ '"~" ,=,,ß"
19 * the hope that it will be useful, . "K= ,=RMMMßM"""
20 * but WITHOUT ANY WARRANTY; .'''
21 * without even the implied warranty
22 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 *
24 * See the GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with Mandelbulber. If not, see <http://www.gnu.org/licenses/>.
27 *
28 * ###########################################################################
29 *
30 * Authors: Krzysztof Marczak (buddhi1980@gmail.com)
31 *
32 * Widget which contains UI for effects
33 */
34
35 #include "dock_effects.h"
36
37 #include "ui_dock_effects.h"
38
39 #include "dock_image_adjustments.h"
40
41 #include "src/ao_modes.h"
42 #include "src/automated_widgets.hpp"
43 #include "src/initparameters.hpp"
44 #include "src/interface.hpp"
45 #include "src/random.hpp"
46 #include "src/render_window.hpp"
47 #include "src/rendered_image_widget.hpp"
48 #include "src/synchronize_interface.hpp"
49 #include "src/system_data.hpp"
50
cDockEffects(QWidget * parent)51 cDockEffects::cDockEffects(QWidget *parent) : QWidget(parent), ui(new Ui::cDockEffects)
52 {
53 ui->setupUi(this);
54
55 automatedWidgets = new cAutomatedWidgets(this);
56 automatedWidgets->ConnectSignalsForSlidersInWindow(this);
57 ConnectSignals();
58 }
59
~cDockEffects()60 cDockEffects::~cDockEffects()
61 {
62 delete ui;
63 }
64
ConnectSignals() const65 void cDockEffects::ConnectSignals() const
66 {
67 connect(ui->button_calculateFog, SIGNAL(clicked()), this, SLOT(slotPressedButtonAutoFog()));
68
69 connect(ui->comboBox_ambient_occlusion_mode, SIGNAL(currentIndexChanged(int)), this,
70 SLOT(slotChangedComboAmbientOcclusionMode(int)));
71
72 connect(ui->logedit_aux_light_manual_placement_dist, SIGNAL(textChanged(const QString &)), this,
73 SLOT(slotEditedLineEditManualLightPlacementDistance(const QString &)));
74
75 connect(
76 ui->pushButton_DOF_set_focus, SIGNAL(clicked()), this, SLOT(slotPressedButtonSetDOFByMouse()));
77 connect(
78 ui->pushButton_DOF_update, SIGNAL(clicked()), this, SLOT(slotPressedButtonUpdatePostEffects()));
79 connect(ui->pushButton_post_effects_update, SIGNAL(clicked()), this,
80 SLOT(slotPressedButtonUpdatePostEffects()));
81
82 connect(ui->pushButton_set_fog_by_mouse, SIGNAL(clicked()), this,
83 SLOT(slotPressedButtonSetFogByMouse()));
84 connect(ui->pushButton_place_random_lights_by_mouse, SIGNAL(clicked()), this,
85 SLOT(slotPressedButtonPlaceRandomLightsByMouse()));
86
87 connect(ui->checkBox_aux_light_place_behind, SIGNAL(stateChanged(int)), this,
88 SLOT(slotChangedPlaceLightBehindObjects(int)));
89
90 connect(ui->groupCheck_DOF_monte_carlo, SIGNAL(toggled(bool)), this,
91 SLOT(slotChangedEnableMCDOF(bool)));
92 connect(ui->checkBox_DOF_MC_global_illumination, SIGNAL(stateChanged(int)), this,
93 SLOT(slotChangedEnableGI(int)));
94
95 connect(ui->pushButton_clouds_randomize, &QPushButton::clicked, this,
96 &cDockEffects::slotPressedButtonCloudsRandomize);
97
98 connect(ui->widget_light_sources_manager,
99 &cLightSourcesManager::signalChangeLightPlacementDistance, this,
100 &cDockEffects::slotSetAuxLightManualPlacementDistance);
101 }
102
SynchronizeInterfaceBasicFogEnabled(std::shared_ptr<cParameterContainer> par) const103 void cDockEffects::SynchronizeInterfaceBasicFogEnabled(
104 std::shared_ptr<cParameterContainer> par) const
105 {
106 SynchronizeInterfaceWindow(ui->groupCheck_basic_fog_enabled, par, qInterface::write);
107 }
108
SynchronizeInterfaceDOFEnabled(std::shared_ptr<cParameterContainer> par) const109 void cDockEffects::SynchronizeInterfaceDOFEnabled(std::shared_ptr<cParameterContainer> par) const
110 {
111 SynchronizeInterfaceWindow(ui->groupCheck_DOF_enabled, par, qInterface::write);
112 }
113
SynchronizeInterfaceLights(std::shared_ptr<cParameterContainer> par) const114 void cDockEffects::SynchronizeInterfaceLights(std::shared_ptr<cParameterContainer> par) const
115 {
116 SynchronizeInterfaceWindow(ui->widget_light_sources_manager, par, qInterface::write);
117 }
118
SynchronizeInterfaceRandomLights(std::shared_ptr<cParameterContainer> par) const119 void cDockEffects::SynchronizeInterfaceRandomLights(std::shared_ptr<cParameterContainer> par) const
120 {
121 SynchronizeInterfaceWindow(ui->groupCheck_random_lights_group, par, qInterface::write);
122 }
123
GetAuxLightManualPlacementDistance() const124 double cDockEffects::GetAuxLightManualPlacementDistance() const
125 {
126 return systemData.locale.toDouble(ui->logedit_aux_light_manual_placement_dist->text());
127 }
128
slotSetAuxLightManualPlacementDistance(double dist) const129 void cDockEffects::slotSetAuxLightManualPlacementDistance(double dist) const
130 {
131 ui->logedit_aux_light_manual_placement_dist->setText(QString("%L1").arg(dist));
132 }
133
slotEditedLineEditManualLightPlacementDistance(const QString & text)134 void cDockEffects::slotEditedLineEditManualLightPlacementDistance(const QString &text)
135 {
136 gMainInterface->renderedImage->SetFrontDist(systemData.locale.toDouble(text));
137 }
138
slotChangedPlaceLightBehindObjects(int state)139 void cDockEffects::slotChangedPlaceLightBehindObjects(int state)
140 {
141 gMainInterface->renderedImage->SetPlaceBehindObjects(state);
142 }
143
slotChangedComboAmbientOcclusionMode(int index) const144 void cDockEffects::slotChangedComboAmbientOcclusionMode(int index) const
145 {
146 bool enabled = index == params::AOModeMultipleRays ? true : false;
147 ui->frame_lightmap_texture->setEnabled(enabled);
148 enabled = index == params::AOModeFast ? true : false;
149 ui->spinbox_ambient_occlusion_fast_tune->setEnabled(enabled);
150 }
151
slotPressedButtonAutoFog()152 void cDockEffects::slotPressedButtonAutoFog()
153 {
154 gMainInterface->AutoFog();
155 }
156
slotPressedButtonUpdatePostEffects()157 void cDockEffects::slotPressedButtonUpdatePostEffects()
158 {
159 gMainInterface->RefreshPostEffects();
160 }
161
slotPressedButtonSetDOFByMouse()162 void cDockEffects::slotPressedButtonSetDOFByMouse()
163 {
164 QList<QVariant> item;
165 item.append(int(RenderedImage::clickDOFFocus));
166 int index = gMainInterface->mainWindow->GetComboBoxMouseClickFunction()->findData(item);
167 gMainInterface->mainWindow->GetComboBoxMouseClickFunction()->setCurrentIndex(index);
168 gMainInterface->renderedImage->setClickMode(item);
169 }
170
slotPressedButtonSetFogByMouse()171 void cDockEffects::slotPressedButtonSetFogByMouse()
172 {
173 QList<QVariant> item;
174 item.append(int(RenderedImage::clickFogVisibility));
175 int index = gMainInterface->mainWindow->GetComboBoxMouseClickFunction()->findData(item);
176 gMainInterface->mainWindow->GetComboBoxMouseClickFunction()->setCurrentIndex(index);
177 gMainInterface->renderedImage->setClickMode(item);
178 }
179
slotPressedButtonPlaceRandomLightsByMouse()180 void cDockEffects::slotPressedButtonPlaceRandomLightsByMouse()
181 {
182 QList<QVariant> item;
183 item.append(int(RenderedImage::clickPlaceRandomLightCenter));
184 int index = gMainInterface->mainWindow->GetComboBoxMouseClickFunction()->findData(item);
185 gMainInterface->mainWindow->GetComboBoxMouseClickFunction()->setCurrentIndex(index);
186 gMainInterface->renderedImage->setClickMode(item);
187 }
188
UpdateLabelAverageDOFSamples(const QString & avg)189 void cDockEffects::UpdateLabelAverageDOFSamples(const QString &avg)
190 {
191 ui->label_average_DOF_samples->setText(avg);
192 }
193
UpdateLabelAverageDOFNoise(const QString & avg)194 void cDockEffects::UpdateLabelAverageDOFNoise(const QString &avg)
195 {
196 ui->label_average_DOF_noise->setText(avg);
197 }
198
slotChangedEnableMCDOF(bool state)199 void cDockEffects::slotChangedEnableMCDOF(bool state)
200 {
201 if (state)
202 {
203 params::enumAOMode AOMode =
204 params::enumAOMode(ui->comboBox_ambient_occlusion_mode->currentIndex());
205 if (AOMode == params::AOModeScreenSpace)
206 {
207 ui->groupCheck_ambient_occlusion_enabled->setChecked(false);
208 }
209 }
210 }
211
slotChangedEnableGI(int state)212 void cDockEffects::slotChangedEnableGI(int state)
213 {
214 ui->checkBox_MC_global_illumination_volumetric->setEnabled(state);
215 }
216
slotPressedButtonCloudsRandomize()217 void cDockEffects::slotPressedButtonCloudsRandomize()
218 {
219 cRandom random;
220 random.Initialize(QTime::currentTime().msec());
221 int rnd = random.Random(100000);
222 ui->spinboxInt_clouds_random_seed->setValue(rnd);
223 }
224
RegenerateLights()225 void cDockEffects::RegenerateLights()
226 {
227 ui->widget_light_sources_manager->Regenerate();
228 }
229