1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/VIEW/DIALOGS/bondProperties.h>
#include <BALL/VIEW/WIDGETS/molecularControl.h>
#include <BALL/KERNEL/bond.h>
#include <BALL/KERNEL/residue.h>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
namespace BALL
{
namespace VIEW
{
BondProperties::BondProperties( Atom* atom, QWidget* parent, const char* name, bool, Qt::WindowFlags fl )
: QDialog(parent, fl),
Ui_BondPropertiesData(),
atom_(atom)
{
setupUi(this);
setObjectName(name);
if (atom->countBonds() == 0)
{
((ModularWidget*)parent)->setStatusbarText((String)tr("Atom has no bonds"));
return;
}
parent_ = parent;
String text;
if (atom_->getParent() != 0 &&
RTTI::isKindOf<Residue>(atom_->getParent()))
{
text = ((Residue*) atom_->getParent())->getID();
}
text += atom_->getFullName();
atom_edit->setText(text.c_str());
bond_box->clear();
for (Position pos = 0; pos < atom_->countBonds(); pos++)
{
bond_box->addItem((String(pos + 1) + String(" . Bond")).c_str());
}
bondSelected();
}
BondProperties::~BondProperties()
{
// no need to delete child widgets, Qt does it all for us
}
void BondProperties::bondSelected()
{
if (bond_box->currentIndex() == -1)
{
name_edit->clear();
partner_edit->clear();
order_edit->clear();
type_edit->clear();
length_edit->clear();
return;
}
Bond* bond = atom_->getBond(bond_box->currentIndex());
name_edit->setText(bond->getName().c_str());
String text;
Atom* partner = bond->getPartner(*atom_);
if (partner->getParent() != 0 &&
RTTI::isKindOf<Residue>(partner->getParent()))
{
text = ((Residue*) partner->getParent())->getID();
}
text += partner->getFullName();
partner_edit->setText(text.c_str());
Vector3 v = atom_->getPosition() - bond->getPartner(*atom_)->getPosition();
length_edit->setText((String(v.getLength()) + " A").c_str());
switch(bond->getOrder())
{
case Bond::ORDER__UNKNOWN:
text = (String)tr("Unknown");
break;
case Bond::ORDER__SINGLE:
text = (String)tr("Single");
break;
case Bond::ORDER__DOUBLE:
text = (String)tr("Double");
break;
case Bond::ORDER__TRIPLE:
text = (String)tr("Triple");
break;
case Bond::ORDER__QUADRUPLE:
text = (String)tr("Quadruple");
break;
case Bond::ORDER__AROMATIC:
text = (String)tr("Aromatic");
break;
case Bond::ORDER__ANY:
text = (String)tr("Any");
break;
}
order_edit->setText(text.c_str());
switch (bond->getType())
{
case Bond::TYPE__UNKNOWN:
text = (String)tr("Unknown");
break;
case Bond::TYPE__COVALENT:
text = (String)tr("Covalent");
break;
case Bond::TYPE__HYDROGEN:
text = (String)tr("Hydrogen");
break;
case Bond::TYPE__DISULPHIDE_BRIDGE:
text = (String)tr("Disulphide Bridge");
break;
case Bond::TYPE__SALT_BRIDGE:
text = (String)tr("Salt Bridge");
break;
case Bond::TYPE__PEPTIDE:
text = (String)tr("Peptide");
break;
}
type_edit->setText(text.c_str());
}
void BondProperties::focusAtom()
{
if (!RTTI::isKindOf<MolecularControl>(parent_) ||
bond_box->currentIndex() == -1)
{
return;
}
MolecularControl& mc = *(MolecularControl*) parent_;
list<Composite*> list;
list.push_back(atom_);
mc.highlight(list);
if (atom_->isSelected()) mc.deselect();
else mc.select();
mc.context_composite_ = atom_;
mc.centerCamera();
}
void BondProperties::focusPartner()
{
if (!RTTI::isKindOf<MolecularControl>(parent_) ||
bond_box->currentIndex() == -1)
{
return;
}
Atom* partner = atom_->getBond(bond_box->currentIndex())->getPartner(*atom_);
MolecularControl& mc = *(MolecularControl*) parent_;
list<Composite*> list;
list.push_back(partner);
mc.highlight(list);
if (partner->isSelected()) mc.deselect();
else mc.select();
mc.context_composite_ = partner;
mc.centerCamera();
}
}
}
|