3 #include "MainWindow.hpp"
6 #include <QCoreApplication>
10 #include <QDockWidget>
20 MainWindow_ui.setupUi(
this);
29 _GLWidget =
new Widget(
this);
32 QHBoxLayout *layout =
new QHBoxLayout;
33 layout->addWidget(_GLWidget);
34 MainWindow_ui.centralwidget->setLayout(layout);
36 QWidget * settingsWidget =
new QWidget(
this);
40 _settings_ui.setupUi(settingsWidget);
41 _settings_ui.FileLabel->setText(
"Open Molecule Data: File => Load Molecule");
42 _settings_ui.PointIntensitySlider->setRange(0,255);
43 _settings_ui.GlossinessSlider->setRange(0,255);
44 _settings_ui.AmbientIntensitySlider->setRange(0,255);
45 _settings_ui.BorderVarianceSlider->setRange(0,255);
46 _settings_ui.BorderWidthSlider->setRange(0,255);
48 connect(_settings_ui.PresetComboBox, SIGNAL(currentTextChanged(QString)),
this, SLOT(
PresetChanged(QString)));
49 connect(_settings_ui.PointIntensitySlider, SIGNAL(valueChanged(
int)),
this, SLOT(
PointIntensityChanged(
int)));
50 connect(_settings_ui.GlossinessSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
GlossinessChanged(
int)));
51 connect(_settings_ui.ShadowCheckBox, SIGNAL(stateChanged(
int)),
this, SLOT(
ShadowChanged(
int)));
52 connect(_settings_ui.AmbientOcclusionRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(
AmbientOcclusionChanged(
bool)));
53 connect(_settings_ui.AmbientIntensitySlider, SIGNAL(valueChanged(
int)),
this, SLOT(
AmbientIntensityChanged(
int)));
54 connect(_settings_ui.BorderWidthSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
BorderWidthChanged(
int)));
55 connect(_settings_ui.BorderVarianceSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
BorderVarianceChanged(
int)));
56 connect(_settings_ui.ColorComboBox, SIGNAL(currentTextChanged(QString)),
this, SLOT(ColorModeChanged(QString)));
57 connect(_settings_ui.OcclusionPresetBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(OcclusionQualityChanged(
int)));
58 layout->addWidget(settingsWidget);
59 settingsWidget->setFixedWidth(245);
60 setMinimumHeight(610);
65 OcclusionQualityChanged(2);
77 _settings_ui.FileLabel->setText(
"Loading PDB File...");
79 QString filename = QFileDialog::getOpenFileName(
this,
"Load molecule data", QString(),
"Protein Data Bank (*.pdb);;All files (*)");
80 if (filename.isNull())
82 string file = filename.toStdString();
84 std::ifstream in(file.c_str());
86 _settings_ui.FileLabel->setText(
"Could not load valid PDB file.");
91 _settings_ui.FileLabel->setText(
"Could not load valid PDB file.");
95 _settings_ui.FileLabel->setText(QString::fromStdString(file.substr(file.find_last_of(
"/")+1)));
115 _pointLightIntensity = changedValue;
117 _settings_ui.PresetComboBox->setCurrentIndex(0);
118 _GLWidget->updateGL();
121 _glossiness = changedValue;
123 _settings_ui.PresetComboBox->setCurrentIndex(0);
124 _GLWidget->updateGL();
132 _settings_ui.PresetComboBox->setCurrentIndex(0);
133 _GLWidget->updateGL();
137 _ambientOcclusionActive =
true;
139 _ambientOcclusionActive =
false;
141 _settings_ui.PresetComboBox->setCurrentIndex(0);
142 _GLWidget->updateGL();
145 _ambientIntensity = changedValue;
147 _settings_ui.PresetComboBox->setCurrentIndex(0);
148 _GLWidget->updateGL();
151 _borderWidth = changedValue;
153 _settings_ui.PresetComboBox->setCurrentIndex(0);
154 _GLWidget->updateGL();
157 _borderVariance = changedValue;
159 _settings_ui.PresetComboBox->setCurrentIndex(0);
160 _GLWidget->updateGL();
163 void MainWindow::ColorModeChanged(
const QString changedValue) {
165 if (changedValue.compare(
"Per Atom")==0) {
167 _GLWidget->updateGL();
168 }
else if (changedValue.compare(
"Per Chain")==0) {
171 _GLWidget->updateGL();
172 }
else if (changedValue.compare(
"No Color")==0) {
175 _GLWidget->updateGL();
181 void MainWindow::OcclusionQualityChanged(
const int changedValue) {
184 _GLWidget->updateGL();
186 _settings_ui.OcclusionPresetBox->setCurrentIndex(changedValue);
192 if (changedValue.compare(
"Combined Lighting")==0) {
194 _ambientOcclusionActive =
true;
196 _ambientIntensity = 100;
197 _pointLightIntensity = 150;
199 _borderVariance = 128;
209 _GLWidget->updateGL();
210 _settings_ui.PresetComboBox->setCurrentText(changedValue);
211 }
else if (changedValue.compare(
"Ambient Occlusion Only")==0) {
213 _ambientOcclusionActive =
true;
214 _ambientIntensity = 230;
215 _pointLightIntensity = 0;
225 _GLWidget->updateGL();
226 _settings_ui.PresetComboBox->setCurrentText(changedValue);
227 }
else if (changedValue.compare(
"Direct Lighting Only")==0) {
229 _ambientOcclusionActive =
false;
231 _ambientIntensity = 64;
232 _pointLightIntensity = 128;
243 _GLWidget->updateGL();
244 _settings_ui.PresetComboBox->setCurrentText(changedValue);
245 }
else if (changedValue.compare(
"Shape Perception")==0) {
247 _ambientOcclusionActive =
true;
248 _pointLightIntensity = 0;
249 _ambientIntensity = 230;
251 _borderVariance = 128;
260 _GLWidget->updateGL();
261 _settings_ui.PresetComboBox->setCurrentText(changedValue);
269 _settings_ui.ShadowCheckBox->setChecked(_shadows);
270 _settings_ui.AmbientOcclusionRadioButton->setChecked(_ambientOcclusionActive);
271 _settings_ui.AmbientConstantRadioButton->setChecked(!_ambientOcclusionActive);
272 _settings_ui.PointIntensitySlider->setValue(_pointLightIntensity);
273 _settings_ui.GlossinessSlider->setValue(_glossiness);
274 _settings_ui.AmbientIntensitySlider->setValue(_ambientIntensity);
275 _settings_ui.BorderVarianceSlider->setValue(_borderWidth);
276 _settings_ui.BorderWidthSlider->setValue(_borderWidth);
277 _settings_ui.ColorComboBox->setCurrentIndex(_colorMode);