Skip to content

Commit

Permalink
updated automatic update of constraints
Browse files Browse the repository at this point in the history
Signed-off-by: kantundpeterpan <[email protected]>
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
kantundpeterpan authored and ghutchis committed Mar 11, 2022
1 parent 8be3045 commit 33e9693
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
1 change: 0 additions & 1 deletion avogadro/qtplugins/constraints/.#constraintsdialog.cpp

This file was deleted.

32 changes: 16 additions & 16 deletions avogadro/qtplugins/constraints/constraintsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,31 @@ namespace Avogadro {
{
m_plugin->m_molecule->atom(i).setSelected(false);
}
// get currently selected constraint
QModelIndex idx = ui->ConstraintsTableView->selectionModel()->currentIndex();
// extract constraint from ConstraintModel
QtPlugins::Constraint* c = &m_plugin->m_molecule->constraints->ConstraintsList[idx.row()];
// iterate over involved uniqueAtomIDs
for (int i = 0; i < c->Atoms.size(); i++)
if (m_plugin->m_molecule->constraints->ConstraintsList.size()>0)
{
// get atom by uniqueID and set selected
m_plugin->m_molecule->atomByUniqueId(c->Atoms[i]).setSelected(true);
qDebug() << "Set selected";
// get currently selected constraint
QModelIndex idx = ui->ConstraintsTableView->selectionModel()->currentIndex();
// extract selected constraint from ConstraintModel
QtPlugins::Constraint* c = &m_plugin->m_molecule->constraints->ConstraintsList[idx.row()];
// iterate over involved uniqueAtomIDs
for (int i = 0; i < c->Atoms.size(); i++)
{
// get atom by uniqueID and set selected
m_plugin->m_molecule->atomByUniqueId(c->Atoms[i]).setSelected(true);
qDebug() << "Set selected";
}
//emit molecule changes
m_plugin->m_molecule->emitChanged(Molecule::Atoms);
}
m_plugin->m_molecule->emitChanged(Molecule::Atoms);
}
}

void ConstraintsDialog::setModel()
{
ui->ConstraintsTableView->setModel(m_plugin->m_molecule->constraints);
connectHighlight(ui->checkHighlight->checkState());
connect( m_plugin->m_molecule, SIGNAL( changed(unsigned int)),
m_plugin->m_molecule->constraints, SLOT (emitDataChanged()));
/*
connect( ui->ConstraintsTableView, SIGNAL( selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected)),
this, SLOT(highlightSelected()));
*/
}

void ConstraintsDialog::acceptConstraints()
Expand Down Expand Up @@ -123,7 +123,7 @@ namespace Avogadro {
void ConstraintsDialog::deleteAllConstraints()
{
m_plugin->m_molecule->constraints->clear();
this->update();
// this->update();
}

}
Expand Down
5 changes: 3 additions & 2 deletions avogadro/qtplugins/constraints/constraintsextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ namespace Avogadro {
if (mol != m_molecule)
{
m_molecule = mol;
dialog->setModel();
dialog->connectHighlight(0);
// dialog->connectHighlight(0);
}

if (!m_molecule->constraints)
{
m_molecule->constraints = new ConstraintsModel(m_molecule);
}
dialog->setModel();
}

bool ConstraintsExtension::readMolecule(QtGui::Molecule& mol){
Expand Down

0 comments on commit 33e9693

Please sign in to comment.