Commit 8d7af489 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Correctly set and update rendering plugins

parent ac81d6b1
......@@ -92,8 +92,10 @@ MoleculeDialog::MoleculeDialog(QWidget * parent)
m_drawSettings->setValue("bondOrder", 1);
m_drawSettings->setValue("addHydrogens", 0);
ui.styleCombo->setModel(
qobject_cast<QAbstractItemModel*>(&ui.glWidget->sceneModel()));
ui.styleCombo->addItems({"Wireframe", "Ball and Stick", "Van der Waals"});
slotUpdateScenePlugin();
connect(ui.styleCombo, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
this, &MoleculeDialog::slotUpdateScenePlugin);
connect(ui.tabWidget, &QTabWidget::currentChanged,
this, &MoleculeDialog::setViewEdit);
......@@ -163,6 +165,18 @@ void MoleculeDialog::slotLoadMolecule()
loadMolecule(filename);
}
void MoleculeDialog::slotUpdateScenePlugin() {
const QString text = ui.styleCombo->currentText();
for (int i = 0; i < ui.glWidget->sceneModel().rowCount(QModelIndex()); ++i) {
QModelIndex index = ui.glWidget->sceneModel().index(i, 0);
if (text == ui.glWidget->sceneModel().data(index, Qt::DisplayRole)) {
ui.glWidget->sceneModel().setData(index, Qt::Checked, Qt::CheckStateRole);
} else {
ui.glWidget->sceneModel().setData(index, Qt::Unchecked, Qt::CheckStateRole);
}
}
}
void MoleculeDialog::loadMolecule(const QString &filename)
{
if (filename.isEmpty()) {
......@@ -191,7 +205,7 @@ void MoleculeDialog::loadMolecule(const QString &filename)
this, &MoleculeDialog::slotUpdateStatistics);
}
ui.glWidget->resetCamera();
ui.glWidget->update();
ui.glWidget->updateScene();
}
void MoleculeDialog::clearAllElementsInEditor()
......
......@@ -66,6 +66,11 @@ private slots:
*/
void slotLoadMolecule();
/**
* Update the currently active scene plugin.
*/
void slotUpdateScenePlugin();
/**
* Get a new molecule using hot new stuff
*/
......
......@@ -45,20 +45,7 @@
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="KComboBox" name="styleCombo"/>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QComboBox" name="styleCombo"/>
</item>
</layout>
</item>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment